--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -30,16 +30,17 @@ from ..frontend.data import (
GeneratedFile,
GeneratedSources,
HostDefines,
HostSources,
JARManifest,
ObjdirFiles,
PerSourceFlag,
Sources,
+ VariablePassthru,
)
from ..util import (
FileAvoidWrite,
expand_variables,
)
from ..frontend.context import (
AbsolutePath,
ObjDirPath,
@@ -60,16 +61,17 @@ class BackendTupfile(object):
self.shell_exported = False
self.defines = []
self.host_defines = []
self.delayed_generated_files = []
self.per_source_flags = defaultdict(list)
self.local_flags = defaultdict(list)
self.sources = defaultdict(list)
self.host_sources = defaultdict(list)
+ self.variables = {}
self.fh = FileAvoidWrite(self.name, capture_diff=True)
self.fh.write('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT.\n')
self.fh.write('\n')
def write(self, buf):
self.fh.write(buf)
@@ -116,31 +118,34 @@ class BackendTupfile(object):
cmd=['!tup_ln'],
inputs=[source],
outputs=outputs,
)
def gen_sources_rules(self, extra_inputs):
sources = self.sources
host_sources = self.host_sources
+ as_dash_c = self.variables.get('AS_DASH_C_FLAG', self.environment.substs['AS_DASH_C_FLAG'])
compilers = [
- (sources['.S'], 'AS', 'ASFLAGS', ''),
- (sources['.cpp'], 'CXX', 'CXXFLAGS', ''),
- (sources['.c'], 'CC', 'CFLAGS', ''),
- (host_sources['.cpp'], 'HOST_CXX', 'HOST_CXXFLAGS', 'host_'),
- (host_sources['.c'], 'HOST_CC', 'HOST_CFLAGS', 'host_'),
+ (sources['.S'], 'AS', 'SFLAGS', '-c', ''),
+ (sources['.s'], 'AS', 'ASFLAGS', as_dash_c, ''),
+ (sources['.cpp'], 'CXX', 'CXXFLAGS', '-c', ''),
+ (sources['.c'], 'CC', 'CFLAGS', '-c', ''),
+ (host_sources['.cpp'], 'HOST_CXX', 'HOST_CXXFLAGS', '-c', 'host_'),
+ (host_sources['.c'], 'HOST_CC', 'HOST_CFLAGS', '-c', 'host_'),
]
- for srcs, compiler, flags, prefix in compilers:
+ for srcs, compiler, flags, dash_c, prefix in compilers:
for src in sorted(srcs):
# AS can be set to $(CC), so we need to call expand_variables on
# the compiler to get the real value.
- cmd = [expand_variables(self.environment.substs[compiler], self.environment.substs)]
+ compiler_value = self.variables.get(compiler, self.environment.substs[compiler])
+ cmd = [expand_variables(compiler_value, self.environment.substs)]
cmd.extend(shell_quote(f) for f in self.local_flags[flags])
cmd.extend(shell_quote(f) for f in self.per_source_flags[src])
- cmd.extend(['-c', '%f', '-o', '%o'])
+ cmd.extend([dash_c, '%f', '-o', '%o'])
self.rule(
cmd=cmd,
inputs=[src],
extra_inputs=extra_inputs,
outputs=[prefix + '%B.o'],
display='%s %%f' % compiler,
)
@@ -275,16 +280,18 @@ class TupOnly(CommonBackend, PartialBack
backend_file.per_source_flags[obj.file_name].extend(obj.flags)
elif isinstance(obj, ComputedFlags):
self._process_computed_flags(obj, backend_file)
elif isinstance(obj, (Sources, GeneratedSources)):
if obj.relobjdir.startswith(self._supported_dirs):
backend_file.sources[obj.canonical_suffix].extend(obj.files)
elif isinstance(obj, HostSources):
backend_file.host_sources[obj.canonical_suffix].extend(obj.files)
+ elif isinstance(obj, VariablePassthru):
+ backend_file.variables = obj.variables
return True
def consume_finished(self):
CommonBackend.consume_finished(self)
# The approach here is similar to fastermake.py, but we
# simply write out the resulting files here.