diff options
author | ThiƩbaud Weksteen <tweek@google.com> | 2020-12-07 13:40:19 +0100 |
---|---|---|
committer | ThiƩbaud Weksteen <tweek@google.com> | 2020-12-07 14:45:09 +0100 |
commit | fa5feae43c3102ce62efcb6fe305e37b523d269b (patch) | |
tree | dcaa441cc9ff218ed21dd9902aad8b144f869c99 /rust/project_json_test.go | |
parent | 5e2697117f3381c30de36df8789109d82cbea326 (diff) |
Add dependencies for source-generated crates
When using SourceProviders, the dependency tree does not include
directly the source variant, only the built variant. For instance:
liba --> libbingena_rlib --> libbingena_source
However, libbindgena_rlib did not have a source associated with the
module, and was therefore not added as a dependency. Modify the logic so
that a SourceProvider library will find the right variant and always
have a source defined.
Adds display_name fields to the crate description to ease debugging.
Test: rust-analyzer analysis-stats .
Bug: 174158339
Change-Id: Id65708d57cd176f7e1da353f4a5f7ad65b003090
Diffstat (limited to 'rust/project_json_test.go')
-rw-r--r-- | rust/project_json_test.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/rust/project_json_test.go b/rust/project_json_test.go index aff16978b..ba66215c5 100644 --- a/rust/project_json_test.go +++ b/rust/project_json_test.go @@ -119,9 +119,9 @@ func TestProjectJsonDep(t *testing.T) { func TestProjectJsonBinary(t *testing.T) { bp := ` rust_binary { - name: "liba", - srcs: ["a/src/lib.rs"], - crate_name: "a" + name: "libz", + srcs: ["z/src/lib.rs"], + crate_name: "z" } ` jsonContent := testProjectJson(t, bp) @@ -132,7 +132,7 @@ func TestProjectJsonBinary(t *testing.T) { if !ok { t.Fatalf("Unexpected type for root_module: %v", crate["root_module"]) } - if rootModule == "a/src/lib.rs" { + if rootModule == "z/src/lib.rs" { return } } @@ -142,10 +142,10 @@ func TestProjectJsonBinary(t *testing.T) { func TestProjectJsonBindGen(t *testing.T) { bp := ` rust_library { - name: "liba", - srcs: ["src/lib.rs"], + name: "libd", + srcs: ["d/src/lib.rs"], rlibs: ["libbindings1"], - crate_name: "a" + crate_name: "d" } rust_bindgen { name: "libbindings1", @@ -155,10 +155,10 @@ func TestProjectJsonBindGen(t *testing.T) { wrapper_src: "src/any.h", } rust_library_host { - name: "libb", - srcs: ["src/lib.rs"], + name: "libe", + srcs: ["e/src/lib.rs"], rustlibs: ["libbindings2"], - crate_name: "b" + crate_name: "e" } rust_bindgen_host { name: "libbindings2", @@ -190,6 +190,19 @@ func TestProjectJsonBindGen(t *testing.T) { } } } + // Check that liba depends on libbindings1 + if strings.Contains(rootModule, "d/src/lib.rs") { + found := false + for _, depName := range validateDependencies(t, crate) { + if depName == "bindings1" { + found = true + break + } + } + if !found { + t.Errorf("liba does not depend on libbindings1: %v", crate) + } + } } } |