diff options
author | John Ericson <git@JohnEricson.me> | 2018-12-12 00:19:03 -0500 |
---|---|---|
committer | John Ericson <git@JohnEricson.me> | 2019-02-02 13:59:14 -0500 |
commit | 19f81d3e33c70c9c902dabaad732e5d33bf05bd4 (patch) | |
tree | f86664395d7233bbba9e3c129c81c7056c6fa98b /mesonbuild/backend/backends.py | |
parent | 6dbe33d949237411b1291c30f5383885befb3554 (diff) | |
download | meson-19f81d3e33c70c9c902dabaad732e5d33bf05bd4.zip meson-19f81d3e33c70c9c902dabaad732e5d33bf05bd4.tar.gz meson-19f81d3e33c70c9c902dabaad732e5d33bf05bd4.tar.bz2 |
Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.
Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so
- The logic is cross-agnostic, i.e. there are no conditions affected by
`is_cross_build()`.
- Compiler args for both the build and host machines can always be
controlled by the command line.
- Compiler args for both machines can always be controlled separately.
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r-- | mesonbuild/backend/backends.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index a0326f3..ba5bd90 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -20,7 +20,7 @@ from .. import mesonlib from .. import mlog import json import subprocess -from ..mesonlib import MesonException, OrderedSet +from ..mesonlib import MachineChoice, MesonException, OrderedSet from ..mesonlib import classify_unity_sources from ..mesonlib import File from ..compilers import CompilerArgs, VisualStudioCCompiler @@ -185,9 +185,14 @@ class Backend: self.environment.coredata.base_options) def get_compiler_options_for_target(self, target): - return OptionOverrideProxy(target.option_overrides, - # no code depends on builtins for now - self.environment.coredata.compiler_options) + if self.environment.is_cross_build() and not target.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + + return OptionOverrideProxy( + target.option_overrides, + self.environment.coredata.compiler_options[for_machine]) def get_option_for_target(self, option_name, target): if option_name in target.option_overrides: @@ -574,10 +579,14 @@ class Backend: # Add compile args added using add_global_arguments() # These override per-project arguments commands += self.build.get_global_args(compiler, target.is_cross) + if self.environment.is_cross_build() and not target.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST 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. - commands += self.environment.coredata.get_external_args(compiler.get_language()) + commands += self.environment.coredata.get_external_args(for_machine, compiler.get_language()) # Always set -fPIC for shared libraries if isinstance(target, build.SharedLibrary): commands += compiler.get_pic_args() |