Merge "Min_sdk_version check for updatable apexes" into main
diff --git a/android/Android.bp b/android/Android.bp
index 3c38148..774d24a 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -42,6 +42,7 @@
"buildinfo_prop.go",
"compliance_metadata.go",
"config.go",
+ "container.go",
"test_config.go",
"configurable_properties.go",
"configured_jars.go",
diff --git a/android/androidmk_test.go b/android/androidmk_test.go
index ae2187f..72b8654 100644
--- a/android/androidmk_test.go
+++ b/android/androidmk_test.go
@@ -36,10 +36,6 @@
data AndroidMkData
distFiles TaggedDistFiles
outputFile OptionalPath
-
- // The paths that will be used as the default dist paths if no tag is
- // specified.
- defaultDistPaths Paths
}
const (
@@ -51,6 +47,7 @@
func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) {
m.base().licenseMetadataFile = PathForOutput(ctx, "meta_lic")
+ var defaultDistPaths Paths
// If the dist_output_file: true then create an output file that is stored in
// the OutputFile property of the AndroidMkEntry.
@@ -62,7 +59,7 @@
// property in AndroidMkEntry when determining the default dist paths.
// Setting this first allows it to be overridden based on the
// default_dist_files setting replicating that previous behavior.
- m.defaultDistPaths = Paths{path}
+ defaultDistPaths = Paths{path}
}
// Based on the setting of the default_dist_files property possibly create a
@@ -71,29 +68,40 @@
defaultDistFiles := proptools.StringDefault(m.properties.Default_dist_files, defaultDistFiles_Tagged)
switch defaultDistFiles {
case defaultDistFiles_None:
- // Do nothing
+ m.setOutputFiles(ctx, defaultDistPaths)
case defaultDistFiles_Default:
path := PathForTesting("default-dist.out")
- m.defaultDistPaths = Paths{path}
+ defaultDistPaths = Paths{path}
+ m.setOutputFiles(ctx, defaultDistPaths)
m.distFiles = MakeDefaultDistFiles(path)
case defaultDistFiles_Tagged:
// Module types that set AndroidMkEntry.DistFiles to the result of calling
// GenerateTaggedDistFiles(ctx) relied on no tag being treated as "" which
- // meant that the default dist paths would be whatever was returned by
- // OutputFiles(""). In order to preserve that behavior when treating no tag
- // as being equal to DefaultDistTag this ensures that
- // OutputFiles(DefaultDistTag) will return the same as OutputFiles("").
- m.defaultDistPaths = PathsForTesting("one.out")
+ // meant that the default dist paths would be the same as empty-string-tag
+ // output files. In order to preserve that behavior when treating no tag
+ // as being equal to DefaultDistTag this ensures that DefaultDistTag output
+ // will be the same as empty-string-tag output.
+ defaultDistPaths = PathsForTesting("one.out")
+ m.setOutputFiles(ctx, defaultDistPaths)
// This must be called after setting defaultDistPaths/outputFile as
- // GenerateTaggedDistFiles calls into OutputFiles(tag) which may use those
- // fields.
+ // GenerateTaggedDistFiles calls into outputFiles property which may use
+ // those fields.
m.distFiles = m.GenerateTaggedDistFiles(ctx)
}
}
+func (m *customModule) setOutputFiles(ctx ModuleContext, defaultDistPaths Paths) {
+ ctx.SetOutputFiles(PathsForTesting("one.out"), "")
+ ctx.SetOutputFiles(PathsForTesting("two.out", "three/four.out"), ".multiple")
+ ctx.SetOutputFiles(PathsForTesting("another.out"), ".another-tag")
+ if defaultDistPaths != nil {
+ ctx.SetOutputFiles(defaultDistPaths, DefaultDistTag)
+ }
+}
+
func (m *customModule) AndroidMk() AndroidMkData {
return AndroidMkData{
Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) {
@@ -102,25 +110,6 @@
}
}
-func (m *customModule) OutputFiles(tag string) (Paths, error) {
- switch tag {
- case DefaultDistTag:
- if m.defaultDistPaths != nil {
- return m.defaultDistPaths, nil
- } else {
- return nil, fmt.Errorf("default dist tag is not available")
- }
- case "":
- return PathsForTesting("one.out"), nil
- case ".multiple":
- return PathsForTesting("two.out", "three/four.out"), nil
- case ".another-tag":
- return PathsForTesting("another.out"), nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (m *customModule) AndroidMkEntries() []AndroidMkEntries {
return []AndroidMkEntries{
{
diff --git a/android/apex.go b/android/apex.go
index 683e501..ecab8e3 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -610,9 +610,15 @@
return ""
}
- // If this module has no apex variations the use the platform variation.
if len(apexInfos) == 0 {
- return ""
+ if ctx.IsAddingDependency() {
+ // If this module has no apex variations we can't do any mapping on the incoming variation, just return it
+ // and let the caller get a "missing variant" error.
+ return incomingVariation
+ } else {
+ // If this module has no apex variations the use the platform variation.
+ return ""
+ }
}
// Convert the list of apex infos into from the AllApexInfoProvider into the merged list
diff --git a/android/arch_list.go b/android/arch_list.go
index f4409a9..4233456 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -103,6 +103,7 @@
"kryo385",
"exynos-m1",
"exynos-m2",
+ "oryon",
},
X86: {},
X86_64: {},
diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go
index defbff0..bba4c0d 100644
--- a/android/buildinfo_prop.go
+++ b/android/buildinfo_prop.go
@@ -15,8 +15,6 @@
package android
import (
- "fmt"
-
"github.com/google/blueprint/proptools"
)
@@ -41,20 +39,10 @@
installPath InstallPath
}
-var _ OutputFileProducer = (*buildinfoPropModule)(nil)
-
func (p *buildinfoPropModule) installable() bool {
return proptools.BoolDefault(p.properties.Installable, true)
}
-// OutputFileProducer
-func (p *buildinfoPropModule) OutputFiles(tag string) (Paths, error) {
- if tag != "" {
- return nil, fmt.Errorf("unsupported tag %q", tag)
- }
- return Paths{p.outputFilePath}, nil
-}
-
func shouldAddBuildThumbprint(config Config) bool {
knownOemProperties := []string{
"ro.product.brand",
@@ -76,6 +64,8 @@
return
}
p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath
+ ctx.SetOutputFiles(Paths{p.outputFilePath}, "")
+
if !ctx.Config().KatiEnabled() {
WriteFileRule(ctx, p.outputFilePath, "# no buildinfo.prop if kati is disabled")
return
diff --git a/android/config.go b/android/config.go
index cda01f0..d16377d 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1055,6 +1055,22 @@
return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
}
+func (c *config) ExtraOtaKeys(ctx PathContext, recovery bool) []SourcePath {
+ var otaKeys []string
+ if recovery {
+ otaKeys = c.productVariables.ExtraOtaRecoveryKeys
+ } else {
+ otaKeys = c.productVariables.ExtraOtaKeys
+ }
+
+ otaPaths := make([]SourcePath, len(otaKeys))
+ for i, key := range otaKeys {
+ otaPaths[i] = PathForSource(ctx, key+".x509.pem")
+ }
+
+ return otaPaths
+}
+
func (c *config) BuildKeys() string {
defaultCert := String(c.productVariables.DefaultAppCertificate)
if defaultCert == "" || defaultCert == filepath.Join(testKeyDir, "testkey") {
diff --git a/android/container.go b/android/container.go
new file mode 100644
index 0000000..c4fdd9c
--- /dev/null
+++ b/android/container.go
@@ -0,0 +1,233 @@
+// Copyright 2024 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package android
+
+import (
+ "reflect"
+ "slices"
+
+ "github.com/google/blueprint"
+)
+
+type StubsAvailableModule interface {
+ IsStubsModule() bool
+}
+
+// Returns true if the dependency module is a stubs module
+var depIsStubsModule = func(_ ModuleContext, _, dep Module) bool {
+ if stubsModule, ok := dep.(StubsAvailableModule); ok {
+ return stubsModule.IsStubsModule()
+ }
+ return false
+}
+
+// Labels of exception functions, which are used to determine special dependencies that allow
+// otherwise restricted inter-container dependencies
+type exceptionHandleFuncLabel int
+
+const (
+ checkStubs exceptionHandleFuncLabel = iota
+)
+
+// Functions cannot be used as a value passed in providers, because functions are not
+// hashable. As a workaround, the exceptionHandleFunc enum values are passed using providers,
+// and the corresponding functions are called from this map.
+var exceptionHandleFunctionsTable = map[exceptionHandleFuncLabel]func(ModuleContext, Module, Module) bool{
+ checkStubs: depIsStubsModule,
+}
+
+type InstallableModule interface {
+ EnforceApiContainerChecks() bool
+}
+
+type restriction struct {
+ // container of the dependency
+ dependency *container
+
+ // Error message to be emitted to the user when the dependency meets this restriction
+ errorMessage string
+
+ // List of labels of allowed exception functions that allows bypassing this restriction.
+ // If any of the functions mapped to each labels returns true, this dependency would be
+ // considered allowed and an error will not be thrown.
+ allowedExceptions []exceptionHandleFuncLabel
+}
+type container struct {
+ // The name of the container i.e. partition, api domain
+ name string
+
+ // Map of dependency restricted containers.
+ restricted []restriction
+}
+
+var (
+ VendorContainer = &container{
+ name: VendorVariation,
+ restricted: nil,
+ }
+ SystemContainer = &container{
+ name: "system",
+ restricted: []restriction{
+ {
+ dependency: VendorContainer,
+ errorMessage: "Module belonging to the system partition other than HALs is " +
+ "not allowed to depend on the vendor partition module, in order to support " +
+ "independent development/update cycles and to support the Generic System " +
+ "Image. Try depending on HALs, VNDK or AIDL instead.",
+ allowedExceptions: []exceptionHandleFuncLabel{},
+ },
+ },
+ }
+ ProductContainer = &container{
+ name: ProductVariation,
+ restricted: []restriction{
+ {
+ dependency: VendorContainer,
+ errorMessage: "Module belonging to the product partition is not allowed to " +
+ "depend on the vendor partition module, as this may lead to security " +
+ "vulnerabilities. Try depending on the HALs or utilize AIDL instead.",
+ allowedExceptions: []exceptionHandleFuncLabel{},
+ },
+ },
+ }
+ ApexContainer = initializeApexContainer()
+ CtsContainer = &container{
+ name: "cts",
+ restricted: []restriction{
+ {
+ dependency: SystemContainer,
+ errorMessage: "CTS module should not depend on the modules belonging to the " +
+ "system partition, including \"framework\". Depending on the system " +
+ "partition may lead to disclosure of implementation details and regression " +
+ "due to API changes across platform versions. Try depending on the stubs instead.",
+ allowedExceptions: []exceptionHandleFuncLabel{checkStubs},
+ },
+ },
+ }
+)
+
+func initializeApexContainer() *container {
+ apexContainer := &container{
+ name: "apex",
+ restricted: []restriction{
+ {
+ dependency: SystemContainer,
+ errorMessage: "Module belonging to Apex(es) is not allowed to depend on the " +
+ "modules belonging to the system partition. Either statically depend on the " +
+ "module or convert the depending module to java_sdk_library and depend on " +
+ "the stubs.",
+ allowedExceptions: []exceptionHandleFuncLabel{checkStubs},
+ },
+ },
+ }
+
+ apexContainer.restricted = append(apexContainer.restricted, restriction{
+ dependency: apexContainer,
+ errorMessage: "Module belonging to Apex(es) is not allowed to depend on the " +
+ "modules belonging to other Apex(es). Either include the depending " +
+ "module in the Apex or convert the depending module to java_sdk_library " +
+ "and depend on its stubs.",
+ allowedExceptions: []exceptionHandleFuncLabel{checkStubs},
+ })
+
+ return apexContainer
+}
+
+type ContainersInfo struct {
+ belongingContainers []*container
+
+ belongingApexes []ApexInfo
+}
+
+func (c *ContainersInfo) BelongingContainers() []*container {
+ return c.belongingContainers
+}
+
+var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]()
+
+// Determines if the module can be installed in the system partition or not.
+// Logic is identical to that of modulePartition(...) defined in paths.go
+func installInSystemPartition(ctx ModuleContext) bool {
+ module := ctx.Module()
+ return !module.InstallInTestcases() &&
+ !module.InstallInData() &&
+ !module.InstallInRamdisk() &&
+ !module.InstallInVendorRamdisk() &&
+ !module.InstallInDebugRamdisk() &&
+ !module.InstallInRecovery() &&
+ !module.InstallInVendor() &&
+ !module.InstallInOdm() &&
+ !module.InstallInProduct() &&
+ determineModuleKind(module.base(), ctx.blueprintBaseModuleContext()) == platformModule
+}
+
+func generateContainerInfo(ctx ModuleContext) ContainersInfo {
+ inSystem := installInSystemPartition(ctx)
+ inProduct := ctx.Module().InstallInProduct()
+ inVendor := ctx.Module().InstallInVendor()
+ inCts := false
+ inApex := false
+
+ if m, ok := ctx.Module().(ImageInterface); ok {
+ inProduct = inProduct || m.ProductVariantNeeded(ctx)
+ inVendor = inVendor || m.VendorVariantNeeded(ctx)
+ }
+
+ props := ctx.Module().GetProperties()
+ for _, prop := range props {
+ val := reflect.ValueOf(prop).Elem()
+ if val.Kind() == reflect.Struct {
+ testSuites := val.FieldByName("Test_suites")
+ if testSuites.IsValid() && testSuites.Kind() == reflect.Slice && slices.Contains(testSuites.Interface().([]string), "cts") {
+ inCts = true
+ }
+ }
+ }
+
+ var belongingApexes []ApexInfo
+ if apexInfo, ok := ModuleProvider(ctx, AllApexInfoProvider); ok {
+ belongingApexes = apexInfo.ApexInfos
+ inApex = true
+ }
+
+ containers := []*container{}
+ if inSystem {
+ containers = append(containers, SystemContainer)
+ }
+ if inProduct {
+ containers = append(containers, ProductContainer)
+ }
+ if inVendor {
+ containers = append(containers, VendorContainer)
+ }
+ if inCts {
+ containers = append(containers, CtsContainer)
+ }
+ if inApex {
+ containers = append(containers, ApexContainer)
+ }
+
+ return ContainersInfo{
+ belongingContainers: containers,
+ belongingApexes: belongingApexes,
+ }
+}
+
+func setContainerInfo(ctx ModuleContext) {
+ if _, ok := ctx.Module().(InstallableModule); ok {
+ containersInfo := generateContainerInfo(ctx)
+ SetProvider(ctx, ContainersInfoProvider, containersInfo)
+ }
+}
diff --git a/android/image.go b/android/image.go
index c278dcd..0f03107 100644
--- a/android/image.go
+++ b/android/image.go
@@ -22,7 +22,7 @@
// VendorVariantNeeded should return true if the module needs a vendor variant (installed on the vendor image).
VendorVariantNeeded(ctx BaseModuleContext) bool
- // ProductVariantNeeded should return true if the module needs a product variant (unstalled on the product image).
+ // ProductVariantNeeded should return true if the module needs a product variant (installed on the product image).
ProductVariantNeeded(ctx BaseModuleContext) bool
// CoreVariantNeeded should return true if the module needs a core variant (installed on the system image).
diff --git a/android/license_metadata.go b/android/license_metadata.go
index 3fea029..8056189 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -45,8 +45,7 @@
}
var outputFiles Paths
- if outputFileProducer, ok := ctx.Module().(OutputFileProducer); ok {
- outputFiles, _ = outputFileProducer.OutputFiles("")
+ if outputFiles, err := outputFilesForModule(ctx, ctx.Module(), ""); err == nil {
outputFiles = PathsIfNonNil(outputFiles...)
}
diff --git a/android/module.go b/android/module.go
index 66f6e1b..dd56031 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1207,29 +1207,7 @@
continue
}
}
-
- // if the tagged dist file cannot be obtained from OutputFilesProvider,
- // fall back to use OutputFileProducer
- // TODO: remove this part after OutputFilesProvider fully replaces OutputFileProducer
- if outputFileProducer, ok := m.module.(OutputFileProducer); ok {
- // Call the OutputFiles(tag) method to get the paths associated with the tag.
- distFilesForTag, err := outputFileProducer.OutputFiles(tag)
- // If the tag was not supported and is not DefaultDistTag then it is an error.
- // Failing to find paths for DefaultDistTag is not an error. It just means
- // that the module type requires the legacy behavior.
- if err != nil && tag != DefaultDistTag {
- ctx.PropertyErrorf("dist.tag", "%s", err.Error())
- }
- distFiles = distFiles.addPathsForTag(tag, distFilesForTag...)
- } else if tag != DefaultDistTag {
- // If the tag was specified then it is an error if the module does not
- // implement OutputFileProducer because there is no other way of accessing
- // the paths for the specified tag.
- ctx.PropertyErrorf("dist.tag",
- "tag %s not supported because the module does not implement OutputFileProducer", tag)
- }
}
-
return distFiles
}
@@ -1746,7 +1724,11 @@
}
}
-func (m *ModuleBase) archModuleContextFactory(ctx blueprint.IncomingTransitionContext) archModuleContext {
+type archModuleContextFactoryContext interface {
+ Config() interface{}
+}
+
+func (m *ModuleBase) archModuleContextFactory(ctx archModuleContextFactoryContext) archModuleContext {
config := ctx.Config().(Config)
target := m.Target()
primaryArch := false
@@ -1775,6 +1757,8 @@
variables: make(map[string]string),
}
+ setContainerInfo(ctx)
+
m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic")
dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx)
@@ -2379,7 +2363,7 @@
// The name of the module.
moduleName string
- // The tag that will be passed to the module's OutputFileProducer.OutputFiles(tag) method.
+ // The tag that will be used to get the specific output file(s).
tag string
}
@@ -2433,14 +2417,7 @@
Srcs() Paths
}
-// A module that implements OutputFileProducer can be referenced from any property that is tagged with `android:"path"`
-// using the ":module" syntax or ":module{.tag}" syntax and provides a list of output files to be used as if they were
-// listed in the property.
-type OutputFileProducer interface {
- OutputFiles(tag string) (Paths, error)
-}
-
-// OutputFilesForModule returns the paths from an OutputFileProducer with the given tag. On error, including if the
+// OutputFilesForModule returns the output file paths with the given tag. On error, including if the
// module produced zero paths, it reports errors to the ctx and returns nil.
func OutputFilesForModule(ctx PathContext, module blueprint.Module, tag string) Paths {
paths, err := outputFilesForModule(ctx, module, tag)
@@ -2451,7 +2428,7 @@
return paths
}
-// OutputFileForModule returns the path from an OutputFileProducer with the given tag. On error, including if the
+// OutputFileForModule returns the output file paths with the given tag. On error, including if the
// module produced zero or multiple paths, it reports errors to the ctx and returns nil.
func OutputFileForModule(ctx PathContext, module blueprint.Module, tag string) Path {
paths, err := outputFilesForModule(ctx, module, tag)
@@ -2491,21 +2468,14 @@
if outputFilesFromProvider != nil || err != OutputFilesProviderNotSet {
return outputFilesFromProvider, err
}
- if outputFileProducer, ok := module.(OutputFileProducer); ok {
- paths, err := outputFileProducer.OutputFiles(tag)
- if err != nil {
- return nil, fmt.Errorf("failed to get output file from module %q at tag %q: %s",
- pathContextName(ctx, module), tag, err.Error())
- }
- return paths, nil
- } else if sourceFileProducer, ok := module.(SourceFileProducer); ok {
+ if sourceFileProducer, ok := module.(SourceFileProducer); ok {
if tag != "" {
- return nil, fmt.Errorf("module %q is a SourceFileProducer, not an OutputFileProducer, and so does not support tag %q", pathContextName(ctx, module), tag)
+ return nil, fmt.Errorf("module %q is a SourceFileProducer, which does not support tag %q", pathContextName(ctx, module), tag)
}
paths := sourceFileProducer.Srcs()
return paths, nil
} else {
- return nil, fmt.Errorf("module %q is not an OutputFileProducer or SourceFileProducer", pathContextName(ctx, module))
+ return nil, fmt.Errorf("module %q is not a SourceFileProducer or having valid output file for tag %q", pathContextName(ctx, module), tag)
}
}
@@ -2519,7 +2489,12 @@
var outputFiles OutputFilesInfo
fromProperty := false
- if mctx, isMctx := ctx.(ModuleContext); isMctx {
+ type OutputFilesProviderModuleContext interface {
+ OtherModuleProviderContext
+ Module() Module
+ }
+
+ if mctx, isMctx := ctx.(OutputFilesProviderModuleContext); isMctx {
if mctx.Module() != module {
outputFiles, _ = OtherModuleProvider(mctx, module, OutputFilesProvider)
} else {
@@ -2533,7 +2508,6 @@
// TODO: Add a check for skipped context
if outputFiles.isEmpty() {
- // TODO: Add a check for param module not having OutputFilesProvider set
return nil, OutputFilesProviderNotSet
}
diff --git a/android/module_test.go b/android/module_test.go
index 1f3db5c..922ea21 100644
--- a/android/module_test.go
+++ b/android/module_test.go
@@ -935,31 +935,54 @@
}
}
-type fakeBlueprintModule struct{}
-
-func (fakeBlueprintModule) Name() string { return "foo" }
-
-func (fakeBlueprintModule) GenerateBuildActions(blueprint.ModuleContext) {}
-
type sourceProducerTestModule struct {
- fakeBlueprintModule
- source Path
+ ModuleBase
+ props struct {
+ // A represents the source file
+ A string
+ }
}
-func (s sourceProducerTestModule) Srcs() Paths { return Paths{s.source} }
-
-type outputFileProducerTestModule struct {
- fakeBlueprintModule
- output map[string]Path
- error map[string]error
+func sourceProducerTestModuleFactory() Module {
+ module := &sourceProducerTestModule{}
+ module.AddProperties(&module.props)
+ InitAndroidModule(module)
+ return module
}
-func (o outputFileProducerTestModule) OutputFiles(tag string) (Paths, error) {
- return PathsIfNonNil(o.output[tag]), o.error[tag]
+func (s sourceProducerTestModule) GenerateAndroidBuildActions(ModuleContext) {}
+
+func (s sourceProducerTestModule) Srcs() Paths { return PathsForTesting(s.props.A) }
+
+type outputFilesTestModule struct {
+ ModuleBase
+ props struct {
+ // A represents the tag
+ A string
+ // B represents the output file for tag A
+ B string
+ }
+}
+
+func outputFilesTestModuleFactory() Module {
+ module := &outputFilesTestModule{}
+ module.AddProperties(&module.props)
+ InitAndroidModule(module)
+ return module
+}
+
+func (o outputFilesTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ if o.props.A != "" || o.props.B != "" {
+ ctx.SetOutputFiles(PathsForTesting(o.props.B), o.props.A)
+ }
+ // This is to simulate the case that some module uses an object to set its
+ // OutputFilesProvider, but the object itself is empty.
+ ctx.SetOutputFiles(Paths{}, "missing")
}
type pathContextAddMissingDependenciesWrapper struct {
PathContext
+ OtherModuleProviderContext
missingDeps []string
}
@@ -970,52 +993,87 @@
return module.Name()
}
+func (p *pathContextAddMissingDependenciesWrapper) Module() Module { return nil }
+
func TestOutputFileForModule(t *testing.T) {
testcases := []struct {
name string
- module blueprint.Module
+ bp string
tag string
- env map[string]string
- config func(*config)
expected string
missingDeps []string
+ env map[string]string
+ config func(*config)
}{
{
- name: "SourceFileProducer",
- module: &sourceProducerTestModule{source: PathForTesting("foo.txt")},
- expected: "foo.txt",
+ name: "SourceFileProducer",
+ bp: `spt_module {
+ name: "test_module",
+ a: "spt.txt",
+ }
+ `,
+ tag: "",
+ expected: "spt.txt",
},
{
- name: "OutputFileProducer",
- module: &outputFileProducerTestModule{output: map[string]Path{"": PathForTesting("foo.txt")}},
- expected: "foo.txt",
+ name: "OutputFileProviderEmptyStringTag",
+ bp: `oft_module {
+ name: "test_module",
+ a: "",
+ b: "empty.txt",
+ }
+ `,
+ tag: "",
+ expected: "empty.txt",
},
{
- name: "OutputFileProducer_tag",
- module: &outputFileProducerTestModule{output: map[string]Path{"foo": PathForTesting("foo.txt")}},
+ name: "OutputFileProviderTag",
+ bp: `oft_module {
+ name: "test_module",
+ a: "foo",
+ b: "foo.txt",
+ }
+ `,
tag: "foo",
expected: "foo.txt",
},
{
- name: "OutputFileProducer_AllowMissingDependencies",
+ name: "OutputFileAllowMissingDependencies",
+ bp: `oft_module {
+ name: "test_module",
+ }
+ `,
+ tag: "missing",
+ expected: "missing_output_file/test_module",
+ missingDeps: []string{"test_module"},
config: func(config *config) {
config.TestProductVariables.Allow_missing_dependencies = boolPtr(true)
},
- module: &outputFileProducerTestModule{},
- missingDeps: []string{"foo"},
- expected: "missing_output_file/foo",
},
}
+
for _, tt := range testcases {
- config := TestConfig(buildDir, tt.env, "", nil)
- if tt.config != nil {
- tt.config(config.config)
- }
- ctx := &pathContextAddMissingDependenciesWrapper{
- PathContext: PathContextForTesting(config),
- }
- got := OutputFileForModule(ctx, tt.module, tt.tag)
- AssertPathRelativeToTopEquals(t, "expected source path", tt.expected, got)
- AssertArrayString(t, "expected missing deps", tt.missingDeps, ctx.missingDeps)
+ t.Run(tt.name, func(t *testing.T) {
+ result := GroupFixturePreparers(
+ PrepareForTestWithDefaults,
+ FixtureRegisterWithContext(func(ctx RegistrationContext) {
+ ctx.RegisterModuleType("spt_module", sourceProducerTestModuleFactory)
+ ctx.RegisterModuleType("oft_module", outputFilesTestModuleFactory)
+ }),
+ FixtureWithRootAndroidBp(tt.bp),
+ ).RunTest(t)
+
+ config := TestConfig(buildDir, tt.env, tt.bp, nil)
+ if tt.config != nil {
+ tt.config(config.config)
+ }
+ ctx := &pathContextAddMissingDependenciesWrapper{
+ PathContext: PathContextForTesting(config),
+ OtherModuleProviderContext: result.TestContext.OtherModuleProviderAdaptor(),
+ }
+ got := OutputFileForModule(ctx, result.ModuleForTests("test_module", "").Module(), tt.tag)
+ AssertPathRelativeToTopEquals(t, "expected output path", tt.expected, got)
+ AssertArrayString(t, "expected missing deps", tt.missingDeps, ctx.missingDeps)
+ })
}
}
diff --git a/android/mutator.go b/android/mutator.go
index 440b906..b81dd12 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -400,6 +400,12 @@
Config() Config
DeviceConfig() DeviceConfig
+
+ // IsAddingDependency returns true if the transition is being called while adding a dependency
+ // after the transition mutator has already run, or false if it is being called when the transition
+ // mutator is running. This should be used sparingly, all uses will have to be removed in order
+ // to support creating variants on demand.
+ IsAddingDependency() bool
}
type OutgoingTransitionContext interface {
@@ -574,6 +580,10 @@
return DeviceConfig{c.bp.Config().(Config).deviceConfig}
}
+func (c *incomingTransitionContextImpl) IsAddingDependency() bool {
+ return c.bp.IsAddingDependency()
+}
+
func (c *incomingTransitionContextImpl) provider(provider blueprint.AnyProviderKey) (any, bool) {
return c.bp.Provider(provider)
}
diff --git a/android/neverallow.go b/android/neverallow.go
index 62c5e59..ef4b8b8 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -237,6 +237,7 @@
Without("name", "init_first_stage").
Without("name", "init_first_stage.microdroid").
With("install_in_root", "true").
+ NotModuleType("prebuilt_root").
Because("install_in_root is only for init_first_stage."),
}
}
diff --git a/android/packaging.go b/android/packaging.go
index ae412e1..c247ed2 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -17,6 +17,7 @@
import (
"fmt"
"path/filepath"
+ "sort"
"strings"
"github.com/google/blueprint"
@@ -377,31 +378,59 @@
// CopySpecsToDir is a helper that will add commands to the rule builder to copy the PackagingSpec
// entries into the specified directory.
func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir WritablePath) (entries []string) {
- if len(specs) == 0 {
+ dirsToSpecs := make(map[WritablePath]map[string]PackagingSpec)
+ dirsToSpecs[dir] = specs
+ return p.CopySpecsToDirs(ctx, builder, dirsToSpecs)
+}
+
+// CopySpecsToDirs is a helper that will add commands to the rule builder to copy the PackagingSpec
+// entries into corresponding directories.
+func (p *PackagingBase) CopySpecsToDirs(ctx ModuleContext, builder *RuleBuilder, dirsToSpecs map[WritablePath]map[string]PackagingSpec) (entries []string) {
+ empty := true
+ for _, specs := range dirsToSpecs {
+ if len(specs) > 0 {
+ empty = false
+ break
+ }
+ }
+ if empty {
return entries
}
+
seenDir := make(map[string]bool)
preparerPath := PathForModuleOut(ctx, "preparer.sh")
cmd := builder.Command().Tool(preparerPath)
var sb strings.Builder
sb.WriteString("set -e\n")
- for _, k := range SortedKeys(specs) {
- ps := specs[k]
- destPath := filepath.Join(dir.String(), ps.relPathInPackage)
- destDir := filepath.Dir(destPath)
- entries = append(entries, ps.relPathInPackage)
- if _, ok := seenDir[destDir]; !ok {
- seenDir[destDir] = true
- sb.WriteString(fmt.Sprintf("mkdir -p %s\n", destDir))
- }
- if ps.symlinkTarget == "" {
- cmd.Implicit(ps.srcPath)
- sb.WriteString(fmt.Sprintf("cp %s %s\n", ps.srcPath, destPath))
- } else {
- sb.WriteString(fmt.Sprintf("ln -sf %s %s\n", ps.symlinkTarget, destPath))
- }
- if ps.executable {
- sb.WriteString(fmt.Sprintf("chmod a+x %s\n", destPath))
+
+ dirs := make([]WritablePath, 0, len(dirsToSpecs))
+ for dir, _ := range dirsToSpecs {
+ dirs = append(dirs, dir)
+ }
+ sort.Slice(dirs, func(i, j int) bool {
+ return dirs[i].String() < dirs[j].String()
+ })
+
+ for _, dir := range dirs {
+ specs := dirsToSpecs[dir]
+ for _, k := range SortedKeys(specs) {
+ ps := specs[k]
+ destPath := filepath.Join(dir.String(), ps.relPathInPackage)
+ destDir := filepath.Dir(destPath)
+ entries = append(entries, ps.relPathInPackage)
+ if _, ok := seenDir[destDir]; !ok {
+ seenDir[destDir] = true
+ sb.WriteString(fmt.Sprintf("mkdir -p %s\n", destDir))
+ }
+ if ps.symlinkTarget == "" {
+ cmd.Implicit(ps.srcPath)
+ sb.WriteString(fmt.Sprintf("cp %s %s\n", ps.srcPath, destPath))
+ } else {
+ sb.WriteString(fmt.Sprintf("ln -sf %s %s\n", ps.symlinkTarget, destPath))
+ }
+ if ps.executable {
+ sb.WriteString(fmt.Sprintf("chmod a+x %s\n", destPath))
+ }
}
}
diff --git a/android/paths.go b/android/paths.go
index 03772eb..dda48dd 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -463,8 +463,8 @@
// - glob, relative to the local module directory, resolves as filepath(s), relative to the local
// source directory.
// - other modules using the ":name{.tag}" syntax. These modules must implement SourceFileProducer
-// or OutputFileProducer. These resolve as a filepath to an output filepath or generated source
-// filepath.
+// or set the OutputFilesProvider. These resolve as a filepath to an output filepath or generated
+// source filepath.
//
// Properties passed as the paths argument must have been annotated with struct tag
// `android:"path"` so that dependencies on SourceFileProducer modules will have already been handled by the
@@ -491,8 +491,8 @@
// - glob, relative to the local module directory, resolves as filepath(s), relative to the local
// source directory. Not valid in excludes.
// - other modules using the ":name{.tag}" syntax. These modules must implement SourceFileProducer
-// or OutputFileProducer. These resolve as a filepath to an output filepath or generated source
-// filepath.
+// or set the OutputFilesProvider. These resolve as a filepath to an output filepath or generated
+// source filepath.
//
// excluding the items (similarly resolved
// Properties passed as the paths argument must have been annotated with struct tag
@@ -620,8 +620,8 @@
// - glob, relative to the local module directory, resolves as filepath(s), relative to the local
// source directory. Not valid in excludes.
// - other modules using the ":name{.tag}" syntax. These modules must implement SourceFileProducer
-// or OutputFileProducer. These resolve as a filepath to an output filepath or generated source
-// filepath.
+// or set the OutputFilesProvider. These resolve as a filepath to an output filepath or generated
+// source filepath.
//
// and a list of the module names of missing module dependencies are returned as the second return.
// Properties passed as the paths argument must have been annotated with struct tag
diff --git a/android/paths_test.go b/android/paths_test.go
index 93b9b9a..941f0ca 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -1183,9 +1183,6 @@
Outs []string
Tagged []string
}
-
- outs Paths
- tagged Paths
}
func pathForModuleSrcOutputFileProviderModuleFactory() Module {
@@ -1196,24 +1193,17 @@
}
func (p *pathForModuleSrcOutputFileProviderModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ var outs, taggedOuts Paths
for _, out := range p.props.Outs {
- p.outs = append(p.outs, PathForModuleOut(ctx, out))
+ outs = append(outs, PathForModuleOut(ctx, out))
}
for _, tagged := range p.props.Tagged {
- p.tagged = append(p.tagged, PathForModuleOut(ctx, tagged))
+ taggedOuts = append(taggedOuts, PathForModuleOut(ctx, tagged))
}
-}
-func (p *pathForModuleSrcOutputFileProviderModule) OutputFiles(tag string) (Paths, error) {
- switch tag {
- case "":
- return p.outs, nil
- case ".tagged":
- return p.tagged, nil
- default:
- return nil, fmt.Errorf("unsupported tag %q", tag)
- }
+ ctx.SetOutputFiles(outs, "")
+ ctx.SetOutputFiles(taggedOuts, ".tagged")
}
type pathForModuleSrcTestCase struct {
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index d775ac3..6e4fc0c 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -15,7 +15,6 @@
package android
import (
- "fmt"
"testing"
"github.com/google/blueprint"
@@ -494,7 +493,6 @@
properties struct {
Srcs []string `android:"path,arch_variant"`
}
- src Path
}
func newPrebuiltModule() Module {
@@ -510,24 +508,17 @@
}
func (p *prebuiltModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ var src Path
if len(p.properties.Srcs) >= 1 {
- p.src = p.prebuilt.SingleSourcePath(ctx)
+ src = p.prebuilt.SingleSourcePath(ctx)
}
+ ctx.SetOutputFiles(Paths{src}, "")
}
func (p *prebuiltModule) Prebuilt() *Prebuilt {
return &p.prebuilt
}
-func (p *prebuiltModule) OutputFiles(tag string) (Paths, error) {
- switch tag {
- case "":
- return Paths{p.src}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
type sourceModuleProperties struct {
Deps []string `android:"path,arch_variant"`
}
diff --git a/android/sdk.go b/android/sdk.go
index 121470d..4bcbe2e 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -513,6 +513,9 @@
// SupportedLinkages returns the names of the linkage variants supported by this module.
SupportedLinkages() []string
+ // DisablesStrip returns true if the stripping needs to be disabled for this module.
+ DisablesStrip() bool
+
// ArePrebuiltsRequired returns true if prebuilts are required in the sdk snapshot, false
// otherwise.
ArePrebuiltsRequired() bool
@@ -618,6 +621,9 @@
// The names of linkage variants supported by this module.
SupportedLinkageNames []string
+ // StripDisabled returns true if the stripping needs to be disabled for this module.
+ StripDisabled bool
+
// When set to true BpPropertyNotRequired indicates that the member type does not require the
// property to be specifiable in an Android.bp file.
BpPropertyNotRequired bool
@@ -689,6 +695,10 @@
return b.SupportedLinkageNames
}
+func (b *SdkMemberTypeBase) DisablesStrip() bool {
+ return b.StripDisabled
+}
+
// registeredModuleExportsMemberTypes is the set of registered SdkMemberTypes for module_exports
// modules.
var registeredModuleExportsMemberTypes = &sdkRegistry{}
diff --git a/android/testing.go b/android/testing.go
index 18fd3b3..e39a1a7 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1018,31 +1018,21 @@
return normalizeStringMapRelativeToTop(m.config, m.module.VariablesForTests())
}
-// OutputFiles first checks if module base outputFiles property has any output
+// OutputFiles 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
+// 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: remove OutputFileProducer part
outputFiles := m.Module().base().outputFiles
if tag == "" && outputFiles.DefaultOutputFiles != nil {
return outputFiles.DefaultOutputFiles.RelativeToTop()
} else if taggedOutputFiles, hasTag := outputFiles.TaggedOutputFiles[tag]; hasTag {
- return taggedOutputFiles
+ return taggedOutputFiles.RelativeToTop()
}
- producer, ok := m.module.(OutputFileProducer)
- if !ok {
- t.Fatalf("%q must implement OutputFileProducer\n", m.module.Name())
- }
- paths, err := producer.OutputFiles(tag)
- if err != nil {
- t.Fatal(err)
- }
-
- return paths.RelativeToTop()
+ t.Fatal(fmt.Errorf("No test output file has been set for tag %q", tag))
+ return nil
}
// TestingSingleton is wrapper around an android.Singleton that provides methods to find information about individual
diff --git a/android/util.go b/android/util.go
index e21e66b..3c0af2f 100644
--- a/android/util.go
+++ b/android/util.go
@@ -201,6 +201,12 @@
return listsDiffer, diff1, diff2
}
+// Returns true if the two lists have common elements.
+func HasIntersection[T comparable](l1, l2 []T) bool {
+ _, a, b := ListSetDifference(l1, l2)
+ return len(a)+len(b) < len(setFromList(l1))+len(setFromList(l2))
+}
+
// Returns true if the given string s is prefixed with any string in the given prefix list.
func HasAnyPrefix(s string, prefixList []string) bool {
for _, prefix := range prefixList {
diff --git a/android/util_test.go b/android/util_test.go
index 8e73d83..6537d69 100644
--- a/android/util_test.go
+++ b/android/util_test.go
@@ -818,3 +818,52 @@
})
}
}
+
+var hasIntersectionTestCases = []struct {
+ name string
+ l1 []string
+ l2 []string
+ expected bool
+}{
+ {
+ name: "empty",
+ l1: []string{"a", "b", "c"},
+ l2: []string{},
+ expected: false,
+ },
+ {
+ name: "both empty",
+ l1: []string{},
+ l2: []string{},
+ expected: false,
+ },
+ {
+ name: "identical",
+ l1: []string{"a", "b", "c"},
+ l2: []string{"a", "b", "c"},
+ expected: true,
+ },
+ {
+ name: "duplicates",
+ l1: []string{"a", "a", "a"},
+ l2: []string{"a", "b", "c"},
+ expected: true,
+ },
+ {
+ name: "duplicates with no intersection",
+ l1: []string{"d", "d", "d", "d"},
+ l2: []string{"a", "b", "c"},
+ expected: false,
+ },
+}
+
+func TestHasIntersection(t *testing.T) {
+ for _, testCase := range hasIntersectionTestCases {
+ t.Run(testCase.name, func(t *testing.T) {
+ hasIntersection := HasIntersection(testCase.l1, testCase.l2)
+ if !reflect.DeepEqual(hasIntersection, testCase.expected) {
+ t.Errorf("expected %#v, got %#v", testCase.expected, hasIntersection)
+ }
+ })
+ }
+}
diff --git a/android/variable.go b/android/variable.go
index a331439..d144f7d 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -274,8 +274,10 @@
AAPTPreferredConfig *string `json:",omitempty"`
AAPTPrebuiltDPI []string `json:",omitempty"`
- DefaultAppCertificate *string `json:",omitempty"`
- MainlineSepolicyDevCertificates *string `json:",omitempty"`
+ DefaultAppCertificate *string `json:",omitempty"`
+ ExtraOtaKeys []string `json:",omitempty"`
+ ExtraOtaRecoveryKeys []string `json:",omitempty"`
+ MainlineSepolicyDevCertificates *string `json:",omitempty"`
AppsDefaultVersionName *string `json:",omitempty"`
diff --git a/apex/Android.bp b/apex/Android.bp
index abae9e2..17fdfc3 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -37,6 +37,7 @@
"apex_test.go",
"bootclasspath_fragment_test.go",
"classpath_element_test.go",
+ "container_test.go",
"dexpreopt_bootjars_test.go",
"platform_bootclasspath_test.go",
"systemserver_classpath_fragment_test.go",
diff --git a/apex/apex.go b/apex/apex.go
index f2dfb84..f9b30d4 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -157,8 +157,7 @@
// Default: true.
Installable *bool
- // If set true, VNDK libs are considered as stable libs and are not included in this APEX.
- // Should be only used in non-system apexes (e.g. vendor: true). Default is false.
+ // Deprecated. Do not use. TODO(b/350644693) remove this after removing all usage
Use_vndk_as_stable *bool
// The type of filesystem to use. Either 'ext4', 'f2fs' or 'erofs'. Default 'ext4'.
@@ -950,24 +949,6 @@
return
}
- // Special casing for APEXes on non-system (e.g., vendor, odm, etc.) partitions. They are
- // provided with a property named use_vndk_as_stable, which when set to true doesn't collect
- // VNDK libraries as transitive dependencies. This option is useful for reducing the size of
- // 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())
- if proptools.Bool(a.properties.Use_vndk_as_stable) {
- if !useVndk {
- mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
- }
- if a.minSdkVersionValue(mctx) != "" {
- mctx.PropertyErrorf("use_vndk_as_stable", "not supported when min_sdk_version is set")
- }
- if mctx.Failed() {
- return
- }
- }
-
continueApexDepsWalk := func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
@@ -985,10 +966,6 @@
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
// above.
return true
@@ -1386,7 +1363,7 @@
var _ cc.Coverage = (*apexBundle)(nil)
// Implements cc.Coverage
-func (a *apexBundle) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
+func (a *apexBundle) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
return ctx.DeviceConfig().NativeCoverageEnabled()
}
@@ -2118,20 +2095,10 @@
}
case testTag:
if ccTest, ok := child.(*cc.Module); ok {
- if ccTest.IsTestPerSrcAllTestsVariation() {
- // Multiple-output test module (where `test_per_src: true`).
- //
- // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
- // We do not add this variation to `filesInfo`, as it has no output;
- // however, we do add the other variations of this module as indirect
- // dependencies (see below).
- } else {
- // Single-output test module (where `test_per_src: false`).
- af := apexFileForExecutable(ctx, ccTest)
- af.class = nativeTest
- vctx.filesInfo = append(vctx.filesInfo, af)
- addAconfigFiles(vctx, ctx, child)
- }
+ af := apexFileForExecutable(ctx, ccTest)
+ af.class = nativeTest
+ vctx.filesInfo = append(vctx.filesInfo, af)
+ addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
@@ -2220,19 +2187,6 @@
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies
}
- } else if cc.IsTestPerSrcDepTag(depTag) {
- if ch, ok := child.(*cc.Module); ok {
- af := apexFileForExecutable(ctx, ch)
- // Handle modules created as `test_per_src` variations of a single test module:
- // use the name of the generated test binary (`fileToCopy`) instead of the name
- // of the original test module (`depName`, shared by all `test_per_src`
- // variations of that module).
- af.androidMkModuleName = filepath.Base(af.builtFile.String())
- // these are not considered transitive dep
- af.transitiveDep = false
- vctx.filesInfo = append(vctx.filesInfo, af)
- return true // track transitive dependencies
- }
} else if cc.IsHeaderDepTag(depTag) {
// nothing
} else if java.IsJniDepTag(depTag) {
@@ -2726,9 +2680,6 @@
if a.UsePlatformApis() {
ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
}
- if proptools.Bool(a.properties.Use_vndk_as_stable) {
- ctx.PropertyErrorf("use_vndk_as_stable", "updatable APEXes can't use external VNDK libs")
- }
if a.FutureUpdatable() {
ctx.PropertyErrorf("future_updatable", "Already updatable. Remove `future_updatable: true:`")
}
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index e6ebff2..a8d89b1 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -46,6 +46,9 @@
Command: "cat $out.rsp | xargs cat" +
// Only track non-external dependencies, i.e. those that end up in the binary
" | grep -v '(external)'" +
+ // Allowlist androidx deps
+ " | grep -v '^androidx\\.'" +
+ " | grep -v '^prebuilt_androidx\\.'" +
// Ignore comments in any of the files
" | grep -v '^#'" +
" | sort -u -f >$out",
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 34e7dee..a2dbbfc 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5728,7 +5728,6 @@
updatable: false,
tests: [
"mytest",
- "mytests",
],
}
@@ -5771,25 +5770,6 @@
"testdata/baz"
],
}
-
- cc_test {
- name: "mytests",
- gtest: false,
- srcs: [
- "mytest1.cpp",
- "mytest2.cpp",
- "mytest3.cpp",
- ],
- test_per_src: true,
- relative_install_path: "test",
- system_shared_libs: [],
- static_executable: true,
- stl: "none",
- data: [
- ":fg",
- ":fg2",
- ],
- }
`)
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
@@ -5803,11 +5783,6 @@
ensureContains(t, copyCmds, "image.apex/bin/test/baz")
ensureContains(t, copyCmds, "image.apex/bin/test/bar/baz")
- // Ensure that test deps built with `test_per_src` are copied into apex.
- ensureContains(t, copyCmds, "image.apex/bin/test/mytest1")
- ensureContains(t, copyCmds, "image.apex/bin/test/mytest2")
- ensureContains(t, copyCmds, "image.apex/bin/test/mytest3")
-
// Ensure the module is correctly translated.
bundle := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle)
data := android.AndroidMkDataForTest(t, ctx, bundle)
@@ -5817,9 +5792,6 @@
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
ensureContains(t, androidMk, "LOCAL_MODULE := mytest.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
}
@@ -8278,60 +8250,6 @@
`)
}
-func Test_use_vndk_as_stable_shouldnt_be_used_for_updatable_vendor_apexes(t *testing.T) {
- testApexError(t, `"myapex" .*: use_vndk_as_stable: updatable APEXes can't use external VNDK libs`, `
- apex {
- name: "myapex",
- key: "myapex.key",
- updatable: true,
- use_vndk_as_stable: true,
- soc_specific: true,
- }
-
- apex_key {
- name: "myapex.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
- `)
-}
-
-func Test_use_vndk_as_stable_shouldnt_be_used_with_min_sdk_version(t *testing.T) {
- testApexError(t, `"myapex" .*: use_vndk_as_stable: not supported when min_sdk_version is set`, `
- apex {
- name: "myapex",
- key: "myapex.key",
- updatable: false,
- min_sdk_version: "29",
- use_vndk_as_stable: true,
- vendor: true,
- }
-
- apex_key {
- name: "myapex.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
- `)
-}
-
-func Test_use_vndk_as_stable_shouldnt_be_used_for_non_vendor_apexes(t *testing.T) {
- testApexError(t, `"myapex" .*: use_vndk_as_stable: not supported for system/system_ext APEXes`, `
- apex {
- name: "myapex",
- key: "myapex.key",
- updatable: false,
- use_vndk_as_stable: true,
- }
-
- apex_key {
- name: "myapex.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
- `)
-}
-
func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) {
testApexError(t, `"mysystemserverclasspathfragment" .* it must not set generate_classpaths_proto to false`, `
apex {
diff --git a/apex/container_test.go b/apex/container_test.go
new file mode 100644
index 0000000..3931174
--- /dev/null
+++ b/apex/container_test.go
@@ -0,0 +1,329 @@
+// 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 apex
+
+import (
+ "android/soong/android"
+ "android/soong/java"
+ "fmt"
+ "testing"
+)
+
+var checkContainerMatch = func(t *testing.T, name string, container string, expected bool, actual bool) {
+ errorMessage := fmt.Sprintf("module %s container %s value differ", name, container)
+ android.AssertBoolEquals(t, errorMessage, expected, actual)
+}
+
+func TestApexDepsContainers(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForApexTest,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mybootclasspathlib"),
+ ).RunTestWithBp(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ bootclasspath_fragments: [
+ "mybootclasspathfragment",
+ ],
+ updatable: true,
+ min_sdk_version: "30",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ contents: [
+ "mybootclasspathlib",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+ java_sdk_library {
+ name: "mybootclasspathlib",
+ srcs: [
+ "mybootclasspathlib.java",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
+ static_libs: [
+ "foo",
+ "baz",
+ ],
+ libs: [
+ "bar",
+ ],
+ min_sdk_version: "30",
+ }
+ java_library {
+ name: "foo",
+ srcs:[
+ "A.java",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ min_sdk_version: "30",
+ }
+ java_library {
+ name: "bar",
+ srcs:[
+ "A.java",
+ ],
+ min_sdk_version: "30",
+ }
+ java_library {
+ name: "baz",
+ srcs:[
+ "A.java",
+ ],
+ apex_available: [
+ "//apex_available:platform",
+ "myapex",
+ ],
+ min_sdk_version: "30",
+ }
+ `)
+ testcases := []struct {
+ moduleName string
+ variant string
+ isSystemContainer bool
+ isApexContainer bool
+ }{
+ {
+ moduleName: "mybootclasspathlib",
+ variant: "android_common_myapex",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "mybootclasspathlib.impl",
+ variant: "android_common_apex30",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "mybootclasspathlib.stubs",
+ variant: "android_common",
+ isSystemContainer: true,
+ isApexContainer: false,
+ },
+ {
+ moduleName: "foo",
+ variant: "android_common_apex30",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "bar",
+ variant: "android_common",
+ isSystemContainer: true,
+ isApexContainer: false,
+ },
+ {
+ moduleName: "baz",
+ variant: "android_common_apex30",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ }
+
+ for _, c := range testcases {
+ m := result.ModuleForTests(c.moduleName, c.variant)
+ containers, _ := android.OtherModuleProvider(result.TestContext.OtherModuleProviderAdaptor(), m.Module(), android.ContainersInfoProvider)
+ belongingContainers := containers.BelongingContainers()
+ checkContainerMatch(t, c.moduleName, "system", c.isSystemContainer, android.InList(android.SystemContainer, belongingContainers))
+ checkContainerMatch(t, c.moduleName, "apex", c.isApexContainer, android.InList(android.ApexContainer, belongingContainers))
+ }
+}
+
+func TestNonUpdatableApexDepsContainers(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForApexTest,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mybootclasspathlib"),
+ ).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",
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ contents: [
+ "mybootclasspathlib",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+ java_sdk_library {
+ name: "mybootclasspathlib",
+ srcs: [
+ "mybootclasspathlib.java",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
+ static_libs: [
+ "foo",
+ ],
+ libs: [
+ "bar",
+ ],
+ }
+ java_library {
+ name: "foo",
+ srcs:[
+ "A.java",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ }
+ java_library {
+ name: "bar",
+ srcs:[
+ "A.java",
+ ],
+ }
+ `)
+ testcases := []struct {
+ moduleName string
+ variant string
+ isSystemContainer bool
+ isApexContainer bool
+ }{
+ {
+ moduleName: "mybootclasspathlib",
+ variant: "android_common_myapex",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "mybootclasspathlib.impl",
+ variant: "android_common_apex10000",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "mybootclasspathlib.stubs",
+ variant: "android_common",
+ isSystemContainer: true,
+ isApexContainer: false,
+ },
+ {
+ moduleName: "foo",
+ variant: "android_common_apex10000",
+ isSystemContainer: true,
+ isApexContainer: true,
+ },
+ {
+ moduleName: "bar",
+ variant: "android_common",
+ isSystemContainer: true,
+ isApexContainer: false,
+ },
+ }
+
+ for _, c := range testcases {
+ m := result.ModuleForTests(c.moduleName, c.variant)
+ containers, _ := android.OtherModuleProvider(result.TestContext.OtherModuleProviderAdaptor(), m.Module(), android.ContainersInfoProvider)
+ belongingContainers := containers.BelongingContainers()
+ checkContainerMatch(t, c.moduleName, "system", c.isSystemContainer, android.InList(android.SystemContainer, belongingContainers))
+ checkContainerMatch(t, c.moduleName, "apex", c.isApexContainer, android.InList(android.ApexContainer, belongingContainers))
+ }
+}
+
+func TestUpdatableAndNonUpdatableApexesIdenticalMinSdkVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForApexTest,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/myapex_non_updatable-file_contexts": nil,
+ "system/sepolicy/apex/myapex_updatable-file_contexts": nil,
+ }),
+ ).RunTestWithBp(t, `
+ apex {
+ name: "myapex_non_updatable",
+ key: "myapex_non_updatable.key",
+ java_libs: [
+ "foo",
+ ],
+ updatable: false,
+ min_sdk_version: "30",
+ }
+ apex_key {
+ name: "myapex_non_updatable.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ apex {
+ name: "myapex_updatable",
+ key: "myapex_updatable.key",
+ java_libs: [
+ "foo",
+ ],
+ updatable: true,
+ min_sdk_version: "30",
+ }
+ apex_key {
+ name: "myapex_updatable.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_library {
+ name: "foo",
+ srcs:[
+ "A.java",
+ ],
+ apex_available: [
+ "myapex_non_updatable",
+ "myapex_updatable",
+ ],
+ min_sdk_version: "30",
+ sdk_version: "current",
+ }
+ `)
+
+ fooApexVariant := result.ModuleForTests("foo", "android_common_apex30")
+ containers, _ := android.OtherModuleProvider(result.TestContext.OtherModuleProviderAdaptor(), fooApexVariant.Module(), android.ContainersInfoProvider)
+ belongingContainers := containers.BelongingContainers()
+ checkContainerMatch(t, "foo", "system", true, android.InList(android.SystemContainer, belongingContainers))
+ checkContainerMatch(t, "foo", "apex", true, android.InList(android.ApexContainer, belongingContainers))
+}
diff --git a/bin/afind b/bin/afind
new file mode 100755
index 0000000..080f06a
--- /dev/null
+++ b/bin/afind
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Copyright (C) 2022 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.
+
+dir=${1:-.}
+
+shift
+
+args=( $@ )
+if [[ ${#args[@]} -eq 0 ]] ; then
+ args=( -print )
+fi
+
+find "$dir" -name .repo -prune -o -name .git -prune -o -name out -prune -o ${args[@]}
+
+exit $?
diff --git a/bin/aninja b/bin/aninja
index cceb794..5acb968 100755
--- a/bin/aninja
+++ b/bin/aninja
@@ -20,6 +20,19 @@
require_top
require_lunch
+case $(uname -s) in
+ Darwin)
+ host_arch=darwin-x86
+ ;;
+ Linux)
+ host_arch=linux-x86
+ ;;
+ *)
+ >&2 echo Unknown host $(uname -s)
+ exit 1
+ ;;
+esac
+
cd $(gettop)
-prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@"
+prebuilts/build-tools/${host_arch}/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@"
diff --git a/cc/afdo.go b/cc/afdo.go
index 00b2245..6921edf 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -176,6 +176,9 @@
func (a *afdoTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ if !m.Enabled(ctx) {
+ return
+ }
if variation == "" {
// The empty variation is either a module that has enabled AFDO for itself, or the non-AFDO
// variant of a dependency.
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 143e86f..4134653 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -351,9 +351,6 @@
ctx.subAndroidMk(entries, test.testDecorator)
entries.Class = "NATIVE_TESTS"
- if Bool(test.Properties.Test_per_src) {
- entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
- }
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
if test.testConfig != nil {
entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
diff --git a/cc/cc.go b/cc/cc.go
index 24f6b83..740be3a 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -51,7 +51,6 @@
ctx.BottomUp("sdk", sdkMutator).Parallel()
ctx.BottomUp("llndk", llndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
- ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
})
@@ -799,7 +798,6 @@
dataLibDepTag = dependencyTag{name: "data lib"}
dataBinDepTag = dependencyTag{name: "data bin"}
runtimeDepTag = installDependencyTag{name: "runtime lib"}
- testPerSrcDepTag = dependencyTag{name: "test_per_src"}
stubImplDepTag = dependencyTag{name: "stub_impl"}
JniFuzzLibTag = dependencyTag{name: "jni_fuzz_lib_tag"}
FdoProfileTag = dependencyTag{name: "fdo_profile"}
@@ -826,11 +824,6 @@
return depTag == runtimeDepTag
}
-func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
- ccDepTag, ok := depTag.(dependencyTag)
- return ok && ccDepTag == testPerSrcDepTag
-}
-
// Module contains the properties and members used by all C/C++ module types, and implements
// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
// to construct the output file. Behavior can be customized with a Customizer, or "decorator",
@@ -1386,17 +1379,11 @@
}
func (c *Module) isCfi() bool {
- if sanitize := c.sanitize; sanitize != nil {
- return Bool(sanitize.Properties.SanitizeMutated.Cfi)
- }
- return false
+ return c.sanitize.isSanitizerEnabled(cfi)
}
func (c *Module) isFuzzer() bool {
- if sanitize := c.sanitize; sanitize != nil {
- return Bool(sanitize.Properties.SanitizeMutated.Fuzzer)
- }
- return false
+ return c.sanitize.isSanitizerEnabled(Fuzzer)
}
func (c *Module) isNDKStubLibrary() bool {
@@ -1786,11 +1773,6 @@
return nil
}
-func (c *Module) IsTestPerSrcAllTestsVariation() bool {
- test, ok := c.linker.(testPerSrc)
- return ok && test.isAllTestsVariation()
-}
-
func (c *Module) DataPaths() []android.DataPath {
if p, ok := c.installer.(interface {
dataPaths() []android.DataPath
@@ -1943,16 +1925,6 @@
TopLevelTarget: c.testModule,
})
- // Handle the case of a test module split by `test_per_src` mutator.
- //
- // The `test_per_src` mutator adds an extra variation named "", depending on all the other
- // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this
- // module and return early, as this module does not produce an output file per se.
- if c.IsTestPerSrcAllTestsVariation() {
- c.outputFile = android.OptionalPath{}
- return
- }
-
c.Properties.SubName = GetSubnameProperty(actx, c)
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
@@ -3758,14 +3730,12 @@
}
// Overrides ApexModule.IsInstallabeToApex()
-// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
+// Only shared/runtime libraries .
func (c *Module) IsInstallableToApex() bool {
if lib := c.library; lib != nil {
// Stub libs and prebuilt libs in a versioned SDK are not
// installable to APEX even though they are shared libs.
return lib.shared() && !lib.buildStubs()
- } else if _, ok := c.linker.(testPerSrc); ok {
- return true
}
return false
}
diff --git a/cc/cc_test_only_property_test.go b/cc/cc_test_only_property_test.go
index c14f34e..972e86b 100644
--- a/cc/cc_test_only_property_test.go
+++ b/cc/cc_test_only_property_test.go
@@ -78,38 +78,6 @@
}
}
-func TestTestOnlyValueWithTestPerSrcProp(t *testing.T) {
- t.Parallel()
- ctx := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, `
- // These should be test-only
- cc_test { name: "cc-test",
- gtest: false,
- test_per_src: true,
- srcs: ["foo_test.cpp"],
- test_options: { unit_test: false, },
- }
- `)
-
- // Ensure all variation of test-per-src tests are marked test-only.
- ctx.VisitAllModules(func(m blueprint.Module) {
- testOnly := false
- if provider, ok := android.OtherModuleProvider(ctx.TestContext.OtherModuleProviderAdaptor(), m, android.TestOnlyProviderKey); ok {
- if provider.TestOnly {
- testOnly = true
- }
- }
- if module, ok := m.(*Module); ok {
- if testModule, ok := module.installer.(*testBinary); ok {
- if !testOnly && *testModule.Properties.Test_per_src {
- t.Errorf("%v is not test-only but should be", m)
- }
- }
- }
- })
-}
-
func TestTestOnlyInTeamsProto(t *testing.T) {
t.Parallel()
ctx := android.GroupFixturePreparers(
diff --git a/cc/check.go b/cc/check.go
index 32d1f06..e3af3b2 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -45,7 +45,8 @@
ctx.PropertyErrorf(prop, "-Weverything is not allowed in Android.bp files. "+
"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.")
}
- } else if strings.HasPrefix(flag, "-target") || strings.HasPrefix(flag, "--target") {
+ } else if strings.HasPrefix(flag, "-target ") || strings.HasPrefix(flag, "--target ") ||
+ strings.HasPrefix(flag, "-target=") || strings.HasPrefix(flag, "--target=") {
ctx.PropertyErrorf(prop, "Bad flag: `%s`, use the correct target soong rule.", flag)
} else if strings.Contains(flag, " ") {
args := strings.Split(flag, " ")
@@ -63,6 +64,10 @@
if len(args) > 2 {
ctx.PropertyErrorf(prop, "`-mllvm` only takes one argument: `%s`", flag)
}
+ } else if args[0] == "-Xclang" {
+ if len(args) > 2 {
+ ctx.PropertyErrorf(prop, "`-Xclang` only takes one argument: `%s`", flag)
+ }
} else if strings.HasPrefix(flag, "-D") && strings.Contains(flag, "=") {
// Do nothing in this case.
// For now, we allow space characters in -DNAME=def form to allow use cases
diff --git a/cc/cmake_ext_add_aidl_library.txt b/cc/cmake_ext_add_aidl_library.txt
index aa3235e3..d5c134e 100644
--- a/cc/cmake_ext_add_aidl_library.txt
+++ b/cc/cmake_ext_add_aidl_library.txt
@@ -1,3 +1,12 @@
+if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "^(arm|aarch)")
+ set(PREBUILTS_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/prebuilts/host/linux_musl-arm64/bin")
+else()
+ set(PREBUILTS_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/prebuilts/host/linux-x86/bin")
+endif()
+if (NOT AIDL_BIN)
+ find_program(AIDL_BIN aidl REQUIRED HINTS "${PREBUILTS_BIN_DIR}")
+endif()
+
function(add_aidl_library NAME LANG AIDLROOT SOURCES AIDLFLAGS)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
cmake_policy(SET CMP0116 NEW)
diff --git a/cc/cmake_main.txt b/cc/cmake_main.txt
index f6e21a6..eeabf53 100644
--- a/cc/cmake_main.txt
+++ b/cc/cmake_main.txt
@@ -6,20 +6,12 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddAidlLibrary)
include(AppendCxxFlagsIfSupported)
+include(FindThreads)
if (NOT ANDROID_BUILD_TOP)
set(ANDROID_BUILD_TOP "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
-if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "^(arm|aarch)")
- set(PREBUILTS_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/prebuilts/host/linux_musl-arm64/bin")
-else()
- set(PREBUILTS_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/prebuilts/host/linux-x86/bin")
-endif()
-if (NOT AIDL_BIN)
- find_program(AIDL_BIN aidl REQUIRED HINTS "${PREBUILTS_BIN_DIR}")
-endif()
-
<<cflagsList .M.Name "_CFLAGS" .M.Properties.Cflags .M.Properties.Unportable_flags .M.Properties.Cflags_ignored>>
<<range .Pprop.SystemPackages ->>
@@ -29,6 +21,7 @@
add_subdirectory("${ANDROID_BUILD_TOP}/<<.>>" "<<.>>/build" EXCLUDE_FROM_ALL)
<<end>>
add_compile_options(${<<.M.Name>>_CFLAGS})
+link_libraries(${CMAKE_THREAD_LIBS_INIT})
<<range $moduleDir, $value := .ModuleDirs ->>
add_subdirectory(<<$moduleDir>>)
<<end>>
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index a5f8708..fb2924a 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -51,8 +51,10 @@
var cmakeExtAppendFlags string
var defaultUnportableFlags []string = []string{
+ "-Wno-c99-designator",
"-Wno-class-memaccess",
"-Wno-exit-time-destructors",
+ "-Winconsistent-missing-override",
"-Wno-inconsistent-missing-override",
"-Wreorder-init-list",
"-Wno-reorder-init-list",
@@ -67,6 +69,12 @@
"libc",
"libc++",
"libc++_static",
+ "libc++demangle",
+ "libc_musl",
+ "libc_musl_crtbegin_so",
+ "libc_musl_crtbegin_static",
+ "libc_musl_crtend",
+ "libc_musl_crtend_so",
"libdl",
"libm",
"prebuilt_libclang_rt.builtins",
@@ -89,8 +97,14 @@
}
type CmakeSnapshotProperties struct {
- // Modules to add to the snapshot package. Their dependencies are pulled in automatically.
- Modules []string
+ // Host modules to add to the snapshot package. Their dependencies are pulled in automatically.
+ Modules_host []string
+
+ // System modules to add to the snapshot package. Their dependencies are pulled in automatically.
+ Modules_system []string
+
+ // Vendor modules to add to the snapshot package. Their dependencies are pulled in automatically.
+ Modules_vendor []string
// Host prebuilts to bundle with the snapshot. These are tools needed to build outside Android.
Prebuilts []string
@@ -268,8 +282,14 @@
}
func (m *CmakeSnapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
+ deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
+ deviceSystemVariations := append(deviceVariations, blueprint.Variation{"image", ""})
+ deviceVendorVariations := append(deviceVariations, blueprint.Variation{"image", "vendor"})
hostVariations := ctx.Config().BuildOSTarget.Variations()
- ctx.AddVariationDependencies(hostVariations, cmakeSnapshotModuleTag, m.Properties.Modules...)
+
+ ctx.AddVariationDependencies(hostVariations, cmakeSnapshotModuleTag, m.Properties.Modules_host...)
+ ctx.AddVariationDependencies(deviceSystemVariations, cmakeSnapshotModuleTag, m.Properties.Modules_system...)
+ ctx.AddVariationDependencies(deviceVendorVariations, cmakeSnapshotModuleTag, m.Properties.Modules_vendor...)
if len(m.Properties.Prebuilts) > 0 {
prebuilts := append(m.Properties.Prebuilts, "libc++")
diff --git a/cc/cmake_snapshot_test.go b/cc/cmake_snapshot_test.go
index 8fca6c1..b6f4369 100644
--- a/cc/cmake_snapshot_test.go
+++ b/cc/cmake_snapshot_test.go
@@ -38,7 +38,9 @@
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
cc_cmake_snapshot {
name: "foo",
- modules: [],
+ modules_host: [],
+ modules_system: [],
+ modules_vendor: [],
prebuilts: ["libc++"],
include_sources: true,
}`)
@@ -65,7 +67,7 @@
result := android.GroupFixturePreparers(PrepareForIntegrationTestWithCc, xtra).RunTestWithBp(t, `
cc_cmake_snapshot {
name: "foo",
- modules: [
+ modules_system: [
"foo_binary",
],
include_sources: true,
@@ -99,7 +101,7 @@
cc_cmake_snapshot {
name: "foo",
- modules: [],
+ modules_system: [],
prebuilts: ["libc++"],
include_sources: true,
}`)
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index e5e95f3..6a5293f 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -29,8 +29,6 @@
// This is already the driver's Android default, but duplicated here (and
// below) for ease of experimentation with additional extensions.
"-march=rv64gcv_zba_zbb_zbs",
- // TODO: move to driver (https://github.com/google/android-riscv64/issues/111)
- "-mno-strict-align",
// TODO: remove when qemu V works (https://gitlab.com/qemu-project/qemu/-/issues/1976)
// (Note that we'll probably want to wait for berberis to be good enough
// that most people don't care about qemu's V performance either!)
diff --git a/cc/coverage.go b/cc/coverage.go
index f6092e4..a7618dd 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -23,26 +23,26 @@
)
var (
- clangCoverageHostLdFlags = []string{
- "-Wl,--no-as-needed",
- "-Wl,--wrap,open",
- }
- clangContinuousCoverageFlags = []string{
- "-mllvm",
- "-runtime-counter-relocation",
- }
- clangCoverageCFlags = []string{
- "-Wno-frame-larger-than=",
- }
- clangCoverageCommonFlags = []string{
- "-fcoverage-mapping",
- "-Wno-pass-failed",
- "-D__ANDROID_CLANG_COVERAGE__",
- }
- clangCoverageHWASanFlags = []string{
- "-mllvm",
- "-hwasan-globals=0",
- }
+ clangCoverageHostLdFlags = []string{
+ "-Wl,--no-as-needed",
+ "-Wl,--wrap,open",
+ }
+ clangContinuousCoverageFlags = []string{
+ "-mllvm",
+ "-runtime-counter-relocation",
+ }
+ clangCoverageCFlags = []string{
+ "-Wno-frame-larger-than=",
+ }
+ clangCoverageCommonFlags = []string{
+ "-fcoverage-mapping",
+ "-Wno-pass-failed",
+ "-D__ANDROID_CLANG_COVERAGE__",
+ }
+ clangCoverageHWASanFlags = []string{
+ "-mllvm",
+ "-hwasan-globals=0",
+ }
)
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
@@ -247,9 +247,19 @@
return properties
}
+type IsNativeCoverageNeededContext interface {
+ Config() android.Config
+ DeviceConfig() android.DeviceConfig
+ Device() bool
+}
+
+var _ IsNativeCoverageNeededContext = android.IncomingTransitionContext(nil)
+var _ IsNativeCoverageNeededContext = android.BaseModuleContext(nil)
+var _ IsNativeCoverageNeededContext = android.BottomUpMutatorContext(nil)
+
type UseCoverage interface {
android.Module
- IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool
+ IsNativeCoverageNeeded(ctx IsNativeCoverageNeededContext) bool
}
// Coverage is an interface for non-CC modules to implement to be mutated for coverage
diff --git a/cc/library.go b/cc/library.go
index 4373b46..560b1ae 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2220,8 +2220,12 @@
if variants[i] != "" || isLLNDK || isVendorPublicLibrary || isImportedApiLibrary {
// A stubs or LLNDK stubs variant.
c := m.(*Module)
- c.sanitize = nil
- c.stl = nil
+ if c.sanitize != nil {
+ c.sanitize.Properties.ForceDisable = true
+ }
+ if c.stl != nil {
+ c.stl.Properties.Stl = StringPtr("none")
+ }
c.Properties.PreventInstall = true
lib := moduleLibraryInterface(m)
isLatest := i == (len(versions) - 1)
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index a65b1ba..1f71c19 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -31,6 +31,7 @@
SupportsSdk: true,
HostOsDependent: true,
SupportedLinkageNames: []string{"shared"},
+ StripDisabled: true,
},
prebuiltModuleType: "cc_prebuilt_library_shared",
}
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 632c76d..85c3edf 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -184,10 +184,6 @@
return ""
}
-func (txt *llndkLibrariesTxtModule) OutputFiles(tag string) (android.Paths, error) {
- return android.Paths{txt.outputFile}, nil
-}
-
func llndkMutator(mctx android.BottomUpMutatorContext) {
m, ok := mctx.Module().(*Module)
if !ok {
diff --git a/cc/makevars.go b/cc/makevars.go
index 9d29aff..cd13965 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -138,7 +138,6 @@
ctx.Strict("CLANG_COVERAGE_HWASAN_FLAGS", strings.Join(clangCoverageHWASanFlags, " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(asanCflags, " "))
- ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", strings.Join(asanLdflags, " "))
ctx.Strict("HWADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(hwasanCflags, " "))
ctx.Strict("HWADDRESS_SANITIZER_GLOBAL_OPTIONS", strings.Join(hwasanGlobalOptions, ","))
diff --git a/cc/sanitize.go b/cc/sanitize.go
index d72d7d3..64a313b 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -36,7 +36,6 @@
asanCflags = []string{
"-fno-omit-frame-pointer",
}
- asanLdflags = []string{"-Wl,-u,__asan_preinit"}
// DO NOT ADD MLLVM FLAGS HERE! ADD THEM BELOW TO hwasanCommonFlags.
hwasanCflags = []string{
@@ -383,7 +382,19 @@
Sanitize SanitizeUserProps `android:"arch_variant"`
SanitizeMutated sanitizeMutatedProperties `blueprint:"mutated"`
- SanitizerEnabled bool `blueprint:"mutated"`
+ // ForceDisable is set by the version mutator to disable sanitization of stubs variants
+ ForceDisable bool `blueprint:"mutated"`
+
+ // SanitizerEnabled is set by begin() if any of the sanitize boolean properties are set after
+ // applying the logic that enables globally enabled sanitizers and disables any unsupported
+ // sanitizers.
+ // TODO(b/349906293): this has some unintuitive behavior. It is set in begin() before the sanitize
+ // mutator is run if any of the individual sanitizes properties are set, and then the individual
+ // sanitize properties are cleared in the non-sanitized variants, but this value is never cleared.
+ // That results in SanitizerEnabled being set in variants that have no sanitizers enabled, causing
+ // some of the sanitizer logic in flags() to be applied to the non-sanitized variant.
+ SanitizerEnabled bool `blueprint:"mutated"`
+
MinimalRuntimeDep bool `blueprint:"mutated"`
BuiltinsDep bool `blueprint:"mutated"`
UbsanRuntimeDep bool `blueprint:"mutated"`
@@ -455,6 +466,10 @@
s := &sanitize.Properties.SanitizeMutated
s.copyUserPropertiesToMutated(&sanitize.Properties.Sanitize)
+ if sanitize.Properties.ForceDisable {
+ return
+ }
+
// Don't apply sanitizers to NDK code.
if ctx.useSdk() {
s.Never = BoolPtr(true)
@@ -765,6 +780,10 @@
}
func (s *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
+ if s.Properties.ForceDisable {
+ return flags
+ }
+
if !s.Properties.SanitizerEnabled && !s.Properties.UbsanRuntimeDep {
return flags
}
@@ -777,16 +796,17 @@
flags.RequiredInstructionSet = "arm"
}
flags.Local.CFlags = append(flags.Local.CFlags, asanCflags...)
- flags.Local.LdFlags = append(flags.Local.LdFlags, asanLdflags...)
if Bool(sanProps.Writeonly) {
flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", "-asan-instrument-reads=0")
}
if ctx.Host() {
- // -nodefaultlibs (provided with libc++) prevents the driver from linking
- // libraries needed with -fsanitize=address. http://b/18650275 (WAI)
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--no-as-needed")
+ if !ctx.Darwin() { // ld64.lld doesn't know about '--no-as-needed'
+ // -nodefaultlibs (provided with libc++) prevents the driver from linking
+ // libraries needed with -fsanitize=address. http://b/18650275 (WAI)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--no-as-needed")
+ }
} else {
flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", "-asan-globals=0")
if ctx.bootstrap() {
@@ -1104,7 +1124,7 @@
if s == nil {
return false
}
- if proptools.Bool(s.Properties.SanitizeMutated.Never) {
+ if s.Properties.ForceDisable || proptools.Bool(s.Properties.SanitizeMutated.Never) {
return false
}
@@ -1329,7 +1349,7 @@
}
func (c *Module) SanitizeNever() bool {
- return Bool(c.sanitize.Properties.SanitizeMutated.Never)
+ return c.sanitize.Properties.ForceDisable || Bool(c.sanitize.Properties.SanitizeMutated.Never)
}
func (c *Module) IsSanitizerExplicitlyDisabled(t SanitizerType) bool {
@@ -1340,6 +1360,9 @@
func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) {
// Change this to PlatformSanitizable when/if non-cc modules support ubsan sanitizers.
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
+ if c.sanitize.Properties.ForceDisable {
+ return
+ }
isSanitizableDependencyTag := c.SanitizableDepTagChecker()
mctx.WalkDeps(func(child, parent android.Module) bool {
if !isSanitizableDependencyTag(mctx.OtherModuleDependencyTag(child)) {
@@ -1350,7 +1373,7 @@
if !ok || !d.static() {
return false
}
- if d.sanitize != nil {
+ if d.sanitize != nil && !d.sanitize.Properties.ForceDisable {
if enableMinimalRuntime(d.sanitize) {
// If a static dependency is built with the minimal runtime,
// make sure we include the ubsan minimal runtime.
@@ -1385,6 +1408,10 @@
if !c.Enabled(mctx) {
return
}
+ if c.sanitize.Properties.ForceDisable {
+ return
+ }
+
var sanitizers []string
var diagSanitizers []string
@@ -1899,7 +1926,3 @@
func (txt *sanitizerLibrariesTxtModule) SubDir() string {
return ""
}
-
-func (txt *sanitizerLibrariesTxtModule) OutputFiles(tag string) (android.Paths, error) {
- return android.Paths{txt.outputFile}, nil
-}
diff --git a/cc/test.go b/cc/test.go
index a96af31..f5bb761 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -15,11 +15,9 @@
package cc
import (
+ "github.com/google/blueprint/proptools"
"path/filepath"
"strconv"
- "strings"
-
- "github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/tradefed"
@@ -75,13 +73,9 @@
}
type TestBinaryProperties struct {
- // Create a separate binary for each source file. Useful when there is
- // global state that can not be torn down and reset between each test suite.
- Test_per_src *bool
-
// Disables the creation of a test-specific directory when used with
// relative_install_path. Useful if several tests need to be in the same
- // directory, but test_per_src doesn't work.
+ // directory.
No_named_install_directory *bool
// list of files or filegroup modules that provide data that should be installed alongside
@@ -174,86 +168,14 @@
return module.Init()
}
-type testPerSrc interface {
- testPerSrc() bool
- srcs() []string
- isAllTestsVariation() bool
- setSrc(string, string)
- unsetSrc()
-}
-
-func (test *testBinary) testPerSrc() bool {
- return Bool(test.Properties.Test_per_src)
-}
-
-func (test *testBinary) srcs() []string {
- return test.baseCompiler.Properties.Srcs
-}
-
func (test *testBinary) dataPaths() []android.DataPath {
return test.data
}
-func (test *testBinary) isAllTestsVariation() bool {
- stem := test.binaryDecorator.Properties.Stem
- return stem != nil && *stem == ""
-}
-
-func (test *testBinary) setSrc(name, src string) {
- test.baseCompiler.Properties.Srcs = []string{src}
- test.binaryDecorator.Properties.Stem = StringPtr(name)
-}
-
-func (test *testBinary) unsetSrc() {
- test.baseCompiler.Properties.Srcs = nil
- test.binaryDecorator.Properties.Stem = StringPtr("")
-}
-
func (test *testBinary) testBinary() bool {
return true
}
-var _ testPerSrc = (*testBinary)(nil)
-
-func TestPerSrcMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok {
- if test, ok := m.linker.(testPerSrc); ok {
- numTests := len(test.srcs())
- if test.testPerSrc() && numTests > 0 {
- if duplicate, found := android.CheckDuplicate(test.srcs()); found {
- mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
- return
- }
- testNames := make([]string, numTests)
- for i, src := range test.srcs() {
- testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
- }
- // In addition to creating one variation per test source file,
- // create an additional "all tests" variation named "", and have it
- // depends on all other test_per_src variations. This is useful to
- // create subsequent dependencies of a given module on all
- // test_per_src variations created above: by depending on
- // variation "", that module will transitively depend on all the
- // other test_per_src variations without the need to know their
- // name or even their number.
- testNames = append(testNames, "")
- tests := mctx.CreateLocalVariations(testNames...)
- allTests := tests[numTests]
- allTests.(*Module).linker.(testPerSrc).unsetSrc()
- // Prevent the "all tests" variation from being installable nor
- // exporting to Make, as it won't create any output file.
- allTests.(*Module).Properties.PreventInstall = true
- allTests.(*Module).Properties.HideFromMake = true
- for i, src := range test.srcs() {
- tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
- mctx.AddInterVariantDependency(testPerSrcDepTag, allTests, tests[i])
- }
- mctx.AliasVariation("")
- }
- }
- }
-}
-
type testDecorator struct {
LinkerProperties TestLinkerProperties
InstallerProperties TestInstallerProperties
@@ -382,10 +304,6 @@
}
moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.extraTestConfigs.Strings()...)
- if Bool(test.Properties.Test_per_src) {
- moduleInfoJSON.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
- }
-
moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
if len(test.InstallerProperties.Test_suites) > 0 {
diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go
index cfac7d7..93c50cd 100644
--- a/cmd/release_config/release_config_lib/flag_artifact.go
+++ b/cmd/release_config/release_config_lib/flag_artifact.go
@@ -116,20 +116,20 @@
if path != "" {
LoadMessage(path, ret)
} else {
- ret.FlagDeclarationArtifacts = []*rc_proto.FlagDeclarationArtifact{}
+ ret.FlagDeclarationArtifactList = []*rc_proto.FlagDeclarationArtifact{}
}
return ret
}
func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts(intermediates []*rc_proto.FlagDeclarationArtifacts) *rc_proto.FlagDeclarationArtifacts {
- ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifacts: []*rc_proto.FlagDeclarationArtifact{}}
+ ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifactList: []*rc_proto.FlagDeclarationArtifact{}}
for _, fa := range *fas {
- ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fa.GenerateFlagDeclarationArtifact())
+ ret.FlagDeclarationArtifactList = append(ret.FlagDeclarationArtifactList, fa.GenerateFlagDeclarationArtifact())
}
for _, fda := range intermediates {
- ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fda.FlagDeclarationArtifacts...)
+ ret.FlagDeclarationArtifactList = append(ret.FlagDeclarationArtifactList, fda.FlagDeclarationArtifactList...)
}
- slices.SortFunc(ret.FlagDeclarationArtifacts, func(a, b *rc_proto.FlagDeclarationArtifact) int {
+ slices.SortFunc(ret.FlagDeclarationArtifactList, func(a, b *rc_proto.FlagDeclarationArtifact) int {
return cmp.Compare(*a.Name, *b.Name)
})
return ret
diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go
index 6d71d93..adf0e62 100644
--- a/cmd/release_config/release_config_lib/release_config.go
+++ b/cmd/release_config/release_config_lib/release_config.go
@@ -192,6 +192,7 @@
workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL)
myDirsMap := make(map[int]bool)
+ myValueDirsMap := make(map[int]bool)
if isBuildPrefix && releasePlatformVersion != nil {
if MarshalValue(releasePlatformVersion.Value) != strings.ToUpper(config.Name) {
value := FlagValue{
@@ -226,6 +227,8 @@
config.PriorStagesMap[priorStage] = true
}
myDirsMap[contrib.DeclarationIndex] = true
+ // This path *could* provide a value for this release config.
+ myValueDirsMap[contrib.DeclarationIndex] = true
if config.AconfigFlagsOnly {
// AconfigFlagsOnly allows very very few build flag values, all of them are part of aconfig flags.
allowedFlags := map[string]bool{
@@ -243,10 +246,13 @@
if !ok {
return fmt.Errorf("Setting value for undefined flag %s in %s\n", name, value.path)
}
+ // Record that flag declarations from fa.DeclarationIndex were included in this release config.
myDirsMap[fa.DeclarationIndex] = true
+ // Do not set myValueDirsMap, since it just records that we *could* provide values here.
if fa.DeclarationIndex > contrib.DeclarationIndex {
// Setting location is to the left of declaration.
- return fmt.Errorf("Setting value for flag %s not allowed in %s\n", name, value.path)
+ return fmt.Errorf("Setting value for flag %s (declared in %s) not allowed in %s\n",
+ name, filepath.Dir(configs.ReleaseConfigMaps[fa.DeclarationIndex].path), value.path)
}
if isRoot && *fa.FlagDeclaration.Workflow != workflowManual {
// The "root" release config can only contain workflow: MANUAL flags.
@@ -273,10 +279,14 @@
releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.TrimSpace(strings.Join(myAconfigValueSets, " "))}}
directories := []string{}
+ valueDirectories := []string{}
for idx, confDir := range configs.configDirs {
if _, ok := myDirsMap[idx]; ok {
directories = append(directories, confDir)
}
+ if _, ok := myValueDirsMap[idx]; ok {
+ valueDirectories = append(valueDirectories, confDir)
+ }
}
// Now build the per-partition artifacts
@@ -316,6 +326,7 @@
AconfigValueSets: myAconfigValueSets,
Inherits: myInherits,
Directories: directories,
+ ValueDirectories: valueDirectories,
PriorStages: SortedMapKeys(config.PriorStagesMap),
}
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 73a7e87..d2de89a 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
@@ -137,7 +137,7 @@
unknownFields protoimpl.UnknownFields
// The artifacts
- FlagDeclarationArtifacts []*FlagDeclarationArtifact `protobuf:"bytes,1,rep,name=flag_declaration_artifacts,json=flagDeclarationArtifacts" json:"flag_declaration_artifacts,omitempty"`
+ FlagDeclarationArtifactList []*FlagDeclarationArtifact `protobuf:"bytes,1,rep,name=flag_declaration_artifact_list,json=flagDeclarationArtifactList" json:"flag_declaration_artifact_list,omitempty"`
}
func (x *FlagDeclarationArtifacts) Reset() {
@@ -172,9 +172,9 @@
return file_build_flags_declarations_proto_rawDescGZIP(), []int{1}
}
-func (x *FlagDeclarationArtifacts) GetFlagDeclarationArtifacts() []*FlagDeclarationArtifact {
+func (x *FlagDeclarationArtifacts) GetFlagDeclarationArtifactList() []*FlagDeclarationArtifact {
if x != nil {
- return x.FlagDeclarationArtifacts
+ return x.FlagDeclarationArtifactList
}
return nil
}
@@ -204,20 +204,20 @@
0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x6f,
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0xce, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52,
0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10,
- 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x93, 0x01, 0x0a, 0x1a, 0x66, 0x6c,
+ 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x9a, 0x01, 0x0a, 0x1a, 0x66, 0x6c,
0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61,
- 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x75, 0x0a, 0x1a, 0x66, 0x6c, 0x61, 0x67,
+ 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x7c, 0x0a, 0x1e, 0x66, 0x6c, 0x61, 0x67,
0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x72, 0x74,
- 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 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, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x72, 0x74,
- 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x18, 0x66, 0x6c, 0x61, 0x67, 0x44, 0x65, 0x63, 0x6c, 0x61,
- 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 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,
+ 0x69, 0x66, 0x61, 0x63, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
+ 0x32, 0x37, 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, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x1b, 0x66, 0x6c, 0x61, 0x67, 0x44,
+ 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61,
+ 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 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 (
@@ -240,7 +240,7 @@
}
var file_build_flags_declarations_proto_depIdxs = []int32{
2, // 0: android.release_config_proto.flag_declaration_artifact.workflow:type_name -> android.release_config_proto.workflow
- 0, // 1: android.release_config_proto.flag_declaration_artifacts.flag_declaration_artifacts:type_name -> android.release_config_proto.flag_declaration_artifact
+ 0, // 1: android.release_config_proto.flag_declaration_artifacts.flag_declaration_artifact_list:type_name -> android.release_config_proto.flag_declaration_artifact
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
diff --git a/cmd/release_config/release_config_proto/build_flags_declarations.proto b/cmd/release_config/release_config_proto/build_flags_declarations.proto
index e0cf099..233158e 100644
--- a/cmd/release_config/release_config_proto/build_flags_declarations.proto
+++ b/cmd/release_config/release_config_proto/build_flags_declarations.proto
@@ -71,5 +71,5 @@
message flag_declaration_artifacts {
// The artifacts
- repeated flag_declaration_artifact flag_declaration_artifacts = 1;
+ repeated flag_declaration_artifact flag_declaration_artifact_list = 1;
}
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 b246eb6..c63ea26 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
@@ -223,12 +223,18 @@
// The names of the release_config_artifacts from which we inherited.
// Included for reference only.
Inherits []string `protobuf:"bytes,5,rep,name=inherits" json:"inherits,omitempty"`
- // The release config directories used for this config.
+ // The release config directories used for this config. This includes
+ // directories that provide flag declarations, but do not provide any flag
+ // values specific to this release config.
// For example, "build/release".
Directories []string `protobuf:"bytes,6,rep,name=directories" json:"directories,omitempty"`
// Prior stage(s) for flag advancement (during development).
// Once a flag has met criteria in a prior stage, it can advance to this one.
PriorStages []string `protobuf:"bytes,7,rep,name=prior_stages,json=priorStages" json:"prior_stages,omitempty"`
+ // The release config directories that contribute directly to this release
+ // config. The listed directories contain at least a `release_config` message
+ // for this release config.
+ ValueDirectories []string `protobuf:"bytes,8,rep,name=value_directories,json=valueDirectories" json:"value_directories,omitempty"`
}
func (x *ReleaseConfigArtifact) Reset() {
@@ -312,6 +318,13 @@
return nil
}
+func (x *ReleaseConfigArtifact) GetValueDirectories() []string {
+ if x != nil {
+ return x.ValueDirectories
+ }
+ return nil
+}
+
type ReleaseConfigsArtifact struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -412,7 +425,7 @@
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,
+ 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x22, 0xdd,
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,
@@ -431,42 +444,44 @@
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,
+ 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63,
+ 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 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, 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, 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, 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,
+ 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 (
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 2f1715b..4dc84e9 100644
--- a/cmd/release_config/release_config_proto/build_flags_out.proto
+++ b/cmd/release_config/release_config_proto/build_flags_out.proto
@@ -82,13 +82,20 @@
// Included for reference only.
repeated string inherits = 5;
- // The release config directories used for this config.
+ // The release config directories used for this config. This includes
+ // directories that provide flag declarations, but do not provide any flag
+ // values specific to this release config.
// For example, "build/release".
repeated string directories = 6;
// Prior stage(s) for flag advancement (during development).
// Once a flag has met criteria in a prior stage, it can advance to this one.
repeated string prior_stages = 7;
+
+ // The release config directories that contribute directly to this release
+ // config. The listed directories contain at least a `release_config` message
+ // for this release config.
+ repeated string value_directories = 8;
}
message release_configs_artifact {
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index d44cf7e..201515f 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -527,7 +527,7 @@
return false
}
- if contains(global.SpeedApps, name) || contains(global.SystemServerApps, name) {
+ if contains(global.SystemServerApps, name) {
return false
}
diff --git a/docs/java.dot b/docs/java.dot
new file mode 100644
index 0000000..ad7628d
--- /dev/null
+++ b/docs/java.dot
@@ -0,0 +1,127 @@
+digraph java {
+ //rankdir="LR";
+ //splines="false";
+ //cluster=true;
+ //node [ ordering="in" ];
+ node [ shape="rect" style="rounded" color="blue" ];
+
+ {
+ rank="same";
+ lib_java_sources [ label="library\njava sources" group="lib" ];
+ lib2_java_sources [ label="library\njava sources" group="lib2" ];
+ app_java_sources [ label="app\njava sources" group="app" ];
+ }
+
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_java_classes [ label="library java\n.class files" ];
+ lib_java_headers [ label="library java\nheader .class files" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib_spacer [ style=invis width=4 ];
+ lib2_java_classes [ label="library java\n.class files" ];
+ lib2_java_headers [ label="library java\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib2_combined_classes [ label="combined library\n.class files" ];
+ lib2_combined_headers [ label="combined library\nheader .class files" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ lib2_spacer [ style=invis width=4 ];
+ app_java_classes [ label="app java\n.class files" ];
+ }
+ {
+ rank="same";
+ app_combined_classes [ label="combined app and library\n.class files" ];
+ }
+ {
+ rank="same";
+ app_dex [ label="app classes.dex files" ];
+ }
+
+
+ node [ shape="rect" style="" color="black" ];
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_turbine_action [ label="turbine" ];
+ lib_javac_action [ label="javac" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib2_turbine_action [ label="turbine" ];
+ lib2_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ lib2_combine_action [ label="merge_zips" ];
+ lib2_combine_headers_action [ label="merge_zips" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ app_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ app_combine_action [ label="merge_zips" ];
+ }
+ {
+ rank="same";
+ app_r8_action [ label="r8" ];
+ }
+
+ // library
+
+ lib_java_sources -> lib_turbine_action [ weight=100 ];
+ lib_turbine_action -> lib_java_headers [ weight=100 ];
+
+ lib_java_sources -> lib_javac_action [ weight=1000 ];
+ lib_javac_action -> lib_java_classes [ weight=100 ];
+
+ lib_java_headers -> lib_spacer [ style=invis ];
+
+ // library 2
+
+ lib_java_headers -> lib2_turbine_action [ weight=0 ];
+ lib2_java_sources -> lib2_turbine_action [ weight=100 ];
+ lib2_turbine_action -> lib2_java_headers [ weight=100 ];
+
+ lib_java_headers -> lib2_javac_action [ weight=0 ];
+ lib2_java_sources -> lib2_javac_action [ weight=1000 ];
+ lib2_javac_action ->lib2_java_classes [ weight=100 ];
+
+ lib_java_classes -> lib2_combine_action [ weight=0 ];
+ lib2_java_classes -> lib2_combine_action [ weight=100 ];
+ lib2_combine_action -> lib2_combined_classes [ weight=100 ];
+
+ lib_java_headers -> lib2_combine_headers_action [ weight=0 ];
+ lib2_java_headers -> lib2_combine_headers_action [ weight=100 ];
+ lib2_combine_headers_action -> lib2_combined_headers [ weight=100 ];
+
+ lib2_combined_headers -> lib2_spacer [ style=invis ];
+
+ // app
+
+ lib2_combined_headers -> app_javac_action [ weight=0 ];
+ app_java_sources -> app_javac_action [ weight=1000 ];
+ app_javac_action -> app_java_classes [ weight=100 ];
+
+ lib2_combined_classes -> app_combine_action [ weight=0 ];
+ app_java_classes -> app_combine_action [ weight=100 ];
+ app_combine_action -> app_combined_classes [ weight=100 ];
+
+ app_combined_classes -> app_r8_action;
+ app_r8_action -> app_dex [ weight=100 ];
+}
diff --git a/docs/kotlin.dot b/docs/kotlin.dot
new file mode 100644
index 0000000..7a23c16
--- /dev/null
+++ b/docs/kotlin.dot
@@ -0,0 +1,196 @@
+digraph java {
+ //rankdir="LR";
+ //splines="false";
+ //cluster=true;
+ ranksep="0.75 equally"
+ //node [ ordering="in" ];
+ node [ shape="rect" style="rounded" color="blue" ];
+ {
+ rank="same";
+ lib_java_sources [ label="library\njava sources" group="lib" ];
+ lib_kotlin_sources [ label="library\nkotlin sources" group="lib" ];
+ lib2_java_sources [ label="library\njava sources" group="lib2" ];
+ lib2_kotlin_sources [ label="library\nkotlin sources" group="lib2" ];
+ app_java_sources [ label="app\njava sources" group="app" ];
+ app_kotlin_sources [ label="app\nkotlin sources" group="app" ];
+ }
+
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_kotlin_classes [ label="library kotlin\n.class files" ];
+ lib_kotlin_headers [ label="library kotlin\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib_java_classes [ label="library java\n.class files" ];
+ lib_java_headers [ label="library java\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib_combined_classes [ label="combined library\n.class files" ];
+ lib_combined_headers [ label="combined library\nheader .class files" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib_spacer [ style=invis width=4 ];
+ lib2_kotlin_classes [ label="library kotlin\n.class files" ];
+ lib2_kotlin_headers [ label="library kotlin\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib2_java_classes [ label="library java\n.class files" ];
+ lib2_java_headers [ label="library java\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib2_combined_classes [ label="combined library\n.class files" ];
+ lib2_combined_headers [ label="combined library\nheader .class files" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ lib2_spacer [ style=invis width=4 ];
+ app_kotlin_classes [ label="app kotlin\n.class files" ];
+ app_kotlin_headers [ label="app kotlin\nheader .class files" ] }
+ {
+ rank="same";
+ app_java_classes [ label="app java\n.class files" ];
+ }
+ {
+ rank="same";
+ app_combined_classes [ label="combined app and library\n.class files" ];
+ }
+ {
+ rank="same";
+ app_dex [ label="app classes.dex files" ];
+ }
+
+
+ node [ shape="rect" style="" color="black" ];
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ lib_turbine_action [ label="turbine" ];
+ lib_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ lib_combine_action [ label="merge_zips" ];
+ lib_combine_headers_action [ label="merge_zips" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib2_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ lib2_turbine_action [ label="turbine" ];
+ lib2_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ lib2_combine_action [ label="merge_zips" ];
+ lib2_combine_headers_action [ label="merge_zips" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ app_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ app_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ app_combine_action [ label="merge_zips" ];
+ }
+ {
+ rank="same";
+ app_r8_action [ label="r8" ];
+ }
+
+ // library
+
+ lib_kotlin_sources -> lib_kotlinc_action [ weight=100 ];
+ lib_java_sources -> lib_kotlinc_action;
+ lib_kotlinc_action -> lib_kotlin_classes, lib_kotlin_headers [ weight=100 ];
+
+ lib_kotlin_headers -> lib_turbine_action [ weight=0 ];
+ lib_java_sources -> lib_turbine_action [ weight=100 ];
+ lib_turbine_action -> lib_java_headers [ weight=100 ];
+
+ lib_kotlin_headers -> lib_javac_action [ weight=0 ];
+ lib_java_sources -> lib_javac_action [ weight=1000 ];
+ lib_javac_action -> lib_java_classes [ weight=100 ];
+
+ lib_kotlin_classes -> lib_combine_action [ weight = 0 ];
+ lib_java_classes -> lib_combine_action [ weight = 100 ];
+ lib_combine_action -> lib_combined_classes [ weight=100 ];
+
+ lib_kotlin_headers -> lib_combine_headers_action [ weight = 0 ];
+ lib_java_headers -> lib_combine_headers_action [ weight = 100 ];
+ lib_combine_headers_action -> lib_combined_headers [ weight=100 ];
+
+ lib_combined_headers -> lib_spacer [ style=invis ];
+
+ // library 2
+
+ lib_combined_headers -> lib2_kotlinc_action [ weight=0 ];
+ lib2_kotlin_sources -> lib2_kotlinc_action [ weight=100 ];
+ lib2_java_sources -> lib2_kotlinc_action;
+ lib2_kotlinc_action -> lib2_kotlin_classes, lib2_kotlin_headers [ weight=100 ];
+
+ lib_combined_headers -> lib2_turbine_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_turbine_action [ weight=0 ];
+ lib2_java_sources -> lib2_turbine_action [ weight=100 ];
+ lib2_turbine_action -> lib2_java_headers [ weight=100 ];
+
+ lib_combined_headers -> lib2_javac_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_javac_action [ weight=0 ];
+ lib2_java_sources -> lib2_javac_action [ weight=1000 ];
+ lib2_javac_action ->lib2_java_classes [ weight=100 ];
+
+ lib_combined_classes -> lib2_combine_action [ weight=0 ];
+ lib2_kotlin_classes -> lib2_combine_action [ weight=0 ];
+ lib2_java_classes -> lib2_combine_action [ weight=100 ];
+ lib2_combine_action -> lib2_combined_classes [ weight=100 ];
+
+ lib_combined_headers -> lib2_combine_headers_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_combine_headers_action [ weight=0 ];
+ lib2_java_headers -> lib2_combine_headers_action [ weight=100 ];
+ lib2_combine_headers_action -> lib2_combined_headers [ weight=100 ];
+
+ lib2_combined_headers -> lib2_spacer [ style=invis ];
+
+ // app
+
+ lib2_combined_headers -> app_kotlinc_action [ weight=0 ];
+ app_kotlin_sources -> app_kotlinc_action [ weight=100 ];
+ app_java_sources -> app_kotlinc_action;
+ app_kotlinc_action -> app_kotlin_headers, app_kotlin_classes [ weight=100 ];
+
+ lib2_combined_headers -> app_javac_action [ weight=0 ];
+ app_kotlin_headers -> app_javac_action [ weight=0 ];
+ app_java_sources -> app_javac_action [ weight=1000 ];
+ app_javac_action -> app_java_classes [ weight=100 ];
+
+ lib2_combined_classes -> app_combine_action [ weight=0 ];
+ app_kotlin_classes -> app_combine_action [ weight=0 ];
+ app_java_classes -> app_combine_action [ weight=100 ];
+ app_combine_action -> app_combined_classes [ weight=100 ];
+
+ app_combined_classes -> app_r8_action;
+ app_r8_action -> app_dex [ weight=100 ];
+}
diff --git a/docs/kotlin_with_annotation_processors.dot b/docs/kotlin_with_annotation_processors.dot
new file mode 100644
index 0000000..70c9bf3
--- /dev/null
+++ b/docs/kotlin_with_annotation_processors.dot
@@ -0,0 +1,277 @@
+digraph java {
+ //rankdir="LR";
+ //splines="false";
+ //cluster=true;
+ ranksep="0.75 equally"
+ //node [ ordering="in" ];
+ node [ shape="rect" style="rounded" color="blue" ];
+ {
+ rank="same";
+ lib_java_sources [ label="library\njava sources" group="lib" ];
+ lib_kotlin_sources [ label="library\nkotlin sources" group="lib" ];
+ lib2_java_sources [ label="library\njava sources" group="lib2" ];
+ lib2_kotlin_sources [ label="library\nkotlin sources" group="lib2" ];
+ app_java_sources [ label="app\njava sources" group="app" ];
+ app_kotlin_sources [ label="app\nkotlin sources" group="app" ];
+ }
+
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_kotlin_stubs [ label="library\nkotlin stubs" ];
+ }
+ {
+ rank="same";
+ lib_apt_src_jar [ label="library annotation\nprocessor sources" ];
+ }
+ {
+ rank="same";
+ lib_kotlin_classes [ label="library kotlin\n.class files" ];
+ lib_kotlin_headers [ label="library kotlin\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib_java_classes [ label="library java\n.class files" ];
+ lib_java_headers [ label="library java\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib_combined_classes [ label="combined library\n.class files" ];
+ lib_combined_headers [ label="combined library\nheader .class files" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib_spacer [ style=invis width=4 ];
+ lib2_kotlin_stubs [ label="library\nkotlin stubs" ];
+ }
+ {
+ rank="same";
+ lib2_apt_src_jar [ label="library annotation\nprocessor sources" ];
+ }
+ {
+ rank="same";
+ lib2_kotlin_classes [ label="library kotlin\n.class files" ];
+ lib2_kotlin_headers [ label="library kotlin\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib2_java_classes [ label="library java\n.class files" ];
+ lib2_java_headers [ label="library java\nheader .class files" ];
+ }
+ {
+ rank="same";
+ lib2_combined_classes [ label="combined library\n.class files" ];
+ lib2_combined_headers [ label="combined library\nheader .class files" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ lib2_spacer [ style=invis width=4 ];
+ app_kotlin_stubs [ label="app\nkotlin stubs" ];
+ }
+ {
+ rank="same";
+ app_apt_src_jar [ label="app annotation\nprocessor sources" ];
+ }
+ {
+ rank="same";
+ app_kotlin_classes [ label="app kotlin\n.class files" ];
+ app_kotlin_headers [ label="app kotlin\nheader .class files" ] }
+ {
+ rank="same";
+ app_java_classes [ label="app java\n.class files" ];
+ }
+ {
+ rank="same";
+ app_combined_classes [ label="combined app and library\n.class files" ];
+ }
+ {
+ rank="same";
+ app_dex [ label="app classes.dex files" ];
+ }
+
+
+ node [ shape="rect" style="" color="black" ];
+ node [ group="lib"];
+ {
+ rank="same";
+ lib_kapt_action [ label="kapt" ];
+ }
+ {
+ rank="same";
+ lib_turbine_apt_action [ label="turbine apt" ];
+ }
+ {
+ rank="same";
+ lib_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ lib_turbine_action [ label="turbine" ];
+ lib_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ lib_combine_action [ label="merge_zips" ];
+ lib_combine_headers_action [ label="merge_zips" ];
+ }
+
+ node [ group="lib2"];
+ {
+ rank="same";
+ lib2_kapt_action [ label="kapt" ];
+ }
+ {
+ rank="same";
+ lib2_turbine_apt_action [ label="turbine apt" ];
+ }
+ {
+ rank="same";
+ lib2_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ lib2_turbine_action [ label="turbine" ];
+ lib2_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ lib2_combine_action [ label="merge_zips" ];
+ lib2_combine_headers_action [ label="merge_zips" ];
+ }
+
+ node [ group="app"];
+ {
+ rank="same";
+ app_kapt_action [ label="kapt" ];
+ }
+ {
+ rank="same";
+ app_turbine_apt_action [ label="turbine apt" ];
+ }
+ {
+ rank="same";
+ app_kotlinc_action [ label="kotlinc" ];
+ }
+ {
+ rank="same";
+ app_javac_action [ label="javac" ];
+ }
+ {
+ rank="same";
+ app_combine_action [ label="merge_zips" ];
+ }
+ {
+ rank="same";
+ app_r8_action [ label="r8" ];
+ }
+
+ // library
+
+ lib_kotlin_sources -> lib_kapt_action [ weight=0 ];
+ lib_java_sources -> lib_kapt_action;
+ lib_kapt_action -> lib_kotlin_stubs [ weight=100 ];
+
+ lib_kotlin_stubs -> lib_turbine_apt_action [ weight=100 ];
+ lib_turbine_apt_action -> lib_apt_src_jar [ weight=100 ];
+
+ lib_apt_src_jar -> lib_kotlinc_action [ weight=0 ];
+ lib_kotlin_sources -> lib_kotlinc_action [ weight=100 ];
+ lib_java_sources -> lib_kotlinc_action;
+ lib_kotlinc_action -> lib_kotlin_classes, lib_kotlin_headers [ weight=100 ];
+
+ lib_apt_src_jar -> lib_turbine_action [ weight=0 ];
+ lib_kotlin_headers -> lib_turbine_action [ weight=0 ];
+ lib_java_sources -> lib_turbine_action [ weight=100 ];
+ lib_turbine_action -> lib_java_headers [ weight=100 ];
+
+ lib_apt_src_jar -> lib_javac_action [ weight=0 ];
+ lib_kotlin_headers -> lib_javac_action [ weight=0 ];
+ lib_java_sources -> lib_javac_action [ weight=1000 ];
+ lib_javac_action -> lib_java_classes [ weight=100 ];
+
+ lib_kotlin_classes -> lib_combine_action [ weight = 0 ];
+ lib_java_classes -> lib_combine_action [ weight = 100 ];
+ lib_combine_action -> lib_combined_classes [ weight=100 ];
+
+ lib_kotlin_headers -> lib_combine_headers_action [ weight = 0 ];
+ lib_java_headers -> lib_combine_headers_action [ weight = 100 ];
+ lib_combine_headers_action -> lib_combined_headers [ weight=100 ];
+
+ lib_combined_headers -> lib_spacer [ style=invis ];
+
+ // library 2
+
+ lib_combined_headers -> lib2_kapt_action [ weight=0 ];
+ lib2_kotlin_sources -> lib2_kapt_action [ weight=0 ];
+ lib2_java_sources -> lib2_kapt_action;
+ lib2_kapt_action -> lib2_kotlin_stubs [ weight=100 ];
+
+ lib_combined_headers -> lib2_turbine_apt_action [ weight=0 ];
+ lib2_kotlin_stubs -> lib2_turbine_apt_action [ weight=100 ];
+ lib2_turbine_apt_action -> lib2_apt_src_jar [ weight=100 ];
+
+ lib_combined_headers -> lib2_kotlinc_action [ weight=0 ];
+ lib2_apt_src_jar -> lib2_kotlinc_action [ weight=0 ];
+ lib2_kotlin_sources -> lib2_kotlinc_action [ weight=100 ];
+ lib2_java_sources -> lib2_kotlinc_action;
+ lib2_kotlinc_action -> lib2_kotlin_classes, lib2_kotlin_headers [ weight=100 ];
+
+ lib_combined_headers -> lib2_turbine_action [ weight=0 ];
+ lib2_apt_src_jar -> lib2_turbine_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_turbine_action [ weight=0 ];
+ lib2_java_sources -> lib2_turbine_action [ weight=100 ];
+ lib2_turbine_action -> lib2_java_headers [ weight=100 ];
+
+ lib_combined_headers -> lib2_javac_action [ weight=0 ];
+ lib2_apt_src_jar -> lib2_javac_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_javac_action [ weight=0 ];
+ lib2_java_sources -> lib2_javac_action [ weight=1000 ];
+ lib2_javac_action ->lib2_java_classes [ weight=100 ];
+
+ lib_combined_classes -> lib2_combine_action [ weight=0 ];
+ lib2_kotlin_classes -> lib2_combine_action [ weight=0 ];
+ lib2_java_classes -> lib2_combine_action [ weight=100 ];
+ lib2_combine_action -> lib2_combined_classes [ weight=100 ];
+
+ lib_combined_headers -> lib2_combine_headers_action [ weight=0 ];
+ lib2_kotlin_headers -> lib2_combine_headers_action [ weight=0 ];
+ lib2_java_headers -> lib2_combine_headers_action [ weight=100 ];
+ lib2_combine_headers_action -> lib2_combined_headers [ weight=100 ];
+
+ lib2_combined_headers -> lib2_spacer [ style=invis ];
+
+ // app
+
+ lib2_combined_headers -> app_kapt_action [ weight=0 ];
+ app_kotlin_sources -> app_kapt_action [ weight=0 ];
+ app_java_sources -> app_kapt_action;
+ app_kapt_action -> app_kotlin_stubs [ weight=100 ];
+
+ lib2_combined_headers -> app_turbine_apt_action [ weight=0 ];
+ app_kotlin_stubs -> app_turbine_apt_action [ weight=100 ];
+ app_turbine_apt_action -> app_apt_src_jar [ weight=100 ];
+
+ lib2_combined_headers -> app_kotlinc_action [ weight=0 ];
+ app_apt_src_jar -> app_kotlinc_action [ weight=0 ];
+ app_kotlin_sources -> app_kotlinc_action [ weight=100 ];
+ app_java_sources -> app_kotlinc_action;
+ app_kotlinc_action -> app_kotlin_headers, app_kotlin_classes [ weight=100 ];
+
+ lib2_combined_headers -> app_javac_action [ weight=0 ];
+ app_apt_src_jar -> app_javac_action [ weight=0 ];
+ app_kotlin_headers -> app_javac_action [ weight=0 ];
+ app_java_sources -> app_javac_action [ weight=1000 ];
+ app_javac_action -> app_java_classes [ weight=100 ];
+
+ lib2_combined_classes -> app_combine_action [ weight=0 ];
+ app_kotlin_classes -> app_combine_action [ weight=0 ];
+ app_java_classes -> app_combine_action [ weight=100 ];
+ app_combine_action -> app_combined_classes [ weight=100 ];
+
+ app_combined_classes -> app_r8_action;
+ app_r8_action -> app_dex [ weight=100 ];
+}
diff --git a/etc/Android.bp b/etc/Android.bp
index 97788e4..f02c12a 100644
--- a/etc/Android.bp
+++ b/etc/Android.bp
@@ -11,8 +11,9 @@
"soong-android",
],
srcs: [
- "prebuilt_etc.go",
"install_symlink.go",
+ "otacerts_zip.go",
+ "prebuilt_etc.go",
],
testSrcs: [
"prebuilt_etc_test.go",
diff --git a/etc/otacerts_zip.go b/etc/otacerts_zip.go
new file mode 100644
index 0000000..b6f175a
--- /dev/null
+++ b/etc/otacerts_zip.go
@@ -0,0 +1,146 @@
+// 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 etc
+
+import (
+ "android/soong/android"
+
+ "github.com/google/blueprint/proptools"
+)
+
+func init() {
+ RegisterOtacertsZipBuildComponents(android.InitRegistrationContext)
+}
+
+func RegisterOtacertsZipBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("otacerts_zip", otacertsZipFactory)
+}
+
+type otacertsZipProperties struct {
+ // Make this module available when building for recovery.
+ // Only the recovery partition is available.
+ Recovery_available *bool
+
+ // Optional subdirectory under which the zip file is installed into.
+ Relative_install_path *string
+
+ // Optional name for the installed file. If unspecified, otacerts.zip is used.
+ Filename *string
+}
+
+type otacertsZipModule struct {
+ android.ModuleBase
+
+ properties otacertsZipProperties
+ outputPath android.OutputPath
+}
+
+// otacerts_zip collects key files defined in PRODUCT_DEFAULT_DEV_CERTIFICATE
+// and PRODUCT_EXTRA_OTA_KEYS for system or PRODUCT_EXTRA_RECOVERY_KEYS for
+// recovery image. The output file (otacerts.zip by default) is installed into
+// the relative_install_path directory under the etc directory of the target
+// partition.
+func otacertsZipFactory() android.Module {
+ module := &otacertsZipModule{}
+ module.AddProperties(&module.properties)
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ return module
+}
+
+var _ android.ImageInterface = (*otacertsZipModule)(nil)
+
+func (m *otacertsZipModule) ImageMutatorBegin(ctx android.BaseModuleContext) {}
+
+func (m *otacertsZipModule) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
+ return false
+}
+
+func (m *otacertsZipModule) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
+ return false
+}
+
+func (m *otacertsZipModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
+ return !m.ModuleBase.InstallInRecovery()
+}
+
+func (m *otacertsZipModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return false
+}
+
+func (m *otacertsZipModule) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return false
+}
+
+func (m *otacertsZipModule) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return false
+}
+
+func (m *otacertsZipModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
+ return proptools.Bool(m.properties.Recovery_available) || m.ModuleBase.InstallInRecovery()
+}
+
+func (m *otacertsZipModule) ExtraImageVariations(ctx android.BaseModuleContext) []string {
+ return nil
+}
+
+func (m *otacertsZipModule) SetImageVariation(ctx android.BaseModuleContext, variation string) {
+}
+
+func (m *otacertsZipModule) InRecovery() bool {
+ return m.ModuleBase.InRecovery() || m.ModuleBase.InstallInRecovery()
+}
+
+func (m *otacertsZipModule) InstallInRecovery() bool {
+ return m.InRecovery()
+}
+
+func (m *otacertsZipModule) outputFileName() string {
+ // Use otacerts.zip if not specified.
+ return proptools.StringDefault(m.properties.Filename, "otacerts.zip")
+}
+
+func (m *otacertsZipModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ // Read .x509.pem file defined in PRODUCT_DEFAULT_DEV_CERTIFICATE or the default test key.
+ pem, _ := ctx.Config().DefaultAppCertificate(ctx)
+ // Read .x509.pem files listed in PRODUCT_EXTRA_OTA_KEYS or PRODUCT_EXTRA_RECOVERY_KEYS.
+ extras := ctx.Config().ExtraOtaKeys(ctx, m.InRecovery())
+ srcPaths := append([]android.SourcePath{pem}, extras...)
+ m.outputPath = android.PathForModuleOut(ctx, m.outputFileName()).OutputPath
+
+ rule := android.NewRuleBuilder(pctx, ctx)
+ cmd := rule.Command().BuiltTool("soong_zip").
+ FlagWithOutput("-o ", m.outputPath).
+ Flag("-j ").
+ Flag("-symlinks=false ")
+ for _, src := range srcPaths {
+ cmd.FlagWithInput("-f ", src)
+ }
+ rule.Build(ctx.ModuleName(), "Generating the otacerts zip file")
+
+ installPath := android.PathForModuleInstall(ctx, "etc", proptools.String(m.properties.Relative_install_path))
+ ctx.InstallFile(installPath, m.outputFileName(), m.outputPath)
+}
+
+func (m *otacertsZipModule) AndroidMkEntries() []android.AndroidMkEntries {
+ nameSuffix := ""
+ if m.InRecovery() {
+ nameSuffix = ".recovery"
+ }
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
+ Class: "ETC",
+ SubName: nameSuffix,
+ OutputFile: android.OptionalPathForPath(m.outputPath),
+ }}
+}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 5a4818f..fc6d1f7 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -50,6 +50,7 @@
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
+ ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
@@ -125,6 +126,15 @@
Relative_install_path *string `android:"arch_variant"`
}
+type prebuiltRootProperties struct {
+ // Install this module to the root directory, without partition subdirs. When this module is
+ // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
+ // then be copied to the root of system.img. When this module is packaged by other modules like
+ // android_filesystem, this module will be installed to the root ("/"), unlike normal
+ // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
+ Install_in_root *bool
+}
+
type PrebuiltEtcModule interface {
android.Module
@@ -139,7 +149,12 @@
android.ModuleBase
android.DefaultableModuleBase
- properties prebuiltEtcProperties
+ properties prebuiltEtcProperties
+
+ // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
+ // prebuilt_avb and prebuilt_root modules use this.
+ rootProperties prebuiltRootProperties
+
subdirProperties prebuiltSubdirProperties
sourceFilePaths android.Paths
@@ -241,6 +256,10 @@
return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
}
+func (p *PrebuiltEtc) InstallInRoot() bool {
+ return proptools.Bool(p.rootProperties.Install_in_root)
+}
+
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
}
@@ -501,6 +520,13 @@
func InitPrebuiltRootModule(p *PrebuiltEtc) {
p.installDirBase = "."
p.AddProperties(&p.properties)
+ p.AddProperties(&p.rootProperties)
+}
+
+func InitPrebuiltAvbModule(p *PrebuiltEtc) {
+ p.installDirBase = "avb"
+ p.AddProperties(&p.properties)
+ p.rootProperties.Install_in_root = proptools.BoolPtr(true)
}
// prebuilt_etc is for a prebuilt artifact that is installed in
@@ -553,6 +579,20 @@
return module
}
+// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
+// `prebuilt_avb` will not have a `system` subdirectory.
+// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
+// root directory of the partition: <partition_root>/avb.
+// prebuilt_avb does not allow adding any other subdirectories.
+func PrebuiltAvbFactory() android.Module {
+ module := &PrebuiltEtc{}
+ InitPrebuiltAvbModule(module)
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
+ return module
+}
+
// prebuilt_root is for a prebuilt artifact that is installed in
// <partition>/ directory. Can't have any sub directories.
func PrebuiltRootFactory() android.Module {
diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go
index c44574a..e739afe 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -244,6 +244,31 @@
`)
}
+func TestPrebuiltAvbInstallDirPath(t *testing.T) {
+ result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
+ prebuilt_avb {
+ name: "foo.conf",
+ src: "foo.conf",
+ filename: "foo.conf",
+ //recovery: true,
+ }
+ `)
+
+ p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
+ expected := "out/soong/target/product/test_device/root/avb"
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+}
+
+func TestPrebuiltAvdInstallDirPathValidate(t *testing.T) {
+ prepareForPrebuiltEtcTest.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("filename cannot contain separator")).RunTestWithBp(t, `
+ prebuilt_avb {
+ name: "foo.conf",
+ src: "foo.conf",
+ filename: "foo/bar.conf",
+ }
+ `)
+}
+
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_usr_share {
diff --git a/filesystem/aconfig_files.go b/filesystem/aconfig_files.go
index 8daee85..5c047bc 100644
--- a/filesystem/aconfig_files.go
+++ b/filesystem/aconfig_files.go
@@ -16,7 +16,6 @@
import (
"android/soong/android"
- "path/filepath"
"strings"
"github.com/google/blueprint/proptools"
@@ -56,6 +55,7 @@
sb.WriteString(" \\\n")
sb.WriteString(sbCaches.String())
cmd.ImplicitOutput(installAconfigFlagsPath)
+ f.appendToEntry(ctx, installAconfigFlagsPath)
installAconfigStorageDir := dir.Join(ctx, "etc", "aconfig")
sb.WriteString("mkdir -p ")
@@ -63,16 +63,18 @@
sb.WriteRune('\n')
generatePartitionAconfigStorageFile := func(fileType, fileName string) {
+ outputPath := installAconfigStorageDir.Join(ctx, fileName)
sb.WriteString(aconfigToolPath.String())
sb.WriteString(" create-storage --container ")
sb.WriteString(f.PartitionType())
sb.WriteString(" --file ")
sb.WriteString(fileType)
sb.WriteString(" --out ")
- sb.WriteString(filepath.Join(installAconfigStorageDir.String(), fileName))
+ sb.WriteString(outputPath.String())
sb.WriteString(" \\\n")
sb.WriteString(sbCaches.String())
- cmd.ImplicitOutput(installAconfigStorageDir.Join(ctx, fileName))
+ cmd.ImplicitOutput(outputPath)
+ f.appendToEntry(ctx, outputPath)
}
generatePartitionAconfigStorageFile("package_map", "package.map")
generatePartitionAconfigStorageFile("flag_map", "flag.map")
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index c889dd6..5c7ef43 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -60,7 +60,9 @@
output android.OutputPath
installDir android.InstallPath
- // For testing. Keeps the result of CopySpecsToDir()
+ fileListFile android.OutputPath
+
+ // Keeps the entries installed from this filesystem
entries []string
}
@@ -221,8 +223,26 @@
f.installDir = android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(f.installDir, f.installFileName(), f.output)
-
ctx.SetOutputFiles([]android.Path{f.output}, "")
+
+ f.fileListFile = android.PathForModuleOut(ctx, "fileList").OutputPath
+ android.WriteFileRule(ctx, f.fileListFile, f.installedFilesList())
+}
+
+func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.OutputPath) {
+ partitionBaseDir := android.PathForModuleOut(ctx, "root", f.partitionName()).String() + "/"
+
+ relPath, inTargetPartition := strings.CutPrefix(installedFile.String(), partitionBaseDir)
+ if inTargetPartition {
+ f.entries = append(f.entries, relPath)
+ }
+}
+
+func (f *filesystem) installedFilesList() string {
+ installedFilePaths := android.FirstUniqueStrings(f.entries)
+ slices.Sort(installedFilePaths)
+
+ return strings.Join(installedFilePaths, "\n")
}
func validatePartitionType(ctx android.ModuleContext, p partition) {
@@ -269,17 +289,19 @@
builder.Command().Textf("(! [ -e %s -o -L %s ] || (echo \"%s already exists from an earlier stage of the build\" && exit 1))", dst, dst, dst)
builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String()))
builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String())
+ f.appendToEntry(ctx, dst)
}
// create extra files if there's any
if f.buildExtraFiles != nil {
rootForExtraFiles := android.PathForModuleGen(ctx, "root-extra").OutputPath
extraFiles := f.buildExtraFiles(ctx, rootForExtraFiles)
- for _, f := range extraFiles {
- rel, err := filepath.Rel(rootForExtraFiles.String(), f.String())
+ for _, extraFile := range extraFiles {
+ rel, err := filepath.Rel(rootForExtraFiles.String(), extraFile.String())
if err != nil || strings.HasPrefix(rel, "..") {
- ctx.ModuleErrorf("can't make %q relative to %q", f, rootForExtraFiles)
+ ctx.ModuleErrorf("can't make %q relative to %q", extraFile, rootForExtraFiles)
}
+ f.appendToEntry(ctx, rootDir.Join(ctx, rel))
}
if len(extraFiles) > 0 {
builder.Command().BuiltTool("merge_directories").
@@ -290,6 +312,25 @@
}
}
+func (f *filesystem) copyPackagingSpecs(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir, rebasedDir android.WritablePath) []string {
+ rootDirSpecs := make(map[string]android.PackagingSpec)
+ rebasedDirSpecs := make(map[string]android.PackagingSpec)
+
+ for rel, spec := range specs {
+ if spec.Partition() == "root" {
+ rootDirSpecs[rel] = spec
+ } else {
+ rebasedDirSpecs[rel] = spec
+ }
+ }
+
+ dirsToSpecs := make(map[android.WritablePath]map[string]android.PackagingSpec)
+ dirsToSpecs[rootDir] = rootDirSpecs
+ dirsToSpecs[rebasedDir] = rebasedDirSpecs
+
+ return f.CopySpecsToDirs(ctx, builder, dirsToSpecs)
+}
+
func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath {
rootDir := android.PathForModuleOut(ctx, "root").OutputPath
rebasedDir := rootDir
@@ -300,7 +341,7 @@
// Wipe the root dir to get rid of leftover files from prior builds
builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
specs := f.gatherFilteredPackagingSpecs(ctx)
- f.entries = f.CopySpecsToDir(ctx, builder, specs, rebasedDir)
+ f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
f.buildNonDepsFiles(ctx, builder, rootDir)
f.addMakeBuiltFiles(ctx, builder, rootDir)
@@ -443,7 +484,7 @@
// Wipe the root dir to get rid of leftover files from prior builds
builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
specs := f.gatherFilteredPackagingSpecs(ctx)
- f.entries = f.CopySpecsToDir(ctx, builder, specs, rebasedDir)
+ f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
f.buildNonDepsFiles(ctx, builder, rootDir)
f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
@@ -535,6 +576,8 @@
for _, path := range android.SortedKeys(logtagsFilePaths) {
cmd.Text(path)
}
+
+ f.appendToEntry(ctx, eventLogtagsPath)
}
type partition interface {
@@ -558,6 +601,7 @@
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", f.installDir.String())
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", f.installFileName())
+ entries.SetString("LOCAL_FILESYSTEM_FILELIST", f.fileListFile.String())
},
},
}}
@@ -607,7 +651,7 @@
var _ cc.UseCoverage = (*filesystem)(nil)
-func (*filesystem) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
+func (*filesystem) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go
index 3e50ff7..d7bb654 100644
--- a/filesystem/fsverity_metadata.go
+++ b/filesystem/fsverity_metadata.go
@@ -87,6 +87,7 @@
sb.WriteRune(' ')
sb.WriteString(srcPath.String())
sb.WriteRune('\n')
+ f.appendToEntry(ctx, destPath)
}
// STEP 2: generate signed BuildManifest.apk
@@ -108,6 +109,7 @@
sb.WriteString(" --output ")
sb.WriteString(manifestPbPath.String())
sb.WriteRune(' ')
+ f.appendToEntry(ctx, manifestPbPath)
manifestGeneratorListPath := android.PathForModuleOut(ctx, "fsverity_manifest.list")
f.writeManifestGeneratorListFile(ctx, manifestGeneratorListPath.OutputPath, matchedSpecs, rebasedDir)
@@ -115,15 +117,18 @@
sb.WriteString(manifestGeneratorListPath.String())
sb.WriteRune('\n')
cmd.Implicit(manifestGeneratorListPath)
+ f.appendToEntry(ctx, manifestGeneratorListPath.OutputPath)
// STEP 2-2: generate BuildManifest.apk (unsigned)
aapt2Path := ctx.Config().HostToolPath(ctx, "aapt2")
apkPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", "BuildManifest.apk")
+ idsigPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", "BuildManifest.apk.idsig")
manifestTemplatePath := android.PathForSource(ctx, "system/security/fsverity/AndroidManifest.xml")
libs := android.PathsForModuleSrc(ctx, f.properties.Fsverity.Libs)
cmd.Implicit(aapt2Path)
cmd.Implicit(manifestTemplatePath)
cmd.Implicits(libs)
+ cmd.ImplicitOutput(apkPath)
sb.WriteString(aapt2Path.String())
sb.WriteString(" link -o ")
@@ -150,12 +155,15 @@
sb.WriteString(f.partitionName())
sb.WriteRune('\n')
+ f.appendToEntry(ctx, apkPath)
+
// STEP 2-3: sign BuildManifest.apk
apksignerPath := ctx.Config().HostToolPath(ctx, "apksigner")
pemPath, keyPath := ctx.Config().DefaultAppCertificate(ctx)
cmd.Implicit(apksignerPath)
cmd.Implicit(pemPath)
cmd.Implicit(keyPath)
+ cmd.ImplicitOutput(idsigPath)
sb.WriteString(apksignerPath.String())
sb.WriteString(" sign --in ")
sb.WriteString(apkPath.String())
@@ -165,5 +173,7 @@
sb.WriteString(keyPath.String())
sb.WriteRune('\n')
+ f.appendToEntry(ctx, idsigPath)
+
android.WriteExecutableFileRuleVerbatim(ctx, fsverityBuilderPath, sb.String())
}
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 15cacfb..69d922d 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -94,9 +94,10 @@
return output
}
-// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" partition.
-// Note that "apex" module installs its contents to "apex"(fake partition) as well
+// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" / "root"
+// partition. Note that "apex" module installs its contents to "apex"(fake partition) as well
// for symbol lookup by imitating "activated" paths.
func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool {
- return s.filesystem.filterInstallablePackagingSpec(ps) && ps.Partition() == "system"
+ return s.filesystem.filterInstallablePackagingSpec(ps) &&
+ (ps.Partition() == "system" || ps.Partition() == "root")
}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index c0942d3..5b40768 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -754,6 +754,7 @@
func GenSrcsFactory() android.Module {
m := NewGenSrcs()
android.InitAndroidModule(m)
+ android.InitDefaultableModule(m)
return m
}
diff --git a/java/Android.bp b/java/Android.bp
index 54b36ab..a941754 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -87,6 +87,7 @@
"app_set_test.go",
"app_test.go",
"code_metadata_test.go",
+ "container_test.go",
"bootclasspath_fragment_test.go",
"device_host_converter_test.go",
"dex_test.go",
diff --git a/java/aar.go b/java/aar.go
index 3168d9b..2f49a95 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -798,18 +798,6 @@
aarFile android.WritablePath
}
-var _ android.OutputFileProducer = (*AndroidLibrary)(nil)
-
-// For OutputFileProducer interface
-func (a *AndroidLibrary) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case ".aar":
- return []android.Path{a.aarFile}, nil
- default:
- return a.Library.OutputFiles(tag)
- }
-}
-
var _ AndroidLibraryDependency = (*AndroidLibrary)(nil)
func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -911,6 +899,13 @@
android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
AconfigTextFiles: aconfigTextFilePaths,
})
+
+ a.setOutputFiles(ctx)
+}
+
+func (a *AndroidLibrary) setOutputFiles(ctx android.ModuleContext) {
+ ctx.SetOutputFiles([]android.Path{a.aarFile}, ".aar")
+ setOutputFiles(ctx, a.Library.Module)
}
func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) {
@@ -1021,20 +1016,6 @@
classLoaderContexts dexpreopt.ClassLoaderContextMap
}
-var _ android.OutputFileProducer = (*AARImport)(nil)
-
-// For OutputFileProducer interface
-func (a *AARImport) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case ".aar":
- return []android.Path{a.aarPath}, nil
- case "":
- return []android.Path{a.implementationAndResourcesJarFile}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (a *AARImport) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return android.SdkSpecFrom(ctx, String(a.properties.Sdk_version))
}
@@ -1388,6 +1369,9 @@
android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: a.jniPackages,
})
+
+ ctx.SetOutputFiles([]android.Path{a.implementationAndResourcesJarFile}, "")
+ ctx.SetOutputFiles([]android.Path{a.aarPath}, ".aar")
}
func (a *AARImport) HeaderJars() android.Paths {
diff --git a/java/aar_test.go b/java/aar_test.go
index 18efd20..ebad310 100644
--- a/java/aar_test.go
+++ b/java/aar_test.go
@@ -159,21 +159,21 @@
bar := result.ModuleForTests("bar", "android_common")
baz := result.ModuleForTests("baz", "android_common")
- fooOutputPath := android.OutputFileForModule(android.PathContext(nil), foo.Module(), "")
- barOutputPath := android.OutputFileForModule(android.PathContext(nil), bar.Module(), "")
- bazOutputPath := android.OutputFileForModule(android.PathContext(nil), baz.Module(), "")
+ fooOutputPaths := foo.OutputFiles(t, "")
+ barOutputPaths := bar.OutputFiles(t, "")
+ bazOutputPaths := baz.OutputFiles(t, "")
- android.AssertPathRelativeToTopEquals(t, "foo output path",
- "out/soong/.intermediates/foo/android_common/withres/foo.jar", fooOutputPath)
- android.AssertPathRelativeToTopEquals(t, "bar output path",
- "out/soong/.intermediates/bar/android_common/aar/bar.jar", barOutputPath)
- android.AssertPathRelativeToTopEquals(t, "baz output path",
- "out/soong/.intermediates/baz/android_common/withres/baz.jar", bazOutputPath)
+ android.AssertPathsRelativeToTopEquals(t, "foo output path",
+ []string{"out/soong/.intermediates/foo/android_common/withres/foo.jar"}, fooOutputPaths)
+ android.AssertPathsRelativeToTopEquals(t, "bar output path",
+ []string{"out/soong/.intermediates/bar/android_common/aar/bar.jar"}, barOutputPaths)
+ android.AssertPathsRelativeToTopEquals(t, "baz output path",
+ []string{"out/soong/.intermediates/baz/android_common/withres/baz.jar"}, bazOutputPaths)
android.AssertStringEquals(t, "foo relative output path",
- "foo.jar", fooOutputPath.Rel())
+ "foo.jar", fooOutputPaths[0].Rel())
android.AssertStringEquals(t, "bar relative output path",
- "bar.jar", barOutputPath.Rel())
+ "bar.jar", barOutputPaths[0].Rel())
android.AssertStringEquals(t, "baz relative output path",
- "baz.jar", bazOutputPath.Rel())
+ "baz.jar", bazOutputPaths[0].Rel())
}
diff --git a/java/app.go b/java/app.go
index f35e4c3..19dc8d5 100644
--- a/java/app.go
+++ b/java/app.go
@@ -583,7 +583,11 @@
a.aapt.splitNames = a.appProperties.Package_splits
a.aapt.LoggingParent = String(a.overridableAppProperties.Logging_parent)
if a.Updatable() {
- a.aapt.defaultManifestVersion = android.DefaultUpdatableModuleVersion
+ if override := ctx.Config().Getenv("OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION"); override != "" {
+ a.aapt.defaultManifestVersion = override
+ } else {
+ a.aapt.defaultManifestVersion = android.DefaultUpdatableModuleVersion
+ }
}
// Use non final ids if we are doing optimized shrinking and are using R8.
@@ -1013,6 +1017,22 @@
isPrebuilt: false,
},
)
+
+ a.setOutputFiles(ctx)
+}
+
+func (a *AndroidApp) setOutputFiles(ctx android.ModuleContext) {
+ ctx.SetOutputFiles([]android.Path{a.proguardOptionsFile}, ".aapt.proguardOptionsFile")
+ if a.aaptSrcJar != nil {
+ ctx.SetOutputFiles([]android.Path{a.aaptSrcJar}, ".aapt.srcjar")
+ }
+ if a.rJar != nil {
+ ctx.SetOutputFiles([]android.Path{a.rJar}, ".aapt.jar")
+ }
+ ctx.SetOutputFiles([]android.Path{a.outputFile}, ".apk")
+ ctx.SetOutputFiles([]android.Path{a.exportPackage}, ".export-package.apk")
+ ctx.SetOutputFiles([]android.Path{a.aapt.manifestPath}, ".manifest.xml")
+ setOutputFiles(ctx, a.Library.Module)
}
type appDepsInterface interface {
@@ -1203,36 +1223,11 @@
return a.Library.DepIsInSameApex(ctx, dep)
}
-// For OutputFileProducer interface
-func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- // In some instances, it can be useful to reference the aapt-generated flags from another
- // target, e.g., system server implements services declared in the framework-res manifest.
- case ".aapt.proguardOptionsFile":
- return []android.Path{a.proguardOptionsFile}, nil
- case ".aapt.srcjar":
- if a.aaptSrcJar != nil {
- return []android.Path{a.aaptSrcJar}, nil
- }
- case ".aapt.jar":
- if a.rJar != nil {
- return []android.Path{a.rJar}, nil
- }
- case ".apk":
- return []android.Path{a.outputFile}, nil
- case ".export-package.apk":
- return []android.Path{a.exportPackage}, nil
- case ".manifest.xml":
- return []android.Path{a.aapt.manifestPath}, nil
- }
- return a.Library.OutputFiles(tag)
-}
-
func (a *AndroidApp) Privileged() bool {
return Bool(a.appProperties.Privileged)
}
-func (a *AndroidApp) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
+func (a *AndroidApp) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
diff --git a/java/app_import.go b/java/app_import.go
index dc8470d..fa87997 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -17,7 +17,6 @@
// This file contains the module implementations for android_app_import and android_test_import.
import (
- "fmt"
"reflect"
"strings"
@@ -422,6 +421,8 @@
},
)
+ ctx.SetOutputFiles([]android.Path{a.outputFile}, "")
+
// TODO: androidmk converter jni libs
}
@@ -461,15 +462,6 @@
return a.outputFile
}
-func (a *AndroidAppImport) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return []android.Path{a.outputFile}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (a *AndroidAppImport) JacocoReportClassesFile() android.Path {
return nil
}
diff --git a/java/app_test.go b/java/app_test.go
index 9e2d19e..e878ccf 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -119,10 +119,7 @@
foo.Output(expectedOutput)
}
- outputFiles, err := foo.Module().(*AndroidApp).OutputFiles("")
- if err != nil {
- t.Fatal(err)
- }
+ outputFiles := foo.OutputFiles(t, "")
android.AssertPathsRelativeToTopEquals(t, `OutputFiles("")`, expectedOutputs, outputFiles)
}
@@ -519,6 +516,49 @@
testJavaError(t, `"libjni" .*: links "libbar" built against newer API version "current"`, bp)
}
+func TestUpdatableApps_ApplyDefaultUpdatableModuleVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "31",
+ updatable: true,
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ android.AssertStringDoesContain(t,
+ "com.android.foo: expected manifest fixer to set override-placeholder-version to android.DefaultUpdatableModuleVersion",
+ foo.BuildParams.Args["args"],
+ fmt.Sprintf("--override-placeholder-version %s", android.DefaultUpdatableModuleVersion),
+ )
+}
+
+func TestUpdatableApps_ApplyOverrideApexManifestDefaultVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureMergeEnv(map[string]string{
+ "OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234",
+ }),
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "31",
+ updatable: true,
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ android.AssertStringDoesContain(t,
+ "com.android.foo: expected manifest fixer to set override-placeholder-version to 1234",
+ foo.BuildParams.Args["args"],
+ "--override-placeholder-version 1234",
+ )
+}
+
func TestResourceDirs(t *testing.T) {
testCases := []struct {
name string
@@ -4556,3 +4596,44 @@
)
}
+
+func TestNotApplyDefaultUpdatableModuleVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "31",
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ android.AssertStringDoesNotContain(t,
+ "com.android.foo: expected manifest fixer to not set override-placeholder-version",
+ foo.BuildParams.Args["args"],
+ "--override-placeholder-version",
+ )
+}
+
+func TestNotApplyOverrideApexManifestDefaultVersion(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureMergeEnv(map[string]string{
+ "OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234",
+ }),
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "31",
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ android.AssertStringDoesNotContain(t,
+ "com.android.foo: expected manifest fixer to not set override-placeholder-version",
+ foo.BuildParams.Args["args"],
+ "--override-placeholder-version",
+ )
+}
diff --git a/java/base.go b/java/base.go
index ee8df3e..02dc3e3 100644
--- a/java/base.go
+++ b/java/base.go
@@ -552,6 +552,18 @@
aconfigCacheFiles android.Paths
}
+var _ android.InstallableModule = (*Module)(nil)
+
+// To satisfy the InstallableModule interface
+func (j *Module) EnforceApiContainerChecks() bool {
+ return true
+}
+
+// Overrides android.ModuleBase.InstallInProduct()
+func (j *Module) InstallInProduct() bool {
+ return j.ProductSpecific()
+}
+
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
sdkVersion := j.SdkVersion(ctx)
if sdkVersion.Stable() {
@@ -652,35 +664,21 @@
android.SetProvider(ctx, hiddenAPIPropertyInfoProvider, hiddenAPIInfo)
}
-func (j *Module) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return append(android.Paths{j.outputFile}, j.extraOutputFiles...), nil
- case android.DefaultDistTag:
- return android.Paths{j.outputFile}, nil
- case ".jar":
- return android.Paths{j.implementationAndResourcesJar}, nil
- case ".hjar":
- return android.Paths{j.headerJarFile}, nil
- case ".proguard_map":
- if j.dexer.proguardDictionary.Valid() {
- return android.Paths{j.dexer.proguardDictionary.Path()}, nil
- }
- return nil, fmt.Errorf("%q was requested, but no output file was found.", tag)
- case ".generated_srcjars":
- return j.properties.Generated_srcjars, nil
- case ".lint":
- if j.linter.outputs.xml != nil {
- return android.Paths{j.linter.outputs.xml}, nil
- }
- return nil, fmt.Errorf("%q was requested, but no output file was found.", tag)
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
+// helper method for java modules to set OutputFilesProvider
+func setOutputFiles(ctx android.ModuleContext, m Module) {
+ ctx.SetOutputFiles(append(android.Paths{m.outputFile}, m.extraOutputFiles...), "")
+ ctx.SetOutputFiles(android.Paths{m.outputFile}, android.DefaultDistTag)
+ ctx.SetOutputFiles(android.Paths{m.implementationAndResourcesJar}, ".jar")
+ ctx.SetOutputFiles(android.Paths{m.headerJarFile}, ".hjar")
+ if m.dexer.proguardDictionary.Valid() {
+ ctx.SetOutputFiles(android.Paths{m.dexer.proguardDictionary.Path()}, ".proguard_map")
+ }
+ ctx.SetOutputFiles(m.properties.Generated_srcjars, ".generated_srcjars")
+ if m.linter.outputs.xml != nil {
+ ctx.SetOutputFiles(android.Paths{m.linter.outputs.xml}, ".lint")
}
}
-var _ android.OutputFileProducer = (*Module)(nil)
-
func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
initJavaModule(module, hod, false)
}
diff --git a/java/container_test.go b/java/container_test.go
new file mode 100644
index 0000000..3441855
--- /dev/null
+++ b/java/container_test.go
@@ -0,0 +1,129 @@
+// 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 java
+
+import (
+ "android/soong/android"
+ "fmt"
+ "testing"
+)
+
+var checkContainerMatch = func(t *testing.T, name string, container string, expected bool, actual bool) {
+ errorMessage := fmt.Sprintf("module %s container %s value differ", name, container)
+ android.AssertBoolEquals(t, errorMessage, expected, actual)
+}
+
+func TestJavaContainersModuleProperties(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ ).RunTestWithBp(t, `
+ java_library {
+ name: "foo",
+ srcs: ["A.java"],
+ }
+ java_library {
+ name: "foo_vendor",
+ srcs: ["A.java"],
+ vendor: true,
+ sdk_version: "current",
+ }
+ java_library {
+ name: "foo_soc_specific",
+ srcs: ["A.java"],
+ soc_specific: true,
+ sdk_version: "current",
+ }
+ java_library {
+ name: "foo_product_specific",
+ srcs: ["A.java"],
+ product_specific: true,
+ sdk_version: "current",
+ }
+ java_test {
+ name: "foo_cts_test",
+ srcs: ["A.java"],
+ test_suites: [
+ "cts",
+ ],
+ }
+ java_test {
+ name: "foo_non_cts_test",
+ srcs: ["A.java"],
+ test_suites: [
+ "general-tests",
+ ],
+ }
+ `)
+
+ testcases := []struct {
+ moduleName string
+ isSystemContainer bool
+ isVendorContainer bool
+ isProductContainer bool
+ isCts bool
+ }{
+ {
+ moduleName: "foo",
+ isSystemContainer: true,
+ isVendorContainer: false,
+ isProductContainer: false,
+ isCts: false,
+ },
+ {
+ moduleName: "foo_vendor",
+ isSystemContainer: false,
+ isVendorContainer: true,
+ isProductContainer: false,
+ isCts: false,
+ },
+ {
+ moduleName: "foo_soc_specific",
+ isSystemContainer: false,
+ isVendorContainer: true,
+ isProductContainer: false,
+ isCts: false,
+ },
+ {
+ moduleName: "foo_product_specific",
+ isSystemContainer: false,
+ isVendorContainer: false,
+ isProductContainer: true,
+ isCts: false,
+ },
+ {
+ moduleName: "foo_cts_test",
+ isSystemContainer: false,
+ isVendorContainer: false,
+ isProductContainer: false,
+ isCts: true,
+ },
+ {
+ moduleName: "foo_non_cts_test",
+ isSystemContainer: false,
+ isVendorContainer: false,
+ isProductContainer: false,
+ isCts: false,
+ },
+ }
+
+ for _, c := range testcases {
+ m := result.ModuleForTests(c.moduleName, "android_common")
+ containers, _ := android.OtherModuleProvider(result.TestContext.OtherModuleProviderAdaptor(), m.Module(), android.ContainersInfoProvider)
+ belongingContainers := containers.BelongingContainers()
+ checkContainerMatch(t, c.moduleName, "system", c.isSystemContainer, android.InList(android.SystemContainer, belongingContainers))
+ checkContainerMatch(t, c.moduleName, "vendor", c.isVendorContainer, android.InList(android.VendorContainer, belongingContainers))
+ checkContainerMatch(t, c.moduleName, "product", c.isProductContainer, android.InList(android.ProductContainer, belongingContainers))
+ }
+}
diff --git a/java/dex.go b/java/dex.go
index c75e774..7bb6925 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -91,6 +91,10 @@
// Exclude kotlinc generate files: *.kotlin_module, *.kotlin_builtins. Defaults to false.
Exclude_kotlinc_generated_files *bool
+
+ // Disable dex container (also known as "multi-dex").
+ // This may be necessary as a temporary workaround to mask toolchain bugs (see b/341652226).
+ No_dex_container *bool
}
type dexer struct {
diff --git a/java/droiddoc_test.go b/java/droiddoc_test.go
index 8d1f591..e584640 100644
--- a/java/droiddoc_test.go
+++ b/java/droiddoc_test.go
@@ -69,11 +69,7 @@
"bar-doc/a.java": nil,
"bar-doc/b.java": nil,
})
- barStubs := ctx.ModuleForTests("bar-stubs", "android_common")
- barStubsOutputs, err := barStubs.Module().(*Droidstubs).OutputFiles("")
- if err != nil {
- t.Errorf("Unexpected error %q retrieving \"bar-stubs\" output file", err)
- }
+ barStubsOutputs := ctx.ModuleForTests("bar-stubs", "android_common").OutputFiles(t, "")
if len(barStubsOutputs) != 1 {
t.Errorf("Expected one output from \"bar-stubs\" got %s", barStubsOutputs)
}
diff --git a/java/droidstubs.go b/java/droidstubs.go
index b32b754..a8e0a22 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -283,66 +283,6 @@
return module
}
-func getStubsTypeAndTag(tag string) (StubsType, string, error) {
- if len(tag) == 0 {
- return Everything, "", nil
- }
- if tag[0] != '.' {
- return Unavailable, "", fmt.Errorf("tag must begin with \".\"")
- }
-
- stubsType := Everything
- // Check if the tag has a stubs type prefix (e.g. ".exportable")
- for st := Everything; st <= Exportable; st++ {
- if strings.HasPrefix(tag, "."+st.String()) {
- stubsType = st
- }
- }
-
- return stubsType, strings.TrimPrefix(tag, "."+stubsType.String()), nil
-}
-
-// Droidstubs' tag supports specifying with the stubs type.
-// While supporting the pre-existing tags, it also supports tags with
-// the stubs type prefix. Some examples are shown below:
-// {.annotations.zip} - pre-existing behavior. Returns the path to the
-// annotation zip.
-// {.exportable} - Returns the path to the exportable stubs src jar.
-// {.exportable.annotations.zip} - Returns the path to the exportable
-// annotations zip file.
-// {.runtime.api_versions.xml} - Runtime stubs does not generate api versions
-// xml file. For unsupported combinations, the default everything output file
-// is returned.
-func (d *Droidstubs) OutputFiles(tag string) (android.Paths, error) {
- stubsType, prefixRemovedTag, err := getStubsTypeAndTag(tag)
- if err != nil {
- return nil, err
- }
- switch prefixRemovedTag {
- case "":
- stubsSrcJar, err := d.StubsSrcJar(stubsType)
- return android.Paths{stubsSrcJar}, err
- case ".docs.zip":
- docZip, err := d.DocZip(stubsType)
- return android.Paths{docZip}, err
- case ".api.txt", android.DefaultDistTag:
- // This is the default dist path for dist properties that have no tag property.
- apiFilePath, err := d.ApiFilePath(stubsType)
- return android.Paths{apiFilePath}, err
- case ".removed-api.txt":
- removedApiFilePath, err := d.RemovedApiFilePath(stubsType)
- return android.Paths{removedApiFilePath}, err
- case ".annotations.zip":
- annotationsZip, err := d.AnnotationsZip(stubsType)
- return android.Paths{annotationsZip}, err
- case ".api_versions.xml":
- apiVersionsXmlFilePath, err := d.ApiVersionsXmlFilePath(stubsType)
- return android.Paths{apiVersionsXmlFilePath}, err
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (d *Droidstubs) AnnotationsZip(stubsType StubsType) (ret android.Path, err error) {
switch stubsType {
case Everything:
@@ -1363,6 +1303,46 @@
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
+
+ d.setOutputFiles(ctx)
+}
+
+// This method sets the outputFiles property, which is used to set the
+// OutputFilesProvider later.
+// Droidstubs' tag supports specifying with the stubs type.
+// While supporting the pre-existing tags, it also supports tags with
+// the stubs type prefix. Some examples are shown below:
+// {.annotations.zip} - pre-existing behavior. Returns the path to the
+// annotation zip.
+// {.exportable} - Returns the path to the exportable stubs src jar.
+// {.exportable.annotations.zip} - Returns the path to the exportable
+// annotations zip file.
+// {.runtime.api_versions.xml} - Runtime stubs does not generate api versions
+// xml file. For unsupported combinations, the default everything output file
+// is returned.
+func (d *Droidstubs) setOutputFiles(ctx android.ModuleContext) {
+ tagToOutputFileFunc := map[string]func(StubsType) (android.Path, error){
+ "": d.StubsSrcJar,
+ ".docs.zip": d.DocZip,
+ ".api.txt": d.ApiFilePath,
+ android.DefaultDistTag: d.ApiFilePath,
+ ".removed-api.txt": d.RemovedApiFilePath,
+ ".annotations.zip": d.AnnotationsZip,
+ ".api_versions.xml": d.ApiVersionsXmlFilePath,
+ }
+ stubsTypeToPrefix := map[StubsType]string{
+ Everything: "",
+ Exportable: ".exportable",
+ }
+ for _, tag := range android.SortedKeys(tagToOutputFileFunc) {
+ for _, stubType := range android.SortedKeys(stubsTypeToPrefix) {
+ tagWithPrefix := stubsTypeToPrefix[stubType] + tag
+ outputFile, err := tagToOutputFileFunc[tag](stubType)
+ if err == nil {
+ ctx.SetOutputFiles(android.Paths{outputFile}, tagWithPrefix)
+ }
+ }
+ }
}
func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {
@@ -1453,17 +1433,6 @@
stubsSrcJar android.Path
}
-func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- // prebuilt droidstubs does not output "exportable" stubs.
- // Output the "everything" stubs srcjar file if the tag is ".exportable".
- case "", ".exportable":
- return android.Paths{p.stubsSrcJar}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (d *PrebuiltStubsSources) StubsSrcJar(_ StubsType) (android.Path, error) {
return d.stubsSrcJar, nil
}
@@ -1502,6 +1471,11 @@
rule.Build("zip src", "Create srcjar from prebuilt source")
p.stubsSrcJar = outPath
}
+
+ ctx.SetOutputFiles(android.Paths{p.stubsSrcJar}, "")
+ // prebuilt droidstubs does not output "exportable" stubs.
+ // Output the "everything" stubs srcjar file if the tag is ".exportable".
+ ctx.SetOutputFiles(android.Paths{p.stubsSrcJar}, ".exportable")
}
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
diff --git a/java/java.go b/java/java.go
index a2fc5fb..88b31b5 100644
--- a/java/java.go
+++ b/java/java.go
@@ -977,6 +977,8 @@
TestOnly: Bool(j.sourceProperties.Test_only),
TopLevelTarget: j.sourceProperties.Top_level_test_target,
})
+
+ setOutputFiles(ctx, j.Module)
}
func (j *Library) setInstallRules(ctx android.ModuleContext, installModuleName string) {
@@ -1356,7 +1358,7 @@
return true
}
-func (j *TestHost) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
+func (j *TestHost) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
return ctx.DeviceConfig().NativeCoverageEnabled()
}
@@ -1836,6 +1838,8 @@
// libraries. This is verified by TestBinary.
j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
ctx.ModuleName()+ext, j.wrapperFile)
+
+ setOutputFiles(ctx, j.Library.Module)
}
}
@@ -2752,6 +2756,9 @@
StubsLinkType: j.stubsLinkType,
// TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
})
+
+ ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, "")
+ ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, ".jar")
}
func (j *Import) maybeInstall(ctx android.ModuleContext, jarName string, outputFile android.Path) {
@@ -2772,17 +2779,6 @@
ctx.InstallFile(installDir, jarName, outputFile)
}
-func (j *Import) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "", ".jar":
- return android.Paths{j.combinedImplementationFile}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
-var _ android.OutputFileProducer = (*Import)(nil)
-
func (j *Import) HeaderJars() android.Paths {
return android.PathsIfNonNil(j.combinedHeaderFile)
}
diff --git a/java/java_test.go b/java/java_test.go
index 2f27932..33079f3 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2993,23 +2993,23 @@
bar := result.ModuleForTests("bar", "android_common")
baz := result.ModuleForTests("baz", "android_common")
- fooOutputPath := android.OutputFileForModule(android.PathContext(nil), foo.Module(), "")
- barOutputPath := android.OutputFileForModule(android.PathContext(nil), bar.Module(), "")
- bazOutputPath := android.OutputFileForModule(android.PathContext(nil), baz.Module(), "")
+ fooOutputPaths := foo.OutputFiles(t, "")
+ barOutputPaths := bar.OutputFiles(t, "")
+ bazOutputPaths := baz.OutputFiles(t, "")
- android.AssertPathRelativeToTopEquals(t, "foo output path",
- "out/soong/.intermediates/foo/android_common/javac/foo.jar", fooOutputPath)
- android.AssertPathRelativeToTopEquals(t, "bar output path",
- "out/soong/.intermediates/bar/android_common/combined/bar.jar", barOutputPath)
- android.AssertPathRelativeToTopEquals(t, "baz output path",
- "out/soong/.intermediates/baz/android_common/combined/baz.jar", bazOutputPath)
+ android.AssertPathsRelativeToTopEquals(t, "foo output path",
+ []string{"out/soong/.intermediates/foo/android_common/javac/foo.jar"}, fooOutputPaths)
+ android.AssertPathsRelativeToTopEquals(t, "bar output path",
+ []string{"out/soong/.intermediates/bar/android_common/combined/bar.jar"}, barOutputPaths)
+ android.AssertPathsRelativeToTopEquals(t, "baz output path",
+ []string{"out/soong/.intermediates/baz/android_common/combined/baz.jar"}, bazOutputPaths)
android.AssertStringEquals(t, "foo relative output path",
- "foo.jar", fooOutputPath.Rel())
+ "foo.jar", fooOutputPaths[0].Rel())
android.AssertStringEquals(t, "bar relative output path",
- "bar.jar", barOutputPath.Rel())
+ "bar.jar", barOutputPaths[0].Rel())
android.AssertStringEquals(t, "baz relative output path",
- "baz.jar", bazOutputPath.Rel())
+ "baz.jar", bazOutputPaths[0].Rel())
}
func assertTestOnlyAndTopLevel(t *testing.T, ctx *android.TestResult, expectedTestOnly []string, expectedTopLevel []string) {
diff --git a/java/robolectric.go b/java/robolectric.go
index cb22fa0..4cad5b1 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -29,8 +29,12 @@
)
func init() {
- android.RegisterModuleType("android_robolectric_test", RobolectricTestFactory)
- android.RegisterModuleType("android_robolectric_runtimes", robolectricRuntimesFactory)
+ RegisterRobolectricBuildComponents(android.InitRegistrationContext)
+}
+
+func RegisterRobolectricBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("android_robolectric_test", RobolectricTestFactory)
+ ctx.RegisterModuleType("android_robolectric_runtimes", robolectricRuntimesFactory)
}
var robolectricDefaultLibs = []string{
@@ -74,6 +78,8 @@
// Use strict mode to limit access of Robolectric API directly. See go/roboStrictMode
Strict_mode *bool
+
+ Jni_libs []string
}
type robolectricTest struct {
@@ -137,6 +143,10 @@
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(),
roboRuntimesTag, "robolectric-android-all-prebuilts")
+
+ for _, lib := range r.robolectricProperties.Jni_libs {
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
+ }
}
func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -270,6 +280,12 @@
installDeps = append(installDeps, installedData)
}
+ soInstallPath := installPath.Join(ctx, getLibPath(r.forceArchType))
+ for _, jniLib := range collectTransitiveJniDeps(ctx) {
+ installJni := ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
+ installDeps = append(installDeps, installJni)
+ }
+
r.installFile = ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.combinedJar, installDeps...)
android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
diff --git a/java/robolectric_test.go b/java/robolectric_test.go
new file mode 100644
index 0000000..4775bac
--- /dev/null
+++ b/java/robolectric_test.go
@@ -0,0 +1,98 @@
+// 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 java
+
+import (
+ "runtime"
+ "testing"
+
+ "android/soong/android"
+)
+
+var prepareRobolectricRuntime = android.GroupFixturePreparers(
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ RegisterRobolectricBuildComponents(ctx)
+ }),
+ android.FixtureAddTextFile("robolectric/Android.bp", `
+ java_library {
+ name: "Robolectric_all-target_upstream",
+ srcs: ["Robo.java"]
+ }
+
+ java_library {
+ name: "mockito-robolectric-prebuilt",
+ srcs: ["Mockito.java"]
+ }
+
+ java_library {
+ name: "truth",
+ srcs: ["Truth.java"]
+ }
+
+ java_library {
+ name: "junitxml",
+ srcs: ["JUnitXml.java"]
+ }
+
+ java_library_host {
+ name: "robolectric-host-android_all",
+ srcs: ["Runtime.java"]
+ }
+
+ android_robolectric_runtimes {
+ name: "robolectric-android-all-prebuilts",
+ jars: ["android-all/Runtime.jar"],
+ lib: "robolectric-host-android_all",
+ }
+ `),
+)
+
+func TestRobolectricJniTest(t *testing.T) {
+ if runtime.GOOS != "linux" {
+ t.Skip("requires linux")
+ }
+
+ ctx := android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithJava,
+ prepareRobolectricRuntime,
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "inst-target",
+ srcs: ["App.java"],
+ platform_apis: true,
+ }
+
+ cc_library_shared {
+ name: "jni-lib1",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ }
+
+ android_robolectric_test {
+ name: "robo-test",
+ instrumentation_for: "inst-target",
+ srcs: ["FooTest.java"],
+ jni_libs: [
+ "jni-lib1"
+ ],
+ }
+ `)
+
+ CheckModuleHasDependency(t, ctx.TestContext, "robo-test", "android_common", "jni-lib1")
+
+ // Check that the .so files make it into the output.
+ module := ctx.ModuleForTests("robo-test", "android_common")
+ module.Output(installPathPrefix + "/robo-test/lib64/jni-lib1.so")
+}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index e6cb6c4..1eb7ab8 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -538,9 +538,6 @@
// of the API.
Api_packages []string
- // list of package names that must be hidden from the API
- Hidden_api_packages []string
-
// the relative path to the directory containing the api specification files.
// Defaults to "api".
Api_dir *string
@@ -1086,57 +1083,26 @@
return regexp.MustCompile(fmt.Sprintf(`^\.(%s)\.(%s)$`, scopesRegexp, componentsRegexp))
}()
-// For OutputFileProducer interface
-//
-// .<scope>.<component name>, for all ComponentNames (for example: .public.removed-api.txt)
-func (c *commonToSdkLibraryAndImport) commonOutputFiles(tag string) (android.Paths, error) {
- if groups := tagSplitter.FindStringSubmatch(tag); groups != nil {
- scopeName := groups[1]
- component := groups[2]
-
- if scope, ok := scopeByName[scopeName]; ok {
- paths := c.findScopePaths(scope)
- if paths == nil {
- return nil, fmt.Errorf("%q does not provide api scope %s", c.module.RootLibraryName(), scopeName)
- }
-
- switch component {
- case stubsSourceComponentName:
- if paths.stubsSrcJar.Valid() {
- return android.Paths{paths.stubsSrcJar.Path()}, nil
- }
-
- case apiTxtComponentName:
- if paths.currentApiFilePath.Valid() {
- return android.Paths{paths.currentApiFilePath.Path()}, nil
- }
-
- case removedApiTxtComponentName:
- if paths.removedApiFilePath.Valid() {
- return android.Paths{paths.removedApiFilePath.Path()}, nil
- }
-
- case annotationsComponentName:
- if paths.annotationsZip.Valid() {
- return android.Paths{paths.annotationsZip.Path()}, nil
- }
- }
-
- return nil, fmt.Errorf("%s not available for api scope %s", component, scopeName)
- } else {
- return nil, fmt.Errorf("unknown scope %s in %s", scope, tag)
+func (module *commonToSdkLibraryAndImport) setOutputFiles(ctx android.ModuleContext) {
+ if module.doctagPaths != nil {
+ ctx.SetOutputFiles(module.doctagPaths, ".doctags")
+ }
+ for _, scopeName := range android.SortedKeys(scopeByName) {
+ paths := module.findScopePaths(scopeByName[scopeName])
+ if paths == nil {
+ continue
}
-
- } else {
- switch tag {
- case ".doctags":
- if c.doctagPaths != nil {
- return c.doctagPaths, nil
- } else {
- return nil, fmt.Errorf("no doctag_files specified on %s", c.module.RootLibraryName())
+ componentToOutput := map[string]android.OptionalPath{
+ stubsSourceComponentName: paths.stubsSrcJar,
+ apiTxtComponentName: paths.currentApiFilePath,
+ removedApiTxtComponentName: paths.removedApiFilePath,
+ annotationsComponentName: paths.annotationsZip,
+ }
+ for _, component := range android.SortedKeys(componentToOutput) {
+ if componentToOutput[component].Valid() {
+ ctx.SetOutputFiles(android.Paths{componentToOutput[component].Path()}, "."+scopeName+"."+component)
}
}
- return nil, nil
}
}
@@ -1579,20 +1545,6 @@
}
}
-func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
- paths, err := module.commonOutputFiles(tag)
- if paths != nil || err != nil {
- return paths, err
- }
- if module.requiresRuntimeImplementationLibrary() {
- return module.implLibraryModule.OutputFiles(tag)
- }
- if tag == "" {
- return nil, nil
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
-
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if disableSourceApexVariant(ctx) {
// Prebuilts are active, do not create the installation rules for the source javalib.
@@ -1702,6 +1654,10 @@
}
}
android.SetProvider(ctx, android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
+ module.setOutputFiles(ctx)
+ if module.requiresRuntimeImplementationLibrary() && module.implLibraryModule != nil {
+ setOutputFiles(ctx, module.implLibraryModule.Module)
+ }
}
func (module *SdkLibrary) BuiltInstalledForApex() []dexpreopterInstall {
@@ -2007,10 +1963,6 @@
if len(module.sdkLibraryProperties.Api_packages) != 0 {
droidstubsArgs = append(droidstubsArgs, "--stub-packages "+strings.Join(module.sdkLibraryProperties.Api_packages, ":"))
}
- if len(module.sdkLibraryProperties.Hidden_api_packages) != 0 {
- droidstubsArgs = append(droidstubsArgs,
- android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package "))
- }
droidstubsArgs = append(droidstubsArgs, module.sdkLibraryProperties.Droiddoc_options...)
disabledWarnings := []string{"HiddenSuperclass"}
if proptools.BoolDefault(module.sdkLibraryProperties.Api_lint.Legacy_errors_allowed, true) {
@@ -2937,18 +2889,6 @@
var _ hiddenAPIModule = (*SdkLibraryImport)(nil)
-func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) {
- paths, err := module.commonOutputFiles(tag)
- if paths != nil || err != nil {
- return paths, err
- }
- if module.implLibraryModule != nil {
- return module.implLibraryModule.OutputFiles(tag)
- } else {
- return nil, nil
- }
-}
-
func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
module.generateCommonBuildActions(ctx)
@@ -3031,6 +2971,11 @@
}
}
}
+
+ module.setOutputFiles(ctx)
+ if module.implLibraryModule != nil {
+ setOutputFiles(ctx, module.implLibraryModule.Module)
+ }
}
func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 39f8c76..a8a1494 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -492,7 +492,7 @@
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "bar" variant "android_common": failed to get output file from module "foo" at tag ".public.annotations.zip": annotations.zip not available for api scope public`)).
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "bar" variant "android_common": unsupported module reference tag ".public.annotations.zip"`)).
RunTestWithBp(t, `
java_sdk_library {
name: "foo",
@@ -517,7 +517,7 @@
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"foo" does not provide api scope system`)).
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "bar" variant "android_common": unsupported module reference tag ".system.stubs.source"`)).
RunTestWithBp(t, `
java_sdk_library {
name: "foo",
@@ -606,7 +606,7 @@
t.Run("stubs.source", func(t *testing.T) {
prepareForJavaTest.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`stubs.source not available for api scope public`)).
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.stubs.source"`)).
RunTestWithBp(t, bp+`
java_library {
name: "bar",
@@ -621,7 +621,7 @@
t.Run("api.txt", func(t *testing.T) {
prepareForJavaTest.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`api.txt not available for api scope public`)).
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.api.txt"`)).
RunTestWithBp(t, bp+`
java_library {
name: "bar",
@@ -635,7 +635,7 @@
t.Run("removed-api.txt", func(t *testing.T) {
prepareForJavaTest.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`removed-api.txt not available for api scope public`)).
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.removed-api.txt"`)).
RunTestWithBp(t, bp+`
java_library {
name: "bar",
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 3a8d3cf..87c0814 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -104,7 +104,7 @@
// Secondly, if there's provideLibs gathered from provideModules, append them
var provideLibs []string
for _, m := range provideModules {
- if c, ok := m.(*cc.Module); ok && cc.IsStubTarget(c) {
+ if c, ok := m.(*cc.Module); ok && (cc.IsStubTarget(c) || c.HasLlndkStubs()) {
for _, ps := range c.PackagingSpecs() {
provideLibs = append(provideLibs, ps.FileName())
}
diff --git a/rust/benchmark.go b/rust/benchmark.go
index c0f1e24..8c3e515 100644
--- a/rust/benchmark.go
+++ b/rust/benchmark.go
@@ -22,7 +22,7 @@
type BenchmarkProperties struct {
// Disables the creation of a test-specific directory when used with
// relative_install_path. Useful if several tests need to be in the same
- // directory, but test_per_src doesn't work.
+ // directory.
No_named_install_directory *bool
// the name of the test configuration (for example "AndroidBenchmark.xml") that should be
diff --git a/rust/builder.go b/rust/builder.go
index 1ce92f4..f469f56 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -520,6 +520,9 @@
// this flag.
rustdocFlags = append(rustdocFlags, "-Z", "unstable-options", "--enable-index-page")
+ // Ensure we use any special-case code-paths for Soong.
+ rustdocFlags = append(rustdocFlags, "--cfg", "soong")
+
targetTriple := ctx.toolchain().RustTriple()
// Collect rustc flags
diff --git a/rust/config/darwin_host.go b/rust/config/darwin_host.go
index 03bea82..a4bc187 100644
--- a/rust/config/darwin_host.go
+++ b/rust/config/darwin_host.go
@@ -21,7 +21,7 @@
)
var (
- DarwinRustFlags = []string{}
+ DarwinRustFlags = []string{"-C split-debuginfo=off"}
DarwinRustLinkFlags = []string{
"-B${cc_config.MacToolPath}",
}
diff --git a/rust/library.go b/rust/library.go
index 96c02c8..ba73f27 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -86,8 +86,6 @@
VariantIsRlib bool `blueprint:"mutated"`
// This variant is a shared library
VariantIsShared bool `blueprint:"mutated"`
- // This variant is a static library
- VariantIsStatic bool `blueprint:"mutated"`
// This variant is a source provider
VariantIsSource bool `blueprint:"mutated"`
@@ -179,7 +177,7 @@
}
func (library *libraryDecorator) static() bool {
- return library.MutatedProperties.VariantIsStatic
+ return false
}
func (library *libraryDecorator) source() bool {
@@ -205,14 +203,12 @@
func (library *libraryDecorator) setRlib() {
library.MutatedProperties.VariantIsRlib = true
library.MutatedProperties.VariantIsDylib = false
- library.MutatedProperties.VariantIsStatic = false
library.MutatedProperties.VariantIsShared = false
}
func (library *libraryDecorator) setDylib() {
library.MutatedProperties.VariantIsRlib = false
library.MutatedProperties.VariantIsDylib = true
- library.MutatedProperties.VariantIsStatic = false
library.MutatedProperties.VariantIsShared = false
}
@@ -229,17 +225,13 @@
}
func (library *libraryDecorator) setShared() {
- library.MutatedProperties.VariantIsStatic = false
library.MutatedProperties.VariantIsShared = true
library.MutatedProperties.VariantIsRlib = false
library.MutatedProperties.VariantIsDylib = false
}
func (library *libraryDecorator) setStatic() {
- library.MutatedProperties.VariantIsStatic = true
- library.MutatedProperties.VariantIsShared = false
- library.MutatedProperties.VariantIsRlib = false
- library.MutatedProperties.VariantIsDylib = false
+ panic(fmt.Errorf("static variant is not supported for rust modules, use the rlib variant instead"))
}
func (library *libraryDecorator) setSource() {
diff --git a/rust/rust.go b/rust/rust.go
index 6b7b2fb..9dae75e 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -501,7 +501,7 @@
var _ cc.Coverage = (*Module)(nil)
-func (mod *Module) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
+func (mod *Module) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
return mod.coverage != nil && mod.coverage.Properties.NeedCoverageVariant
}
@@ -1107,7 +1107,6 @@
rlibDepTag = dependencyTag{name: "rlibTag", library: true}
dylibDepTag = dependencyTag{name: "dylib", library: true, dynamic: true}
procMacroDepTag = dependencyTag{name: "procMacro", procMacro: true}
- testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"}
sourceDepTag = dependencyTag{name: "source"}
dataLibDepTag = dependencyTag{name: "data lib"}
dataBinDepTag = dependencyTag{name: "data bin"}
diff --git a/rust/test.go b/rust/test.go
index 2583893..3087d8d 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -27,7 +27,7 @@
type TestProperties struct {
// Disables the creation of a test-specific directory when used with
// relative_install_path. Useful if several tests need to be in the same
- // directory, but test_per_src doesn't work.
+ // directory.
No_named_install_directory *bool
// the name of the test configuration (for example "AndroidTest.xml") that should be
diff --git a/scripts/gen_build_prop.py b/scripts/gen_build_prop.py
index 42e3207..799e00b 100644
--- a/scripts/gen_build_prop.py
+++ b/scripts/gen_build_prop.py
@@ -19,9 +19,12 @@
import argparse
import contextlib
import json
+import os
import subprocess
import sys
+TEST_KEY_DIR = "build/make/target/product/security"
+
def get_build_variant(product_config):
if product_config["Eng"]:
return "eng"
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 9490d12..5d76930 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -148,6 +148,9 @@
srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -368,6 +371,9 @@
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -455,6 +461,9 @@
},
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -697,6 +706,9 @@
srcs: ["x86_64/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -824,6 +836,9 @@
export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -932,6 +947,9 @@
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -950,6 +968,9 @@
srcs: ["arm/lib/myothernativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -967,6 +988,9 @@
srcs: ["arm/lib/mysystemnativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -1041,6 +1065,9 @@
export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -1127,6 +1154,9 @@
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -2021,6 +2051,9 @@
srcs: ["arm/lib/sslnil.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -2038,6 +2071,9 @@
srcs: ["arm/lib/sslempty.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -2055,6 +2091,9 @@
srcs: ["arm/lib/sslnonempty.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`))
@@ -2114,6 +2153,9 @@
srcs: ["linux_glibc/x86/lib/sslvariants.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
)
@@ -2154,6 +2196,7 @@
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
+ stl: "none",
compile_multilib: "both",
stubs: {
versions: [
@@ -2171,6 +2214,9 @@
srcs: ["arm/lib/stubslib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`))
}
@@ -2242,6 +2288,9 @@
srcs: ["linux_glibc/x86/lib/stubslib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
)
@@ -2298,6 +2347,9 @@
srcs: ["linux_glibc/x86/lib/mylib-host.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -2355,6 +2407,9 @@
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
diff --git a/sdk/update.go b/sdk/update.go
index 0a97fd9..198c8d4 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -434,6 +434,14 @@
prebuiltModule := memberType.AddPrebuiltModule(memberCtx, member)
s.createMemberSnapshot(memberCtx, member, prebuiltModule.(*bpModule))
+ // Set stripper to none to skip stripping for generated snapshots.
+ // Mainline prebuilts (cc_prebuilt_library_shared) are not strippable in older platforms.
+ // Thus, stripping should be skipped when being used as prebuilts.
+ if memberType.DisablesStrip() {
+ stripPropertySet := prebuiltModule.(*bpModule).AddPropertySet("strip")
+ stripPropertySet.AddProperty("none", true)
+ }
+
if member.memberType != android.LicenseModuleSdkMemberType && !builder.isInternalMember(member.name) {
// More exceptions
// 1. Skip BCP and SCCP fragments
diff --git a/ui/build/config.go b/ui/build/config.go
index c4a6797..2470f84 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -99,9 +99,10 @@
// Autodetected
totalRAM uint64
- brokenDupRules bool
- brokenUsesNetwork bool
- brokenNinjaEnvVars []string
+ brokenDupRules bool
+ brokenUsesNetwork bool
+ brokenNinjaEnvVars []string
+ brokenMissingOutputs bool
pathReplaced bool
@@ -120,6 +121,10 @@
// There's quite a bit of overlap with module-info.json and soong module graph. We
// could consider merging them.
moduleDebugFile string
+
+ // Whether to use n2 instead of ninja. This is controlled with the
+ // environment variable SOONG_USE_N2
+ useN2 bool
}
type NinjaWeightListSource uint
@@ -282,6 +287,10 @@
ret.moduleDebugFile, _ = filepath.Abs(shared.JoinPath(ret.SoongOutDir(), "soong-debug-info.json"))
}
+ if os.Getenv("SOONG_USE_N2") == "true" {
+ ret.useN2 = true
+ }
+
ret.environ.Unset(
// We're already using it
"USE_SOONG_UI",
@@ -312,6 +321,7 @@
"DISPLAY",
"GREP_OPTIONS",
"JAVAC",
+ "LEX",
"NDK_ROOT",
"POSIXLY_CORRECT",
@@ -337,6 +347,9 @@
// We read it here already, don't let others share in the fun
"GENERATE_SOONG_DEBUG",
+
+ // Use config.useN2 instead.
+ "SOONG_USE_N2",
)
if ret.UseGoma() || ret.ForceUseGoma() {
@@ -1608,6 +1621,14 @@
return c.brokenNinjaEnvVars
}
+func (c *configImpl) SetBuildBrokenMissingOutputs(val bool) {
+ c.brokenMissingOutputs = val
+}
+
+func (c *configImpl) BuildBrokenMissingOutputs() bool {
+ return c.brokenMissingOutputs
+}
+
func (c *configImpl) SetTargetDeviceDir(dir string) {
c.targetDeviceDir = dir
}
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index eba86a0..e77df44 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -235,6 +235,11 @@
"BUILD_BROKEN_SRC_DIR_IS_WRITABLE",
"BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST",
+ // Whether missing outputs should be treated as warnings
+ // instead of errors.
+ // `true` will relegate missing outputs to warnings.
+ "BUILD_BROKEN_MISSING_OUTPUTS",
+
// Not used, but useful to be in the soong.log
"TARGET_BUILD_TYPE",
"HOST_ARCH",
@@ -301,4 +306,5 @@
config.SetBuildBrokenUsesNetwork(makeVars["BUILD_BROKEN_USES_NETWORK"] == "true")
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))
config.SetSourceRootDirs(strings.Fields(makeVars["PRODUCT_SOURCE_ROOT_DIRS"]))
+ config.SetBuildBrokenMissingOutputs(makeVars["BUILD_BROKEN_MISSING_OUTPUTS"] == "true")
}
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index 551b8ab..1935e72 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -56,6 +56,17 @@
"-d", "stats",
"--frontend_file", fifo,
}
+ if config.useN2 {
+ executable = config.PrebuiltBuildTool("n2")
+ args = []string{
+ "-d", "trace",
+ // TODO: implement these features, or remove them.
+ //"-d", "keepdepfile",
+ //"-d", "keeprsp",
+ //"-d", "stats",
+ "--frontend-file", fifo,
+ }
+ }
args = append(args, config.NinjaArgs()...)
@@ -72,10 +83,22 @@
args = append(args, "-f", config.CombinedNinjaFile())
- args = append(args,
- "-o", "usesphonyoutputs=yes",
- "-w", "dupbuild=err",
- "-w", "missingdepfile=err")
+ if !config.useN2 {
+ args = append(args,
+ "-o", "usesphonyoutputs=yes",
+ "-w", "dupbuild=err",
+ "-w", "missingdepfile=err")
+ }
+
+ if !config.BuildBrokenMissingOutputs() {
+ // Missing outputs will be treated as errors.
+ // BUILD_BROKEN_MISSING_OUTPUTS can be used to bypass this check.
+ if !config.useN2 {
+ args = append(args,
+ "-w", "missingoutfile=err",
+ )
+ }
+ }
cmd := Command(ctx, config, "ninja", executable, args...)
@@ -89,16 +112,22 @@
switch config.NinjaWeightListSource() {
case NINJA_LOG:
- cmd.Args = append(cmd.Args, "-o", "usesninjalogasweightlist=yes")
+ if !config.useN2 {
+ cmd.Args = append(cmd.Args, "-o", "usesninjalogasweightlist=yes")
+ }
case EVENLY_DISTRIBUTED:
// pass empty weight list means ninja considers every tasks's weight as 1(default value).
- cmd.Args = append(cmd.Args, "-o", "usesweightlist=/dev/null")
+ if !config.useN2 {
+ cmd.Args = append(cmd.Args, "-o", "usesweightlist=/dev/null")
+ }
case EXTERNAL_FILE:
fallthrough
case HINT_FROM_SOONG:
// The weight list is already copied/generated.
- ninjaWeightListPath := filepath.Join(config.OutDir(), ninjaWeightListFileName)
- cmd.Args = append(cmd.Args, "-o", "usesweightlist="+ninjaWeightListPath)
+ if !config.useN2 {
+ ninjaWeightListPath := filepath.Join(config.OutDir(), ninjaWeightListFileName)
+ cmd.Args = append(cmd.Args, "-o", "usesweightlist="+ninjaWeightListPath)
+ }
}
// Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
@@ -198,11 +227,16 @@
// We don't want this build broken flag to cause reanalysis, so allow it through to the
// actions.
"BUILD_BROKEN_INCORRECT_PARTITION_IMAGES",
+ "SOONG_USE_N2",
+ "RUST_BACKTRACE",
}, config.BuildBrokenNinjaUsesEnvVars()...)...)
}
cmd.Environment.Set("DIST_DIR", config.DistDir())
cmd.Environment.Set("SHELL", "/bin/bash")
+ if config.useN2 {
+ cmd.Environment.Set("RUST_BACKTRACE", "1")
+ }
// Print the environment variables that Ninja is operating in.
ctx.Verboseln("Ninja environment: ")
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 77fee0a..e18cc25 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -638,6 +638,22 @@
"--frontend_file", fifo,
"-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"),
}
+ if config.useN2 {
+ ninjaArgs = []string{
+ // TODO: implement these features, or remove them.
+ //"-d", "keepdepfile",
+ //"-d", "stats",
+ //"-o", "usesphonyoutputs=yes",
+ //"-o", "preremoveoutputs=yes",
+ //"-w", "dupbuild=err",
+ //"-w", "outputdir=err",
+ //"-w", "missingoutfile=err",
+ "-v",
+ "-j", strconv.Itoa(config.Parallel()),
+ "--frontend-file", fifo,
+ "-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"),
+ }
+ }
if extra, ok := config.Environment().Get("SOONG_UI_NINJA_ARGS"); ok {
ctx.Printf(`CAUTION: arguments in $SOONG_UI_NINJA_ARGS=%q, e.g. "-n", can make soong_build FAIL or INCORRECT`, extra)
@@ -645,8 +661,13 @@
}
ninjaArgs = append(ninjaArgs, targets...)
+ ninjaCmd := config.PrebuiltBuildTool("ninja")
+ if config.useN2 {
+ ninjaCmd = config.PrebuiltBuildTool("n2")
+ }
+
cmd := Command(ctx, config, "soong bootstrap",
- config.PrebuiltBuildTool("ninja"), ninjaArgs...)
+ ninjaCmd, ninjaArgs...)
var ninjaEnv Environment