rust: validate existence of library source
While rust_bindgen modules may be interpreted as libraries, they do not
have a reference to the generated source until bindgen has been
executed. For now, ignore these modules.
Update the unit tests to cover the rust_bindgen case.
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162881856
Change-Id: Ie736d7ebb115f2c1f9a90be006c972ce24265c6a
diff --git a/rust/project_json.go b/rust/project_json.go
index 41dd194..7537540 100644
--- a/rust/project_json.go
+++ b/rust/project_json.go
@@ -75,7 +75,6 @@
knownCrates map[string]crateInfo, module android.Module,
crate *rustProjectCrate, deps map[string]int) {
- //TODO(tweek): The stdlib dependencies do not appear here. We need to manually add them.
ctx.VisitDirectDeps(module, func(child android.Module) {
childId, childName, ok := appendLibraryAndDeps(ctx, project, knownCrates, child)
if !ok {
@@ -115,8 +114,11 @@
return cInfo.ID, crateName, true
}
crate := rustProjectCrate{Deps: make([]rustProjectDep, 0), Cfgs: make([]string, 0)}
- src := rustLib.baseCompiler.Properties.Srcs[0]
- crate.RootModule = path.Join(ctx.ModuleDir(rModule), src)
+ srcs := rustLib.baseCompiler.Properties.Srcs
+ if len(srcs) == 0 {
+ return 0, "", false
+ }
+ crate.RootModule = path.Join(ctx.ModuleDir(rModule), srcs[0])
crate.Edition = rustLib.baseCompiler.edition()
deps := make(map[string]int)