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: I329d0fe3d94b77d395c3684f55ab01544ff7c18f
This commit is contained in:
Thiébaud Weksteen
2020-08-05 09:29:23 +02:00
parent 2f628baeae
commit 83ee52f4cd
3 changed files with 104 additions and 17 deletions

View File

@@ -75,7 +75,6 @@ func mergeDependencies(ctx android.SingletonContext, project *rustProjectJson,
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, childCrateName, ok := appendLibraryAndDeps(ctx, project, knownCrates, child)
if !ok {
@@ -116,8 +115,11 @@ func appendLibraryAndDeps(ctx android.SingletonContext, project *rustProjectJson
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)