|
|
|
@ -254,14 +254,14 @@ class CLikeCompiler: |
|
|
|
|
code = 'int main(void) { int class=0; return class; }\n' |
|
|
|
|
return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) |
|
|
|
|
|
|
|
|
|
def check_header(self, hname, prefix, env, *, extra_args=None, dependencies=None): |
|
|
|
|
def check_header(self, hname: str, prefix: str, env, *, extra_args=None, dependencies=None): |
|
|
|
|
fargs = {'prefix': prefix, 'header': hname} |
|
|
|
|
code = '''{prefix} |
|
|
|
|
#include <{header}>''' |
|
|
|
|
return self.compiles(code.format(**fargs), env, extra_args=extra_args, |
|
|
|
|
dependencies=dependencies) |
|
|
|
|
|
|
|
|
|
def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None, disable_cache=False): |
|
|
|
|
def has_header(self, hname: str, prefix: str, env, *, extra_args=None, dependencies=None, disable_cache: bool = False): |
|
|
|
|
fargs = {'prefix': prefix, 'header': hname} |
|
|
|
|
code = '''{prefix} |
|
|
|
|
#ifdef __has_include |
|
|
|
@ -274,7 +274,7 @@ class CLikeCompiler: |
|
|
|
|
return self.compiles(code.format(**fargs), env, extra_args=extra_args, |
|
|
|
|
dependencies=dependencies, mode='preprocess', disable_cache=disable_cache) |
|
|
|
|
|
|
|
|
|
def has_header_symbol(self, hname, symbol, prefix, env, *, extra_args=None, dependencies=None): |
|
|
|
|
def has_header_symbol(self, hname: str, symbol: str, prefix: str, env, *, extra_args=None, dependencies=None): |
|
|
|
|
fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol} |
|
|
|
|
t = '''{prefix} |
|
|
|
|
#include <{header}> |
|
|
|
@ -288,7 +288,7 @@ class CLikeCompiler: |
|
|
|
|
return self.compiles(t.format(**fargs), env, extra_args=extra_args, |
|
|
|
|
dependencies=dependencies) |
|
|
|
|
|
|
|
|
|
def _get_basic_compiler_args(self, env, mode): |
|
|
|
|
def _get_basic_compiler_args(self, env, mode: str): |
|
|
|
|
cargs, largs = [], [] |
|
|
|
|
# Select a CRT if needed since we're linking |
|
|
|
|
if mode == 'link': |
|
|
|
@ -354,11 +354,11 @@ class CLikeCompiler: |
|
|
|
|
|
|
|
|
|
def compiles(self, code: str, env, *, |
|
|
|
|
extra_args: T.Sequence[T.Union[T.Sequence[str], str]] = None, |
|
|
|
|
dependencies=None, mode: str = 'compile', disable_cache=False) -> T.Tuple[bool, bool]: |
|
|
|
|
dependencies=None, mode: str = 'compile', disable_cache: bool = False) -> T.Tuple[bool, bool]: |
|
|
|
|
with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: |
|
|
|
|
return p.returncode == 0, p.cached |
|
|
|
|
|
|
|
|
|
def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir=None) -> T.Tuple[bool, bool]: |
|
|
|
|
def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir: str = None) -> T.Tuple[bool, bool]: |
|
|
|
|
args = self._get_compiler_check_args(env, extra_args, dependencies, mode) |
|
|
|
|
if disable_cache or want_output: |
|
|
|
|
return self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir) |
|
|
|
@ -916,21 +916,21 @@ class CLikeCompiler: |
|
|
|
|
architecture. |
|
|
|
|
''' |
|
|
|
|
# If not building on macOS for Darwin, do a simple file check |
|
|
|
|
files = [Path(f) for f in files] |
|
|
|
|
paths = [Path(f) for f in files] |
|
|
|
|
if not env.machines.host.is_darwin() or not env.machines.build.is_darwin(): |
|
|
|
|
for f in files: |
|
|
|
|
if f.is_file(): |
|
|
|
|
return f |
|
|
|
|
for p in paths: |
|
|
|
|
if p.is_file(): |
|
|
|
|
return p |
|
|
|
|
# Run `lipo` and check if the library supports the arch we want |
|
|
|
|
for f in files: |
|
|
|
|
if not f.is_file(): |
|
|
|
|
for p in paths: |
|
|
|
|
if not p.is_file(): |
|
|
|
|
continue |
|
|
|
|
archs = mesonlib.darwin_get_object_archs(str(f)) |
|
|
|
|
archs = mesonlib.darwin_get_object_archs(str(p)) |
|
|
|
|
if archs and env.machines.host.cpu_family in archs: |
|
|
|
|
return f |
|
|
|
|
return p |
|
|
|
|
else: |
|
|
|
|
mlog.debug('Rejected {}, supports {} but need {}' |
|
|
|
|
.format(f, archs, env.machines.host.cpu_family)) |
|
|
|
|
.format(p, archs, env.machines.host.cpu_family)) |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
@functools.lru_cache() |
|
|
|
|