diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-03-11 21:37:40 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-08-06 00:11:38 +0300 |
commit | 647e871484eb2d8b5ce695c2ff97c9cbd9fd6d5d (patch) | |
tree | d5fed1555235c1d256e45bfa327c365e4da42a4c /mesonbuild | |
parent | c9aea4e11c648f1051454132626bcb4aef976d6d (diff) | |
download | meson-crossargfix.zip meson-crossargfix.tar.gz meson-crossargfix.tar.bz2 |
Store global and project arguments separately for cross and native compilation.crossargfix
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 20 | ||||
-rw-r--r-- | mesonbuild/build.py | 26 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 21 |
4 files changed, 49 insertions, 22 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 2105d42..7381eb5 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -532,10 +532,10 @@ class Backend: # Add buildtype args: optimization level, debugging, etc. commands += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target)) # Add compile args added using add_project_arguments() - commands += self.build.get_project_args(compiler, target.subproject) + commands += self.build.get_project_args(compiler, target.subproject, target.is_cross) # Add compile args added using add_global_arguments() # These override per-project arguments - commands += self.build.get_global_args(compiler) + commands += self.build.get_global_args(compiler, target.is_cross) if not target.is_cross: # Compile args added from the env: CFLAGS/CXXFLAGS, etc. We want these # to override all the defaults, but not the per-target compile args. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 913830f..cea548c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -853,8 +853,8 @@ int dummy; for dep in target.get_external_deps(): commands.extend_direct(dep.get_link_args()) - commands += self.build.get_project_args(compiler, target.subproject) - commands += self.build.get_global_args(compiler) + commands += self.build.get_project_args(compiler, target.subproject, target.is_cross) + commands += self.build.get_global_args(compiler, target.is_cross) elem = NinjaBuildElement(self.all_outputs, outputs, 'cs_COMPILER', rel_srcs) elem.add_dep(deps) @@ -867,8 +867,8 @@ int dummy; deps = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets] args = [] args += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target)) - args += self.build.get_global_args(compiler) - args += self.build.get_project_args(compiler, target.subproject) + args += self.build.get_global_args(compiler, target.is_cross) + args += self.build.get_project_args(compiler, target.subproject, target.is_cross) args += target.get_java_args() args += compiler.get_output_args(self.get_target_private_dir(target)) args += target.get_classpath_args() @@ -1242,8 +1242,8 @@ int dummy; os.makedirs(self.get_target_private_dir_abs(target), exist_ok=True) compile_args = swiftc.get_compile_only_args() compile_args += swiftc.get_module_args(module_name) - compile_args += self.build.get_project_args(swiftc, target.subproject) - compile_args += self.build.get_global_args(swiftc) + compile_args += self.build.get_project_args(swiftc, target.subproject, target.is_cross) + compile_args += self.build.get_global_args(swiftc, target.is_cross) for i in reversed(target.get_include_dirs()): basedir = i.get_curdir() for d in i.get_incdirs(): @@ -1255,8 +1255,8 @@ int dummy; sargs = swiftc.get_include_args(srctreedir) compile_args += sargs link_args = swiftc.get_output_args(os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))) - link_args += self.build.get_project_link_args(swiftc, target.subproject) - link_args += self.build.get_global_link_args(swiftc) + link_args += self.build.get_project_link_args(swiftc, target.subproject, target.is_cross) + link_args += self.build.get_global_link_args(swiftc, target.is_cross) rundir = self.get_target_private_dir(target) out_module_name = self.swift_module_file_name(target) in_module_files = self.determine_swift_dep_modules(target) @@ -2389,10 +2389,10 @@ rule FORTRAN_DEP_HACK%s if not isinstance(target, build.StaticLibrary): # Add link args added using add_project_link_arguments() - commands += self.build.get_project_link_args(linker, target.subproject) + commands += self.build.get_project_link_args(linker, target.subproject, target.is_cross) # Add link args added using add_global_link_arguments() # These override per-project link arguments - commands += self.build.get_global_link_args(linker) + commands += self.build.get_global_link_args(linker, target.is_cross) if not target.is_cross: # Link args added from the env: LDFLAGS. We want these to # override all the defaults but not the per-target link args. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a3cd993..54bb050 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -104,9 +104,13 @@ class Build: self.compilers = OrderedDict() self.cross_compilers = OrderedDict() self.global_args = {} + self.global_cross_args = {} self.projects_args = {} + self.projects_cross_args = {} self.global_link_args = {} + self.global_cross_link_args = {} self.projects_link_args = {} + self.projects_cross_link_args = {} self.tests = [] self.benchmarks = [] self.headers = [] @@ -167,20 +171,30 @@ class Build: def get_install_subdirs(self): return self.install_dirs - def get_global_args(self, compiler): + def get_global_args(self, compiler, is_cross): + if is_cross: + return self.global_cross_args.get(compiler.get_language(), []) return self.global_args.get(compiler.get_language(), []) - def get_project_args(self, compiler, project): - args = self.projects_args.get(project) + def get_project_args(self, compiler, project, is_cross): + if is_cross: + args = self.projects_cross_args.get(project) + else: + args = self.projects_args.get(project) if not args: return [] return args.get(compiler.get_language(), []) - def get_global_link_args(self, compiler): + def get_global_link_args(self, compiler, is_cross): + if is_cross: + return self.global_cross_link_args.get(compiler.get_language(), []) return self.global_link_args.get(compiler.get_language(), []) - def get_project_link_args(self, compiler, project): - link_args = self.projects_link_args.get(project) + def get_project_link_args(self, compiler, project, is_cross): + if is_cross: + link_args = self.projects_cross_link_args.get(project) + else: + link_args = self.projects_link_args.get(project) if not link_args: return [] diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 95fc408..a823f53 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3630,25 +3630,38 @@ different subdirectory. timeout_multiplier=timeout_multiplier, env=env) + def use_cross_list(self, kwargs): + if 'native' in kwargs: + b = kwargs['native'] + if not isinstance(b, bool): + raise InterpreterException('Native keyword must be boolean.') + return not b + else: + return self.environment.is_cross_build() + @permittedKwargs(permitted_kwargs['add_global_arguments']) @stringArgs def func_add_global_arguments(self, node, args, kwargs): - self.add_global_arguments(node, self.build.global_args, args, kwargs) + arg_obj = self.build.global_cross_args if self.use_cross_list(kwargs) else self.build.global_args + self.add_global_arguments(node, arg_obj, args, kwargs) @permittedKwargs(permitted_kwargs['add_global_link_arguments']) @stringArgs def func_add_global_link_arguments(self, node, args, kwargs): - self.add_global_arguments(node, self.build.global_link_args, args, kwargs) + arg_obj = self.build.global_cross_link_args if self.use_cross_list(kwargs) else self.build.global_link_args + self.add_global_arguments(node, arg_obj, args, kwargs) @permittedKwargs(permitted_kwargs['add_project_arguments']) @stringArgs def func_add_project_arguments(self, node, args, kwargs): - self.add_project_arguments(node, self.build.projects_args, args, kwargs) + arg_obj = self.build.projects_cross_args if self.use_cross_list(kwargs) else self.build.projects_args + self.add_project_arguments(node, arg_obj, args, kwargs) @permittedKwargs(permitted_kwargs['add_project_link_arguments']) @stringArgs def func_add_project_link_arguments(self, node, args, kwargs): - self.add_project_arguments(node, self.build.projects_link_args, args, kwargs) + arg_obj = self.build.projects_cross_link_args if self.use_cross_list(kwargs) else self.build.projects_link_args + self.add_project_arguments(node, arg_obj, args, kwargs) def add_global_arguments(self, node, argsdict, args, kwargs): if self.is_subproject(): |