Bug 1560442 - Allow to build rust code in a separate tier. r=froydnj

When the `MOZ_RUST_TIER` environment variable is set, we enable a separate
tier that builds rust code only. This is useful to measure build times for
rust code separately from other compilations.

Differential Revision: https://phabricator.services.mozilla.com/D35501

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-06-21 13:20:17 +00:00
Родитель 46f3d5ee22
Коммит c74d2769cd
2 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -42,7 +42,7 @@ endif # WINNT
ifndef INCLUDED_AUTOCONF_MK
default::
else
TIERS := $(if $(MOZ_ARTIFACT_BUILDS),artifact )$(if $(MOZ_EME_WIN32_ARTIFACT),win32-artifact )$(if $(MOZ_ANDROID_FAT_AAR_ARCHITECTURES),android-fat-aar-artifact )pre-export export $(if $(COMPILE_ENVIRONMENT),compile )misc libs tools$(if $(filter check recurse_check,$(MAKECMDGOALS)), check)
TIERS := $(if $(MOZ_ARTIFACT_BUILDS),artifact )$(if $(MOZ_EME_WIN32_ARTIFACT),win32-artifact )$(if $(MOZ_ANDROID_FAT_AAR_ARCHITECTURES),android-fat-aar-artifact )pre-export export $(if $(COMPILE_ENVIRONMENT),$(if $(MOZ_RUST_TIER),rust )compile )misc libs tools$(if $(filter check recurse_check,$(MAKECMDGOALS)), check)
endif
# These defines are used to support the twin-topsrcdir model for comm-central.

Просмотреть файл

@ -401,7 +401,7 @@ class RecursiveMakeBackend(CommonBackend):
self._traversal = RecursiveMakeTraversal()
self._compile_graph = OrderedDefaultDict(set)
self._rust_dirs = set()
self._rust_targets = set()
self._no_skip = {
'export': set(),
@ -632,17 +632,17 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(obj, RustProgram):
self._process_rust_program(obj, backend_file)
self._rust_dirs.add(obj.relobjdir)
# Hook the program into the compile graph.
build_target = self._build_target_for_obj(obj)
self._compile_graph[build_target]
self._rust_targets.add(build_target)
elif isinstance(obj, HostRustProgram):
self._process_host_rust_program(obj, backend_file)
self._rust_dirs.add(obj.relobjdir)
# Hook the program into the compile graph.
build_target = self._build_target_for_obj(obj)
self._compile_graph[build_target]
self._rust_targets.add(build_target)
elif isinstance(obj, RustTests):
self._process_rust_tests(obj, backend_file)
@ -680,13 +680,13 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(obj, RustLibrary):
self.backend_input_files.add(obj.cargo_file)
self._process_rust_library(obj, backend_file)
self._rust_dirs.add(obj.relobjdir)
# No need to call _process_linked_libraries, because Rust
# libraries are self-contained objects at this point.
# Hook the library into the compile graph.
build_target = self._build_target_for_obj(obj)
self._compile_graph[build_target]
self._rust_targets.add(build_target)
elif isinstance(obj, SharedLibrary):
self._process_shared_library(obj, backend_file)
@ -820,10 +820,12 @@ class RecursiveMakeBackend(CommonBackend):
# Directories containing rust compilations don't generally depend
# on other directories in the tree, so putting them first here will
# start them earlier in the build.
rule.add_dependencies(
chain((r for r in roots if mozpath.dirname(r) in self._rust_dirs),
(r for r in roots if mozpath.dirname(r) not in self._rust_dirs))
)
rust_roots = [r for r in roots if r in self._rust_targets]
if category == 'compile' and rust_roots:
rust_rule = root_deps_mk.create_rule(['recurse_rust'])
rust_rule.add_dependencies(rust_roots)
rule.add_dependencies(chain(rust_roots, roots))
for target, deps in sorted(graph.items()):
if deps:
rule = root_deps_mk.create_rule([target])