Merge "Don't evaluate the enabled property in a defaultable hook" into main am: c379ea0fd4 am: 9e67f9499a

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3264841

Change-Id: Ie75437c9cd18539d3a670080f40378e6a4a49d94
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-09-12 20:42:00 +00:00
committed by Automerger Merge Worker
2 changed files with 19 additions and 5 deletions

View File

@@ -1346,6 +1346,14 @@ func (m *ModuleBase) Enabled(ctx ConfigurableEvaluatorContext) bool {
return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
}
// Returns a copy of the enabled property, useful for passing it on to sub-modules
func (m *ModuleBase) EnabledProperty() proptools.Configurable[bool] {
if m.commonProperties.ForcedDisabled {
return proptools.NewSimpleConfigurable(false)
}
return m.commonProperties.Enabled.Clone()
}
func (m *ModuleBase) Disable() {
m.commonProperties.ForcedDisabled = true
}

View File

@@ -1727,6 +1727,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
staticLibs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs)
props := struct {
Name *string
Enabled proptools.Configurable[bool]
Visibility []string
Libs []string
Static_libs proptools.Configurable[[]string]
@@ -1734,6 +1735,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
Stem *string
}{
Name: proptools.StringPtr(module.implLibraryModuleName()),
Enabled: module.EnabledProperty(),
Visibility: visibility,
Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),
@@ -1762,6 +1764,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
type libraryProperties struct {
Name *string
Enabled proptools.Configurable[bool]
Visibility []string
Srcs []string
Installable *bool
@@ -1788,6 +1791,7 @@ type libraryProperties struct {
func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
props := libraryProperties{}
props.Enabled = module.EnabledProperty()
props.Visibility = []string{"//visibility:override", "//visibility:private"}
// sources are generated from the droiddoc
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
@@ -1838,6 +1842,7 @@ func (module *SdkLibrary) createExportableStubsLibrary(mctx android.DefaultableH
func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookContext, apiScope *apiScope, name string, scopeSpecificDroidstubsArgs []string) {
props := struct {
Name *string
Enabled proptools.Configurable[bool]
Visibility []string
Srcs []string
Installable *bool
@@ -1879,6 +1884,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
// * libs (static_libs/libs)
props.Name = proptools.StringPtr(name)
props.Enabled = module.EnabledProperty()
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility)
props.Srcs = append(props.Srcs, module.properties.Srcs...)
props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...)
@@ -2004,6 +2010,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
props := struct {
Name *string
Enabled proptools.Configurable[bool]
Visibility []string
Api_contributions []string
Libs proptools.Configurable[[]string]
@@ -2016,6 +2023,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
}{}
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
props.Enabled = module.EnabledProperty()
props.Visibility = []string{"//visibility:override", "//visibility:private"}
apiContributions := []string{}
@@ -2066,6 +2074,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope, doDist bool) libraryProperties {
props := libraryProperties{}
props.Enabled = module.EnabledProperty()
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
props.Sdk_version = proptools.StringPtr(sdkVersion)
@@ -2158,6 +2167,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
}
props := struct {
Name *string
Enabled proptools.Configurable[bool]
Lib_name *string
Apex_available []string
On_bootclasspath_since *string
@@ -2168,6 +2178,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
Uses_libs_dependencies []string
}{
Name: proptools.StringPtr(module.xmlPermissionsModuleName()),
Enabled: module.EnabledProperty(),
Lib_name: proptools.StringPtr(module.BaseModuleName()),
Apex_available: module.ApexProperties.Apex_available,
On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since,
@@ -2263,11 +2274,6 @@ func (module *SdkLibrary) getApiDir() string {
// runtime libs and xml file. If requested, the stubs and docs are created twice
// once for public API level and once for system API level
func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) {
// If the module has been disabled then don't create any child modules.
if !module.Enabled(mctx) {
return
}
if len(module.properties.Srcs) == 0 {
mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
return