summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2021-11-26 11:19:42 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-11-26 11:19:42 +0000
commita3ee4aadce16fa271b77793af127a3645de44ebc (patch)
tree17bb1674a79cb605ddc0bcd6c6a19983b875cee4 /android
parentfe87ccef2a677341bad15a8fad84fb913a126ab4 (diff)
parente65c3aee021fda3e7d37cae5064080effff73ecf (diff)
Merge "Fix prebuilt selection logic for cc_prebuilt_library_headers."
Diffstat (limited to 'android')
-rw-r--r--android/prebuilt.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/android/prebuilt.go b/android/prebuilt.go
index e18989271..b0a4f434f 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -97,7 +97,10 @@ type ConfigVarProperties struct {
type Prebuilt struct {
properties PrebuiltProperties
- srcsSupplier PrebuiltSrcsSupplier
+ // nil if the prebuilt has no srcs property at all. See InitPrebuiltModuleWithoutSrcs.
+ srcsSupplier PrebuiltSrcsSupplier
+
+ // "-" if the prebuilt has no srcs property at all. See InitPrebuiltModuleWithoutSrcs.
srcsPropertyName string
}
@@ -177,6 +180,23 @@ func (p *Prebuilt) UsePrebuilt() bool {
// Return the src value or nil if it is not available.
type PrebuiltSrcsSupplier func(ctx BaseModuleContext, prebuilt Module) []string
+func initPrebuiltModuleCommon(module PrebuiltInterface) *Prebuilt {
+ p := module.Prebuilt()
+ module.AddProperties(&p.properties)
+ module.base().customizableProperties = module.GetProperties()
+ return p
+}
+
+// Initialize the module as a prebuilt module that has no dedicated property that lists its
+// sources. SingleSourcePathFromSupplier should not be called for this module.
+//
+// This is the case e.g. for header modules, which provides the headers in source form
+// regardless whether they are prebuilt or not.
+func InitPrebuiltModuleWithoutSrcs(module PrebuiltInterface) {
+ p := initPrebuiltModuleCommon(module)
+ p.srcsPropertyName = "-"
+}
+
// Initialize the module as a prebuilt module that uses the provided supplier to access the
// prebuilt sources of the module.
//
@@ -190,10 +210,6 @@ type PrebuiltSrcsSupplier func(ctx BaseModuleContext, prebuilt Module) []string
// The provided property name is used to provide helpful error messages in the event that
// a problem arises, e.g. calling SingleSourcePath() when more than one source is provided.
func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier PrebuiltSrcsSupplier, srcsPropertyName string) {
- p := module.Prebuilt()
- module.AddProperties(&p.properties)
- module.base().customizableProperties = module.GetProperties()
-
if srcsSupplier == nil {
panic(fmt.Errorf("srcsSupplier must not be nil"))
}
@@ -201,6 +217,7 @@ func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier Pr
panic(fmt.Errorf("srcsPropertyName must not be empty"))
}
+ p := initPrebuiltModuleCommon(module)
p.srcsSupplier = srcsSupplier
p.srcsPropertyName = srcsPropertyName
}
@@ -336,7 +353,7 @@ func PrebuiltSourceDepsMutator(ctx BottomUpMutatorContext) {
func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
m := ctx.Module()
if p := GetEmbeddedPrebuilt(m); p != nil {
- if p.srcsSupplier == nil {
+ if p.srcsSupplier == nil && p.srcsPropertyName == "" {
panic(fmt.Errorf("prebuilt module did not have InitPrebuiltModule called on it"))
}
if !p.properties.SourceExists {