diff options
65 files changed, 857 insertions, 498 deletions
diff --git a/Android.bp b/Android.bp index 432c7fc4f..535246e65 100644 --- a/Android.bp +++ b/Android.bp @@ -1,5 +1,8 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], + default_visibility: [ + "//build/soong:__subpackages__", + ], } subdirs = [ @@ -23,6 +26,8 @@ bootstrap_go_package { srcs: [ "doc.go", ], + // Used by plugins, though probably shouldn't be. + visibility: ["//visibility:public"], } // @@ -40,6 +45,7 @@ cc_defaults { enabled: true, }, }, + defaults_visibility: ["//visibility:public"], } // @@ -51,6 +57,7 @@ kernel_headers { vendor: true, recovery_available: true, min_sdk_version: "apex_inherit", + visibility: ["//visibility:public"], } cc_genrule { @@ -75,6 +82,7 @@ cc_genrule { cmd: "$(location) -s $(out) $(in)", srcs: [":linker"], out: ["linker.s"], + visibility: ["//bionic/libc"], } cc_genrule { @@ -99,11 +107,13 @@ cc_genrule { cmd: "$(location) -T $(out) $(in)", srcs: [":linker"], out: ["linker.script"], + visibility: ["//visibility:public"], } // Instantiate the dex_bootjars singleton module. dex_bootjars { name: "dex_bootjars", + visibility: ["//visibility:public"], } // Pseudo-test that's run on checkbuilds to ensure that get_clang_version can @@ -123,6 +133,7 @@ dexpreopt_systemserver_check { // container for apex_contributions selected using build flags all_apex_contributions { name: "all_apex_contributions", + visibility: ["//visibility:public"], } product_config { diff --git a/aidl_library/Android.bp b/aidl_library/Android.bp index ec2150427..07472a492 100644 --- a/aidl_library/Android.bp +++ b/aidl_library/Android.bp @@ -29,4 +29,5 @@ bootstrap_go_package { "aidl_library_test.go", ], pluginFor: ["soong_build"], + visibility: ["//visibility:public"], } diff --git a/android/Android.bp b/android/Android.bp index 16a34b7de..2adedfea7 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -88,6 +88,7 @@ bootstrap_go_package { "prebuilt.go", "prebuilt_build_tool.go", "product_config.go", + "product_config_to_bp.go", "proto.go", "provider.go", "raw_files.go", @@ -154,4 +155,6 @@ bootstrap_go_package { "vintf_fragment_test.go", "visibility_test.go", ], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/android/arch.go b/android/arch.go index a7868bac4..942727ace 100644 --- a/android/arch.go +++ b/android/arch.go @@ -396,20 +396,21 @@ func (target Target) Variations() []blueprint.Variation { // device_supported and host_supported properties to determine which OsTypes are enabled for this // module, then searches through the Targets to determine which have enabled Targets for this // module. -func osMutator(mctx BottomUpMutatorContext) { - module := mctx.Module() - base := module.base() +type osTransitionMutator struct{} - // Nothing to do for modules that are not architecture specific (e.g. a genrule). - if !base.ArchSpecific() { - return - } +type allOsInfo struct { + Os map[string]OsType + Variations []string +} + +var allOsProvider = blueprint.NewMutatorProvider[*allOsInfo]("os_propagate") - // Collect a list of OSTypes supported by this module based on the HostOrDevice value - // passed to InitAndroidArchModule and the device_supported and host_supported properties. +// moduleOSList collects a list of OSTypes supported by this module based on the HostOrDevice +// value passed to InitAndroidArchModule and the device_supported and host_supported properties. +func moduleOSList(ctx ConfigContext, base *ModuleBase) []OsType { var moduleOSList []OsType for _, os := range osTypeList { - for _, t := range mctx.Config().Targets[os] { + for _, t := range ctx.Config().Targets[os] { if base.supportsTarget(t) { moduleOSList = append(moduleOSList, os) break @@ -417,53 +418,91 @@ func osMutator(mctx BottomUpMutatorContext) { } } - createCommonOSVariant := base.commonProperties.CreateCommonOSVariant + if base.commonProperties.CreateCommonOSVariant { + // A CommonOS variant was requested so add it to the list of OS variants to + // create. It needs to be added to the end because it needs to depend on the + // the other variants and inter variant dependencies can only be created from a + // later variant in that list to an earlier one. That is because variants are + // always processed in the order in which they are created. + moduleOSList = append(moduleOSList, CommonOS) + } + + return moduleOSList +} + +func (o *osTransitionMutator) Split(ctx BaseModuleContext) []string { + module := ctx.Module() + base := module.base() + + // Nothing to do for modules that are not architecture specific (e.g. a genrule). + if !base.ArchSpecific() { + return []string{""} + } + + moduleOSList := moduleOSList(ctx, base) // If there are no supported OSes then disable the module. - if len(moduleOSList) == 0 && !createCommonOSVariant { + if len(moduleOSList) == 0 { base.Disable() - return + return []string{""} } // Convert the list of supported OsTypes to the variation names. osNames := make([]string, len(moduleOSList)) + osMapping := make(map[string]OsType, len(moduleOSList)) for i, os := range moduleOSList { osNames[i] = os.String() + osMapping[osNames[i]] = os } - if createCommonOSVariant { - // A CommonOS variant was requested so add it to the list of OS variants to - // create. It needs to be added to the end because it needs to depend on the - // the other variants in the list returned by CreateVariations(...) and inter - // variant dependencies can only be created from a later variant in that list to - // an earlier one. That is because variants are always processed in the order in - // which they are returned from CreateVariations(...). - osNames = append(osNames, CommonOS.Name) - moduleOSList = append(moduleOSList, CommonOS) + SetProvider(ctx, allOsProvider, &allOsInfo{ + Os: osMapping, + Variations: osNames, + }) + + return osNames +} + +func (o *osTransitionMutator) OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string { + return sourceVariation +} + +func (o *osTransitionMutator) IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string { + module := ctx.Module() + base := module.base() + + if !base.ArchSpecific() { + return "" } - // Create the variations, annotate each one with which OS it was created for, and - // squash the appropriate OS-specific properties into the top level properties. - modules := mctx.CreateVariations(osNames...) - for i, m := range modules { - m.base().commonProperties.CompileOS = moduleOSList[i] - m.base().setOSProperties(mctx) + return incomingVariation +} + +func (o *osTransitionMutator) Mutate(ctx BottomUpMutatorContext, variation string) { + module := ctx.Module() + base := module.base() + + if variation == "" { + return } - if createCommonOSVariant { + allOsInfo, ok := ModuleProvider(ctx, allOsProvider) + if !ok { + panic(fmt.Errorf("missing allOsProvider")) + } + + // Annotate this variant with which OS it was created for, and + // squash the appropriate OS-specific properties into the top level properties. + base.commonProperties.CompileOS = allOsInfo.Os[variation] + base.setOSProperties(ctx) + + if variation == CommonOS.String() { // A CommonOS variant was requested so add dependencies from it (the last one in // the list) to the OS type specific variants. - last := len(modules) - 1 - commonOSVariant := modules[last] - commonOSVariant.base().commonProperties.CommonOSVariant = true - for _, module := range modules[0:last] { - // Ignore modules that are enabled. Note, this will only avoid adding - // 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(mctx) { - mctx.AddInterVariantDependency(commonOsToOsSpecificVariantTag, commonOSVariant, module) - } + osList := allOsInfo.Variations[:len(allOsInfo.Variations)-1] + for _, os := range osList { + variation := []blueprint.Variation{{"os", os}} + ctx.AddVariationDependencies(variation, commonOsToOsSpecificVariantTag, ctx.ModuleName()) } } } @@ -496,7 +535,7 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module { var DarwinUniversalVariantTag = archDepTag{name: "darwin universal binary"} -// archMutator splits a module into a variant for each Target requested by the module. Target selection +// archTransitionMutator splits a module into a variant for each Target requested by the module. Target selection // for a module is in three levels, OsClass, multilib, and then Target. // OsClass selection is determined by: // - The HostOrDeviceSupported value passed in to InitAndroidArchModule by the module type factory, which selects @@ -527,25 +566,32 @@ var DarwinUniversalVariantTag = archDepTag{name: "darwin universal binary"} // // Modules can be initialized with InitAndroidMultiTargetsArchModule, in which case they will be split by OsClass, // but will have a common Target that is expected to handle all other selected Targets via ctx.MultiTargets(). -func archMutator(mctx BottomUpMutatorContext) { - module := mctx.Module() +type archTransitionMutator struct{} + +type allArchInfo struct { + Targets map[string]Target + MultiTargets []Target + Primary string + Multilib string +} + +var allArchProvider = blueprint.NewMutatorProvider[*allArchInfo]("arch_propagate") + +func (a *archTransitionMutator) Split(ctx BaseModuleContext) []string { + module := ctx.Module() base := module.base() if !base.ArchSpecific() { - return + return []string{""} } os := base.commonProperties.CompileOS if os == CommonOS { - // Make sure that the target related properties are initialized for the - // CommonOS variant. - addTargetProperties(module, commonTargetMap[os.Name], nil, true) - // Do not create arch specific variants for the CommonOS variant. - return + return []string{""} } - osTargets := mctx.Config().Targets[os] + osTargets := ctx.Config().Targets[os] image := base.commonProperties.ImageVariation // Filter NativeBridge targets unless they are explicitly supported. @@ -572,19 +618,18 @@ func archMutator(mctx BottomUpMutatorContext) { prefer32 := os == Windows // Determine the multilib selection for this module. - ignorePrefer32OnDevice := mctx.Config().IgnorePrefer32OnDevice() - multilib, extraMultilib := decodeMultilib(base, os, ignorePrefer32OnDevice) + multilib, extraMultilib := decodeMultilib(ctx, base) // Convert the multilib selection into a list of Targets. targets, err := decodeMultilibTargets(multilib, osTargets, prefer32) if err != nil { - mctx.ModuleErrorf("%s", err.Error()) + ctx.ModuleErrorf("%s", err.Error()) } // If there are no supported targets disable the module. if len(targets) == 0 { base.Disable() - return + return []string{""} } // If the module is using extraMultilib, decode the extraMultilib selection into @@ -593,7 +638,7 @@ func archMutator(mctx BottomUpMutatorContext) { if extraMultilib != "" { multiTargets, err = decodeMultilibTargets(extraMultilib, osTargets, prefer32) if err != nil { - mctx.ModuleErrorf("%s", err.Error()) + ctx.ModuleErrorf("%s", err.Error()) } multiTargets = filterHostCross(multiTargets, targets[0].HostCross) } @@ -601,7 +646,7 @@ func archMutator(mctx BottomUpMutatorContext) { // Recovery is always the primary architecture, filter out any other architectures. // Common arch is also allowed if image == RecoveryVariation { - primaryArch := mctx.Config().DevicePrimaryArchType() + primaryArch := ctx.Config().DevicePrimaryArchType() targets = filterToArch(targets, primaryArch, Common) multiTargets = filterToArch(multiTargets, primaryArch, Common) } @@ -609,37 +654,109 @@ func archMutator(mctx BottomUpMutatorContext) { // If there are no supported targets disable the module. if len(targets) == 0 { base.Disable() - return + return []string{""} } // Convert the targets into a list of arch variation names. targetNames := make([]string, len(targets)) + targetMapping := make(map[string]Target, len(targets)) for i, target := range targets { targetNames[i] = target.ArchVariation() + targetMapping[targetNames[i]] = targets[i] } - // Create the variations, annotate each one with which Target it was created for, and - // squash the appropriate arch-specific properties into the top level properties. - modules := mctx.CreateVariations(targetNames...) - for i, m := range modules { - addTargetProperties(m, targets[i], multiTargets, i == 0) - m.base().setArchProperties(mctx) + SetProvider(ctx, allArchProvider, &allArchInfo{ + Targets: targetMapping, + MultiTargets: multiTargets, + Primary: targetNames[0], + Multilib: multilib, + }) + return targetNames +} + +func (a *archTransitionMutator) OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string { + return sourceVariation +} + +func (a *archTransitionMutator) IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string { + module := ctx.Module() + base := module.base() - // Install support doesn't understand Darwin+Arm64 - if os == Darwin && targets[i].HostCross { - m.base().commonProperties.SkipInstall = true + if !base.ArchSpecific() { + return "" + } + + os := base.commonProperties.CompileOS + if os == CommonOS { + // Do not create arch specific variants for the CommonOS variant. + return "" + } + + if incomingVariation == "" { + multilib, _ := decodeMultilib(ctx, base) + if multilib == "common" { + return "common" } } + return incomingVariation +} + +func (a *archTransitionMutator) Mutate(ctx BottomUpMutatorContext, variation string) { + module := ctx.Module() + base := module.base() + os := base.commonProperties.CompileOS + + if os == CommonOS { + // Make sure that the target related properties are initialized for the + // CommonOS variant. + addTargetProperties(module, commonTargetMap[os.Name], nil, true) + return + } + + if variation == "" { + return + } + + if !base.ArchSpecific() { + panic(fmt.Errorf("found variation %q for non arch specifc module", variation)) + } + + allArchInfo, ok := ModuleProvider(ctx, allArchProvider) + if !ok { + return + } + + target, ok := allArchInfo.Targets[variation] + if !ok { + panic(fmt.Errorf("missing Target for %q", variation)) + } + primary := variation == allArchInfo.Primary + multiTargets := allArchInfo.MultiTargets + + // Annotate the new variant with which Target it was created for, and + // squash the appropriate arch-specific properties into the top level properties. + addTargetProperties(ctx.Module(), target, multiTargets, primary) + base.setArchProperties(ctx) + + // Install support doesn't understand Darwin+Arm64 + if os == Darwin && target.HostCross { + base.commonProperties.SkipInstall = true + } // Create a dependency for Darwin Universal binaries from the primary to secondary // architecture. The module itself will be responsible for calling lipo to merge the outputs. if os == Darwin { - if multilib == "darwin_universal" && len(modules) == 2 { - mctx.AddInterVariantDependency(DarwinUniversalVariantTag, modules[1], modules[0]) - } else if multilib == "darwin_universal_common_first" && len(modules) == 3 { - mctx.AddInterVariantDependency(DarwinUniversalVariantTag, modules[2], modules[1]) + isUniversalBinary := (allArchInfo.Multilib == "darwin_universal" && len(allArchInfo.Targets) == 2) || + allArchInfo.Multilib == "darwin_universal_common_first" && len(allArchInfo.Targets) == 3 + isPrimary := variation == ctx.Config().BuildArch.String() + hasSecondaryConfigured := len(ctx.Config().Targets[Darwin]) > 1 + if isUniversalBinary && isPrimary && hasSecondaryConfigured { + secondaryArch := ctx.Config().Targets[Darwin][1].Arch.String() + variation := []blueprint.Variation{{"arch", secondaryArch}} + ctx.AddVariationDependencies(variation, DarwinUniversalVariantTag, ctx.ModuleName()) } } + } // addTargetProperties annotates a variant with the Target is is being compiled for, the list @@ -656,7 +773,9 @@ func addTargetProperties(m Module, target Target, multiTargets []Target, primary // multilib from the factory's call to InitAndroidArchModule if none was set. For modules that // called InitAndroidMultiTargetsArchModule it always returns "common" for multilib, and returns // the actual multilib in extraMultilib. -func decodeMultilib(base *ModuleBase, os OsType, ignorePrefer32OnDevice bool) (multilib, extraMultilib string) { +func decodeMultilib(ctx ConfigContext, base *ModuleBase) (multilib, extraMultilib string) { + os := base.commonProperties.CompileOS + ignorePrefer32OnDevice := ctx.Config().IgnorePrefer32OnDevice() // First check the "android.compile_multilib" or "host.compile_multilib" properties. switch os.Class { case Device: diff --git a/android/arch_test.go b/android/arch_test.go index 6134a065f..57c901032 100644 --- a/android/arch_test.go +++ b/android/arch_test.go @@ -451,7 +451,7 @@ func TestArchMutator(t *testing.T) { for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - if tt.goOS != runtime.GOOS { + if tt.goOS != "" && tt.goOS != runtime.GOOS { t.Skipf("requries runtime.GOOS %s", tt.goOS) } diff --git a/android/config.go b/android/config.go index 368e57381..00fc823a8 100644 --- a/android/config.go +++ b/android/config.go @@ -238,6 +238,11 @@ func (c Config) ReleaseAconfigFlagDefaultPermission() string { return c.config.productVariables.ReleaseAconfigFlagDefaultPermission } +// Enable object size sanitizer +func (c Config) ReleaseBuildObjectSizeSanitizer() bool { + return c.config.productVariables.GetBuildFlagBool("RELEASE_BUILD_OBJECT_SIZE_SANITIZER") +} + // The flag indicating behavior for the tree wrt building modules or using prebuilts // derived from RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE func (c Config) ReleaseDefaultModuleBuildFromSource() bool { @@ -1965,6 +1970,10 @@ func (c *config) GetBuildFlag(name string) (string, bool) { return val, ok } +func (c *config) UseOptimizedResourceShrinkingByDefault() bool { + return c.productVariables.GetBuildFlagBool("RELEASE_USE_OPTIMIZED_RESOURCE_SHRINKING_BY_DEFAULT") +} + func (c *config) UseResourceProcessorByDefault() bool { return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT") } diff --git a/android/defaults.go b/android/defaults.go index 0d51d9d7c..3d06c69c9 100644 --- a/android/defaults.go +++ b/android/defaults.go @@ -69,7 +69,7 @@ type Defaultable interface { // Apply defaults from the supplied Defaults to the property structures supplied to // setProperties(...). - applyDefaults(TopDownMutatorContext, []Defaults) + applyDefaults(BottomUpMutatorContext, []Defaults) // Set the hook to be called after any defaults have been applied. // @@ -101,6 +101,7 @@ func InitDefaultableModule(module DefaultableModule) { // A restricted subset of context methods, similar to LoadHookContext. type DefaultableHookContext interface { EarlyModuleContext + OtherModuleProviderContext CreateModule(ModuleFactory, ...interface{}) Module AddMissingDependencies(missingDeps []string) @@ -209,7 +210,7 @@ func InitDefaultsModule(module DefaultsModule) { var _ Defaults = (*DefaultsModuleBase)(nil) -func (defaultable *DefaultableModuleBase) applyDefaults(ctx TopDownMutatorContext, +func (defaultable *DefaultableModuleBase) applyDefaults(ctx BottomUpMutatorContext, defaultsList []Defaults) { for _, defaults := range defaultsList { @@ -226,7 +227,7 @@ func (defaultable *DefaultableModuleBase) applyDefaults(ctx TopDownMutatorContex // Product variable properties need special handling, the type of the filtered product variable // property struct may not be identical between the defaults module and the defaultable module. // Use PrependMatchingProperties to apply whichever properties match. -func (defaultable *DefaultableModuleBase) applyDefaultVariableProperties(ctx TopDownMutatorContext, +func (defaultable *DefaultableModuleBase) applyDefaultVariableProperties(ctx BottomUpMutatorContext, defaults Defaults, defaultableProp interface{}) { if defaultableProp == nil { return @@ -254,7 +255,7 @@ func (defaultable *DefaultableModuleBase) applyDefaultVariableProperties(ctx Top } } -func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx TopDownMutatorContext, +func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx BottomUpMutatorContext, defaults Defaults, defaultableProp interface{}) { for _, def := range defaults.properties() { @@ -273,7 +274,7 @@ func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx TopDownMuta func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) { ctx.BottomUp("defaults_deps", defaultsDepsMutator).Parallel() - ctx.TopDown("defaults", defaultsMutator).Parallel() + ctx.BottomUp("defaults", defaultsMutator).Parallel() } func defaultsDepsMutator(ctx BottomUpMutatorContext) { @@ -282,8 +283,12 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) { } } -func defaultsMutator(ctx TopDownMutatorContext) { +func defaultsMutator(ctx BottomUpMutatorContext) { if defaultable, ok := ctx.Module().(Defaultable); ok { + if _, isDefaultsModule := ctx.Module().(Defaults); isDefaultsModule { + // Don't squash transitive defaults into defaults modules + return + } defaults := defaultable.defaults().Defaults if len(defaults) > 0 { var defaultsList []Defaults diff --git a/android/init.go b/android/init.go index d5b486b10..b46229282 100644 --- a/android/init.go +++ b/android/init.go @@ -18,5 +18,6 @@ import "encoding/gob" func init() { gob.Register(ModuleOutPath{}) + gob.Register(PhonyPath{}) gob.Register(unstableInfo{}) } diff --git a/android/module.go b/android/module.go index dd83d6407..1a3f328eb 100644 --- a/android/module.go +++ b/android/module.go @@ -443,12 +443,6 @@ type commonProperties struct { // Set at module initialization time by calling InitCommonOSAndroidMultiTargetsArchModule CreateCommonOSVariant bool `blueprint:"mutated"` - // If set to true then this variant is the CommonOS variant that has dependencies on its - // OsType specific variants. - // - // 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. @@ -1221,7 +1215,7 @@ func (m *ModuleBase) ArchSpecific() bool { // True if the current variant is a CommonOS variant, false otherwise. func (m *ModuleBase) IsCommonOSVariant() bool { - return m.commonProperties.CommonOSVariant + return m.commonProperties.CompileOS == CommonOS } // supportsTarget returns true if the given Target is supported by the current module. @@ -2212,7 +2206,12 @@ func (m *ModuleBase) IsNativeBridgeSupported() bool { return proptools.Bool(m.commonProperties.Native_bridge_supported) } +type ConfigContext interface { + Config() Config +} + type ConfigurableEvaluatorContext interface { + OtherModuleProviderContext Config() Config OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) HasMutatorFinished(mutatorName string) bool diff --git a/android/mutator.go b/android/mutator.go index 2ef4d7fef..940494506 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -148,9 +148,9 @@ var preArch = []RegisterMutatorFunc{ } func registerArchMutator(ctx RegisterMutatorsContext) { - ctx.BottomUp("os", osMutator).Parallel() + ctx.Transition("os", &osTransitionMutator{}) ctx.Transition("image", &imageTransitionMutator{}) - ctx.BottomUp("arch", archMutator).Parallel() + ctx.Transition("arch", &archTransitionMutator{}) } var preDeps = []RegisterMutatorFunc{ @@ -193,16 +193,16 @@ type BaseMutatorContext interface { // Rename all variants of a module. The new name is not visible to calls to ModuleName, // AddDependency or OtherModuleName until after this mutator pass is complete. Rename(name string) + + // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies + // the specified property structs to it as if the properties were set in a blueprint file. + CreateModule(ModuleFactory, ...interface{}) Module } type TopDownMutator func(TopDownMutatorContext) type TopDownMutatorContext interface { BaseMutatorContext - - // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies - // the specified property structs to it as if the properties were set in a blueprint file. - CreateModule(ModuleFactory, ...interface{}) Module } type topDownMutatorContext struct { @@ -516,6 +516,9 @@ type androidTransitionMutator struct { } func (a *androidTransitionMutator) Split(ctx blueprint.BaseModuleContext) []string { + if a.finalPhase { + panic("TransitionMutator not allowed in FinalDepsMutators") + } if m, ok := ctx.Module().(Module); ok { moduleContext := m.base().baseModuleContextFactory(ctx) return a.mutator.Split(&moduleContext) @@ -739,6 +742,14 @@ func (b *bottomUpMutatorContext) Rename(name string) { b.Module().base().commonProperties.DebugName = name } +func (b *bottomUpMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module { + return b.bp.CreateModule(factory, name, props...) +} + +func (b *bottomUpMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module { + return createModule(b, factory, "_bottomUpMutatorModule", props...) +} + func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module { if b.baseModuleContext.checkedMissingDeps() { panic("Adding deps not allowed after checking for missing deps") diff --git a/android/mutator_test.go b/android/mutator_test.go index 21eebd2c8..b3ef00f3d 100644 --- a/android/mutator_test.go +++ b/android/mutator_test.go @@ -81,6 +81,40 @@ func TestMutatorAddMissingDependencies(t *testing.T) { AssertDeepEquals(t, "foo missing deps", []string{"added_missing_dep", "regular_missing_dep"}, foo.missingDeps) } +type testTransitionMutator struct { + split func(ctx BaseModuleContext) []string + outgoingTransition func(ctx OutgoingTransitionContext, sourceVariation string) string + incomingTransition func(ctx IncomingTransitionContext, incomingVariation string) string + mutate func(ctx BottomUpMutatorContext, variation string) +} + +func (t *testTransitionMutator) Split(ctx BaseModuleContext) []string { + if t.split != nil { + return t.split(ctx) + } + return []string{""} +} + +func (t *testTransitionMutator) OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string { + if t.outgoingTransition != nil { + return t.outgoingTransition(ctx, sourceVariation) + } + return sourceVariation +} + +func (t *testTransitionMutator) IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string { + if t.incomingTransition != nil { + return t.incomingTransition(ctx, incomingVariation) + } + return incomingVariation +} + +func (t *testTransitionMutator) Mutate(ctx BottomUpMutatorContext, variation string) { + if t.mutate != nil { + t.mutate(ctx, variation) + } +} + func TestModuleString(t *testing.T) { bp := ` test { @@ -94,9 +128,11 @@ func TestModuleString(t *testing.T) { FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.PreArchMutators(func(ctx RegisterMutatorsContext) { - ctx.BottomUp("pre_arch", func(ctx BottomUpMutatorContext) { - moduleStrings = append(moduleStrings, ctx.Module().String()) - ctx.CreateVariations("a", "b") + ctx.Transition("pre_arch", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + moduleStrings = append(moduleStrings, ctx.Module().String()) + return []string{"a", "b"} + }, }) ctx.TopDown("rename_top_down", func(ctx TopDownMutatorContext) { moduleStrings = append(moduleStrings, ctx.Module().String()) @@ -105,16 +141,23 @@ func TestModuleString(t *testing.T) { }) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { - ctx.BottomUp("pre_deps", func(ctx BottomUpMutatorContext) { - moduleStrings = append(moduleStrings, ctx.Module().String()) - ctx.CreateVariations("c", "d") + ctx.Transition("pre_deps", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + moduleStrings = append(moduleStrings, ctx.Module().String()) + return []string{"c", "d"} + }, }) }) ctx.PostDepsMutators(func(ctx RegisterMutatorsContext) { - ctx.BottomUp("post_deps", func(ctx BottomUpMutatorContext) { - moduleStrings = append(moduleStrings, ctx.Module().String()) - ctx.CreateLocalVariations("e", "f") + ctx.Transition("post_deps", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + moduleStrings = append(moduleStrings, ctx.Module().String()) + return []string{"e", "f"} + }, + outgoingTransition: func(ctx OutgoingTransitionContext, sourceVariation string) string { + return "" + }, }) ctx.BottomUp("rename_bottom_up", func(ctx BottomUpMutatorContext) { moduleStrings = append(moduleStrings, ctx.Module().String()) @@ -138,15 +181,15 @@ func TestModuleString(t *testing.T) { "foo{pre_arch:b}", "foo{pre_arch:a}", - // After rename_top_down. - "foo_renamed1{pre_arch:a}", + // After rename_top_down (reversed because pre_deps TransitionMutator.Split is TopDown). "foo_renamed1{pre_arch:b}", + "foo_renamed1{pre_arch:a}", - // After pre_deps. - "foo_renamed1{pre_arch:a,pre_deps:c}", - "foo_renamed1{pre_arch:a,pre_deps:d}", - "foo_renamed1{pre_arch:b,pre_deps:c}", + // After pre_deps (reversed because post_deps TransitionMutator.Split is TopDown). "foo_renamed1{pre_arch:b,pre_deps:d}", + "foo_renamed1{pre_arch:b,pre_deps:c}", + "foo_renamed1{pre_arch:a,pre_deps:d}", + "foo_renamed1{pre_arch:a,pre_deps:c}", // After post_deps. "foo_renamed1{pre_arch:a,pre_deps:c,post_deps:e}", @@ -202,8 +245,10 @@ func TestFinalDepsPhase(t *testing.T) { ctx.AddFarVariationDependencies([]blueprint.Variation{}, dep1Tag, "common_dep_1") } }) - ctx.BottomUp("variant", func(ctx BottomUpMutatorContext) { - ctx.CreateLocalVariations("a", "b") + ctx.Transition("variant", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + return []string{"a", "b"} + }, }) }) @@ -243,27 +288,20 @@ func TestFinalDepsPhase(t *testing.T) { } func TestNoCreateVariationsInFinalDeps(t *testing.T) { - checkErr := func() { - if err := recover(); err == nil || !strings.Contains(fmt.Sprintf("%s", err), "not allowed in FinalDepsMutators") { - panic("Expected FinalDepsMutators consistency check to fail") - } - } - GroupFixturePreparers( FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.FinalDepsMutators(func(ctx RegisterMutatorsContext) { - ctx.BottomUp("vars", func(ctx BottomUpMutatorContext) { - defer checkErr() - ctx.CreateVariations("a", "b") - }) - ctx.BottomUp("local_vars", func(ctx BottomUpMutatorContext) { - defer checkErr() - ctx.CreateLocalVariations("a", "b") + ctx.Transition("vars", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + return []string{"a", "b"} + }, }) }) ctx.RegisterModuleType("test", mutatorTestModuleFactory) }), FixtureWithRootAndroidBp(`test {name: "foo"}`), - ).RunTest(t) + ). + ExtendWithErrorHandler(FixtureExpectsOneErrorPattern("not allowed in FinalDepsMutators")). + RunTest(t) } diff --git a/android/paths.go b/android/paths.go index 0a4f89187..0d94f03e6 100644 --- a/android/paths.go +++ b/android/paths.go @@ -91,6 +91,7 @@ func GlobFiles(ctx EarlyModulePathContext, globPattern string, excludes []string // the Path methods that rely on module dependencies having been resolved. type ModuleWithDepsPathContext interface { EarlyModulePathContext + OtherModuleProviderContext VisitDirectDepsBlueprint(visit func(blueprint.Module)) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag HasMutatorFinished(mutatorName string) bool diff --git a/android/product_config.go b/android/product_config.go index 04180bf2b..ce3acc9f2 100644 --- a/android/product_config.go +++ b/android/product_config.go @@ -14,7 +14,9 @@ package android -import "github.com/google/blueprint/proptools" +import ( + "github.com/google/blueprint/proptools" +) func init() { ctx := InitRegistrationContext diff --git a/android/product_config_to_bp.go b/android/product_config_to_bp.go new file mode 100644 index 000000000..680328f67 --- /dev/null +++ b/android/product_config_to_bp.go @@ -0,0 +1,35 @@ +// 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 + +func init() { + ctx := InitRegistrationContext + ctx.RegisterParallelSingletonType("product_config_to_bp_singleton", productConfigToBpSingletonFactory) +} + +type productConfigToBpSingleton struct{} + +func (s *productConfigToBpSingleton) GenerateBuildActions(ctx SingletonContext) { + // TODO: update content from make-based product config + var content string + generatedBp := PathForOutput(ctx, "soong_generated_product_config.bp") + WriteFileRule(ctx, generatedBp, content) + ctx.Phony("product_config_to_bp", generatedBp) +} + +// productConfigToBpSingleton generates a bp file from make-based product config +func productConfigToBpSingletonFactory() Singleton { + return &productConfigToBpSingleton{} +} diff --git a/android/singleton_module_test.go b/android/singleton_module_test.go index 3b1bf39e3..3b8c6b213 100644 --- a/android/singleton_module_test.go +++ b/android/singleton_module_test.go @@ -96,12 +96,6 @@ func TestUnusedSingletonModule(t *testing.T) { } } -func testVariantSingletonModuleMutator(ctx BottomUpMutatorContext) { - if _, ok := ctx.Module().(*testSingletonModule); ok { - ctx.CreateVariations("a", "b") - } -} - func TestVariantSingletonModule(t *testing.T) { if testing.Short() { t.Skip("test fails with data race enabled") @@ -116,7 +110,11 @@ func TestVariantSingletonModule(t *testing.T) { prepareForSingletonModuleTest, FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { - ctx.BottomUp("test_singleton_module_mutator", testVariantSingletonModuleMutator) + ctx.Transition("test_singleton_module_mutator", &testTransitionMutator{ + split: func(ctx BaseModuleContext) []string { + return []string{"a", "b"} + }, + }) }) }), ). diff --git a/android/team_proto/Android.bp b/android/team_proto/Android.bp index 7e2a4c137..5faaaf10e 100644 --- a/android/team_proto/Android.bp +++ b/android/team_proto/Android.bp @@ -40,4 +40,8 @@ python_library_host { proto: { canonical_path_from_root: false, }, + visibility: [ + "//build/soong:__subpackages__", + "//tools/asuite/team_build_scripts", + ], } diff --git a/android/testing.go b/android/testing.go index 1ee6e4cdb..196b22e3e 100644 --- a/android/testing.go +++ b/android/testing.go @@ -1330,6 +1330,10 @@ func (ctx *panickingConfigAndErrorContext) HasMutatorFinished(mutatorName string return ctx.ctx.HasMutatorFinished(mutatorName) } +func (ctx *panickingConfigAndErrorContext) otherModuleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) { + return ctx.ctx.otherModuleProvider(m, p) +} + func PanickingConfigAndErrorContext(ctx *TestContext) ConfigurableEvaluatorContext { return &panickingConfigAndErrorContext{ ctx: ctx, diff --git a/android/visibility.go b/android/visibility.go index 89c0adc15..61f220026 100644 --- a/android/visibility.go +++ b/android/visibility.go @@ -283,7 +283,7 @@ func RegisterVisibilityRuleGatherer(ctx RegisterMutatorsContext) { // This must be registered after the deps have been resolved. func RegisterVisibilityRuleEnforcer(ctx RegisterMutatorsContext) { - ctx.TopDown("visibilityRuleEnforcer", visibilityRuleEnforcer).Parallel() + ctx.BottomUp("visibilityRuleEnforcer", visibilityRuleEnforcer).Parallel() } // Checks the per-module visibility rule lists before defaults expansion. @@ -507,7 +507,7 @@ func splitRule(ctx BaseModuleContext, ruleExpression string, currentPkg, propert return true, pkg, name } -func visibilityRuleEnforcer(ctx TopDownMutatorContext) { +func visibilityRuleEnforcer(ctx BottomUpMutatorContext) { qualified := createVisibilityModuleReference(ctx.ModuleName(), ctx.ModuleDir(), ctx.Module()) // Visit all the dependencies making sure that this module has access to them all. diff --git a/apex/Android.bp b/apex/Android.bp index ef2f75570..4848513f2 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -42,4 +42,6 @@ bootstrap_go_package { "systemserver_classpath_fragment_test.go", ], pluginFor: ["soong_build"], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/apex/apex.go b/apex/apex.go index c12d1e473..9e3f288ce 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -55,11 +55,10 @@ func registerApexBuildComponents(ctx android.RegistrationContext) { } func registerPreArchMutators(ctx android.RegisterMutatorsContext) { - ctx.TopDown("prebuilt_apex_module_creator", prebuiltApexModuleCreatorMutator).Parallel() + ctx.BottomUp("prebuilt_apex_module_creator", prebuiltApexModuleCreatorMutator).Parallel() } func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { - ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() } diff --git a/apex/apex_test.go b/apex/apex_test.go index 2b9772821..0d5bad445 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4885,236 +4885,6 @@ type moduleErrorfTestCtx struct { func (ctx moduleErrorfTestCtx) ModuleErrorf(format string, args ...interface{}) { } -// These tests verify that the prebuilt_apex/deapexer to java_import wiring allows for the -// propagation of paths to dex implementation jars from the former to the latter. -func TestPrebuiltExportDexImplementationJars(t *testing.T) { - transform := android.NullFixturePreparer - - checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) { - t.Helper() - // Make sure the import has been given the correct path to the dex jar. - p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency) - dexJarBuildPath := p.DexJarBuildPath(moduleErrorfTestCtx{}).PathOrNil() - stem := android.RemoveOptionalPrebuiltPrefix(name) - android.AssertStringEquals(t, "DexJarBuildPath should be apex-related path.", - ".intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar", - android.NormalizePathForTesting(dexJarBuildPath)) - } - - checkDexJarInstallPath := func(t *testing.T, ctx *android.TestContext, name string) { - t.Helper() - // Make sure the import has been given the correct path to the dex jar. - p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency) - dexJarBuildPath := p.DexJarInstallPath() - stem := android.RemoveOptionalPrebuiltPrefix(name) - android.AssertStringEquals(t, "DexJarInstallPath should be apex-related path.", - "target/product/test_device/apex/myapex/javalib/"+stem+".jar", - android.NormalizePathForTesting(dexJarBuildPath)) - } - - ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext, name string) { - t.Helper() - // Make sure that an apex variant is not created for the source module. - android.AssertArrayString(t, "Check if there is no source variant", - []string{"android_common"}, - ctx.ModuleVariantsForTests(name)) - } - - t.Run("prebuilt only", func(t *testing.T) { - bp := ` - prebuilt_apex { - name: "myapex", - arch: { - arm64: { - src: "myapex-arm64.apex", - }, - arm: { - src: "myapex-arm.apex", - }, - }, - exported_java_libs: ["libfoo", "libbar"], - } - - java_import { - name: "libfoo", - jars: ["libfoo.jar"], - sdk_version: "core_current", - } - - java_sdk_library_import { - name: "libbar", - public: { - jars: ["libbar.jar"], - }, - } - ` - - // Make sure that dexpreopt can access dex implementation files from the prebuilt. - ctx := testDexpreoptWithApexes(t, bp, "", transform) - - deapexerName := deapexerModuleName("prebuilt_myapex") - android.AssertStringEquals(t, "APEX module name from deapexer name", "prebuilt_myapex", apexModuleName(deapexerName)) - - // Make sure that the deapexer has the correct input APEX. - deapexer := ctx.ModuleForTests(deapexerName, "android_common") - rule := deapexer.Rule("deapexer") - if expected, actual := []string{"myapex-arm64.apex"}, android.NormalizePathsForTesting(rule.Implicits); !reflect.DeepEqual(expected, actual) { - t.Errorf("expected: %q, found: %q", expected, actual) - } - - // Make sure that the prebuilt_apex has the correct input APEX. - prebuiltApex := ctx.ModuleForTests("myapex", "android_common_myapex") - rule = prebuiltApex.Rule("android/soong/android.Cp") - if expected, actual := "myapex-arm64.apex", android.NormalizePathForTesting(rule.Input); !reflect.DeepEqual(expected, actual) { - t.Errorf("expected: %q, found: %q", expected, actual) - } - - checkDexJarBuildPath(t, ctx, "libfoo") - checkDexJarInstallPath(t, ctx, "libfoo") - - checkDexJarBuildPath(t, ctx, "libbar") - checkDexJarInstallPath(t, ctx, "libbar") - }) - - t.Run("prebuilt with source preferred", func(t *testing.T) { - - bp := ` - apex { - name: "myapex", - key: "myapex.key", - updatable: false, - java_libs: [ - "libfoo", - "libbar", - ], - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - prebuilt_apex { - name: "myapex", - arch: { - arm64: { - src: "myapex-arm64.apex", - }, - arm: { - src: "myapex-arm.apex", - }, - }, - exported_java_libs: ["libfoo", "libbar"], - } - - java_import { - name: "libfoo", - jars: ["libfoo.jar"], - apex_available: [ - "myapex", - ], - compile_dex: true, - sdk_version: "core_current", - } - - java_library { - name: "libfoo", - srcs: ["foo/bar/MyClass.java"], - apex_available: [ - "myapex", - ], - compile_dex: true, - sdk_version: "core_current", - } - - java_sdk_library_import { - name: "libbar", - public: { - jars: ["libbar.jar"], - }, - apex_available: [ - "myapex", - ], - compile_dex: true, - } - - java_sdk_library { - name: "libbar", - srcs: ["foo/bar/MyClass.java"], - unsafe_ignore_missing_latest_api: true, - apex_available: [ - "myapex", - ], - compile_dex: true, - sdk_version: "core_current", - } - ` - - // Make sure that dexpreopt can access dex implementation files from the prebuilt. - ctx := testDexpreoptWithApexes(t, bp, "", transform) - - checkDexJarBuildPath(t, ctx, "prebuilt_libfoo") - checkDexJarInstallPath(t, ctx, "prebuilt_libfoo") - - checkDexJarBuildPath(t, ctx, "prebuilt_libbar") - checkDexJarInstallPath(t, ctx, "prebuilt_libbar") - }) - - t.Run("prebuilt preferred with source", func(t *testing.T) { - bp := ` - prebuilt_apex { - name: "myapex", - arch: { - arm64: { - src: "myapex-arm64.apex", - }, - arm: { - src: "myapex-arm.apex", - }, - }, - exported_java_libs: ["libfoo", "libbar"], - } - - java_import { - name: "libfoo", - prefer: true, - jars: ["libfoo.jar"], - } - - java_library { - name: "libfoo", - sdk_version: "core_current", - } - - java_sdk_library_import { - name: "libbar", - prefer: true, - public: { - jars: ["libbar.jar"], - }, - } - - java_sdk_library { - name: "libbar", - srcs: ["foo/bar/MyClass.java"], - unsafe_ignore_missing_latest_api: true, - } - ` - - // Make sure that dexpreopt can access dex implementation files from the prebuilt. - ctx := testDexpreoptWithApexes(t, bp, "", transform) - - checkDexJarBuildPath(t, ctx, "prebuilt_libfoo") - checkDexJarInstallPath(t, ctx, "prebuilt_libfoo") - ensureNoSourceVariant(t, ctx, "libfoo") - - checkDexJarBuildPath(t, ctx, "prebuilt_libbar") - checkDexJarInstallPath(t, ctx, "prebuilt_libbar") - ensureNoSourceVariant(t, ctx, "libbar") - }) -} - func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { preparer := android.GroupFixturePreparers( java.FixtureConfigureApexBootJars("myapex:libfoo", "myapex:libbar"), @@ -5243,18 +5013,10 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { apex_set { name: "myapex", set: "myapex.apks", - exported_java_libs: ["myjavalib"], exported_bootclasspath_fragments: ["my-bootclasspath-fragment"], exported_systemserverclasspath_fragments: ["my-systemserverclasspath-fragment"], } - java_import { - name: "myjavalib", - jars: ["myjavalib.jar"], - apex_available: ["myapex"], - permitted_packages: ["javalib"], - } - prebuilt_bootclasspath_fragment { name: "my-bootclasspath-fragment", contents: ["libfoo", "libbar"], @@ -9618,42 +9380,6 @@ func TestAndroidMk_DexpreoptBuiltInstalledForApex(t *testing.T) { ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo.myapex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex\n") } -func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) { - ctx := testApex(t, ` - prebuilt_apex { - name: "myapex", - arch: { - arm64: { - src: "myapex-arm64.apex", - }, - arm: { - src: "myapex-arm.apex", - }, - }, - exported_java_libs: ["foo"], - } - - java_import { - name: "foo", - jars: ["foo.jar"], - apex_available: ["myapex"], - } - `, - dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"), - ) - - prebuilt := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*Prebuilt) - entriesList := android.AndroidMkEntriesForTest(t, ctx, prebuilt) - mainModuleEntries := entriesList[0] - android.AssertArrayString(t, - "LOCAL_REQUIRED_MODULES", - mainModuleEntries.EntryMap["LOCAL_REQUIRED_MODULES"], - []string{ - "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex", - "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex", - }) -} - func TestAndroidMk_RequiredModules(t *testing.T) { ctx := testApex(t, ` apex { @@ -11930,3 +11656,110 @@ func TestPrebuiltStubNoinstall(t *testing.T) { ) }) } + +func TestSdkLibraryTransitiveClassLoaderContext(t *testing.T) { + // This test case tests that listing the impl lib instead of the top level java_sdk_library + // in libs of android_app and java_library does not lead to class loader context device/host + // path mismatch errors. + android.GroupFixturePreparers( + prepareForApexTest, + android.PrepareForIntegrationTestWithAndroid, + PrepareForTestWithApexBuildComponents, + android.FixtureModifyEnv(func(env map[string]string) { + env["DISABLE_CONTAINER_CHECK"] = "true" + }), + withFiles(filesForSdkLibrary), + android.FixtureMergeMockFs(android.MockFS{ + "system/sepolicy/apex/com.android.foo30-file_contexts": nil, + }), + ).RunTestWithBp(t, ` + apex { + name: "com.android.foo30", + key: "myapex.key", + updatable: true, + bootclasspath_fragments: [ + "foo-bootclasspath-fragment", + ], + java_libs: [ + "bar", + ], + apps: [ + "bar-app", + ], + min_sdk_version: "30", + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + bootclasspath_fragment { + name: "foo-bootclasspath-fragment", + contents: [ + "framework-foo", + ], + apex_available: [ + "com.android.foo30", + ], + hidden_api: { + split_packages: ["*"] + }, + } + + java_sdk_library { + name: "framework-foo", + srcs: [ + "A.java" + ], + unsafe_ignore_missing_latest_api: true, + apex_available: [ + "com.android.foo30", + ], + compile_dex: true, + sdk_version: "core_current", + shared_library: false, + } + + java_library { + name: "bar", + srcs: [ + "A.java" + ], + libs: [ + "framework-foo.impl", + ], + apex_available: [ + "com.android.foo30", + ], + sdk_version: "core_current", + } + + java_library { + name: "baz", + srcs: [ + "A.java" + ], + libs: [ + "bar", + ], + sdk_version: "core_current", + } + + android_app { + name: "bar-app", + srcs: [ + "A.java" + ], + libs: [ + "baz", + "framework-foo.impl", + ], + apex_available: [ + "com.android.foo30", + ], + sdk_version: "core_current", + min_sdk_version: "30", + manifest: "AndroidManifest.xml", + } + `) +} diff --git a/apex/prebuilt.go b/apex/prebuilt.go index f1a134eea..f6f3efbfb 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -107,11 +107,6 @@ type PrebuiltCommonProperties struct { // from PRODUCT_PACKAGES. Overrides []string - // List of java libraries that are embedded inside this prebuilt APEX bundle and for which this - // APEX bundle will create an APEX variant and provide dex implementation jars for use by - // dexpreopt and boot jars package check. - Exported_java_libs []string - // List of bootclasspath fragments inside this prebuilt APEX bundle and for which this APEX // bundle will create an APEX variant. Exported_bootclasspath_fragments []string @@ -265,7 +260,7 @@ func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries { // prebuiltApexModuleCreator defines the methods that need to be implemented by prebuilt_apex and // apex_set in order to create the modules needed to provide access to the prebuilt .apex file. type prebuiltApexModuleCreator interface { - createPrebuiltApexModules(ctx android.TopDownMutatorContext) + createPrebuiltApexModules(ctx android.BottomUpMutatorContext) } // prebuiltApexModuleCreatorMutator is the mutator responsible for invoking the @@ -275,7 +270,7 @@ type prebuiltApexModuleCreator interface { // will need to access dependencies added by that (exported modules) but must run before the // DepsMutator so that the deapexer module it creates can add dependencies onto itself from the // exported modules. -func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) { +func prebuiltApexModuleCreatorMutator(ctx android.BottomUpMutatorContext) { module := ctx.Module() if creator, ok := module.(prebuiltApexModuleCreator); ok { creator.createPrebuiltApexModules(ctx) @@ -283,8 +278,7 @@ func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) { } func (p *prebuiltCommon) hasExportedDeps() bool { - return len(p.prebuiltCommonProperties.Exported_java_libs) > 0 || - len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 || + return len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 || len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0 } @@ -292,11 +286,6 @@ func (p *prebuiltCommon) hasExportedDeps() bool { func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() - for _, dep := range p.prebuiltCommonProperties.Exported_java_libs { - prebuiltDep := android.PrebuiltNameFromSource(dep) - ctx.AddDependency(module, exportedJavaLibTag, prebuiltDep) - } - for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments { prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, exportedBootclasspathFragmentTag, prebuiltDep) @@ -543,7 +532,7 @@ func PrebuiltFactory() android.Module { return module } -func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, apexFileProperties *ApexFileProperties) { +func createApexSelectorModule(ctx android.BottomUpMutatorContext, name string, apexFileProperties *ApexFileProperties) { props := struct { Name *string }{ @@ -559,9 +548,9 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap // createDeapexerModuleIfNeeded will create a deapexer module if it is needed. // // A deapexer module is only needed when the prebuilt apex specifies one or more modules in either -// the `exported_java_libs` or `exported_bootclasspath_fragments` properties as that indicates that +// the `exported_bootclasspath_fragments` properties as that indicates that // the listed modules need access to files from within the prebuilt .apex file. -func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) { +func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.BottomUpMutatorContext, deapexerName string, apexFileSource string) { // Only create the deapexer module if it is needed. if !p.hasExportedDeps() { return @@ -666,7 +655,6 @@ func (t exportedDependencyTag) RequiresFilesFromPrebuiltApex() {} var _ android.RequiresFilesFromPrebuiltApexTag = exportedDependencyTag{} var ( - exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"} exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"} exportedSystemserverclasspathFragmentTag = exportedDependencyTag{name: "exported_systemserverclasspath_fragments"} ) @@ -677,7 +665,7 @@ var _ prebuiltApexModuleCreator = (*Prebuilt)(nil) // build. // // If this needs to make files from within a `.apex` file available for use by other Soong modules, -// e.g. make dex implementation jars available for java_import modules listed in exported_java_libs, +// e.g. make dex implementation jars available for `contents` listed in exported_bootclasspath_fragments, // it does so as follows: // // 1. It creates a `deapexer` module that actually extracts the files from the `.apex` file and @@ -703,7 +691,7 @@ var _ prebuiltApexModuleCreator = (*Prebuilt)(nil) // / | \ // V V V // selector <--- deapexer <--- exported java lib -func (p *Prebuilt) createPrebuiltApexModules(ctx android.TopDownMutatorContext) { +func (p *Prebuilt) createPrebuiltApexModules(ctx android.BottomUpMutatorContext) { apexSelectorModuleName := apexSelectorModuleName(p.Name()) createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties) @@ -958,7 +946,7 @@ func apexSetFactory() android.Module { return module } -func createApexExtractorModule(ctx android.TopDownMutatorContext, name string, apexExtractorProperties *ApexExtractorProperties) { +func createApexExtractorModule(ctx android.BottomUpMutatorContext, name string, apexExtractorProperties *ApexExtractorProperties) { props := struct { Name *string }{ @@ -984,7 +972,7 @@ var _ prebuiltApexModuleCreator = (*ApexSet)(nil) // prebuilt_apex except that instead of creating a selector module which selects one .apex file // from those provided this creates an extractor module which extracts the appropriate .apex file // from the zip file containing them. -func (a *ApexSet) createPrebuiltApexModules(ctx android.TopDownMutatorContext) { +func (a *ApexSet) createPrebuiltApexModules(ctx android.BottomUpMutatorContext) { apexExtractorModuleName := apexExtractorModuleName(a.Name()) createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties) diff --git a/apex/vndk.go b/apex/vndk.go index 781aa3cbf..3ececc5c1 100644 --- a/apex/vndk.go +++ b/apex/vndk.go @@ -54,13 +54,26 @@ type apexVndkProperties struct { Vndk_version *string } -func apexVndkMutator(mctx android.TopDownMutatorContext) { - if ab, ok := mctx.Module().(*apexBundle); ok && ab.vndkApex { - if ab.IsNativeBridgeSupported() { +func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) { + if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) { + vndkVersion := m.VndkVersion() + + if vndkVersion == "" { + return + } + vndkVersion = "v" + vndkVersion + + vndkApexName := "com.android.vndk." + vndkVersion + + if mctx.OtherModuleExists(vndkApexName) { + mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApexName) + } + } else if a, ok := mctx.Module().(*apexBundle); ok && a.vndkApex { + if a.IsNativeBridgeSupported() { mctx.PropertyErrorf("native_bridge_supported", "%q doesn't support native bridge binary.", mctx.ModuleType()) } - vndkVersion := ab.vndkVersion() + vndkVersion := a.vndkVersion() if vndkVersion != "" { apiLevel, err := android.ApiLevelFromUser(mctx, vndkVersion) if err != nil { @@ -72,32 +85,14 @@ func apexVndkMutator(mctx android.TopDownMutatorContext) { if len(targets) > 0 && apiLevel.LessThan(cc.MinApiForArch(mctx, targets[0].Arch.ArchType)) { // Disable VNDK APEXes for VNDK versions less than the minimum supported API // level for the primary architecture. - ab.Disable() + a.Disable() + } else { + mctx.AddDependency(mctx.Module(), prebuiltTag, cc.VndkLibrariesTxtModules(vndkVersion, mctx)...) } } } } -func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) { - if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) { - vndkVersion := m.VndkVersion() - - if vndkVersion == "" { - return - } - vndkVersion = "v" + vndkVersion - - vndkApexName := "com.android.vndk." + vndkVersion - - if mctx.OtherModuleExists(vndkApexName) { - mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApexName) - } - } else if a, ok := mctx.Module().(*apexBundle); ok && a.vndkApex { - vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current") - mctx.AddDependency(mctx.Module(), prebuiltTag, cc.VndkLibrariesTxtModules(vndkVersion, mctx)...) - } -} - // name is module.BaseModuleName() which is used as LOCAL_MODULE_NAME and also LOCAL_OVERRIDES_* func makeCompatSymlinks(name string, ctx android.ModuleContext) (symlinks android.InstallPaths) { // small helper to add symlink commands diff --git a/bpf/bpf.go b/bpf/bpf.go index 73c8800d8..86798217f 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -56,6 +56,7 @@ var ( ) func registerBpfBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("bpf_defaults", defaultsFactory) ctx.RegisterModuleType("bpf", BpfFactory) } @@ -77,10 +78,16 @@ type BpfProperties struct { // the C/C++ module. Cflags []string - // directories (relative to the root of the source tree) that will - // be added to the include paths using -I. + // list of directories relative to the root of the source tree that + // will be added to the include paths using -I. + // If possible, don't use this. If adding paths from the current + // directory, use local_include_dirs. If adding paths from other + // modules, use export_include_dirs in that module. Include_dirs []string + // list of directories relative to the Blueprint file that will be + // added to the include path using -I. + Local_include_dirs []string // optional subdirectory under which this module is installed into. Sub_dir string @@ -94,7 +101,7 @@ type BpfProperties struct { type bpf struct { android.ModuleBase - + android.DefaultableModuleBase properties BpfProperties objs android.Paths @@ -163,6 +170,10 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { "-I " + ctx.ModuleDir(), } + for _, dir := range android.PathsForModuleSrc(ctx, bpf.properties.Local_include_dirs) { + cflags = append(cflags, "-I "+dir.String()) + } + for _, dir := range android.PathsForSource(ctx, bpf.properties.Include_dirs) { cflags = append(cflags, "-I "+dir.String()) } @@ -264,6 +275,26 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { } } +type Defaults struct { + android.ModuleBase + android.DefaultsModuleBase +} + +func defaultsFactory() android.Module { + return DefaultsFactory() +} + +func DefaultsFactory(props ...interface{}) android.Module { + module := &Defaults{} + + module.AddProperties(props...) + module.AddProperties(&BpfProperties{}) + + android.InitDefaultsModule(module) + + return module +} + func (bpf *bpf) SubDir() string { return bpf.properties.Sub_dir } @@ -274,5 +305,7 @@ func BpfFactory() android.Module { module.AddProperties(&module.properties) android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + android.InitDefaultableModule(module) + return module } diff --git a/bpf/libbpf/libbpf_prog.go b/bpf/libbpf/libbpf_prog.go index 1fdb3d636..ac6151040 100644 --- a/bpf/libbpf/libbpf_prog.go +++ b/bpf/libbpf/libbpf_prog.go @@ -61,6 +61,7 @@ var ( ) func registerLibbpfProgBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("libbpf_defaults", defaultsFactory) ctx.RegisterModuleType("libbpf_prog", LibbpfProgFactory) } @@ -88,14 +89,17 @@ type LibbpfProgProperties struct { // be added to the include path using -I Local_include_dirs []string `android:"arch_variant"` + Header_libs []string `android:"arch_variant"` + // optional subdirectory under which this module is installed into. Relative_install_path string } type libbpfProg struct { android.ModuleBase + android.DefaultableModuleBase properties LibbpfProgProperties - objs android.Paths + objs android.Paths } var _ android.ImageInterface = (*libbpfProg)(nil) @@ -139,6 +143,7 @@ func (libbpf *libbpfProg) SetImageVariation(ctx android.BaseModuleContext, varia func (libbpf *libbpfProg) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.AddDependency(ctx.Module(), libbpfProgDepTag, "libbpf_headers") + ctx.AddVariationDependencies(nil, cc.HeaderDepTag(), libbpf.properties.Header_libs...) } func (libbpf *libbpfProg) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -180,6 +185,11 @@ func (libbpf *libbpfProg) GenerateAndroidBuildActions(ctx android.ModuleContext) depName := ctx.OtherModuleName(dep) ctx.ModuleErrorf("module %q is not a genrule", depName) } + } else if depTag == cc.HeaderDepTag() { + depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, cc.FlagExporterInfoProvider) + for _, dir := range depExporterInfo.IncludeDirs { + cflags = append(cflags, "-I "+dir.String()) + } } }) @@ -269,10 +279,32 @@ func (libbpf *libbpfProg) AndroidMk() android.AndroidMkData { } } +type Defaults struct { + android.ModuleBase + android.DefaultsModuleBase +} + +func defaultsFactory() android.Module { + return DefaultsFactory() +} + +func DefaultsFactory(props ...interface{}) android.Module { + module := &Defaults{} + + module.AddProperties(props...) + module.AddProperties(&LibbpfProgProperties{}) + + android.InitDefaultsModule(module) + + return module +} + func LibbpfProgFactory() android.Module { module := &libbpfProg{} module.AddProperties(&module.properties) android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) + android.InitDefaultableModule(module) + return module } diff --git a/cc/Android.bp b/cc/Android.bp index 29526143f..3688c8a9a 100644 --- a/cc/Android.bp +++ b/cc/Android.bp @@ -116,4 +116,6 @@ bootstrap_go_package { "cmake_module_cc.txt", ], pluginFor: ["soong_build"], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/cc/TEST_MAPPING b/cc/TEST_MAPPING new file mode 100644 index 000000000..be2809de0 --- /dev/null +++ b/cc/TEST_MAPPING @@ -0,0 +1,7 @@ +{ + "imports": [ + { + "path": "bionic" + } + ] +} @@ -59,10 +59,10 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) { san.registerMutators(ctx) } - ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel() + ctx.BottomUp("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel() ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel() - ctx.TopDown("fuzz_deps", fuzzMutatorDeps) + ctx.BottomUp("fuzz_deps", fuzzMutatorDeps) ctx.Transition("coverage", &coverageTransitionMutator{}) @@ -73,7 +73,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) { ctx.Transition("lto", <oTransitionMutator{}) ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel() - ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() + ctx.BottomUp("double_loadable", checkDoubleLoadableLibraries).Parallel() }) ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) { @@ -2783,7 +2783,7 @@ func checkLinkTypeMutator(ctx android.BottomUpMutatorContext) { // If a library has a vendor variant and is a (transitive) dependency of an LLNDK library, // it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true // or as vndk-sp (vndk: { enabled: true, support_system_process: true}). -func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { +func checkDoubleLoadableLibraries(ctx android.BottomUpMutatorContext) { check := func(child, parent android.Module) bool { to, ok := child.(*Module) if !ok { diff --git a/cc/cc_test.go b/cc/cc_test.go index 93630dbd7..3f3347b51 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -49,17 +49,30 @@ var apexVersion = "28" func registerTestMutators(ctx android.RegistrationContext) { ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { - ctx.BottomUp("apex", testApexMutator).Parallel() + ctx.Transition("apex", &testApexTransitionMutator{}) }) } -func testApexMutator(mctx android.BottomUpMutatorContext) { - modules := mctx.CreateVariations(apexVariationName) +type testApexTransitionMutator struct{} + +func (t *testApexTransitionMutator) Split(ctx android.BaseModuleContext) []string { + return []string{apexVariationName} +} + +func (t *testApexTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string { + return sourceVariation +} + +func (t *testApexTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string { + return incomingVariation +} + +func (t *testApexTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) { apexInfo := android.ApexInfo{ ApexVariationName: apexVariationName, MinSdkVersion: android.ApiLevelForTest(apexVersion), } - mctx.SetVariationProvider(modules[0], android.ApexInfoProvider, apexInfo) + android.SetProvider(ctx, android.ApexInfoProvider, apexInfo) } // testCcWithConfig runs tests using the prepareForCcTest diff --git a/cc/config/Android.bp b/cc/config/Android.bp index 289409fb3..f514db68d 100644 --- a/cc/config/Android.bp +++ b/cc/config/Android.bp @@ -35,4 +35,8 @@ bootstrap_go_package { testSrcs: [ "tidy_test.go", ], + visibility: [ + "//build/soong:__subpackages__", + "//prebuilts/clang/host/linux-x86/soong", + ], } diff --git a/cc/fuzz.go b/cc/fuzz.go index d9e221b16..3f21bc6e7 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -57,7 +57,7 @@ func (fuzzer *fuzzer) props() []interface{} { return []interface{}{&fuzzer.Properties} } -func fuzzMutatorDeps(mctx android.TopDownMutatorContext) { +func fuzzMutatorDeps(mctx android.BottomUpMutatorContext) { currentModule, ok := mctx.Module().(*Module) if !ok { return diff --git a/cc/libbuildversion/Android.bp b/cc/libbuildversion/Android.bp index b105a3029..c1f2c1044 100644 --- a/cc/libbuildversion/Android.bp +++ b/cc/libbuildversion/Android.bp @@ -20,4 +20,5 @@ cc_library_static { "//apex_available:anyapex", ], vendor_available: true, + visibility: ["//visibility:public"], } diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go index 8202cc05a..2706261a8 100644 --- a/cc/ndk_abi.go +++ b/cc/ndk_abi.go @@ -46,7 +46,7 @@ func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) if m, ok := module.(*Module); ok { if installer, ok := m.installer.(*stubDecorator); ok { - if canDumpAbi(ctx.Config(), ctx.ModuleDir(module)) { + if installer.hasAbiDump { depPaths = append(depPaths, installer.abiDumpPath) } } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index bd6dfa301..94e0452dd 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -125,6 +125,7 @@ type stubDecorator struct { parsedCoverageXmlPath android.ModuleOutPath installPath android.Path abiDumpPath android.OutputPath + hasAbiDump bool abiDiffPaths android.Paths apiLevel android.ApiLevel @@ -330,11 +331,11 @@ func (this *stubDecorator) findPrebuiltAbiDump(ctx ModuleContext, } // Feature flag. -func canDumpAbi(config android.Config, moduleDir string) bool { +func (this *stubDecorator) canDumpAbi(ctx ModuleContext) bool { if runtime.GOOS == "darwin" { return false } - if strings.HasPrefix(moduleDir, "bionic/") { + if strings.HasPrefix(ctx.ModuleDir(), "bionic/") { // Bionic has enough uncommon implementation details like ifuncs and asm // code that the ABI tracking here has a ton of false positives. That's // causing pretty extreme friction for development there, so disabling @@ -343,8 +344,14 @@ func canDumpAbi(config android.Config, moduleDir string) bool { // http://b/358653811 return false } + + if this.apiLevel.IsCurrent() { + // "current" (AKA 10000) is not tracked. + return false + } + // http://b/156513478 - return config.ReleaseNdkAbiMonitored() + return ctx.Config().ReleaseNdkAbiMonitored() } // Feature flag to disable diffing against prebuilts. @@ -357,6 +364,7 @@ func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) { this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx, this.apiLevel.String(), ctx.Arch().ArchType.String(), this.libraryName(ctx), "abi.stg") + this.hasAbiDump = true headersList := getNdkABIHeadersFile(ctx) ctx.Build(pctx, android.BuildParams{ Rule: stg, @@ -478,7 +486,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile, c.apiLevel, "") objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc) c.versionScriptPath = nativeAbiResult.versionScript - if canDumpAbi(ctx.Config(), ctx.ModuleDir()) { + if c.canDumpAbi(ctx) { c.dumpAbi(ctx, nativeAbiResult.symbolList) if canDiffAbi(ctx.Config()) { c.diffAbi(ctx) diff --git a/cc/sanitize.go b/cc/sanitize.go index 7b0652c38..7f52ce1c7 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -176,7 +176,7 @@ func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) { switch t { case cfi, Hwasan, Asan, tsan, Fuzzer, scs, Memtag_stack: sanitizer := &sanitizerSplitMutator{t} - ctx.TopDown(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator) + ctx.BottomUp(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator) ctx.Transition(t.variationName(), sanitizer) case Memtag_heap, Memtag_globals, intOverflow: // do nothing @@ -1153,7 +1153,7 @@ type sanitizerSplitMutator struct { // If an APEX is sanitized or not depends on whether it contains at least one // sanitized module. Transition mutators cannot propagate information up the // dependency graph this way, so we need an auxiliary mutator to do so. -func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.TopDownMutatorContext) { +func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.BottomUpMutatorContext) { if sanitizeable, ok := ctx.Module().(Sanitizeable); ok { enabled := sanitizeable.IsSanitizerEnabled(ctx.Config(), s.sanitizer.name()) ctx.VisitDirectDeps(func(dep android.Module) { @@ -1355,7 +1355,7 @@ func (c *Module) IsSanitizerExplicitlyDisabled(t SanitizerType) bool { } // Propagate the ubsan minimal runtime dependency when there are integer overflow sanitized static dependencies. -func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) { +func sanitizerRuntimeDepsMutator(mctx android.BottomUpMutatorContext) { // Change this to PlatformSanitizable when/if non-cc modules support ubsan sanitizers. if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { if c.sanitize.Properties.ForceDisable { @@ -1437,11 +1437,11 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { //"null", //"shift-base", //"signed-integer-overflow", - // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. - // https://llvm.org/PR19302 - // http://reviews.llvm.org/D6974 - // "object-size", ) + + if mctx.Config().ReleaseBuildObjectSizeSanitizer() { + sanitizers = append(sanitizers, "object-size") + } } sanitizers = append(sanitizers, sanProps.Misc_undefined...) } diff --git a/cmd/extract_apks/bundle_proto/Android.bp b/cmd/extract_apks/bundle_proto/Android.bp index e56c0fb32..0abf1e251 100644 --- a/cmd/extract_apks/bundle_proto/Android.bp +++ b/cmd/extract_apks/bundle_proto/Android.bp @@ -10,4 +10,8 @@ python_library_host { proto: { canonical_path_from_root: false, }, + visibility: [ + "//build/soong:__subpackages__", + "//tools/mainline:__subpackages__", + ], } diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 24a44b4da..577c6cc74 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -212,7 +212,14 @@ func writeDepFile(outputFile string, eventHandler *metrics.EventHandler, ninjaDe } // Check if there are changes to the environment file, product variable file and -// soong_build binary, in which case no incremental will be performed. +// soong_build binary, in which case no incremental will be performed. For env +// variables we check the used env file, which will be removed in soong ui if +// there is any changes to the env variables used last time, in which case the +// check below will fail and a full build will be attempted. If any new env +// variables are added in the new run, soong ui won't be able to detect it, the +// used env file check below will pass. But unless there is a soong build code +// change, in which case the soong build binary check will fail, otherwise the +// new env variables shouldn't have any affect. func incrementalValid(config android.Config, configCacheFile string) (*ConfigCache, bool) { var newConfigCache ConfigCache data, err := os.ReadFile(shared.JoinPath(topDir, usedEnvFile)) diff --git a/cmd/symbols_map/Android.bp b/cmd/symbols_map/Android.bp index e3ae6ede5..272e8061a 100644 --- a/cmd/symbols_map/Android.bp +++ b/cmd/symbols_map/Android.bp @@ -30,4 +30,5 @@ bootstrap_go_package { srcs: [ "symbols_map_proto/symbols_map.pb.go", ], + visibility: ["//visibility:public"], } diff --git a/cmd/zip2zip/Android.bp b/cmd/zip2zip/Android.bp index 3ef766865..7f9b16582 100644 --- a/cmd/zip2zip/Android.bp +++ b/cmd/zip2zip/Android.bp @@ -27,4 +27,6 @@ blueprint_go_binary { "zip2zip.go", ], testSrcs: ["zip2zip_test.go"], + // Used by genrules + visibility: ["//visibility:public"], } diff --git a/compliance/license_metadata_proto/Android.bp b/compliance/license_metadata_proto/Android.bp index 3c041e48b..47612854f 100644 --- a/compliance/license_metadata_proto/Android.bp +++ b/compliance/license_metadata_proto/Android.bp @@ -24,4 +24,8 @@ bootstrap_go_package { "golang-protobuf-reflect-protoreflect", "golang-protobuf-runtime-protoimpl", ], + visibility: [ + "//build/make/tools/compliance:__subpackages__", + "//build/soong:__subpackages__", + ], } diff --git a/compliance/project_metadata_proto/Android.bp b/compliance/project_metadata_proto/Android.bp index 56e76e79f..0c807b22f 100644 --- a/compliance/project_metadata_proto/Android.bp +++ b/compliance/project_metadata_proto/Android.bp @@ -24,4 +24,5 @@ bootstrap_go_package { "golang-protobuf-reflect-protoreflect", "golang-protobuf-runtime-protoimpl", ], + visibility: ["//build/make/tools/compliance:__subpackages__"], } diff --git a/etc/Android.bp b/etc/Android.bp index f02c12a2a..580c54f9b 100644 --- a/etc/Android.bp +++ b/etc/Android.bp @@ -20,4 +20,6 @@ bootstrap_go_package { "install_symlink_test.go", ], pluginFor: ["soong_build"], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 0b390624f..035399282 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -147,14 +147,14 @@ type filesystemProperties struct { func filesystemFactory() android.Module { module := &filesystem{} module.filterPackagingSpec = module.filterInstallablePackagingSpec - initFilesystemModule(module) + initFilesystemModule(module, module) return module } -func initFilesystemModule(module *filesystem) { - module.AddProperties(&module.properties) - android.InitPackageModule(module) - module.PackagingBase.DepsCollectFirstTargetOnly = true +func initFilesystemModule(module android.DefaultableModule, filesystemModule *filesystem) { + module.AddProperties(&filesystemModule.properties) + android.InitPackageModule(filesystemModule) + filesystemModule.PackagingBase.DepsCollectFirstTargetOnly = true android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) } diff --git a/filesystem/system_image.go b/filesystem/system_image.go index 805249e9a..63cb627d8 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -38,7 +38,7 @@ func systemImageFactory() android.Module { module.AddProperties(&module.properties) module.filesystem.buildExtraFiles = module.buildExtraFiles module.filesystem.filterPackagingSpec = module.filterPackagingSpec - initFilesystemModule(&module.filesystem) + initFilesystemModule(module, &module.filesystem) return module } diff --git a/genrule/Android.bp b/genrule/Android.bp index 7331741de..f4197e691 100644 --- a/genrule/Android.bp +++ b/genrule/Android.bp @@ -22,4 +22,6 @@ bootstrap_go_package { "genrule_test.go", ], pluginFor: ["soong_build"], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/java/Android.bp b/java/Android.bp index 9603815a1..926a294e9 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -120,4 +120,5 @@ bootstrap_go_package { "test_spec_test.go", ], pluginFor: ["soong_build"], + visibility: ["//visibility:public"], } diff --git a/java/config/Android.bp b/java/config/Android.bp index bfe83ab8c..6217390bb 100644 --- a/java/config/Android.bp +++ b/java/config/Android.bp @@ -17,4 +17,8 @@ bootstrap_go_package { "kotlin.go", "makevars.go", ], + visibility: [ + "//build/soong:__subpackages__", + "//external/error_prone/soong", + ], } diff --git a/java/dex.go b/java/dex.go index 7d42efc9c..e0e642c63 100644 --- a/java/dex.go +++ b/java/dex.go @@ -120,7 +120,7 @@ func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool } func (d *DexProperties) optimizedResourceShrinkingEnabled(ctx android.ModuleContext) bool { - return d.resourceShrinkingEnabled(ctx) && Bool(d.Optimize.Optimized_shrink_resources) + return d.resourceShrinkingEnabled(ctx) && BoolDefault(d.Optimize.Optimized_shrink_resources, ctx.Config().UseOptimizedResourceShrinkingByDefault()) } func (d *dexer) optimizeOrObfuscateEnabled() bool { @@ -245,6 +245,16 @@ func (d *dexer) dexCommonFlags(ctx android.ModuleContext, if err != nil { ctx.PropertyErrorf("min_sdk_version", "%s", err) } + if !Bool(d.dexProperties.No_dex_container) && effectiveVersion.FinalOrFutureInt() >= 36 { + // W is 36, but we have not bumped the SDK version yet, so check for both. + if ctx.Config().PlatformSdkVersion().FinalInt() >= 36 || + ctx.Config().PlatformSdkCodename() == "Wear" { + // TODO(b/329465418): Skip this module since it causes issue with app DRM + if ctx.ModuleName() != "framework-minus-apex" { + flags = append([]string{"-JDcom.android.tools.r8.dexContainerExperiment"}, flags...) + } + } + } // If the specified SDK level is 10000, then configure the compiler to use the // current platform SDK level and to compile the build as a platform build. @@ -390,7 +400,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams) r8Flags = append(r8Flags, "--resource-input", d.resourcesInput.Path().String()) r8Deps = append(r8Deps, d.resourcesInput.Path()) r8Flags = append(r8Flags, "--resource-output", d.resourcesOutput.Path().String()) - if Bool(opt.Optimized_shrink_resources) { + if d.dexProperties.optimizedResourceShrinkingEnabled(ctx) { r8Flags = append(r8Flags, "--optimized-resource-shrinking") } } diff --git a/java/java.go b/java/java.go index cdd48d7bc..d63bbe6e1 100644 --- a/java/java.go +++ b/java/java.go @@ -3345,6 +3345,10 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module, if lib, ok := depModule.(SdkLibraryDependency); ok && lib.sharedLibrary() { // A shared SDK library. This should be added as a top-level CLC element. sdkLib = &depName + } else if lib, ok := depModule.(SdkLibraryComponentDependency); ok && lib.OptionalSdkLibraryImplementation() != nil { + if depModule.Name() == proptools.String(lib.OptionalSdkLibraryImplementation())+".impl" { + sdkLib = lib.OptionalSdkLibraryImplementation() + } } else if ulib, ok := depModule.(ProvidesUsesLib); ok { // A non-SDK library disguised as an SDK library by the means of `provides_uses_lib` // property. This should be handled in the same way as a shared SDK library. diff --git a/java/kotlin.go b/java/kotlin.go index 5a76df29d..f42d16304 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -162,7 +162,7 @@ func (j *Module) kotlinCompile(ctx android.ModuleContext, outputFile, headerOutp "srcJarDir": android.PathForModuleOut(ctx, "kotlinc", "srcJars.xref").String(), } if commonSrcsList.Valid() { - args["commonSrcFilesList"] = "--srcs @" + commonSrcsList.String() + args["commonSrcFilesList"] = "--common_srcs @" + commonSrcsList.String() } ctx.Build(pctx, android.BuildParams{ Rule: kotlinKytheExtract, diff --git a/java/metalava/Android.bp b/java/metalava/Android.bp index ccbd191d3..6bf183296 100644 --- a/java/metalava/Android.bp +++ b/java/metalava/Android.bp @@ -15,4 +15,5 @@ filegroup { name: "metalava-config-files", srcs: ["*-config.xml"], + visibility: ["//visibility:public"], } diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 67ed84e1d..5b145c658 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -110,6 +110,7 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon p.installConfigFile = android.PathForModuleInstall(ctx, "etc", "compatconfig", p.configFile.Base()) rule.Build(configFileName, "Extract compat/compat_config.xml and install it") ctx.InstallFile(p.installDirPath, p.configFile.Base(), p.configFile) + ctx.SetOutputFiles(android.Paths{p.configFile}, "") } func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { diff --git a/java/ravenwood.go b/java/ravenwood.go index 3fa73e64d..9239bbd6b 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -34,6 +34,7 @@ var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"} var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"} var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"} var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"} +var ravenwoodTestInstResourceApkTag = dependencyTag{name: "ravenwoodtest-inst-res-apk"} const ravenwoodUtilsName = "ravenwood-utils" const ravenwoodRuntimeName = "ravenwood-runtime" @@ -56,11 +57,17 @@ type ravenwoodTestProperties struct { Jni_libs []string // Specify another android_app module here to copy it to the test directory, so that - // the ravenwood test can access it. + // the ravenwood test can access it. This APK will be loaded as resources of the test + // target app. // TODO: For now, we simply refer to another android_app module and copy it to the // test directory. Eventually, android_ravenwood_test should support all the resource // related properties and build resources from the `res/` directory. Resource_apk *string + + // Specify another android_app module here to copy it to the test directory, so that + // the ravenwood test can access it. This APK will be loaded as resources of the test + // instrumentation app itself. + Inst_resource_apk *string } type ravenwoodTest struct { @@ -127,6 +134,10 @@ func (r *ravenwoodTest) DepsMutator(ctx android.BottomUpMutatorContext) { if resourceApk := proptools.String(r.ravenwoodTestProperties.Resource_apk); resourceApk != "" { ctx.AddVariationDependencies(nil, ravenwoodTestResourceApkTag, resourceApk) } + + if resourceApk := proptools.String(r.ravenwoodTestProperties.Inst_resource_apk); resourceApk != "" { + ctx.AddVariationDependencies(nil, ravenwoodTestInstResourceApkTag, resourceApk) + } } func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -194,13 +205,16 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { } resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks") - if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 { - for _, installFile := range android.OtherModuleProviderOrDefault( - ctx, resApk[0], android.InstallFilesProvider).InstallFiles { - installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile) + + copyResApk := func(tag blueprint.DependencyTag, toFileName string) { + if resApk := ctx.GetDirectDepsWithTag(tag); len(resApk) > 0 { + installFile := android.OutputFileForModule(ctx, resApk[0], "") + installResApk := ctx.InstallFile(resApkInstallPath, toFileName, installFile) installDeps = append(installDeps, installResApk) } } + copyResApk(ravenwoodTestResourceApkTag, "ravenwood-res.apk") + copyResApk(ravenwoodTestInstResourceApkTag, "ravenwood-inst-res.apk") // Install our JAR with all dependencies ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...) diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index 0a1b08926..753a118e9 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -66,6 +66,10 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers( name: "app2", sdk_version: "current", } + android_app { + name: "app3", + sdk_version: "current", + } prebuilt_font { name: "Font.ttf", src: "Font.ttf", @@ -167,6 +171,7 @@ func TestRavenwoodTest(t *testing.T) { "ravenwood-runtime-jni2", ], resource_apk: "app2", + inst_resource_apk: "app3", sdk_version: "test_current", } `) @@ -194,6 +199,7 @@ func TestRavenwoodTest(t *testing.T) { module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so") module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so") module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-res.apk") + module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-inst-res.apk") // ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted. for _, o := range module.AllOutputs() { diff --git a/linkerconfig/proto/Android.bp b/linkerconfig/proto/Android.bp index 754e7bfbb..a93050251 100644 --- a/linkerconfig/proto/Android.bp +++ b/linkerconfig/proto/Android.bp @@ -15,6 +15,7 @@ cc_library_static { "//apex_available:platform", "//apex_available:anyapex", ], + visibility: ["//system/linkerconfig"], } python_library_host { diff --git a/phony/Android.bp b/phony/Android.bp index db5efc98e..2e250c699 100644 --- a/phony/Android.bp +++ b/phony/Android.bp @@ -13,4 +13,5 @@ bootstrap_go_package { "phony.go", ], pluginFor: ["soong_build"], + visibility: ["//visibility:public"], } diff --git a/response/Android.bp b/response/Android.bp index e19981f8f..2f319fec9 100644 --- a/response/Android.bp +++ b/response/Android.bp @@ -13,4 +13,8 @@ bootstrap_go_package { testSrcs: [ "response_test.go", ], + visibility: [ + "//build/make/tools/compliance", + "//build/soong:__subpackages__", + ], } diff --git a/rust/Android.bp b/rust/Android.bp index 53c94621e..781f325d1 100644 --- a/rust/Android.bp +++ b/rust/Android.bp @@ -61,4 +61,5 @@ bootstrap_go_package { "test_test.go", ], pluginFor: ["soong_build"], + visibility: ["//visibility:public"], } diff --git a/rust/config/Android.bp b/rust/config/Android.bp index 79ea7a174..25f7580d0 100644 --- a/rust/config/Android.bp +++ b/rust/config/Android.bp @@ -24,4 +24,8 @@ bootstrap_go_package { "x86_64_device.go", "arm64_linux_host.go", ], + visibility: [ + "//build/soong:__subpackages__", + "//prebuilts/rust/soong", + ], } diff --git a/sysprop/Android.bp b/sysprop/Android.bp index a00a5e42c..22cba3bf1 100644 --- a/sysprop/Android.bp +++ b/sysprop/Android.bp @@ -21,4 +21,6 @@ bootstrap_go_package { "sysprop_test.go", ], pluginFor: ["soong_build"], + // Used by plugins + visibility: ["//visibility:public"], } diff --git a/testing/code_metadata_internal_proto/Android.bp b/testing/code_metadata_internal_proto/Android.bp index a534cc20b..396e44f52 100644 --- a/testing/code_metadata_internal_proto/Android.bp +++ b/testing/code_metadata_internal_proto/Android.bp @@ -20,10 +20,14 @@ bootstrap_go_package { name: "soong-testing-code_metadata_internal_proto", pkgPath: "android/soong/testing/code_metadata_internal_proto", deps: [ - "golang-protobuf-reflect-protoreflect", - "golang-protobuf-runtime-protoimpl", - ], + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + ], srcs: [ "code_metadata_internal.pb.go", ], + visibility: [ + "//build/make/tools/metadata", + "//build/soong:__subpackages__", + ], } diff --git a/testing/code_metadata_proto/Android.bp b/testing/code_metadata_proto/Android.bp index f07efffb3..ae41d4aa1 100644 --- a/testing/code_metadata_proto/Android.bp +++ b/testing/code_metadata_proto/Android.bp @@ -26,6 +26,7 @@ bootstrap_go_package { srcs: [ "code_metadata.pb.go", ], + visibility: ["//build/make/tools/metadata"], } python_library_host { @@ -40,4 +41,5 @@ python_library_host { proto: { canonical_path_from_root: false, }, + visibility: ["//tools/asuite/team_build_scripts"], } diff --git a/testing/test_spec_proto/Android.bp b/testing/test_spec_proto/Android.bp index d5ad70b73..1070d1a9c 100644 --- a/testing/test_spec_proto/Android.bp +++ b/testing/test_spec_proto/Android.bp @@ -26,6 +26,11 @@ bootstrap_go_package { srcs: [ "test_spec.pb.go", ], + visibility: [ + "//build/make/tools/metadata", + "//build/soong:__subpackages__", + "//vendor:__subpackages__", + ], } python_library_host { @@ -40,4 +45,5 @@ python_library_host { proto: { canonical_path_from_root: false, }, + visibility: ["//tools/asuite/team_build_scripts"], } diff --git a/tests/build_action_caching_test.sh b/tests/build_action_caching_test.sh new file mode 100755 index 000000000..981827d6f --- /dev/null +++ b/tests/build_action_caching_test.sh @@ -0,0 +1,110 @@ +#!/bin/bash -u + +set -o pipefail + +# Test that the mk and ninja files generated by Soong don't change if some +# incremental modules are restored from cache. + +OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)" +echo ${OUTPUT_DIR} + +function cleanup { + rm -rf "${OUTPUT_DIR}" +} +trap cleanup EXIT + +function run_soong_build { + USE_RBE=false TARGET_PRODUCT=aosp_arm TARGET_RELEASE=trunk_staging TARGET_BUILD_VARIANT=userdebug build/soong/soong_ui.bash --make-mode --incremental-build-actions nothing +} + +function run_soong_clean { + build/soong/soong_ui.bash --make-mode clean +} + +function assert_files_equal { + if [ $# -ne 2 ]; then + echo "Usage: assert_files_equal file1 file2" + exit 1 + fi + + if ! cmp -s "$1" "$2"; then + echo "Files are different: $1 $2" + exit 1 + fi +} + +function compare_mtimes() { + if [ $# -ne 2 ]; then + echo "Usage: compare_mtimes file1 file2" + exit 1 + fi + + file1_mtime=$(stat -c '%Y' $1) + file2_mtime=$(stat -c '%Y' $2) + + if [ "$file1_mtime" -eq "$file2_mtime" ]; then + return 1 + else + return 0 + fi +} + +function test_build_action_restoring() { + run_soong_clean + cat > ${OUTPUT_DIR}/Android.bp <<'EOF' +python_binary_host { + name: "my_little_binary_host", + srcs: ["my_little_binary_host.py"], +} +EOF + touch ${OUTPUT_DIR}/my_little_binary_host.py + run_soong_build + mkdir -p "${OUTPUT_DIR}/before" + cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm.*.ninja ${OUTPUT_DIR}/before + # add a comment to the bp file, this should force a new analysis but no module + # should be really impacted, so all the incremental modules should be skipped. + cat >> ${OUTPUT_DIR}/Android.bp <<'EOF' +// new comments +EOF + run_soong_build + mkdir -p "${OUTPUT_DIR}/after" + cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm.*.ninja ${OUTPUT_DIR}/after + + compare_files +} + +function compare_files() { + for file_before in ${OUTPUT_DIR}/before/*.ninja; do + file_after="${OUTPUT_DIR}/after/$(basename "$file_before")" + assert_files_equal $file_before $file_after + compare_mtimes $file_before $file_after + if [ $? -ne 0 ]; then + echo "Files have identical mtime: $file_before $file_after" + exit 1 + fi + done + + for file_before in ${OUTPUT_DIR}/before/*.mk; do + file_after="${OUTPUT_DIR}/after/$(basename "$file_before")" + assert_files_equal $file_before $file_after + compare_mtimes $file_before $file_after + # mk files shouldn't be regenerated + if [ $? -ne 1 ]; then + echo "Files have different mtimes: $file_before $file_after" + exit 1 + fi + done + + for file_before in ${OUTPUT_DIR}/before/build_aosp_arm_ninja_incremental/*.ninja; do + file_after="${OUTPUT_DIR}/after/build_aosp_arm_ninja_incremental/$(basename "$file_before")" + assert_files_equal $file_before $file_after + compare_mtimes $file_before $file_after + # ninja files of skipped modules shouldn't be regenerated + if [ $? -ne 1 ]; then + echo "Files have different mtimes: $file_before $file_after" + exit 1 + fi + done +} + +test_build_action_restoring diff --git a/zip/cmd/Android.bp b/zip/cmd/Android.bp index 43bf232a0..16c3f698f 100644 --- a/zip/cmd/Android.bp +++ b/zip/cmd/Android.bp @@ -24,4 +24,6 @@ blueprint_go_binary { srcs: [ "main.go", ], + // Used by genrules + visibility: ["//visibility:public"], } |