Merge "rust: Allow modules to use only generated sources" am: 0ad64f50fd
am: 951f8669c5
am: 41b2c884cc
am: f0c5abed26
am: 6d1108916d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1792593 Change-Id: I9ff7d5d6a43277ae2f2c16f97b94b9ba870fc459
This commit is contained in:
@@ -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:]
|
||||
}
|
||||
|
Reference in New Issue
Block a user