summaryrefslogtreecommitdiff
path: root/rust/project_json.go
diff options
context:
space:
mode:
author ThiƩbaud Weksteen <tweek@google.com> 2020-08-05 09:29:23 +0200
committer ThiƩbaud Weksteen <tweek@google.com> 2020-08-05 11:29:33 +0200
commit891cd578c70911416775511654ad396fc95be054 (patch)
treefc9f398cb3e36adeb09a76e104e19716c2b9b857 /rust/project_json.go
parentda931d4abdd32d97c518ffb901c6631317d78b80 (diff)
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
Diffstat (limited to 'rust/project_json.go')
-rw-r--r--rust/project_json.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/rust/project_json.go b/rust/project_json.go
index 41dd194ee..75375408c 100644
--- a/rust/project_json.go
+++ b/rust/project_json.go
@@ -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, childName, ok := appendLibraryAndDeps(ctx, project, knownCrates, child)
if !ok {
@@ -115,8 +114,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)