Merge "Don't evaluate the enabled property in a defaultable hook" into main am: c379ea0fd4
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3264841 Change-Id: Ia9d10fa1fef3718c9aced086880b592c9a576f95 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1346,6 +1346,14 @@ func (m *ModuleBase) Enabled(ctx ConfigurableEvaluatorContext) bool {
|
|||||||
return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
|
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() {
|
func (m *ModuleBase) Disable() {
|
||||||
m.commonProperties.ForcedDisabled = true
|
m.commonProperties.ForcedDisabled = true
|
||||||
}
|
}
|
||||||
|
@@ -1727,6 +1727,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
|
|||||||
staticLibs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs)
|
staticLibs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs)
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Enabled proptools.Configurable[bool]
|
||||||
Visibility []string
|
Visibility []string
|
||||||
Libs []string
|
Libs []string
|
||||||
Static_libs proptools.Configurable[[]string]
|
Static_libs proptools.Configurable[[]string]
|
||||||
@@ -1734,6 +1735,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
|
|||||||
Stem *string
|
Stem *string
|
||||||
}{
|
}{
|
||||||
Name: proptools.StringPtr(module.implLibraryModuleName()),
|
Name: proptools.StringPtr(module.implLibraryModuleName()),
|
||||||
|
Enabled: module.EnabledProperty(),
|
||||||
Visibility: visibility,
|
Visibility: visibility,
|
||||||
|
|
||||||
Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),
|
Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),
|
||||||
@@ -1762,6 +1764,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
|
|||||||
|
|
||||||
type libraryProperties struct {
|
type libraryProperties struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Enabled proptools.Configurable[bool]
|
||||||
Visibility []string
|
Visibility []string
|
||||||
Srcs []string
|
Srcs []string
|
||||||
Installable *bool
|
Installable *bool
|
||||||
@@ -1788,6 +1791,7 @@ type libraryProperties struct {
|
|||||||
|
|
||||||
func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
|
func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
|
||||||
props := libraryProperties{}
|
props := libraryProperties{}
|
||||||
|
props.Enabled = module.EnabledProperty()
|
||||||
props.Visibility = []string{"//visibility:override", "//visibility:private"}
|
props.Visibility = []string{"//visibility:override", "//visibility:private"}
|
||||||
// sources are generated from the droiddoc
|
// sources are generated from the droiddoc
|
||||||
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
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) {
|
func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookContext, apiScope *apiScope, name string, scopeSpecificDroidstubsArgs []string) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Enabled proptools.Configurable[bool]
|
||||||
Visibility []string
|
Visibility []string
|
||||||
Srcs []string
|
Srcs []string
|
||||||
Installable *bool
|
Installable *bool
|
||||||
@@ -1879,6 +1884,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
|||||||
// * libs (static_libs/libs)
|
// * libs (static_libs/libs)
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(name)
|
props.Name = proptools.StringPtr(name)
|
||||||
|
props.Enabled = module.EnabledProperty()
|
||||||
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility)
|
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility)
|
||||||
props.Srcs = append(props.Srcs, module.properties.Srcs...)
|
props.Srcs = append(props.Srcs, module.properties.Srcs...)
|
||||||
props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_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) {
|
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Enabled proptools.Configurable[bool]
|
||||||
Visibility []string
|
Visibility []string
|
||||||
Api_contributions []string
|
Api_contributions []string
|
||||||
Libs proptools.Configurable[[]string]
|
Libs proptools.Configurable[[]string]
|
||||||
@@ -2016,6 +2023,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
|
|||||||
}{}
|
}{}
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
|
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
|
||||||
|
props.Enabled = module.EnabledProperty()
|
||||||
props.Visibility = []string{"//visibility:override", "//visibility:private"}
|
props.Visibility = []string{"//visibility:override", "//visibility:private"}
|
||||||
|
|
||||||
apiContributions := []string{}
|
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 {
|
func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope, doDist bool) libraryProperties {
|
||||||
props := libraryProperties{}
|
props := libraryProperties{}
|
||||||
|
|
||||||
|
props.Enabled = module.EnabledProperty()
|
||||||
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
|
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
|
||||||
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
||||||
props.Sdk_version = proptools.StringPtr(sdkVersion)
|
props.Sdk_version = proptools.StringPtr(sdkVersion)
|
||||||
@@ -2158,6 +2167,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
|
|||||||
}
|
}
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Enabled proptools.Configurable[bool]
|
||||||
Lib_name *string
|
Lib_name *string
|
||||||
Apex_available []string
|
Apex_available []string
|
||||||
On_bootclasspath_since *string
|
On_bootclasspath_since *string
|
||||||
@@ -2168,6 +2178,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
|
|||||||
Uses_libs_dependencies []string
|
Uses_libs_dependencies []string
|
||||||
}{
|
}{
|
||||||
Name: proptools.StringPtr(module.xmlPermissionsModuleName()),
|
Name: proptools.StringPtr(module.xmlPermissionsModuleName()),
|
||||||
|
Enabled: module.EnabledProperty(),
|
||||||
Lib_name: proptools.StringPtr(module.BaseModuleName()),
|
Lib_name: proptools.StringPtr(module.BaseModuleName()),
|
||||||
Apex_available: module.ApexProperties.Apex_available,
|
Apex_available: module.ApexProperties.Apex_available,
|
||||||
On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since,
|
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
|
// 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
|
// once for public API level and once for system API level
|
||||||
func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) {
|
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 {
|
if len(module.properties.Srcs) == 0 {
|
||||||
mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
|
mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user