Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix MesonToolchain quotes #10707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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