From fa5feae43c3102ce62efcb6fe305e37b523d269b Mon Sep 17 00:00:00 2001 From: ThiƩbaud Weksteen Date: Mon, 7 Dec 2020 13:40:19 +0100 Subject: 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 --- rust/project_json_test.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'rust/project_json_test.go') 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) + } + } } } -- cgit v1.2.3-59-g8ed1b