diff --git a/conan/tools/meson/toolchain.py b/conan/tools/meson/toolchain.py index 188484b6f6d..9ed22b466fe 100644 --- a/conan/tools/meson/toolchain.py +++ b/conan/tools/meson/toolchain.py @@ -181,7 +181,11 @@ def __init__(self, conanfile, backend=None): compilers_by_conf = self._conanfile.conf.get("tools.build:compiler_executables", default={}, check_type=dict) # Read the VirtualBuildEnv to update the variables + # FIXME: This VirtualBuildEnv instance is breaking things!! + # FIXME: It shouldn't be used here, not intended for this use case + prev_status = self._conanfile.virtualbuildenv build_env = VirtualBuildEnv(self._conanfile).vars() + self._conanfile.virtualbuildenv = prev_status #: Defines the Meson ``c`` variable. Defaulted to ``CC`` build environment value self.c = compilers_by_conf.get("c") or build_env.get("CC") or default_comp #: Defines the Meson ``cpp`` variable. Defaulted to ``CXX`` build environment value diff --git a/conans/test/integration/toolchains/meson/test_mesontoolchain.py b/conans/test/integration/toolchains/meson/test_mesontoolchain.py index e857397c392..b1d3278087c 100644 --- a/conans/test/integration/toolchains/meson/test_mesontoolchain.py +++ b/conans/test/integration/toolchains/meson/test_mesontoolchain.py @@ -51,6 +51,10 @@ def generate(self): "host_prof": cross}) t.run("install . -pr:h host_prof -pr:b build_prof") + # Checking that the global conanbuild aggregator includes conanbuildenv-xxx file + # it should have been generated by implicit VirtualBuildEnv generator + env_file = t.load("conanbuild.sh") + assert "conanbuildenv" in env_file content = t.load(MesonToolchain.cross_filename) assert "c_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content assert "c_link_args = ['-isysroot', '/other/sdk/path', '-arch', 'myarch', '-otherminversion=10.7']" in content