diff options
-rw-r--r-- | backends.py | 15 | ||||
-rw-r--r-- | build.py | 5 | ||||
-rw-r--r-- | environment.py | 15 |
3 files changed, 23 insertions, 12 deletions
diff --git a/backends.py b/backends.py index 69b46e2..b0d3dad 100644 --- a/backends.py +++ b/backends.py @@ -486,7 +486,9 @@ class NinjaBackend(Backend): outfile.write('# Rules for compiling.\n\n') self.generate_compile_rules(outfile) outfile.write('# Rules for linking.\n\n') - self.generate_static_link_rules(outfile) + if self.environment.is_cross_build(): + self.generate_static_link_rules(True, outfile) + self.generate_static_link_rules(False, outfile) self.generate_dynamic_link_rules(outfile) self.generate_dep_gen_rules(outfile) outfile.write('# Other rules\n\n') @@ -503,9 +505,14 @@ class NinjaBackend(Backend): outfile.write(' description = Regenerating build files\n') outfile.write(' generator = 1\n\n') - def generate_static_link_rules(self, outfile): - static_linker = self.build.static_linker - rule = 'rule STATIC_LINKER\n' + def generate_static_link_rules(self, is_cross, outfile): + if is_cross: + static_linker = self.build.static_cross_linker + crstr = '_CROSS' + else: + static_linker = self.build.static_linker + crstr = '' + rule = 'rule STATIC%s_LINKER\n' % crstr command = ' command = %s $LINK_FLAGS %s $in\n' % \ (' '.join(static_linker.get_exelist()), ' '.join(static_linker.get_output_flags('$out'))) @@ -29,6 +29,7 @@ class Build: self.man = [] self.data = [] self.static_linker = None + self.static_cross_linker = None self.configure_files = [] def add_compiler(self, compiler): @@ -37,8 +38,8 @@ class Build: self.compilers.append(compiler) def add_cross_compiler(self, compiler): - #if len(self.cross_compilers) == 0: - # self.static_linker = self.environment.detect_static_linker(compiler) + if len(self.cross_compilers) == 0: + self.static_cross_linker = self.environment.detect_static_linker(compiler) self.cross_compilers.append(compiler) def get_project(self): diff --git a/environment.py b/environment.py index a29e9e4..8c1e0b4 100644 --- a/environment.py +++ b/environment.py @@ -953,13 +953,16 @@ class Environment(): raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') def detect_static_linker(self, compiler): - evar = 'AR' - if evar in os.environ: - linker = os.environ[evar].strip() - if isinstance(compiler, VisualStudioCCompiler): - linker= self.vs_static_linker + if compiler.is_cross: + linker = self.cross_info['ar'] else: - linker = self.default_static_linker + evar = 'AR' + if evar in os.environ: + linker = os.environ[evar].strip() + if isinstance(compiler, VisualStudioCCompiler): + linker= self.vs_static_linker + else: + linker = self.default_static_linker basename = os.path.basename(linker).lower() if basename == 'lib' or basename == 'lib.exe': arg = '/?' |