diff options
Diffstat (limited to 'mesonbuild/backend/vs2010backend.py')
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 783ae64..80204e4 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -25,7 +25,9 @@ from .. import dependencies from .. import mlog from .. import compilers from ..compilers import CompilerArgs -from ..mesonlib import MesonException, File, python_command, replace_if_different +from ..mesonlib import ( + MesonException, MachineChoice, File, python_command, replace_if_different +) from ..environment import Environment, build_filename def autodetect_vs_version(build): @@ -878,10 +880,14 @@ class Vs2010Backend(backends.Backend): file_inc_dirs = dict((lang, []) for lang in target.compilers) # The order in which these compile args are added must match # generate_single_compile() and generate_basic_compiler_args() + if self.environment.is_cross_build() and not target.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST for l, comp in target.compilers.items(): if l in file_args: file_args[l] += compilers.get_base_compile_args(self.get_base_options_for_target(target), comp) - file_args[l] += comp.get_option_compile_args(self.environment.coredata.compiler_options) + file_args[l] += comp.get_option_compile_args(self.environment.coredata.compiler_options[for_machine]) # Add compile args added using add_project_arguments() for l, args in self.build.projects_args.get(target.subproject, {}).items(): @@ -893,9 +899,10 @@ class Vs2010Backend(backends.Backend): if l in file_args: file_args[l] += args 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. - for key, opt in self.environment.coredata.compiler_options.items(): + # Compile args added from the env or cross file: CFLAGS/CXXFLAGS, + # etc. We want these to override all the defaults, but not the + # per-target compile args. + for key, opt in self.environment.coredata.compiler_options[for_machine].items(): l, suffix = key.split('_', 1) if suffix == 'args' and l in file_args: file_args[l] += opt.value @@ -1054,9 +1061,10 @@ class Vs2010Backend(backends.Backend): # These override per-project link arguments extra_link_args += self.build.get_global_link_args(compiler, 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. - extra_link_args += self.environment.coredata.get_external_link_args(compiler.get_language()) + # Link args added from the env: LDFLAGS, or the cross file. We + # want these to override all the defaults but not the + # per-target link args. + extra_link_args += self.environment.coredata.get_external_link_args(for_machine, compiler.get_language()) # Only non-static built targets need link args and link dependencies extra_link_args += target.link_args # External deps must be last because target link libraries may depend on them. @@ -1079,7 +1087,7 @@ class Vs2010Backend(backends.Backend): # to be after all internal and external libraries so that unresolved # symbols from those can be found here. This is needed when the # *_winlibs that we want to link to are static mingw64 libraries. - extra_link_args += compiler.get_option_link_args(self.environment.coredata.compiler_options) + extra_link_args += compiler.get_option_link_args(self.environment.coredata.compiler_options[for_machine]) (additional_libpaths, additional_links, extra_link_args) = self.split_link_args(extra_link_args.to_native()) # Add more libraries to be linked if needed |