diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 6d51a7a9254d..954c03284700 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -539,13 +539,16 @@ class RecursiveMakeBackend(CommonBackend): backend_file.write('JAR_MANIFEST := %s\n' % obj.path.full_path) elif isinstance(obj, RustProgram): - # Note that for these and host Rust programs, we don't need to - # bother with linked libraries, because Cargo will take care of - # all of that for us. self._process_rust_program(obj, backend_file) + # Hook the program into the compile graph. + build_target = self._build_target_for_obj(obj) + self._compile_graph[build_target] elif isinstance(obj, HostRustProgram): self._process_host_rust_program(obj, backend_file) + # Hook the program into the compile graph. + build_target = self._build_target_for_obj(obj) + self._compile_graph[build_target] elif isinstance(obj, Program): self._process_program(obj.program, backend_file) diff --git a/python/mozbuild/mozbuild/test/backend/data/rust-programs/Cargo.toml b/python/mozbuild/mozbuild/test/backend/data/rust-programs/code/Cargo.toml similarity index 100% rename from python/mozbuild/mozbuild/test/backend/data/rust-programs/Cargo.toml rename to python/mozbuild/mozbuild/test/backend/data/rust-programs/code/Cargo.toml diff --git a/python/mozbuild/mozbuild/test/backend/data/rust-programs/code/moz.build b/python/mozbuild/mozbuild/test/backend/data/rust-programs/code/moz.build new file mode 100644 index 000000000000..e1f939043c64 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/rust-programs/code/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +RUST_PROGRAMS += ['target'] +HOST_RUST_PROGRAMS += ['host'] diff --git a/python/mozbuild/mozbuild/test/backend/data/rust-programs/moz.build b/python/mozbuild/mozbuild/test/backend/data/rust-programs/moz.build index e1f939043c64..a56dad81e950 100644 --- a/python/mozbuild/mozbuild/test/backend/data/rust-programs/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/rust-programs/moz.build @@ -2,5 +2,4 @@ # Any copyright is dedicated to the Public Domain. # http://creativecommons.org/publicdomain/zero/1.0/ -RUST_PROGRAMS += ['target'] -HOST_RUST_PROGRAMS += ['host'] +DIRS += ['code'] diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index f504ee6ac5a1..b09d6f6eb756 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -768,11 +768,11 @@ class TestRecursiveMakeBackend(BackendTester): """Test that {HOST_,}RUST_PROGRAMS are written to backend.mk correctly.""" env = self._consume('rust-programs', RecursiveMakeBackend) - backend_path = mozpath.join(env.topobjdir, 'backend.mk') + backend_path = mozpath.join(env.topobjdir, 'code/backend.mk') lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]] expected = [ - 'CARGO_FILE := %s/Cargo.toml' % env.topsrcdir, + 'CARGO_FILE := %s/code/Cargo.toml' % env.topsrcdir, 'RUST_PROGRAMS += i686-pc-windows-msvc/release/target.exe', 'RUST_CARGO_PROGRAMS += target', 'HOST_RUST_PROGRAMS += i686-pc-windows-msvc/release/host.exe', @@ -781,6 +781,11 @@ class TestRecursiveMakeBackend(BackendTester): self.assertEqual(lines, expected) + root_deps_path = mozpath.join(env.topobjdir, 'root-deps.mk') + lines = [l.strip() for l in open(root_deps_path, 'rt').readlines()] + + self.assertTrue(any(l == 'recurse_compile: code/host code/target' for l in lines)) + def test_final_target(self): """Test that FINAL_TARGET is written to backend.mk correctly.""" env = self._consume('final_target', RecursiveMakeBackend)