Skip to content

Commit

Permalink
fix MesonToolchain quotes (#10707)
Browse files Browse the repository at this point in the history
* conan 1.47.0-dev

* fix MesonToolchain quotes

* merge

* add test

* fix test for multi-platform

Co-authored-by: czoido <[email protected]>
  • Loading branch information
memsharded and czoido authored Mar 3, 2022
1 parent 142235b commit ccc9ff7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
14 changes: 7 additions & 7 deletions conan/tools/meson/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class MesonToolchain(object):
{% if pkgconfig %}pkgconfig = '{{pkgconfig}}'{% endif %}
[built-in options]
{% if buildtype %}buildtype = {{buildtype}}{% endif %}
{% if buildtype %}buildtype = '{{buildtype}}'{% endif %}
{% if debug %}debug = {{debug}}{% endif %}
{% if default_library %}default_library = {{default_library}}{% endif %}
{% if default_library %}default_library = '{{default_library}}'{% endif %}
{% if b_vscrt %}b_vscrt = '{{b_vscrt}}' {% endif %}
{% if b_ndebug %}b_ndebug = {{b_ndebug}}{% endif %}
{% if b_staticpic %}b_staticpic = {{b_staticpic}}{% endif %}
Expand Down Expand Up @@ -206,15 +206,15 @@ def _context(self):
"windres": self.windres,
"pkgconfig": self.pkgconfig,
# https://mesonbuild.com/Builtin-options.html#core-options
"buildtype": to_meson_value(self._buildtype),
"default_library": to_meson_value(self._default_library),
"buildtype": self._buildtype,
"default_library": self._default_library,
"backend": self._backend,
# https://mesonbuild.com/Builtin-options.html#base-options
"b_vscrt": self._b_vscrt,
"b_staticpic": to_meson_value(self._b_staticpic),
"b_ndebug": to_meson_value(self._b_ndebug),
"b_staticpic": to_meson_value(self._b_staticpic), # boolean
"b_ndebug": to_meson_value(self._b_ndebug), # boolean as string
# https://mesonbuild.com/Builtin-options.html#compiler-options
"cpp_std": to_meson_value(self._cpp_std),
"cpp_std": self._cpp_std,
"c_args": to_meson_value(self.c_args.strip().split()),
"c_link_args": to_meson_value(self.c_link_args.strip().split()),
"cpp_args": to_meson_value(self.cpp_args.strip().split()),
Expand Down
22 changes: 22 additions & 0 deletions conans/test/integration/toolchains/meson/test_mesontoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,25 @@ def generate(self):
t.run("install . -pr:h host_prof -pr:b build_prof")
content = t.load(MesonToolchain.cross_filename)
assert expected_args in content


def test_correct_quotes():
profile = textwrap.dedent("""
[settings]
os=Windows
arch=x86_64
compiler=gcc
compiler.version=9
compiler.cppstd=17
compiler.libcxx=libstdc++11
build_type=Release
""")
t = TestClient()
t.save({"conanfile.txt": "[generators]\nMesonToolchain",
"profile": profile})

t.run("install . -pr=profile")
content = t.load(MesonToolchain.native_filename)
assert "cpp_std = 'c++17'" in content
assert "backend = 'ninja'" in content
assert "buildtype = 'release'" in content

0 comments on commit ccc9ff7

Please sign in to comment.