Skip to content

Commit 13ae10d

Browse files
Revert "fix: sysroot property (conan-io#16011)"
This change breaks all our meson builds as when passing --sysroot meson will prefix every single include directory with the sysroot...
1 parent f094b72 commit 13ae10d

File tree

3 files changed

+7
-61
lines changed

3 files changed

+7
-61
lines changed

conan/tools/meson/toolchain.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,6 @@ def __init__(self, conanfile, backend=None, native=False):
261261
default_comp = "cl"
262262
default_comp_cpp = "cl"
263263

264-
# Read configuration for sys_root property (honoring existing conf)
265-
self._sys_root = self._conanfile_conf.get("tools.build:sysroot", check_type=str)
266-
if self._sys_root:
267-
self.properties["sys_root"] = self._sys_root
268-
269264
# Read configuration for compilers
270265
compilers_by_conf = self._conanfile_conf.get("tools.build:compiler_executables", default={},
271266
check_type=dict)
@@ -425,11 +420,10 @@ def _get_extra_flags(self):
425420
linker_scripts = self._conanfile_conf.get("tools.build:linker_scripts", default=[], check_type=list)
426421
linker_script_flags = ['-T"' + linker_script + '"' for linker_script in linker_scripts]
427422
defines = self._conanfile_conf.get("tools.build:defines", default=[], check_type=list)
428-
sys_root = [f"--sysroot={self._sys_root}"] if self._sys_root else [""]
429-
ld = sharedlinkflags + exelinkflags + linker_script_flags + sys_root + self.extra_ldflags
423+
ld = sharedlinkflags + exelinkflags + linker_script_flags + self.extra_ldflags
430424
return {
431-
"cxxflags": cxxflags + sys_root + self.extra_cxxflags,
432-
"cflags": cflags + sys_root + self.extra_cflags,
425+
"cxxflags": cxxflags + self.extra_cxxflags,
426+
"cflags": cflags + self.extra_cflags,
433427
"ldflags": ld,
434428
"defines": [f"-D{d}" for d in (defines + self.extra_defines)]
435429
}

test/functional/toolchains/meson/test_meson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import pytest
88

9-
from conan.test.assets.sources import gen_function_cpp, gen_function_h
10-
from conan.test.utils.tools import TestClient
119
from conans.model.recipe_ref import RecipeReference
10+
from conan.test.assets.sources import gen_function_cpp, gen_function_h
1211
from test.functional.toolchains.meson._base import TestMesonBase
12+
from conan.test.utils.tools import TestClient
1313

1414

1515
class MesonToolchainTest(TestMesonBase):

test/integration/toolchains/meson/test_mesontoolchain.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
import platform
3-
import re
43
import textwrap
54

65
import pytest
76

87
from conan.test.assets.genconanfile import GenConanfile
9-
from conan.test.utils.tools import TestClient
8+
from conan.tools.files import load
109
from conan.tools.meson import MesonToolchain
10+
from conan.test.utils.tools import TestClient
1111

1212

1313
def test_apple_meson_keep_user_custom_flags():
@@ -599,54 +599,6 @@ def test_compiler_path_with_spaces():
599599
assert "cpp = 'cpp compiler path with spaces'" in conan_meson_native
600600

601601

602-
def test_meson_sysroot_app():
603-
"""Testing when users pass tools.build:sysroot on the profile with Meson
604-
605-
The generated conan_meson_cross.ini needs to contain both sys_root property to fill the
606-
PKG_CONFIG_PATH and the compiler flags with --sysroot.
607-
608-
When cross-building, Meson needs both compiler_executables in the config, otherwise it will fail
609-
when running setup.
610-
"""
611-
sysroot = "/my/new/sysroot/path"
612-
client = TestClient()
613-
profile = textwrap.dedent(f"""
614-
[settings]
615-
os = Macos
616-
arch = armv8
617-
compiler = apple-clang
618-
compiler.version = 13.0
619-
compiler.libcxx = libc++
620-
621-
[conf]
622-
tools.build:sysroot={sysroot}
623-
tools.build:verbosity=verbose
624-
tools.compilation:verbosity=verbose
625-
tools.apple:sdk_path=/my/sdk/path
626-
""")
627-
profile_build = textwrap.dedent(f"""
628-
[settings]
629-
os = Macos
630-
arch = x86_64
631-
compiler = apple-clang
632-
compiler.version = 13.0
633-
compiler.libcxx = libc++
634-
""")
635-
client.save({"conanfile.py": GenConanfile(name="hello", version="0.1")
636-
.with_settings("os", "arch", "compiler", "build_type")
637-
.with_generator("MesonToolchain"),
638-
"build": profile_build,
639-
"host": profile})
640-
client.run("install . -pr:h host -pr:b build")
641-
# Check the meson configuration file
642-
conan_meson = client.load("conan_meson_cross.ini")
643-
assert f"sys_root = '{sysroot}'\n" in conan_meson
644-
assert re.search(r"c_args =.+--sysroot={}.+".format(sysroot), conan_meson)
645-
assert re.search(r"c_link_args =.+--sysroot={}.+".format(sysroot), conan_meson)
646-
assert re.search(r"cpp_args =.+--sysroot={}.+".format(sysroot), conan_meson)
647-
assert re.search(r"cpp_link_args =.+--sysroot={}.+".format(sysroot), conan_meson)
648-
649-
650602
def test_cross_x86_64_to_x86():
651603
"""
652604
https://github.com/conan-io/conan/issues/17261

0 commit comments

Comments
 (0)