Merge "Use OutputFilesProvider on genrule" into main
diff --git a/Android.bp b/Android.bp
index b1db8e9..2c0ef47 100644
--- a/Android.bp
+++ b/Android.bp
@@ -104,6 +104,7 @@
// Instantiate the dex_bootjars singleton module.
dex_bootjars {
name: "dex_bootjars",
+ no_full_install: true,
}
// Pseudo-test that's run on checkbuilds to ensure that get_clang_version can
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index 71a64dd..dac0ae3 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -15,7 +15,6 @@
package aconfig
import (
- "fmt"
"strings"
"android/soong/android"
@@ -44,8 +43,6 @@
// The flags will only be repackaged if this prop is true.
Exportable bool
}
-
- intermediatePath android.WritablePath
}
func DeclarationsFactory() android.Module {
@@ -86,18 +83,6 @@
}
}
-func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- // The default output of this module is the intermediates format, which is
- // not installable and in a private format that no other rules can handle
- // correctly.
- return []android.Path{module.intermediatePath}, nil
- default:
- return nil, fmt.Errorf("unsupported aconfig_declarations module reference tag %q", tag)
- }
-}
-
func joinAndPrefix(prefix string, values []string) string {
var sb strings.Builder
for _, v := range values {
@@ -171,5 +156,4 @@
IntermediateCacheOutputPath: intermediateCacheFilePath,
IntermediateDumpOutputPath: intermediateDumpFilePath,
})
-
}
diff --git a/aconfig/build_flags/declarations.go b/aconfig/build_flags/declarations.go
index f6a6ee1..e927db2 100644
--- a/aconfig/build_flags/declarations.go
+++ b/aconfig/build_flags/declarations.go
@@ -15,7 +15,6 @@
package build_flags
import (
- "fmt"
"strings"
"android/soong/android"
@@ -39,8 +38,6 @@
// aconfig files, relative to this Android.bp file
Srcs []string `android:"path"`
}
-
- intermediatePath android.WritablePath
}
func DeclarationsFactory() android.Module {
@@ -53,18 +50,6 @@
return module
}
-func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- // The default output of this module is the intermediates format, which is
- // not installable and in a private format that no other rules can handle
- // correctly.
- return []android.Path{module.intermediatePath}, nil
- default:
- return nil, fmt.Errorf("unsupported build_flags_declarations module reference tag %q", tag)
- }
-}
-
func joinAndPrefix(prefix string, values []string) string {
var sb strings.Builder
for _, v := range values {
diff --git a/aconfig/codegen/aconfig_declarations_group.go b/aconfig/codegen/aconfig_declarations_group.go
index 1c91bee..13daf47 100644
--- a/aconfig/codegen/aconfig_declarations_group.go
+++ b/aconfig/codegen/aconfig_declarations_group.go
@@ -15,7 +15,6 @@
package codegen
import (
- "fmt"
"maps"
"android/soong/android"
@@ -40,11 +39,6 @@
android.DefaultableModuleBase
properties AconfigDeclarationsGroupProperties
-
- aconfigDeclarationNames []string
- intermediateCacheOutputPaths android.Paths
- javaSrcjars android.Paths
- modeInfos map[string]android.ModeInfo
}
type AconfigDeclarationsGroupProperties struct {
@@ -77,63 +71,45 @@
ctx.AddDependency(ctx.Module(), rustAconfigLibraryTag, adg.properties.Rust_aconfig_libraries...)
}
-func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
- adg.modeInfos = make(map[string]android.ModeInfo)
+func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ modeInfos := make(map[string]android.ModeInfo)
+ var aconfigDeclarationNames []string
+ var intermediateCacheOutputPaths android.Paths
+ var javaSrcjars android.Paths
ctx.VisitDirectDeps(func(dep android.Module) {
tag := ctx.OtherModuleDependencyTag(dep)
if provider, ok := android.OtherModuleProvider(ctx, dep, android.CodegenInfoProvider); ok {
// aconfig declaration names and cache files are collected for all aconfig library dependencies
- adg.aconfigDeclarationNames = append(adg.aconfigDeclarationNames, provider.AconfigDeclarations...)
- adg.intermediateCacheOutputPaths = append(adg.intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...)
+ aconfigDeclarationNames = append(aconfigDeclarationNames, provider.AconfigDeclarations...)
+ intermediateCacheOutputPaths = append(intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...)
switch tag {
case aconfigDeclarationsGroupTag:
// Will retrieve outputs from another language codegen modules when support is added
- adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
- maps.Copy(adg.modeInfos, provider.ModeInfos)
+ javaSrcjars = append(javaSrcjars, provider.Srcjars...)
+ maps.Copy(modeInfos, provider.ModeInfos)
case javaAconfigLibraryTag:
- adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
- maps.Copy(adg.modeInfos, provider.ModeInfos)
+ javaSrcjars = append(javaSrcjars, provider.Srcjars...)
+ maps.Copy(modeInfos, provider.ModeInfos)
case ccAconfigLibraryTag:
- maps.Copy(adg.modeInfos, provider.ModeInfos)
+ maps.Copy(modeInfos, provider.ModeInfos)
case rustAconfigLibraryTag:
- maps.Copy(adg.modeInfos, provider.ModeInfos)
+ maps.Copy(modeInfos, provider.ModeInfos)
}
}
})
-}
-func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- adg.VisitDeps(ctx)
- adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames)
- adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths)
+ aconfigDeclarationNames = android.FirstUniqueStrings(aconfigDeclarationNames)
+ intermediateCacheOutputPaths = android.FirstUniquePaths(intermediateCacheOutputPaths)
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
- AconfigDeclarations: adg.aconfigDeclarationNames,
- IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths,
- Srcjars: adg.javaSrcjars,
- ModeInfos: adg.modeInfos,
+ AconfigDeclarations: aconfigDeclarationNames,
+ IntermediateCacheOutputPaths: intermediateCacheOutputPaths,
+ Srcjars: javaSrcjars,
+ ModeInfos: modeInfos,
})
-}
-var _ android.OutputFileProducer = (*AconfigDeclarationsGroup)(nil)
-
-func (adg *AconfigDeclarationsGroup) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return adg.intermediateCacheOutputPaths, nil
- case ".srcjars":
- return adg.javaSrcjars, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %s", tag)
- }
-}
-
-func (adg *AconfigDeclarationsGroup) Srcjars() android.Paths {
- return adg.javaSrcjars
-}
-
-func (adg *AconfigDeclarationsGroup) AconfigDeclarations() []string {
- return adg.aconfigDeclarationNames
+ ctx.SetOutputFiles(intermediateCacheOutputPaths, "")
+ ctx.SetOutputFiles(javaSrcjars, ".srcjars")
}
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index 9f42e21..673ac2a 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -15,8 +15,6 @@
package codegen
import (
- "fmt"
-
"android/soong/android"
"android/soong/java"
@@ -80,7 +78,7 @@
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
declarationsModules := ctx.GetDirectDepsWithTag(declarationsTag)
if len(declarationsModules) != 1 {
- panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
+ panic("Exactly one aconfig_declarations property required")
}
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
@@ -133,10 +131,6 @@
return srcJarPath, declarations.IntermediateCacheOutputPath
}
-func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) AconfigDeclarations() *string {
- return proptools.StringPtr(callbacks.properties.Aconfig_declarations)
-}
-
func isModeSupported(mode string) bool {
return android.InList(mode, aconfigSupportedModes)
}
diff --git a/android/api_levels.go b/android/api_levels.go
index fab5fc7..dc17238 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -291,6 +291,8 @@
var ApiLevelUpsideDownCake = uncheckedFinalApiLevel(34)
+var ApiLevelVanillaIceCream = uncheckedFinalApiLevel(35)
+
// ReplaceFinalizedCodenames returns the API level number associated with that API level
// if the `raw` input is the codename of an API level has been finalized.
// If the input is *not* a finalized codename, the input is returned unmodified.
diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go
index 8288fc5..083f3ef 100644
--- a/android/buildinfo_prop.go
+++ b/android/buildinfo_prop.go
@@ -23,7 +23,7 @@
func init() {
ctx := InitRegistrationContext
- ctx.RegisterParallelSingletonModuleType("buildinfo_prop", buildinfoPropFactory)
+ ctx.RegisterModuleType("buildinfo_prop", buildinfoPropFactory)
}
type buildinfoPropProperties struct {
@@ -32,7 +32,7 @@
}
type buildinfoPropModule struct {
- SingletonModuleBase
+ ModuleBase
properties buildinfoPropProperties
@@ -88,6 +88,10 @@
}
func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ if ctx.ModuleName() != "buildinfo.prop" || ctx.ModuleDir() != "build/soong" {
+ ctx.ModuleErrorf("There can only be one buildinfo_prop module in build/soong")
+ return
+ }
p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath
if !ctx.Config().KatiEnabled() {
WriteFileRule(ctx, p.outputFilePath, "# no buildinfo.prop if kati is disabled")
@@ -111,10 +115,11 @@
cmd.FlagWithArg("--build-id=", config.BuildId())
cmd.FlagWithArg("--build-keys=", config.BuildKeys())
- // shouldn't depend on BuildNumberFile and BuildThumbprintFile to prevent from rebuilding
- // on every incremental build.
- cmd.FlagWithArg("--build-number-file=", config.BuildNumberFile(ctx).String())
+ // Note: depending on BuildNumberFile will cause the build.prop file to be rebuilt
+ // every build, but that's intentional.
+ cmd.FlagWithInput("--build-number-file=", config.BuildNumberFile(ctx))
if shouldAddBuildThumbprint(config) {
+ // In the previous make implementation, a dependency was not added on the thumbprint file
cmd.FlagWithArg("--build-thumbprint-file=", config.BuildThumbprintFile(ctx).String())
}
@@ -123,8 +128,10 @@
cmd.FlagWithArg("--build-variant=", buildVariant)
cmd.FlagForEachArg("--cpu-abis=", config.DeviceAbi())
- // shouldn't depend on BUILD_DATETIME_FILE to prevent from rebuilding on every incremental
- // build.
+ // Technically we should also have a dependency on BUILD_DATETIME_FILE,
+ // but it can be either an absolute or relative path, which is hard to turn into
+ // a Path object. So just rely on the BuildNumberFile always changing to cause
+ // us to rebuild.
cmd.FlagWithArg("--date-file=", ctx.Config().Getenv("BUILD_DATETIME_FILE"))
if len(config.ProductLocales()) > 0 {
@@ -163,12 +170,8 @@
ctx.InstallFile(p.installPath, p.Name(), p.outputFilePath)
}
-func (f *buildinfoPropModule) GenerateSingletonBuildActions(ctx SingletonContext) {
- // does nothing; buildinfo_prop is a singeton because two buildinfo modules don't make sense.
-}
-
func (p *buildinfoPropModule) AndroidMkEntries() []AndroidMkEntries {
- return []AndroidMkEntries{AndroidMkEntries{
+ return []AndroidMkEntries{{
Class: "ETC",
OutputFile: OptionalPathForPath(p.outputFilePath),
ExtraEntries: []AndroidMkExtraEntriesFunc{
@@ -184,7 +187,7 @@
// buildinfo_prop module generates a build.prop file, which contains a set of common
// system/build.prop properties, such as ro.build.version.*. Not all properties are implemented;
// currently this module is only for microdroid.
-func buildinfoPropFactory() SingletonModule {
+func buildinfoPropFactory() Module {
module := &buildinfoPropModule{}
module.AddProperties(&module.properties)
InitAndroidModule(module)
diff --git a/android/config.go b/android/config.go
index a18cb8b..1124488 100644
--- a/android/config.go
+++ b/android/config.go
@@ -22,7 +22,6 @@
"fmt"
"os"
"path/filepath"
- "reflect"
"runtime"
"strconv"
"strings"
@@ -37,9 +36,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android/soongconfig"
- "android/soong/bazel"
"android/soong/remoteexec"
- "android/soong/starlark_fmt"
)
// Bool re-exports proptools.Bool for the android package.
@@ -413,7 +410,7 @@
proptools.StringPtr(String(configurable.Platform_sdk_codename))
}
- return saveToBazelConfigFile(configurable, filepath.Dir(filename))
+ return nil
}
// atomically writes the config file in case two copies of soong_build are running simultaneously
@@ -447,81 +444,6 @@
return nil
}
-type productVariableStarlarkRepresentation struct {
- soongType string
- selectable bool
- archVariant bool
-}
-
-func saveToBazelConfigFile(config *ProductVariables, outDir string) error {
- dir := filepath.Join(outDir, bazel.SoongInjectionDirName, "product_config")
- err := createDirIfNonexistent(dir, os.ModePerm)
- if err != nil {
- return fmt.Errorf("Could not create dir %s: %s", dir, err)
- }
-
- allProductVariablesType := reflect.TypeOf((*ProductVariables)(nil)).Elem()
- productVariablesInfo := make(map[string]productVariableStarlarkRepresentation)
- p := variableProperties{}
- t := reflect.TypeOf(p.Product_variables)
- for i := 0; i < t.NumField(); i++ {
- f := t.Field(i)
- archVariant := proptools.HasTag(f, "android", "arch_variant")
- if mainProductVariablesStructField, ok := allProductVariablesType.FieldByName(f.Name); ok {
- productVariablesInfo[f.Name] = productVariableStarlarkRepresentation{
- soongType: stringRepresentationOfSimpleType(mainProductVariablesStructField.Type),
- selectable: true,
- archVariant: archVariant,
- }
- } else {
- panic("Unknown variable " + f.Name)
- }
- }
-
- err = pathtools.WriteFileIfChanged(filepath.Join(dir, "product_variable_constants.bzl"), []byte(fmt.Sprintf(`
-# product_var_constant_info is a map of product variables to information about them. The fields are:
-# - soongType: The type of the product variable as it appears in soong's ProductVariables struct.
-# examples are string, bool, int, *bool, *string, []string, etc. This may be an overly
-# conservative estimation of the type, for example a *bool could oftentimes just be a
-# bool that defaults to false.
-# - selectable: if this product variable can be selected on in Android.bp/build files. This means
-# it's listed in the "variableProperties" soong struct. Currently all variables in
-# this list are selectable because we only need the selectable ones at the moment,
-# but the list may be expanded later.
-# - archVariant: If the variable is tagged as arch variant in the "variableProperties" struct.
-product_var_constant_info = %s
-product_var_constraints = [k for k, v in product_var_constant_info.items() if v.selectable]
-arch_variant_product_var_constraints = [k for k, v in product_var_constant_info.items() if v.selectable and v.archVariant]
-`, starlark_fmt.PrintAny(productVariablesInfo, 0))), 0644)
- if err != nil {
- return fmt.Errorf("Could not write .bzl config file %s", err)
- }
- err = pathtools.WriteFileIfChanged(filepath.Join(dir, "BUILD"),
- []byte(bazel.GeneratedBazelFileWarning), 0644)
- if err != nil {
- return fmt.Errorf("Could not write BUILD config file %s", err)
- }
-
- return nil
-}
-
-func stringRepresentationOfSimpleType(ty reflect.Type) string {
- switch ty.Kind() {
- case reflect.String:
- return "string"
- case reflect.Bool:
- return "bool"
- case reflect.Int:
- return "int"
- case reflect.Slice:
- return "[]" + stringRepresentationOfSimpleType(ty.Elem())
- case reflect.Pointer:
- return "*" + stringRepresentationOfSimpleType(ty.Elem())
- default:
- panic("unimplemented type: " + ty.Kind().String())
- }
-}
-
// NullConfig returns a mostly empty Config for use by standalone tools like dexpreopt_gen that
// use the android package.
func NullConfig(outDir, soongOutDir string) Config {
@@ -1392,10 +1314,6 @@
return String(c.productVariables.PrebuiltHiddenApiDir)
}
-func (c *config) IsVndkDeprecated() bool {
- return !Bool(c.productVariables.KeepVndk)
-}
-
func (c *config) VendorApiLevel() string {
return String(c.productVariables.VendorApiLevel)
}
diff --git a/android/image.go b/android/image.go
index bc6b8cd..9cad056 100644
--- a/android/image.go
+++ b/android/image.go
@@ -44,9 +44,8 @@
ExtraImageVariations(ctx BaseModuleContext) []string
// SetImageVariation is called for each newly created image variant. The receiver is the original
- // module, "variation" is the name of the newly created variant and "module" is the newly created
- // variant itself.
- SetImageVariation(ctx BaseModuleContext, variation string, module Module)
+ // module, "variation" is the name of the newly created variant. "variation" is set on the receiver.
+ SetImageVariation(ctx BaseModuleContext, variation string)
}
const (
@@ -106,7 +105,7 @@
mod := ctx.CreateVariations(variations...)
for i, v := range variations {
mod[i].base().setImageVariation(v)
- m.SetImageVariation(ctx, v, mod[i])
+ mod[i].(ImageInterface).SetImageVariation(ctx, v)
}
}
}
diff --git a/android/selects_test.go b/android/selects_test.go
index 6f980ce..3093deb 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -778,6 +778,27 @@
my_string_list: &[]string{"a.cpp", "b.cpp", "c.cpp"},
},
},
+ {
+ name: "Test AppendSimpleValue",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string_list: ["a.cpp"] + select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": ["a.cpp"],
+ "b": ["b.cpp"],
+ default: ["c.cpp"],
+ }),
+ }
+ `,
+ vendorVars: map[string]map[string]string{
+ "selects_test": {
+ "append_to_string_list": "foo.cpp",
+ },
+ },
+ provider: selectsTestProvider{
+ my_string_list: &[]string{"a.cpp", "c.cpp", "foo.cpp"},
+ },
+ },
}
for _, tc := range testCases {
@@ -892,6 +913,10 @@
}
func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ toAppend := ctx.Config().VendorConfig("selects_test").String("append_to_string_list")
+ if toAppend != "" {
+ p.properties.My_string_list.AppendSimpleValue([]string{toAppend})
+ }
SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{
my_bool: optionalToPtr(p.properties.My_bool.Get(ctx)),
my_string: optionalToPtr(p.properties.My_string.Get(ctx)),
diff --git a/android/testing.go b/android/testing.go
index 6518f4a..6fb2997 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1014,10 +1014,18 @@
return normalizeStringMapRelativeToTop(m.config, m.module.VariablesForTests())
}
-// OutputFiles calls OutputFileProducer.OutputFiles on the encapsulated module, exits the test
-// immediately if there is an error and otherwise returns the result of calling Paths.RelativeToTop
+// OutputFiles first checks if module base outputFiles property has any output
+// files can be used to return.
+// If not, it calls OutputFileProducer.OutputFiles on the
+// encapsulated module, exits the test immediately if there is an error and
+// otherwise returns the result of calling Paths.RelativeToTop
// on the returned Paths.
func (m TestingModule) OutputFiles(t *testing.T, tag string) Paths {
+ // TODO: add non-empty-string tag case and remove OutputFileProducer part
+ if tag == "" && m.module.base().outputFiles.DefaultOutputFiles != nil {
+ return m.module.base().outputFiles.DefaultOutputFiles.RelativeToTop()
+ }
+
producer, ok := m.module.(OutputFileProducer)
if !ok {
t.Fatalf("%q must implement OutputFileProducer\n", m.module.Name())
diff --git a/android/updatable_modules.go b/android/updatable_modules.go
index 1548170..dd7dc2c 100644
--- a/android/updatable_modules.go
+++ b/android/updatable_modules.go
@@ -33,4 +33,4 @@
// * AOSP - xx9990000
// * x-mainline-prod - xx9990000
// * master - 990090000
-const DefaultUpdatableModuleVersion = "990090000"
+const DefaultUpdatableModuleVersion = "350090000"
diff --git a/android/variable.go b/android/variable.go
index 1633816..2500140 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -490,8 +490,6 @@
ReleaseDefaultModuleBuildFromSource *bool `json:",omitempty"`
- KeepVndk *bool `json:",omitempty"`
-
CheckVendorSeappViolations *bool `json:",omitempty"`
BuildFlags map[string]string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index e79afad..c19732e 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -18,7 +18,6 @@
import (
"fmt"
- "log"
"path/filepath"
"regexp"
"sort"
@@ -954,7 +953,6 @@
// the non-system APEXes because the VNDK libraries won't be included (and duped) in the
// APEX, but shared across APEXes via the VNDK APEX.
useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
- excludeVndkLibs := useVndk && a.useVndkAsStable(mctx)
if proptools.Bool(a.properties.Use_vndk_as_stable) {
if !useVndk {
mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
@@ -962,11 +960,6 @@
if a.minSdkVersionValue(mctx) != "" {
mctx.PropertyErrorf("use_vndk_as_stable", "not supported when min_sdk_version is set")
}
- mctx.VisitDirectDepsWithTag(sharedLibTag, func(dep android.Module) {
- if c, ok := dep.(*cc.Module); ok && c.IsVndk() {
- mctx.PropertyErrorf("use_vndk_as_stable", "Trying to include a VNDK library(%s) while use_vndk_as_stable is true.", dep.Name())
- }
- })
if mctx.Failed() {
return
}
@@ -988,16 +981,9 @@
if !android.IsDepInSameApex(mctx, parent, child) {
return false
}
- if excludeVndkLibs {
- if c, ok := child.(*cc.Module); ok && c.IsVndk() {
- return false
- }
- }
- //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
- if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
- log.Print("Libbinder is linked from Vendor APEX ", a.Name(), " with module ", parent.Name())
- return false
+ if useVndk && child.Name() == "libbinder" {
+ mctx.ModuleErrorf("Module %s in the vendor APEX %s should not use libbinder. Use libbinder_ndk instead.", parent.Name(), a.Name())
}
// By default, all the transitive dependencies are collected, unless filtered out
@@ -1677,12 +1663,12 @@
var _ javaModule = (*java.SdkLibraryImport)(nil)
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
-func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
+func apexFileForJavaModule(ctx android.ModuleContext, module javaModule) apexFile {
return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath(ctx).PathOrNil())
}
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
-func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
+func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
dirInApex := "javalib"
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
@@ -1693,10 +1679,12 @@
if sdkLib, ok := module.(*java.SdkLibrary); ok {
for _, install := range sdkLib.BuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
+ install.PackageFile(ctx)
}
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
+ install.PackageFile(ctx)
}
}
return af
@@ -2128,7 +2116,7 @@
}
case prebuiltTag:
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
- filesToCopy, _ := prebuilt.OutputFiles("")
+ filesToCopy := android.OutputFilesForModule(ctx, prebuilt, "")
for _, etcFile := range filesToCopy {
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
}
@@ -2193,15 +2181,6 @@
// tags used below are private (e.g. `cc.sharedDepTag`).
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
if ch, ok := child.(*cc.Module); ok {
- if ch.UseVndk() && a.useVndkAsStable(ctx) && ch.IsVndk() {
- vctx.requireNativeLibs = append(vctx.requireNativeLibs, ":vndk")
- return false
- }
-
- //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
- if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
- return false
- }
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
@@ -2274,7 +2253,7 @@
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
} else if java.IsXmlPermissionsFileDepTag(depTag) {
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
- filesToCopy, _ := prebuilt.OutputFiles("")
+ filesToCopy := android.OutputFilesForModule(ctx, prebuilt, "")
for _, etcFile := range filesToCopy {
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
}
@@ -3022,12 +3001,3 @@
func (a *apexBundle) IsTestApex() bool {
return a.testApex
}
-
-func (a *apexBundle) useVndkAsStable(ctx android.BaseModuleContext) bool {
- // VNDK cannot be linked if it is deprecated
- if ctx.Config().IsVndkDeprecated() {
- return false
- }
-
- return proptools.Bool(a.properties.Use_vndk_as_stable)
-}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index c60ee73..dfc4bb3 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3785,32 +3785,31 @@
}
func TestVndkApexDoesntSupportNativeBridgeSupported(t *testing.T) {
- testApexError(t, `module "com.android.vndk.current" .*: native_bridge_supported: .* doesn't support native bridge binary`, `
+ testApexError(t, `module "com.android.vndk.v30" .*: native_bridge_supported: .* doesn't support native bridge binary`, `
apex_vndk {
- name: "com.android.vndk.current",
- key: "com.android.vndk.current.key",
+ name: "com.android.vndk.v30",
+ key: "com.android.vndk.v30.key",
file_contexts: ":myapex-file_contexts",
native_bridge_supported: true,
}
apex_key {
- name: "com.android.vndk.current.key",
+ name: "com.android.vndk.v30.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
- cc_library {
+ vndk_prebuilt_shared {
name: "libvndk",
+ version: "30",
+ target_arch: "arm",
srcs: ["mylib.cpp"],
vendor_available: true,
product_available: true,
native_bridge_supported: true,
- host_supported: true,
vndk: {
enabled: true,
},
- system_shared_libs: [],
- stl: "none",
}
`)
}
@@ -9807,188 +9806,196 @@
}
}
-// TODO(b/193460475): Re-enable this test
-//func TestApexStrictUpdtabilityLint(t *testing.T) {
-// bpTemplate := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// java_libs: ["myjavalib"],
-// updatable: %v,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// lint: {
-// strict_updatability_linting: %v,
-// },
-// sdk_version: "current",
-// min_sdk_version: "29",
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// testCases := []struct {
-// testCaseName string
-// apexUpdatable bool
-// javaStrictUpdtabilityLint bool
-// lintFileExists bool
-// disallowedFlagExpected bool
-// }{
-// {
-// testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd",
-// apexUpdatable: true,
-// javaStrictUpdtabilityLint: true,
-// lintFileExists: false,
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "non-updatable apex respects strict_updatability of javalib",
-// apexUpdatable: false,
-// javaStrictUpdtabilityLint: false,
-// lintFileExists: true,
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "non-updatable apex respects strict updatability of javalib",
-// apexUpdatable: false,
-// javaStrictUpdtabilityLint: true,
-// lintFileExists: true,
-// disallowedFlagExpected: true,
-// },
-// {
-// testCaseName: "updatable apex sets strict updatability of javalib to true",
-// apexUpdatable: true,
-// javaStrictUpdtabilityLint: false, // will be set to true by mutator
-// lintFileExists: true,
-// disallowedFlagExpected: true,
-// },
-// }
-//
-// for _, testCase := range testCases {
-// bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint)
-// fixtures := []android.FixturePreparer{}
-// if testCase.lintFileExists {
-// fixtures = append(fixtures, fs.AddToFixture())
-// }
-//
-// result := testApex(t, bp, fixtures...)
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi")
-//
-// if disallowedFlagActual != testCase.disallowedFlagExpected {
-// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
-// }
-// }
-//}
-//
-//func TestUpdatabilityLintSkipLibcore(t *testing.T) {
-// bp := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// java_libs: ["myjavalib"],
-// updatable: true,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// sdk_version: "current",
-// min_sdk_version: "29",
-// }
-// `
-//
-// testCases := []struct {
-// testCaseName string
-// moduleDirectory string
-// disallowedFlagExpected bool
-// }{
-// {
-// testCaseName: "lintable module defined outside libcore",
-// moduleDirectory: "",
-// disallowedFlagExpected: true,
-// },
-// {
-// testCaseName: "lintable module defined in libcore root directory",
-// moduleDirectory: "libcore/",
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "lintable module defined in libcore child directory",
-// moduleDirectory: "libcore/childdir/",
-// disallowedFlagExpected: true,
-// },
-// }
-//
-// for _, testCase := range testCases {
-// lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
-// bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
-// result := testApex(t, "", lintFileCreator, bpFileCreator)
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
-// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
-//
-// if disallowedFlagActual != testCase.disallowedFlagExpected {
-// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
-// }
-// }
-//}
-//
-//// checks transtive deps of an apex coming from bootclasspath_fragment
-//func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
-// bp := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// bootclasspath_fragments: ["mybootclasspathfragment"],
-// updatable: true,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// bootclasspath_fragment {
-// name: "mybootclasspathfragment",
-// contents: ["myjavalib"],
-// apex_available: ["myapex"],
-// hidden_api: {
-// split_packages: ["*"],
-// },
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// sdk_version: "current",
-// min_sdk_version: "29",
-// compile_dex: true,
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture())
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command)
-// }
-//}
+func TestApexStrictUpdtabilityLint(t *testing.T) {
+ bpTemplate := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjavalib"],
+ updatable: %v,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ lint: {
+ strict_updatability_linting: %v,
+ %s
+ },
+ sdk_version: "current",
+ min_sdk_version: "29",
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ testCases := []struct {
+ testCaseName string
+ apexUpdatable bool
+ javaStrictUpdtabilityLint bool
+ lintFileExists bool
+ disallowedFlagExpected bool
+ }{
+ {
+ testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd",
+ apexUpdatable: true,
+ javaStrictUpdtabilityLint: true,
+ lintFileExists: false,
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "non-updatable apex respects strict_updatability of javalib",
+ apexUpdatable: false,
+ javaStrictUpdtabilityLint: false,
+ lintFileExists: true,
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "non-updatable apex respects strict updatability of javalib",
+ apexUpdatable: false,
+ javaStrictUpdtabilityLint: true,
+ lintFileExists: true,
+ disallowedFlagExpected: true,
+ },
+ {
+ testCaseName: "updatable apex sets strict updatability of javalib to true",
+ apexUpdatable: true,
+ javaStrictUpdtabilityLint: false, // will be set to true by mutator
+ lintFileExists: true,
+ disallowedFlagExpected: true,
+ },
+ }
+
+ for _, testCase := range testCases {
+ fixtures := []android.FixturePreparer{}
+ baselineProperty := ""
+ if testCase.lintFileExists {
+ fixtures = append(fixtures, fs.AddToFixture())
+ baselineProperty = "baseline_filename: \"lint-baseline.xml\""
+ }
+ bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint, baselineProperty)
+
+ result := testApex(t, bp, fixtures...)
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi")
+
+ if disallowedFlagActual != testCase.disallowedFlagExpected {
+ t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
+ }
+ }
+}
+
+func TestUpdatabilityLintSkipLibcore(t *testing.T) {
+ bp := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjavalib"],
+ updatable: true,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ sdk_version: "current",
+ min_sdk_version: "29",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+
+ testCases := []struct {
+ testCaseName string
+ moduleDirectory string
+ disallowedFlagExpected bool
+ }{
+ {
+ testCaseName: "lintable module defined outside libcore",
+ moduleDirectory: "",
+ disallowedFlagExpected: true,
+ },
+ {
+ testCaseName: "lintable module defined in libcore root directory",
+ moduleDirectory: "libcore/",
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "lintable module defined in libcore child directory",
+ moduleDirectory: "libcore/childdir/",
+ disallowedFlagExpected: true,
+ },
+ }
+
+ for _, testCase := range testCases {
+ lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
+ bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
+ result := testApex(t, "", lintFileCreator, bpFileCreator)
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
+ disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
+
+ if disallowedFlagActual != testCase.disallowedFlagExpected {
+ t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
+ }
+ }
+}
+
+// checks transtive deps of an apex coming from bootclasspath_fragment
+func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
+ bp := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ updatable: true,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ contents: ["myjavalib"],
+ apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ sdk_version: "current",
+ min_sdk_version: "29",
+ compile_dex: true,
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture())
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command)
+ }
+}
// updatable apexes should propagate updatable=true to its apps
func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index af9123e..919cb01 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -1366,4 +1366,89 @@
android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs)
}
+func TestBootclasspathFragmentProtoContainsMinSdkVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForTestWithBootclasspathFragment,
+ prepareForTestWithMyapex,
+ // Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
+ java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
+ // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
+ // is disabled.
+ android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
+
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("foo", "bar"),
+ ).RunTestWithBp(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ bootclasspath_fragments: [
+ "mybootclasspathfragment",
+ ],
+ updatable: false,
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_sdk_library {
+ name: "foo",
+ srcs: ["b.java"],
+ shared_library: false,
+ public: {enabled: true},
+ apex_available: [
+ "myapex",
+ ],
+ min_sdk_version: "33",
+ }
+
+ java_sdk_library {
+ name: "bar",
+ srcs: ["b.java"],
+ shared_library: false,
+ public: {enabled: true},
+ apex_available: [
+ "myapex",
+ ],
+ min_sdk_version: "34",
+ }
+
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ contents: [
+ "foo",
+ "bar",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+ `)
+
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ classPathProtoContent := android.ContentFromFileRuleForTests(t, result.TestContext, fragment.Output("bootclasspath.pb.textproto"))
+ // foo
+ ensureContains(t, classPathProtoContent, `jars {
+path: "/apex/myapex/javalib/foo.jar"
+classpath: BOOTCLASSPATH
+min_sdk_version: "33"
+max_sdk_version: ""
+}
+`)
+ // bar
+ ensureContains(t, classPathProtoContent, `jars {
+path: "/apex/myapex/javalib/bar.jar"
+classpath: BOOTCLASSPATH
+min_sdk_version: "34"
+max_sdk_version: ""
+}
+`)
+}
+
// TODO(b/177892522) - add test for host apex.
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 9ad5159..65c23d3 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -197,6 +197,7 @@
// If this apex contains a system server jar, then the dexpreopt artifacts should be added as required
for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
+ install.PackageFile(ctx)
}
}
@@ -587,15 +588,6 @@
return false
}
-func (p *Prebuilt) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return android.Paths{p.outputApex}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
func PrebuiltFactory() android.Module {
module := &Prebuilt{}
@@ -894,6 +886,8 @@
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
+
+ ctx.SetOutputFiles(android.Paths{p.outputApex}, "")
}
func (p *Prebuilt) ProvenanceMetaDataFile() android.OutputPath {
@@ -1009,15 +1003,6 @@
return false
}
-func (a *ApexSet) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return android.Paths{a.outputApex}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
func apexSetFactory() android.Module {
module := &ApexSet{}
@@ -1121,6 +1106,8 @@
for _, overridden := range a.prebuiltCommonProperties.Overrides {
a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx)...)
}
+
+ ctx.SetOutputFiles(android.Paths{a.outputApex}, "")
}
type systemExtContext struct {
diff --git a/bin/Android.bp b/bin/Android.bp
new file mode 100644
index 0000000..4d6d911
--- /dev/null
+++ b/bin/Android.bp
@@ -0,0 +1,26 @@
+// 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+ default_team: "trendy_team_build",
+}
+
+filegroup {
+ name: "run_tool_with_logging_script",
+ visibility: [
+ "//build/soong/tests:__subpackages__",
+ ],
+ srcs: ["run_tool_with_logging"],
+}
diff --git a/bin/run_tool_with_logging b/bin/run_tool_with_logging
new file mode 100755
index 0000000..2b2c8d8
--- /dev/null
+++ b/bin/run_tool_with_logging
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# Copyright (C) 2024 The Android Open Source Project
+#
+# 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.
+
+# Run commands in a subshell for us to handle forced terminations with a trap
+# handler.
+(
+tool_tag="$1"
+shift
+tool_binary="$1"
+shift
+
+# If the logger is not configured, run the original command and return.
+if [[ -z "${ANDROID_TOOL_LOGGER}" ]]; then
+ "${tool_binary}" "${@}"
+ exit $?
+fi
+
+# Otherwise, run the original command and call the logger when done.
+start_time=$(date +%s.%N)
+logger=${ANDROID_TOOL_LOGGER}
+
+# Install a trap to call the logger even when the process terminates abnormally.
+# The logger is run in the background and its output suppressed to avoid
+# interference with the user flow.
+trap '
+exit_code=$?;
+# Remove the trap to prevent duplicate log.
+trap - EXIT;
+"${logger}" \
+ --tool_tag="${tool_tag}" \
+ --start_timestamp="${start_time}" \
+ --end_timestamp="$(date +%s.%N)" \
+ --tool_args="$*" \
+ --exit_code="${exit_code}" \
+ ${ANDROID_TOOL_LOGGER_EXTRA_ARGS} \
+ > /dev/null 2>&1 &
+exit ${exit_code}
+' SIGINT SIGTERM SIGQUIT EXIT
+
+# Run the original command.
+"${tool_binary}" "${@}"
+)
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 2eb869e..ce00b5b 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -131,7 +131,7 @@
return nil
}
-func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string) {
bpf.properties.VendorInternal = variation == "vendor"
}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 62ba4de..143e86f 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -104,16 +104,6 @@
entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
}
entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
- if c.InVendorOrProduct() {
- if c.IsVndk() && !c.static() {
- entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
- // VNDK libraries available to vendor are not installed because
- // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
- if !c.IsVndkExt() {
- entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
- }
- }
- }
if c.InVendor() {
entries.SetBool("LOCAL_IN_VENDOR", true)
} else if c.InProduct() {
diff --git a/cc/builder.go b/cc/builder.go
index 7a3394a..8719d4f 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -485,7 +485,7 @@
coverageFiles = make(android.Paths, 0, len(srcFiles))
}
var kytheFiles android.Paths
- if flags.emitXrefs {
+ if flags.emitXrefs && ctx.Module() == ctx.PrimaryModule() {
kytheFiles = make(android.Paths, 0, len(srcFiles))
}
@@ -664,7 +664,7 @@
})
// Register post-process build statements (such as for tidy or kythe).
- if emitXref {
+ if emitXref && ctx.Module() == ctx.PrimaryModule() {
kytheFile := android.ObjPathWithExt(ctx, subdir, srcFile, "kzip")
ctx.Build(pctx, android.BuildParams{
Rule: kytheExtract,
diff --git a/cc/cc.go b/cc/cc.go
index cb82f86..df0aa6d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -49,7 +49,6 @@
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("sdk", sdkMutator).Parallel()
- ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("llndk", llndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
@@ -286,6 +285,11 @@
// Deprecated. true is the default, false is invalid.
Clang *bool `android:"arch_variant"`
+ // Aggresively trade performance for smaller binary size.
+ // This should only be used for on-device binaries that are rarely executed and not
+ // performance critical.
+ Optimize_for_size *bool `android:"arch_variant"`
+
// The API level that this module is built against. The APIs of this API level will be
// visible at build time, but use of any APIs newer than min_sdk_version will render the
// module unloadable on older devices. In the future it will be possible to weakly-link new
@@ -475,19 +479,6 @@
// IsLLNDK is set to true for the vendor variant of a cc_library module that has LLNDK stubs.
IsLLNDK bool `blueprint:"mutated"`
- // IsVNDKCore is set if a VNDK module does not set the vndk.support_system_process property.
- IsVNDKCore bool `blueprint:"mutated"`
-
- // IsVNDKSP is set if a VNDK module sets the vndk.support_system_process property.
- IsVNDKSP bool `blueprint:"mutated"`
-
- // IsVNDKPrivate is set if a VNDK module sets the vndk.private property or an LLNDK
- // module sets the llndk.private property.
- IsVNDKPrivate bool `blueprint:"mutated"`
-
- // IsVNDKProduct is set if a VNDK module sets the product_available property.
- IsVNDKProduct bool `blueprint:"mutated"`
-
// IsVendorPublicLibrary is set for the core and product variants of a library that has
// vendor_public_library stubs.
IsVendorPublicLibrary bool `blueprint:"mutated"`
@@ -514,12 +505,7 @@
useVndk() bool
isNdk(config android.Config) bool
IsLlndk() bool
- IsLlndkPublic() bool
isImplementationForLLNDKPublic() bool
- IsVndkPrivate() bool
- isVndk() bool
- isVndkSp() bool
- IsVndkExt() bool
IsVendorPublicLibrary() bool
inProduct() bool
inVendor() bool
@@ -529,7 +515,6 @@
InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
- getVndkExtendsModuleName() string
isAfdoCompile(ctx ModuleContext) bool
isOrderfileCompile() bool
isCfi() bool
@@ -546,6 +531,7 @@
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
notInPlatform() bool
+ optimizeForSize() bool
}
type SharedFlags struct {
@@ -894,7 +880,6 @@
coverage *coverage
fuzzer *fuzzer
sabi *sabi
- vndkdep *vndkdep
lto *lto
afdo *afdo
orderfile *orderfile
@@ -968,12 +953,7 @@
"InstallInVendorRamdisk": c.InstallInVendorRamdisk(),
"InstallInRecovery": c.InstallInRecovery(),
"InstallInRoot": c.InstallInRoot(),
- "IsVndk": c.IsVndk(),
- "IsVndkExt": c.IsVndkExt(),
- "IsVndkPrivate": c.IsVndkPrivate(),
- "IsVndkSp": c.IsVndkSp(),
"IsLlndk": c.IsLlndk(),
- "IsLlndkPublic": c.IsLlndkPublic(),
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
"ApexSdkVersion": c.apexSdkVersion,
"TestFor": c.TestFor(),
@@ -985,6 +965,7 @@
"WinMsgSrcs": hasWinMsg,
"YaccSrsc": hasYacc,
"OnlyCSrcs": !(hasAidl || hasLex || hasProto || hasRenderscript || hasSysprop || hasWinMsg || hasYacc),
+ "OptimizeForSize": c.OptimizeForSize(),
}
}
@@ -1070,6 +1051,10 @@
return false
}
+func (c *Module) OptimizeForSize() bool {
+ return Bool(c.Properties.Optimize_for_size)
+}
+
func (c *Module) SdkVersion() string {
return String(c.Properties.Sdk_version)
}
@@ -1278,9 +1263,6 @@
if c.sabi != nil {
c.AddProperties(c.sabi.props()...)
}
- if c.vndkdep != nil {
- c.AddProperties(c.vndkdep.props()...)
- }
if c.lto != nil {
c.AddProperties(c.lto.props()...)
}
@@ -1335,10 +1317,6 @@
return c.VendorProperties.IsLLNDK
}
-func (c *Module) IsLlndkPublic() bool {
- return c.VendorProperties.IsLLNDK && !c.VendorProperties.IsVNDKPrivate
-}
-
func (m *Module) NeedsLlndkVariants() bool {
lib := moduleLibraryInterface(m)
return lib != nil && (lib.hasLLNDKStubs() || lib.hasLLNDKHeaders())
@@ -1385,31 +1363,6 @@
!Bool(library.Properties.Llndk.Private)
}
-// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
-func (c *Module) IsVndkPrivate() bool {
- // Check if VNDK-core-private or VNDK-SP-private
- if c.IsVndk() {
- return Bool(c.vndkdep.Properties.Vndk.Private)
- }
-
- // Check if LLNDK-private
- if library, ok := c.library.(*libraryDecorator); ok && c.IsLlndk() {
- return Bool(library.Properties.Llndk.Private)
- }
-
- return false
-}
-
-// IsVndk() returns true if this module has a vndk variant.
-// Note that IsVndk() returns true for all variants of vndk-enabled libraries. Not only vendor variant,
-// but also platform and product variants of vndk-enabled libraries return true for IsVndk().
-func (c *Module) IsVndk() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndk()
- }
- return false
-}
-
func (c *Module) isAfdoCompile(ctx ModuleContext) bool {
if afdo := c.afdo; afdo != nil {
return afdo.isAfdoCompile(ctx)
@@ -1445,31 +1398,10 @@
return false
}
-func (c *Module) IsVndkSp() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndkSp()
- }
- return false
-}
-
-func (c *Module) IsVndkExt() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndkExt()
- }
- return false
-}
-
func (c *Module) SubName() string {
return c.Properties.SubName
}
-func (c *Module) getVndkExtendsModuleName() string {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.getVndkExtendsModuleName()
- }
- return ""
-}
-
func (c *Module) IsStubs() bool {
if lib := c.library; lib != nil {
return lib.buildStubs()
@@ -1613,6 +1545,10 @@
return ctx.mod.Object()
}
+func (ctx *moduleContextImpl) optimizeForSize() bool {
+ return ctx.mod.OptimizeForSize()
+}
+
func (ctx *moduleContextImpl) canUseSdk() bool {
return ctx.mod.canUseSdk()
}
@@ -1623,14 +1559,6 @@
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
- config := ctx.ctx.Config()
- if !config.IsVndkDeprecated() && ctx.useVndk() {
- vndkVer := ctx.mod.VndkVersion()
- if inList(vndkVer, config.PlatformVersionActiveCodenames()) {
- return "current"
- }
- return vndkVer
- }
return String(ctx.mod.Properties.Sdk_version)
}
return ""
@@ -1647,7 +1575,7 @@
if ctx.ctx.Device() {
config := ctx.ctx.Config()
- if config.IsVndkDeprecated() && ctx.inVendor() {
+ if ctx.inVendor() {
// If building for vendor with final API, then use the latest _stable_ API as "current".
if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
ver = config.PlatformSdkVersion().String()
@@ -1707,22 +1635,10 @@
return ctx.mod.IsLlndk()
}
-func (ctx *moduleContextImpl) IsLlndkPublic() bool {
- return ctx.mod.IsLlndkPublic()
-}
-
func (ctx *moduleContextImpl) isImplementationForLLNDKPublic() bool {
return ctx.mod.isImplementationForLLNDKPublic()
}
-func (ctx *moduleContextImpl) IsVndkPrivate() bool {
- return ctx.mod.IsVndkPrivate()
-}
-
-func (ctx *moduleContextImpl) isVndk() bool {
- return ctx.mod.IsVndk()
-}
-
func (ctx *moduleContextImpl) isAfdoCompile(mctx ModuleContext) bool {
return ctx.mod.isAfdoCompile(mctx)
}
@@ -1743,14 +1659,6 @@
return ctx.mod.isNDKStubLibrary()
}
-func (ctx *moduleContextImpl) isVndkSp() bool {
- return ctx.mod.IsVndkSp()
-}
-
-func (ctx *moduleContextImpl) IsVndkExt() bool {
- return ctx.mod.IsVndkExt()
-}
-
func (ctx *moduleContextImpl) IsVendorPublicLibrary() bool {
return ctx.mod.IsVendorPublicLibrary()
}
@@ -1770,10 +1678,6 @@
return ctx.mod.BaseModuleName()
}
-func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
- return ctx.mod.getVndkExtendsModuleName()
-}
-
func (ctx *moduleContextImpl) isForPlatform() bool {
apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
return apexInfo.IsForPlatform()
@@ -1838,7 +1742,6 @@
module.coverage = &coverage{}
module.fuzzer = &fuzzer{}
module.sabi = &sabi{}
- module.vndkdep = &vndkdep{}
module.lto = <o{}
module.afdo = &afdo{}
module.orderfile = &orderfile{}
@@ -2770,15 +2673,6 @@
{Mutator: "link", Variation: "shared"},
}, ndkLateStubDepTag, apiLateNdkLibs...)
- if vndkdep := c.vndkdep; vndkdep != nil {
- if vndkdep.isVndkExt() {
- actx.AddVariationDependencies([]blueprint.Variation{
- c.ImageVariation(),
- {Mutator: "link", Variation: "shared"},
- }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
- }
- }
-
if len(deps.AidlLibs) > 0 {
actx.AddDependency(
c,
@@ -2816,20 +2710,6 @@
return
}
- // VNDK is cc.Module supported only for now.
- if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
- // Though allowed dependency is limited by the image mutator,
- // each vendor and product module needs to check link-type
- // for VNDK.
- if ccTo, ok := to.(*Module); ok {
- if ccFrom.vndkdep != nil {
- ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
- }
- } else if _, ok := to.(LinkableInterface); !ok {
- ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
- }
- return
- }
// TODO(b/244244438) : Remove this once all variants are implemented
if ccFrom, ok := from.(*Module); ok && ccFrom.isImportedApiLibrary() {
return
@@ -2984,7 +2864,7 @@
return true
}
- if to.IsVndkSp() || to.IsLlndk() {
+ if to.IsLlndk() {
return false
}
@@ -3818,15 +3698,6 @@
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
if c.InVendorOrProduct() {
if c.IsLlndk() {
- if !c.IsLlndkPublic() {
- return "native:vndk_private"
- }
- return "native:vndk"
- }
- if c.IsVndk() && !c.IsVndkExt() {
- if c.IsVndkPrivate() {
- return "native:vndk_private"
- }
return "native:vndk"
}
if c.InProduct() {
@@ -4028,15 +3899,6 @@
return c.IsStubs() || c.Target().NativeBridge == android.NativeBridgeEnabled
}
-// Overrides android.ApexModuleBase.UniqueApexVariations
-func (c *Module) UniqueApexVariations() bool {
- // When a vendor APEX needs a VNDK lib in it (use_vndk_as_stable: false), it should be a unique
- // APEX variation. Otherwise, another vendor APEX with use_vndk_as_stable:true may use a wrong
- // variation of the VNDK lib because APEX variations are merged/grouped.
- // TODO(b/274401041) Find a way to merge APEX variations for vendor apexes.
- return c.UseVndk() && c.IsVndk()
-}
-
func (c *Module) overriddenModules() []string {
if o, ok := c.linker.(overridable); ok {
return o.overriddenModules()
@@ -4144,7 +4006,6 @@
&TidyProperties{},
&CoverageProperties{},
&SAbiProperties{},
- &VndkProperties{},
<OProperties{},
&AfdoProperties{},
&OrderfileProperties{},
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 026d291..c2bb25a 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -658,7 +658,7 @@
}{
{vendorVariant, "libvendor", "native:vendor"},
{vendorVariant, "libllndk", "native:vndk"},
- {vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"},
+ {vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vendor"},
{coreVariant, "libllndk", "native:platform"},
}
for _, test := range tests {
diff --git a/cc/cmake_main.txt b/cc/cmake_main.txt
index deb1de1..e9177d6 100644
--- a/cc/cmake_main.txt
+++ b/cc/cmake_main.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.18)
project(<<.M.Name>> CXX)
set(CMAKE_CXX_STANDARD 20)
+enable_testing()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddAidlLibrary)
diff --git a/cc/cmake_module_cc.txt b/cc/cmake_module_cc.txt
index 488e5e1..0dc45ae 100644
--- a/cc/cmake_module_cc.txt
+++ b/cc/cmake_module_cc.txt
@@ -1,6 +1,6 @@
<<$srcs := getSources .M>>
<<$includeDirs := getIncludeDirs .Ctx .M>>
-<<$cflags := (getCompilerProperties .M).Cflags>>
+<<$cflags := getCflagsProperty .Ctx .M>>
<<$deps := mapLibraries .Ctx .M (concat5
(getLinkerProperties .M).Whole_static_libs
(getLinkerProperties .M).Static_libs
@@ -8,15 +8,24 @@
(getLinkerProperties .M).Header_libs
(getExtraLibs .M)
) .Pprop.LibraryMapping>>
+<<$moduleType := getModuleType .M>>
+<<$moduleTypeCmake := "executable">>
+<<if eq $moduleType "library">>
+<<$moduleTypeCmake = "library">>
+<<end>>
# <<.M.Name>>
<<if $srcs>>
<<setList .M.Name "_SRCS" "${ANDROID_BUILD_TOP}/" (toStrings $srcs)>>
-add_<<getModuleType .M>>(<<.M.Name>> ${<<.M.Name>>_SRCS})
+add_<<$moduleTypeCmake>>(<<.M.Name>> ${<<.M.Name>>_SRCS})
<<- else>>
-add_<<getModuleType .M>>(<<.M.Name>> INTERFACE)
+add_<<$moduleTypeCmake>>(<<.M.Name>> INTERFACE)
<<- end>>
-add_<<getModuleType .M>>(android::<<.M.Name>> ALIAS <<.M.Name>>)
+<<- if eq $moduleType "library">>
+add_library(android::<<.M.Name>> ALIAS <<.M.Name>>)
+<<- else if eq $moduleType "test">>
+add_test(NAME <<.M.Name>> COMMAND <<.M.Name>>)
+<<- end>>
<<print "">>
<<- if $includeDirs>>
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index c21a46f..b4d1268 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -187,6 +187,10 @@
"getCompilerProperties": func(m *Module) BaseCompilerProperties {
return m.compiler.baseCompilerProps()
},
+ "getCflagsProperty": func(ctx android.ModuleContext, m *Module) []string {
+ cflags := m.compiler.baseCompilerProps().Cflags
+ return cflags.GetOrDefault(ctx, nil)
+ },
"getLinkerProperties": func(m *Module) BaseLinkerProperties {
return m.linker.baseLinkerProps()
},
@@ -488,17 +492,24 @@
case *libraryDecorator:
return "library"
case *testBinary:
- return "executable"
+ return "test"
+ case *benchmarkDecorator:
+ return "test"
}
- panic(fmt.Sprintf("Unexpected module type: %T", m.compiler))
+ panic(fmt.Sprintf("Unexpected module type: %T", m.linker))
}
func getExtraLibs(m *Module) []string {
switch decorator := m.linker.(type) {
case *testBinary:
if decorator.testDecorator.gtest() {
- return []string{"libgtest"}
+ return []string{
+ "libgtest",
+ "libgtest_main",
+ }
}
+ case *benchmarkDecorator:
+ return []string{"libgoogle-benchmark"}
}
return nil
}
@@ -507,7 +518,7 @@
moduleDir := ctx.OtherModuleDir(m) + string(filepath.Separator)
switch decorator := m.compiler.(type) {
case *libraryDecorator:
- return sliceWithPrefix(moduleDir, decorator.flagExporter.Properties.Export_include_dirs)
+ return sliceWithPrefix(moduleDir, decorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil))
}
return nil
}
diff --git a/cc/compiler.go b/cc/compiler.go
index 34d98c0..d8446fb 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -50,7 +50,7 @@
Exclude_srcs []string `android:"path,arch_variant"`
// list of module-specific flags that will be used for C and C++ compiles.
- Cflags []string `android:"arch_variant"`
+ Cflags proptools.Configurable[[]string] `android:"arch_variant"`
// list of module-specific flags that will be used for C++ compiles
Cppflags []string `android:"arch_variant"`
@@ -98,10 +98,10 @@
// list of generated headers to add to the include path. These are the names
// of genrule modules.
- Generated_headers []string `android:"arch_variant,variant_prepend"`
+ Generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
// pass -frtti instead of -fno-rtti
- Rtti *bool
+ Rtti *bool `android:"arch_variant"`
// C standard version to use. Can be a specific version (such as "gnu11"),
// "experimental" (which will use draft versions like C1x when available),
@@ -172,12 +172,6 @@
Target_api *string
}
- Debug, Release struct {
- // list of module-specific flags that will be used for C and C++ compiles in debug or
- // release builds
- Cflags []string `android:"arch_variant"`
- } `android:"arch_variant"`
-
Target struct {
Vendor, Product struct {
// list of source files that should only be used in vendor or
@@ -274,7 +268,7 @@
}
func (compiler *baseCompiler) appendCflags(flags []string) {
- compiler.Properties.Cflags = append(compiler.Properties.Cflags, flags...)
+ compiler.Properties.Cflags.AppendSimpleValue(flags)
}
func (compiler *baseCompiler) appendAsflags(flags []string) {
@@ -302,7 +296,7 @@
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedSources = removeListFromList(deps.GeneratedSources, compiler.Properties.Exclude_generated_sources)
- deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
+ deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers.GetOrDefault(ctx, nil)...)
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
android.ProtoDeps(ctx, &compiler.Proto)
@@ -372,7 +366,8 @@
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
- CheckBadCompilerFlags(ctx, "cflags", compiler.Properties.Cflags)
+ cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
+ CheckBadCompilerFlags(ctx, "cflags", cflags)
CheckBadCompilerFlags(ctx, "cppflags", compiler.Properties.Cppflags)
CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
@@ -385,7 +380,7 @@
esc := proptools.NinjaAndShellEscapeList
- flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Cflags)...)
+ flags.Local.CFlags = append(flags.Local.CFlags, esc(cflags)...)
flags.Local.CppFlags = append(flags.Local.CppFlags, esc(compiler.Properties.Cppflags)...)
flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Asflags)...)
@@ -478,11 +473,6 @@
ctx.ModuleErrorf("%s", err)
}
- CheckBadCompilerFlags(ctx, "release.cflags", compiler.Properties.Release.Cflags)
-
- // TODO: debug
- flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Release.Cflags)...)
-
if !ctx.DeviceConfig().BuildBrokenClangCFlags() && len(compiler.Properties.Clang_cflags) != 0 {
ctx.PropertyErrorf("clang_cflags", "property is deprecated, see Changes.md file")
} else {
@@ -693,6 +683,11 @@
flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp")
}
+ if ctx.optimizeForSize() {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-Oz")
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-enable-ml-inliner=release")
+ }
+
// Exclude directories from manual binder interface allowed list.
//TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
if android.HasAnyPrefix(ctx.ModuleDir(), allowedManualInterfacePaths) {
@@ -814,7 +809,7 @@
Header_libs []string `android:"arch_variant,variant_prepend"`
// list of clang flags required to correctly interpret the headers.
- Cflags []string `android:"arch_variant"`
+ Cflags proptools.Configurable[[]string] `android:"arch_variant"`
// list of c++ specific clang flags required to correctly interpret the headers.
// This is provided primarily to make sure cppflags defined in cc_defaults are pulled in.
diff --git a/cc/config/darwin_host.go b/cc/config/darwin_host.go
index 47c61b0..4856669 100644
--- a/cc/config/darwin_host.go
+++ b/cc/config/darwin_host.go
@@ -50,6 +50,8 @@
darwinSupportedSdkVersions = []string{
"11",
"12",
+ "13",
+ "14",
}
darwinAvailableLibraries = append(
diff --git a/cc/config/global.go b/cc/config/global.go
index 290a27d..62a4765 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -300,6 +300,9 @@
// New warnings to be fixed after clang-r475365
"-Wno-error=single-bit-bitfield-constant-conversion", // http://b/243965903
"-Wno-error=enum-constexpr-conversion", // http://b/243964282
+ // New warnings to be fixed after clang-r522817
+ "-Wno-error=invalid-offsetof",
+ "-Wno-error=thread-safety-reference-return",
// Irrelevant on Android because _we_ don't use exceptions, but causes
// lots of build noise because libcxx/libcxxabi do. This can probably
@@ -307,6 +310,9 @@
// until then because it causes warnings in the _callers_, not the
// project itself.
"-Wno-deprecated-dynamic-exception-spec",
+
+ // Allow using VLA CXX extension.
+ "-Wno-vla-cxx-extension",
}
noOverride64GlobalCflags = []string{}
@@ -391,7 +397,7 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r510928"
+ ClangDefaultVersion = "clang-r522817"
ClangDefaultShortVersion = "18"
// Directories with warnings from Android.bp files.
diff --git a/cc/genrule.go b/cc/genrule.go
index 431a01c..cabf787 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -62,6 +62,8 @@
android.InitApexModule(module)
+ android.InitDefaultableModule(module)
+
return module
}
@@ -114,5 +116,5 @@
return variants
}
-func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
diff --git a/cc/image.go b/cc/image.go
index f8c5ca5..48a9174 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -17,8 +17,6 @@
// functions to determine where a module is installed, etc.
import (
- "fmt"
- "reflect"
"strings"
"android/soong/android"
@@ -157,52 +155,6 @@
return c.ModuleBase.InstallInRecovery()
}
-func visitPropsAndCompareVendorAndProductProps(v reflect.Value) bool {
- if v.Kind() != reflect.Struct {
- return true
- }
- for i := 0; i < v.NumField(); i++ {
- prop := v.Field(i)
- if prop.Kind() == reflect.Struct && v.Type().Field(i).Name == "Target" {
- vendor_prop := prop.FieldByName("Vendor")
- product_prop := prop.FieldByName("Product")
- if vendor_prop.Kind() != reflect.Struct && product_prop.Kind() != reflect.Struct {
- // Neither Target.Vendor nor Target.Product is defined
- continue
- }
- if vendor_prop.Kind() != reflect.Struct || product_prop.Kind() != reflect.Struct ||
- !reflect.DeepEqual(vendor_prop.Interface(), product_prop.Interface()) {
- // If only one of either Target.Vendor or Target.Product is
- // defined or they have different values, it fails the build
- // since VNDK must have the same properties for both vendor
- // and product variants.
- return false
- }
- } else if !visitPropsAndCompareVendorAndProductProps(prop) {
- // Visit the substructures to find Target.Vendor and Target.Product
- return false
- }
- }
- return true
-}
-
-// In the case of VNDK, vendor and product variants must have the same properties.
-// VNDK installs only one file and shares it for both vendor and product modules on
-// runtime. We may not define different versions of a VNDK lib for each partition.
-// This function is used only for the VNDK modules that is available to both vendor
-// and product partitions.
-func (c *Module) compareVendorAndProductProps() bool {
- if !c.IsVndk() && !Bool(c.VendorProperties.Product_available) {
- panic(fmt.Errorf("This is only for product available VNDK libs. %q is not a VNDK library or not product available", c.Name()))
- }
- for _, properties := range c.GetProperties() {
- if !visitPropsAndCompareVendorAndProductProps(reflect.ValueOf(properties).Elem()) {
- return false
- }
- }
- return true
-}
-
// ImageMutatableModule provides a common image mutation interface for LinkableInterface modules.
type ImageMutatableModule interface {
android.Module
@@ -260,62 +212,9 @@
var _ ImageMutatableModule = (*Module)(nil)
func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
- m.CheckVndkProperties(mctx)
MutateImage(mctx, m)
}
-// CheckVndkProperties checks whether the VNDK-related properties are set correctly.
-// If properties are not set correctly, results in a module context property error.
-func (m *Module) CheckVndkProperties(mctx android.BaseModuleContext) {
- vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
- productSpecific := mctx.ProductSpecific()
-
- if vndkdep := m.vndkdep; vndkdep != nil {
- if vndkdep.isVndk() {
- if vendorSpecific || productSpecific {
- if !vndkdep.isVndkExt() {
- mctx.PropertyErrorf("vndk",
- "must set `extends: \"...\"` to vndk extension")
- } else if Bool(m.VendorProperties.Vendor_available) {
- mctx.PropertyErrorf("vendor_available",
- "must not set at the same time as `vndk: {extends: \"...\"}`")
- } else if Bool(m.VendorProperties.Product_available) {
- mctx.PropertyErrorf("product_available",
- "must not set at the same time as `vndk: {extends: \"...\"}`")
- }
- } else {
- if vndkdep.isVndkExt() {
- mctx.PropertyErrorf("vndk",
- "must set `vendor: true` or `product_specific: true` to set `extends: %q`",
- m.getVndkExtendsModuleName())
- }
- if !Bool(m.VendorProperties.Vendor_available) {
- mctx.PropertyErrorf("vndk",
- "vendor_available must be set to true when `vndk: {enabled: true}`")
- }
- if Bool(m.VendorProperties.Product_available) {
- // If a VNDK module creates both product and vendor variants, they
- // must have the same properties since they share a single VNDK
- // library on runtime.
- if !m.compareVendorAndProductProps() {
- mctx.ModuleErrorf("product properties must have the same values with the vendor properties for VNDK modules")
- }
- }
- }
- } else {
- if vndkdep.isVndkSp() {
- mctx.PropertyErrorf("vndk",
- "must set `enabled: true` to set `support_system_process: true`")
- }
- if vndkdep.isVndkExt() {
- mctx.PropertyErrorf("vndk",
- "must set `enabled: true` to set `extends: %q`",
- m.getVndkExtendsModuleName())
- }
- }
- }
-}
-
func (m *Module) VendorAvailable() bool {
return Bool(m.VendorProperties.Vendor_available)
}
@@ -456,7 +355,7 @@
} else {
vendorVariants = append(vendorVariants, m.SnapshotVersion(mctx))
}
- } else if m.HasNonSystemVariants() && !m.IsVndkExt() {
+ } else if m.HasNonSystemVariants() {
// This will be available to /system unless it is product_specific
// which will be handled later.
coreVariantNeeded = true
@@ -628,30 +527,29 @@
}
}
-func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
- m := module.(*Module)
+func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.RamdiskVariation {
- m.MakeAsPlatform()
- squashRamdiskSrcs(m)
+ c.MakeAsPlatform()
+ squashRamdiskSrcs(c)
} else if variant == android.VendorRamdiskVariation {
- m.MakeAsPlatform()
- squashVendorRamdiskSrcs(m)
+ c.MakeAsPlatform()
+ squashVendorRamdiskSrcs(c)
} else if variant == android.RecoveryVariation {
- m.MakeAsPlatform()
- squashRecoverySrcs(m)
+ c.MakeAsPlatform()
+ squashRecoverySrcs(c)
} else if strings.HasPrefix(variant, VendorVariation) {
- m.Properties.ImageVariation = VendorVariation
+ c.Properties.ImageVariation = VendorVariation
if strings.HasPrefix(variant, VendorVariationPrefix) {
- m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
+ c.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
}
- squashVendorSrcs(m)
+ squashVendorSrcs(c)
} else if strings.HasPrefix(variant, ProductVariation) {
- m.Properties.ImageVariation = ProductVariation
+ c.Properties.ImageVariation = ProductVariation
if strings.HasPrefix(variant, ProductVariationPrefix) {
- m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ c.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
}
- squashProductSrcs(m)
+ squashProductSrcs(c)
}
if c.NeedsVendorPublicLibraryVariants() &&
diff --git a/cc/library.go b/cc/library.go
index b9c1466..e49f50c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -149,7 +149,7 @@
Sanitized Sanitized `android:"arch_variant"`
- Cflags []string `android:"arch_variant"`
+ Cflags proptools.Configurable[[]string] `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
@@ -190,7 +190,7 @@
// be added to the include path (using -I) for this module and any module that links
// against this module. Directories listed in export_include_dirs do not need to be
// listed in local_include_dirs.
- Export_include_dirs []string `android:"arch_variant,variant_prepend"`
+ Export_include_dirs proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
// list of directories that will be added to the system include path
// using -isystem for this module and any module that links against this module.
@@ -292,7 +292,7 @@
if ctx.inProduct() && f.Properties.Target.Product.Override_export_include_dirs != nil {
return android.PathsForModuleSrc(ctx, f.Properties.Target.Product.Override_export_include_dirs)
}
- return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
+ return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs.GetOrDefault(ctx, nil))
}
func (f *flagExporter) exportedSystemIncludes(ctx ModuleContext) android.Paths {
@@ -464,9 +464,9 @@
}
if library.static() {
- flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags...)
+ flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags.GetOrDefault(ctx, nil)...)
} else if library.shared() {
- flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags...)
+ flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags.GetOrDefault(ctx, nil)...)
}
if library.shared() {
@@ -1588,14 +1588,19 @@
// override the module's export_include_dirs with llndk.override_export_include_dirs
// if it is set.
if override := library.Properties.Llndk.Override_export_include_dirs; override != nil {
- library.flagExporter.Properties.Export_include_dirs = override
+ library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
+ nil,
+ []proptools.ConfigurableCase[[]string]{
+ proptools.NewConfigurableCase[[]string](nil, &override),
+ },
+ )
}
if Bool(library.Properties.Llndk.Export_headers_as_system) {
library.flagExporter.Properties.Export_system_include_dirs = append(
library.flagExporter.Properties.Export_system_include_dirs,
- library.flagExporter.Properties.Export_include_dirs...)
- library.flagExporter.Properties.Export_include_dirs = nil
+ library.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil)...)
+ library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](nil, nil)
}
}
@@ -1603,7 +1608,12 @@
// override the module's export_include_dirs with vendor_public_library.override_export_include_dirs
// if it is set.
if override := library.Properties.Vendor_public_library.Override_export_include_dirs; override != nil {
- library.flagExporter.Properties.Export_include_dirs = override
+ library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
+ nil,
+ []proptools.ConfigurableCase[[]string]{
+ proptools.NewConfigurableCase[[]string](nil, &override),
+ },
+ )
}
}
@@ -1752,22 +1762,7 @@
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() {
- if ctx.Device() && ctx.useVndk() {
- // set subDir for VNDK extensions
- if ctx.IsVndkExt() {
- if ctx.isVndkSp() {
- library.baseInstaller.subDir = "vndk-sp"
- } else {
- library.baseInstaller.subDir = "vndk"
- }
- }
-
- // do not install vndk libs
- // vndk libs are packaged into VNDK APEX
- if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() && !ctx.inProduct() {
- return
- }
- } else if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
+ if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
// Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory.
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
@@ -2071,8 +2066,8 @@
// Check libraries in addition to cflags, since libraries may be exporting different
// include directories.
- if len(staticCompiler.StaticProperties.Static.Cflags) == 0 &&
- len(sharedCompiler.SharedProperties.Shared.Cflags) == 0 &&
+ if len(staticCompiler.StaticProperties.Static.Cflags.GetOrDefault(mctx, nil)) == 0 &&
+ len(sharedCompiler.SharedProperties.Shared.Cflags.GetOrDefault(mctx, nil)) == 0 &&
len(staticCompiler.StaticProperties.Static.Whole_static_libs) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Whole_static_libs) == 0 &&
len(staticCompiler.StaticProperties.Static.Static_libs) == 0 &&
diff --git a/cc/library_stub.go b/cc/library_stub.go
index cddb1b5..9643ec2 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -20,6 +20,8 @@
"android/soong/android"
"android/soong/multitree"
+
+ "github.com/google/blueprint/proptools"
)
var (
@@ -122,7 +124,7 @@
// The directories are not guaranteed to exist during Soong analysis.
func (d *apiLibraryDecorator) exportIncludes(ctx ModuleContext) {
exporterProps := d.flagExporter.Properties
- for _, dir := range exporterProps.Export_include_dirs {
+ for _, dir := range exporterProps.Export_include_dirs.GetOrDefault(ctx, nil) {
d.dirs = append(d.dirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
}
// system headers
@@ -178,16 +180,21 @@
in = variantMod.Src()
// Copy LLDNK properties to cc_api_library module
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs = append(
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs,
+ exportIncludeDirs := append(d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil),
variantMod.exportProperties.Export_include_dirs...)
+ d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
+ nil,
+ []proptools.ConfigurableCase[[]string]{
+ proptools.NewConfigurableCase[[]string](nil, &exportIncludeDirs),
+ },
+ )
// Export headers as system include dirs if specified. Mostly for libc
if Bool(variantMod.exportProperties.Export_headers_as_system) {
d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs = append(
d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs,
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs...)
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs = nil
+ d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil)...)
+ d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](nil, nil)
}
}
}
@@ -504,5 +511,5 @@
return variations
}
-func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
diff --git a/cc/linkable.go b/cc/linkable.go
index fecc6a2..2309fe8 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -136,9 +136,6 @@
// IsLlndk returns true for both LLNDK (public) and LLNDK-private libs.
IsLlndk() bool
- // IsLlndkPublic returns true only for LLNDK (public) libs.
- IsLlndkPublic() bool
-
// HasLlndkStubs returns true if this library has a variant that will build LLNDK stubs.
HasLlndkStubs() bool
@@ -162,12 +159,6 @@
// Bootstrap tests if this module is allowed to use non-APEX version of libraries.
Bootstrap() bool
- // IsVndkSp returns true if this is a VNDK-SP module.
- IsVndkSp() bool
-
- IsVndk() bool
- IsVndkExt() bool
- IsVndkPrivate() bool
IsVendorPublicLibrary() bool
IsVndkPrebuiltLibrary() bool
HasVendorVariant() bool
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 5b86c64..632c76d 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -15,9 +15,11 @@
package cc
import (
+ "fmt"
+ "strings"
+
"android/soong/android"
"android/soong/etc"
- "strings"
)
var (
@@ -96,7 +98,6 @@
}
var _ etc.PrebuiltEtcModule = &llndkLibrariesTxtModule{}
-var _ android.OutputFileProducer = &llndkLibrariesTxtModule{}
// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
// generated by Soong but can be referenced by other modules.
@@ -118,6 +119,18 @@
installPath := android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(installPath, filename, txt.outputFile)
+
+ ctx.SetOutputFiles(android.Paths{txt.outputFile}, "")
+}
+
+func getVndkFileName(m *Module) (string, error) {
+ if library, ok := m.linker.(*libraryDecorator); ok {
+ return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
+ }
+ if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok {
+ return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
+ }
+ return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
}
func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) {
@@ -162,11 +175,6 @@
}
// PrebuiltEtcModule interface
-func (txt *llndkLibrariesTxtModule) OutputFile() android.OutputPath {
- return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
func (txt *llndkLibrariesTxtModule) BaseDir() string {
return "etc"
}
@@ -200,8 +208,10 @@
m.VendorProperties.IsLLNDK = true
}
- if m.IsVndkPrebuiltLibrary() && !m.IsVndk() {
- m.VendorProperties.IsLLNDK = true
+ if vndkprebuilt, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
+ if !Bool(vndkprebuilt.properties.Vndk.Enabled) {
+ m.VendorProperties.IsLLNDK = true
+ }
}
}
diff --git a/cc/lto.go b/cc/lto.go
index a084db7..4444152 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -54,6 +54,9 @@
// Use -fwhole-program-vtables cflag.
Whole_program_vtables *bool
+
+ // Use --lto-O0 flag.
+ Lto_O0 *bool
}
type lto struct {
@@ -106,12 +109,8 @@
ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
var ltoLdFlags []string
- // The module did not explicitly turn on LTO. Only leverage LTO's
- // better dead code elimination and CFG simplification, but do
- // not perform costly optimizations for a balance between compile
- // time, binary size and performance.
- // Apply the same for Eng builds as well.
- if !lto.ThinLTO() || ctx.Config().Eng() {
+ // Do not perform costly LTO optimizations for Eng builds.
+ if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}
@@ -144,7 +143,7 @@
if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") {
// Register allocation MLGO flags for ARM64.
- if ctx.Arch().ArchType == android.Arm64 {
+ if ctx.Arch().ArchType == android.Arm64 && !ctx.optimizeForSize() {
ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release")
}
// Flags for training MLGO model.
diff --git a/cc/sanitize.go b/cc/sanitize.go
index e6075ad..d72d7d3 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -681,12 +681,6 @@
s.Integer_overflow = nil
}
- // Also disable CFI for VNDK variants of components
- if ctx.isVndk() && ctx.useVndk() {
- s.Cfi = nil
- s.Diag.Cfi = nil
- }
-
if ctx.inRamdisk() || ctx.inVendorRamdisk() || ctx.inRecovery() {
// HWASan ramdisk (which is built from recovery) goes over some bootloader limit.
// Keep libc instrumented so that ramdisk / vendor_ramdisk / recovery can run hwasan-instrumented code if necessary.
@@ -1798,7 +1792,6 @@
}
var _ etc.PrebuiltEtcModule = (*sanitizerLibrariesTxtModule)(nil)
-var _ android.OutputFileProducer = (*sanitizerLibrariesTxtModule)(nil)
func RegisterSanitizerLibrariesTxtType(ctx android.RegistrationContext) {
ctx.RegisterModuleType("sanitizer_libraries_txt", sanitizerLibrariesTxtFactory)
@@ -1886,6 +1879,8 @@
installPath := android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(installPath, filename, txt.outputFile)
+
+ ctx.SetOutputFiles(android.Paths{txt.outputFile}, "")
}
func (txt *sanitizerLibrariesTxtModule) AndroidMkEntries() []android.AndroidMkEntries {
@@ -1896,11 +1891,6 @@
}
// PrebuiltEtcModule interface
-func (txt *sanitizerLibrariesTxtModule) OutputFile() android.OutputPath {
- return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
func (txt *sanitizerLibrariesTxtModule) BaseDir() string {
return "etc"
}
diff --git a/cc/testing.go b/cc/testing.go
index 989be02..02f9924 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -555,7 +555,6 @@
ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
- RegisterVndkLibraryTxtTypes(ctx)
RegisterLlndkLibraryTxtType(ctx)
}),
@@ -704,7 +703,6 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
- RegisterVndkLibraryTxtTypes(ctx)
RegisterLlndkLibraryTxtType(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
diff --git a/cc/vndk.go b/cc/vndk.go
index ea55835..9d196a0 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -15,25 +15,17 @@
package cc
import (
- "errors"
- "fmt"
"strings"
"android/soong/android"
- "android/soong/etc"
-
- "github.com/google/blueprint"
- "github.com/google/blueprint/proptools"
)
const (
- llndkLibrariesTxt = "llndk.libraries.txt"
- llndkLibrariesTxtForApex = "llndk.libraries.txt.apex"
- vndkCoreLibrariesTxt = "vndkcore.libraries.txt"
- vndkSpLibrariesTxt = "vndksp.libraries.txt"
- vndkPrivateLibrariesTxt = "vndkprivate.libraries.txt"
- vndkProductLibrariesTxt = "vndkproduct.libraries.txt"
- vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt"
+ llndkLibrariesTxt = "llndk.libraries.txt"
+ vndkCoreLibrariesTxt = "vndkcore.libraries.txt"
+ vndkSpLibrariesTxt = "vndksp.libraries.txt"
+ vndkPrivateLibrariesTxt = "vndkprivate.libraries.txt"
+ vndkProductLibrariesTxt = "vndkproduct.libraries.txt"
)
func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string {
@@ -83,444 +75,9 @@
}
}
-type vndkdep struct {
- Properties VndkProperties
-}
-
-func (vndk *vndkdep) props() []interface{} {
- return []interface{}{&vndk.Properties}
-}
-
-func (vndk *vndkdep) isVndk() bool {
- return Bool(vndk.Properties.Vndk.Enabled)
-}
-
-func (vndk *vndkdep) isVndkSp() bool {
- return Bool(vndk.Properties.Vndk.Support_system_process)
-}
-
-func (vndk *vndkdep) isVndkExt() bool {
- return vndk.Properties.Vndk.Extends != nil
-}
-
-func (vndk *vndkdep) getVndkExtendsModuleName() string {
- return String(vndk.Properties.Vndk.Extends)
-}
-
-func (vndk *vndkdep) typeName() string {
- if !vndk.isVndk() {
- return "native:vendor"
- }
- if !vndk.isVndkExt() {
- if !vndk.isVndkSp() {
- return "native:vendor:vndk"
- }
- return "native:vendor:vndksp"
- }
- if !vndk.isVndkSp() {
- return "native:vendor:vndkext"
- }
- return "native:vendor:vndkspext"
-}
-
-// VNDK link type check from a module with UseVndk() == true.
-func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) {
- if to.linker == nil {
- return
- }
- if !vndk.isVndk() {
- // Non-VNDK modules those installed to /vendor, /system/vendor,
- // /product or /system/product cannot depend on VNDK-private modules
- // that include VNDK-core-private, VNDK-SP-private and LLNDK-private.
- if to.IsVndkPrivate() {
- ctx.ModuleErrorf("non-VNDK module should not link to %q which has `private: true`", to.Name())
- }
- }
- if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
- // Check only shared libraries.
- // Other (static) libraries are allowed to link.
- return
- }
-
- if to.IsLlndk() {
- // LL-NDK libraries are allowed to link
- return
- }
-
- if !to.UseVndk() {
- ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
- vndk.typeName(), to.Name())
- return
- }
- if tag == vndkExtDepTag {
- // Ensure `extends: "name"` property refers a vndk module that has vendor_available
- // and has identical vndk properties.
- if to.vndkdep == nil || !to.vndkdep.isVndk() {
- ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
- return
- }
- if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
- ctx.ModuleErrorf(
- "`extends` refers a module %q with mismatched support_system_process",
- to.Name())
- return
- }
- if to.IsVndkPrivate() {
- ctx.ModuleErrorf(
- "`extends` refers module %q which has `private: true`",
- to.Name())
- return
- }
- }
- if to.vndkdep == nil {
- return
- }
-
- // Check the dependencies of VNDK shared libraries.
- if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
- ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
- vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
- return
- }
-}
-
-func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
- // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
- if from.isVndkExt() {
- if from.isVndkSp() {
- if to.isVndk() && !to.isVndkSp() {
- return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
- }
- return nil
- }
- // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
- return nil
- }
- if from.isVndk() {
- if to.isVndkExt() {
- return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
- }
- if from.isVndkSp() {
- if !to.isVndkSp() {
- return errors.New("VNDK-SP must only depend on VNDK-SP")
- }
- return nil
- }
- if !to.isVndk() {
- return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
- }
- return nil
- }
- // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
- return nil
-}
-
-type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string)
-
-var (
- vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP })
- vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore })
- vndkPrivateLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKPrivate })
- vndkProductLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKProduct })
-)
-
-// vndkModuleLister takes a predicate that operates on a Module and returns a moduleListerFunc
-// that produces a list of module names and output file names for which the predicate returns true.
-func vndkModuleLister(predicate func(*Module) bool) moduleListerFunc {
- return func(ctx android.SingletonContext) (moduleNames, fileNames []string) {
- ctx.VisitAllModules(func(m android.Module) {
- if c, ok := m.(*Module); ok && predicate(c) && !c.IsVndkPrebuiltLibrary() {
- filename, err := getVndkFileName(c)
- if err != nil {
- ctx.ModuleErrorf(m, "%s", err)
- }
- moduleNames = append(moduleNames, ctx.ModuleName(m))
- fileNames = append(fileNames, filename)
- }
- })
- moduleNames = android.SortedUniqueStrings(moduleNames)
- fileNames = android.SortedUniqueStrings(fileNames)
- return
- }
-}
-
-// vndkModuleListRemover takes a moduleListerFunc and a prefix and returns a moduleListerFunc
-// that returns the same lists as the input moduleListerFunc, but with modules with the
-// given prefix removed.
-func vndkModuleListRemover(lister moduleListerFunc, prefix string) moduleListerFunc {
- return func(ctx android.SingletonContext) (moduleNames, fileNames []string) {
- moduleNames, fileNames = lister(ctx)
- filter := func(in []string) []string {
- out := make([]string, 0, len(in))
- for _, lib := range in {
- if strings.HasPrefix(lib, prefix) {
- continue
- }
- out = append(out, lib)
- }
- return out
- }
- return filter(moduleNames), filter(fileNames)
- }
-}
-
-func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
- if m.InProduct() {
- // We may skip the steps for the product variants because they
- // are already covered by the vendor variants.
- return
- }
-
- name := m.BaseModuleName()
-
- if lib := m.library; lib != nil && lib.hasStubsVariants() && name != "libz" {
- // b/155456180 libz is the ONLY exception here. We don't want to make
- // libz an LLNDK library because we in general can't guarantee that
- // libz will behave consistently especially about the compression.
- // i.e. the compressed output might be different across releases.
- // As the library is an external one, it's risky to keep the compatibility
- // promise if it becomes an LLNDK.
- mctx.PropertyErrorf("vndk.enabled", "This library provides stubs. Shouldn't be VNDK. Consider making it as LLNDK")
- }
-
- if m.vndkdep.isVndkSp() {
- m.VendorProperties.IsVNDKSP = true
- } else {
- m.VendorProperties.IsVNDKCore = true
- }
- if m.IsVndkPrivate() {
- m.VendorProperties.IsVNDKPrivate = true
- }
- if Bool(m.VendorProperties.Product_available) {
- m.VendorProperties.IsVNDKProduct = true
- }
-}
-
-// Check for modules that mustn't be VNDK
-func shouldSkipVndkMutator(ctx android.ConfigAndErrorContext, m *Module) bool {
- if !m.Enabled(ctx) {
- return true
- }
- if !m.Device() {
- // Skip non-device modules
- return true
- }
- if m.Target().NativeBridge == android.NativeBridgeEnabled {
- // Skip native_bridge modules
- return true
- }
- return false
-}
-
-func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
- if shouldSkipVndkMutator(mctx, m) {
- return false
- }
-
- // TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared
- // When b/142675459 is landed, remove following check
- if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
- // prebuilt vndk modules should match with device
- if !p.MatchesWithDevice(mctx.DeviceConfig()) {
- return false
- }
- }
-
- if lib, ok := m.linker.(libraryInterface); ok {
- // VNDK APEX doesn't need stub variants
- if lib.buildStubs() {
- return false
- }
- return lib.shared() && m.InVendor() && m.IsVndk() && !m.IsVndkExt()
- }
- return false
-}
-
-// gather list of vndk-core, vndk-sp, and ll-ndk libs
-func VndkMutator(mctx android.BottomUpMutatorContext) {
- m, ok := mctx.Module().(*Module)
- if !ok {
- return
- }
-
- if shouldSkipVndkMutator(mctx, m) {
- return
- }
-
- lib, isLib := m.linker.(*libraryDecorator)
- prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
-
- if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
- m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
- }
- if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
- m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
- }
-
- if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) {
- if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
- processVndkLibrary(mctx, m)
- return
- }
- }
-}
-
-func init() {
- RegisterVndkLibraryTxtTypes(android.InitRegistrationContext)
-}
-
-func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
- ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
- ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
- ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
- ctx.RegisterParallelSingletonModuleType("vndkproduct_libraries_txt", vndkProductLibrariesTxtFactory)
-}
-
-type vndkLibrariesTxt struct {
- android.SingletonModuleBase
-
- lister moduleListerFunc
- makeVarName string
- filterOutFromMakeVar string
-
- properties VndkLibrariesTxtProperties
-
- outputFile android.OutputPath
- moduleNames []string
- fileNames []string
-}
-
-type VndkLibrariesTxtProperties struct {
- Insert_vndk_version *bool
- Stem *string
-}
-
-var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
-var _ android.OutputFileProducer = &vndkLibrariesTxt{}
-
-// vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries
-// generated by Soong but can be referenced by other modules.
-// For example, apex_vndk can depend on these files as prebuilt.
-func vndkSPLibrariesTxtFactory() android.SingletonModule {
- return newVndkLibrariesTxt(vndkSPLibraries, "VNDK_SAMEPROCESS_LIBRARIES")
-}
-
-// vndkcore_libraries_txt is a singleton module whose content is a list of VNDK core libraries
-// generated by Soong but can be referenced by other modules.
-// For example, apex_vndk can depend on these files as prebuilt.
-func vndkCoreLibrariesTxtFactory() android.SingletonModule {
- return newVndkLibrariesTxt(vndkCoreLibraries, "VNDK_CORE_LIBRARIES")
-}
-
-// vndkprivate_libraries_txt is a singleton module whose content is a list of VNDK private libraries
-// generated by Soong but can be referenced by other modules.
-// For example, apex_vndk can depend on these files as prebuilt.
-func vndkPrivateLibrariesTxtFactory() android.SingletonModule {
- return newVndkLibrariesTxt(vndkPrivateLibraries, "VNDK_PRIVATE_LIBRARIES")
-}
-
-// vndkproduct_libraries_txt is a singleton module whose content is a list of VNDK product libraries
-// generated by Soong but can be referenced by other modules.
-// For example, apex_vndk can depend on these files as prebuilt.
-func vndkProductLibrariesTxtFactory() android.SingletonModule {
- return newVndkLibrariesTxt(vndkProductLibraries, "VNDK_PRODUCT_LIBRARIES")
-}
-
-func newVndkLibrariesWithMakeVarFilter(lister moduleListerFunc, makeVarName string, filter string) android.SingletonModule {
- m := &vndkLibrariesTxt{
- lister: lister,
- makeVarName: makeVarName,
- filterOutFromMakeVar: filter,
- }
- m.AddProperties(&m.properties)
- android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
- return m
-}
-
-func newVndkLibrariesTxt(lister moduleListerFunc, makeVarName string) android.SingletonModule {
- return newVndkLibrariesWithMakeVarFilter(lister, makeVarName, "")
-}
-
func insertVndkVersion(filename string, vndkVersion string) string {
if index := strings.LastIndex(filename, "."); index != -1 {
return filename[:index] + "." + vndkVersion + filename[index:]
}
return filename
}
-
-func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- filename := proptools.StringDefault(txt.properties.Stem, txt.Name())
-
- txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
-
- installPath := android.PathForModuleInstall(ctx, "etc")
- ctx.InstallFile(installPath, filename, txt.outputFile)
-}
-
-func (txt *vndkLibrariesTxt) GenerateSingletonBuildActions(ctx android.SingletonContext) {
- txt.moduleNames, txt.fileNames = txt.lister(ctx)
- android.WriteFileRule(ctx, txt.outputFile, strings.Join(txt.fileNames, "\n"))
-}
-
-func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
- return []android.AndroidMkEntries{android.AndroidMkEntries{
- Class: "ETC",
- OutputFile: android.OptionalPathForPath(txt.outputFile),
- ExtraEntries: []android.AndroidMkExtraEntriesFunc{
- func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
- entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
- },
- },
- }}
-}
-
-func (txt *vndkLibrariesTxt) MakeVars(ctx android.MakeVarsContext) {
- if txt.makeVarName == "" {
- return
- }
-
- filter := func(modules []string, prefix string) []string {
- if prefix == "" {
- return modules
- }
- var result []string
- for _, module := range modules {
- if strings.HasPrefix(module, prefix) {
- continue
- } else {
- result = append(result, module)
- }
- }
- return result
- }
- ctx.Strict(txt.makeVarName, strings.Join(filter(txt.moduleNames, txt.filterOutFromMakeVar), " "))
-}
-
-// PrebuiltEtcModule interface
-func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
- return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
-func (txt *vndkLibrariesTxt) BaseDir() string {
- return "etc"
-}
-
-// PrebuiltEtcModule interface
-func (txt *vndkLibrariesTxt) SubDir() string {
- return ""
-}
-
-func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
- return android.Paths{txt.outputFile}, nil
-}
-
-func getVndkFileName(m *Module) (string, error) {
- if library, ok := m.linker.(*libraryDecorator); ok {
- return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
- }
- if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok {
- return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
- }
- return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
-}
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 4d2412f..e7dff40 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -49,6 +49,8 @@
// },
// }
type vndkPrebuiltProperties struct {
+ VndkProperties
+
// VNDK snapshot version.
Version *string
@@ -268,3 +270,14 @@
func init() {
android.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
}
+
+func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
+ if !m.Enabled(mctx) {
+ return true
+ }
+
+ if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
+ return p.MatchesWithDevice(mctx.DeviceConfig()) && Bool(p.properties.Vndk.Enabled)
+ }
+ return false
+}
diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go
index f74784b..5d183ee 100644
--- a/cmd/release_config/build_flag/main.go
+++ b/cmd/release_config/build_flag/main.go
@@ -163,6 +163,7 @@
for _, fa := range configs.FlagArtifacts {
args = append(args, *fa.FlagDeclaration.Name)
}
+ slices.Sort(args)
}
var maxVariableNameLen, maxReleaseNameLen int
@@ -232,7 +233,7 @@
} else {
outputOneLine(arg, config.Name, "REDACTED", "%s")
}
- if isTrace {
+ if err == nil && isTrace {
for _, trace := range config.FlagArtifacts[arg].Traces {
fmt.Printf(" => \"%s\" in %s\n", rc_lib.MarshalValue(trace.Value), *trace.Source)
}
@@ -244,6 +245,8 @@
func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, args []string) error {
var valueDir string
+ var redacted bool
+ var value string
if len(commonFlags.targetReleases) > 1 {
return fmt.Errorf("set command only allows one --release argument. Got: %s", strings.Join(commonFlags.targetReleases, " "))
}
@@ -251,13 +254,20 @@
setFlags := flag.NewFlagSet("set", flag.ExitOnError)
setFlags.StringVar(&valueDir, "dir", "", "Directory in which to place the value")
+ setFlags.BoolVar(&redacted, "redacted", false, "Whether the flag should be redacted")
setFlags.Parse(args)
setArgs := setFlags.Args()
- if len(setArgs) != 2 {
+ if redacted {
+ if len(setArgs) != 1 {
+ return fmt.Errorf("set command expected '--redacted=true flag', got: --redacted=true %s", strings.Join(setArgs, " "))
+ }
+ } else if len(setArgs) != 2 {
return fmt.Errorf("set command expected flag and value, got: %s", strings.Join(setArgs, " "))
}
name := setArgs[0]
- value := setArgs[1]
+ if !redacted {
+ value = setArgs[1]
+ }
release, err := configs.GetReleaseConfig(targetRelease)
targetRelease = release.Name
if err != nil {
@@ -278,9 +288,30 @@
valueDir = mapDir
}
+ var updatedFiles []string
+ rcPath := filepath.Join(valueDir, "release_configs", fmt.Sprintf("%s.textproto", targetRelease))
+ // Create the release config declaration only if necessary.
+ if _, err = os.Stat(rcPath); err != nil {
+ if err = os.MkdirAll(filepath.Dir(rcPath), 0775); err != nil {
+ return err
+ }
+ rcValue := &rc_proto.ReleaseConfig{
+ Name: proto.String(targetRelease),
+ }
+ err = rc_lib.WriteMessage(rcPath, rcValue)
+ if err != nil {
+ return err
+ }
+ updatedFiles = append(updatedFiles, rcPath)
+ }
+
flagValue := &rc_proto.FlagValue{
- Name: proto.String(name),
- Value: rc_lib.UnmarshalValue(value),
+ Name: proto.String(name),
+ }
+ if redacted {
+ flagValue.Redacted = proto.Bool(true)
+ } else {
+ flagValue.Value = rc_lib.UnmarshalValue(value)
}
flagPath := filepath.Join(valueDir, "flag_values", targetRelease, fmt.Sprintf("%s.textproto", name))
err = rc_lib.WriteMessage(flagPath, flagValue)
@@ -293,11 +324,12 @@
if err != nil {
return err
}
- err = GetCommand(configs, commonFlags, cmd, args[0:1])
+ err = GetCommand(configs, commonFlags, cmd, []string{name})
if err != nil {
return err
}
- fmt.Printf("Updated: %s\n", flagPath)
+ updatedFiles = append(updatedFiles, flagPath)
+ fmt.Printf("Added/Updated: %s\n", strings.Join(updatedFiles, " "))
return nil
}
diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go
index bd4ab49..d06b2b7 100644
--- a/cmd/release_config/release_config/main.go
+++ b/cmd/release_config/release_config/main.go
@@ -88,7 +88,7 @@
return
}
// Write the makefile where release_config.mk is going to look for it.
- err = configs.WriteMakefile(makefilePath, targetRelease)
+ err = config.WriteMakefile(makefilePath, targetRelease, configs)
if err != nil {
panic(err)
}
@@ -97,7 +97,7 @@
for _, c := range configs.GetSortedReleaseConfigs() {
if c.Name != targetRelease {
makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name))
- err = configs.WriteMakefile(makefilePath, c.Name)
+ err = config.WriteMakefile(makefilePath, c.Name, configs)
if err != nil {
panic(err)
}
diff --git a/cmd/release_config/release_config_lib/Android.bp b/cmd/release_config/release_config_lib/Android.bp
index 0c67e11..17251bd 100644
--- a/cmd/release_config/release_config_lib/Android.bp
+++ b/cmd/release_config/release_config_lib/Android.bp
@@ -24,6 +24,7 @@
"golang-protobuf-reflect-protoreflect",
"golang-protobuf-runtime-protoimpl",
"soong-cmd-release_config-proto",
+ "blueprint-pathtools",
],
srcs: [
"flag_artifact.go",
diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go
index 6d36595..cfac7d7 100644
--- a/cmd/release_config/release_config_lib/flag_artifact.go
+++ b/cmd/release_config/release_config_lib/flag_artifact.go
@@ -67,7 +67,7 @@
if artifactsPath != "" {
fas := &rc_proto.FlagArtifacts{}
LoadMessage(artifactsPath, fas)
- for _, fa_pb := range fas.FlagArtifacts {
+ for _, fa_pb := range fas.Flags {
fa := &FlagArtifact{}
fa.FlagDeclaration = fa_pb.GetFlagDeclaration()
if val := fa_pb.GetValue(); val != nil {
@@ -82,6 +82,15 @@
return &ret
}
+func (fas *FlagArtifacts) SortedFlagNames() []string {
+ var names []string
+ for k, _ := range *fas {
+ names = append(names, k)
+ }
+ slices.Sort(names)
+ return names
+}
+
func (fa *FlagArtifact) GenerateFlagDeclarationArtifact() *rc_proto.FlagDeclarationArtifact {
ret := &rc_proto.FlagDeclarationArtifact{
Name: fa.FlagDeclaration.Name,
@@ -135,9 +144,11 @@
value := &rc_proto.Value{}
proto.Merge(value, src.Value)
return &FlagArtifact{
- FlagDeclaration: src.FlagDeclaration,
- Traces: src.Traces,
- Value: value,
+ FlagDeclaration: src.FlagDeclaration,
+ Traces: src.Traces,
+ Value: value,
+ DeclarationIndex: src.DeclarationIndex,
+ Redacted: src.Redacted,
}
}
diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go
index 02b693c..6911e54 100644
--- a/cmd/release_config/release_config_lib/release_config.go
+++ b/cmd/release_config/release_config_lib/release_config.go
@@ -17,6 +17,7 @@
import (
"cmp"
"fmt"
+ "os"
"path/filepath"
"regexp"
"slices"
@@ -169,8 +170,12 @@
if err != nil {
return err
}
- iConfig.GenerateReleaseConfig(configs)
- if err := config.InheritConfig(iConfig); err != nil {
+ err = iConfig.GenerateReleaseConfig(configs)
+ if err != nil {
+ return err
+ }
+ err = config.InheritConfig(iConfig)
+ if err != nil {
return err
}
}
@@ -277,13 +282,13 @@
if _, ok := config.PartitionBuildFlags[container]; !ok {
config.PartitionBuildFlags[container] = &rc_proto.FlagArtifacts{}
}
- config.PartitionBuildFlags[container].FlagArtifacts = append(config.PartitionBuildFlags[container].FlagArtifacts, artifact)
+ config.PartitionBuildFlags[container].Flags = append(config.PartitionBuildFlags[container].Flags, artifact)
}
}
config.ReleaseConfigArtifact = &rc_proto.ReleaseConfigArtifact{
Name: proto.String(config.Name),
OtherNames: config.OtherNames,
- FlagArtifacts: func() []*rc_proto.FlagArtifact {
+ Flags: func() []*rc_proto.FlagArtifact {
ret := []*rc_proto.FlagArtifact{}
flagNames := []string{}
for k := range config.FlagArtifacts {
@@ -310,10 +315,78 @@
return nil
}
+// Write the makefile for this targetRelease.
+func (config *ReleaseConfig) WriteMakefile(outFile, targetRelease string, configs *ReleaseConfigs) error {
+ makeVars := make(map[string]string)
+
+ myFlagArtifacts := config.FlagArtifacts.Clone()
+ // Sort the flags by name first.
+ names := myFlagArtifacts.SortedFlagNames()
+ partitions := make(map[string][]string)
+
+ vNames := []string{}
+ addVar := func(name, suffix, value string) {
+ fullName := fmt.Sprintf("_ALL_RELEASE_FLAGS.%s.%s", name, suffix)
+ vNames = append(vNames, fullName)
+ makeVars[fullName] = value
+ }
+
+ for _, name := range names {
+ flag := myFlagArtifacts[name]
+ decl := flag.FlagDeclaration
+
+ for _, container := range decl.Containers {
+ partitions[container] = append(partitions[container], name)
+ }
+ value := MarshalValue(flag.Value)
+ makeVars[name] = value
+ addVar(name, "TYPE", ValueType(flag.Value))
+ addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
+ addVar(name, "DEFAULT", MarshalValue(decl.Value))
+ addVar(name, "VALUE", value)
+ addVar(name, "DECLARED_IN", *flag.Traces[0].Source)
+ addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source)
+ addVar(name, "NAMESPACE", *decl.Namespace)
+ }
+ pNames := []string{}
+ for k := range partitions {
+ pNames = append(pNames, k)
+ }
+ slices.Sort(pNames)
+
+ // Now sort the make variables, and output them.
+ slices.Sort(vNames)
+
+ // Write the flags as:
+ // _ALL_RELELASE_FLAGS
+ // _ALL_RELEASE_FLAGS.PARTITIONS.*
+ // all _ALL_RELEASE_FLAGS.*, sorted by name
+ // Final flag values, sorted by name.
+ data := fmt.Sprintf("# TARGET_RELEASE=%s\n", config.Name)
+ if targetRelease != config.Name {
+ data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease)
+ }
+ // As it stands this list is not per-product, but conceptually it is, and will be.
+ data += fmt.Sprintf("ALL_RELEASE_CONFIGS_FOR_PRODUCT :=$= %s\n", strings.Join(configs.GetAllReleaseNames(), " "))
+ data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " "))
+ data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " "))
+ for _, pName := range pNames {
+ data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " "))
+ }
+ for _, vName := range vNames {
+ data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName])
+ }
+ data += "\n\n# Values for all build flags\n"
+ for _, name := range names {
+ data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name])
+ }
+ return os.WriteFile(outFile, []byte(data), 0644)
+}
+
func (config *ReleaseConfig) WritePartitionBuildFlags(outDir string) error {
var err error
for partition, flags := range config.PartitionBuildFlags {
- slices.SortFunc(flags.FlagArtifacts, func(a, b *rc_proto.FlagArtifact) int {
+ slices.SortFunc(flags.Flags, func(a, b *rc_proto.FlagArtifact) int {
return cmp.Compare(*a.FlagDeclaration.Name, *b.FlagDeclaration.Name)
})
// The json file name must not be modified as this is read from
diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go
index 052cde8..f2e1388 100644
--- a/cmd/release_config/release_config_lib/release_configs.go
+++ b/cmd/release_config/release_config_lib/release_configs.go
@@ -395,94 +395,10 @@
allReleaseNames = append(allReleaseNames, v.Name)
allReleaseNames = append(allReleaseNames, v.OtherNames...)
}
- slices.SortFunc(allReleaseNames, func(a, b string) int {
- return cmp.Compare(a, b)
- })
+ slices.Sort(allReleaseNames)
return allReleaseNames
}
-// Write the makefile for this targetRelease.
-func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) error {
- makeVars := make(map[string]string)
- config, err := configs.GetReleaseConfig(targetRelease)
- if err != nil {
- return err
- }
-
- myFlagArtifacts := config.FlagArtifacts.Clone()
- // Sort the flags by name first.
- names := []string{}
- for k, _ := range myFlagArtifacts {
- names = append(names, k)
- }
- slices.SortFunc(names, func(a, b string) int {
- return cmp.Compare(a, b)
- })
- partitions := make(map[string][]string)
-
- vNames := []string{}
- addVar := func(name, suffix, value string) {
- fullName := fmt.Sprintf("_ALL_RELEASE_FLAGS.%s.%s", name, suffix)
- vNames = append(vNames, fullName)
- makeVars[fullName] = value
- }
-
- for _, name := range names {
- flag := myFlagArtifacts[name]
- decl := flag.FlagDeclaration
-
- for _, container := range decl.Containers {
- partitions[container] = append(partitions[container], name)
- }
- value := MarshalValue(flag.Value)
- makeVars[name] = value
- addVar(name, "TYPE", ValueType(flag.Value))
- addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
- addVar(name, "DEFAULT", MarshalValue(decl.Value))
- addVar(name, "VALUE", value)
- addVar(name, "DECLARED_IN", *flag.Traces[0].Source)
- addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source)
- addVar(name, "NAMESPACE", *decl.Namespace)
- }
- pNames := []string{}
- for k := range partitions {
- pNames = append(pNames, k)
- }
- slices.SortFunc(pNames, func(a, b string) int {
- return cmp.Compare(a, b)
- })
-
- // Now sort the make variables, and output them.
- slices.SortFunc(vNames, func(a, b string) int {
- return cmp.Compare(a, b)
- })
-
- // Write the flags as:
- // _ALL_RELELASE_FLAGS
- // _ALL_RELEASE_FLAGS.PARTITIONS.*
- // all _ALL_RELEASE_FLAGS.*, sorted by name
- // Final flag values, sorted by name.
- data := fmt.Sprintf("# TARGET_RELEASE=%s\n", config.Name)
- if targetRelease != config.Name {
- data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease)
- }
- // As it stands this list is not per-product, but conceptually it is, and will be.
- data += fmt.Sprintf("ALL_RELEASE_CONFIGS_FOR_PRODUCT :=$= %s\n", strings.Join(configs.GetAllReleaseNames(), " "))
- data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " "))
- data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " "))
- for _, pName := range pNames {
- data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " "))
- }
- for _, vName := range vNames {
- data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName])
- }
- data += "\n\n# Values for all build flags\n"
- for _, name := range names {
- data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name])
- }
- return os.WriteFile(outFile, []byte(data), 0644)
-}
-
func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) error {
otherNames := make(map[string][]string)
for aliasName, aliasTarget := range configs.Aliases {
diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go
index b8824d1..9919c70 100644
--- a/cmd/release_config/release_config_lib/util.go
+++ b/cmd/release_config/release_config_lib/util.go
@@ -25,6 +25,7 @@
"slices"
"strings"
+ "github.com/google/blueprint/pathtools"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)
@@ -83,6 +84,11 @@
// error: any error encountered.
func WriteFormattedMessage(path, format string, message proto.Message) (err error) {
var data []byte
+ if _, err := os.Stat(filepath.Dir(path)); err != nil {
+ if err = os.MkdirAll(filepath.Dir(path), 0775); err != nil {
+ return err
+ }
+ }
switch format {
case "json":
data, err = json.MarshalIndent(message, "", " ")
@@ -96,7 +102,7 @@
if err != nil {
return err
}
- return os.WriteFile(path, data, 0644)
+ return pathtools.WriteFileIfChanged(path, data, 0644)
}
// Read a message from a file.
diff --git a/cmd/release_config/release_config_proto/build_flags_common.pb.go b/cmd/release_config/release_config_proto/build_flags_common.pb.go
index 1e927db..82fbcfa 100644
--- a/cmd/release_config/release_config_proto/build_flags_common.pb.go
+++ b/cmd/release_config/release_config_proto/build_flags_common.pb.go
@@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.30.0
+// protoc-gen-go v1.33.0
// protoc v3.21.12
// source: build_flags_common.proto
diff --git a/cmd/release_config/release_config_proto/build_flags_declarations.pb.go b/cmd/release_config/release_config_proto/build_flags_declarations.pb.go
index c0573ed..73a7e87 100644
--- a/cmd/release_config/release_config_proto/build_flags_declarations.pb.go
+++ b/cmd/release_config/release_config_proto/build_flags_declarations.pb.go
@@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.30.0
+// protoc-gen-go v1.33.0
// protoc v3.21.12
// source: build_flags_declarations.proto
diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go
index 309ec34..b246eb6 100644
--- a/cmd/release_config/release_config_proto/build_flags_out.pb.go
+++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go
@@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.30.0
+// protoc-gen-go v1.33.0
// protoc v3.21.12
// source: build_flags_out.proto
@@ -163,7 +163,7 @@
unknownFields protoimpl.UnknownFields
// The artifacts
- FlagArtifacts []*FlagArtifact `protobuf:"bytes,1,rep,name=flag_artifacts,json=flagArtifacts" json:"flag_artifacts,omitempty"`
+ Flags []*FlagArtifact `protobuf:"bytes,1,rep,name=flags" json:"flags,omitempty"`
}
func (x *FlagArtifacts) Reset() {
@@ -198,9 +198,9 @@
return file_build_flags_out_proto_rawDescGZIP(), []int{2}
}
-func (x *FlagArtifacts) GetFlagArtifacts() []*FlagArtifact {
+func (x *FlagArtifacts) GetFlags() []*FlagArtifact {
if x != nil {
- return x.FlagArtifacts
+ return x.Flags
}
return nil
}
@@ -217,7 +217,7 @@
OtherNames []string `protobuf:"bytes,2,rep,name=other_names,json=otherNames" json:"other_names,omitempty"`
// The complete set of build flags in this release config, after all
// inheritance and other processing is complete.
- FlagArtifacts []*FlagArtifact `protobuf:"bytes,3,rep,name=flag_artifacts,json=flagArtifacts" json:"flag_artifacts,omitempty"`
+ Flags []*FlagArtifact `protobuf:"bytes,3,rep,name=flags" json:"flags,omitempty"`
// The (complete) list of aconfig_value_sets Soong modules to use.
AconfigValueSets []string `protobuf:"bytes,4,rep,name=aconfig_value_sets,json=aconfigValueSets" json:"aconfig_value_sets,omitempty"`
// The names of the release_config_artifacts from which we inherited.
@@ -277,9 +277,9 @@
return nil
}
-func (x *ReleaseConfigArtifact) GetFlagArtifacts() []*FlagArtifact {
+func (x *ReleaseConfigArtifact) GetFlags() []*FlagArtifact {
if x != nil {
- return x.FlagArtifacts
+ return x.Flags
}
return nil
}
@@ -406,67 +406,67 @@
0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69,
0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x70, 0x6f, 0x69, 0x6e,
- 0x74, 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x64, 0x0a, 0x0e, 0x66, 0x6c, 0x61,
- 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x52, 0x0a, 0x0e, 0x66,
- 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20,
- 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65,
- 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74,
- 0x52, 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x22,
- 0xb1, 0x02, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
- 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e,
- 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
- 0x1f, 0x0a, 0x0b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02,
- 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73,
- 0x12, 0x52, 0x0a, 0x0e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63,
- 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f,
- 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74,
- 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66,
- 0x61, 0x63, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f,
- 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09,
- 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65,
- 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05,
- 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20,
- 0x0a, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20,
- 0x03, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73,
- 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x67, 0x65, 0x73,
- 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x53, 0x74, 0x61,
- 0x67, 0x65, 0x73, 0x22, 0xe8, 0x03, 0x0a, 0x18, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f,
- 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74,
- 0x12, 0x5c, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
- 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f,
- 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f,
- 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52,
- 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x69,
- 0x0a, 0x15, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f,
- 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e,
- 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f,
- 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c,
- 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69,
- 0x66, 0x61, 0x63, 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61,
- 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x12, 0x87, 0x01, 0x0a, 0x17, 0x72, 0x65,
- 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70,
- 0x73, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x61, 0x6e,
+ 0x74, 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x63, 0x0a, 0x0e, 0x66, 0x6c, 0x61,
+ 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x66,
+ 0x6c, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64,
+ 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e,
+ 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61,
+ 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x52, 0x0e,
+ 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x22, 0xb0,
+ 0x02, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69,
+ 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
+ 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f,
+ 0x0a, 0x0b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20,
+ 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12,
+ 0x41, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b,
+ 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
+ 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c,
+ 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x05, 0x66, 0x6c, 0x61,
+ 0x67, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10,
+ 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73,
+ 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03,
+ 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20, 0x0a, 0x0b,
+ 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28,
+ 0x09, 0x52, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x21,
+ 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x67, 0x65, 0x73, 0x18, 0x07,
+ 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x67, 0x65,
+ 0x73, 0x52, 0x0e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74,
+ 0x73, 0x22, 0xe8, 0x03, 0x0a, 0x18, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f,
+ 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x5c,
+ 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64,
+ 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f,
+ 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x72,
+ 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x69, 0x0a, 0x15,
+ 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f,
+ 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e,
0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61,
- 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66,
- 0x61, 0x63, 0x74, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x72,
- 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73,
- 0x4d, 0x61, 0x70, 0x1a, 0x79, 0x0a, 0x19, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f,
- 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79,
- 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
- 0x65, 0x79, 0x12, 0x46, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65,
- 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f,
- 0x6d, 0x61, 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x33,
- 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f,
- 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72,
- 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72,
- 0x6f, 0x74, 0x6f,
+ 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61,
+ 0x63, 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
+ 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x12, 0x87, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65,
+ 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x73, 0x5f,
+ 0x6d, 0x61, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x61, 0x6e, 0x64, 0x72,
+ 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
+ 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
+ 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63,
+ 0x74, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d,
+ 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x72, 0x65, 0x6c,
+ 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61,
+ 0x70, 0x1a, 0x79, 0x0a, 0x19, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66,
+ 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
+ 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
+ 0x12, 0x46, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
+ 0x30, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
+ 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72,
+ 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61,
+ 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x33, 0x5a, 0x31,
+ 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65,
+ 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c,
+ 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f,
}
var (
@@ -498,8 +498,8 @@
7, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration
6, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value
0, // 3: android.release_config_proto.flag_artifact.traces:type_name -> android.release_config_proto.tracepoint
- 1, // 4: android.release_config_proto.flag_artifacts.flag_artifacts:type_name -> android.release_config_proto.flag_artifact
- 1, // 5: android.release_config_proto.release_config_artifact.flag_artifacts:type_name -> android.release_config_proto.flag_artifact
+ 1, // 4: android.release_config_proto.flag_artifacts.flags:type_name -> android.release_config_proto.flag_artifact
+ 1, // 5: android.release_config_proto.release_config_artifact.flags:type_name -> android.release_config_proto.flag_artifact
3, // 6: android.release_config_proto.release_configs_artifact.release_config:type_name -> android.release_config_proto.release_config_artifact
3, // 7: android.release_config_proto.release_configs_artifact.other_release_configs:type_name -> android.release_config_proto.release_config_artifact
5, // 8: android.release_config_proto.release_configs_artifact.release_config_maps_map:type_name -> android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry
diff --git a/cmd/release_config/release_config_proto/build_flags_out.proto b/cmd/release_config/release_config_proto/build_flags_out.proto
index 0cbc157..2f1715b 100644
--- a/cmd/release_config/release_config_proto/build_flags_out.proto
+++ b/cmd/release_config/release_config_proto/build_flags_out.proto
@@ -58,7 +58,8 @@
message flag_artifacts {
// The artifacts
- repeated flag_artifact flag_artifacts = 1;
+ repeated flag_artifact flags = 1;
+ reserved "flag_artifacts";
}
message release_config_artifact {
@@ -71,7 +72,8 @@
// The complete set of build flags in this release config, after all
// inheritance and other processing is complete.
- repeated flag_artifact flag_artifacts = 3;
+ repeated flag_artifact flags = 3;
+ reserved "flag_artifacts";
// The (complete) list of aconfig_value_sets Soong modules to use.
repeated string aconfig_value_sets = 4;
diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go
index 8de340e..bc5f5c0 100644
--- a/cmd/release_config/release_config_proto/build_flags_src.pb.go
+++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go
@@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.30.0
+// protoc-gen-go v1.33.0
// protoc v3.21.12
// source: build_flags_src.proto
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index fd3b27f..2075488 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -133,10 +133,6 @@
// Returns the sub install directory relative to BaseDir().
SubDir() string
-
- // Returns an android.OutputPath to the intermediate file, which is the renamed prebuilt source
- // file.
- OutputFiles(tag string) (android.Paths, error)
}
type PrebuiltEtc struct {
@@ -245,7 +241,7 @@
return nil
}
-func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
@@ -272,17 +268,6 @@
return p.outputFilePaths[0]
}
-var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
-
-func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return p.outputFilePaths.Paths(), nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (p *PrebuiltEtc) SubDir() string {
if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
return subDir
@@ -424,6 +409,8 @@
for _, ip := range installs {
ip.addInstallRules(ctx)
}
+
+ ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
}
type installProperties struct {
diff --git a/filesystem/avb_gen_vbmeta_image.go b/filesystem/avb_gen_vbmeta_image.go
index 985f0ea..a7fd782 100644
--- a/filesystem/avb_gen_vbmeta_image.go
+++ b/filesystem/avb_gen_vbmeta_image.go
@@ -81,6 +81,8 @@
a.output = android.PathForModuleOut(ctx, a.installFileName()).OutputPath
cmd.FlagWithOutput("--output_vbmeta_image ", a.output)
builder.Build("avbGenVbmetaImage", fmt.Sprintf("avbGenVbmetaImage %s", ctx.ModuleName()))
+
+ ctx.SetOutputFiles([]android.Path{a.output}, "")
}
var _ android.AndroidMkEntriesProvider = (*avbGenVbmetaImage)(nil)
@@ -99,16 +101,6 @@
}}
}
-var _ android.OutputFileProducer = (*avbGenVbmetaImage)(nil)
-
-// Implements android.OutputFileProducer
-func (a *avbGenVbmetaImage) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{a.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
-
type avbGenVbmetaImageDefaults struct {
android.ModuleBase
android.DefaultsModuleBase
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 352b451..e796ab9 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -123,6 +123,8 @@
b.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(b.installDir, b.installFileName(), b.output)
+
+ ctx.SetOutputFiles([]android.Path{b.output}, "")
}
func (b *bootimg) buildBootImage(ctx android.ModuleContext, vendor bool) android.OutputPath {
@@ -292,13 +294,3 @@
}
return nil
}
-
-var _ android.OutputFileProducer = (*bootimg)(nil)
-
-// Implements android.OutputFileProducer
-func (b *bootimg) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{b.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index d2572c2..c889dd6 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -221,6 +221,8 @@
f.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(f.installDir, f.installFileName(), f.output)
+
+ ctx.SetOutputFiles([]android.Path{f.output}, "")
}
func validatePartitionType(ctx android.ModuleContext, p partition) {
@@ -561,16 +563,6 @@
}}
}
-var _ android.OutputFileProducer = (*filesystem)(nil)
-
-// Implements android.OutputFileProducer
-func (f *filesystem) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{f.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
-
// Filesystem is the public interface for the filesystem struct. Currently, it's only for the apex
// package to have access to the output file.
type Filesystem interface {
diff --git a/filesystem/logical_partition.go b/filesystem/logical_partition.go
index e2f7d7b..e483fe4 100644
--- a/filesystem/logical_partition.go
+++ b/filesystem/logical_partition.go
@@ -185,6 +185,8 @@
l.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(l.installDir, l.installFileName(), l.output)
+
+ ctx.SetOutputFiles([]android.Path{l.output}, "")
}
// Add a rule that converts the filesystem for the given partition to the given rule builder. The
@@ -231,13 +233,3 @@
func (l *logicalPartition) SignedOutputPath() android.Path {
return nil // logical partition is not signed by itself
}
-
-var _ android.OutputFileProducer = (*logicalPartition)(nil)
-
-// Implements android.OutputFileProducer
-func (l *logicalPartition) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{l.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
diff --git a/filesystem/raw_binary.go b/filesystem/raw_binary.go
index 1544ea7..ad36c29 100644
--- a/filesystem/raw_binary.go
+++ b/filesystem/raw_binary.go
@@ -15,8 +15,6 @@
package filesystem
import (
- "fmt"
-
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -88,6 +86,8 @@
r.output = outputFile
r.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(r.installDir, r.installFileName(), r.output)
+
+ ctx.SetOutputFiles([]android.Path{r.output}, "")
}
var _ android.AndroidMkEntriesProvider = (*rawBinary)(nil)
@@ -109,13 +109,3 @@
func (r *rawBinary) SignedOutputPath() android.Path {
return nil
}
-
-var _ android.OutputFileProducer = (*rawBinary)(nil)
-
-// Implements android.OutputFileProducer
-func (r *rawBinary) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{r.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index 43a2f37..0c6e7f4 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -211,6 +211,8 @@
v.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(v.installDir, v.installFileName(), v.output)
+
+ ctx.SetOutputFiles([]android.Path{v.output}, "")
}
// Returns the embedded shell command that prints the rollback index
@@ -288,13 +290,3 @@
func (v *vbmeta) SignedOutputPath() android.Path {
return v.OutputPath() // vbmeta is always signed
}
-
-var _ android.OutputFileProducer = (*vbmeta)(nil)
-
-// Implements android.OutputFileProducer
-func (v *vbmeta) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return []android.Path{v.output}, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 12dcb4a..b2353036 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -649,7 +649,7 @@
func (x noopImageInterface) DebugRamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
-func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func NewGenSrcs() *Module {
diff --git a/java/aar.go b/java/aar.go
index 07392f6..3168d9b 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -831,12 +831,13 @@
if a.usesLibrary.shouldDisableDexpreopt {
a.dexpreopter.disableDexpreopt()
}
+ aconfigTextFilePaths := getAconfigFilePaths(ctx)
a.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: android.SdkContext(a),
classLoaderContexts: a.classLoaderContexts,
enforceDefaultTargetSdkVersion: false,
- aconfigTextFiles: getAconfigFilePaths(ctx),
+ aconfigTextFiles: aconfigTextFilePaths,
usesLibrary: &a.usesLibrary,
},
)
@@ -906,6 +907,10 @@
JniPackages: prebuiltJniPackages,
})
}
+
+ android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
+ AconfigTextFiles: aconfigTextFilePaths,
+ })
}
func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) {
diff --git a/java/app.go b/java/app.go
index a24099c..739ef1a 100644
--- a/java/app.go
+++ b/java/app.go
@@ -47,6 +47,13 @@
}, "packageName")
)
+type FlagsPackages struct {
+ // Paths to the aconfig dump output text files that are consumed by aapt2
+ AconfigTextFiles android.Paths
+}
+
+var FlagsPackagesProvider = blueprint.NewProvider[FlagsPackages]()
+
func RegisterAppBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("android_app", AndroidAppFactory)
ctx.RegisterModuleType("android_test", AndroidTestFactory)
@@ -478,18 +485,27 @@
}
func getAconfigFilePaths(ctx android.ModuleContext) (aconfigTextFilePaths android.Paths) {
- ctx.VisitDirectDepsWithTag(aconfigDeclarationTag, func(dep android.Module) {
- if provider, ok := android.OtherModuleProvider(ctx, dep, android.AconfigDeclarationsProviderKey); ok {
- aconfigTextFilePaths = append(aconfigTextFilePaths, provider.IntermediateDumpOutputPath)
- } else {
- ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
- "flags_packages property, but %s is not aconfig_declarations module type",
- dep.Name(),
- )
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ tag := ctx.OtherModuleDependencyTag(dep)
+ switch tag {
+ case staticLibTag:
+ if flagPackages, ok := android.OtherModuleProvider(ctx, dep, FlagsPackagesProvider); ok {
+ aconfigTextFilePaths = append(aconfigTextFilePaths, flagPackages.AconfigTextFiles...)
+ }
+
+ case aconfigDeclarationTag:
+ if provider, ok := android.OtherModuleProvider(ctx, dep, android.AconfigDeclarationsProviderKey); ok {
+ aconfigTextFilePaths = append(aconfigTextFilePaths, provider.IntermediateDumpOutputPath)
+ } else {
+ ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
+ "flags_packages property, but %s is not aconfig_declarations module type",
+ dep.Name(),
+ )
+ }
}
})
- return aconfigTextFilePaths
+ return android.FirstUniquePaths(aconfigTextFilePaths)
}
func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
@@ -544,6 +560,9 @@
// Use non final ids if we are doing optimized shrinking and are using R8.
nonFinalIds := a.dexProperties.optimizedResourceShrinkingEnabled(ctx) && a.dexer.effectiveOptimizeEnabled()
+
+ aconfigTextFilePaths := getAconfigFilePaths(ctx)
+
a.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: android.SdkContext(a),
@@ -552,13 +571,17 @@
enforceDefaultTargetSdkVersion: a.enforceDefaultTargetSdkVersion(),
forceNonFinalResourceIDs: nonFinalIds,
extraLinkFlags: aaptLinkFlags,
- aconfigTextFiles: getAconfigFilePaths(ctx),
+ aconfigTextFiles: aconfigTextFilePaths,
usesLibrary: &a.usesLibrary,
},
)
// apps manifests are handled by aapt, don't let Module see them
a.properties.Manifest = nil
+
+ android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
+ AconfigTextFiles: aconfigTextFilePaths,
+ })
}
func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
diff --git a/java/app_test.go b/java/app_test.go
index 8049494..1a862fa 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4369,6 +4369,82 @@
)
}
+func TestAppFlagsPackagesPropagation(t *testing.T) {
+ ctx := testApp(t, `
+ aconfig_declarations {
+ name: "foo",
+ package: "com.example.package.foo",
+ container: "com.android.foo",
+ srcs: [
+ "foo.aconfig",
+ ],
+ }
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package.bar",
+ container: "com.android.bar",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ aconfig_declarations {
+ name: "baz",
+ package: "com.example.package.baz",
+ container: "com.android.baz",
+ srcs: [
+ "baz.aconfig",
+ ],
+ }
+ android_library {
+ name: "foo_lib",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ flags_packages: [
+ "foo",
+ ],
+ }
+ android_library {
+ name: "bar_lib",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ flags_packages: [
+ "bar",
+ ],
+ }
+ android_app {
+ name: "baz_app",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ flags_packages: [
+ "baz",
+ ],
+ static_libs: [
+ "bar_lib",
+ ],
+ libs: [
+ "foo_lib",
+ ],
+ }
+ `)
+
+ bazApp := ctx.ModuleForTests("baz_app", "android_common")
+
+ // android_app module depends on aconfig_declarations listed in flags_packages
+ // and that of static libs, but not libs
+ aapt2LinkRule := bazApp.Rule("android/soong/java.aapt2Link")
+ linkInFlags := aapt2LinkRule.Args["inFlags"]
+ android.AssertStringDoesContain(t,
+ "aapt2 link command expected to pass feature flags arguments of flags_packages and that of its static libs",
+ linkInFlags,
+ "--feature-flags @out/soong/.intermediates/bar/intermediate.txt --feature-flags @out/soong/.intermediates/baz/intermediate.txt",
+ )
+ android.AssertStringDoesNotContain(t,
+ "aapt2 link command expected to not pass feature flags arguments of flags_packages of its libs",
+ linkInFlags,
+ "--feature-flags @out/soong/.intermediates/foo/intermediate.txt",
+ )
+}
+
// Test that dexpreopt is disabled if an optional_uses_libs exists, but does not provide an implementation.
func TestNoDexpreoptOptionalUsesLibDoesNotHaveImpl(t *testing.T) {
bp := `
diff --git a/java/base.go b/java/base.go
index b4f800b..ee8df3e 100644
--- a/java/base.go
+++ b/java/base.go
@@ -94,6 +94,9 @@
// if not blank, used as prefix to generate repackage rule
Jarjar_prefix *string
+ // if set to true, skip the jarjar repackaging
+ Skip_jarjar_repackage *bool
+
// If not blank, set the java version passed to javac as -source and -target
Java_version *string
@@ -1109,11 +1112,13 @@
jarjarProviderData := j.collectJarJarRules(ctx)
if jarjarProviderData != nil {
android.SetProvider(ctx, JarJarProvider, *jarjarProviderData)
- text := getJarJarRuleText(jarjarProviderData)
- if text != "" {
- ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt")
- android.WriteFileRule(ctx, ruleTextFile, text)
- j.repackageJarjarRules = ruleTextFile
+ if !proptools.Bool(j.properties.Skip_jarjar_repackage) {
+ text := getJarJarRuleText(jarjarProviderData)
+ if text != "" {
+ ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt")
+ android.WriteFileRule(ctx, ruleTextFile, text)
+ j.repackageJarjarRules = ruleTextFile
+ }
}
}
@@ -1852,7 +1857,7 @@
classes := android.PathForModuleOut(ctx, "javac", jarName).OutputPath
TransformJavaToClasses(ctx, classes, idx, srcFiles, srcJars, annoSrcJar, flags, extraJarDeps)
- if ctx.Config().EmitXrefRules() {
+ if ctx.Config().EmitXrefRules() && ctx.Module() == ctx.PrimaryModule() {
extractionFile := android.PathForModuleOut(ctx, kzipName)
emitXrefRule(ctx, extractionFile, idx, srcFiles, srcJars, flags, extraJarDeps)
j.kytheFiles = append(j.kytheFiles, extractionFile)
@@ -2544,7 +2549,7 @@
case Implementation:
return RenameUseInclude, "info"
default:
- //fmt.Printf("LJ: %v -> %v StubsLinkType unknown\n", module, m)
+ //fmt.Printf("collectDirectDepsProviders: %v -> %v StubsLinkType unknown\n", module, m)
// Fall through to the heuristic logic.
}
switch reflect.TypeOf(m).String() {
diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go
index 07bc5c1..18a5dae 100644
--- a/java/classpath_fragment.go
+++ b/java/classpath_fragment.go
@@ -128,19 +128,21 @@
return m.Name() == configuredJars.Jar(i)
}, func(m android.Module) {
if s, ok := m.(*SdkLibrary); ok {
+ minSdkVersion := s.MinSdkVersion(ctx)
+ maxSdkVersion := s.MaxSdkVersion(ctx)
// TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
- if s.minSdkVersion.Specified() {
- if s.minSdkVersion.IsCurrent() {
+ if minSdkVersion.Specified() {
+ if minSdkVersion.IsCurrent() {
jar.minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
- jar.minSdkVersion = s.minSdkVersion.String()
+ jar.minSdkVersion = minSdkVersion.String()
}
}
- if s.maxSdkVersion.Specified() {
- if s.maxSdkVersion.IsCurrent() {
+ if maxSdkVersion.Specified() {
+ if maxSdkVersion.IsCurrent() {
jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
- jar.maxSdkVersion = s.maxSdkVersion.String()
+ jar.maxSdkVersion = maxSdkVersion.String()
}
}
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 832b850..7949244 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -96,6 +96,10 @@
}
}
+func (install dexpreopterInstall) PackageFile(ctx android.ModuleContext) android.PackagingSpec {
+ return ctx.PackageFile(install.installDirOnDevice, install.installFileOnDevice, install.outputPathOnHost)
+}
+
type Dexpreopter struct {
dexpreopter
}
@@ -312,10 +316,6 @@
dexpreopt.RegisterToolDeps(ctx)
}
-func (d *dexpreopter) odexOnSystemOther(ctx android.ModuleContext, libName string, installPath android.InstallPath) bool {
- return dexpreopt.OdexOnSystemOtherByName(libName, android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx))
-}
-
// Returns the install path of the dex jar of a module.
//
// Do not rely on `ApexInfo.ApexVariationName` because it can be something like "apex1000", rather
@@ -545,12 +545,29 @@
// Use the path of the dex file to determine the library name
isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(dexJarStem)
+ dexpreoptPartition := d.installPath.Partition()
+ // dexpreoptPartition is set to empty for dexpreopts of system APEX and system_other.
+ // In case of system APEX, however, we can set it to "system" manually.
+ // TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of
+ // using the dex location to generate the installPath.
+ if isApexSystemServerJar {
+ dexpreoptPartition = "system"
+ }
for _, install := range dexpreoptRule.Installs() {
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
+ partition := dexpreoptPartition
+ if strings.HasPrefix(installDir, partition+"/") {
+ installDir = strings.TrimPrefix(installDir, partition+"/")
+ } else {
+ // If the partition for the installDir is different from the install partition, set the
+ // partition empty to install the dexpreopt files to the desired partition.
+ // TODO(b/346439786): Define and use the dexpreopt module type to avoid this mismatch.
+ partition = ""
+ }
installBase := filepath.Base(install.To)
arch := filepath.Base(installDir)
- installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
+ installPath := android.PathForModuleInPartitionInstall(ctx, partition, installDir)
isProfile := strings.HasSuffix(installBase, ".prof")
if isProfile {
@@ -584,6 +601,37 @@
}
}
+func getModuleInstallPathInfo(ctx android.ModuleContext, fullInstallPath string) (android.InstallPath, string, string) {
+ installPath := android.PathForModuleInstall(ctx)
+ installDir, installBase := filepath.Split(strings.TrimPrefix(fullInstallPath, "/"))
+
+ if !strings.HasPrefix(installDir, installPath.Partition()+"/") {
+ // Return empty filename if the install partition is not for the target image.
+ return installPath, "", ""
+ }
+ relDir, err := filepath.Rel(installPath.Partition(), installDir)
+ if err != nil {
+ panic(err)
+ }
+ return installPath, relDir, installBase
+}
+
+// RuleBuilder.Install() adds output-to-install copy pairs to a list for Make. To share this
+// information with PackagingSpec in soong, call PackageFile for them.
+// The install path and the target install partition of the module must be the same.
+func packageFile(ctx android.ModuleContext, install android.RuleBuilderInstall) {
+ installPath, relDir, name := getModuleInstallPathInfo(ctx, install.To)
+ // Empty name means the install partition is not for the target image.
+ // For the system image, files for "apex" and "system_other" are skipped here.
+ // The skipped "apex" files are for testing only, for example,
+ // "/apex/art_boot_images/javalib/x86/boot.vdex".
+ // TODO(b/320196894): Files for "system_other" are skipped because soong creates the system
+ // image only for now.
+ if name != "" {
+ ctx.PackageFile(installPath.Join(ctx, relDir), name, install.From)
+ }
+}
+
func (d *dexpreopter) DexpreoptBuiltInstalledForApex() []dexpreopterInstall {
return d.builtInstalledForApex
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 7229ca0..defa82c 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -612,6 +612,9 @@
profileInstalls: profileInstalls,
profileLicenseMetadataFile: android.OptionalPathForPath(ctx.LicenseMetadataFile()),
})
+ for _, install := range profileInstalls {
+ packageFile(ctx, install)
+ }
}
}
@@ -929,6 +932,35 @@
return apexNameToApexExportsInfoMap
}
+func packageFileForTargetImage(ctx android.ModuleContext, image *bootImageVariant) {
+ if image.target.Os != ctx.Os() {
+ // This is not for the target device.
+ return
+ }
+
+ for _, install := range image.installs {
+ packageFile(ctx, install)
+ }
+
+ for _, install := range image.vdexInstalls {
+ if image.target.Arch.ArchType.Name != ctx.DeviceConfig().DeviceArch() {
+ // Note that the vdex files are identical between architectures. If the target image is
+ // not for the primary architecture create symlinks to share the vdex of the primary
+ // architecture with the other architectures.
+ //
+ // Assuming that the install path has the architecture name with it, replace the
+ // architecture name with the primary architecture name to find the source vdex file.
+ installPath, relDir, name := getModuleInstallPathInfo(ctx, install.To)
+ if name != "" {
+ srcRelDir := strings.Replace(relDir, image.target.Arch.ArchType.Name, ctx.DeviceConfig().DeviceArch(), 1)
+ ctx.InstallSymlink(installPath.Join(ctx, relDir), name, installPath.Join(ctx, srcRelDir, name))
+ }
+ } else {
+ packageFile(ctx, install)
+ }
+ }
+}
+
// Generate boot image build rules for a specific target.
func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, profile android.Path) bootImageVariantOutputs {
@@ -1123,6 +1155,7 @@
image.installs = rule.Installs()
image.vdexInstalls = vdexInstalls
image.unstrippedInstalls = unstrippedInstalls
+ packageFileForTargetImage(ctx, image)
// Only set the licenseMetadataFile from the active module.
if isActiveModule(ctx, ctx.Module()) {
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 5ca6c25..b32b754 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -1054,8 +1054,7 @@
}
if !treatDocumentationIssuesAsErrors {
- // Treat documentation issues as warnings, but error when new.
- cmd.Flag("--error-when-new-category").Flag("Documentation")
+ treatDocumentationIssuesAsWarningErrorWhenNew(cmd)
}
// Add "check released" options. (Detect incompatible API changes from the last public release)
@@ -1083,6 +1082,22 @@
}
}
+// HIDDEN_DOCUMENTATION_ISSUES is the set of documentation related issues that should always be
+// hidden as they are very noisy and provide little value.
+var HIDDEN_DOCUMENTATION_ISSUES = []string{
+ "Deprecated",
+ "IntDef",
+ "Nullable",
+}
+
+func treatDocumentationIssuesAsWarningErrorWhenNew(cmd *android.RuleBuilderCommand) {
+ // Treat documentation issues as warnings, but error when new.
+ cmd.Flag("--error-when-new-category").Flag("Documentation")
+
+ // Hide some documentation issues that generated a lot of noise for little benefit.
+ cmd.FlagForEachArg("--hide ", HIDDEN_DOCUMENTATION_ISSUES)
+}
+
// Sandbox rule for generating exportable stubs and other artifacts
func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
optionalCmdParams := stubsCommandParams{
@@ -1154,7 +1169,7 @@
}
// Treat documentation issues as warnings, but error when new.
- cmd.Flag("--error-when-new-category").Flag("Documentation")
+ treatDocumentationIssuesAsWarningErrorWhenNew(cmd)
if params.stubConfig.generateStubs {
rule.Command().
diff --git a/java/java.go b/java/java.go
index ccccbac..08fb678 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2180,7 +2180,7 @@
// Map where key is the api scope name and value is the int value
// representing the order of the api scope, narrowest to the widest
-var scopeOrderMap = allApiScopes.MapToIndex(
+var scopeOrderMap = AllApiScopes.MapToIndex(
func(s *apiScope) string { return s.name })
func (al *ApiLibrary) sortApiFilesByApiScope(ctx android.ModuleContext, srcFilesInfo []JavaApiImportInfo) []JavaApiImportInfo {
diff --git a/java/lint.go b/java/lint.go
index 82fac91..2eea07d 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -319,25 +319,19 @@
cmd.FlagWithInput("@",
android.PathForSource(ctx, "build/soong/java/lint_defaults.txt"))
- if l.compileSdkKind == android.SdkPublic {
- cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
- } else {
- // TODO(b/268261262): Remove this branch. We're demoting NewApi to a warning due to pre-existing issues that need to be fixed.
- cmd.FlagForEachArg("--warning_check ", l.extraMainlineLintErrors)
- }
+ cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks)
cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks)
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks)
- // TODO(b/193460475): Re-enable strict updatability linting
- //if l.GetStrictUpdatabilityLinting() {
- // // Verify the module does not baseline issues that endanger safe updatability.
- // if baselinePath := l.getBaselineFilepath(ctx); baselinePath.Valid() {
- // cmd.FlagWithInput("--baseline ", baselinePath.Path())
- // cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
- // }
- //}
+ if l.GetStrictUpdatabilityLinting() {
+ // Verify the module does not baseline issues that endanger safe updatability.
+ if l.properties.Lint.Baseline_filename != nil {
+ cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
+ cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
+ }
+ }
return lintPaths{
projectXML: projectXMLPath,
diff --git a/java/lint_test.go b/java/lint_test.go
index 751b139..b51753f 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -91,9 +91,8 @@
t.Error("did not use the correct file for baseline")
}
- if !strings.Contains(*sboxProto.Commands[0].Command, "--warning_check NewApi") {
- // TODO(b/268261262): Change this to check for --error_check
- t.Error("should check NewApi warnings")
+ if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") {
+ t.Error("should check NewApi errors")
}
if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") {
@@ -153,52 +152,55 @@
}
}
-// TODO(b/193460475): Re-enable this test
-//func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
-// bp := `
-// java_library {
-// name: "foo",
-// srcs: [
-// "a.java",
-// ],
-// static_libs: ["bar"],
-// min_sdk_version: "29",
-// sdk_version: "current",
-// lint: {
-// strict_updatability_linting: true,
-// },
-// }
-//
-// java_library {
-// name: "bar",
-// srcs: [
-// "a.java",
-// ],
-// min_sdk_version: "29",
-// sdk_version: "current",
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
-// RunTestWithBp(t, bp)
-//
-// foo := result.ModuleForTests("foo", "android_common")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command,
-// "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Error("did not restrict baselining NewApi")
-// }
-//
-// bar := result.ModuleForTests("bar", "android_common")
-// sboxProto = android.RuleBuilderSboxProtoForTests(t, bar.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command,
-// "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Error("did not restrict baselining NewApi")
-// }
-//}
+func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
+ bp := `
+ java_library {
+ name: "foo",
+ srcs: [
+ "a.java",
+ ],
+ static_libs: ["bar"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ strict_updatability_linting: true,
+ baseline_filename: "lint-baseline.xml",
+ },
+ }
+
+ java_library {
+ name: "bar",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
+ RunTestWithBp(t, bp)
+
+ foo := result.ModuleForTests("foo", "android_common")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Error("did not restrict baselining NewApi")
+ }
+
+ bar := result.ModuleForTests("bar", "android_common")
+ sboxProto = android.RuleBuilderSboxProtoForTests(t, result.TestContext, bar.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Error("did not restrict baselining NewApi")
+ }
+}
func TestJavaLintDatabaseSelectionFull(t *testing.T) {
testCases := []struct {
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index 99fa092..49756dd 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -266,7 +266,7 @@
func (p *platformCompatConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
if p.metadata != nil {
- ctx.Strict("INTERNAL_PLATFORM_MERGED_COMPAT_CONFIG", p.metadata.String())
+ ctx.DistForGoal("droidcore", p.metadata)
}
}
diff --git a/java/rro.go b/java/rro.go
index 72170fc..0fc6e1c 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -150,12 +150,13 @@
aaptLinkFlags = append(aaptLinkFlags,
"--rename-overlay-category "+*r.overridableProperties.Category)
}
+ aconfigTextFilePaths := getAconfigFilePaths(ctx)
r.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: r,
enforceDefaultTargetSdkVersion: false,
extraLinkFlags: aaptLinkFlags,
- aconfigTextFiles: getAconfigFilePaths(ctx),
+ aconfigTextFiles: aconfigTextFilePaths,
},
)
@@ -176,6 +177,10 @@
partition := rroPartition(ctx)
r.installDir = android.PathForModuleInPartitionInstall(ctx, partition, "overlay", String(r.properties.Theme))
ctx.InstallFile(r.installDir, r.outputFile.Base(), r.outputFile)
+
+ android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
+ AconfigTextFiles: aconfigTextFilePaths,
+ })
}
func (r *RuntimeResourceOverlay) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 72eb6e3..e9fa83a 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -324,6 +324,16 @@
return ret
}
+func (scopes apiScopes) ConvertStubsLibraryExportableToEverything(name string) string {
+ for _, scope := range scopes {
+ if strings.HasSuffix(name, scope.exportableStubsLibraryModuleNameSuffix()) {
+ return strings.TrimSuffix(name, scope.exportableStubsLibraryModuleNameSuffix()) +
+ scope.stubsLibraryModuleNameSuffix()
+ }
+ }
+ return name
+}
+
var (
scopeByName = make(map[string]*apiScope)
allScopeNames []string
@@ -418,7 +428,7 @@
},
kind: android.SdkSystemServer,
})
- allApiScopes = apiScopes{
+ AllApiScopes = apiScopes{
apiScopePublic,
apiScopeSystem,
apiScopeTest,
@@ -1204,7 +1214,7 @@
paths := c.findClosestScopePath(apiScope)
if paths == nil {
var scopes []string
- for _, s := range allApiScopes {
+ for _, s := range AllApiScopes {
if c.findScopePaths(s) != nil {
scopes = append(scopes, s.name)
}
@@ -1421,7 +1431,7 @@
// Check to see if any scopes have been explicitly enabled. If any have then all
// must be.
anyScopesExplicitlyEnabled := false
- for _, scope := range allApiScopes {
+ for _, scope := range AllApiScopes {
scopeProperties := module.scopeToProperties[scope]
if scopeProperties.Enabled != nil {
anyScopesExplicitlyEnabled = true
@@ -1431,7 +1441,7 @@
var generatedScopes apiScopes
enabledScopes := make(map[*apiScope]struct{})
- for _, scope := range allApiScopes {
+ for _, scope := range AllApiScopes {
scopeProperties := module.scopeToProperties[scope]
// If any scopes are explicitly enabled then ignore the legacy enabled status.
// This is to ensure that any new usages of this module type do not rely on legacy
@@ -1451,7 +1461,7 @@
// Now check to make sure that any scope that is extended by an enabled scope is also
// enabled.
- for _, scope := range allApiScopes {
+ for _, scope := range AllApiScopes {
if _, ok := enabledScopes[scope]; ok {
extends := scope.extends
if extends != nil {
@@ -2580,7 +2590,7 @@
// Initialize the map from scope to scope specific properties.
scopeToProperties := make(map[*apiScope]*ApiScopeProperties)
- for _, scope := range allApiScopes {
+ for _, scope := range AllApiScopes {
scopeToProperties[scope] = scope.scopeSpecificProperties(module)
}
module.scopeToProperties = scopeToProperties
@@ -2697,7 +2707,7 @@
// Dynamically create a structure type for each apiscope in allApiScopes.
func createAllScopePropertiesStructType() reflect.Type {
var fields []reflect.StructField
- for _, apiScope := range allApiScopes {
+ for _, apiScope := range AllApiScopes {
field := reflect.StructField{
Name: apiScope.fieldName,
Type: reflect.TypeOf(sdkLibraryScopeProperties{}),
@@ -2715,7 +2725,7 @@
allScopePropertiesStruct := allScopePropertiesPtr.Elem()
scopeProperties := make(map[*apiScope]*sdkLibraryScopeProperties)
- for _, apiScope := range allApiScopes {
+ for _, apiScope := range AllApiScopes {
field := allScopePropertiesStruct.FieldByName(apiScope.fieldName)
scopeProperties[apiScope] = field.Addr().Interface().(*sdkLibraryScopeProperties)
}
@@ -3242,11 +3252,6 @@
return "permissions"
}
-// from android.PrebuiltEtcModule
-func (module *sdkLibraryXml) OutputFiles(tag string) (android.Paths, error) {
- return android.OutputPaths{module.outputFilePath}.Paths(), nil
-}
-
var _ etc.PrebuiltEtcModule = (*sdkLibraryXml)(nil)
// from android.ApexModule
@@ -3390,6 +3395,8 @@
module.installDirPath = android.PathForModuleInstall(ctx, "etc", module.SubDir())
ctx.PackageFile(module.installDirPath, libName+".xml", module.outputFilePath)
+
+ ctx.SetOutputFiles(android.OutputPaths{module.outputFilePath}.Paths(), "")
}
func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
@@ -3597,7 +3604,7 @@
s.Stem = sdk.distStem()
s.Scopes = make(map[*apiScope]*scopeProperties)
- for _, apiScope := range allApiScopes {
+ for _, apiScope := range AllApiScopes {
paths := sdk.findScopePaths(apiScope)
if paths == nil {
continue
@@ -3659,7 +3666,7 @@
stem := s.Stem
- for _, apiScope := range allApiScopes {
+ for _, apiScope := range AllApiScopes {
if properties, ok := s.Scopes[apiScope]; ok {
scopeSet := propertySet.AddPropertySet(apiScope.propertyName)
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 98aa408..3a8d3cf 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -15,7 +15,6 @@
package linkerconfig
import (
- "fmt"
"sort"
"strings"
@@ -73,17 +72,6 @@
return l.outputFilePath
}
-var _ android.OutputFileProducer = (*linkerConfig)(nil)
-
-func (l *linkerConfig) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return android.Paths{l.outputFilePath}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
input := android.PathForModuleSrc(ctx, android.String(l.properties.Src))
output := android.PathForModuleOut(ctx, "linker.config.pb").OutputPath
@@ -98,6 +86,8 @@
l.SkipInstall()
}
ctx.InstallFile(l.installDirPath, l.outputFilePath.Base(), l.outputFilePath)
+
+ ctx.SetOutputFiles(android.Paths{l.outputFilePath}, "")
}
func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 4277753..83a6e95 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -236,7 +236,8 @@
esc := proptools.NinjaAndShellEscapeList
// Filter out invalid cflags
- for _, flag := range b.ClangProperties.Cflags {
+ cflagsProp := b.ClangProperties.Cflags.GetOrDefault(ctx, nil)
+ for _, flag := range cflagsProp {
if flag == "-x c++" || flag == "-xc++" {
ctx.PropertyErrorf("cflags",
"-x c++ should not be specified in cflags; setting cpp_std specifies this is a C++ header, or change the file extension to '.hpp' or '.hh'")
@@ -248,7 +249,7 @@
}
// Module defined clang flags and include paths
- cflags = append(cflags, esc(b.ClangProperties.Cflags)...)
+ cflags = append(cflags, esc(cflagsProp)...)
for _, include := range b.ClangProperties.Local_include_dirs {
cflags = append(cflags, "-I"+android.PathForModuleSrc(ctx, include).String())
implicits = append(implicits, android.PathForModuleSrc(ctx, include))
diff --git a/rust/config/global.go b/rust/config/global.go
index e83e23a..6943467 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var (
pctx = android.NewPackageContext("android/soong/rust/config")
- RustDefaultVersion = "1.77.1.p1"
+ RustDefaultVersion = "1.78.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/rust/image.go b/rust/image.go
index e0d267d..fec6d92 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -197,21 +197,20 @@
return mod.InVendor() || mod.InProduct()
}
-func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
- m := module.(*Module)
+func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.VendorRamdiskVariation {
- m.MakeAsPlatform()
+ mod.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
- m.MakeAsPlatform()
+ mod.MakeAsPlatform()
} else if strings.HasPrefix(variant, cc.VendorVariation) {
- m.Properties.ImageVariation = cc.VendorVariation
+ mod.Properties.ImageVariation = cc.VendorVariation
if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
+ mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
}
} else if strings.HasPrefix(variant, cc.ProductVariation) {
- m.Properties.ImageVariation = cc.ProductVariation
+ mod.Properties.ImageVariation = cc.ProductVariation
if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
+ mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
}
}
}
diff --git a/rust/rust.go b/rust/rust.go
index 5790dd6..7cd9df4 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -345,19 +345,6 @@
return mod.Properties.SubName
}
-func (mod *Module) IsVndk() bool {
- // TODO(b/165791368)
- return false
-}
-
-func (mod *Module) IsVndkExt() bool {
- return false
-}
-
-func (mod *Module) IsVndkSp() bool {
- return false
-}
-
func (mod *Module) IsVndkPrebuiltLibrary() bool {
// Rust modules do not provide VNDK prebuilts
return false
@@ -380,10 +367,6 @@
return false
}
-func (c *Module) IsLlndkPublic() bool {
- return false
-}
-
func (mod *Module) KernelHeadersDecorator() bool {
return false
}
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index f9d49d9..4894210 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -519,4 +519,140 @@
)
})
+ t.Run("test replacing exportable module", func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "anothersdklibrary"),
+ android.FixtureWithRootAndroidBp(`
+ sdk {
+ name: "mysdk",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ core_platform_api: {
+ stub_libs: [
+ "anothersdklibrary.stubs.exportable",
+ ],
+ },
+ api: {
+ stub_libs: [
+ "anothersdklibrary",
+ ],
+ },
+ }
+
+ java_sdk_library {
+ name: "mysdklibrary",
+ srcs: ["Test.java"],
+ compile_dex: true,
+ min_sdk_version: "S",
+ public: {enabled: true},
+ permitted_packages: ["mysdklibrary"],
+ }
+
+ java_sdk_library {
+ name: "anothersdklibrary",
+ srcs: ["Test.java"],
+ compile_dex: true,
+ min_sdk_version: "S",
+ public: {enabled: true},
+ system: {enabled: true},
+ module_lib: {enabled: true},
+ }
+ `),
+ android.FixtureMergeEnv(map[string]string{
+ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake", "Tiramisu", "S-V2"}
+ }),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+prebuilt_bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ api: {
+ stub_libs: ["anothersdklibrary"],
+ },
+ core_platform_api: {
+ stub_libs: ["anothersdklibrary.stubs"],
+ },
+ hidden_api: {
+ annotation_flags: "hiddenapi/annotation-flags.csv",
+ metadata: "hiddenapi/metadata.csv",
+ index: "hiddenapi/index.csv",
+ stub_flags: "hiddenapi/stub-flags.csv",
+ all_flags: "hiddenapi/all-flags.csv",
+ },
+}
+
+java_sdk_library_import {
+ name: "mysdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ shared_library: true,
+ compile_dex: true,
+ permitted_packages: ["mysdklibrary"],
+ public: {
+ jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/public/mysdklibrary.txt",
+ removed_api: "sdk_library/public/mysdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+}
+
+java_sdk_library_import {
+ name: "anothersdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ shared_library: true,
+ compile_dex: true,
+ public: {
+ jars: ["sdk_library/public/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/public/anothersdklibrary.txt",
+ removed_api: "sdk_library/public/anothersdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+ system: {
+ jars: ["sdk_library/system/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/system/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/system/anothersdklibrary.txt",
+ removed_api: "sdk_library/system/anothersdklibrary-removed.txt",
+ sdk_version: "system_current",
+ },
+ module_lib: {
+ jars: ["sdk_library/module-lib/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/module-lib/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/module-lib/anothersdklibrary.txt",
+ removed_api: "sdk_library/module-lib/anothersdklibrary-removed.txt",
+ sdk_version: "module_current",
+ },
+}
+`),
+ )
+ })
+
}
diff --git a/sdk/update.go b/sdk/update.go
index afecf9f..0a97fd9 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -480,6 +480,12 @@
// Transform the module module to make it suitable for use in the snapshot.
module = transformModule(module, snapshotTransformer)
module = transformModule(module, emptyClasspathContentsTransformation{})
+
+ targetApiLevel, err := android.ApiLevelFromUserWithConfig(ctx.Config(), s.targetBuildRelease(ctx).name)
+ if err == nil && targetApiLevel.LessThan(android.ApiLevelVanillaIceCream) {
+ module = transformModule(module, replaceExportablePropertiesTransformer{})
+ }
+
if module != nil {
bpFile.AddModule(module)
}
@@ -804,6 +810,50 @@
}
}
+type replaceExportablePropertiesTransformer struct {
+ identityTransformation
+}
+
+var _ bpTransformer = (*replaceExportablePropertiesTransformer)(nil)
+
+func handleExportableProperties[T any](value T) any {
+ switch v := any(value).(type) {
+ case string:
+ return java.AllApiScopes.ConvertStubsLibraryExportableToEverything(v)
+ case *bpPropertySet:
+ v.properties = handleExportableProperties(v.properties).(map[string]interface{})
+ return v
+ case []string:
+ result := make([]string, len(v))
+ for i, elem := range v {
+ result[i] = handleExportableProperties(elem).(string)
+ }
+ return result
+ case []any:
+ result := make([]any, len(v))
+ for i, elem := range v {
+ result[i] = handleExportableProperties(elem)
+ }
+ return result
+ case map[string]any:
+ result := make(map[string]any)
+ for k, val := range v {
+ result[k] = handleExportableProperties(val)
+ }
+ return result
+ default:
+ return value
+ }
+}
+
+func (t replaceExportablePropertiesTransformer) transformPropertySetAfterContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+ if name == "name" {
+ return propertySet, tag
+ }
+ propertySet.properties = handleExportableProperties(propertySet.properties).(map[string]interface{})
+ return propertySet, tag
+}
+
func generateBpContents(bpFile *bpFile) string {
contents := &generatedContents{}
contents.IndentedPrintf("// This is auto-generated. DO NOT EDIT.\n")
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 3cbbc45..48a442d 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -15,7 +15,6 @@
package sh
import (
- "fmt"
"path/filepath"
"strings"
@@ -100,6 +99,12 @@
// Make this module available when building for recovery.
Recovery_available *bool
+
+ // The name of the image this module is built for
+ ImageVariation string `blueprint:"mutated"`
+
+ // Suffix for the name of Android.mk entries generated by this module
+ SubName string `blueprint:"mutated"`
}
type TestProperties struct {
@@ -188,15 +193,6 @@
return s.outputFilePath
}
-func (s *ShBinary) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return android.Paths{s.outputFilePath}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (s *ShBinary) SubDir() string {
return proptools.String(s.properties.Sub_dir)
}
@@ -217,15 +213,15 @@
func (s *ShBinary) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (s *ShBinary) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
- return !s.ModuleBase.InstallInRecovery() && !s.ModuleBase.InstallInRamdisk()
+ return !s.InstallInRecovery() && !s.InstallInRamdisk() && !s.InstallInVendorRamdisk() && !s.ModuleBase.InstallInVendor()
}
func (s *ShBinary) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
- return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk()
+ return proptools.Bool(s.properties.Ramdisk_available) || s.InstallInRamdisk()
}
func (s *ShBinary) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
- return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.ModuleBase.InstallInVendorRamdisk()
+ return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.InstallInVendorRamdisk()
}
func (s *ShBinary) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -233,14 +229,43 @@
}
func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
- return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery()
+ return proptools.Bool(s.properties.Recovery_available) || s.InstallInRecovery()
}
func (s *ShBinary) ExtraImageVariations(ctx android.BaseModuleContext) []string {
- return nil
+ extraVariations := []string{}
+ if s.InstallInProduct() {
+ extraVariations = append(extraVariations, cc.ProductVariation)
+ }
+ if s.InstallInVendor() {
+ extraVariations = append(extraVariations, cc.VendorVariation)
+ }
+ return extraVariations
}
-func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string) {
+ s.properties.ImageVariation = variation
+}
+
+// Overrides ModuleBase.InstallInRamdisk() so that the install rule respects
+// Ramdisk_available property for ramdisk variant
+func (s *ShBinary) InstallInRamdisk() bool {
+ return s.ModuleBase.InstallInRamdisk() ||
+ (proptools.Bool(s.properties.Ramdisk_available) && s.properties.ImageVariation == android.RamdiskVariation)
+}
+
+// Overrides ModuleBase.InstallInVendorRamdisk() so that the install rule respects
+// Vendor_ramdisk_available property for vendor ramdisk variant
+func (s *ShBinary) InstallInVendorRamdisk() bool {
+ return s.ModuleBase.InstallInVendorRamdisk() ||
+ (proptools.Bool(s.properties.Vendor_ramdisk_available) && s.properties.ImageVariation == android.VendorRamdiskVariation)
+}
+
+// Overrides ModuleBase.InstallInRecovery() so that the install rule respects
+// Recovery_available property for recovery variant
+func (s *ShBinary) InstallInRecovery() bool {
+ return s.ModuleBase.InstallInRecovery() ||
+ (proptools.Bool(s.properties.Recovery_available) && s.properties.ImageVariation == android.RecoveryVariation)
}
func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
@@ -270,7 +295,22 @@
Output: s.outputFilePath,
Input: s.sourceFilePath,
})
+
+ s.properties.SubName = s.GetSubname(ctx)
+
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: []string{s.sourceFilePath.String()}})
+
+ ctx.SetOutputFiles(android.Paths{s.outputFilePath}, "")
+}
+
+func (s *ShBinary) GetSubname(ctx android.ModuleContext) string {
+ ret := ""
+ if s.properties.ImageVariation != "" {
+ if s.properties.ImageVariation != cc.VendorVariation {
+ ret = "." + s.properties.ImageVariation
+ }
+ }
+ return ret
}
func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -286,7 +326,7 @@
}
func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
- return []android.AndroidMkEntries{android.AndroidMkEntries{
+ return []android.AndroidMkEntries{{
Class: "EXECUTABLES",
OutputFile: android.OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
@@ -297,6 +337,7 @@
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !s.Installable())
},
},
+ SubName: s.properties.SubName,
}}
}
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index b9b68be..84f20c5 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -49,8 +49,6 @@
android.ModuleBase
properties syspropGenProperties
-
- genSrcjars android.Paths
}
type syspropRustGenRule struct {
@@ -59,7 +57,6 @@
properties rustLibraryProperties
}
-var _ android.OutputFileProducer = (*syspropJavaGenRule)(nil)
var _ rust.SourceProvider = (*syspropRustGenRule)(nil)
var (
@@ -100,6 +97,7 @@
}
})
+ var genSrcjars android.Paths
for _, syspropFile := range android.PathsForModuleSrc(ctx, g.properties.Srcs) {
srcJarFile := android.GenPathWithExt(ctx, "sysprop", syspropFile, "srcjar")
@@ -114,8 +112,10 @@
},
})
- g.genSrcjars = append(g.genSrcjars, srcJarFile)
+ genSrcjars = append(genSrcjars, srcJarFile)
}
+
+ ctx.SetOutputFiles(genSrcjars, "")
}
func (g *syspropJavaGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -124,15 +124,6 @@
ctx.AddFarVariationDependencies(nil, nil, proptools.String(g.properties.Check_api))
}
-func (g *syspropJavaGenRule) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return g.genSrcjars, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func syspropJavaGenFactory() android.Module {
g := &syspropJavaGenRule{}
g.AddProperties(&g.properties)
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..458cf4b
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,34 @@
+// 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+ default_team: "trendy_team_build",
+}
+
+python_test_host {
+ name: "run_tool_with_logging_test",
+ main: "run_tool_with_logging_test.py",
+ pkg_path: "testdata",
+ srcs: [
+ "run_tool_with_logging_test.py",
+ ],
+ test_options: {
+ unit_test: true,
+ },
+ data: [
+ ":run_tool_with_logging_script",
+ ":tool_event_logger",
+ ],
+}
diff --git a/tests/run_tool_with_logging_test.py b/tests/run_tool_with_logging_test.py
new file mode 100644
index 0000000..57a6d62
--- /dev/null
+++ b/tests/run_tool_with_logging_test.py
@@ -0,0 +1,337 @@
+# Copyright 2024 The Android Open Source Project
+#
+# 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.
+
+import dataclasses
+import glob
+from importlib import resources
+import logging
+import os
+from pathlib import Path
+import re
+import shutil
+import signal
+import stat
+import subprocess
+import sys
+import tempfile
+import textwrap
+import time
+import unittest
+
+EXII_RETURN_CODE = 0
+INTERRUPTED_RETURN_CODE = 130
+
+
+class RunToolWithLoggingTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ # Configure to print logging to stdout.
+ logging.basicConfig(filename=None, level=logging.DEBUG)
+ console = logging.StreamHandler(sys.stdout)
+ logging.getLogger("").addHandler(console)
+
+ def setUp(self):
+ super().setUp()
+ self.working_dir = tempfile.TemporaryDirectory()
+ # Run all the tests from working_dir which is our temp Android build top.
+ os.chdir(self.working_dir.name)
+
+ self.logging_script_path = self._import_executable("run_tool_with_logging")
+
+ def tearDown(self):
+ self.working_dir.cleanup()
+ super().tearDown()
+
+ def test_does_not_log_when_logger_var_empty(self):
+ test_tool = TestScript.create(self.working_dir)
+
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER=""
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ test_tool.assert_called_once_with_args("arg1 arg2")
+
+ def test_does_not_log_with_logger_unset(self):
+ test_tool = TestScript.create(self.working_dir)
+
+ self._run_script_and_wait(f"""
+ unset ANDROID_TOOL_LOGGER
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ test_tool.assert_called_once_with_args("arg1 arg2")
+
+ def test_log_success_with_logger_enabled(self):
+ test_tool = TestScript.create(self.working_dir)
+ test_logger = TestScript.create(self.working_dir)
+
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ test_tool.assert_called_once_with_args("arg1 arg2")
+ expected_logger_args = (
+ "--tool_tag=FAKE_TOOL --start_timestamp=\d+\.\d+ --end_timestamp="
+ "\d+\.\d+ --tool_args=arg1 arg2 --exit_code=0"
+ )
+ test_logger.assert_called_once_with_args(expected_logger_args)
+
+ def test_run_tool_output_is_same_with_and_without_logging(self):
+ test_tool = TestScript.create(self.working_dir, "echo 'tool called'")
+ test_logger = TestScript.create(self.working_dir)
+
+ run_tool_with_logging_stdout, run_tool_with_logging_stderr = (
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+ )
+
+ run_tool_without_logging_stdout, run_tool_without_logging_stderr = (
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {test_tool.executable} arg1 arg2
+ """)
+ )
+
+ self.assertEqual(
+ run_tool_with_logging_stdout, run_tool_without_logging_stdout
+ )
+ self.assertEqual(
+ run_tool_with_logging_stderr, run_tool_without_logging_stderr
+ )
+
+ def test_logger_output_is_suppressed(self):
+ test_tool = TestScript.create(self.working_dir)
+ test_logger = TestScript.create(self.working_dir, "echo 'logger called'")
+
+ run_tool_with_logging_output, _ = self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ self.assertNotIn("logger called", run_tool_with_logging_output)
+
+ def test_logger_error_is_suppressed(self):
+ test_tool = TestScript.create(self.working_dir)
+ test_logger = TestScript.create(
+ self.working_dir, "echo 'logger failed' > /dev/stderr; exit 1"
+ )
+
+ _, err = self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ self.assertNotIn("logger failed", err)
+
+ def test_log_success_when_tool_interrupted(self):
+ test_tool = TestScript.create(self.working_dir, script_body="sleep 100")
+ test_logger = TestScript.create(self.working_dir)
+
+ process = self._run_script(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ pgid = os.getpgid(process.pid)
+ # Give sometime for the subprocess to start.
+ time.sleep(1)
+ # Kill the subprocess and any processes created in the same group.
+ os.killpg(pgid, signal.SIGINT)
+
+ returncode, _, _ = self._wait_for_process(process)
+ self.assertEqual(returncode, INTERRUPTED_RETURN_CODE)
+
+ expected_logger_args = (
+ "--tool_tag=FAKE_TOOL --start_timestamp=\d+\.\d+ --end_timestamp="
+ "\d+\.\d+ --tool_args=arg1 arg2 --exit_code=130"
+ )
+ test_logger.assert_called_once_with_args(expected_logger_args)
+
+ def test_logger_can_be_toggled_on(self):
+ test_tool = TestScript.create(self.working_dir)
+ test_logger = TestScript.create(self.working_dir)
+
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER=""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ test_logger.assert_called_with_times(1)
+
+ def test_logger_can_be_toggled_off(self):
+ test_tool = TestScript.create(self.working_dir)
+ test_logger = TestScript.create(self.working_dir)
+
+ self._run_script_and_wait(f"""
+ export ANDROID_TOOL_LOGGER="{test_logger.executable}"
+ export ANDROID_TOOL_LOGGER=""
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ test_logger.assert_not_called()
+
+ def test_integration_tool_event_logger_dry_run(self):
+ test_tool = TestScript.create(self.working_dir)
+ logger_path = self._import_executable("tool_event_logger")
+
+ self._run_script_and_wait(f"""
+ TMPDIR="{self.working_dir.name}"
+ export ANDROID_TOOL_LOGGER="{logger_path}"
+ export ANDROID_TOOL_LOGGER_EXTRA_ARGS="--dry_run"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} arg1 arg2
+ """)
+
+ self._assert_logger_dry_run()
+
+ def test_tool_args_do_not_fail_logger(self):
+ test_tool = TestScript.create(self.working_dir)
+ logger_path = self._import_executable("tool_event_logger")
+
+ self._run_script_and_wait(f"""
+ TMPDIR="{self.working_dir.name}"
+ export ANDROID_TOOL_LOGGER="{logger_path}"
+ export ANDROID_TOOL_LOGGER_EXTRA_ARGS="--dry_run"
+ {self.logging_script_path} "FAKE_TOOL" {test_tool.executable} --tool-arg1
+ """)
+
+ self._assert_logger_dry_run()
+
+ def _import_executable(self, executable_name: str) -> Path:
+ # logger = "tool_event_logger"
+ executable_path = Path(self.working_dir.name).joinpath(executable_name)
+ with resources.as_file(
+ resources.files("testdata").joinpath(executable_name)
+ ) as p:
+ shutil.copy(p, executable_path)
+ Path.chmod(executable_path, 0o755)
+ return executable_path
+
+ def _assert_logger_dry_run(self):
+ log_files = glob.glob(self.working_dir.name + "/tool_event_logger_*/*.log")
+ self.assertEqual(len(log_files), 1)
+
+ with open(log_files[0], "r") as f:
+ lines = f.readlines()
+ self.assertEqual(len(lines), 1)
+ self.assertIn("dry run", lines[0])
+
+ def _run_script_and_wait(self, test_script: str) -> tuple[str, str]:
+ process = self._run_script(test_script)
+ returncode, out, err = self._wait_for_process(process)
+ logging.debug("script stdout: %s", out)
+ logging.debug("script stderr: %s", err)
+ self.assertEqual(returncode, EXII_RETURN_CODE)
+ return out, err
+
+ def _run_script(self, test_script: str) -> subprocess.Popen:
+ return subprocess.Popen(
+ test_script,
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True,
+ start_new_session=True,
+ executable="/bin/bash",
+ )
+
+ def _wait_for_process(
+ self, process: subprocess.Popen
+ ) -> tuple[int, str, str]:
+ pgid = os.getpgid(process.pid)
+ out, err = process.communicate()
+ # Wait for all process in the same group to complete since the logger runs
+ # as a separate detached process.
+ self._wait_for_process_group(pgid)
+ return (process.returncode, out, err)
+
+ def _wait_for_process_group(self, pgid: int, timeout: int = 5):
+ """Waits for all subprocesses within the process group to complete."""
+ start_time = time.time()
+ while True:
+ if time.time() - start_time > timeout:
+ raise TimeoutError(
+ f"Process group did not complete after {timeout} seconds"
+ )
+ for pid in os.listdir("/proc"):
+ if pid.isdigit():
+ try:
+ if os.getpgid(int(pid)) == pgid:
+ time.sleep(0.1)
+ break
+ except (FileNotFoundError, PermissionError, ProcessLookupError):
+ pass
+ else:
+ # All processes have completed.
+ break
+
+
+@dataclasses.dataclass
+class TestScript:
+ executable: Path
+ output_file: Path
+
+ def create(temp_dir: Path, script_body: str = ""):
+ with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as f:
+ output_file = f.name
+
+ with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as f:
+ executable = f.name
+ executable_contents = textwrap.dedent(f"""
+ #!/bin/bash
+
+ echo "${{@}}" >> {output_file}
+ {script_body}
+ """)
+ f.write(executable_contents.encode("utf-8"))
+
+ Path.chmod(f.name, os.stat(f.name).st_mode | stat.S_IEXEC)
+
+ return TestScript(executable, output_file)
+
+ def assert_called_with_times(self, expected_call_times: int):
+ lines = self._read_contents_from_output_file()
+ assert len(lines) == expected_call_times, (
+ f"Expect to call {expected_call_times} times, but actually called"
+ f" {len(lines)} times."
+ )
+
+ def assert_called_with_args(self, expected_args: str):
+ lines = self._read_contents_from_output_file()
+ assert len(lines) > 0
+ assert re.search(expected_args, lines[0]), (
+ f"Expect to call with args {expected_args}, but actually called with"
+ f" args {lines[0]}."
+ )
+
+ def assert_not_called(self):
+ self.assert_called_with_times(0)
+
+ def assert_called_once_with_args(self, expected_args: str):
+ self.assert_called_with_times(1)
+ self.assert_called_with_args(expected_args)
+
+ def _read_contents_from_output_file(self) -> list[str]:
+ with open(self.output_file, "r") as f:
+ return f.readlines()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
index a29f413..bbac2db 100644
--- a/ui/build/androidmk_denylist.go
+++ b/ui/build/androidmk_denylist.go
@@ -19,10 +19,13 @@
)
var androidmk_denylist []string = []string{
+ "bionic/",
"chained_build_config/",
"cts/",
"dalvik/",
"developers/",
+ "development/",
+ "device/sample/",
"frameworks/",
// Do not block other directories in kernel/, see b/319658303.
"kernel/configs/",
@@ -31,6 +34,10 @@
"libcore/",
"libnativehelper/",
"pdk/",
+ "prebuilts/",
+ "sdk/",
+ "test/",
+ "trusty/",
// Add back toolchain/ once defensive Android.mk files are removed
//"toolchain/",
}
diff --git a/ui/build/build.go b/ui/build/build.go
index 9a9eccd..03d8392 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -21,7 +21,6 @@
"path/filepath"
"sync"
"text/template"
- "time"
"android/soong/ui/metrics"
)
@@ -66,9 +65,12 @@
// (to allow for source control that uses something other than numbers),
// but must be a single word and a valid file name.
//
- // If no BUILD_NUMBER is set, create a useful "I am an engineering build
- // from this date/time" value. Make it start with a non-digit so that
- // anyone trying to parse it as an integer will probably get "0".
+ // If no BUILD_NUMBER is set, create a useful "I am an engineering build"
+ // value. Make it start with a non-digit so that anyone trying to parse
+ // it as an integer will probably get "0". This value used to contain
+ // a timestamp, but now that more dependencies are tracked in order to
+ // reduce the importance of `m installclean`, changing it every build
+ // causes unnecessary rebuilds for local development.
buildNumber, ok := config.environ.Get("BUILD_NUMBER")
if ok {
writeValueIfChanged(ctx, config, config.OutDir(), "file_name_tag.txt", buildNumber)
@@ -77,7 +79,7 @@
if username, ok = config.environ.Get("BUILD_USERNAME"); !ok {
ctx.Fatalln("Missing BUILD_USERNAME")
}
- buildNumber = fmt.Sprintf("eng.%.6s.%s", username, time.Now().Format("20060102.150405" /* YYYYMMDD.HHMMSS */))
+ buildNumber = fmt.Sprintf("eng.%.6s.00000000.000000", username)
writeValueIfChanged(ctx, config, config.OutDir(), "file_name_tag.txt", username)
}
// Write the build number to a file so it can be read back in