diff options
101 files changed, 1149 insertions, 335 deletions
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg index 317f5c434..e8cad7d7b 100644 --- a/PREUPLOAD.cfg +++ b/PREUPLOAD.cfg @@ -4,3 +4,4 @@ bpfmt = true [Hook Scripts] do_not_use_DO_NOT_MERGE = ${REPO_ROOT}/build/soong/scripts/check_do_not_merge.sh ${PREUPLOAD_COMMIT} +aosp_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "." diff --git a/TEST_MAPPING b/TEST_MAPPING index 9f386ca49..6eabd7c14 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -3,5 +3,14 @@ { "path": "packages/modules/SdkExtensions" } + ], + + "postsubmit": [ + { + "name": "MicrodroidHostTestCases" + }, + { + "name": "MicrodroidTestApp" + } ] } diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index d29e3122d..71a64dddc 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -73,8 +73,9 @@ func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext if len(module.properties.Package) == 0 { ctx.PropertyErrorf("package", "missing package property") } - // TODO(b/311155208): Add mandatory check for container after all pre-existing - // ones are changed. + if len(module.properties.Container) == 0 { + ctx.PropertyErrorf("container", "missing container property") + } // Add a dependency on the aconfig_value_sets defined in // RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go index 5201fedb1..c37274c71 100644 --- a/aconfig/aconfig_declarations_test.go +++ b/aconfig/aconfig_declarations_test.go @@ -88,19 +88,49 @@ func TestAconfigDeclarationsWithContainer(t *testing.T) { android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo") } -func TestAconfigDeclarationsWithoutContainer(t *testing.T) { - bp := ` - aconfig_declarations { - name: "module_name", - package: "com.example.package", - srcs: [ - "foo.aconfig", - ], - } - ` - result := runTest(t, android.FixtureExpectsNoErrors, bp) - - module := result.ModuleForTests("module_name", "") - rule := module.Rule("aconfig") - android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0) +func TestMandatoryProperties(t *testing.T) { + testCases := []struct { + name string + expectedError string + bp string + }{ + { + name: "Srcs missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package", + container: "otherapex", + }`, + expectedError: `missing source files`, + }, + { + name: "Package missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + container: "otherapex", + srcs: ["foo.aconfig"], + }`, + expectedError: `missing package property`, + }, + { + name: "Container missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package", + srcs: ["foo.aconfig"], + }`, + expectedError: `missing container property`, + }, + } + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError) + android.GroupFixturePreparers(PrepareForTestWithAconfigBuildComponents). + ExtendWithErrorHandler(errorHandler). + RunTestWithBp(t, test.bp) + }) + } } diff --git a/aconfig/codegen/aconfig_declarations_group_test.go b/aconfig/codegen/aconfig_declarations_group_test.go index ec7cea383..c69d21ffd 100644 --- a/aconfig/codegen/aconfig_declarations_group_test.go +++ b/aconfig/codegen/aconfig_declarations_group_test.go @@ -15,9 +15,10 @@ package codegen import ( + "testing" + "android/soong/android" "android/soong/java" - "testing" ) func TestAconfigDeclarationsGroup(t *testing.T) { @@ -28,6 +29,7 @@ func TestAconfigDeclarationsGroup(t *testing.T) { aconfig_declarations { name: "foo-aconfig", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -39,6 +41,7 @@ func TestAconfigDeclarationsGroup(t *testing.T) { aconfig_declarations { name: "bar-aconfig", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go index cf9ffbd33..d01d13b61 100644 --- a/aconfig/codegen/cc_aconfig_library_test.go +++ b/aconfig/codegen/cc_aconfig_library_test.go @@ -50,6 +50,7 @@ func testCCCodegenModeHelper(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -112,6 +113,7 @@ func testIncorrectCCCodegenModeHelper(t *testing.T, bpMode string, err string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -167,6 +169,7 @@ func TestAndroidMkCcLibrary(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations_bar", package: "com.example.package", + container: "com.android.foo", srcs: ["bar.aconfig"], } @@ -241,6 +244,7 @@ func TestForceReadOnly(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go index de45b5cc3..87b54a47f 100644 --- a/aconfig/codegen/java_aconfig_library_test.go +++ b/aconfig/codegen/java_aconfig_library_test.go @@ -35,6 +35,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { aconfig_declarations { name: "my_aconfig_declarations_foo", package: "com.example.package.foo", + container: "system", srcs: ["foo.aconfig"], } @@ -46,6 +47,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { aconfig_declarations { name: "my_aconfig_declarations_bar", package: "com.example.package.bar", + container: "system", srcs: ["bar.aconfig"], } @@ -60,7 +62,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0] makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"] - android.EnsureListContainsSuffix(t, makeVar, "android_common/aconfig_merged.pb") + android.EnsureListContainsSuffix(t, makeVar, "android_common/system/aconfig_merged.pb") } func TestAndroidMkJavaLibrary(t *testing.T) { @@ -175,6 +177,7 @@ func testCodegenMode(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], exportable: true, } @@ -200,6 +203,7 @@ func testCodegenModeWithError(t *testing.T, bpMode string, err string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -234,3 +238,52 @@ func TestForceReadOnlyMode(t *testing.T) { func TestUnsupportedMode(t *testing.T) { testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode") } + +func TestMkEntriesMatchedContainer(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithAconfigBuildComponents, + java.PrepareForTestWithJavaDefaultModules). + ExtendWithErrorHandler(android.FixtureExpectsNoErrors). + RunTestWithBp(t, ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package.foo", + container: "system", + srcs: ["foo.aconfig"], + } + + java_aconfig_library { + name: "my_java_aconfig_library_foo", + aconfig_declarations: "my_aconfig_declarations_foo", + } + + aconfig_declarations { + name: "my_aconfig_declarations_bar", + package: "com.example.package.bar", + container: "system_ext", + srcs: ["bar.aconfig"], + } + + java_aconfig_library { + name: "my_java_aconfig_library_bar", + aconfig_declarations: "my_aconfig_declarations_bar", + } + + java_library { + name: "my_module", + srcs: [ + "src/foo.java", + ], + static_libs: [ + "my_java_aconfig_library_foo", + "my_java_aconfig_library_bar", + ], + platform_apis: true, + } + `) + + module := result.ModuleForTests("my_module", "android_common").Module() + entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0] + makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"] + android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb") +} diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go index fe28f9441..523b464c0 100644 --- a/aconfig/codegen/rust_aconfig_library_test.go +++ b/aconfig/codegen/rust_aconfig_library_test.go @@ -46,6 +46,7 @@ func TestRustAconfigLibrary(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -131,6 +132,7 @@ func testRustCodegenModeHelper(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } rust_aconfig_library { @@ -193,6 +195,7 @@ func testIncorrectRustCodegenModeHelper(t *testing.T, bpMode string, err string) aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } rust_aconfig_library { diff --git a/android/Android.bp b/android/Android.bp index f130d3aee..9ce8cdcd2 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -41,6 +41,7 @@ bootstrap_go_package { "buildinfo_prop.go", "config.go", "test_config.go", + "configurable_properties.go", "configured_jars.go", "csuite_config.go", "deapexer.go", @@ -60,6 +61,7 @@ bootstrap_go_package { "license_metadata.go", "license_sdk_member.go", "licenses.go", + "logtags.go", "makevars.go", "metrics.go", "module.go", diff --git a/android/androidmk.go b/android/androidmk.go index 07f7c58d0..66f42f97c 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -36,6 +36,7 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/bootstrap" "github.com/google/blueprint/pathtools" + "github.com/google/blueprint/proptools" ) func init() { @@ -541,6 +542,11 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint a.SetPath("LOCAL_SOONG_INSTALLED_MODULE", base.katiInstalls[len(base.katiInstalls)-1].to) a.SetString("LOCAL_SOONG_INSTALL_PAIRS", base.katiInstalls.BuiltInstalled()) a.SetPaths("LOCAL_SOONG_INSTALL_SYMLINKS", base.katiSymlinks.InstallPaths().Paths()) + } else { + // Soong may not have generated the install rule also when `no_full_install: true`. + // Mark this module as uninstallable in order to prevent Make from creating an + // install rule there. + a.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", proptools.Bool(base.commonProperties.No_full_install)) } if len(base.testData) > 0 { @@ -849,7 +855,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs * mod blueprint.Module, provider AndroidMkDataProvider) error { amod := mod.(Module).base() - if shouldSkipAndroidMkProcessing(amod) { + if shouldSkipAndroidMkProcessing(ctx, amod) { return nil } @@ -939,7 +945,7 @@ func WriteAndroidMkData(w io.Writer, data AndroidMkData) { func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, mod blueprint.Module, provider AndroidMkEntriesProvider) error { - if shouldSkipAndroidMkProcessing(mod.(Module).base()) { + if shouldSkipAndroidMkProcessing(ctx, mod.(Module).base()) { return nil } @@ -961,11 +967,11 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleIn return nil } -func ShouldSkipAndroidMkProcessing(module Module) bool { - return shouldSkipAndroidMkProcessing(module.base()) +func ShouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module Module) bool { + return shouldSkipAndroidMkProcessing(ctx, module.base()) } -func shouldSkipAndroidMkProcessing(module *ModuleBase) bool { +func shouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module *ModuleBase) bool { if !module.commonProperties.NamespaceExportedToMake { // TODO(jeffrygaston) do we want to validate that there are no modules being // exported to Kati that depend on this module? @@ -984,7 +990,7 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool { return true } - return !module.Enabled() || + return !module.Enabled(ctx) || module.commonProperties.HideFromMake || // Make does not understand LinuxBionic module.Os() == LinuxBionic || diff --git a/android/arch.go b/android/arch.go index cd8882bbd..e0c6908c1 100644 --- a/android/arch.go +++ b/android/arch.go @@ -486,7 +486,7 @@ func osMutator(bpctx blueprint.BottomUpMutatorContext) { // dependencies on OsType variants that are explicitly disabled in their // properties. The CommonOS variant will still depend on disabled variants // if they are disabled afterwards, e.g. in archMutator if - if module.Enabled() { + if module.Enabled(mctx) { mctx.AddInterVariantDependency(commonOsToOsSpecificVariantTag, commonOSVariant, module) } } @@ -511,7 +511,7 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module { var variants []Module mctx.VisitDirectDeps(func(m Module) { if mctx.OtherModuleDependencyTag(m) == commonOsToOsSpecificVariantTag { - if m.Enabled() { + if m.Enabled(mctx) { variants = append(variants, m) } } diff --git a/android/arch_test.go b/android/arch_test.go index 5021a67af..f0a58a90b 100644 --- a/android/arch_test.go +++ b/android/arch_test.go @@ -423,7 +423,7 @@ func TestArchMutator(t *testing.T) { variants := ctx.ModuleVariantsForTests(name) for _, variant := range variants { m := ctx.ModuleForTests(name, variant) - if m.Module().Enabled() { + if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) { ret = append(ret, variant) } } @@ -533,7 +533,7 @@ func TestArchMutatorNativeBridge(t *testing.T) { variants := ctx.ModuleVariantsForTests(name) for _, variant := range variants { m := ctx.ModuleForTests(name, variant) - if m.Module().Enabled() { + if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) { ret = append(ret, variant) } } diff --git a/android/base_module_context.go b/android/base_module_context.go index c5fe58578..296352057 100644 --- a/android/base_module_context.go +++ b/android/base_module_context.go @@ -325,7 +325,7 @@ func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag b return nil } - if !aModule.Enabled() { + if !aModule.Enabled(b) { if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) { if b.Config().AllowMissingDependencies() { b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) diff --git a/android/config.go b/android/config.go index 3ea9d4dfa..f6711e61f 100644 --- a/android/config.go +++ b/android/config.go @@ -818,12 +818,12 @@ func (c *config) GetenvWithDefault(key string, defaultValue string) string { } func (c *config) IsEnvTrue(key string) bool { - value := c.Getenv(key) + value := strings.ToLower(c.Getenv(key)) return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true" } func (c *config) IsEnvFalse(key string) bool { - value := c.Getenv(key) + value := strings.ToLower(c.Getenv(key)) return value == "0" || value == "n" || value == "no" || value == "off" || value == "false" } diff --git a/android/configurable_properties.go b/android/configurable_properties.go new file mode 100644 index 000000000..dad42fa1d --- /dev/null +++ b/android/configurable_properties.go @@ -0,0 +1,28 @@ +package android + +import "github.com/google/blueprint/proptools" + +// CreateSelectOsToBool is a utility function that makes it easy to create a +// Configurable property value that maps from os to a bool. Use an empty string +// to indicate a "default" case. +func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] { + var resultCases []proptools.ConfigurableCase[bool] + for pattern, value := range cases { + if pattern == "" { + resultCases = append(resultCases, proptools.NewConfigurableCase( + []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()}, + value, + )) + } else { + resultCases = append(resultCases, proptools.NewConfigurableCase( + []proptools.ConfigurablePattern{proptools.NewStringConfigurablePattern(pattern)}, + value, + )) + } + } + + return proptools.NewConfigurable( + []proptools.ConfigurableCondition{proptools.NewConfigurableCondition("os", nil)}, + resultCases, + ) +} diff --git a/android/early_module_context.go b/android/early_module_context.go index cf1b5fcab..23f4c90a2 100644 --- a/android/early_module_context.go +++ b/android/early_module_context.go @@ -173,5 +173,5 @@ func (e *earlyModuleContext) Namespace() *Namespace { } func (e *earlyModuleContext) OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) { - e.EarlyModuleContext.OtherModulePropertyErrorf(module, property, fmt, args) + e.EarlyModuleContext.OtherModulePropertyErrorf(module, property, fmt, args...) } diff --git a/android/gen_notice.go b/android/gen_notice.go index 1acc638e8..6815f6467 100644 --- a/android/gen_notice.go +++ b/android/gen_notice.go @@ -62,7 +62,7 @@ func (s *genNoticeBuildRules) GenerateBuildActions(ctx SingletonContext) { if mod == nil { continue } - if !mod.Enabled() { // don't depend on variants without build rules + if !mod.Enabled(ctx) { // don't depend on variants without build rules continue } modules = append(modules, mod) diff --git a/android/license_metadata.go b/android/license_metadata.go index eabb1b170..3fea02909 100644 --- a/android/license_metadata.go +++ b/android/license_metadata.go @@ -36,7 +36,7 @@ var ( func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { base := ctx.Module().base() - if !base.Enabled() { + if !base.Enabled(ctx) { return } @@ -69,7 +69,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { if dep == nil { return } - if !dep.Enabled() { + if !dep.Enabled(ctx) { return } @@ -195,7 +195,7 @@ func isContainerFromFileExtensions(installPaths InstallPaths, builtPaths Paths) for _, path := range paths { switch path.Ext() { - case ".zip", ".tar", ".tgz", ".tar.gz", ".img", ".srcszip", ".apex": + case ".zip", ".tar", ".tgz", ".tar.gz", ".img", ".srcszip", ".apex", ".capex": return true } } diff --git a/android/logtags.go b/android/logtags.go new file mode 100644 index 000000000..d11cccf4f --- /dev/null +++ b/android/logtags.go @@ -0,0 +1,56 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package android + +import "github.com/google/blueprint" + +func init() { + RegisterParallelSingletonType("logtags", LogtagsSingleton) +} + +type LogtagsInfo struct { + Logtags Paths +} + +var LogtagsProviderKey = blueprint.NewProvider[*LogtagsInfo]() + +func LogtagsSingleton() Singleton { + return &logtagsSingleton{} +} + +type logtagsSingleton struct{} + +func MergedLogtagsPath(ctx PathContext) OutputPath { + return PathForIntermediates(ctx, "all-event-log-tags.txt") +} + +func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) { + var allLogtags Paths + ctx.VisitAllModules(func(module Module) { + if !module.ExportedToMake() { + return + } + if logtagsInfo, ok := SingletonModuleProvider(ctx, module, LogtagsProviderKey); ok { + allLogtags = append(allLogtags, logtagsInfo.Logtags...) + } + }) + + builder := NewRuleBuilder(pctx, ctx) + builder.Command(). + BuiltTool("merge-event-log-tags"). + FlagWithOutput("-o ", MergedLogtagsPath(ctx)). + Inputs(SortedUniquePaths(allLogtags)) + builder.Build("all-event-log-tags.txt", "merge logtags") +} diff --git a/android/makevars.go b/android/makevars.go index 4039e7edb..e73645fdc 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -98,6 +98,7 @@ type MakeVarsContext interface { BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) + OtherModulePropertyErrorf(module Module, property, format string, args ...interface{}) Errorf(format string, args ...interface{}) VisitAllModules(visit func(Module)) @@ -265,7 +266,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) { } ctx.VisitAllModules(func(m Module) { - if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled() { + if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled(ctx) { mctx := &makeVarsContext{ SingletonContext: ctx, } diff --git a/android/module.go b/android/module.go index effca0346..40a591007 100644 --- a/android/module.go +++ b/android/module.go @@ -60,7 +60,7 @@ type Module interface { base() *ModuleBase Disable() - Enabled() bool + Enabled(ctx ConfigAndErrorContext) bool Target() Target MultiTargets() []Target @@ -287,7 +287,7 @@ type commonProperties struct { // but are not usually required (e.g. superceded by a prebuilt) should not be // disabled as that will prevent them from being built by the checkbuild target // and so prevent early detection of changes that have broken those modules. - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` // Controls the visibility of this module to other modules. Allowable values are one or more of // these formats: @@ -484,6 +484,11 @@ type commonProperties struct { // Set by osMutator. CommonOSVariant bool `blueprint:"mutated"` + // When set to true, this module is not installed to the full install path (ex: under + // out/target/product/<name>/<partition>). It can be installed only to the packaging + // modules like android_filesystem. + No_full_install *bool + // When HideFromMake is set to true, no entry for this variant will be emitted in the // generated Android.mk file. HideFromMake bool `blueprint:"mutated"` @@ -1392,14 +1397,11 @@ func (m *ModuleBase) PartitionTag(config DeviceConfig) string { return partition } -func (m *ModuleBase) Enabled() bool { +func (m *ModuleBase) Enabled(ctx ConfigAndErrorContext) bool { if m.commonProperties.ForcedDisabled { return false } - if m.commonProperties.Enabled == nil { - return !m.Os().DefaultDisabled - } - return *m.commonProperties.Enabled + return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled) } func (m *ModuleBase) Disable() { @@ -1643,7 +1645,7 @@ func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) { // not be created if the module is not exported to make. // Those could depend on the build target and fail to compile // for the current build target. - if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(a) { + if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, a) { allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) } }) @@ -1835,7 +1837,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i]) } - if m.Enabled() { + if m.Enabled(ctx) { // ensure all direct android.Module deps are enabled ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) { if m, ok := bm.(Module); ok { @@ -2136,7 +2138,7 @@ func (m *ModuleBase) ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools. } func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args ...interface{}) { - e.ctx.OtherModulePropertyErrorf(e.m, property, fmt, args) + e.ctx.OtherModulePropertyErrorf(e.m, property, fmt, args...) } func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue { @@ -2535,7 +2537,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) { } osDeps := map[osAndCross]Paths{} ctx.VisitAllModules(func(module Module) { - if module.Enabled() { + if module.Enabled(ctx) { key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross} osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...) } diff --git a/android/module_context.go b/android/module_context.go index dea22bab4..605d3baeb 100644 --- a/android/module_context.go +++ b/android/module_context.go @@ -444,6 +444,21 @@ func (m *moduleContext) skipInstall() bool { return false } +// Tells whether this module is installed to the full install path (ex: +// out/target/product/<name>/<partition>) or not. If this returns false, the install build rule is +// not created and this module can only be installed to packaging modules like android_filesystem. +func (m *moduleContext) requiresFullInstall() bool { + if m.skipInstall() { + return false + } + + if proptools.Bool(m.module.base().commonProperties.No_full_install) { + return false + } + + return true +} + func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath { return m.installFile(installPath, name, srcPath, deps, false, true, nil) @@ -490,7 +505,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false) } - if !m.skipInstall() { + if m.requiresFullInstall() { deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList())...) deps = append(deps, m.module.base().installedInitRcPaths...) deps = append(deps, m.module.base().installedVintfFragmentsPaths...) @@ -563,7 +578,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src if err != nil { panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err)) } - if !m.skipInstall() { + if m.requiresFullInstall() { if m.Config().KatiEnabled() { // When creating the symlink rule in Soong but embedding in Make, write the rule to a @@ -612,7 +627,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str fullInstallPath := installPath.Join(m, name) m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true) - if !m.skipInstall() { + if m.requiresFullInstall() { if m.Config().KatiEnabled() { // When creating the symlink rule in Soong but embedding in Make, write the rule to a // makefile instead of directly to the ninja file so that main.mk can add the diff --git a/android/mutator.go b/android/mutator.go index 75ba65048..440b9060f 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -293,15 +293,14 @@ type BottomUpMutatorContext interface { // WalkDeps, etc. AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) - // ReplaceDependencies replaces all dependencies on the identical variant of the module with the - // specified name with the current variant of this module. Replacements don't take effect until - // after the mutator pass is finished. + // ReplaceDependencies finds all the variants of the module with the specified name, then + // replaces all dependencies onto those variants with the current variant of this module. + // Replacements don't take effect until after the mutator pass is finished. ReplaceDependencies(string) - // ReplaceDependencies replaces all dependencies on the identical variant of the module with the - // specified name with the current variant of this module as long as the supplied predicate returns - // true. - // + // ReplaceDependenciesIf finds all the variants of the module with the specified name, then + // replaces all dependencies onto those variants with the current variant of this module + // as long as the supplied predicate returns true. // Replacements don't take effect until after the mutator pass is finished. ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate) @@ -595,11 +594,16 @@ func (a *androidTransitionMutator) IncomingTransition(bpctx blueprint.IncomingTr func (a *androidTransitionMutator) Mutate(ctx blueprint.BottomUpMutatorContext, variation string) { if am, ok := ctx.Module().(Module); ok { + if variation != "" { + // TODO: this should really be checking whether the TransitionMutator affected this module, not + // the empty variant, but TransitionMutator has no concept of skipping a module. + base := am.base() + base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, a.name) + base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variation) + } + mctx := bottomUpMutatorContextFactory(ctx, am, a.finalPhase) defer bottomUpMutatorContextPool.Put(mctx) - base := am.base() - base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, a.name) - base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variation) a.mutator.Mutate(mctx, variation) } } @@ -674,13 +678,11 @@ func RegisterComponentsMutator(ctx RegisterMutatorsContext) { // on component modules to be added so that they can depend directly on a prebuilt // module. func componentDepsMutator(ctx BottomUpMutatorContext) { - if m := ctx.Module(); m.Enabled() { - m.ComponentDepsMutator(ctx) - } + ctx.Module().ComponentDepsMutator(ctx) } func depsMutator(ctx BottomUpMutatorContext) { - if m := ctx.Module(); m.Enabled() { + if m := ctx.Module(); m.Enabled(ctx) { m.base().baseDepsMutator(ctx) m.DepsMutator(ctx) } diff --git a/android/override_module.go b/android/override_module.go index 1341f537c..55f384f1f 100644 --- a/android/override_module.go +++ b/android/override_module.go @@ -28,6 +28,7 @@ package android // module based on it. import ( + "fmt" "sort" "sync" @@ -120,7 +121,7 @@ type OverridableModule interface { addOverride(o OverrideModule) getOverrides() []OverrideModule - override(ctx BaseModuleContext, m Module, o OverrideModule) + override(ctx BaseModuleContext, bm OverridableModule, o OverrideModule) GetOverriddenBy() string GetOverriddenByModuleDir() string @@ -191,15 +192,14 @@ func (b *OverridableModuleBase) setOverridesProperty(overridesProperty *[]string } // Overrides a base module with the given OverrideModule. -func (b *OverridableModuleBase) override(ctx BaseModuleContext, m Module, o OverrideModule) { - +func (b *OverridableModuleBase) override(ctx BaseModuleContext, bm OverridableModule, o OverrideModule) { for _, p := range b.overridableProperties { for _, op := range o.getOverridingProperties() { if proptools.TypeEqual(p, op) { err := proptools.ExtendProperties(p, op, nil, proptools.OrderReplace) if err != nil { if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { - ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) + ctx.OtherModulePropertyErrorf(bm, propertyErr.Property, "%s", propertyErr.Err.Error()) } else { panic(err) } @@ -210,7 +210,7 @@ func (b *OverridableModuleBase) override(ctx BaseModuleContext, m Module, o Over // Adds the base module to the overrides property, if exists, of the overriding module. See the // comment on OverridableModuleBase.overridesProperty for details. if b.overridesProperty != nil { - *b.overridesProperty = append(*b.overridesProperty, ctx.ModuleName()) + *b.overridesProperty = append(*b.overridesProperty, ctx.OtherModuleName(bm)) } b.overridableModuleProperties.OverriddenBy = o.Name() b.overridableModuleProperties.OverriddenByModuleDir = o.ModuleDir() @@ -235,7 +235,7 @@ func (b *OverridableModuleBase) OverridablePropertiesDepsMutator(ctx BottomUpMut // to keep them in this order and not put any order mutators between them. func RegisterOverridePostDepsMutators(ctx RegisterMutatorsContext) { ctx.BottomUp("override_deps", overrideModuleDepsMutator).Parallel() - ctx.BottomUp("perform_override", performOverrideMutator).Parallel() + ctx.Transition("override", &overrideTransitionMutator{}) // overridableModuleDepsMutator calls OverridablePropertiesDepsMutator so that overridable modules can // add deps from overridable properties. ctx.BottomUp("overridable_deps", overridableModuleDepsMutator).Parallel() @@ -262,18 +262,6 @@ func overrideModuleDepsMutator(ctx BottomUpMutatorContext) { ctx.PropertyErrorf("base", "%q is not a valid module name", base) return } - // See if there's a prebuilt module that overrides this override module with prefer flag, - // in which case we call HideFromMake on the corresponding variant later. - ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) { - prebuilt := GetEmbeddedPrebuilt(dep) - if prebuilt == nil { - panic("PrebuiltDepTag leads to a non-prebuilt module " + dep.Name()) - } - if prebuilt.UsePrebuilt() { - module.setOverriddenByPrebuilt(dep) - return - } - }) baseModule := ctx.AddDependency(ctx.Module(), overrideBaseDepTag, *module.getOverrideModuleProperties().Base)[0] if o, ok := baseModule.(OverridableModule); ok { overrideModule := ctx.Module().(OverrideModule) @@ -285,11 +273,13 @@ func overrideModuleDepsMutator(ctx BottomUpMutatorContext) { // Now, goes through all overridable modules, finds all modules overriding them, creates a local // variant for each of them, and performs the actual overriding operation by calling override(). -func performOverrideMutator(ctx BottomUpMutatorContext) { +type overrideTransitionMutator struct{} + +func (overrideTransitionMutator) Split(ctx BaseModuleContext) []string { if b, ok := ctx.Module().(OverridableModule); ok { overrides := b.getOverrides() if len(overrides) == 0 { - return + return []string{""} } variants := make([]string, len(overrides)+1) // The first variant is for the original, non-overridden, base module. @@ -297,32 +287,74 @@ func performOverrideMutator(ctx BottomUpMutatorContext) { for i, o := range overrides { variants[i+1] = o.(Module).Name() } - mods := ctx.CreateLocalVariations(variants...) - // Make the original variation the default one to depend on if no other override module variant - // is specified. - ctx.AliasVariation(variants[0]) - for i, o := range overrides { - mods[i+1].(OverridableModule).override(ctx, mods[i+1], o) - if prebuilt := o.getOverriddenByPrebuilt(); prebuilt != nil { - // The overriding module itself, too, is overridden by a prebuilt. - // Perform the same check for replacement - checkInvariantsForSourceAndPrebuilt(ctx, mods[i+1], prebuilt) - // Copy the flag and hide it in make - mods[i+1].ReplacedByPrebuilt() - } - } + return variants } else if o, ok := ctx.Module().(OverrideModule); ok { // Create a variant of the overriding module with its own name. This matches the above local // variant name rule for overridden modules, and thus allows ReplaceDependencies to match the // two. - ctx.CreateLocalVariations(o.Name()) - // To allow dependencies to be added without having to know the above variation. - ctx.AliasVariation(o.Name()) + return []string{o.Name()} + } + + return []string{""} +} + +func (overrideTransitionMutator) OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string { + if o, ok := ctx.Module().(OverrideModule); ok { + if ctx.DepTag() == overrideBaseDepTag { + return o.Name() + } + } + + // Variations are always local and shouldn't affect the variant used for dependencies + return "" +} + +func (overrideTransitionMutator) IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string { + if _, ok := ctx.Module().(OverridableModule); ok { + return incomingVariation + } else if o, ok := ctx.Module().(OverrideModule); ok { + // To allow dependencies to be added without having to know the variation. + return o.Name() + } + + return "" +} + +func (overrideTransitionMutator) Mutate(ctx BottomUpMutatorContext, variation string) { + if o, ok := ctx.Module().(OverrideModule); ok { + overridableDeps := ctx.GetDirectDepsWithTag(overrideBaseDepTag) + if len(overridableDeps) > 1 { + panic(fmt.Errorf("expected a single dependency with overrideBaseDepTag, found %q", overridableDeps)) + } else if len(overridableDeps) == 1 { + b := overridableDeps[0].(OverridableModule) + b.override(ctx, b, o) + + checkPrebuiltReplacesOverride(ctx, b) + } + } +} + +func checkPrebuiltReplacesOverride(ctx BottomUpMutatorContext, b OverridableModule) { + // See if there's a prebuilt module that overrides this override module with prefer flag, + // in which case we call HideFromMake on the corresponding variant later. + prebuiltDeps := ctx.GetDirectDepsWithTag(PrebuiltDepTag) + for _, prebuiltDep := range prebuiltDeps { + prebuilt := GetEmbeddedPrebuilt(prebuiltDep) + if prebuilt == nil { + panic("PrebuiltDepTag leads to a non-prebuilt module " + prebuiltDep.Name()) + } + if prebuilt.UsePrebuilt() { + // The overriding module itself, too, is overridden by a prebuilt. + // Perform the same check for replacement + checkInvariantsForSourceAndPrebuilt(ctx, b, prebuiltDep) + // Copy the flag and hide it in make + b.ReplacedByPrebuilt() + } } } func overridableModuleDepsMutator(ctx BottomUpMutatorContext) { - if b, ok := ctx.Module().(OverridableModule); ok && b.Enabled() { + if b, ok := ctx.Module().(OverridableModule); ok && b.Enabled(ctx) { b.OverridablePropertiesDepsMutator(ctx) } } diff --git a/android/packaging.go b/android/packaging.go index 66772183c..fe61da1e9 100644 --- a/android/packaging.go +++ b/android/packaging.go @@ -50,6 +50,25 @@ type PackagingSpec struct { skipInstall bool } +func (p *PackagingSpec) Equals(other *PackagingSpec) bool { + if other == nil { + return false + } + if p.relPathInPackage != other.relPathInPackage { + return false + } + if p.srcPath != other.srcPath || p.symlinkTarget != other.symlinkTarget { + return false + } + if p.executable != other.executable { + return false + } + if p.partition != other.partition { + return false + } + return true +} + // Get file name of installed package func (p *PackagingSpec) FileName() string { if p.relPathInPackage != "" { @@ -243,9 +262,15 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter continue } } - if _, ok := m[ps.relPathInPackage]; !ok { - m[ps.relPathInPackage] = ps + dstPath := ps.relPathInPackage + if existingPs, ok := m[dstPath]; ok { + if !existingPs.Equals(&ps) { + ctx.ModuleErrorf("packaging conflict at %v:\n%v\n%v", dstPath, existingPs, ps) + } + continue } + + m[dstPath] = ps } }) return m diff --git a/android/paths.go b/android/paths.go index 2b33f67ce..8d92aa4a9 100644 --- a/android/paths.go +++ b/android/paths.go @@ -60,6 +60,7 @@ type EarlyModulePathContext interface { ModuleDir() string ModuleErrorf(fmt string, args ...interface{}) + OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{}) } var _ EarlyModulePathContext = ModuleContext(nil) @@ -277,6 +278,7 @@ type WritablePath interface { type genPathProvider interface { genPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleGenPath + genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath } type objPathProvider interface { objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath @@ -295,6 +297,16 @@ func GenPathWithExt(ctx ModuleOutPathContext, subdir string, p Path, ext string) return PathForModuleGen(ctx) } +// GenPathWithExtAndTrimExt derives a new file path in ctx's generated sources directory +// from the current path, but with the new extension and trim the suffix. +func GenPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir string, p Path, ext string, trimExt string) ModuleGenPath { + if path, ok := p.(genPathProvider); ok { + return path.genPathWithExtAndTrimExt(ctx, subdir, ext, trimExt) + } + ReportPathErrorf(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p) + return PathForModuleGen(ctx) +} + // ObjPathWithExt derives a new file path in ctx's object directory from the // current path, but with the new extension. func ObjPathWithExt(ctx ModuleOutPathContext, subdir string, p Path, ext string) ModuleObjPath { @@ -550,7 +562,7 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag if module == nil { return nil, missingDependencyError{[]string{moduleName}} } - if aModule, ok := module.(Module); ok && !aModule.Enabled() { + if aModule, ok := module.(Module); ok && !aModule.Enabled(ctx) { return nil, missingDependencyError{[]string{moduleName}} } if outProducer, ok := module.(OutputFileProducer); ok { @@ -1507,6 +1519,17 @@ func (p SourcePath) genPathWithExt(ctx ModuleOutPathContext, subdir, ext string) return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } +func (p SourcePath) genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath { + // If Trim_extension being set, force append Output_extension without replace original extension. + if trimExt != "" { + if ext != "" { + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)+"."+ext) + } + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)) + } + return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) +} + func (p SourcePath) objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } @@ -1594,6 +1617,17 @@ func (p ModuleGenPath) genPathWithExt(ctx ModuleOutPathContext, subdir, ext stri return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } +func (p ModuleGenPath) genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath { + // If Trim_extension being set, force append Output_extension without replace original extension. + if trimExt != "" { + if ext != "" { + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)+"."+ext) + } + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)) + } + return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) +} + func (p ModuleGenPath) objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } diff --git a/android/prebuilt.go b/android/prebuilt.go index 2b7b55b5d..1f9b33111 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -275,7 +275,7 @@ func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface srcPropertyName := proptools.PropertyNameForField(srcField) srcsSupplier := func(ctx BaseModuleContext, _ Module) []string { - if !module.Enabled() { + if !module.Enabled(ctx) { return nil } value := srcPropsValue.FieldByIndex(srcFieldIndex) @@ -425,7 +425,7 @@ func PrebuiltSourceDepsMutator(ctx BottomUpMutatorContext) { m := ctx.Module() // If this module is a prebuilt, is enabled and has not been renamed to source then add a // dependency onto the source if it is present. - if p := GetEmbeddedPrebuilt(m); p != nil && m.Enabled() && !p.properties.PrebuiltRenamedToSource { + if p := GetEmbeddedPrebuilt(m); p != nil && m.Enabled(ctx) && !p.properties.PrebuiltRenamedToSource { bmn, _ := m.(baseModuleName) name := bmn.BaseModuleName() if ctx.OtherModuleReverseDependencyVariantExists(name) { @@ -702,7 +702,7 @@ func (p *Prebuilt) usePrebuilt(ctx BaseMutatorContext, source Module, prebuilt M } // If source is not available or is disabled then always use the prebuilt. - if source == nil || !source.Enabled() { + if source == nil || !source.Enabled(ctx) { return true } diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index 575b9266c..d775ac356 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -351,7 +351,7 @@ func TestPrebuilts(t *testing.T) { } }) - moduleIsDisabled := !foo.Module().Enabled() + moduleIsDisabled := !foo.Module().Enabled(PanickingConfigAndErrorContext(result.TestContext)) deps := foo.Module().(*sourceModule).deps if moduleIsDisabled { if len(deps) > 0 { diff --git a/android/register.go b/android/register.go index d00c15fd0..aeb3b4c1b 100644 --- a/android/register.go +++ b/android/register.go @@ -16,8 +16,9 @@ package android import ( "fmt" - "github.com/google/blueprint" "reflect" + + "github.com/google/blueprint" ) // A sortable component is one whose registration order affects the order in which it is executed diff --git a/android/sdk_version.go b/android/sdk_version.go index b2ff960ee..01b55d0da 100644 --- a/android/sdk_version.go +++ b/android/sdk_version.go @@ -40,9 +40,15 @@ type SdkContext interface { // SdkKind represents a particular category of an SDK spec like public, system, test, etc. type SdkKind int +// These are generally ordered from the narrower sdk version to the wider sdk version, +// but not all entries have a strict subset/superset relationship. +// For example, SdkTest and SdkModule do not have a strict subset/superset relationship but both +// are supersets of SdkSystem. +// The general trend should be kept when an additional sdk kind is added. const ( SdkInvalid SdkKind = iota SdkNone + SdkToolchain // API surface provided by ART to compile other API domains SdkCore SdkCorePlatform SdkIntraCore // API surface provided by one core module to another @@ -53,7 +59,6 @@ const ( SdkModule SdkSystemServer SdkPrivate - SdkToolchain // API surface provided by ART to compile other API domains ) // String returns the string representation of this SdkKind diff --git a/android/singleton.go b/android/singleton.go index 76df1ebba..d364384e2 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -284,5 +284,5 @@ func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provid } func (s *singletonContextAdaptor) OtherModulePropertyErrorf(module Module, property string, format string, args ...interface{}) { - s.blueprintSingletonContext().OtherModulePropertyErrorf(module, property, format, args) + s.blueprintSingletonContext().OtherModulePropertyErrorf(module, property, format, args...) } diff --git a/android/testing.go b/android/testing.go index 7b4411e2f..c692c7295 100644 --- a/android/testing.go +++ b/android/testing.go @@ -1287,3 +1287,21 @@ func EnsureListContainsSuffix(t *testing.T, result []string, expected string) { t.Errorf("%q is not found in %v", expected, result) } } + +type panickingConfigAndErrorContext struct { + ctx *TestContext +} + +func (ctx *panickingConfigAndErrorContext) OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{}) { + panic(ctx.ctx.PropertyErrorf(module, property, fmt, args...).Error()) +} + +func (ctx *panickingConfigAndErrorContext) Config() Config { + return ctx.ctx.Config() +} + +func PanickingConfigAndErrorContext(ctx *TestContext) ConfigAndErrorContext { + return &panickingConfigAndErrorContext{ + ctx: ctx, + } +} diff --git a/android/variable.go b/android/variable.go index 599f88e3f..419bd61de 100644 --- a/android/variable.go +++ b/android/variable.go @@ -58,16 +58,16 @@ type variableProperties struct { // unbundled_build is a catch-all property to annotate modules that don't build in one or // more unbundled branches, usually due to dependencies missing from the manifest. Unbundled_build struct { - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` } `android:"arch_variant"` // similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt // sdk specifically. Always_use_prebuilt_sdks struct { - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` } `android:"arch_variant"` - Malloc_not_svelte struct { + Malloc_low_memory struct { Cflags []string `android:"arch_variant"` Shared_libs []string `android:"arch_variant"` Whole_static_libs []string `android:"arch_variant"` @@ -278,7 +278,7 @@ type ProductVariables struct { Unbundled_build_image *bool `json:",omitempty"` Always_use_prebuilt_sdks *bool `json:",omitempty"` Skip_boot_jars_check *bool `json:",omitempty"` - Malloc_not_svelte *bool `json:",omitempty"` + Malloc_low_memory *bool `json:",omitempty"` Malloc_zero_contents *bool `json:",omitempty"` Malloc_pattern_fill_contents *bool `json:",omitempty"` Safestack *bool `json:",omitempty"` @@ -612,7 +612,7 @@ func (v *ProductVariables) SetDefaultConfig() { AAPTCharacteristics: stringPtr("nosdcard"), AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"}, - Malloc_not_svelte: boolPtr(true), + Malloc_low_memory: boolPtr(false), Malloc_zero_contents: boolPtr(true), Malloc_pattern_fill_contents: boolPtr(false), Safestack: boolPtr(false), diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go index 9d61e1cf9..8a8bb2eaa 100644 --- a/androidmk/androidmk/android.go +++ b/androidmk/androidmk/android.go @@ -151,7 +151,7 @@ func init() { "LOCAL_CLANG_CFLAGS": "clang_cflags", "LOCAL_YACCFLAGS": "yacc.flags", "LOCAL_SANITIZE_RECOVER": "sanitize.recover", - "LOCAL_LOGTAGS_FILES": "logtags", + "LOCAL_SOONG_LOGTAGS_FILES": "logtags", "LOCAL_EXPORT_HEADER_LIBRARY_HEADERS": "export_header_lib_headers", "LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": "export_shared_lib_headers", "LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": "export_static_lib_headers", diff --git a/apex/apex.go b/apex/apex.go index ef57d7efc..12a6c9bf4 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1077,7 +1077,7 @@ type ApexInfoMutator interface { // specific variant to modules that support the ApexInfoMutator. // It also propagates updatable=true to apps of updatable apexes func apexInfoMutator(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } @@ -1094,7 +1094,7 @@ func apexInfoMutator(mctx android.TopDownMutatorContext) { // apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module // This check is enforced for updatable modules func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() { @@ -1121,7 +1121,7 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { // enforceAppUpdatability propagates updatable=true to apps of updatable apexes func enforceAppUpdatability(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() { @@ -1199,7 +1199,7 @@ func (a *apexBundle) checkStrictUpdatabilityLinting() bool { // unique apex variations for this module. See android/apex.go for more about unique apex variant. // TODO(jiyong): move this to android/apex.go? func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1211,7 +1211,7 @@ func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { // the apex in order to retrieve its contents later. // TODO(jiyong): move this to android/apex.go? func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1226,7 +1226,7 @@ func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { // TODO(jiyong): move this to android/apex.go? func apexTestForMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if _, ok := mctx.Module().(android.ApexModule); ok { @@ -1340,7 +1340,7 @@ func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool { // See android.UpdateDirectlyInAnyApex // TODO(jiyong): move this to android/apex.go? func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1968,7 +1968,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { return false } - if mod, ok := child.(android.Module); ok && !mod.Enabled() { + if mod, ok := child.(android.Module); ok && !mod.Enabled(ctx) { return false } depName := ctx.OtherModuleName(child) diff --git a/apex/apex_test.go b/apex/apex_test.go index 1be10483f..a13edbf5e 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -5601,8 +5601,21 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { compile_dex: true, } ` + // This test disables libbar, which causes the ComponentDepsMutator to add + // deps on libbar.stubs and other sub-modules that don't exist. We can + // enable AllowMissingDependencies to work around that, but enabling that + // causes extra checks for missing source files to dex_bootjars, so add those + // to the mock fs as well. + preparer2 := android.GroupFixturePreparers( + preparer, + android.PrepareForTestWithAllowMissingDependencies, + android.FixtureMergeMockFs(map[string][]byte{ + "build/soong/scripts/check_boot_jars/package_allowed_list.txt": nil, + "frameworks/base/config/boot-profile.txt": nil, + }), + ) - ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment) + ctx := testDexpreoptWithApexes(t, bp, "", preparer2, fragment) checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") @@ -9220,7 +9233,7 @@ func TestPrebuiltStubLibDep(t *testing.T) { continue } mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module) - if !mod.Enabled() || mod.IsHideFromMake() { + if !mod.Enabled(android.PanickingConfigAndErrorContext(ctx)) || mod.IsHideFromMake() { continue } for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) { @@ -11407,6 +11420,7 @@ func TestAconfifDeclarationsValidation(t *testing.T) { aconfig_declarations { name: "%[1]s", package: "com.example.package", + container: "system", srcs: [ "%[1]s.aconfig", ], diff --git a/cc/androidmk.go b/cc/androidmk.go index ef2636625..071d829bf 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -88,7 +88,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries { ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { if len(c.Properties.Logtags) > 0 { - entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...) + entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", c.logtagsPaths.Strings()...) } // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make // world, even if it is an empty list. In the Make world, diff --git a/cc/builder.go b/cc/builder.go index e78b8c0de..e255cbebb 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -608,6 +608,10 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs ccCmd = "clang++" moduleFlags = cppflags moduleToolingFlags = toolingCppflags + case ".rs": + // A source provider (e.g. rust_bindgen) may provide both rs and c files. + // Ignore the rs files. + continue case ".h", ".hpp": ctx.PropertyErrorf("srcs", "Header file %s is not supported, instead use export_include_dirs or local_include_dirs.", srcFile) continue @@ -320,7 +320,7 @@ type BaseProperties struct { // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags // file - Logtags []string + Logtags []string `android:"path"` // Make this module available when building for ramdisk. // On device without a dedicated recovery partition, the module is only @@ -909,6 +909,8 @@ type Module struct { // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo mergedAconfigFiles map[string]android.Paths + + logtagsPaths android.Paths } func (c *Module) AddJSONData(d *map[string]interface{}) { @@ -1998,6 +2000,11 @@ func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { ctx := moduleContextFromAndroidModuleContext(actx, c) + c.logtagsPaths = android.PathsForModuleSrc(actx, c.Properties.Logtags) + android.SetProvider(ctx, android.LogtagsProviderKey, &android.LogtagsInfo{ + Logtags: c.logtagsPaths, + }) + // If Test_only is set on a module in bp file, respect the setting, otherwise // see if is a known test module type. testOnly := c.testModule || c.testLibrary() @@ -2509,7 +2516,7 @@ func (c *Module) shouldUseApiSurface() bool { } func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { - if !c.Enabled() { + if !c.Enabled(actx) { return } @@ -2757,7 +2764,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { } func BeginMutator(ctx android.BottomUpMutatorContext) { - if c, ok := ctx.Module().(*Module); ok && c.Enabled() { + if c, ok := ctx.Module().(*Module); ok && c.Enabled(ctx) { c.beginMutator(ctx) } } diff --git a/cc/compiler.go b/cc/compiler.go index 9a961cfb9..a1b329e2c 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -141,6 +141,19 @@ type BaseCompilerProperties struct { Flags []string } + // Populated by aidl_interface CPP backend to let other modules (e.g. cc_cmake_snapshot) + // access actual source files and not generated cpp intermediary sources. + AidlInterface struct { + // list of aidl_interface sources + Sources []string `blueprint:"mutated"` + + // AIDL backend language (e.g. "cpp", "ndk") + Lang string `blueprint:"mutated"` + + // list of flags passed to AIDL generator + Flags []string `blueprint:"mutated"` + } `blueprint:"mutated"` + Renderscript struct { // list of directories that will be added to the llvm-rs-cc include paths Include_dirs []string diff --git a/cc/fuzz.go b/cc/fuzz.go index 2436f33d2..b3e663962 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -433,7 +433,7 @@ func (s *ccRustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) return } // Discard non-fuzz targets. - if ok := fuzz.IsValid(ccModule.FuzzModuleStruct()); !ok { + if ok := fuzz.IsValid(ctx, ccModule.FuzzModuleStruct()); !ok { return } diff --git a/cc/library.go b/cc/library.go index a436649d0..12ecc131a 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1322,7 +1322,7 @@ func currRefAbiDumpSdkVersion(ctx ModuleContext) string { // sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump). func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext, sourceDump, referenceDump android.Path, - baseName, nameExt string, isLlndkOrNdk, allowExtensions bool, + baseName, nameExt string, isLlndk, allowExtensions bool, sourceVersion, errorMessage string) { extraFlags := []string{"-target-version", sourceVersion} @@ -1334,7 +1334,7 @@ func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext, "-allow-unreferenced-changes", "-allow-unreferenced-elf-symbol-changes") } - if isLlndkOrNdk { + if isLlndk { extraFlags = append(extraFlags, "-consider-opaque-types-different") } if allowExtensions { @@ -1350,23 +1350,23 @@ func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext, func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext, sourceDump, referenceDump android.Path, - baseName string, isLlndkOrNdk bool, sourceVersion, prevVersion string) { + baseName string, isLlndk bool, sourceVersion, prevVersion string) { errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/main/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "." library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, prevVersion, - isLlndkOrNdk, true /* allowExtensions */, sourceVersion, errorMessage) + isLlndk, true /* allowExtensions */, sourceVersion, errorMessage) } func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, sourceDump, referenceDump android.Path, - baseName, nameExt string, isLlndkOrNdk bool) { + baseName, nameExt string, isLlndk bool) { libName := strings.TrimSuffix(baseName, filepath.Ext(baseName)) errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, nameExt, - isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage) + isLlndk, false /* allowExtensions */, "current", errorMessage) } func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, @@ -1381,7 +1381,7 @@ func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, } library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, nameExt, - false /* isLlndkOrNdk */, false /* allowExtensions */, "current", errorMessage) + false /* isLlndk */, false /* allowExtensions */, "current", errorMessage) } func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathDeps, objs Objects, fileName string, soFile android.Path) { @@ -1436,7 +1436,6 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD dumpDir := filepath.Join("prebuilts", "abi-dumps", dumpDirName) isLlndk := (tag == llndkLsdumpTag) isApex := (tag == apexLsdumpTag) - isNdk := (tag == ndkLsdumpTag) binderBitness := ctx.DeviceConfig().BinderBitness() nameExt := "" if isLlndk { @@ -1468,7 +1467,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName) if prevDumpFile.Valid() { library.crossVersionAbiDiff(ctx, sourceDump, prevDumpFile.Path(), - fileName, isLlndk || isNdk, currVersion, nameExt+prevVersion) + fileName, isLlndk, currVersion, nameExt+prevVersion) } // Check against the current version. sourceDump = implDump @@ -1488,7 +1487,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName) if currDumpFile.Valid() { library.sameVersionAbiDiff(ctx, sourceDump, currDumpFile.Path(), - fileName, nameExt, isLlndk || isNdk) + fileName, nameExt, isLlndk) } } // Check against the opt-in reference dumps. diff --git a/cc/linker.go b/cc/linker.go index 9686697c8..56a68b2ce 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -330,6 +330,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) + deps.ReexportHeaderLibHeaders = removeListFromList(deps.ReexportHeaderLibHeaders, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor.Exclude_runtime_libs) @@ -342,6 +343,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Product.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Product.Exclude_static_libs) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Product.Exclude_header_libs) + deps.ReexportHeaderLibHeaders = removeListFromList(deps.ReexportHeaderLibHeaders, linker.Properties.Target.Product.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Product.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Product.Exclude_static_libs) deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Product.Exclude_runtime_libs) diff --git a/cc/llndk_library.go b/cc/llndk_library.go index ae9da9851..5b86c6478 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -121,6 +121,11 @@ func (txt *llndkLibrariesTxtModule) GenerateAndroidBuildActions(ctx android.Modu } func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) { + if txt.outputFile.String() == "" { + // Skip if target file path is empty + return + } + ctx.VisitAllModules(func(m android.Module) { if c, ok := m.(*Module); ok && c.VendorProperties.IsLLNDK && !c.Header() && !c.IsVndkPrebuiltLibrary() { filename, err := getVndkFileName(c) @@ -181,7 +186,7 @@ func llndkMutator(mctx android.BottomUpMutatorContext) { return } - if shouldSkipLlndkMutator(m) { + if shouldSkipLlndkMutator(mctx, m) { return } @@ -201,8 +206,8 @@ func llndkMutator(mctx android.BottomUpMutatorContext) { } // Check for modules that mustn't be LLNDK -func shouldSkipLlndkMutator(m *Module) bool { - if !m.Enabled() { +func shouldSkipLlndkMutator(mctx android.BottomUpMutatorContext, m *Module) bool { + if !m.Enabled(mctx) { return true } if !m.Device() { diff --git a/cc/makevars.go b/cc/makevars.go index 9251d6a49..51bcbf090 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -279,7 +279,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, sanitizerLibs := android.SortedStringValues(sanitizerVariables) var sanitizerLibStems []string ctx.VisitAllModules(func(m android.Module) { - if !m.Enabled() { + if !m.Enabled(ctx) { return } diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go index 86166dcbb..5beeab1ee 100644 --- a/cc/ndk_abi.go +++ b/cc/ndk_abi.go @@ -40,7 +40,7 @@ type ndkAbiDumpSingleton struct{} func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } @@ -78,7 +78,7 @@ type ndkAbiDiffSingleton struct{} func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled() { + if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { return } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 25231fdf5..f32606814 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -148,7 +148,7 @@ func ndkLibraryVersions(ctx android.BaseMutatorContext, from android.ApiLevel) [ } func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string { - if !ctx.Module().Enabled() { + if !ctx.Module().Enabled(ctx) { return nil } if ctx.Target().NativeBridge == android.NativeBridgeEnabled { diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index e815172ae..3c48f6881 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go @@ -150,7 +150,7 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { var installPaths android.Paths var licensePaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled() { + if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { return } diff --git a/cc/sabi.go b/cc/sabi.go index cd9bf6393..edd9cfe80 100644 --- a/cc/sabi.go +++ b/cc/sabi.go @@ -31,7 +31,6 @@ type lsdumpTag string const ( apexLsdumpTag lsdumpTag = "APEX" llndkLsdumpTag lsdumpTag = "LLNDK" - ndkLsdumpTag lsdumpTag = "NDK" platformLsdumpTag lsdumpTag = "PLATFORM" productLsdumpTag lsdumpTag = "PRODUCT" vendorLsdumpTag lsdumpTag = "VENDOR" @@ -42,8 +41,6 @@ func (tag *lsdumpTag) dirName() string { switch *tag { case apexLsdumpTag: return "platform" - case ndkLsdumpTag: - return "ndk" case llndkLsdumpTag: return "vndk" case platformLsdumpTag: @@ -137,9 +134,6 @@ func classifySourceAbiDump(ctx android.BaseModuleContext) []lsdumpTag { if m.isImplementationForLLNDKPublic() { result = append(result, llndkLsdumpTag) } - if m.IsNdk(ctx.Config()) { - result = append(result, ndkLsdumpTag) - } // APEX and opt-in platform dumps are placed in the same directory. if m.library.hasStubsVariants() { result = append(result, apexLsdumpTag) diff --git a/cc/sanitize.go b/cc/sanitize.go index 2a1ee3c5f..1a94729c6 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -82,7 +82,7 @@ var ( hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512", "export_memory_stats=0", "max_malloc_fill_size=131072", "malloc_fill_byte=0"} memtagStackCommonFlags = []string{"-march=armv8-a+memtag"} - memtagStackLlvmFlags = []string{"-dom-tree-reachability-max-bbs-to-explore=128"} + memtagStackLlvmFlags = []string{"-dom-tree-reachability-max-bbs-to-explore=128"} hostOnlySanitizeFlags = []string{"-fno-sanitize-recover=all"} deviceOnlySanitizeFlags = []string{"-fsanitize-trap=all"} @@ -176,11 +176,11 @@ func (t SanitizerType) name() string { func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) { switch t { - case cfi, Hwasan, Asan, tsan, Fuzzer, scs: + case cfi, Hwasan, Asan, tsan, Fuzzer, scs, Memtag_stack: sanitizer := &sanitizerSplitMutator{t} ctx.TopDown(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator) ctx.Transition(t.variationName(), sanitizer) - case Memtag_heap, Memtag_stack, Memtag_globals, intOverflow: + case Memtag_heap, Memtag_globals, intOverflow: // do nothing default: panic(fmt.Errorf("unknown SanitizerType %d", t)) @@ -407,6 +407,7 @@ func init() { android.RegisterMakeVarsProvider(pctx, cfiMakeVarsProvider) android.RegisterMakeVarsProvider(pctx, hwasanMakeVarsProvider) + android.RegisterMakeVarsProvider(pctx, memtagStackMakeVarsProvider) } func (sanitize *sanitize) props() []interface{} { @@ -683,10 +684,14 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Diag.Cfi = nil } - // HWASan ramdisk (which is built from recovery) goes over some bootloader limit. - // Keep libc instrumented so that ramdisk / vendor_ramdisk / recovery can run hwasan-instrumented code if necessary. - if (ctx.inRamdisk() || ctx.inVendorRamdisk() || ctx.inRecovery()) && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") { - s.Hwaddress = nil + if ctx.inRamdisk() || ctx.inVendorRamdisk() || ctx.inRecovery() { + // HWASan ramdisk (which is built from recovery) goes over some bootloader limit. + // Keep libc instrumented so that ramdisk / vendor_ramdisk / recovery can run hwasan-instrumented code if necessary. + if !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") { + s.Hwaddress = nil + } + // Memtag stack in ramdisk makes pKVM unhappy. + s.Memtag_stack = nil } if ctx.staticBinary() { @@ -858,7 +863,7 @@ func (s *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.Local.CFlags = append(flags.Local.CFlags, cfiCflags...) flags.Local.AsFlags = append(flags.Local.AsFlags, cfiAsflags...) - flags.CFlagsDeps = append(flags.CFlagsDeps, android.PathForSource(ctx, cfiBlocklistPath + "/" + cfiBlocklistFilename)) + flags.CFlagsDeps = append(flags.CFlagsDeps, android.PathForSource(ctx, cfiBlocklistPath+"/"+cfiBlocklistFilename)) if Bool(s.Properties.Sanitize.Config.Cfi_assembly_support) { flags.Local.CFlags = append(flags.Local.CFlags, cfiAssemblySupportFlag) } @@ -1310,6 +1315,8 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari hwasanStaticLibs(mctx.Config()).add(c, c.Module().Name()) } else if s.sanitizer == cfi { cfiStaticLibs(mctx.Config()).add(c, c.Module().Name()) + } else if s.sanitizer == Memtag_stack { + memtagStackStaticLibs(mctx.Config()).add(c, c.Module().Name()); } } } else if c.IsSanitizerEnabled(s.sanitizer) { @@ -1378,7 +1385,7 @@ func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) { // Add the dependency to the runtime library for each of the sanitizer variants func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { - if !c.Enabled() { + if !c.Enabled(mctx) { return } var sanitizers []string @@ -1559,7 +1566,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { addStaticDeps(config.BuiltinsRuntimeLibrary(toolchain), true) } - if runtimeSharedLibrary != "" && (toolchain.Bionic() || toolchain.Musl() || c.sanitize.Properties.UbsanRuntimeDep) { + if runtimeSharedLibrary != "" && (toolchain.Bionic() || toolchain.Musl()) { // UBSan is supported on non-bionic linux host builds as well // Adding dependency to the runtime library. We are using *FarVariation* @@ -1722,6 +1729,14 @@ func hwasanStaticLibs(config android.Config) *sanitizerStaticLibsMap { }).(*sanitizerStaticLibsMap) } +var memtagStackStaticLibsKey = android.NewOnceKey("memtagStackStaticLibs") + +func memtagStackStaticLibs(config android.Config) *sanitizerStaticLibsMap { + return config.Once(memtagStackStaticLibsKey, func() interface{} { + return newSanitizerStaticLibsMap(Memtag_stack) + }).(*sanitizerStaticLibsMap) +} + func enableMinimalRuntime(sanitize *sanitize) bool { if sanitize.isSanitizerEnabled(Asan) { return false @@ -1768,3 +1783,7 @@ func cfiMakeVarsProvider(ctx android.MakeVarsContext) { func hwasanMakeVarsProvider(ctx android.MakeVarsContext) { hwasanStaticLibs(ctx.Config()).exportToMake(ctx) } + +func memtagStackMakeVarsProvider(ctx android.MakeVarsContext) { + memtagStackStaticLibs(ctx.Config()).exportToMake(ctx) +} diff --git a/cc/tidy.go b/cc/tidy.go index 76ac7d583..ec1e8a206 100644 --- a/cc/tidy.go +++ b/cc/tidy.go @@ -220,7 +220,7 @@ func collectTidyObjModuleTargets(ctx android.SingletonContext, module android.Mo // (1) Collect all obj/tidy files into OS-specific groups. ctx.VisitAllModuleVariants(module, func(variant android.Module) { - if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(variant) { + if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(ctx, variant) { return } if m, ok := variant.(*Module); ok { diff --git a/cc/vndk.go b/cc/vndk.go index 50e6d4b96..548992d37 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -322,8 +322,8 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) { } // Check for modules that mustn't be VNDK -func shouldSkipVndkMutator(m *Module) bool { - if !m.Enabled() { +func shouldSkipVndkMutator(ctx android.ConfigAndErrorContext, m *Module) bool { + if !m.Enabled(ctx) { return true } if !m.Device() { @@ -338,7 +338,7 @@ func shouldSkipVndkMutator(m *Module) bool { } func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool { - if shouldSkipVndkMutator(m) { + if shouldSkipVndkMutator(mctx, m) { return false } @@ -369,7 +369,7 @@ func VndkMutator(mctx android.BottomUpMutatorContext) { return } - if shouldSkipVndkMutator(m) { + if shouldSkipVndkMutator(mctx, m) { return } @@ -548,6 +548,7 @@ func (txt *vndkLibrariesTxt) SubDir() string { func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) { return android.Paths{txt.outputFile}, nil } + func getVndkFileName(m *Module) (string, error) { if library, ok := m.linker.(*libraryDecorator); ok { return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index ec7d64f1e..cc2b57a27 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -266,7 +266,7 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a return fmt.Errorf("Unknown build flag %s", name) } if valueDir == "" { - mapDir, err := GetMapDir(*flagArtifact.Traces[len(flagArtifact.Traces)-1].Source) + mapDir, err := configs.GetFlagValueDirectory(release, flagArtifact) if err != nil { return err } @@ -325,7 +325,12 @@ func main() { } if len(commonFlags.targetReleases) == 0 { - commonFlags.targetReleases = rc_lib.StringList{"trunk_staging"} + release, ok := os.LookupEnv("TARGET_RELEASE") + if ok { + commonFlags.targetReleases = rc_lib.StringList{release} + } else { + commonFlags.targetReleases = rc_lib.StringList{"trunk_staging"} + } } if err = os.Chdir(commonFlags.top); err != nil { diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 95342b1d0..4d763c8d7 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -21,6 +21,7 @@ var ( manualFlagNamePrefixes []string = []string{ "RELEASE_ACONFIG_", "RELEASE_PLATFORM_", + "RELEASE_BUILD_FLAGS_", } // Set `aconfig_flags_only: true` in these release configs. diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index c443257c6..101dbe381 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -35,6 +35,7 @@ func main() { var product string var allMake bool var useBuildVar bool + var guard bool defaultRelease := os.Getenv("TARGET_RELEASE") if defaultRelease == "" { @@ -52,6 +53,7 @@ func main() { flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs") flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") + flag.BoolVar(&guard, "guard", true, "whether to guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF") flag.Parse() @@ -70,26 +72,27 @@ func main() { if err != nil { panic(err) } - releaseName := config.Name err = os.MkdirAll(outputDir, 0775) if err != nil { panic(err) } - if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil { - panic(err) - } - - if allMake { + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, targetRelease)) + useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] + if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { + // We were told to guard operation and either we have no build flag, or it is False. + // Write an empty file so that release_config.mk will use the old process. + os.WriteFile(makefilePath, []byte{}, 0644) + } else if allMake { + // Write one makefile per release config, using the canonical release name. for k, _ := range configs.ReleaseConfigs { - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) + makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) err = configs.WriteMakefile(makefilePath, k) if err != nil { panic(err) } } } else { - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) err = configs.WriteMakefile(makefilePath, targetRelease) if err != nil { panic(err) @@ -113,4 +116,8 @@ func main() { panic(err) } } + if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil { + panic(err) + } + } diff --git a/cmd/release_config/release_config_lib/flag_value.go b/cmd/release_config/release_config_lib/flag_value.go index e155e7782..59021e260 100644 --- a/cmd/release_config/release_config_lib/flag_value.go +++ b/cmd/release_config/release_config_lib/flag_value.go @@ -52,6 +52,9 @@ func UnmarshalValue(str string) *rc_proto.Value { } func MarshalValue(value *rc_proto.Value) string { + if value == nil { + return "" + } switch val := value.Val.(type) { case *rc_proto.Value_UnspecifiedValue: // Value was never set. diff --git a/cmd/release_config/release_config_lib/flag_value_test.go b/cmd/release_config/release_config_lib/flag_value_test.go index aaa4cafeb..8a98baf6a 100644 --- a/cmd/release_config/release_config_lib/flag_value_test.go +++ b/cmd/release_config/release_config_lib/flag_value_test.go @@ -24,7 +24,7 @@ import ( "google.golang.org/protobuf/proto" ) -type testCaseFlagValue struct { +type testCaseFlagValueFactory struct { protoPath string name string data []byte @@ -32,14 +32,14 @@ type testCaseFlagValue struct { err error } -func (tc testCaseFlagValue) assertProtoEqual(t *testing.T, expected, actual proto.Message) { +func (tc testCaseFlagValueFactory) assertProtoEqual(t *testing.T, expected, actual proto.Message) { if !proto.Equal(expected, actual) { t.Errorf("Expected %q found %q", expected, actual) } } -func TestFlagValue(t *testing.T) { - testCases := []testCaseFlagValue{ +func TestFlagValueFactory(t *testing.T) { + testCases := []testCaseFlagValueFactory{ { name: "stringVal", protoPath: "build/release/flag_values/test/RELEASE_FOO.textproto", @@ -65,3 +65,50 @@ func TestFlagValue(t *testing.T) { tc.assertProtoEqual(t, &tc.expected, &actual.proto) } } + +type testCaseMarshalValue struct { + name string + value *rc_proto.Value + expected string +} + +func TestMarshalValue(t *testing.T) { + testCases := []testCaseMarshalValue{ + { + name: "nil", + value: nil, + expected: "", + }, + { + name: "unspecified", + value: &rc_proto.Value{}, + expected: "", + }, + { + name: "false", + value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{false}}, + expected: "", + }, + { + name: "true", + value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{true}}, + expected: "true", + }, + { + name: "string", + value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{"BAR"}}, + expected: "BAR", + }, + { + name: "obsolete", + value: &rc_proto.Value{Val: &rc_proto.Value_Obsolete{true}}, + expected: " #OBSOLETE", + }, + } + for _, tc := range testCases { + actual := MarshalValue(tc.value) + if actual != tc.expected { + t.Errorf("Expected %q found %q", tc.expected, actual) + } + } +} diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index e51ff08b2..820482239 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -29,7 +29,7 @@ import ( // One directory's contribution to the a release config. type ReleaseConfigContribution struct { - // Paths to files providing this config. + // Path of the file providing this config contribution. path string // The index of the config directory where this release config @@ -90,7 +90,13 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { if !ok { return fmt.Errorf("Could not inherit flag %s from %s", name, iConfig.Name) } - if len(fa.Traces) > 1 { + if name == "RELEASE_ACONFIG_VALUE_SETS" { + if len(fa.Traces) > 0 { + myFa.Traces = append(myFa.Traces, fa.Traces...) + myFa.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{ + myFa.Value.GetStringValue() + " " + fa.Value.GetStringValue()}} + } + } else if len(fa.Traces) > 1 { // A value was assigned. Set our value. myFa.Traces = append(myFa.Traces, fa.Traces[1:]...) myFa.Value = fa.Value @@ -111,21 +117,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro // Start with only the flag declarations. config.FlagArtifacts = configs.FlagArtifacts.Clone() - // Add RELEASE_ACONFIG_VALUE_SETS - workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) - releaseAconfigValueSets := FlagArtifact{ - FlagDeclaration: &rc_proto.FlagDeclaration{ - Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), - Namespace: proto.String("android_UNKNOWN"), - Description: proto.String("Aconfig value sets assembled by release-config"), - Workflow: &workflowManual, - Containers: []string{"system", "system_ext", "product", "vendor"}, - Value: &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}, - }, - DeclarationIndex: -1, - Traces: []*rc_proto.Tracepoint{}, - } - config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets + releaseAconfigValueSets := config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] // Generate any configs we need to inherit. This will detect loops in // the config. @@ -154,27 +146,22 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } contributionsToApply = append(contributionsToApply, config.Contributions...) - myAconfigValueSets := strings.Split(releaseAconfigValueSets.Value.GetStringValue(), " ") - myAconfigValueSetsMap := map[string]bool{} - for _, v := range myAconfigValueSets { - myAconfigValueSetsMap[v] = true - } + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} - // Gather the aconfig_value_sets from this contribution that are not already in the list. + // Gather the aconfig_value_sets from this contribution, allowing duplicates for simplicity. for _, v := range contrib.proto.AconfigValueSets { - if _, ok := myAconfigValueSetsMap[v]; !ok { - contribAconfigValueSets = append(contribAconfigValueSets, v) - myAconfigValueSetsMap[v] = true - } + contribAconfigValueSets = append(contribAconfigValueSets, v) } - myAconfigValueSets = append(myAconfigValueSets, contribAconfigValueSets...) + contribAconfigValueSetsString := strings.Join(contribAconfigValueSets, " ") + releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{ + releaseAconfigValueSets.Value.GetStringValue() + " " + contribAconfigValueSetsString}} releaseAconfigValueSets.Traces = append( releaseAconfigValueSets.Traces, &rc_proto.Tracepoint{ Source: proto.String(contrib.path), - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(contribAconfigValueSets, " ")}}, + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{contribAconfigValueSetsString}}, }) myDirsMap[contrib.DeclarationIndex] = true @@ -204,6 +191,16 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } } } + // Now remove any duplicates from the actual value of RELEASE_ACONFIG_VALUE_SETS + myAconfigValueSets := []string{} + myAconfigValueSetsMap := map[string]bool{} + for _, v := range strings.Split(releaseAconfigValueSets.Value.GetStringValue(), " ") { + if myAconfigValueSetsMap[v] { + continue + } + myAconfigValueSetsMap[v] = true + myAconfigValueSets = append(myAconfigValueSets, v) + } releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.TrimSpace(strings.Join(myAconfigValueSets, " "))}} directories := []string{} diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index cedf247f8..8a4e2d58b 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -95,7 +95,7 @@ func (configs *ReleaseConfigs) WriteArtifact(outDir, product, format string) err } func ReleaseConfigsFactory() (c *ReleaseConfigs) { - return &ReleaseConfigs{ + configs := ReleaseConfigs{ Aliases: make(map[string]*string), FlagArtifacts: make(map[string]*FlagArtifact), ReleaseConfigs: make(map[string]*ReleaseConfig), @@ -103,6 +103,21 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { configDirs: []string{}, configDirIndexes: make(ReleaseConfigDirMap), } + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + releaseAconfigValueSets := FlagArtifact{ + FlagDeclaration: &rc_proto.FlagDeclaration{ + Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), + Namespace: proto.String("android_UNKNOWN"), + Description: proto.String("Aconfig value sets assembled by release-config"), + Workflow: &workflowManual, + Containers: []string{"system", "system_ext", "product", "vendor"}, + Value: &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}, + }, + DeclarationIndex: -1, + Traces: []*rc_proto.Tracepoint{}, + } + configs.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets + return &configs } func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { @@ -116,6 +131,32 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { return m } +// Find the top of the release config contribution directory. +// Returns the parent of the flag_declarations and flag_values directories. +func (configs *ReleaseConfigs) GetDirIndex(path string) (int, error) { + for p := path; p != "."; p = filepath.Dir(p) { + if idx, ok := configs.configDirIndexes[p]; ok { + return idx, nil + } + } + return -1, fmt.Errorf("Could not determine release config directory from %s", path) +} + +// Determine the default directory for writing a flag value. +// +// Returns the path of the highest-Indexed one of: +// - Where the flag is declared +// - Where the release config is first declared +// - The last place the value is being written. +func (configs *ReleaseConfigs) GetFlagValueDirectory(config *ReleaseConfig, flag *FlagArtifact) (string, error) { + current, err := configs.GetDirIndex(*flag.Traces[len(flag.Traces)-1].Source) + if err != nil { + return "", err + } + index := max(flag.DeclarationIndex, config.DeclarationIndex, current) + return configs.configDirs[index], nil +} + func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { if _, err := os.Stat(path); err != nil { return fmt.Errorf("%s does not exist\n", path) @@ -166,6 +207,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex } m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration) name := *flagDeclaration.Name + if name == "RELEASE_ACONFIG_VALUE_SETS" { + return fmt.Errorf("%s: %s is a reserved build flag", path, name) + } if def, ok := configs.FlagArtifacts[name]; !ok { configs.FlagArtifacts[name] = &FlagArtifact{FlagDeclaration: flagDeclaration, DeclarationIndex: ConfigDirIndex} } else if !proto.Equal(def.FlagDeclaration, flagDeclaration) { @@ -176,7 +220,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) if configs.FlagArtifacts[name].Redacted { - return fmt.Errorf("%s may not be redacted by default.", *flagDeclaration.Name) + return fmt.Errorf("%s may not be redacted by default.", name) } return nil }) @@ -203,6 +247,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if fmt.Sprintf("%s.textproto", *flagValue.proto.Name) != filepath.Base(path) { return fmt.Errorf("%s incorrectly sets value for flag %s", path, *flagValue.proto.Name) } + if *flagValue.proto.Name == "RELEASE_ACONFIG_VALUE_SETS" { + return fmt.Errorf("%s: %s is a reserved build flag", path, *flagValue.proto.Name) + } releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) return nil }) @@ -382,7 +429,9 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin if len(releaseConfigMapPaths) == 0 { return nil, fmt.Errorf("No maps found") } - warnf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + if !useBuildVar { + warnf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + } } configs := ReleaseConfigsFactory() diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index cadf9c246..b342ae930 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -127,6 +127,10 @@ type filesystemProperties struct { // the make version. Include_make_built_files string + // When set, builds etc/event-log-tags file by merging logtags from all dependencies. + // Default is false + Build_logtags *bool + Fsverity fsverityProperties } @@ -137,6 +141,7 @@ type filesystemProperties struct { // partitions like system.img. For example, cc_library modules are placed under ./lib[64] directory. func filesystemFactory() android.Module { module := &filesystem{} + module.filterPackagingSpec = module.filterInstallablePackagingSpec initFilesystemModule(module) return module } @@ -189,6 +194,12 @@ func (f *filesystem) partitionName() string { return proptools.StringDefault(f.properties.Partition_name, f.Name()) } +func (f *filesystem) filterInstallablePackagingSpec(ps android.PackagingSpec) bool { + // Filesystem module respects the installation semantic. A PackagingSpec from a module with + // IsSkipInstall() is skipped. + return !ps.SkipInstall() +} + var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -288,6 +299,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi f.buildNonDepsFiles(ctx, builder, rootDir) f.addMakeBuiltFiles(ctx, builder, rootDir) f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir) + f.buildEventLogtagsFile(ctx, builder, rebasedDir) // run host_init_verifier // Ideally we should have a concept of pluggable linters that verify the generated image. @@ -428,6 +440,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) f.buildNonDepsFiles(ctx, builder, rootDir) f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir) + f.buildEventLogtagsFile(ctx, builder, rebasedDir) output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath cmd := builder.Command(). @@ -485,6 +498,37 @@ func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *andro Text(android.PathForArbitraryOutput(ctx, stagingDir).String()) } +func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) { + if !proptools.Bool(f.properties.Build_logtags) { + return + } + + logtagsFilePaths := make(map[string]bool) + ctx.WalkDeps(func(child, parent android.Module) bool { + if logtagsInfo, ok := android.OtherModuleProvider(ctx, child, android.LogtagsProviderKey); ok { + for _, path := range logtagsInfo.Logtags { + logtagsFilePaths[path.String()] = true + } + } + return true + }) + + if len(logtagsFilePaths) == 0 { + return + } + + etcPath := rebasedDir.Join(ctx, "etc") + eventLogtagsPath := etcPath.Join(ctx, "event-log-tags") + builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String()) + cmd := builder.Command().BuiltTool("merge-event-log-tags"). + FlagWithArg("-o ", eventLogtagsPath.String()). + FlagWithInput("-m ", android.MergedLogtagsPath(ctx)) + + for _, path := range android.SortedKeys(logtagsFilePaths) { + cmd.Text(path) + } +} + type partition interface { PartitionType() string } diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index 121504867..acd481352 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -442,3 +442,26 @@ func TestInconsistentPartitionTypesInDefaults(t *testing.T) { } `) } + +func TestPreventDuplicatedEntries(t *testing.T) { + fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( + "packaging conflict at")). + RunTestWithBp(t, ` + android_filesystem { + name: "fs", + deps: [ + "foo", + "foo_dup", + ], + } + + cc_binary { + name: "foo", + } + + cc_binary { + name: "foo_dup", + stem: "foo", + } + `) +} diff --git a/filesystem/system_image.go b/filesystem/system_image.go index 5028a493e..15cacfb4f 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -98,5 +98,5 @@ func (s *systemImage) buildLinkerConfigFile(ctx android.ModuleContext, root andr // Note that "apex" module installs its contents to "apex"(fake partition) as well // for symbol lookup by imitating "activated" paths. func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool { - return ps.Partition() == "system" + return s.filesystem.filterInstallablePackagingSpec(ps) && ps.Partition() == "system" } diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go index 47fd8f439..306d65e29 100644 --- a/fuzz/fuzz_common.go +++ b/fuzz/fuzz_common.go @@ -449,10 +449,10 @@ func IsValidFrameworkForModule(targetFramework Framework, lang Lang, moduleFrame } } -func IsValid(fuzzModule FuzzModule) bool { +func IsValid(ctx android.ConfigAndErrorContext, fuzzModule FuzzModule) bool { // Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of // fuzz targets we're going to package anyway. - if !fuzzModule.Enabled() || fuzzModule.InRamdisk() || fuzzModule.InVendorRamdisk() || fuzzModule.InRecovery() { + if !fuzzModule.Enabled(ctx) || fuzzModule.InRamdisk() || fuzzModule.InVendorRamdisk() || fuzzModule.InRecovery() { return false } diff --git a/genrule/genrule.go b/genrule/genrule.go index 43f4fe5ee..67b96ca92 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -299,7 +299,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { case android.HostToolProvider: // A HostToolProvider provides the path to a tool, which will be copied // into the sandbox. - if !t.(android.Module).Enabled() { + if !t.(android.Module).Enabled(ctx) { if ctx.Config().AllowMissingDependencies() { ctx.AddMissingDependencies([]string{tool}) } else { @@ -714,13 +714,13 @@ func NewGenSrcs() *Module { rule := getSandboxedRuleBuilder(ctx, android.NewRuleBuilder(pctx, ctx).Sbox(genDir, nil)) for _, in := range shard { - outFile := android.GenPathWithExt(ctx, finalSubDir, in, String(properties.Output_extension)) + outFile := android.GenPathWithExtAndTrimExt(ctx, finalSubDir, in, String(properties.Output_extension), String(properties.Trim_extension)) // If sharding is enabled, then outFile is the path to the output file in // the shard directory, and copyTo is the path to the output file in the // final directory. if len(shards) > 1 { - shardFile := android.GenPathWithExt(ctx, genSubDir, in, String(properties.Output_extension)) + shardFile := android.GenPathWithExtAndTrimExt(ctx, genSubDir, in, String(properties.Output_extension), String(properties.Trim_extension)) copyTo = append(copyTo, outFile) outFile = shardFile } @@ -786,6 +786,9 @@ type genSrcsProperties struct { // Additional files needed for build that are not tooling related. Data []string `android:"path"` + + // Trim the matched extension for each input file, and it should start with ".". + Trim_extension *string } const defaultShardSize = 50 diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go index 2dc6a7954..1df887b3e 100644 --- a/genrule/genrule_test.go +++ b/genrule/genrule_test.go @@ -894,6 +894,155 @@ func TestGenSrcsWithSrcsFromExternalPackage(t *testing.T) { ) } +func TestGenSrcsWithTrimExtAndOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: [ + "baz.a.b.c.proto/baz.a.b.c.proto", + "bar.a.b.c.proto", + "qux.ext.a.b.c.proto", + ], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + trim_extension: ".a.b.c.proto", + output_extension: "proto.h", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo.proto.h", + exportedIncludeDir + "/external-protos/path/baz.a.b.c.proto/baz.proto.h", + exportedIncludeDir + "/external-protos/path/bar.proto.h", + exportedIncludeDir + "/external-protos/path/qux.ext.proto.h", + }, + gen.outputFiles, + ) +} + +func TestGenSrcsWithTrimExtButNoOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: [ + "baz.a.b.c.proto/baz.a.b.c.proto", + "bar.a.b.c.proto", + "qux.ext.a.b.c.proto", + ], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + trim_extension: ".a.b.c.proto", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo", + exportedIncludeDir + "/external-protos/path/baz.a.b.c.proto/baz", + exportedIncludeDir + "/external-protos/path/bar", + exportedIncludeDir + "/external-protos/path/qux.ext", + }, + gen.outputFiles, + ) +} + +func TestGenSrcsWithOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: ["baz/baz.a.b.c.proto", "bar.a.b.c.proto"], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + output_extension: "proto.h", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo.a.b.c.proto.h", + exportedIncludeDir + "/external-protos/path/baz/baz.a.b.c.proto.h", + exportedIncludeDir + "/external-protos/path/bar.a.b.c.proto.h", + }, + gen.outputFiles, + ) +} + func TestPrebuiltTool(t *testing.T) { testcases := []struct { name string diff --git a/java/aar_test.go b/java/aar_test.go index d6dbe3c25..18efd2067 100644 --- a/java/aar_test.go +++ b/java/aar_test.go @@ -15,8 +15,9 @@ package java import ( - "android/soong/android" "testing" + + "android/soong/android" ) func TestAarImportProducesJniPackages(t *testing.T) { @@ -98,6 +99,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -105,6 +107,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/androidmk.go b/java/androidmk.go index a52d43965..9cd0bafea 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -92,11 +92,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { if len(library.logtagsSrcs) > 0 { - var logtags []string - for _, l := range library.logtagsSrcs { - logtags = append(logtags, l.Rel()) - } - entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...) + entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", library.logtagsSrcs.Strings()...) } if library.installFile == nil { @@ -457,6 +453,8 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { if app.Name() != "framework-res" { android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles) } + + entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", app.logtagsSrcs.Strings()...) }, }, ExtraFooters: []android.AndroidMkExtraFootersFunc{ diff --git a/java/app_import_test.go b/java/app_import_test.go index 5de50e794..496fc1308 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -509,7 +509,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -586,7 +586,7 @@ func TestAndroidAppImport_SoongConfigVariables(t *testing.T) { variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -629,7 +629,7 @@ func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) { if !a.prebuilt.UsePrebuilt() { t.Errorf("prebuilt foo module is not active") } - if !a.Enabled() { + if !a.Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Errorf("prebuilt foo module is disabled") } } diff --git a/java/app_test.go b/java/app_test.go index eab40e7da..a7c48a1ed 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -4382,6 +4382,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -4389,6 +4390,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/boot_jars.go b/java/boot_jars.go index 5d40ec389..6223dede8 100644 --- a/java/boot_jars.go +++ b/java/boot_jars.go @@ -21,8 +21,8 @@ import ( // isActiveModule returns true if the given module should be considered for boot // jars, i.e. if it's enabled and the preferred one in case of source and // prebuilt alternatives. -func isActiveModule(module android.Module) bool { - if !module.Enabled() { +func isActiveModule(ctx android.ConfigAndErrorContext, module android.Module) bool { + if !module.Enabled(ctx) { return false } return android.IsModulePreferred(module) diff --git a/java/bootclasspath.go b/java/bootclasspath.go index c7dc3afae..77ddf5c05 100644 --- a/java/bootclasspath.go +++ b/java/bootclasspath.go @@ -127,7 +127,10 @@ func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variat // added by addDependencyOntoApexModulePair. func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module { var modules []android.Module - ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) { + isActiveModulePred := func(module android.Module) bool { + return isActiveModule(ctx, module) + } + ctx.VisitDirectDepsIf(isActiveModulePred, func(module android.Module) { t := ctx.OtherModuleDependencyTag(module) if t == tag { modules = append(modules, module) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index cc3da7656..82a34ca9d 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -474,7 +474,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // Only perform a consistency check if this module is the active module. That will prevent an // unused prebuilt that was created without instrumentation from breaking an instrumentation // build. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { b.bootclasspathFragmentPropertyCheck(ctx) } @@ -519,7 +519,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // empty string if this module should not provide a boot image profile. func (b *BootclasspathFragmentModule) getProfileProviderApex(ctx android.BaseModuleContext) string { // Only use the profile from the module that is preferred. - if !isActiveModule(ctx.Module()) { + if !isActiveModule(ctx, ctx.Module()) { return "" } @@ -590,7 +590,7 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. // TODO(b/202896428): Add better way to handle this. _, unknown = android.RemoveFromList("android.car-module", unknown) - if isActiveModule(ctx.Module()) && len(unknown) > 0 { + if isActiveModule(ctx, ctx.Module()) && len(unknown) > 0 { ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) } } diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index f7e3cb93a..7229ca02d 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -562,7 +562,7 @@ func gatherBootclasspathFragments(ctx android.ModuleContext) map[string]android. return ctx.Config().Once(dexBootJarsFragmentsKey, func() interface{} { fragments := make(map[string]android.Module) ctx.WalkDeps(func(child, parent android.Module) bool { - if !isActiveModule(child) { + if !isActiveModule(ctx, child) { return false } tag := ctx.OtherModuleDependencyTag(child) @@ -1125,7 +1125,7 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p image.unstrippedInstalls = unstrippedInstalls // Only set the licenseMetadataFile from the active module. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) } diff --git a/java/droidstubs.go b/java/droidstubs.go index 08caf9109..730be14b0 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -604,6 +604,11 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } } +// AndroidPlusUpdatableJar is the name of some extra jars added into `module-lib` and +// `system-server` directories that contain all the APIs provided by the platform and updatable +// modules because the `android.jar` files do not. See b/337836752. +const AndroidPlusUpdatableJar = "android-plus-updatable.jar" + func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) { if len(d.properties.Api_levels_annotations_dirs) == 0 { ctx.PropertyErrorf("api_levels_annotations_dirs", @@ -621,7 +626,8 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // privileged apps that are only defined since API level 21 (Lollipop), fallback to public stubs // for older releases. Similarly, module-lib falls back to system API. var sdkDirs []string - switch proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") { + apiLevelsSdkType := proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") + switch apiLevelsSdkType { case "system-server": sdkDirs = []string{"system-server", "module-lib", "system", "public"} case "module-lib": @@ -635,9 +641,22 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an return } + // Construct a pattern to match the appropriate extensions that should be included in the + // generated api-versions.xml file. + // // Use the first item in the sdkDirs array as that is the sdk type for the target API levels // being generated but has the advantage over `Api_levels_sdk_type` as it has been validated. - extensionsPattern := fmt.Sprintf(`/extensions/[0-9]+/%s/.*\.jar`, sdkDirs[0]) + // The exception is for system-server which needs to include module-lib and system-server. That + // is because while system-server extends module-lib the system-server extension directory only + // contains service-* modules which provide system-server APIs it does not list the modules which + // only provide a module-lib, so they have to be included separately. + extensionSurfacesPattern := sdkDirs[0] + if apiLevelsSdkType == "system-server" { + // Take the first two items in sdkDirs, which are system-server and module-lib, and construct + // a pattern that will match either. + extensionSurfacesPattern = strings.Join(sdkDirs[0:2], "|") + } + extensionsPattern := fmt.Sprintf(`/extensions/[0-9]+/(%s)/.*\.jar`, extensionSurfacesPattern) var dirs []string var extensions_dir string @@ -648,16 +667,24 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // Grab the first extensions_dir and we find while scanning ExportedDroiddocDir.deps; // ideally this should be read from prebuiltApis.properties.Extensions_* for _, dep := range t.deps { + // Check to see if it matches an extension first. + depBase := dep.Base() if extRegex.MatchString(dep.String()) && d.properties.Extensions_info_file != nil { if extensions_dir == "" { extensions_dir = t.dir.String() + "/extensions" } cmd.Implicit(dep) - } - if dep.Base() == filename { + } else if depBase == filename { + // Check to see if it matches a dessert release for an SDK, e.g. Android, Car, Wear, etc.. cmd.Implicit(dep) - } - if filename != "android.jar" && dep.Base() == "android.jar" { + } else if depBase == AndroidPlusUpdatableJar && d.properties.Extensions_info_file != nil { + // The output api-versions.xml has been requested to include information on SDK + // extensions. That means it also needs to include + // so + // The module-lib and system-server directories should use `android-plus-updatable.jar` + // instead of `android.jar`. See AndroidPlusUpdatableJar for more information. + cmd.Implicit(dep) + } else if filename != "android.jar" && depBase == "android.jar" { // Metalava implicitly searches these patterns: // prebuilts/tools/common/api-versions/android-%/android.jar // prebuilts/sdk/%/public/android.jar @@ -675,9 +702,25 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an } }) + // Generate the list of --android-jar-pattern options. The order matters so the first one which + // matches will be the one that is used for a specific api level.. for _, sdkDir := range sdkDirs { for _, dir := range dirs { - cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, filename)) + addPattern := func(jarFilename string) { + cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, jarFilename)) + } + + if sdkDir == "module-lib" || sdkDir == "system-server" { + // The module-lib and system-server android.jars do not include the updatable modules (as + // doing so in the source would introduce dependency cycles and the prebuilts have to + // match the sources). So, instead an additional `android-plus-updatable.jar` will be used + // that does include the updatable modules and this pattern will match that. This pattern + // is added in addition to the following pattern to decouple this change from the change + // to add the `android-plus-updatable.jar`. + addPattern(AndroidPlusUpdatableJar) + } + + addPattern(filename) } } @@ -1327,7 +1370,7 @@ func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) { // use a strict naming convention var ( droidstubsModuleNamingToSdkKind = map[string]android.SdkKind{ - //public is commented out since the core libraries use public in their java_sdk_library names + // public is commented out since the core libraries use public in their java_sdk_library names "intracore": android.SdkIntraCore, "intra.core": android.SdkIntraCore, "system_server": android.SdkSystemServer, diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 8da695f08..6a14f3645 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -379,6 +379,7 @@ func TestAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -434,6 +435,7 @@ func TestReleaseExportRuntimeApis(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/fuzz.go b/java/fuzz.go index fb31ce794..d37c55804 100644 --- a/java/fuzz.go +++ b/java/fuzz.go @@ -179,7 +179,7 @@ func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) { javaFuzzModule.ApexModuleBase, } - if ok := fuzz.IsValid(fuzzModuleValidator); !ok { + if ok := fuzz.IsValid(ctx, fuzzModuleValidator); !ok { return } diff --git a/java/gen.go b/java/gen.go index 68a9b53fe..1b4f4c7dc 100644 --- a/java/gen.go +++ b/java/gen.go @@ -27,7 +27,6 @@ import ( func init() { pctx.SourcePathVariable("logtagsCmd", "build/make/tools/java-event-log-tags.py") - pctx.SourcePathVariable("mergeLogtagsCmd", "build/make/tools/merge-event-log-tags.py") pctx.SourcePathVariable("logtagsLib", "build/make/tools/event_log_tags.py") } @@ -37,12 +36,6 @@ var ( Command: "$logtagsCmd -o $out $in", CommandDeps: []string{"$logtagsCmd", "$logtagsLib"}, }) - - mergeLogtags = pctx.AndroidStaticRule("mergeLogtags", - blueprint.RuleParams{ - Command: "$mergeLogtagsCmd -o $out $in", - CommandDeps: []string{"$mergeLogtagsCmd", "$logtagsLib"}, - }) ) func genAidl(ctx android.ModuleContext, aidlFiles android.Paths, aidlGlobalFlags string, aidlIndividualFlags map[string]string, deps android.Paths) android.Paths { @@ -178,37 +171,9 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths, outSrcFiles = append(outSrcFiles, srcJarFiles...) } - return outSrcFiles -} - -func LogtagsSingleton() android.Singleton { - return &logtagsSingleton{} -} - -type logtagsProducer interface { - logtags() android.Paths -} - -func (j *Module) logtags() android.Paths { - return j.logtagsSrcs -} - -var _ logtagsProducer = (*Module)(nil) - -type logtagsSingleton struct{} - -func (l *logtagsSingleton) GenerateBuildActions(ctx android.SingletonContext) { - var allLogtags android.Paths - ctx.VisitAllModules(func(module android.Module) { - if logtags, ok := module.(logtagsProducer); ok { - allLogtags = append(allLogtags, logtags.logtags()...) - } + android.SetProvider(ctx, android.LogtagsProviderKey, &android.LogtagsInfo{ + Logtags: j.logtagsSrcs, }) - ctx.Build(pctx, android.BuildParams{ - Rule: mergeLogtags, - Description: "merge logtags", - Output: android.PathForIntermediates(ctx, "all-event-log-tags.txt"), - Inputs: allLogtags, - }) + return outSrcFiles } diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index ae587eac3..cab5402e9 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -1428,7 +1428,7 @@ func deferReportingMissingBootDexJar(ctx android.ModuleContext, module android.M // should not contribute to anything. So, rather than have a missing dex jar cause a Soong // failure defer the error reporting to Ninja. Unless the prebuilt build target is explicitly // built Ninja should never use the dex jar file. - if !isActiveModule(module) { + if !isActiveModule(ctx, module) { return true } diff --git a/java/jacoco.go b/java/jacoco.go index a820b3855..696a0cc37 100644 --- a/java/jacoco.go +++ b/java/jacoco.go @@ -53,7 +53,7 @@ func jacocoDepsMutator(ctx android.BottomUpMutatorContext) { } j, ok := ctx.Module().(instrumentable) - if !ctx.Module().Enabled() || !ok { + if !ctx.Module().Enabled(ctx) || !ok { return } diff --git a/java/java.go b/java/java.go index 725e25abe..30581f265 100644 --- a/java/java.go +++ b/java/java.go @@ -75,7 +75,6 @@ func registerJavaBuildComponents(ctx android.RegistrationContext) { ctx.BottomUp("jacoco_deps", jacocoDepsMutator).Parallel() }) - ctx.RegisterParallelSingletonType("logtags", LogtagsSingleton) ctx.RegisterParallelSingletonType("kythe_java_extract", kytheExtractJavaFactory) } diff --git a/java/java_test.go b/java/java_test.go index a1192bb5f..2f2793202 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2801,6 +2801,7 @@ func TestApiLibraryAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/jdeps.go b/java/jdeps.go index 91f7ce715..340026318 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -48,7 +48,7 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont moduleInfos := make(map[string]android.IdeInfo) ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } diff --git a/java/lint.go b/java/lint.go index 31e7f353d..82fac91cf 100644 --- a/java/lint.go +++ b/java/lint.go @@ -612,7 +612,7 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { apiVersionsDb := findModuleOrErr(ctx, files.apiVersionsModule) if apiVersionsDb == nil { if !ctx.Config().AllowMissingDependencies() { - ctx.Errorf("lint: missing module api_versions_public") + ctx.Errorf("lint: missing module %s", files.apiVersionsModule) } return } @@ -620,7 +620,7 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { sdkAnnotations := findModuleOrErr(ctx, files.annotationsModule) if sdkAnnotations == nil { if !ctx.Config().AllowMissingDependencies() { - ctx.Errorf("lint: missing module sdk-annotations.zip") + ctx.Errorf("lint: missing module %s", files.annotationsModule) } return } diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 2fc6c02a6..99fa092be 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -19,6 +19,7 @@ import ( "path/filepath" "android/soong/android" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -233,7 +234,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet var compatConfigMetadata android.Paths ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } if c, ok := module.(platformCompatConfigMetadataProvider); ok { diff --git a/java/rro_test.go b/java/rro_test.go index d697ec627..742c83982 100644 --- a/java/rro_test.go +++ b/java/rro_test.go @@ -421,6 +421,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -428,6 +429,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/sdk_library.go b/java/sdk_library.go index 113071fbb..2b6c8f8de 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2294,7 +2294,7 @@ func (module *SdkLibrary) getApiDir() string { // 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() { + if !module.Enabled(mctx) { return } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 0f163e6e0..34c63ac61 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1715,6 +1715,7 @@ func TestSdkLibraryExportableStubsLibrary(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/provenance/provenance_singleton.go b/provenance/provenance_singleton.go index 97345afc3..679632c10 100644 --- a/provenance/provenance_singleton.go +++ b/provenance/provenance_singleton.go @@ -18,6 +18,7 @@ package provenance import ( "android/soong/android" + "github.com/google/blueprint" ) @@ -68,6 +69,15 @@ type provenanceInfoSingleton struct { func (p *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) { allMetaDataFiles := make([]android.Path, 0) + moduleFilter := func(module android.Module) bool { + if !module.Enabled(context) || module.IsSkipInstall() { + return false + } + if p, ok := module.(ProvenanceMetadata); ok { + return p.ProvenanceMetaDataFile().String() != "" + } + return false + } context.VisitAllModulesIf(moduleFilter, func(module android.Module) { if p, ok := module.(ProvenanceMetadata); ok { allMetaDataFiles = append(allMetaDataFiles, p.ProvenanceMetaDataFile()) @@ -91,16 +101,6 @@ func (p *provenanceInfoSingleton) GenerateBuildActions(context android.Singleton context.Phony("droidcore", android.PathForPhony(context, "provenance_metadata")) } -func moduleFilter(module android.Module) bool { - if !module.Enabled() || module.IsSkipInstall() { - return false - } - if p, ok := module.(ProvenanceMetadata); ok { - return p.ProvenanceMetaDataFile().String() != "" - } - return false -} - func GenerateArtifactProvenanceMetaData(ctx android.ModuleContext, artifactPath android.Path, installedFile android.InstallPath) android.OutputPath { onDevicePathOfInstalledFile := android.InstallPathToOnDevicePath(ctx, installedFile) artifactMetaDataFile := android.PathForIntermediates(ctx, "provenance_metadata", ctx.ModuleDir(), ctx.ModuleName(), "provenance_metadata.textproto") diff --git a/rust/afdo.go b/rust/afdo.go index 6116c5e21..6bd4bae1a 100644 --- a/rust/afdo.go +++ b/rust/afdo.go @@ -39,7 +39,7 @@ func (afdo *afdo) addDep(ctx BaseModuleContext, actx android.BottomUpMutatorCont return } - if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() { + if mod, ok := ctx.Module().(*Module); ok && mod.Enabled(ctx) { fdoProfileName, err := actx.DeviceConfig().AfdoProfile(actx.ModuleName()) if err != nil { ctx.ModuleErrorf("%s", err.Error()) diff --git a/rust/bindgen.go b/rust/bindgen.go index eaed1b9d4..427775351 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -102,8 +102,17 @@ type BindgenProperties struct { // "my_bindgen [flags] wrapper_header.h -o [output_path] -- [clang flags]" Custom_bindgen string - // flag to indicate if bindgen should handle `static inline` functions (default is false) - Handle_static_inline bool + // flag to indicate if bindgen should handle `static inline` functions (default is false). + // If true, Static_inline_library must be set. + Handle_static_inline *bool + + // module name of the corresponding cc_library_static which includes the static_inline wrapper + // generated functions from bindgen. Must be used together with handle_static_inline. + // + // If there are no static inline functions provided through the header file, + // then bindgen (as of 0.69.2) will silently fail to output a .c file, and + // the cc_library_static depending on this module will fail compilation. + Static_inline_library *string } type bindgenDecorator struct { @@ -159,6 +168,18 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr var cflags []string var implicits android.Paths + var implicitOutputs android.WritablePaths + var validations android.Paths + + if Bool(b.Properties.Handle_static_inline) && b.Properties.Static_inline_library == nil { + ctx.PropertyErrorf("handle_static_inline", + "requires declaring static_inline_library to the corresponding cc_library module that includes the generated C source from bindgen.") + } + + if b.Properties.Static_inline_library != nil && !Bool(b.Properties.Handle_static_inline) { + ctx.PropertyErrorf("static_inline_library", + "requires declaring handle_static_inline.") + } implicits = append(implicits, deps.depGeneratedHeaders...) @@ -235,8 +256,11 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr bindgenFlags := defaultBindgenFlags bindgenFlags = append(bindgenFlags, esc(b.Properties.Bindgen_flags)...) - if b.Properties.Handle_static_inline { - bindgenFlags = append(bindgenFlags, "--experimental --wrap-static-fns") + if Bool(b.Properties.Handle_static_inline) { + outputStaticFnsFile := android.PathForModuleOut(ctx, b.BaseSourceProvider.getStem(ctx)+".c") + implicitOutputs = append(implicitOutputs, outputStaticFnsFile) + validations = append(validations, outputStaticFnsFile) + bindgenFlags = append(bindgenFlags, []string{"--experimental", "--wrap-static-fns", "--wrap-static-fns-path=" + outputStaticFnsFile.String()}...) } // cat reads from stdin if its command line is empty, @@ -285,11 +309,13 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr } ctx.Build(pctx, android.BuildParams{ - Rule: bindgen, - Description: strings.Join([]string{cmdDesc, wrapperFile.Path().Rel()}, " "), - Output: outputFile, - Input: wrapperFile.Path(), - Implicits: implicits, + Rule: bindgen, + Description: strings.Join([]string{cmdDesc, wrapperFile.Path().Rel()}, " "), + Output: outputFile, + Input: wrapperFile.Path(), + Implicits: implicits, + ImplicitOutputs: implicitOutputs, + Validations: validations, Args: map[string]string{ "cmd": cmd, "flags": strings.Join(bindgenFlags, " "), @@ -299,6 +325,14 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr }) b.BaseSourceProvider.OutputFiles = android.Paths{outputFile} + + // Append any additional implicit outputs after the entry point source. + // We append any generated .c file here so it can picked up by cc_library_static modules. + // Those CC modules need to be sure not to pass any included .rs files to Clang. + // We don't have to worry about the additional .c files for Rust modules as only the entry point + // is passed to rustc. + b.BaseSourceProvider.OutputFiles = append(b.BaseSourceProvider.OutputFiles, implicitOutputs.Paths()...) + return outputFile } @@ -350,6 +384,14 @@ func (b *bindgenDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) Deps { deps = muslDeps(ctx, deps, false) } + if !ctx.RustModule().Source() && b.Properties.Static_inline_library != nil { + // This is not the source variant, so add the static inline library as a dependency. + // + // This is necessary to avoid a circular dependency between the source variant and the + // dependent cc module. + deps.StaticLibs = append(deps.StaticLibs, String(b.Properties.Static_inline_library)) + } + deps.SharedLibs = append(deps.SharedLibs, b.ClangProperties.Shared_libs...) deps.StaticLibs = append(deps.StaticLibs, b.ClangProperties.Static_libs...) deps.HeaderLibs = append(deps.HeaderLibs, b.ClangProperties.Header_libs...) diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go index 11cfe4e88..2b7362f08 100644 --- a/rust/bindgen_test.go +++ b/rust/bindgen_test.go @@ -228,7 +228,6 @@ func TestBindgenFlagFile(t *testing.T) { // we may be able to check libbinder.RuleParams.Command to see if it contains $(cat /dev/null flag_file.txt) } - func TestBindgenHandleStaticInlining(t *testing.T) { ctx := testRust(t, ` rust_bindgen { @@ -237,7 +236,14 @@ func TestBindgenHandleStaticInlining(t *testing.T) { crate_name: "bindgen", stem: "libbindgen", source_stem: "bindings", - handle_static_inline: true + handle_static_inline: true, + static_inline_library: "libbindgen_staticfns" + } + + cc_library_static { + name: "libbindgen_staticfns", + srcs: [":libbindgen"], + include_dirs: ["src/"], } `) libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs") @@ -245,4 +251,39 @@ func TestBindgenHandleStaticInlining(t *testing.T) { if !strings.Contains(libbindgen.Args["flags"], "--wrap-static-fns") { t.Errorf("missing flag to handle static inlining in rust_bindgen rule: flags %#v", libbindgen.Args["flags"]) } + + if !strings.Contains(libbindgen.Args["flags"], "--wrap-static-fns-path") { + t.Errorf("missing flag to define path for static inlining C source from bindgen (--wrap-static-fns-path): flags %#v", libbindgen.Args["flags"]) + } + +} + +func TestBindgenStaticInlineProperties(t *testing.T) { + // Make sure handle_static_inline without static_inline_library generates an error + testRustError(t, "requires declaring static_inline_library to the corresponding cc_library module that includes the generated C source from bindgen", ` + rust_bindgen { + name: "libbindgen", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + handle_static_inline: true + } + `) + testRustError(t, "requires declaring handle_static_inline", ` + rust_bindgen { + name: "libbindgen", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + static_inline_library: "libbindgen_staticfns" + } + + cc_library_static { + name: "libbindgen_staticfns", + srcs: [":libbindgen"], + include_dirs: ["src/"], + } + `) } diff --git a/rust/config/global.go b/rust/config/global.go index 03333b80c..e83e23aa5 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -24,7 +24,7 @@ import ( var ( pctx = android.NewPackageContext("android/soong/rust/config") - RustDefaultVersion = "1.77.1" + RustDefaultVersion = "1.77.1.p1" RustDefaultBase = "prebuilts/rust/" DefaultEdition = "2021" Stdlibs = []string{ diff --git a/rust/doc.go b/rust/doc.go index 6970d7979..fe205233d 100644 --- a/rust/doc.go +++ b/rust/doc.go @@ -38,7 +38,7 @@ func (n *rustdocSingleton) GenerateBuildActions(ctx android.SingletonContext) { FlagWithArg("-D ", docDir.String()) ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } diff --git a/rust/library.go b/rust/library.go index 6be4917bf..f58a54fcc 100644 --- a/rust/library.go +++ b/rust/library.go @@ -713,7 +713,7 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) { if sourceVariant { sv := modules[0] for _, v := range modules[1:] { - if !v.Enabled() { + if !v.Enabled(mctx) { continue } mctx.AddInterVariantDependency(sourceDepTag, v, sv) diff --git a/rust/project_json.go b/rust/project_json.go index 05fc09b3a..24dcc89f1 100644 --- a/rust/project_json.go +++ b/rust/project_json.go @@ -119,7 +119,7 @@ func isModuleSupported(ctx android.SingletonContext, module android.Module) (*Mo if !ok { return nil, false } - if !rModule.Enabled() { + if !rModule.Enabled(ctx) { return nil, false } return rModule, true diff --git a/rust/rust.go b/rust/rust.go index c2b61515c..de049f77f 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -1697,7 +1697,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { } func BeginMutator(ctx android.BottomUpMutatorContext) { - if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() { + if mod, ok := ctx.Module().(*Module); ok && mod.Enabled(ctx) { mod.beginMutator(ctx) } } diff --git a/rust/sanitize.go b/rust/sanitize.go index bfd397155..c086880ed 100644 --- a/rust/sanitize.go +++ b/rust/sanitize.go @@ -258,7 +258,7 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps { func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { if mod, ok := mctx.Module().(*Module); ok && mod.sanitize != nil { - if !mod.Enabled() { + if !mod.Enabled(mctx) { return } diff --git a/scripts/gen-kotlin-build-file.py b/scripts/gen-kotlin-build-file.py index 83b4cd8a3..99afdca75 100644 --- a/scripts/gen-kotlin-build-file.py +++ b/scripts/gen-kotlin-build-file.py @@ -79,7 +79,7 @@ def main(): elif src.endswith('.kt'): f.write(' <sources path="%s"/>\n' % path) else: - raise RuntimeError('unknown source file type %s' % file) + raise RuntimeError(f'unknown source file type {src} from rspfile {rsp_file}') for rsp_file in args.common_srcs: for src in NinjaRspFileReader(rsp_file): diff --git a/scripts/run-soong-tests-with-go-tools.sh b/scripts/run-soong-tests-with-go-tools.sh index 93c622ea4..1fbb1fc77 100755 --- a/scripts/run-soong-tests-with-go-tools.sh +++ b/scripts/run-soong-tests-with-go-tools.sh @@ -74,6 +74,6 @@ for dir in "${go_modules[@]}"; do (cd "$dir"; eval ${network_jail} -- ${GOROOT}/bin/go build ./... eval ${network_jail} -- ${GOROOT}/bin/go test ./... - eval ${network_jail} -- ${GOROOT}/bin/go test -race -short ./... + eval ${network_jail} -- ${GOROOT}/bin/go test -race -timeout 20m -short ./... ) done diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go index 63cd4e1b6..b416ebdd4 100644 --- a/snapshot/host_fake_snapshot.go +++ b/snapshot/host_fake_snapshot.go @@ -116,7 +116,7 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) { prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true return } - if !module.Enabled() || module.IsHideFromMake() { + if !module.Enabled(ctx) || module.IsHideFromMake() { return } apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider) diff --git a/ui/build/rbe.go b/ui/build/rbe.go index 5142a416f..8fa147f70 100644 --- a/ui/build/rbe.go +++ b/ui/build/rbe.go @@ -159,12 +159,6 @@ func CheckProdCreds(ctx Context, config Config) { fmt.Fprintln(ctx.Writer, "") return } - if config.GoogleProdCredsExist() { - return - } - fmt.Fprintln(ctx.Writer, "") - fmt.Fprintln(ctx.Writer, "\033[33mWARNING: Missing LOAS credentials, please run `gcert`. This is required for a successful build execution. See go/rbe-android-default-announcement for more information.\033[0m") - fmt.Fprintln(ctx.Writer, "") } // DumpRBEMetrics creates a metrics protobuf file containing RBE related metrics. |