summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2021-08-13 19:37:04 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-08-13 19:37:04 +0000
commit0ad64f50fd60c4b37c250d1011bad0bbeca978dd (patch)
tree26aa056c036e707356323e0889a7deb4c400e051 /rust/compiler.go
parent8711c5cf8c90ddae7971f0c1deeae2edaa1ca7ed (diff)
parente4db0036d7612cf68b63e52c13f6904cab461ce5 (diff)
Merge "rust: Allow modules to use only generated sources"
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index e0d89ac1d..d9e21ff3a 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -65,7 +65,11 @@ const (
)
type BaseCompilerProperties struct {
- // path to the source file that is the main entry point of the program (e.g. main.rs or lib.rs)
+ // path to the source file that is the main entry point of the program (e.g. main.rs or lib.rs).
+ // Only a single source file can be defined. Modules which generate source can be included by prefixing
+ // the module name with ":", for example ":libfoo_bindgen"
+ //
+ // If no source file is defined, a single generated source module can be defined to be used as the main source.
Srcs []string `android:"path,arch_variant"`
// name of the lint set that should be used to validate this module.
@@ -438,12 +442,18 @@ func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, andr
srcIndex = i
}
}
- if numSrcs != 1 {
+ if numSrcs > 1 {
ctx.PropertyErrorf("srcs", incorrectSourcesError)
}
+
+ // If a main source file is not provided we expect only a single SourceProvider module to be defined
+ // within srcs, with the expectation that the first source it provides is the entry point.
if srcIndex != 0 {
ctx.PropertyErrorf("srcs", "main source file must be the first in srcs")
+ } else if numSrcs > 1 {
+ ctx.PropertyErrorf("srcs", "only a single generated source module can be defined without a main source file.")
}
+
paths := android.PathsForModuleSrc(ctx, srcs)
return paths[srcIndex], paths[1:]
}