зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1724374 - Handle the macos SDK through the same code paths as sysroots. r=firefox-build-system-reviewers,andi
Differential Revision: https://phabricator.services.mozilla.com/D121944
This commit is contained in:
Родитель
af61d5c6de
Коммит
ab833087f4
|
@ -121,11 +121,11 @@ option(
|
|||
cxx_compiler,
|
||||
clang_search_path,
|
||||
target,
|
||||
target_sysroot_flags,
|
||||
target_sysroot.path,
|
||||
)
|
||||
@checking("for clang for bindgen", lambda x: x.path if x else "not found")
|
||||
def bindgen_clang_compiler(
|
||||
clang_path, c_compiler, cxx_compiler, clang_search_path, target, sysroot_flags
|
||||
clang_path, c_compiler, cxx_compiler, clang_search_path, target, sysroot_path
|
||||
):
|
||||
# When the target compiler is clang, use that, including flags.
|
||||
if cxx_compiler.type == "clang":
|
||||
|
@ -162,7 +162,9 @@ def bindgen_clang_compiler(
|
|||
# Hack before bug 1617793: if the compiler is clang-cl, hack the target
|
||||
if cxx_compiler.type == "clang-cl":
|
||||
target = split_triplet("%s-pc-windows-msvc" % target.raw_cpu, allow_msvc=True)
|
||||
flags = list(sysroot_flags or ())
|
||||
flags = []
|
||||
if sysroot_path:
|
||||
flags.extend(("--sysroot", sysroot_path))
|
||||
info = check_compiler([clang_path] + flags, "C++", target)
|
||||
return namespace(
|
||||
path=clang_path,
|
||||
|
|
|
@ -19,7 +19,7 @@ def pkg_config_version(pkg_config):
|
|||
return Version(check_cmd_output(pkg_config, "--version").rstrip())
|
||||
|
||||
|
||||
@depends(target_sysroot_path, multiarch_dir, when=pkg_config)
|
||||
@depends(target_sysroot.path, multiarch_dir, when=pkg_config)
|
||||
@imports(_from="os", _import="environ")
|
||||
def pkg_config_vars(sysroot_path, multiarch_dir):
|
||||
if sysroot_path:
|
||||
|
|
|
@ -918,7 +918,7 @@ def provided_program(env_var, when=None):
|
|||
|
||||
|
||||
@template
|
||||
def sysroot_path(host_or_target):
|
||||
def sysroot(host_or_target):
|
||||
if host_or_target is host:
|
||||
host_or_target_str = "host"
|
||||
opt = "--with-host-sysroot"
|
||||
|
@ -948,22 +948,26 @@ def sysroot_path(host_or_target):
|
|||
|
||||
@depends(
|
||||
sysroot_input,
|
||||
host_or_target,
|
||||
macos_sdk,
|
||||
bootstrap_path(
|
||||
depends(host_or_target)(lambda t: "sysroot-{}".format(t.toolchain)),
|
||||
when=bootstrap_sysroot,
|
||||
),
|
||||
)
|
||||
def sysroot_path(sysroot_input, path):
|
||||
def sysroot(sysroot_input, host_or_target, macos_sdk, path):
|
||||
if sysroot_input:
|
||||
path = sysroot_input[0]
|
||||
elif host_or_target.kernel == "Darwin" and macos_sdk:
|
||||
path = macos_sdk
|
||||
if path:
|
||||
log.info("Using %s sysroot in %s", host_or_target_str, path)
|
||||
return namespace(path=path, bootstrapped=bool(path and not sysroot_input))
|
||||
|
||||
return sysroot_path
|
||||
return sysroot
|
||||
|
||||
|
||||
target_sysroot_path = sysroot_path(target)
|
||||
target_sysroot = sysroot(target)
|
||||
|
||||
|
||||
# Use `system_lib_option` instead of `option` for options that enable building
|
||||
|
@ -973,7 +977,7 @@ target_sysroot_path = sysroot_path(target)
|
|||
def system_lib_option(name, *args, **kwargs):
|
||||
option(name, *args, **kwargs)
|
||||
|
||||
@depends(name, target_sysroot_path.bootstrapped)
|
||||
@depends(name, target_sysroot.bootstrapped)
|
||||
def no_system_lib_in_sysroot(value, bootstrapped):
|
||||
if bootstrapped and value:
|
||||
die(
|
||||
|
@ -983,33 +987,10 @@ def system_lib_option(name, *args, **kwargs):
|
|||
)
|
||||
|
||||
|
||||
host_sysroot_path = sysroot_path(host).path
|
||||
target_sysroot_path = target_sysroot_path.path
|
||||
host_sysroot = sysroot(host)
|
||||
|
||||
|
||||
@template
|
||||
def sysroot_flags(host_or_target):
|
||||
sysroot_path = {
|
||||
host: host_sysroot_path,
|
||||
target: target_sysroot_path,
|
||||
}[host_or_target]
|
||||
|
||||
@depends(host_or_target, macos_sdk, sysroot_path)
|
||||
def sysroot_flags(host_or_target, macos_sdk, sysroot_path):
|
||||
if macos_sdk and host_or_target.os == "OSX":
|
||||
return ["--sysroot", macos_sdk]
|
||||
if sysroot_path:
|
||||
return ["--sysroot", sysroot_path]
|
||||
return []
|
||||
|
||||
return sysroot_flags
|
||||
|
||||
|
||||
host_sysroot_flags = sysroot_flags(host)
|
||||
target_sysroot_flags = sysroot_flags(target)
|
||||
|
||||
|
||||
@depends(target, when=target_sysroot_path)
|
||||
@depends(target, when=target_sysroot.path)
|
||||
def multiarch_dir(target):
|
||||
if target.cpu == "x86":
|
||||
# Turn e.g. i686-linux-gnu into i386-linux-gnu
|
||||
|
@ -1052,9 +1033,9 @@ def compiler(
|
|||
target: "target",
|
||||
}[host_or_target]
|
||||
|
||||
sysroot_flags = {
|
||||
host: host_sysroot_flags,
|
||||
target: target_sysroot_flags,
|
||||
sysroot = {
|
||||
host: host_sysroot,
|
||||
target: target_sysroot,
|
||||
}[host_or_target]
|
||||
|
||||
var = {
|
||||
|
@ -1092,15 +1073,17 @@ def compiler(
|
|||
)
|
||||
|
||||
@depends(
|
||||
compiler, provided_compiler, compiler_wrapper, host_or_target, sysroot_flags
|
||||
compiler, provided_compiler, compiler_wrapper, host_or_target, sysroot.path
|
||||
)
|
||||
@checking("whether %s can be used" % what, lambda x: bool(x))
|
||||
@imports(_from="mozbuild.shellutil", _import="quote")
|
||||
def valid_compiler(
|
||||
compiler, provided_compiler, compiler_wrapper, host_or_target, sysroot_flags
|
||||
compiler, provided_compiler, compiler_wrapper, host_or_target, sysroot_path
|
||||
):
|
||||
wrapper = list(compiler_wrapper or ())
|
||||
flags = list(sysroot_flags or ())
|
||||
flags = []
|
||||
if sysroot_path:
|
||||
flags.extend(("--sysroot", sysroot_path))
|
||||
if provided_compiler:
|
||||
wrapper.extend(provided_compiler.wrapper)
|
||||
flags.extend(provided_compiler.flags)
|
||||
|
@ -2244,7 +2227,7 @@ def select_linker(
|
|||
set_config("LINKER_KIND", select_linker.KIND)
|
||||
|
||||
|
||||
@depends_if(select_linker, target, target_sysroot_path, multiarch_dir)
|
||||
@depends_if(select_linker, target, target_sysroot.path, multiarch_dir)
|
||||
@imports("os")
|
||||
def linker_ldflags(linker, target, sysroot_path, multiarch_dir):
|
||||
flags = list((linker and linker.LINKER_FLAG) or [])
|
||||
|
@ -2762,15 +2745,12 @@ def path_remapping(value):
|
|||
@depends(
|
||||
target,
|
||||
check_build_environment,
|
||||
target_sysroot_path,
|
||||
macos_sdk,
|
||||
target_sysroot.path,
|
||||
windows_sdk_dir,
|
||||
vc_path,
|
||||
when="--enable-path-remapping",
|
||||
)
|
||||
def path_remappings(
|
||||
target, build_env, sysroot_path, macos_sdk, windows_sdk_dir, vc_path
|
||||
):
|
||||
def path_remappings(target, build_env, sysroot_path, windows_sdk_dir, vc_path):
|
||||
win = target.kernel == "WINNT"
|
||||
|
||||
# The prefix maps are processed in the order they're specified on the
|
||||
|
@ -2789,8 +2769,6 @@ def path_remappings(
|
|||
# IDEs.
|
||||
if sysroot_path:
|
||||
path_remappings.append((sysroot_path, "k:/" if win else "/sysroot/"))
|
||||
if macos_sdk:
|
||||
path_remappings.append((macos_sdk, "k:/" if win else "/sysroot/"))
|
||||
if windows_sdk_dir:
|
||||
path_remappings.append((windows_sdk_dir, "k:/" if win else "/windows_sdk/"))
|
||||
if vc_path:
|
||||
|
|
|
@ -749,7 +749,7 @@ and/or set $JAVA_HOME.
|
|||
compile_environment = depends(when='--enable-compile-environment')(lambda: True)
|
||||
toolchain_prefix = depends(when=True)(lambda: None)
|
||||
multiarch_dir = depends(when=True)(lambda: None)
|
||||
target_sysroot_path = depends(when=True)(lambda: None)
|
||||
target_sysroot = depends(when=True)(lambda: None)
|
||||
include('%(topsrcdir)s/build/moz.configure/util.configure')
|
||||
include('%(topsrcdir)s/build/moz.configure/checks.configure')
|
||||
include('%(topsrcdir)s/build/moz.configure/pkg.configure')
|
||||
|
|
|
@ -885,7 +885,7 @@ class OSXToolchainTest(BaseToolchainTest):
|
|||
GCC_7_RESULT = LinuxToolchainTest.GCC_7_RESULT
|
||||
GXX_7_RESULT = LinuxToolchainTest.GXX_7_RESULT
|
||||
SYSROOT_FLAGS = {
|
||||
"flags": PrependFlags(["-isysroot", xcrun("", ("--show-sdk-path",))[1]])
|
||||
"flags": PrependFlags(["--sysroot", xcrun("", ("--show-sdk-path",))[1]])
|
||||
}
|
||||
|
||||
def test_clang(self):
|
||||
|
@ -1755,10 +1755,11 @@ class RustTest(BaseConfigureTest):
|
|||
)
|
||||
# Same for the arm_target checks.
|
||||
dep = sandbox._depends[sandbox["arm_target"]]
|
||||
getattr(sandbox, "__value_for_depends")[
|
||||
(dep,)
|
||||
] = arm_target or ReadOnlyNamespace(
|
||||
arm_arch=7, thumb2=False, fpu="vfpv2", float_abi="softfp"
|
||||
getattr(sandbox, "__value_for_depends")[(dep,)] = (
|
||||
arm_target
|
||||
or ReadOnlyNamespace(
|
||||
arm_arch=7, thumb2=False, fpu="vfpv2", float_abi="softfp"
|
||||
)
|
||||
)
|
||||
return sandbox._value_for(sandbox["rust_target_triple"])
|
||||
|
||||
|
|
|
@ -13,10 +13,7 @@ import six
|
|||
from six import StringIO
|
||||
from textwrap import dedent
|
||||
|
||||
from mozunit import (
|
||||
main,
|
||||
MockedOpen,
|
||||
)
|
||||
from mozunit import main, MockedOpen
|
||||
|
||||
from mozbuild.preprocessor import Preprocessor
|
||||
from mozbuild.util import ReadOnlyNamespace
|
||||
|
@ -106,10 +103,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
|
|||
|
||||
def test_normalization(self):
|
||||
pp = CompilerPreprocessor(
|
||||
{
|
||||
"__has_attribute(bar)": 1,
|
||||
'__has_warning("-Wc++98-foo")': 1,
|
||||
}
|
||||
{"__has_attribute(bar)": 1, '__has_warning("-Wc++98-foo")': 1}
|
||||
)
|
||||
pp.out = StringIO()
|
||||
input = StringIO(
|
||||
|
@ -142,13 +136,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
|
|||
self.assertEquals(pp.out.getvalue(), "WFOO\nBAR\nNO_FOO\n")
|
||||
|
||||
def test_condition(self):
|
||||
pp = CompilerPreprocessor(
|
||||
{
|
||||
"A": 1,
|
||||
"B": "2",
|
||||
"C": "0L",
|
||||
}
|
||||
)
|
||||
pp = CompilerPreprocessor({"A": 1, "B": "2", "C": "0L"})
|
||||
pp.out = StringIO()
|
||||
input = StringIO(
|
||||
dedent(
|
||||
|
@ -229,8 +217,8 @@ class FakeCompiler(dict):
|
|||
if arg is None:
|
||||
break
|
||||
if arg.startswith("-"):
|
||||
# Ignore -isysroot and the argument that follows it.
|
||||
if arg == "-isysroot":
|
||||
# Ignore --sysroot and the argument that follows it.
|
||||
if arg == "--sysroot":
|
||||
next(args, None)
|
||||
else:
|
||||
flags.append(arg)
|
||||
|
@ -273,39 +261,17 @@ class FakeCompiler(dict):
|
|||
|
||||
class TestFakeCompiler(unittest.TestCase):
|
||||
def test_fake_compiler(self):
|
||||
with MockedOpen(
|
||||
{
|
||||
"file": "A B C",
|
||||
"file.c": "A B C",
|
||||
}
|
||||
):
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": "1",
|
||||
"B": "2",
|
||||
}
|
||||
)
|
||||
with MockedOpen({"file": "A B C", "file.c": "A B C"}):
|
||||
compiler = FakeCompiler({"A": "1", "B": "2"})
|
||||
self.assertEquals(compiler(None, ["-E", "file"]), (0, "1 2 C", ""))
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
None: {
|
||||
"A": "1",
|
||||
"B": "2",
|
||||
},
|
||||
"-foo": {
|
||||
"C": "foo",
|
||||
},
|
||||
"-bar": {
|
||||
"B": "bar",
|
||||
"C": "bar",
|
||||
},
|
||||
"-qux": {
|
||||
"B": False,
|
||||
},
|
||||
"*.c": {
|
||||
"B": "42",
|
||||
},
|
||||
None: {"A": "1", "B": "2"},
|
||||
"-foo": {"C": "foo"},
|
||||
"-bar": {"B": "bar", "C": "bar"},
|
||||
"-qux": {"B": False},
|
||||
"*.c": {"B": "42"},
|
||||
}
|
||||
)
|
||||
self.assertEquals(compiler(None, ["-E", "file"]), (0, "1 2 C", ""))
|
||||
|
@ -334,111 +300,25 @@ class TestFakeCompiler(unittest.TestCase):
|
|||
)
|
||||
|
||||
def test_multiple_definitions(self):
|
||||
compiler = FakeCompiler({"A": 1, "B": 2}, {"C": 3})
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 2, "C": 3}})
|
||||
compiler = FakeCompiler({"A": 1, "B": 2}, {"B": 4, "C": 3})
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 4, "C": 3}})
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
"C": 3,
|
||||
},
|
||||
{"A": 1, "B": 2}, {None: {"B": 4, "C": 3}, "-foo": {"D": 5}}
|
||||
)
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 4, "C": 3}, "-foo": {"D": 5}})
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{None: {"A": 1, "B": 2}, "-foo": {"D": 5}},
|
||||
{"-foo": {"D": 5}, "-bar": {"E": 6}},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
"C": 3,
|
||||
},
|
||||
},
|
||||
)
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
},
|
||||
)
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
None: {
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
{
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
"-bar": {
|
||||
"E": 6,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
"-bar": {
|
||||
"E": 6,
|
||||
},
|
||||
},
|
||||
compiler, {None: {"A": 1, "B": 2}, "-foo": {"D": 5}, "-bar": {"E": 6}}
|
||||
)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче