diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-05-15 17:36:30 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-07-08 23:50:00 -0700 |
commit | bbd25aeb428edaa7fb332cc0a6771aeede38e286 (patch) | |
tree | 315941dd2e085d7a332fbc0122b9673dab212653 /rust/rust_test.go | |
parent | ecc495fd096871feff67f598fc768ba972a84dd9 (diff) |
Specify module dependency in the srcs list
* "srcs" list contains one main Rust source file,
followed by optional dependent modules.
* A dependent module included in the "srcs" list is
the module name prefixed with ":".
* Add a simple test.
Bug: 160331255
Test: make and manual test build dependencies on genrule modules
Change-Id: I4f079138c2599158810b6412fce81b612a3f64a4
Diffstat (limited to 'rust/rust_test.go')
-rw-r--r-- | rust/rust_test.go | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/rust/rust_test.go b/rust/rust_test.go index 08bc8ca48..e80392589 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -61,6 +61,7 @@ func testConfig(bp string) android.Config { "foo.rs": nil, "foo.c": nil, "src/bar.rs": nil, + "src/any.h": nil, "liby.so": nil, "libz.so": nil, } @@ -181,7 +182,7 @@ func TestDepsTracking(t *testing.T) { } rust_library_host_rlib { name: "librlib", - srcs: ["foo.rs"], + srcs: ["foo.rs", ":my_generator"], crate_name: "rlib", } rust_proc_macro { @@ -189,17 +190,38 @@ func TestDepsTracking(t *testing.T) { srcs: ["foo.rs"], crate_name: "pm", } + genrule { + name: "my_generator", + tools: ["any_rust_binary"], + cmd: "$(location) -o $(out) $(in)", + srcs: ["src/any.h"], + out: ["src/any.rs"], + } rust_binary_host { - name: "fizz-buzz", + name: "fizz-buzz-dep", dylibs: ["libdylib"], rlibs: ["librlib"], proc_macros: ["libpm"], static_libs: ["libstatic"], shared_libs: ["libshared"], - srcs: ["foo.rs"], + srcs: [ + "foo.rs", + ":my_generator", + ], } `) - module := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Module().(*Module) + module := ctx.ModuleForTests("fizz-buzz-dep", "linux_glibc_x86_64").Module().(*Module) + rlibmodule := ctx.ModuleForTests("librlib", "linux_glibc_x86_64_rlib").Module().(*Module) + + srcs := module.compiler.(*binaryDecorator).baseCompiler.Properties.Srcs + if len(srcs) != 2 || !android.InList(":my_generator", srcs) { + t.Errorf("missing module dependency in fizz-buzz)") + } + + srcs = rlibmodule.compiler.(*libraryDecorator).baseCompiler.Properties.Srcs + if len(srcs) != 2 || !android.InList(":my_generator", srcs) { + t.Errorf("missing module dependency in rlib") + } // Since dependencies are added to AndroidMk* properties, we can check these to see if they've been picked up. if !android.InList("libdylib", module.Properties.AndroidMkDylibs) { |