--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -25,16 +25,17 @@ from ..frontend.data import (
ComputedFlags,
ContextDerived,
Defines,
FinalTargetFiles,
FinalTargetPreprocessedFiles,
GeneratedFile,
GeneratedSources,
HostDefines,
+ HostSources,
JARManifest,
ObjdirFiles,
PerSourceFlag,
Sources,
)
from ..util import (
FileAvoidWrite,
expand_variables,
@@ -58,16 +59,17 @@ class BackendTupfile(object):
self.rules_included = False
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.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)
@@ -112,35 +114,38 @@ class BackendTupfile(object):
# platform) without shelling out to a subprocess.
self.rule(
cmd=['!tup_ln'],
inputs=[source],
outputs=outputs,
)
def gen_sources_rules(self, extra_inputs):
+ sources = self.sources
+ host_sources = self.host_sources
compilers = [
- ('.S', 'AS', 'ASFLAGS'),
- ('.cpp', 'CXX', 'CXXFLAGS'),
- ('.c', 'CC', 'CFLAGS'),
+ (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_'),
]
- for extension, compiler, flags in compilers:
- srcs = sorted(self.sources[extension])
- for src in srcs:
+ for srcs, compiler, flags, 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)]
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'])
self.rule(
cmd=cmd,
inputs=[src],
extra_inputs=extra_inputs,
- outputs=['%B.o'],
+ outputs=[prefix + '%B.o'],
display='%s %%f' % compiler,
)
def export_shell(self):
if not self.shell_exported:
# These are used by mach/mixin/process.py to determine the current
# shell.
for var in ('SHELL', 'MOZILLABUILD', 'COMSPEC'):
@@ -268,16 +273,18 @@ class TupOnly(CommonBackend, PartialBack
self._consume_jar_manifest(obj)
elif isinstance(obj, PerSourceFlag):
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)
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.