Snap for 11510257 from 592b54c443bffb7082935ac79cd18dfa953f92e3 to simpleperf-release
Change-Id: Iad5befe36704d994c0954ed7ef780348049a9a9b
diff --git a/README.md b/README.md
index f471c47..93260e6 100644
--- a/README.md
+++ b/README.md
@@ -314,6 +314,9 @@
* `["//visibility:override"]`: Discards any rules inherited from defaults or a
creating module. Can only be used at the beginning of a list of visibility
rules.
+* `["//visibility:any_partition"]`: Any modules of type android_filesystem
+or android_system_image can use this module. Intended for modules that no one
+should link against, but should still be included in soong-built partitions.
* `["//some/package:__pkg__", "//other/package:__pkg__"]`: Only modules in
`some/package` and `other/package` (defined in `some/package/*.bp` and
`other/package/*.bp`) have access to this module. Note that sub-packages do not
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index 78f506a..392e819 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -40,6 +40,9 @@
// Container(system/vendor/apex) that this module belongs to
Container string
+
+ // The flags will only be repackaged if this prop is true.
+ Exportable bool
}
intermediatePath android.WritablePath
@@ -159,6 +162,7 @@
android.SetProvider(ctx, android.AconfigDeclarationsProviderKey, android.AconfigDeclarationsProviderData{
Package: module.properties.Package,
Container: module.properties.Container,
+ Exportable: module.properties.Exportable,
IntermediateCacheOutputPath: intermediateCacheFilePath,
IntermediateDumpOutputPath: intermediateDumpFilePath,
})
diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go
index d508af7..1fe3c86 100644
--- a/aconfig/aconfig_declarations_test.go
+++ b/aconfig/aconfig_declarations_test.go
@@ -27,6 +27,7 @@
name: "module_name",
package: "com.example.package",
container: "com.android.foo",
+ exportable: true,
srcs: [
"foo.aconfig",
"bar.aconfig",
@@ -41,6 +42,7 @@
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
+ android.AssertBoolEquals(t, "exportable", depData.Exportable, true)
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
t.Errorf("Missing intermediates proto path in provider: %s", depData.IntermediateCacheOutputPath.String())
}
@@ -48,3 +50,22 @@
t.Errorf("Missing intermediates text path in provider: %s", depData.IntermediateDumpOutputPath.String())
}
}
+
+func TestAconfigDeclarationsWithExportableUnset(t *testing.T) {
+ bp := `
+ aconfig_declarations {
+ name: "module_name",
+ package: "com.example.package",
+ container: "com.android.foo",
+ srcs: [
+ "foo.aconfig",
+ "bar.aconfig",
+ ],
+ }
+ `
+ result := runTest(t, android.FixtureExpectsNoErrors, bp)
+
+ module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
+ depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
+ android.AssertBoolEquals(t, "exportable", depData.Exportable, false)
+}
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index b6c9023..72fe495 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -31,7 +31,8 @@
}
type allAconfigDeclarationsSingleton struct {
- intermediatePath android.OutputPath
+ intermediateBinaryProtoPath android.OutputPath
+ intermediateTextProtoPath android.OutputPath
}
func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
@@ -59,20 +60,37 @@
panic(fmt.Errorf("Only one aconfig_declarations allowed for each package."))
}
- // Generate build action for aconfig
- this.intermediatePath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
+ // Generate build action for aconfig (binary proto output)
+ this.intermediateBinaryProtoPath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
ctx.Build(pctx, android.BuildParams{
Rule: AllDeclarationsRule,
Inputs: cacheFiles,
- Output: this.intermediatePath,
+ Output: this.intermediateBinaryProtoPath,
Description: "all_aconfig_declarations",
Args: map[string]string{
"cache_files": android.JoinPathsWithPrefix(cacheFiles, "--cache "),
},
})
- ctx.Phony("all_aconfig_declarations", this.intermediatePath)
+ ctx.Phony("all_aconfig_declarations", this.intermediateBinaryProtoPath)
+
+ // Generate build action for aconfig (text proto output)
+ this.intermediateTextProtoPath = android.PathForIntermediates(ctx, "all_aconfig_declarations.textproto")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: AllDeclarationsRuleTextProto,
+ Inputs: cacheFiles,
+ Output: this.intermediateTextProtoPath,
+ Description: "all_aconfig_declarations_textproto",
+ Args: map[string]string{
+ "cache_files": android.JoinPathsWithPrefix(cacheFiles, "--cache "),
+ },
+ })
+ ctx.Phony("all_aconfig_declarations_textproto", this.intermediateTextProtoPath)
}
func (this *allAconfigDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) {
- ctx.DistForGoal("droid", this.intermediatePath)
+ ctx.DistForGoal("droid", this.intermediateBinaryProtoPath)
+ for _, goal := range []string{"droid", "sdk"} {
+ ctx.DistForGoalWithFilename(goal, this.intermediateBinaryProtoPath, "flags.pb")
+ ctx.DistForGoalWithFilename(goal, this.intermediateTextProtoPath, "flags.textproto")
+ }
}
diff --git a/aconfig/codegen/Android.bp b/aconfig/codegen/Android.bp
index 494f7e6..0c78b94 100644
--- a/aconfig/codegen/Android.bp
+++ b/aconfig/codegen/Android.bp
@@ -17,6 +17,7 @@
"soong-rust",
],
srcs: [
+ "aconfig_declarations_group.go",
"cc_aconfig_library.go",
"init.go",
"java_aconfig_library.go",
@@ -24,6 +25,7 @@
"testing.go",
],
testSrcs: [
+ "aconfig_declarations_group_test.go",
"java_aconfig_library_test.go",
"cc_aconfig_library_test.go",
"rust_aconfig_library_test.go",
diff --git a/aconfig/codegen/aconfig_declarations_group.go b/aconfig/codegen/aconfig_declarations_group.go
new file mode 100644
index 0000000..203b6be
--- /dev/null
+++ b/aconfig/codegen/aconfig_declarations_group.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 codegen
+
+import (
+ "android/soong/aconfig"
+ "android/soong/android"
+ "fmt"
+
+ "github.com/google/blueprint"
+)
+
+type dependencyTag struct {
+ blueprint.BaseDependencyTag
+ name string
+}
+
+var (
+ aconfigDeclarationsGroupTag = dependencyTag{name: "aconfigDeclarationsGroup"}
+ javaAconfigLibraryTag = dependencyTag{name: "javaAconfigLibrary"}
+ ccAconfigLibraryTag = dependencyTag{name: "ccAconfigLibrary"}
+ rustAconfigLibraryTag = dependencyTag{name: "rustAconfigLibrary"}
+)
+
+type AconfigDeclarationsGroup struct {
+ android.ModuleBase
+ android.DefaultableModuleBase
+
+ properties AconfigDeclarationsGroupProperties
+
+ aconfigDeclarationNames []string
+ intermediateCacheOutputPaths android.Paths
+ javaSrcjars android.Paths
+}
+
+type AconfigDeclarationsGroupProperties struct {
+
+ // Name of the aconfig_declarations_group modules
+ Aconfig_declarations_groups []string
+
+ // Name of the java_aconfig_library modules
+ Java_aconfig_libraries []string
+
+ // Name of the cc_aconfig_library modules
+ Cc_aconfig_libraries []string
+
+ // Name of the rust_aconfig_library modules
+ Rust_aconfig_libraries []string
+}
+
+func AconfigDeclarationsGroupFactory() android.Module {
+ module := &AconfigDeclarationsGroup{}
+ module.AddProperties(&module.properties)
+ android.InitAndroidModule(module)
+ android.InitDefaultableModule(module)
+ return module
+}
+
+func (adg *AconfigDeclarationsGroup) DepsMutator(ctx android.BottomUpMutatorContext) {
+ ctx.AddDependency(ctx.Module(), aconfigDeclarationsGroupTag, adg.properties.Aconfig_declarations_groups...)
+ ctx.AddDependency(ctx.Module(), javaAconfigLibraryTag, adg.properties.Java_aconfig_libraries...)
+ ctx.AddDependency(ctx.Module(), ccAconfigLibraryTag, adg.properties.Cc_aconfig_libraries...)
+ ctx.AddDependency(ctx.Module(), rustAconfigLibraryTag, adg.properties.Rust_aconfig_libraries...)
+}
+
+func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ tag := ctx.OtherModuleDependencyTag(dep)
+ if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.CodegenInfoProvider); ok {
+
+ // aconfig declaration names and cache files are collected for all aconfig library dependencies
+ adg.aconfigDeclarationNames = append(adg.aconfigDeclarationNames, provider.AconfigDeclarations...)
+ adg.intermediateCacheOutputPaths = append(adg.intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...)
+
+ switch tag {
+ case aconfigDeclarationsGroupTag:
+ // Will retrieve outputs from another language codegen modules when support is added
+ adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
+ case javaAconfigLibraryTag:
+ adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
+ }
+ }
+ })
+}
+
+func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ adg.VisitDeps(ctx)
+ adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames)
+ adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths)
+
+ android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
+ AconfigDeclarations: adg.aconfigDeclarationNames,
+ IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths,
+ Srcjars: adg.javaSrcjars,
+ })
+}
+
+var _ android.OutputFileProducer = (*AconfigDeclarationsGroup)(nil)
+
+func (adg *AconfigDeclarationsGroup) OutputFiles(tag string) (android.Paths, error) {
+ switch tag {
+ case "":
+ return adg.intermediateCacheOutputPaths, nil
+ case ".srcjars":
+ return adg.javaSrcjars, nil
+ default:
+ return nil, fmt.Errorf("unsupported module reference tag %s", tag)
+ }
+}
+
+func (adg *AconfigDeclarationsGroup) Srcjars() android.Paths {
+ return adg.javaSrcjars
+}
+
+func (adg *AconfigDeclarationsGroup) AconfigDeclarations() []string {
+ return adg.aconfigDeclarationNames
+}
diff --git a/aconfig/codegen/aconfig_declarations_group_test.go b/aconfig/codegen/aconfig_declarations_group_test.go
new file mode 100644
index 0000000..ec7cea3
--- /dev/null
+++ b/aconfig/codegen/aconfig_declarations_group_test.go
@@ -0,0 +1,79 @@
+// 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 codegen
+
+import (
+ "android/soong/android"
+ "android/soong/java"
+ "testing"
+)
+
+func TestAconfigDeclarationsGroup(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents,
+ java.PrepareForTestWithJavaDefaultModules,
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "foo-aconfig",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }
+
+ java_aconfig_library {
+ name: "foo-java",
+ aconfig_declarations: "foo-aconfig",
+ }
+
+ aconfig_declarations {
+ name: "bar-aconfig",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }
+
+ java_aconfig_library {
+ name: "bar-java",
+ aconfig_declarations: "bar-aconfig",
+ }
+
+ aconfig_declarations_group {
+ name: "my_group",
+ java_aconfig_libraries: [
+ "foo-java",
+ "bar-java",
+ ],
+ }
+
+ java_library {
+ name: "baz",
+ srcs: [
+ ":my_group{.srcjars}",
+ ],
+ }
+ `)
+
+ // Check if aconfig_declarations_group module depends on the aconfig_library modules
+ java.CheckModuleDependencies(t, result.TestContext, "my_group", "", []string{
+ `bar-java`,
+ `foo-java`,
+ })
+
+ // Check if srcjar files are correctly passed to the reverse dependency of
+ // aconfig_declarations_group module
+ bazModule := result.ModuleForTests("baz", "android_common")
+ bazJavacSrcjars := bazModule.Rule("javac").Args["srcJars"]
+ errorMessage := "baz javac argument expected to contain srcjar provided by aconfig_declrations_group"
+ android.AssertStringDoesContain(t, errorMessage, bazJavacSrcjars, "foo-java.srcjar")
+ android.AssertStringDoesContain(t, errorMessage, bazJavacSrcjars, "bar-java.srcjar")
+}
diff --git a/aconfig/codegen/init.go b/aconfig/codegen/init.go
index 0bff9d2..73a8951 100644
--- a/aconfig/codegen/init.go
+++ b/aconfig/codegen/init.go
@@ -77,6 +77,7 @@
}
func RegisterBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("aconfig_declarations_group", AconfigDeclarationsGroupFactory)
ctx.RegisterModuleType("cc_aconfig_library", CcAconfigLibraryFactory)
ctx.RegisterModuleType("java_aconfig_library", JavaDeclarationsLibraryFactory)
ctx.RegisterModuleType("rust_aconfig_library", RustAconfigLibraryFactory)
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index 4b8d346..7d7296e 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -17,6 +17,7 @@
import (
"fmt"
+ "android/soong/aconfig"
"android/soong/android"
"android/soong/java"
@@ -91,6 +92,12 @@
if !isModeSupported(mode) {
ctx.PropertyErrorf("mode", "%q is not a supported mode", mode)
}
+ // TODO: uncomment this part after internal clean up
+ //if mode == "exported" && !declarations.Exportable {
+ // // if mode is exported, the corresponding aconfig_declaration must mark its
+ // // exportable property true
+ // ctx.PropertyErrorf("mode", "exported mode requires its aconfig_declaration has exportable prop true")
+ //}
ctx.Build(pctx, android.BuildParams{
Rule: javaRule,
@@ -102,12 +109,21 @@
},
})
- // Mark our generated code as possibly needing jarjar repackaging
- // TODO: Maybe control this with a property?
- module.AddJarJarRenameRule(declarations.Package+".Flags", "")
- module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
- module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
- module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
+ if declarations.Exportable {
+ // Mark our generated code as possibly needing jarjar repackaging
+ // The repackaging only happens when the corresponding aconfig_declaration
+ // has property exportable true
+ module.AddJarJarRenameRule(declarations.Package+".Flags", "")
+ module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
+ module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
+ module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
+ }
+
+ android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
+ AconfigDeclarations: []string{declarationsModules[0].Name()},
+ IntermediateCacheOutputPaths: android.Paths{declarations.IntermediateCacheOutputPath},
+ Srcjars: android.Paths{srcJarPath},
+ })
return srcJarPath
}
diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go
index 85d2675..de45b5c 100644
--- a/aconfig/codegen/java_aconfig_library_test.go
+++ b/aconfig/codegen/java_aconfig_library_test.go
@@ -176,6 +176,7 @@
name: "my_aconfig_declarations",
package: "com.example.package",
srcs: ["foo.aconfig"],
+ exportable: true,
}
java_aconfig_library {
diff --git a/aconfig/init.go b/aconfig/init.go
index 3e9d297..e64429f 100644
--- a/aconfig/init.go
+++ b/aconfig/init.go
@@ -20,6 +20,20 @@
"github.com/google/blueprint"
)
+type CodegenInfo struct {
+ // AconfigDeclarations is the name of the aconfig_declarations modules that
+ // the codegen module is associated with
+ AconfigDeclarations []string
+
+ // Paths to the cache files of the associated aconfig_declaration modules
+ IntermediateCacheOutputPaths android.Paths
+
+ // Paths to the srcjar files generated from the java_aconfig_library modules
+ Srcjars android.Paths
+}
+
+var CodegenInfoProvider = blueprint.NewProvider[CodegenInfo]()
+
var (
pctx = android.NewPackageContext("android/soong/aconfig")
@@ -43,7 +57,7 @@
// For create-device-config-sysprops: Generate aconfig flag value map text file
aconfigTextRule = pctx.AndroidStaticRule("aconfig_text",
blueprint.RuleParams{
- Command: `${aconfig} dump-cache --format='{fully_qualified_name}={state:bool}'` +
+ Command: `${aconfig} dump-cache --dedup --format='{fully_qualified_name}={state:bool}'` +
` --cache ${in}` +
` --out ${out}.tmp` +
` && ( if cmp -s ${out}.tmp ${out} ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`,
@@ -56,11 +70,26 @@
// For all_aconfig_declarations: Combine all parsed_flags proto files
AllDeclarationsRule = pctx.AndroidStaticRule("All_aconfig_declarations_dump",
blueprint.RuleParams{
- Command: `${aconfig} dump-cache --format protobuf --out ${out} ${cache_files}`,
+ Command: `${aconfig} dump-cache --dedup --format protobuf --out ${out} ${cache_files}`,
CommandDeps: []string{
"${aconfig}",
},
}, "cache_files")
+ AllDeclarationsRuleTextProto = pctx.AndroidStaticRule("All_aconfig_declarations_dump_textproto",
+ blueprint.RuleParams{
+ Command: `${aconfig} dump-cache --dedup --format textproto --out ${out} ${cache_files}`,
+ CommandDeps: []string{
+ "${aconfig}",
+ },
+ }, "cache_files")
+
+ CreateStorageRule = pctx.AndroidStaticRule("aconfig_create_storage",
+ blueprint.RuleParams{
+ Command: `${aconfig} create-storage --container ${container} --file ${file_type} --out ${out} ${cache_files}`,
+ CommandDeps: []string{
+ "${aconfig}",
+ },
+ }, "container", "file_type", "cache_files")
// For exported_java_aconfig_library: Generate a JAR from all
// java_aconfig_libraries to be consumed by apps built outside the
@@ -73,7 +102,7 @@
blueprint.RuleParams{
Command: `rm -rf ${out}.tmp` +
`&& for cache in ${cache_files}; do ` +
- ` if [ -n "$$(${aconfig} dump-cache --cache $$cache --filter=is_exported:true --format='{fully_qualified_name}')" ]; then ` +
+ ` if [ -n "$$(${aconfig} dump-cache --dedup --cache $$cache --filter=is_exported:true --format='{fully_qualified_name}')" ]; then ` +
` ${aconfig} create-java-lib --cache $$cache --mode=exported --out ${out}.tmp; ` +
` fi ` +
`done` +
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index 1444e7d..74c1a5e 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -35,6 +35,7 @@
type AconfigDeclarationsProviderData struct {
Package string
Container string
+ Exportable bool
IntermediateCacheOutputPath WritablePath
IntermediateDumpOutputPath WritablePath
}
diff --git a/android/all_teams.go b/android/all_teams.go
index dd7d2db..b177e20 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -68,10 +68,6 @@
this.teams_for_mods = make(map[string]moduleTeamInfo)
ctx.VisitAllModules(func(module Module) {
- if !module.Enabled() {
- return
- }
-
bpFile := ctx.BlueprintFile(module)
// Package Modules and Team Modules are stored in a map so we can look them up by name for
diff --git a/android/apex_contributions.go b/android/apex_contributions.go
index 236abf6..c388aff 100644
--- a/android/apex_contributions.go
+++ b/android/apex_contributions.go
@@ -15,6 +15,8 @@
package android
import (
+ "strings"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -98,6 +100,19 @@
func (a *allApexContributions) SetPrebuiltSelectionInfoProvider(ctx BaseModuleContext) {
addContentsToProvider := func(p *PrebuiltSelectionInfoMap, m *apexContributions) {
for _, content := range m.Contents() {
+ // Skip any apexes that have been added to the product specific ignore list
+ if InList(content, ctx.Config().BuildIgnoreApexContributionContents()) {
+ continue
+ }
+ // Coverage builds for TARGET_RELEASE=foo should always build from source,
+ // even if TARGET_RELEASE=foo uses prebuilt mainline modules.
+ // This is necessary because the checked-in prebuilts were generated with
+ // instrumentation turned off.
+ //
+ // Skip any prebuilt contents in coverage builds
+ if strings.HasPrefix(content, "prebuilt_") && (ctx.Config().JavaCoverageEnabled() || ctx.DeviceConfig().NativeCoverageEnabled()) {
+ continue
+ }
if !ctx.OtherModuleExists(content) && !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("%s listed in apex_contributions %s does not exist\n", content, m.Name())
}
diff --git a/android/api_levels.go b/android/api_levels.go
index c019f99..6fa4a0e 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -288,6 +288,8 @@
// a core-for-system-modules.jar for the module-lib API scope.
var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31)
+var ApiLevelR = uncheckedFinalApiLevel(30)
+
// ReplaceFinalizedCodenames returns the API level number associated with that API level
// if the `raw` input is the codename of an API level has been finalized.
// If the input is *not* a finalized codename, the input is returned unmodified.
diff --git a/android/config.go b/android/config.go
index f2dedad..e757d50 100644
--- a/android/config.go
+++ b/android/config.go
@@ -210,13 +210,20 @@
Bool(c.config.productVariables.ReleaseDefaultModuleBuildFromSource)
}
+// Enables flagged apis annotated with READ_WRITE aconfig flags to be included in the stubs
+// and hiddenapi flags so that they are accessible at runtime
+func (c Config) ReleaseExportRuntimeApis() bool {
+ return Bool(c.config.productVariables.ExportRuntimeApis)
+}
+
// Enables ABI monitoring of NDK libraries
func (c Config) ReleaseNdkAbiMonitored() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_NDK_ABI_MONITORED")
}
func (c Config) ReleaseHiddenApiExportableStubs() bool {
- return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS")
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS") ||
+ Bool(c.config.productVariables.HiddenapiExportableStubs)
}
// A DeviceConfig object represents the configuration for a particular device
@@ -648,6 +655,7 @@
"framework-nfc": {},
"framework-ondevicepersonalization": {},
"framework-pdf": {},
+ "framework-pdf-v": {},
"framework-permission": {},
"framework-permission-s": {},
"framework-scheduling": {},
@@ -1336,6 +1344,22 @@
return String(c.productVariables.VendorApiLevel)
}
+func (c *config) PrevVendorApiLevel() string {
+ vendorApiLevel, err := strconv.Atoi(c.VendorApiLevel())
+ if err != nil {
+ panic(fmt.Errorf("Cannot parse vendor API level %s to an integer: %s",
+ c.VendorApiLevel(), err))
+ }
+ if vendorApiLevel < 202404 || vendorApiLevel%100 != 4 {
+ panic("Unknown vendor API level " + c.VendorApiLevel())
+ }
+ // The version before trunk stable is 34.
+ if vendorApiLevel == 202404 {
+ return "34"
+ }
+ return strconv.Itoa(vendorApiLevel - 100)
+}
+
func (c *config) VendorApiLevelFrozen() bool {
return c.productVariables.GetBuildFlagBool("RELEASE_BOARD_API_LEVEL_FROZEN")
}
@@ -1493,18 +1517,18 @@
}
// AfdoProfile returns fully qualified path associated to the given module name
-func (c *deviceConfig) AfdoProfile(name string) (*string, error) {
+func (c *deviceConfig) AfdoProfile(name string) (string, error) {
for _, afdoProfile := range c.config.productVariables.AfdoProfiles {
split := strings.Split(afdoProfile, ":")
if len(split) != 3 {
- return nil, fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+
+ return "", fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+
"The expected format is <module>:<fully-qualified-path-to-fdo_profile>", afdoProfile)
}
if split[0] == name {
- return proptools.StringPtr(strings.Join([]string{split[1], split[2]}, ":")), nil
+ return strings.Join([]string{split[1], split[2]}, ":"), nil
}
}
- return nil, nil
+ return "", nil
}
func (c *deviceConfig) VendorSepolicyDirs() []string {
@@ -1733,10 +1757,6 @@
return String(c.config.productVariables.PlatformSepolicyVersion)
}
-func (c *deviceConfig) TotSepolicyVersion() string {
- return String(c.config.productVariables.TotSepolicyVersion)
-}
-
func (c *deviceConfig) PlatformSepolicyCompatVersions() []string {
return c.config.productVariables.PlatformSepolicyCompatVersions
}
@@ -2042,3 +2062,7 @@
}
return ret
}
+
+func (c *config) BuildIgnoreApexContributionContents() []string {
+ return c.productVariables.BuildIgnoreApexContributionContents
+}
diff --git a/android/packaging.go b/android/packaging.go
index 8873540..a8fb28d 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -85,6 +85,7 @@
// GatherPackagingSpecs gathers PackagingSpecs of transitive dependencies.
GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec
+ GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec
// CopyDepsToZip zips the built artifacts of the dependencies into the given zip file and
// returns zip entries in it. This is expected to be called in GenerateAndroidBuildActions,
@@ -221,14 +222,18 @@
}
}
-// See PackageModule.GatherPackagingSpecs
-func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec {
+func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec {
m := make(map[string]PackagingSpec)
ctx.VisitDirectDeps(func(child Module) {
if pi, ok := ctx.OtherModuleDependencyTag(child).(PackagingItem); !ok || !pi.IsPackagingItem() {
return
}
for _, ps := range child.TransitivePackagingSpecs() {
+ if filter != nil {
+ if !filter(ps) {
+ continue
+ }
+ }
if _, ok := m[ps.relPathInPackage]; !ok {
m[ps.relPathInPackage] = ps
}
@@ -237,6 +242,11 @@
return m
}
+// See PackageModule.GatherPackagingSpecs
+func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec {
+ return p.GatherPackagingSpecsWithFilter(ctx, nil)
+}
+
// 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) {
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index 4a69628..2241b08 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -762,3 +762,45 @@
}
`, selectMainlineModuleContritbutions)
}
+
+// Test that apex_contributions of prebuilt modules are ignored in coverage builds
+func TestSourceIsSelectedInCoverageBuilds(t *testing.T) {
+ prebuiltMainlineContributions := GroupFixturePreparers(
+ FixtureModifyProductVariables(func(variables FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_prebuilt_apex_contributions",
+ }
+ }),
+ FixtureMergeEnv(map[string]string{
+ "EMMA_INSTRUMENT_FRAMEWORK": "true",
+ }),
+ )
+ bp := `
+ source {
+ name: "foo",
+ }
+ prebuilt {
+ name: "foo",
+ srcs: ["prebuilt_file"],
+ }
+ apex_contributions {
+ name: "my_prebuilt_apex_contributions",
+ api_domain: "my_mainline_module",
+ contents: [
+ "prebuilt_foo",
+ ],
+ }
+ all_apex_contributions {
+ name: "all_apex_contributions",
+ }
+ `
+ ctx := GroupFixturePreparers(
+ PrepareForTestWithArchMutator,
+ PrepareForTestWithPrebuilts,
+ FixtureRegisterWithContext(registerTestPrebuiltModules),
+ prebuiltMainlineContributions).RunTestWithBp(t, bp)
+ source := ctx.ModuleForTests("foo", "android_common").Module()
+ AssertBoolEquals(t, "Source should be preferred in coverage builds", true, !source.IsHideFromMake())
+ prebuilt := ctx.ModuleForTests("prebuilt_foo", "android_common").Module()
+ AssertBoolEquals(t, "Prebuilt should not be preferred in coverage builds", false, !prebuilt.IsHideFromMake())
+}
diff --git a/android/rule_builder.go b/android/rule_builder.go
index e8dbd48..85e29bd 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -1157,11 +1157,15 @@
// OutputDir adds the output directory to the command line. This is only available when used with RuleBuilder.Sbox,
// and will be the temporary output directory managed by sbox, not the final one.
-func (c *RuleBuilderCommand) OutputDir() *RuleBuilderCommand {
+func (c *RuleBuilderCommand) OutputDir(subPathComponents ...string) *RuleBuilderCommand {
if !c.rule.sbox {
panic("OutputDir only valid with Sbox")
}
- return c.Text(sboxOutDir)
+ path := sboxOutDir
+ if len(subPathComponents) > 0 {
+ path = filepath.Join(append([]string{sboxOutDir}, subPathComponents...)...)
+ }
+ return c.Text(path)
}
// DepFile adds the specified depfile path to the paths returned by RuleBuilder.DepFiles and adds it to the command
diff --git a/android/singleton.go b/android/singleton.go
index e0e552e..ccddeaf 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -250,8 +250,8 @@
}
func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name string) []Module {
- // get qualified module name for visibility enforcement
- qualified := createQualifiedModuleName(s.ModuleName(referer), s.ModuleDir(referer))
+ // get module reference for visibility enforcement
+ qualified := createVisibilityModuleReference(s.ModuleName(referer), s.ModuleDir(referer), s.ModuleType(referer))
modules := s.SingletonContext.ModuleVariantsFromName(referer, name)
result := make([]Module, 0, len(modules))
@@ -262,7 +262,7 @@
depDir := s.ModuleDir(module)
depQualified := qualifiedModuleName{depDir, depName}
// Targets are always visible to other targets in their own package.
- if depQualified.pkg != qualified.pkg {
+ if depQualified.pkg != qualified.name.pkg {
rule := effectiveVisibilityRules(s.Config(), depQualified)
if !rule.matches(qualified) {
s.ModuleErrorf(referer, "module %q references %q which is not visible to this module\nYou may need to add %q to its visibility",
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index d525bdc..c78b726 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -681,6 +681,14 @@
if !propStruct.IsValid() {
return nil, nil
}
+ if err := s.printfIntoPropertyRecursive(nil, propStruct, configValue); err != nil {
+ return nil, err
+ }
+
+ return values.Interface(), nil
+}
+
+func (s *valueVariable) printfIntoPropertyRecursive(fieldName []string, propStruct reflect.Value, configValue string) error {
for i := 0; i < propStruct.NumField(); i++ {
field := propStruct.Field(i)
kind := field.Kind()
@@ -695,23 +703,31 @@
case reflect.String:
err := printfIntoProperty(field, configValue)
if err != nil {
- return nil, fmt.Errorf("soong_config_variables.%s.%s: %s", s.variable, propStruct.Type().Field(i).Name, err)
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ return fmt.Errorf("soong_config_variables.%s.%s: %s", s.variable, strings.Join(fieldName, "."), err)
}
case reflect.Slice:
for j := 0; j < field.Len(); j++ {
err := printfIntoProperty(field.Index(j), configValue)
if err != nil {
- return nil, fmt.Errorf("soong_config_variables.%s.%s: %s", s.variable, propStruct.Type().Field(i).Name, err)
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ return fmt.Errorf("soong_config_variables.%s.%s: %s", s.variable, strings.Join(fieldName, "."), err)
}
}
case reflect.Bool:
// Nothing to do
+ case reflect.Struct:
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ if err := s.printfIntoPropertyRecursive(fieldName, field, configValue); err != nil {
+ return err
+ }
+ fieldName = fieldName[:len(fieldName)-1]
default:
- return nil, fmt.Errorf("soong_config_variables.%s.%s: unsupported property type %q", s.variable, propStruct.Type().Field(i).Name, kind)
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ return fmt.Errorf("soong_config_variables.%s.%s: unsupported property type %q", s.variable, strings.Join(fieldName, "."), kind)
}
}
-
- return values.Interface(), nil
+ return nil
}
func printfIntoProperty(propertyValue reflect.Value, configValue string) error {
diff --git a/android/soongconfig/modules_test.go b/android/soongconfig/modules_test.go
index db2c83c..1da0b49 100644
--- a/android/soongconfig/modules_test.go
+++ b/android/soongconfig/modules_test.go
@@ -429,6 +429,76 @@
}
}
+func Test_PropertiesToApply_Value_Nested(t *testing.T) {
+ mt, _ := newModuleType(&ModuleTypeProperties{
+ Module_type: "foo",
+ Config_namespace: "bar",
+ Value_variables: []string{"my_value_var"},
+ Properties: []string{"a.b"},
+ })
+ type properties struct {
+ A struct {
+ B string
+ }
+ }
+ conditionsDefault := &properties{
+ A: struct{ B string }{
+ B: "default",
+ },
+ }
+ type valueVarProps struct {
+ A struct {
+ B string
+ }
+ Conditions_default *properties
+ }
+ actualProps := &struct {
+ Soong_config_variables valueSoongConfigVars
+ }{
+ Soong_config_variables: valueSoongConfigVars{
+ My_value_var: &valueVarProps{
+ A: struct{ B string }{
+ B: "A.B=%s",
+ },
+ Conditions_default: conditionsDefault,
+ },
+ },
+ }
+ props := reflect.ValueOf(actualProps)
+
+ testCases := []struct {
+ name string
+ config SoongConfig
+ wantProps []interface{}
+ }{
+ {
+ name: "no_vendor_config",
+ config: Config(map[string]string{}),
+ wantProps: []interface{}{conditionsDefault},
+ },
+ {
+ name: "value_var_set",
+ config: Config(map[string]string{"my_value_var": "Hello"}),
+ wantProps: []interface{}{&properties{
+ A: struct{ B string }{
+ B: "A.B=Hello",
+ },
+ }},
+ },
+ }
+
+ for _, tc := range testCases {
+ gotProps, err := PropertiesToApply(mt, props, tc.config)
+ if err != nil {
+ t.Errorf("%s: Unexpected error in PropertiesToApply: %s", tc.name, err)
+ }
+
+ if !reflect.DeepEqual(gotProps, tc.wantProps) {
+ t.Errorf("%s: Expected %s, got %s", tc.name, tc.wantProps, gotProps)
+ }
+ }
+}
+
func Test_PropertiesToApply_String_Error(t *testing.T) {
mt, _ := newModuleType(&ModuleTypeProperties{
Module_type: "foo",
diff --git a/android/test_suites.go b/android/test_suites.go
index 9ded998..adcc15a 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -24,6 +24,7 @@
type testSuiteFiles struct {
robolectric WritablePath
+ ravenwood WritablePath
}
type TestSuiteModule interface {
@@ -47,12 +48,15 @@
})
t.robolectric = robolectricTestSuite(ctx, files["robolectric-tests"])
-
ctx.Phony("robolectric-tests", t.robolectric)
+
+ t.ravenwood = ravenwoodTestSuite(ctx, files["ravenwood-tests"])
+ ctx.Phony("ravenwood-tests", t.ravenwood)
}
func (t *testSuiteFiles) MakeVars(ctx MakeVarsContext) {
ctx.DistForGoal("robolectric-tests", t.robolectric)
+ ctx.DistForGoal("ravenwood-tests", t.ravenwood)
}
func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) WritablePath {
@@ -74,3 +78,23 @@
return outputFile
}
+
+func ravenwoodTestSuite(ctx SingletonContext, files map[string]InstallPaths) WritablePath {
+ var installedPaths InstallPaths
+ for _, module := range SortedKeys(files) {
+ installedPaths = append(installedPaths, files[module]...)
+ }
+ testCasesDir := pathForInstall(ctx, ctx.Config().BuildOS, X86, "testcases")
+
+ outputFile := PathForOutput(ctx, "packaging", "ravenwood-tests.zip")
+ rule := NewRuleBuilder(pctx, ctx)
+ rule.Command().BuiltTool("soong_zip").
+ FlagWithOutput("-o ", outputFile).
+ FlagWithArg("-P ", "host/testcases").
+ FlagWithArg("-C ", testCasesDir.String()).
+ FlagWithRspFileInputList("-r ", outputFile.ReplaceExtension(ctx, "rsp"), installedPaths.Paths()).
+ Flag("-sha256")
+ rule.Build("ravenwood_tests_zip", "ravenwood-tests.zip")
+
+ return outputFile
+}
diff --git a/android/variable.go b/android/variable.go
index a4917c5..be3c80d 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -383,7 +383,6 @@
BoardSepolicyVers *string `json:",omitempty"`
PlatformSepolicyVersion *string `json:",omitempty"`
- TotSepolicyVersion *string `json:",omitempty"`
SystemExtSepolicyPrebuiltApiDir *string `json:",omitempty"`
ProductSepolicyPrebuiltApiDir *string `json:",omitempty"`
@@ -495,6 +494,12 @@
BuildFlags map[string]string `json:",omitempty"`
BuildFromSourceStub *bool `json:",omitempty"`
+
+ BuildIgnoreApexContributionContents []string `json:",omitempty"`
+
+ HiddenapiExportableStubs *bool `json:",omitempty"`
+
+ ExportRuntimeApis *bool `json:",omitempty"`
}
type PartitionQualifiedVariablesType struct {
diff --git a/android/visibility.go b/android/visibility.go
index 3130135..b387562 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -57,12 +57,29 @@
var visibilityRuleRegexp = regexp.MustCompile(visibilityRulePattern)
+type visibilityModuleReference struct {
+ name qualifiedModuleName
+ isPartitionModule bool
+}
+
+func createVisibilityModuleReference(name, dir, typ string) visibilityModuleReference {
+ isPartitionModule := false
+ switch typ {
+ case "android_filesystem", "android_system_image":
+ isPartitionModule = true
+ }
+ return visibilityModuleReference{
+ name: createQualifiedModuleName(name, dir),
+ isPartitionModule: isPartitionModule,
+ }
+}
+
// A visibility rule is associated with a module and determines which other modules it is visible
// to, i.e. which other modules can depend on the rule's module.
type visibilityRule interface {
// Check to see whether this rules matches m.
// Returns true if it does, false otherwise.
- matches(m qualifiedModuleName) bool
+ matches(m visibilityModuleReference) bool
String() string
}
@@ -108,8 +125,10 @@
// ["//visibility:private"].
type compositeRule []visibilityRule
+var _ visibilityRule = compositeRule{}
+
// A compositeRule matches if and only if any of its rules matches.
-func (c compositeRule) matches(m qualifiedModuleName) bool {
+func (c compositeRule) matches(m visibilityModuleReference) bool {
for _, r := range c {
if r.matches(m) {
return true
@@ -135,8 +154,10 @@
pkg string
}
-func (r packageRule) matches(m qualifiedModuleName) bool {
- return m.pkg == r.pkg
+var _ visibilityRule = packageRule{}
+
+func (r packageRule) matches(m visibilityModuleReference) bool {
+ return m.name.pkg == r.pkg
}
func (r packageRule) String() string {
@@ -149,8 +170,10 @@
pkgPrefix string
}
-func (r subpackagesRule) matches(m qualifiedModuleName) bool {
- return isAncestor(r.pkgPrefix, m.pkg)
+var _ visibilityRule = subpackagesRule{}
+
+func (r subpackagesRule) matches(m visibilityModuleReference) bool {
+ return isAncestor(r.pkgPrefix, m.name.pkg)
}
func isAncestor(p1 string, p2 string) bool {
@@ -168,7 +191,9 @@
// visibilityRule for //visibility:public
type publicRule struct{}
-func (r publicRule) matches(_ qualifiedModuleName) bool {
+var _ visibilityRule = publicRule{}
+
+func (r publicRule) matches(_ visibilityModuleReference) bool {
return true
}
@@ -179,7 +204,9 @@
// visibilityRule for //visibility:private
type privateRule struct{}
-func (r privateRule) matches(_ qualifiedModuleName) bool {
+var _ visibilityRule = privateRule{}
+
+func (r privateRule) matches(_ visibilityModuleReference) bool {
return false
}
@@ -187,6 +214,19 @@
return "//visibility:private"
}
+// visibilityRule for //visibility:any_partition
+type anyPartitionRule struct{}
+
+var _ visibilityRule = anyPartitionRule{}
+
+func (r anyPartitionRule) matches(m visibilityModuleReference) bool {
+ return m.isPartitionModule
+}
+
+func (r anyPartitionRule) String() string {
+ return "//visibility:any_partition"
+}
+
var visibilityRuleMap = NewOnceKey("visibilityRuleMap")
// The map from qualifiedModuleName to visibilityRule.
@@ -237,13 +277,10 @@
// Checks the per-module visibility rule lists before defaults expansion.
func visibilityRuleChecker(ctx BottomUpMutatorContext) {
- qualified := createQualifiedModuleName(ctx.ModuleName(), ctx.ModuleDir())
- if m, ok := ctx.Module().(Module); ok {
- visibilityProperties := m.visibilityProperties()
- for _, p := range visibilityProperties {
- if visibility := p.getStrings(); visibility != nil {
- checkRules(ctx, qualified.pkg, p.getName(), visibility)
- }
+ visibilityProperties := ctx.Module().visibilityProperties()
+ for _, p := range visibilityProperties {
+ if visibility := p.getStrings(); visibility != nil {
+ checkRules(ctx, ctx.ModuleDir(), p.getName(), visibility)
}
}
}
@@ -266,7 +303,7 @@
if pkg == "visibility" {
switch name {
- case "private", "public":
+ case "private", "public", "any_partition":
case "legacy_public":
ctx.PropertyErrorf(property, "//visibility:legacy_public must not be used")
continue
@@ -305,10 +342,7 @@
//
// See ../README.md#Visibility for information on the format of the visibility rules.
func visibilityRuleGatherer(ctx BottomUpMutatorContext) {
- m, ok := ctx.Module().(Module)
- if !ok {
- return
- }
+ m := ctx.Module()
qualifiedModuleId := m.qualifiedModuleId(ctx)
currentPkg := qualifiedModuleId.pkg
@@ -355,6 +389,8 @@
hasNonPrivateRule = false
// This does not actually create a rule so continue onto the next rule.
continue
+ case "any_partition":
+ r = anyPartitionRule{}
}
} else {
switch name {
@@ -395,10 +431,7 @@
func isAllowedFromOutsideVendor(pkg string, name string) bool {
if pkg == "vendor" {
- if name == "__subpackages__" {
- return true
- }
- return false
+ return name == "__subpackages__"
}
return !isAncestor("vendor", pkg)
@@ -434,11 +467,7 @@
}
func visibilityRuleEnforcer(ctx TopDownMutatorContext) {
- if _, ok := ctx.Module().(Module); !ok {
- return
- }
-
- qualified := createQualifiedModuleName(ctx.ModuleName(), ctx.ModuleDir())
+ qualified := createVisibilityModuleReference(ctx.ModuleName(), ctx.ModuleDir(), ctx.ModuleType())
// Visit all the dependencies making sure that this module has access to them all.
ctx.VisitDirectDeps(func(dep Module) {
@@ -453,7 +482,7 @@
depQualified := qualifiedModuleName{depDir, depName}
// Targets are always visible to other targets in their own package.
- if depQualified.pkg == qualified.pkg {
+ if depQualified.pkg == qualified.name.pkg {
return
}
@@ -478,7 +507,7 @@
if ok {
rule = value.(compositeRule)
} else {
- rule = packageDefaultVisibility(config, qualified)
+ rule = packageDefaultVisibility(moduleToVisibilityRule, qualified)
}
// If no rule is specified then return the default visibility rule to avoid
@@ -494,8 +523,7 @@
return qualified
}
-func packageDefaultVisibility(config Config, moduleId qualifiedModuleName) compositeRule {
- moduleToVisibilityRule := moduleToVisibilityRuleMap(config)
+func packageDefaultVisibility(moduleToVisibilityRule *sync.Map, moduleId qualifiedModuleName) compositeRule {
packageQualifiedId := moduleId.getContainingPackageId()
for {
value, ok := moduleToVisibilityRule.Load(packageQualifiedId)
@@ -574,10 +602,12 @@
rule := effectiveVisibilityRules(ctx.Config(), qualified)
+ currentModule := createVisibilityModuleReference(moduleName, dir, ctx.OtherModuleType(module))
+
// Modules are implicitly visible to other modules in the same package,
// without checking the visibility rules. Here we need to add that visibility
// explicitly.
- if !rule.matches(qualified) {
+ if !rule.matches(currentModule) {
if len(rule) == 1 {
if _, ok := rule[0].(privateRule); ok {
// If the rule is //visibility:private we can't append another
diff --git a/android/visibility_test.go b/android/visibility_test.go
index a66f0b6..d4add7d 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -1904,6 +1904,38 @@
}`),
},
},
+ {
+ name: "any_partition visibility works",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ android_filesystem {
+ name: "foo",
+ deps: ["bar"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ package(default_visibility=["//visibility:private"])
+ mock_library {
+ name: "bar",
+ visibility: ["//visibility:any_partition"],
+ }`),
+ },
+ },
+ {
+ name: "any_partition visibility doesn't work for non-partitions",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "foo",
+ deps: ["bar"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ mock_library {
+ name: "bar",
+ visibility: ["//visibility:any_partition"],
+ }`),
+ },
+ expectedErrors: []string{`module "foo" variant "android_common": depends on //top/nested:bar which is not visible to this module`},
+ },
}
func TestVisibility(t *testing.T) {
@@ -1925,6 +1957,8 @@
ctx.RegisterModuleType("mock_library", newMockLibraryModule)
ctx.RegisterModuleType("mock_parent", newMockParentFactory)
ctx.RegisterModuleType("mock_defaults", defaultsFactory)
+ // For testing //visibility:any_partition. The module type doesn't matter, just that it's registered under the name "android_filesystem"
+ ctx.RegisterModuleType("android_filesystem", newMockLibraryModule)
}),
prepareForTestWithFakePrebuiltModules,
// Add additional files to the mock filesystem
diff --git a/apex/apex.go b/apex/apex.go
index 276ac80..c6d8234 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -842,10 +842,12 @@
}
addDependenciesForNativeModules(ctx, deps, target, imageVariation)
- ctx.AddFarVariationDependencies([]blueprint.Variation{
- {Mutator: "os", Variation: target.OsVariation()},
- {Mutator: "arch", Variation: target.ArchVariation()},
- }, shBinaryTag, a.properties.Sh_binaries...)
+ if isPrimaryAbi {
+ ctx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "os", Variation: target.OsVariation()},
+ {Mutator: "arch", Variation: target.ArchVariation()},
+ }, shBinaryTag, a.properties.Sh_binaries...)
+ }
}
// Common-arch dependencies come next
@@ -1165,6 +1167,7 @@
"com.android.ondevicepersonalization",
"com.android.os.statsd",
"com.android.permission",
+ "com.android.profiling",
"com.android.rkpd",
"com.android.scheduling",
"com.android.tethering",
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d3959ec..85d1d71 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -790,6 +790,79 @@
}
}
+func TestApexWithDessertSha(t *testing.T) {
+ ctx := testApex(t, `
+ apex_defaults {
+ name: "my_defaults",
+ key: "myapex.key",
+ product_specific: true,
+ file_contexts: ":my-file-contexts",
+ updatable: false,
+ }
+ apex {
+ name: "myapex_30",
+ min_sdk_version: "30",
+ defaults: ["my_defaults"],
+ }
+
+ apex {
+ name: "myapex_current",
+ min_sdk_version: "current",
+ defaults: ["my_defaults"],
+ }
+
+ apex {
+ name: "myapex_none",
+ defaults: ["my_defaults"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ filegroup {
+ name: "my-file-contexts",
+ srcs: ["product_specific_file_contexts"],
+ }
+ `, withFiles(map[string][]byte{
+ "product_specific_file_contexts": nil,
+ }), android.FixtureModifyProductVariables(
+ func(variables android.FixtureProductVariables) {
+ variables.Unbundled_build = proptools.BoolPtr(true)
+ variables.Always_use_prebuilt_sdks = proptools.BoolPtr(false)
+ }), android.FixtureMergeEnv(map[string]string{
+ "UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA": "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ }))
+
+ testCases := []struct {
+ module string
+ minSdkVersion string
+ }{
+ {
+ module: "myapex_30",
+ minSdkVersion: "30",
+ },
+ {
+ module: "myapex_current",
+ minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ },
+ {
+ module: "myapex_none",
+ minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ },
+ }
+ for _, tc := range testCases {
+ module := ctx.ModuleForTests(tc.module, "android_common_"+tc.module)
+ args := module.Rule("apexRule").Args
+ optFlags := args["opt_flags"]
+ if !strings.Contains(optFlags, "--min_sdk_version "+tc.minSdkVersion) {
+ t.Errorf("%s: Expected min_sdk_version=%s, got: %s", tc.module, tc.minSdkVersion, optFlags)
+ }
+ }
+}
+
func TestFileContexts(t *testing.T) {
for _, vendor := range []bool{true, false} {
prop := ""
@@ -4973,6 +5046,7 @@
key: "myapex.key",
sh_binaries: ["myscript"],
updatable: false,
+ compile_multilib: "both",
}
apex_key {
@@ -11042,25 +11116,23 @@
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
s := mod.Rule("apexRule").Args["copy_commands"]
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
- if len(copyCmds) != 5 {
+ if len(copyCmds) != 8 {
t.Fatalf("Expected 5 commands, got %d in:\n%s", len(copyCmds), s)
}
ensureMatches(t, copyCmds[4], "^cp -f .*/aconfig_flags.pb .*/image.apex$")
+ ensureMatches(t, copyCmds[5], "^cp -f .*/package.map .*/image.apex$")
+ ensureMatches(t, copyCmds[6], "^cp -f .*/flag.map .*/image.apex$")
+ ensureMatches(t, copyCmds[7], "^cp -f .*/flag.val .*/image.apex$")
- combineAconfigRule := mod.Rule("All_aconfig_declarations_dump")
- s = " " + combineAconfigRule.Args["cache_files"]
- aconfigArgs := regexp.MustCompile(" --cache ").Split(s, -1)[1:]
- if len(aconfigArgs) != 2 {
- t.Fatalf("Expected 2 commands, got %d in:\n%s", len(aconfigArgs), s)
+ inputs := []string{
+ "my_aconfig_declarations_foo/intermediate.pb",
+ "my_aconfig_declarations_bar/intermediate.pb",
}
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_bar/intermediate.pb")
-
- buildParams := combineAconfigRule.BuildParams
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_bar/intermediate.pb")
- ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
+ VerifyAconfigRule(t, &mod, "combine_aconfig_declarations", inputs, "android_common_myapex/aconfig_flags.pb", "", "")
+ VerifyAconfigRule(t, &mod, "create_aconfig_package_map_file", inputs, "android_common_myapex/package.map", "myapex", "package_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_map_file", inputs, "android_common_myapex/flag.map", "myapex", "flag_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_val_file", inputs, "android_common_myapex/flag.val", "myapex", "flag_val")
}
func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
@@ -11168,30 +11240,24 @@
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
s := mod.Rule("apexRule").Args["copy_commands"]
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
- if len(copyCmds) != 9 {
- t.Fatalf("Expected 9 commands, got %d in:\n%s", len(copyCmds), s)
+ if len(copyCmds) != 12 {
+ t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s)
}
ensureMatches(t, copyCmds[8], "^cp -f .*/aconfig_flags.pb .*/image.apex$")
+ ensureMatches(t, copyCmds[9], "^cp -f .*/package.map .*/image.apex$")
+ ensureMatches(t, copyCmds[10], "^cp -f .*/flag.map .*/image.apex$")
+ ensureMatches(t, copyCmds[11], "^cp -f .*/flag.val .*/image.apex$")
- combineAconfigRule := mod.Rule("All_aconfig_declarations_dump")
- s = " " + combineAconfigRule.Args["cache_files"]
- aconfigArgs := regexp.MustCompile(" --cache ").Split(s, -1)[1:]
- if len(aconfigArgs) != 3 {
- t.Fatalf("Expected 3 commands, got %d in:\n%s", len(aconfigArgs), s)
+ inputs := []string{
+ "my_aconfig_declarations_foo/intermediate.pb",
+ "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/myapex/aconfig_merged.pb",
+ "my_aconfig_declarations_baz/intermediate.pb",
}
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/myapex/aconfig_merged.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_baz/intermediate.pb")
-
- buildParams := combineAconfigRule.BuildParams
- if len(buildParams.Inputs) != 3 {
- t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
- }
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/myapex/aconfig_merged.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_baz/intermediate.pb")
- ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
+ VerifyAconfigRule(t, &mod, "combine_aconfig_declarations", inputs, "android_common_myapex/aconfig_flags.pb", "", "")
+ VerifyAconfigRule(t, &mod, "create_aconfig_package_map_file", inputs, "android_common_myapex/package.map", "myapex", "package_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_map_file", inputs, "android_common_myapex/flag.map", "myapex", "flag_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_val_file", inputs, "android_common_myapex/flag.val", "myapex", "flag_val")
}
func TestAconfigFilesRustDeps(t *testing.T) {
@@ -11315,28 +11381,43 @@
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
s := mod.Rule("apexRule").Args["copy_commands"]
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
- if len(copyCmds) != 23 {
- t.Fatalf("Expected 23 commands, got %d in:\n%s", len(copyCmds), s)
+ if len(copyCmds) != 26 {
+ t.Fatalf("Expected 26 commands, got %d in:\n%s", len(copyCmds), s)
}
ensureMatches(t, copyCmds[22], "^cp -f .*/aconfig_flags.pb .*/image.apex$")
+ ensureMatches(t, copyCmds[23], "^cp -f .*/package.map .*/image.apex$")
+ ensureMatches(t, copyCmds[24], "^cp -f .*/flag.map .*/image.apex$")
+ ensureMatches(t, copyCmds[25], "^cp -f .*/flag.val .*/image.apex$")
- combineAconfigRule := mod.Rule("All_aconfig_declarations_dump")
- s = " " + combineAconfigRule.Args["cache_files"]
+ inputs := []string{
+ "my_aconfig_declarations_foo/intermediate.pb",
+ "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb",
+ }
+ VerifyAconfigRule(t, &mod, "combine_aconfig_declarations", inputs, "android_common_myapex/aconfig_flags.pb", "", "")
+ VerifyAconfigRule(t, &mod, "create_aconfig_package_map_file", inputs, "android_common_myapex/package.map", "myapex", "package_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_map_file", inputs, "android_common_myapex/flag.map", "myapex", "flag_map")
+ VerifyAconfigRule(t, &mod, "create_aconfig_flag_val_file", inputs, "android_common_myapex/flag.val", "myapex", "flag_val")
+}
+
+func VerifyAconfigRule(t *testing.T, mod *android.TestingModule, desc string, inputs []string, output string, container string, file_type string) {
+ aconfigRule := mod.Description(desc)
+ s := " " + aconfigRule.Args["cache_files"]
aconfigArgs := regexp.MustCompile(" --cache ").Split(s, -1)[1:]
- if len(aconfigArgs) != 2 {
- t.Fatalf("Expected 2 commands, got %d in:\n%s", len(aconfigArgs), s)
+ if len(aconfigArgs) != len(inputs) {
+ t.Fatalf("Expected %d commands, got %d in:\n%s", len(inputs), len(aconfigArgs), s)
}
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb")
- buildParams := combineAconfigRule.BuildParams
- if len(buildParams.Inputs) != 2 {
- t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
+ ensureEquals(t, container, aconfigRule.Args["container"])
+ ensureEquals(t, file_type, aconfigRule.Args["file_type"])
+
+ buildParams := aconfigRule.BuildParams
+ for _, input := range inputs {
+ android.EnsureListContainsSuffix(t, aconfigArgs, input)
+ android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), input)
}
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb")
- ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
+
+ ensureContains(t, buildParams.Output.String(), output)
}
func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
diff --git a/apex/builder.go b/apex/builder.go
index 3078863..e49cf28 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -85,6 +85,18 @@
pctx.HostBinToolVariable("aconfig", "aconfig")
}
+type createStorageStruct struct {
+ Output_file string
+ Desc string
+ File_type string
+}
+
+var createStorageInfo = []createStorageStruct{
+ {"package.map", "create_aconfig_package_map_file", "package_map"},
+ {"flag.map", "create_aconfig_flag_map_file", "flag_map"},
+ {"flag.val", "create_aconfig_flag_val_file", "flag_val"},
+}
+
var (
apexManifestRule = pctx.StaticRule("apexManifestRule", blueprint.RuleParams{
Command: `rm -f $out && ${jsonmodify} $in ` +
@@ -648,6 +660,25 @@
copyCommands = append(copyCommands, "cp -f "+apexAconfigFile.String()+" "+imageDir.String())
implicitInputs = append(implicitInputs, apexAconfigFile)
defaultReadOnlyFiles = append(defaultReadOnlyFiles, apexAconfigFile.Base())
+
+ for _, info := range createStorageInfo {
+ outputFile := android.PathForModuleOut(ctx, info.Output_file)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: aconfig.CreateStorageRule,
+ Inputs: a.aconfigFiles,
+ Output: outputFile,
+ Description: info.Desc,
+ Args: map[string]string{
+ "container": ctx.ModuleName(),
+ "file_type": info.File_type,
+ "cache_files": android.JoinPathsWithPrefix(a.aconfigFiles, "--cache "),
+ },
+ })
+
+ copyCommands = append(copyCommands, "cp -f "+outputFile.String()+" "+imageDir.String())
+ implicitInputs = append(implicitInputs, outputFile)
+ defaultReadOnlyFiles = append(defaultReadOnlyFiles, outputFile.Base())
+ }
}
////////////////////////////////////////////////////////////////////////////////////
@@ -695,18 +726,20 @@
if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
- if java.UseApiFingerprint(ctx) {
- minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
- implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
+ java.UseApiFingerprint(ctx); useApiFingerprint {
+ minSdkVersion = fingerprintMinSdkVersion
+ implicitInputs = append(implicitInputs, fingerprintDeps)
}
}
// apex module doesn't have a concept of target_sdk_version, hence for the time
// being targetSdkVersion == default targetSdkVersion of the branch.
targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
- if java.UseApiFingerprint(ctx) {
- targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
- implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
+ java.UseApiFingerprint(ctx); useApiFingerprint {
+ targetSdkVersion = fingerprintTargetSdkVersion
+ implicitInputs = append(implicitInputs, fingerprintDeps)
}
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
@@ -910,7 +943,7 @@
var validations android.Paths
validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
// TODO(b/279688635) deapexer supports [ext4]
- if suffix == imageApexSuffix && ext4 == a.payloadFsType {
+ if !a.testApex && suffix == imageApexSuffix && ext4 == a.payloadFsType {
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
}
if !a.testApex && len(a.properties.Unwanted_transitive_deps) > 0 {
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 2bd3159..2be9c10 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -86,6 +86,7 @@
"bar-fragment",
],
updatable: false,
+ min_sdk_version: "30", // R
}
apex_key {
@@ -138,6 +139,7 @@
sdk_version: "none",
compile_dex: true,
permitted_packages: ["bar"],
+ min_sdk_version: "30", // R
}
java_sdk_library {
@@ -162,12 +164,12 @@
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
}
- android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
- android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
- android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/index.csv"}, info.IndexPaths)
+ android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
+ android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
+ android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/index.csv"}, info.IndexPaths)
- android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
- android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
// TestPlatformBootclasspath_LegacyPrebuiltFragment verifies that the
diff --git a/bin/soongdbg b/bin/soongdbg
index 132a0f0..bfdbbde 100755
--- a/bin/soongdbg
+++ b/bin/soongdbg
@@ -2,9 +2,12 @@
import argparse
import fnmatch
+import html
+import io
import json
import os
import pathlib
+import subprocess
import types
import sys
@@ -27,6 +30,7 @@
dep = get_or_make_node(self.nodes, d.id, None)
node.deps.add(dep)
dep.rdeps.add(node)
+ node.dep_tags.setdefault(dep, list()).append(d)
def find_paths(self, id1, id2):
# Throws KeyError if one of the names isn't found
@@ -60,6 +64,7 @@
self.module = module
self.deps = set()
self.rdeps = set()
+ self.dep_tags = {}
PROVIDERS = [
@@ -68,21 +73,35 @@
]
-def format_node_label(node):
- if not node.module:
- return node.id
- if node.module.debug:
- module_debug = f"<tr><td>{node.module.debug}</td></tr>"
- else:
- module_debug = ""
+def format_dep_label(node, dep):
+ tags = node.dep_tags.get(dep)
+ labels = []
+ if tags:
+ labels = [tag.tag_type.split("/")[-1] for tag in tags]
+ labels = sorted(set(labels))
+ if labels:
+ result = "<<table border=\"0\" cellborder=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
+ for label in labels:
+ result += f"<tr><td>{label}</td></tr>"
+ result += "</table>>"
+ return result
- result = (f"<<table border=\"0\" cellborder=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
- + f"<tr><td><b>{node.module.name}</b></td></tr>"
- + module_debug
- + f"<tr><td>{node.module.type}</td></tr>")
- for p in node.module.providers:
- if p.type in PROVIDERS:
- result += "<tr><td><font color=\"#666666\">" + format_provider(p) + "</font></td></tr>"
+
+def format_node_label(node, module_formatter):
+ result = "<<table border=\"0\" cellborder=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
+
+ # node name
+ result += f"<tr><td><b>{node.module.name if node.module else node.id}</b></td></tr>"
+
+ if node.module:
+ # node_type
+ result += f"<tr><td>{node.module.type}</td></tr>"
+
+ # module_formatter will return a list of rows
+ for row in module_formatter(node.module):
+ row = html.escape(row)
+ result += f"<tr><td><font color=\"#666666\">{row}</font></td></tr>"
+
result += "</table>>"
return result
@@ -190,22 +209,87 @@
yield m
-def print_nodes(nodes):
- print("digraph {")
+def print_args(parser):
+ parser.add_argument("--label", action="append", metavar="JQ_FILTER",
+ help="jq query for each module metadata")
+ parser.add_argument("--deptags", action="store_true",
+ help="show dependency tags (makes the graph much more complex)")
+
+ group = parser.add_argument_group("output formats",
+ "If no format is provided, a dot file will be written to"
+ + " stdout.")
+ output = group.add_mutually_exclusive_group()
+ output.add_argument("--dot", type=str, metavar="FILENAME",
+ help="Write the graph to this file as dot (graphviz format)")
+ output.add_argument("--svg", type=str, metavar="FILENAME",
+ help="Write the graph to this file as svg")
+
+
+def print_nodes(args, nodes, module_formatter):
+ # Generate the graphviz
+ dep_tag_id = 0
+ dot = io.StringIO()
+ dot.write("digraph {\n")
+ dot.write("node [shape=box];")
+
for node in nodes:
- print(f"\"{node.id}\"[label={format_node_label(node)}];")
+ dot.write(f"\"{node.id}\" [label={format_node_label(node, module_formatter)}];\n")
for dep in node.deps:
if dep in nodes:
- print(f"\"{node.id}\" -> \"{dep.id}\";")
- print("}")
+ if args.deptags:
+ dot.write(f"\"{node.id}\" -> \"__dep_tag_{dep_tag_id}\" [ arrowhead=none ];\n")
+ dot.write(f"\"__dep_tag_{dep_tag_id}\" -> \"{dep.id}\";\n")
+ dot.write(f"\"__dep_tag_{dep_tag_id}\""
+ + f"[label={format_dep_label(node, dep)} shape=ellipse"
+ + " color=\"#666666\" fontcolor=\"#666666\"];\n")
+ else:
+ dot.write(f"\"{node.id}\" -> \"{dep.id}\";\n")
+ dep_tag_id += 1
+ dot.write("}\n")
+ text = dot.getvalue()
+
+ # Write it somewhere
+ if args.dot:
+ with open(args.dot, "w") as f:
+ f.write(text)
+ elif args.svg:
+ subprocess.run(["dot", "-Tsvg", "-o", args.svg],
+ input=text, text=True, check=True)
+ else:
+ sys.stdout.write(text)
-def get_deps(nodes, root):
+def get_deps(nodes, root, maxdepth, reverse):
if root in nodes:
return
nodes.add(root)
- for dep in root.deps:
- get_deps(nodes, dep)
+ if maxdepth != 0:
+ for dep in (root.rdeps if reverse else root.deps):
+ get_deps(nodes, dep, maxdepth-1, reverse)
+
+
+def new_module_formatter(args):
+ def module_formatter(module):
+ if not args.label:
+ return []
+ result = []
+ text = json.dumps(module, default=lambda o: o.__dict__)
+ for jq_filter in args.label:
+ proc = subprocess.run(["jq", jq_filter],
+ input=text, text=True, check=True, stdout=subprocess.PIPE)
+ if proc.stdout:
+ o = json.loads(proc.stdout)
+ if type(o) == list:
+ for row in o:
+ if row:
+ result.append(row)
+ elif type(o) == dict:
+ result.append(str(proc.stdout).strip())
+ else:
+ if o:
+ result.append(str(o).strip())
+ return result
+ return module_formatter
class BetweenCommand:
@@ -213,11 +297,13 @@
def args(self, parser):
parser.add_argument("module", nargs=2,
- help="The two modules")
+ help="the two modules")
+ print_args(parser)
def run(self, args):
graph = load_graph()
- print_nodes(graph.find_paths(args.module[0], args.module[1]))
+ print_nodes(args, graph.find_paths(args.module[0], args.module[1]),
+ new_module_formatter(args))
class DepsCommand:
@@ -226,21 +312,26 @@
def args(self, parser):
parser.add_argument("module", nargs="+",
help="Module to print dependencies of")
+ parser.add_argument("--reverse", action="store_true",
+ help="traverse reverse dependencies")
+ parser.add_argument("--depth", type=int, default=-1,
+ help="max depth of dependencies (can keep the graph size reasonable)")
+ print_args(parser)
def run(self, args):
graph = load_graph()
nodes = set()
err = False
- for id in sys.argv[3:]:
+ for id in args.module:
root = graph.nodes.get(id)
if not root:
sys.stderr.write(f"error: Can't find root: {id}\n")
err = True
continue
- get_deps(nodes, root)
+ get_deps(nodes, root, args.depth, args.reverse)
if err:
sys.exit(1)
- print_nodes(nodes)
+ print_nodes(args, nodes, new_module_formatter(args))
class IdCommand:
@@ -254,6 +345,25 @@
print(m.id)
+class JsonCommand:
+ help = "Print metadata about modules in json format"
+
+ def args(self, parser):
+ module_selection_args(parser)
+ parser.add_argument("--list", action="store_true",
+ help="Print the results in a json list. If not set and multiple"
+ + " modules are matched, the output won't be valid json.")
+
+ def run(self, args):
+ modules = load_and_filter_modules(args)
+ if args.list:
+ json.dump([m for m in modules], sys.stdout, indent=4, default=lambda o: o.__dict__)
+ else:
+ for m in modules:
+ json.dump(m, sys.stdout, indent=4, default=lambda o: o.__dict__)
+ print()
+
+
class QueryCommand:
help = "Query details about modules"
@@ -275,6 +385,7 @@
"between": BetweenCommand(),
"deps": DepsCommand(),
"id": IdCommand(),
+ "json": JsonCommand(),
"query": QueryCommand(),
}
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index 43fb71d..b72b6d3 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -85,6 +85,9 @@
func (singleton *sizesSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var deps android.Paths
ctx.VisitAllModules(func(m android.Module) {
+ if !m.ExportedToMake() {
+ return
+ }
filePaths, ok := android.SingletonModuleProvider(ctx, m, fileSizeMeasurerKey)
if !ok {
return
diff --git a/bpf/bpf.go b/bpf/bpf.go
index e1b512f..38fbd88 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -203,6 +203,15 @@
}
}
+
+ installDir := android.PathForModuleInstall(ctx, "etc", "bpf")
+ if len(bpf.properties.Sub_dir) > 0 {
+ installDir = installDir.Join(ctx, bpf.properties.Sub_dir)
+ }
+ for _, obj := range bpf.objs {
+ ctx.PackageFile(installDir, obj.Base(), obj)
+ }
+
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
}
diff --git a/cc/afdo.go b/cc/afdo.go
index 79fbae1..00b2245 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -21,29 +21,17 @@
"android/soong/android"
"github.com/google/blueprint"
- "github.com/google/blueprint/proptools"
)
// This flag needs to be in both CFlags and LdFlags to ensure correct symbol ordering
const afdoFlagsFormat = "-fprofile-sample-use=%s -fprofile-sample-accurate"
-func recordMissingAfdoProfileFile(ctx android.BaseModuleContext, missing string) {
- getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true)
-}
-
-type afdoRdep struct {
- VariationName *string
- ProfilePath *string
-}
-
type AfdoProperties struct {
// Afdo allows developers self-service enroll for
// automatic feedback-directed optimization using profile data.
Afdo bool
- FdoProfilePath *string `blueprint:"mutated"`
-
- AfdoRDeps []afdoRdep `blueprint:"mutated"`
+ AfdoDep bool `blueprint:"mutated"`
}
type afdo struct {
@@ -62,13 +50,32 @@
}
// afdoEnabled returns true for binaries and shared libraries
-// that set afdo prop to True and there is a profile available
+// that set afdo prop to True.
func (afdo *afdo) afdoEnabled() bool {
return afdo != nil && afdo.Properties.Afdo
}
+func (afdo *afdo) isAfdoCompile(ctx ModuleContext) bool {
+ fdoProfilePath := getFdoProfilePathFromDep(ctx)
+ return !ctx.Host() && (afdo.Properties.Afdo || afdo.Properties.AfdoDep) && (fdoProfilePath != "")
+}
+
+func getFdoProfilePathFromDep(ctx ModuleContext) string {
+ fdoProfileDeps := ctx.GetDirectDepsWithTag(FdoProfileTag)
+ if len(fdoProfileDeps) > 0 && fdoProfileDeps[0] != nil {
+ if info, ok := android.OtherModuleProvider(ctx, fdoProfileDeps[0], FdoProfileProvider); ok {
+ return info.Path.String()
+ }
+ }
+ return ""
+}
+
func (afdo *afdo) flags(ctx ModuleContext, flags Flags) Flags {
- if afdo.Properties.Afdo {
+ if ctx.Host() {
+ return flags
+ }
+
+ if afdo.Properties.Afdo || afdo.Properties.AfdoDep {
// We use `-funique-internal-linkage-names` to associate profiles to the right internal
// functions. This option should be used before generating a profile. Because a profile
// generated for a binary without unique names doesn't work well building a binary with
@@ -86,15 +93,15 @@
// TODO(b/266595187): Remove the following feature once it is enabled in LLVM by default.
flags.Local.CFlags = append([]string{"-mllvm", "-improved-fs-discriminator=true"}, flags.Local.CFlags...)
}
- if path := afdo.Properties.FdoProfilePath; path != nil {
+ if fdoProfilePath := getFdoProfilePathFromDep(ctx); fdoProfilePath != "" {
// The flags are prepended to allow overriding.
- profileUseFlag := fmt.Sprintf(afdoFlagsFormat, *path)
+ profileUseFlag := fmt.Sprintf(afdoFlagsFormat, fdoProfilePath)
flags.Local.CFlags = append([]string{profileUseFlag}, flags.Local.CFlags...)
flags.Local.LdFlags = append([]string{profileUseFlag, "-Wl,-mllvm,-no-warn-sample-unused=true"}, flags.Local.LdFlags...)
// Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
// if profileFile gets updated
- pathForSrc := android.PathForSource(ctx, *path)
+ pathForSrc := android.PathForSource(ctx, fdoProfilePath)
flags.CFlagsDeps = append(flags.CFlagsDeps, pathForSrc)
flags.LdFlagsDeps = append(flags.LdFlagsDeps, pathForSrc)
}
@@ -102,122 +109,86 @@
return flags
}
-func (afdo *afdo) addDep(ctx BaseModuleContext, actx android.BottomUpMutatorContext) {
+func (a *afdo) addDep(ctx android.BottomUpMutatorContext, fdoProfileTarget string) {
+ if fdoProfileName, err := ctx.DeviceConfig().AfdoProfile(fdoProfileTarget); fdoProfileName != "" && err == nil {
+ ctx.AddFarVariationDependencies(
+ []blueprint.Variation{
+ {Mutator: "arch", Variation: ctx.Target().ArchVariation()},
+ {Mutator: "os", Variation: "android"},
+ },
+ FdoProfileTag,
+ fdoProfileName)
+ }
+}
+
+func afdoPropagateViaDepTag(tag blueprint.DependencyTag) bool {
+ libTag, isLibTag := tag.(libraryDependencyTag)
+ // Do not recurse down non-static dependencies
+ if isLibTag {
+ return libTag.static()
+ } else {
+ return tag == objDepTag || tag == reuseObjTag || tag == staticVariantTag
+ }
+}
+
+// afdoTransitionMutator creates afdo variants of cc modules.
+type afdoTransitionMutator struct{}
+
+func (a *afdoTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ return []string{""}
+}
+
+func (a *afdoTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
if ctx.Host() {
- return
+ return ""
}
- if ctx.static() && !ctx.staticBinary() {
- return
- }
-
- if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
- if fdoProfileName, err := actx.DeviceConfig().AfdoProfile(actx.ModuleName()); fdoProfileName != nil && err == nil {
- actx.AddFarVariationDependencies(
- []blueprint.Variation{
- {Mutator: "arch", Variation: actx.Target().ArchVariation()},
- {Mutator: "os", Variation: "android"},
- },
- FdoProfileTag,
- []string{*fdoProfileName}...,
- )
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ if !afdoPropagateViaDepTag(ctx.DepTag()) {
+ return ""
}
+
+ if sourceVariation != "" {
+ return sourceVariation
+ }
+
+ if !m.afdo.afdoEnabled() {
+ return ""
+ }
+
+ // TODO(b/324141705): this is designed to prevent propagating AFDO from static libraries that have afdo: true set, but
+ // it should be m.static() && !m.staticBinary() so that static binaries use AFDO variants of dependencies.
+ if m.static() {
+ return ""
+ }
+
+ return encodeTarget(ctx.Module().Name())
}
+ return ""
}
-// FdoProfileMutator reads the FdoProfileProvider from a direct dep with FdoProfileTag
-// assigns FdoProfileInfo.Path to the FdoProfilePath mutated property
-func (c *Module) fdoProfileMutator(ctx android.BottomUpMutatorContext) {
- if !c.Enabled() {
- return
+func (a *afdoTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ return incomingVariation
}
-
- if !c.afdo.afdoEnabled() {
- return
- }
-
- ctx.VisitDirectDepsWithTag(FdoProfileTag, func(m android.Module) {
- if info, ok := android.OtherModuleProvider(ctx, m, FdoProfileProvider); ok {
- c.afdo.Properties.FdoProfilePath = proptools.StringPtr(info.Path.String())
- }
- })
+ return ""
}
-var _ FdoProfileMutatorInterface = (*Module)(nil)
-
-// Propagate afdo requirements down from binaries and shared libraries
-func afdoDepsMutator(mctx android.TopDownMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.afdo.afdoEnabled() {
- path := m.afdo.Properties.FdoProfilePath
- mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
- tag := mctx.OtherModuleDependencyTag(dep)
- libTag, isLibTag := tag.(libraryDependencyTag)
-
- // Do not recurse down non-static dependencies
- if isLibTag {
- if !libTag.static() {
- return false
- }
- } else {
- if tag != objDepTag && tag != reuseObjTag {
- return false
- }
+func (a *afdoTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ if variation == "" {
+ // The empty variation is either a module that has enabled AFDO for itself, or the non-AFDO
+ // variant of a dependency.
+ if m.afdo.afdoEnabled() && !(m.static() && !m.staticBinary()) && !m.Host() {
+ m.afdo.addDep(ctx, ctx.ModuleName())
}
-
- if dep, ok := dep.(*Module); ok {
- dep.afdo.Properties.AfdoRDeps = append(
- dep.afdo.Properties.AfdoRDeps,
- afdoRdep{
- VariationName: proptools.StringPtr(encodeTarget(m.Name())),
- ProfilePath: path,
- },
- )
- }
-
- return true
- })
- }
-}
-
-// Create afdo variants for modules that need them
-func afdoMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.afdo != nil {
- if !m.static() && m.afdo.Properties.Afdo {
- mctx.SetDependencyVariation(encodeTarget(m.Name()))
- return
- }
-
- variationNames := []string{""}
-
- variantNameToProfilePath := make(map[string]*string)
-
- for _, afdoRDep := range m.afdo.Properties.AfdoRDeps {
- variantName := *afdoRDep.VariationName
- // An rdep can be set twice in AfdoRDeps because there can be
- // more than one path from an afdo-enabled module to
- // a static dep such as
- // afdo_enabled_foo -> static_bar ----> static_baz
- // \ ^
- // ----------------------|
- // We only need to create one variant per unique rdep
- if _, exists := variantNameToProfilePath[variantName]; !exists {
- variationNames = append(variationNames, variantName)
- variantNameToProfilePath[variantName] = afdoRDep.ProfilePath
- }
- }
-
- if len(variationNames) > 1 {
- modules := mctx.CreateVariations(variationNames...)
- for i, name := range variationNames {
- if name == "" {
- continue
- }
- variation := modules[i].(*Module)
- variation.Properties.PreventInstall = true
- variation.Properties.HideFromMake = true
- variation.afdo.Properties.Afdo = true
- variation.afdo.Properties.FdoProfilePath = variantNameToProfilePath[name]
- }
+ } else {
+ // The non-empty variation is the AFDO variant of a dependency of a module that enabled AFDO
+ // for itself.
+ m.Properties.PreventInstall = true
+ m.Properties.HideFromMake = true
+ m.afdo.Properties.AfdoDep = true
+ m.afdo.addDep(ctx, decodeTarget(variation))
}
}
}
diff --git a/cc/afdo_test.go b/cc/afdo_test.go
index b250ad1..0679d13 100644
--- a/cc/afdo_test.go
+++ b/cc/afdo_test.go
@@ -15,6 +15,7 @@
package cc
import (
+ "runtime"
"strings"
"testing"
@@ -42,19 +43,25 @@
bp := `
cc_library_shared {
name: "libTest",
+ host_supported: true,
srcs: ["test.c"],
static_libs: ["libFoo"],
afdo: true,
+ lto: {
+ thin: true,
+ },
}
cc_library_static {
name: "libFoo",
+ host_supported: true,
srcs: ["foo.c"],
static_libs: ["libBar"],
}
cc_library_static {
name: "libBar",
+ host_supported: true,
srcs: ["bar.c"],
}
`
@@ -72,13 +79,20 @@
"afdo_profiles_package/Android.bp": []byte(`
fdo_profile {
name: "libTest_afdo",
- profile: "libTest.afdo",
+ arch: {
+ arm64: {
+ profile: "libTest.afdo",
+ },
+ },
}
`),
}.AddToFixture(),
).RunTestWithBp(t, bp)
- expectedCFlag := "-fprofile-sample-use=afdo_profiles_package/libTest.afdo"
+ profileSampleCFlag := "-fprofile-sample-use=afdo_profiles_package/libTest.afdo"
+ uniqueInternalLinkageNamesCFlag := "-funique-internal-linkage-names"
+ afdoLtoLdFlag := "-Wl,-plugin-opt,-import-instr-limit=40"
+ noAfdoLtoLdFlag := "-Wl,-plugin-opt,-import-instr-limit=5"
libTest := result.ModuleForTests("libTest", "android_arm64_armv8-a_shared")
libFooAfdoVariant := result.ModuleForTests("libFoo", "android_arm64_armv8-a_static_afdo-libTest")
@@ -86,18 +100,32 @@
// Check cFlags of afdo-enabled module and the afdo-variant of its static deps
cFlags := libTest.Rule("cc").Args["cFlags"]
- if !strings.Contains(cFlags, expectedCFlag) {
- t.Errorf("Expected 'libTest' to enable afdo, but did not find %q in cflags %q", expectedCFlag, cFlags)
+ if !strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected 'libTest' to enable afdo profile, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected 'libTest' to enable afdo, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+
+ ldFlags := libTest.Rule("ld").Args["ldFlags"]
+ if !strings.Contains(ldFlags, afdoLtoLdFlag) {
+ t.Errorf("Expected 'libTest' to enable afdo, but did not find %q in ldflags %q", afdoLtoLdFlag, ldFlags)
}
cFlags = libFooAfdoVariant.Rule("cc").Args["cFlags"]
- if !strings.Contains(cFlags, expectedCFlag) {
- t.Errorf("Expected 'libFooAfdoVariant' to enable afdo, but did not find %q in cflags %q", expectedCFlag, cFlags)
+ if !strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected 'libFooAfdoVariant' to enable afdo profile, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected 'libFooAfdoVariant' to enable afdo, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
}
cFlags = libBarAfdoVariant.Rule("cc").Args["cFlags"]
- if !strings.Contains(cFlags, expectedCFlag) {
- t.Errorf("Expected 'libBarAfdoVariant' to enable afdo, but did not find %q in cflags %q", expectedCFlag, cFlags)
+ if !strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected 'libBarAfdoVariant' to enable afdo profile, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected 'libBarAfdoVariant' to enable afdo, but did not find %q in cflags %q", profileSampleCFlag, cFlags)
}
// Check dependency edge from afdo-enabled module to static deps
@@ -114,12 +142,18 @@
libBar := result.ModuleForTests("libBar", "android_arm64_armv8-a_static")
cFlags = libFoo.Rule("cc").Args["cFlags"]
- if strings.Contains(cFlags, expectedCFlag) {
- t.Errorf("Expected 'libFoo' to not enable afdo, but found %q in cflags %q", expectedCFlag, cFlags)
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected 'libFoo' to not enable afdo profile, but found %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+ if strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected 'libFoo' to not enable afdo, but found %q in cflags %q", profileSampleCFlag, cFlags)
}
cFlags = libBar.Rule("cc").Args["cFlags"]
- if strings.Contains(cFlags, expectedCFlag) {
- t.Errorf("Expected 'libBar' to not enable afdo, but found %q in cflags %q", expectedCFlag, cFlags)
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected 'libBar' to not enable afdo profile, but found %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+ if strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected 'libBar' to not enable afdo, but found %q in cflags %q", profileSampleCFlag, cFlags)
}
// Check dependency edges of static deps
@@ -130,6 +164,104 @@
if !hasDirectDep(result, libFoo.Module(), libBar.Module()) {
t.Errorf("libFoo missing dependency on non-afdo variant of libBar")
}
+
+ // Verify that the arm variant does not have FDO since the fdo_profile module only has a profile for arm64
+ libTest32 := result.ModuleForTests("libTest", "android_arm_armv7-a-neon_shared")
+ libFooAfdoVariant32 := result.ModuleForTests("libFoo", "android_arm_armv7-a-neon_static_afdo-libTest_lto-thin")
+ libBarAfdoVariant32 := result.ModuleForTests("libBar", "android_arm_armv7-a-neon_static_afdo-libTest_lto-thin")
+
+ cFlags = libTest32.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected arm32 'libTest' not to enable afdo, but found %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+
+ // TODO(b/324141705): when the fdo_profile module doesn't provide a source file the dependencies don't get
+ // -funique-internal-linkage-names but the module does.
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected arm32 'libTest' to enable -funique-internal-linkage-names but did not find %q in cflags %q",
+ uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+
+ ldFlags = libTest32.Rule("ld").Args["ldFlags"]
+ if !strings.Contains(ldFlags, noAfdoLtoLdFlag) {
+ t.Errorf("Expected arm32 'libTest' to not enable afdo, but did not find %q in ldflags %q", noAfdoLtoLdFlag, ldFlags)
+ }
+ if strings.Contains(ldFlags, afdoLtoLdFlag) {
+ t.Errorf("Expected arm32 'libTest' to not enable afdo, but found %q in ldflags %q", afdoLtoLdFlag, ldFlags)
+ }
+
+ // Check dependency edge from afdo-enabled module to static deps
+ if !hasDirectDep(result, libTest32.Module(), libFooAfdoVariant32.Module()) {
+ t.Errorf("arm32 libTest missing dependency on afdo variant of libFoo")
+ }
+
+ if !hasDirectDep(result, libFooAfdoVariant32.Module(), libBarAfdoVariant32.Module()) {
+ t.Errorf("arm32 libTest missing dependency on afdo variant of libBar")
+ }
+
+ cFlags = libFooAfdoVariant32.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected arm32 'libFoo' to not enable afdo profile, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected arm32 'libFoo' to enable afdo, but did not find %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ cFlags = libBarAfdoVariant32.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected arm32 'libBar' to not enable afdo profile, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ if !strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected arm32 'libBar' to enable afdo, but did not find %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+
+ // Verify that the host variants don't enable afdo
+ libTestHost := result.ModuleForTests("libTest", result.Config.BuildOSTarget.String()+"_shared")
+ libFooHost := result.ModuleForTests("libFoo", result.Config.BuildOSTarget.String()+"_static_lto-thin")
+ libBarHost := result.ModuleForTests("libBar", result.Config.BuildOSTarget.String()+"_static_lto-thin")
+
+ cFlags = libTestHost.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected host 'libTest' to not enable afdo profile, but found %q in cflags %q", profileSampleCFlag, cFlags)
+ }
+
+ if strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected host 'libTest' to not enable afdo but found %q in cflags %q",
+ uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+
+ if runtime.GOOS != "darwin" {
+ ldFlags := libTestHost.Rule("ld").Args["ldFlags"]
+ if !strings.Contains(ldFlags, noAfdoLtoLdFlag) {
+ t.Errorf("Expected host 'libTest' to not enable afdo, but did not find %q in ldflags %q", noAfdoLtoLdFlag, ldFlags)
+ }
+ if strings.Contains(ldFlags, afdoLtoLdFlag) {
+ t.Errorf("Expected host 'libTest' to not enable afdo, but found %q in ldflags %q", afdoLtoLdFlag, ldFlags)
+ }
+ }
+
+ // Check dependency edge from afdo-enabled module to static deps
+ if !hasDirectDep(result, libTestHost.Module(), libFooHost.Module()) {
+ t.Errorf("host libTest missing dependency on non-afdo variant of libFoo")
+ }
+
+ if !hasDirectDep(result, libFooHost.Module(), libBarHost.Module()) {
+ t.Errorf("host libTest missing dependency on non-afdo variant of libBar")
+ }
+
+ cFlags = libFooHost.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected host 'libFoo' to not enable afdo profile, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ if strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected host 'libFoo' to not enable afdo, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ cFlags = libBarHost.Rule("cc").Args["cFlags"]
+ if strings.Contains(cFlags, profileSampleCFlag) {
+ t.Errorf("Expected host 'libBar' to not enable afdo profile, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
+ if strings.Contains(cFlags, uniqueInternalLinkageNamesCFlag) {
+ t.Errorf("Expected host 'libBar' to not enable afdo, but found %q in cflags %q", uniqueInternalLinkageNamesCFlag, cFlags)
+ }
}
func TestAfdoEnabledOnStaticDepNoAfdo(t *testing.T) {
@@ -174,11 +306,11 @@
libBar := result.ModuleForTests("libBar", "android_arm64_armv8-a_static").Module()
if !hasDirectDep(result, libTest, libFoo.Module()) {
- t.Errorf("libTest missing dependency on afdo variant of libFoo")
+ t.Errorf("libTest missing dependency on non-afdo variant of libFoo")
}
if !hasDirectDep(result, libFoo.Module(), libBar) {
- t.Errorf("libFoo missing dependency on afdo variant of libBar")
+ t.Errorf("libFoo missing dependency on non-afdo variant of libBar")
}
fooVariants := result.ModuleVariantsForTests("foo")
diff --git a/cc/cc.go b/cc/cc.go
index 449d38f..2770fb2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -55,7 +55,6 @@
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
- ctx.BottomUp("fdo_profile", fdoProfileMutator)
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -70,8 +69,7 @@
ctx.Transition("coverage", &coverageTransitionMutator{})
- ctx.TopDown("afdo_deps", afdoDepsMutator)
- ctx.BottomUp("afdo", afdoMutator).Parallel()
+ ctx.Transition("afdo", &afdoTransitionMutator{})
ctx.Transition("orderfile", &orderfileTransitionMutator{})
@@ -527,7 +525,7 @@
selectedStl() string
baseModuleName() string
getVndkExtendsModuleName() string
- isAfdoCompile() bool
+ isAfdoCompile(ctx ModuleContext) bool
isOrderfileCompile() bool
isCfi() bool
isFuzzer() bool
@@ -1381,9 +1379,9 @@
return false
}
-func (c *Module) isAfdoCompile() bool {
+func (c *Module) isAfdoCompile(ctx ModuleContext) bool {
if afdo := c.afdo; afdo != nil {
- return afdo.Properties.FdoProfilePath != nil
+ return afdo.isAfdoCompile(ctx)
}
return false
}
@@ -1706,8 +1704,8 @@
return ctx.mod.IsVndk()
}
-func (ctx *moduleContextImpl) isAfdoCompile() bool {
- return ctx.mod.isAfdoCompile()
+func (ctx *moduleContextImpl) isAfdoCompile(mctx ModuleContext) bool {
+ return ctx.mod.isAfdoCompile(mctx)
}
func (ctx *moduleContextImpl) isOrderfileCompile() bool {
@@ -2351,10 +2349,6 @@
}
ctx.ctx = ctx
- if !actx.Host() || !ctx.static() || ctx.staticBinary() {
- c.afdo.addDep(ctx, actx)
- }
-
c.begin(ctx)
}
@@ -3367,7 +3361,7 @@
c.sabi.Properties.ReexportedIncludes, depExporterInfo.IncludeDirs.Strings()...)
}
- makeLibName := MakeLibName(ctx, c, ccDep, depName) + libDepTag.makeSuffix
+ makeLibName := MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName()) + libDepTag.makeSuffix
switch {
case libDepTag.header():
c.Properties.AndroidMkHeaderLibs = append(
@@ -3408,7 +3402,7 @@
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
- c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, depName)+libDepTag.makeSuffix)
+ c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix)
// Record BaseLibName for snapshots.
c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName))
case objDepTag:
diff --git a/cc/check.go b/cc/check.go
index 58ff5b2..32d1f06 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -45,6 +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") {
+ ctx.PropertyErrorf(prop, "Bad flag: `%s`, use the correct target soong rule.", flag)
} else if strings.Contains(flag, " ") {
args := strings.Split(flag, " ")
if args[0] == "-include" {
diff --git a/cc/config/global.go b/cc/config/global.go
index c562614..b21d56c 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -254,7 +254,7 @@
"-Wno-pointer-to-int-cast",
"-Werror=fortify-source",
// http://b/315246135 temporarily disabled
- "-Wno-error=unused-variable",
+ "-Wno-unused-variable",
// http://b/315250603 temporarily disabled
"-Wno-error=format",
// Disabled because it produces many false positives. http://b/323050926
@@ -367,8 +367,6 @@
"-Wno-gnu-offsetof-extensions",
// TODO: Enable this warning http://b/315245071
"-Wno-fortify-source",
- "-Wno-tautological-negation-compare",
- "-Wno-tautological-undefined-compare",
}
llvmNextExtraCommonGlobalCflags = []string{
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index deb922b..6a84fee 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -26,9 +26,7 @@
// Help catch common 32/64-bit errors.
"-Werror=implicit-function-declaration",
"-march=rv64gcv_zba_zbb_zbs",
- // Equivalent to "-munaligned-access", but our clang doesn't have that yet.
- "-Xclang -target-feature -Xclang +unaligned-scalar-mem",
- "-Xclang -target-feature -Xclang +unaligned-vector-mem",
+ "-munaligned-access",
// Until https://gitlab.com/qemu-project/qemu/-/issues/1976 is fixed...
"-mno-implicit-float",
// (https://github.com/google/android-riscv64/issues/124)
@@ -40,9 +38,7 @@
riscv64Ldflags = []string{
"-Wl,--hash-style=gnu",
"-march=rv64gcv_zba_zbb_zbs",
- // Equivalent to "-munaligned-access", but our clang doesn't have that yet.
- "-Xclang -target-feature -Xclang +unaligned-scalar-mem",
- "-Xclang -target-feature -Xclang +unaligned-vector-mem",
+ "-munaligned-access",
// We should change the default for this in clang, but for now...
// (https://github.com/google/android-riscv64/issues/124)
"-Wl,-mllvm -Wl,-jump-is-expensive=false",
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index f497bf9..9bc54d6 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -30,11 +30,6 @@
"-D_FORTIFY_SOURCE=2",
"-fstack-protector",
- // Workaround differences in inttypes.h between host and target.
- //See bug 12708004.
- "-D__STDC_FORMAT_MACROS",
- "-D__STDC_CONSTANT_MACROS",
-
"--gcc-toolchain=${LinuxGccRoot}",
"-fstack-protector-strong",
}
diff --git a/cc/coverage.go b/cc/coverage.go
index 43f5e07..f6092e4 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -91,7 +91,7 @@
}
func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
- if cov.Properties.NeedCoverageVariant {
+ if cov.Properties.NeedCoverageVariant && ctx.Device() {
ctx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, CoverageDepTag, getGcovProfileLibraryName(ctx))
@@ -184,19 +184,22 @@
if gcovCoverage {
flags.Local.LdFlags = append(flags.Local.LdFlags, "--coverage")
- coverage := ctx.GetDirectDepWithTag(getGcovProfileLibraryName(ctx), CoverageDepTag).(*Module)
- deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
-
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
+ if ctx.Device() {
+ coverage := ctx.GetDirectDepWithTag(getGcovProfileLibraryName(ctx), CoverageDepTag).(*Module)
+ deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
+ }
} else if clangCoverage {
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
if EnableContinuousCoverage(ctx) {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm=-runtime-counter-relocation")
}
- coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
- deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,open")
+ if ctx.Device() {
+ coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
+ deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,open")
+ }
}
}
@@ -204,7 +207,7 @@
}
func (cov *coverage) begin(ctx BaseModuleContext) {
- if ctx.Host() {
+ if ctx.Host() && !ctx.Os().Linux() {
// TODO(dwillemsen): because of -nodefaultlibs, we must depend on libclang_rt.profile-*.a
// Just turn off for now.
} else {
diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go
index 0893da5..1a33957 100644
--- a/cc/fdo_profile.go
+++ b/cc/fdo_profile.go
@@ -43,23 +43,10 @@
}
// FdoProfileProvider is used to provide path to an fdo profile
-var FdoProfileProvider = blueprint.NewMutatorProvider[FdoProfileInfo]("fdo_profile")
-
-// FdoProfileMutatorInterface is the interface implemented by fdo_profile module type
-// module types that can depend on an fdo_profile module
-type FdoProfileMutatorInterface interface {
- // FdoProfileMutator eithers set or get FdoProfileProvider
- fdoProfileMutator(ctx android.BottomUpMutatorContext)
-}
-
-var _ FdoProfileMutatorInterface = (*fdoProfile)(nil)
+var FdoProfileProvider = blueprint.NewProvider[FdoProfileInfo]()
// GenerateAndroidBuildActions of fdo_profile does not have any build actions
-func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
-
-// FdoProfileMutator sets FdoProfileProvider to fdo_profile module
-// or sets afdo.Properties.FdoProfilePath to path in FdoProfileProvider of the depended fdo_profile
-func (fp *fdoProfile) fdoProfileMutator(ctx android.BottomUpMutatorContext) {
+func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if fp.properties.Profile != nil {
path := android.PathForModuleSrc(ctx, *fp.properties.Profile)
android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{
@@ -68,14 +55,6 @@
}
}
-// fdoProfileMutator calls the generic fdoProfileMutator function of fdoProfileMutator
-// which is implemented by cc and cc.FdoProfile
-func fdoProfileMutator(ctx android.BottomUpMutatorContext) {
- if f, ok := ctx.Module().(FdoProfileMutatorInterface); ok {
- f.fdoProfileMutator(ctx)
- }
-}
-
func FdoProfileFactory() android.Module {
m := &fdoProfile{}
m.AddProperties(&m.properties)
diff --git a/cc/library.go b/cc/library.go
index 4684d32..e2b4d4f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1354,38 +1354,28 @@
fileName+".lsdump")
}
-func getRefAbiDumpDir(isNdk, isLlndk bool) string {
- var dirName string
- if isNdk {
- dirName = "ndk"
- } else if isLlndk {
- dirName = "vndk"
- } else {
- dirName = "platform"
- }
- return filepath.Join("prebuilts", "abi-dumps", dirName)
-}
-
-func prevRefAbiDumpVersion(ctx ModuleContext, dumpDir string) int {
+// Return the previous and current SDK versions for cross-version ABI diff.
+func crossVersionAbiDiffSdkVersions(ctx ModuleContext, dumpDir string) (string, string) {
sdkVersionInt := ctx.Config().PlatformSdkVersion().FinalInt()
sdkVersionStr := ctx.Config().PlatformSdkVersion().String()
if ctx.Config().PlatformSdkFinal() {
- return sdkVersionInt - 1
+ return strconv.Itoa(sdkVersionInt - 1), sdkVersionStr
} else {
// The platform SDK version can be upgraded before finalization while the corresponding abi dumps hasn't
// been generated. Thus the Cross-Version Check chooses PLATFORM_SDK_VERION - 1 as previous version.
// This situation could be identified by checking the existence of the PLATFORM_SDK_VERION dump directory.
versionedDumpDir := android.ExistentPathForSource(ctx, dumpDir, sdkVersionStr)
if versionedDumpDir.Valid() {
- return sdkVersionInt
+ return sdkVersionStr, strconv.Itoa(sdkVersionInt + 1)
} else {
- return sdkVersionInt - 1
+ return strconv.Itoa(sdkVersionInt - 1), sdkVersionStr
}
}
}
-func currRefAbiDumpVersion(ctx ModuleContext) string {
+// Return the SDK version for same-version ABI diff.
+func currRefAbiDumpSdkVersion(ctx ModuleContext) string {
if ctx.Config().PlatformSdkFinal() {
// After sdk finalization, the ABI of the latest API level must be consistent with the source code,
// so choose PLATFORM_SDK_VERSION as the current version.
@@ -1435,17 +1425,17 @@
}
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
- baseName string, isLlndkOrNdk bool) {
+ baseName, nameExt string, isLlndkOrNdk bool) {
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
- library.sourceAbiDiff(ctx, referenceDump, baseName, "",
+ library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
}
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
- baseName, nameExt string, isLlndkOrNdk bool, refDumpDir string) {
+ baseName, nameExt string, refDumpDir string) {
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName + " -ref-dump-dir $$ANDROID_BUILD_TOP/" + refDumpDir
@@ -1455,7 +1445,7 @@
}
library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
- isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
+ false /* isLlndkOrNdk */, false /* allowExtensions */, "current", errorMessage)
}
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
@@ -1470,38 +1460,56 @@
}
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
- // The logic must be consistent with classifySourceAbiDump.
- isNdk := ctx.isNdk(ctx.Config())
- isLlndk := ctx.isImplementationForLLNDKPublic()
- currVersion := currRefAbiDumpVersion(ctx)
+ currSdkVersion := currRefAbiDumpSdkVersion(ctx)
+ currVendorVersion := ctx.Config().VendorApiLevel()
library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
headerAbiChecker.Exclude_symbol_tags,
- currVersion)
+ currSdkVersion)
for _, tag := range classifySourceAbiDump(ctx) {
- addLsdumpPath(tag + ":" + library.sAbiOutputFile.String())
- }
+ addLsdumpPath(string(tag) + ":" + library.sAbiOutputFile.String())
- dumpDir := getRefAbiDumpDir(isNdk, isLlndk)
- binderBitness := ctx.DeviceConfig().BinderBitness()
- // Check against the previous version.
- prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
- prevVersion := strconv.Itoa(prevVersionInt)
- prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
- prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
- if prevDumpFile.Valid() {
- library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
- fileName, isLlndk || isNdk,
- strconv.Itoa(prevVersionInt+1), prevVersion)
- }
- // Check against the current version.
- currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
- currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
- if currDumpFile.Valid() {
- library.sameVersionAbiDiff(ctx, currDumpFile.Path(),
- fileName, isLlndk || isNdk)
+ dumpDirName := tag.dirName()
+ if dumpDirName == "" {
+ continue
+ }
+ dumpDir := filepath.Join("prebuilts", "abi-dumps", dumpDirName)
+ isLlndk := (tag == llndkLsdumpTag)
+ isNdk := (tag == ndkLsdumpTag)
+ binderBitness := ctx.DeviceConfig().BinderBitness()
+ nameExt := ""
+ if isLlndk {
+ nameExt = "llndk"
+ }
+ // Check against the previous version.
+ var prevVersion, currVersion string
+ // If this release config does not define VendorApiLevel, fall back to the old policy.
+ if isLlndk && currVendorVersion != "" {
+ prevVersion = ctx.Config().PrevVendorApiLevel()
+ currVersion = currVendorVersion
+ } else {
+ prevVersion, currVersion = crossVersionAbiDiffSdkVersions(ctx, dumpDir)
+ }
+ prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
+ prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
+ if prevDumpFile.Valid() {
+ library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
+ fileName, isLlndk || isNdk, currVersion, nameExt+prevVersion)
+ }
+ // Check against the current version.
+ if isLlndk && currVendorVersion != "" {
+ currVersion = currVendorVersion
+ } else {
+ currVersion = currSdkVersion
+ }
+ currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
+ currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
+ if currDumpFile.Valid() {
+ library.sameVersionAbiDiff(ctx, currDumpFile.Path(),
+ fileName, nameExt, isLlndk || isNdk)
+ }
}
// Check against the opt-in reference dumps.
for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs {
@@ -1513,8 +1521,7 @@
continue
}
library.optInAbiDiff(ctx, optInDumpFile.Path(),
- fileName, "opt"+strconv.Itoa(i), isLlndk || isNdk,
- optInDumpDirPath.String())
+ fileName, "opt"+strconv.Itoa(i), optInDumpDirPath.String())
}
}
}
diff --git a/cc/lto.go b/cc/lto.go
index b2b4570..05fa8ee 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -100,7 +100,7 @@
lto.Properties.LtoEnabled = ltoEnabled
}
-func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
+func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags {
// TODO(b/131771163): CFI and Fuzzer controls LTO flags by themselves.
// This has be checked late because these properties can be mutated.
if ctx.isCfi() || ctx.isFuzzer() {
@@ -139,7 +139,7 @@
// Reduce the inlining threshold for a better balance of binary size and
// performance.
if !ctx.Darwin() {
- if ctx.isAfdoCompile() {
+ if ctx.isAfdoCompile(ctx) {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=40")
} else {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 95fb7ed..f6b5ed5 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -595,6 +595,9 @@
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency))
+ // check that LOCAL_SHARED_LIBRARIES contains libbar and not libbar.v<N>
+ entries := android.AndroidMkEntriesForTest(t, ctx, libfoo)[0]
+ android.AssertStringListContains(t, "Version should not be present in LOCAL_SHARED_LIBRARIES", entries.EntryMap["LOCAL_SHARED_LIBRARIES"], "libbar")
// check installation rules
// the selected soong module should be exported to make
@@ -603,7 +606,7 @@
// check LOCAL_MODULE of the selected module name
// the prebuilt should have the same LOCAL_MODULE when exported to make
- entries := android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
+ entries = android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "libbar", entries.EntryMap["LOCAL_MODULE"][0])
}
}
diff --git a/cc/sabi.go b/cc/sabi.go
index 4ca9f5c..af26726 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -26,6 +26,30 @@
lsdumpPathsLock sync.Mutex
)
+type lsdumpTag string
+
+const (
+ llndkLsdumpTag lsdumpTag = "LLNDK"
+ ndkLsdumpTag lsdumpTag = "NDK"
+ platformLsdumpTag lsdumpTag = "PLATFORM"
+ productLsdumpTag lsdumpTag = "PRODUCT"
+ vendorLsdumpTag lsdumpTag = "VENDOR"
+)
+
+// Return the prebuilt ABI dump directory for a tag; an empty string for an opt-in dump.
+func (tag *lsdumpTag) dirName() string {
+ switch *tag {
+ case ndkLsdumpTag:
+ return "ndk"
+ case llndkLsdumpTag:
+ return "vndk"
+ case platformLsdumpTag:
+ return "platform"
+ default:
+ return ""
+ }
+}
+
// Properties for ABI compatibility checker in Android.bp.
type headerAbiCheckerProperties struct {
// Enable ABI checks (even if this is not an LLNDK/VNDK lib)
@@ -98,8 +122,8 @@
}
// Returns a slice of strings that represent the ABI dumps generated for this module.
-func classifySourceAbiDump(ctx android.BaseModuleContext) []string {
- result := []string{}
+func classifySourceAbiDump(ctx android.BaseModuleContext) []lsdumpTag {
+ result := []lsdumpTag{}
m := ctx.Module().(*Module)
headerAbiChecker := m.library.getHeaderAbiCheckerProperties(ctx)
if headerAbiChecker.explicitlyDisabled() {
@@ -107,21 +131,21 @@
}
if !m.InProduct() && !m.InVendor() {
if m.isImplementationForLLNDKPublic() {
- result = append(result, "LLNDK")
+ result = append(result, llndkLsdumpTag)
}
// Return NDK if the library is both NDK and APEX.
// TODO(b/309880485): Split NDK and APEX ABI.
if m.IsNdk(ctx.Config()) {
- result = append(result, "NDK")
+ result = append(result, ndkLsdumpTag)
} else if m.library.hasStubsVariants() || headerAbiChecker.enabled() {
- result = append(result, "PLATFORM")
+ result = append(result, platformLsdumpTag)
}
} else if headerAbiChecker.enabled() {
if m.InProduct() {
- result = append(result, "PRODUCT")
+ result = append(result, productLsdumpTag)
}
if m.InVendor() {
- result = append(result, "VENDOR")
+ result = append(result, vendorLsdumpTag)
}
}
return result
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go
index 1aa6f6f..2c57180 100644
--- a/cmd/merge_zips/merge_zips.go
+++ b/cmd/merge_zips/merge_zips.go
@@ -342,7 +342,8 @@
func (oz *OutputZip) getUninitializedPythonPackages(inputZips []InputZip) ([]string, error) {
// the runfiles packages needs to be populated with "__init__.py".
// the runfiles dirs have been treated as packages.
- allPackages := make(map[string]bool)
+ var allPackages []string // Using a slice to preserve input order.
+ seenPkgs := make(map[string]bool)
initedPackages := make(map[string]bool)
getPackage := func(path string) string {
ret := filepath.Dir(path)
@@ -369,16 +370,17 @@
initedPackages[pyPkg] = true
}
for pyPkg != "" {
- if _, found := allPackages[pyPkg]; found {
+ if _, found := seenPkgs[pyPkg]; found {
break
}
- allPackages[pyPkg] = true
+ seenPkgs[pyPkg] = true
+ allPackages = append(allPackages, pyPkg)
pyPkg = getPackage(pyPkg)
}
}
}
noInitPackages := make([]string, 0)
- for pyPkg := range allPackages {
+ for _, pyPkg := range allPackages {
if _, found := initedPackages[pyPkg]; !found {
noInitPackages = append(noInitPackages, pyPkg)
}
diff --git a/cmd/merge_zips/merge_zips_test.go b/cmd/merge_zips/merge_zips_test.go
index 64b08d0..17228c4 100644
--- a/cmd/merge_zips/merge_zips_test.go
+++ b/cmd/merge_zips/merge_zips_test.go
@@ -103,6 +103,7 @@
stripFiles []string
stripDirs []string
jar bool
+ par bool
sort bool
ignoreDuplicates bool
stripDirEntries bool
@@ -265,6 +266,34 @@
},
out: []testZipEntry{withoutTimestamp, a},
},
+ {
+ name: "emulate par",
+ in: [][]testZipEntry{
+ {
+ testZipEntry{name: "3/main.py"},
+ testZipEntry{name: "c/main.py"},
+ testZipEntry{name: "a/main.py"},
+ testZipEntry{name: "2/main.py"},
+ testZipEntry{name: "b/main.py"},
+ testZipEntry{name: "1/main.py"},
+ },
+ },
+ out: []testZipEntry{
+ testZipEntry{name: "3/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "c/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "a/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "2/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "b/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "1/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "3/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "c/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "a/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "2/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "b/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "1/main.py", timestamp: jar.DefaultTime},
+ },
+ par: true,
+ },
}
for _, test := range testCases {
@@ -280,7 +309,7 @@
writer := zip.NewWriter(out)
err := mergeZips(inputZips, writer, "", "",
- test.sort, test.jar, false, test.stripDirEntries, test.ignoreDuplicates,
+ test.sort, test.jar, test.par, test.stripDirEntries, test.ignoreDuplicates,
test.stripFiles, test.stripDirs, test.zipsToNotStrip)
closeErr := writer.Close()
diff --git a/filesystem/Android.bp b/filesystem/Android.bp
index 07d57c9..cdf6682 100644
--- a/filesystem/Android.bp
+++ b/filesystem/Android.bp
@@ -9,6 +9,7 @@
"blueprint",
"soong",
"soong-android",
+ "soong-bpf", // for testing
"soong-linkerconfig",
],
srcs: [
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 2f6476c..6612a6f 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -50,8 +50,8 @@
// Function that builds extra files under the root directory and returns the files
buildExtraFiles func(ctx android.ModuleContext, root android.OutputPath) android.OutputPaths
- // Function that filters PackagingSpecs returned by PackagingBase.GatherPackagingSpecs()
- filterPackagingSpecs func(specs map[string]android.PackagingSpec)
+ // Function that filters PackagingSpec in PackagingBase.GatherPackagingSpecs()
+ filterPackagingSpec func(spec android.PackagingSpec) bool
output android.OutputPath
installDir android.InstallPath
@@ -493,10 +493,7 @@
// Note that "apex" module installs its contents to "apex"(fake partition) as well
// for symbol lookup by imitating "activated" paths.
func (f *filesystem) gatherFilteredPackagingSpecs(ctx android.ModuleContext) map[string]android.PackagingSpec {
- specs := f.PackagingBase.GatherPackagingSpecs(ctx)
- if f.filterPackagingSpecs != nil {
- f.filterPackagingSpecs(specs)
- }
+ specs := f.PackagingBase.GatherPackagingSpecsWithFilter(ctx, f.filterPackagingSpec)
return specs
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index aef4756..c448105 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -19,6 +19,7 @@
"testing"
"android/soong/android"
+ "android/soong/bpf"
"android/soong/cc"
"android/soong/etc"
@@ -31,6 +32,7 @@
var fixture = android.GroupFixturePreparers(
android.PrepareForIntegrationTestWithAndroid,
+ bpf.PrepareForTestWithBpf,
etc.PrepareForTestWithPrebuiltEtc,
cc.PrepareForIntegrationTestWithCc,
PrepareForTestWithFilesystemBuildComponents,
@@ -40,11 +42,55 @@
result := fixture.RunTestWithBp(t, `
android_filesystem {
name: "myfilesystem",
+ multilib: {
+ common: {
+ deps: [
+ "bpf.o",
+ ],
+ },
+ lib32: {
+ deps: [
+ "foo",
+ "libbar",
+ ],
+ },
+ lib64: {
+ deps: [
+ "libbar",
+ ],
+ },
+ },
+ compile_multilib: "both",
+ }
+
+ bpf {
+ name: "bpf.o",
+ srcs: ["bpf.c"],
+ }
+
+ cc_binary {
+ name: "foo",
+ compile_multilib: "prefer32",
+ }
+
+ cc_library {
+ name: "libbar",
}
`)
// produces "myfilesystem.img"
result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img")
+
+ fs := result.ModuleForTests("myfilesystem", "android_common").Module().(*filesystem)
+ expected := []string{
+ "bin/foo",
+ "lib/libbar.so",
+ "lib64/libbar.so",
+ "etc/bpf/bpf.o",
+ }
+ for _, e := range expected {
+ android.AssertStringListContains(t, "missing entry", fs.entries, e)
+ }
}
func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) {
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 75abf70..34f4ffb 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -37,7 +37,7 @@
module := &systemImage{}
module.AddProperties(&module.properties)
module.filesystem.buildExtraFiles = module.buildExtraFiles
- module.filesystem.filterPackagingSpecs = module.filterPackagingSpecs
+ module.filesystem.filterPackagingSpec = module.filterPackagingSpec
initFilesystemModule(&module.filesystem)
return module
}
@@ -73,10 +73,6 @@
// 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
// for symbol lookup by imitating "activated" paths.
-func (s *systemImage) filterPackagingSpecs(specs map[string]android.PackagingSpec) {
- for k, ps := range specs {
- if ps.Partition() != "system" {
- delete(specs, k)
- }
- }
+func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool {
+ return ps.Partition() == "system"
}
diff --git a/java/Android.bp b/java/Android.bp
index 2585cd2..54b36ab 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -67,6 +67,7 @@
"plugin.go",
"prebuilt_apis.go",
"proto.go",
+ "ravenwood.go",
"robolectric.go",
"rro.go",
"sdk.go",
@@ -107,6 +108,7 @@
"plugin_test.go",
"prebuilt_apis_test.go",
"proto_test.go",
+ "ravenwood_test.go",
"rro_test.go",
"sdk_library_test.go",
"sdk_test.go",
diff --git a/java/aar.go b/java/aar.go
index f61fc83..0edee83 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -23,6 +23,7 @@
"android/soong/android"
"android/soong/dexpreopt"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -414,17 +415,11 @@
linkFlags = append(linkFlags, "--static-lib")
}
+ linkFlags = append(linkFlags, "--no-static-lib-packages")
if a.isLibrary && a.useResourceProcessorBusyBox(ctx) {
- // When building an android_library using ResourceProcessorBusyBox the resources are merged into
- // package-res.apk with --merge-only, but --no-static-lib-packages is not used so that R.txt only
- // contains resources from this library.
+ // When building an android_library using ResourceProcessorBusyBox pass --merge-only to skip resource
+ // references validation until the final app link step when all static libraries are present.
linkFlags = append(linkFlags, "--merge-only")
- } else {
- // When building and app or when building an android_library without ResourceProcessorBusyBox
- // --no-static-lib-packages is used to put all the resources into the app. If ResourceProcessorBusyBox
- // is used then the app's R.txt will be post-processed along with the R.txt files from dependencies to
- // sort resources into the right packages in R.class.
- linkFlags = append(linkFlags, "--no-static-lib-packages")
}
packageRes := android.PathForModuleOut(ctx, "package-res.apk")
@@ -808,6 +803,9 @@
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.aapt.isLibrary = true
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ if a.usesLibrary.shouldDisableDexpreopt {
+ a.dexpreopter.disableDexpreopt()
+ }
a.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: android.SdkContext(a),
@@ -1177,6 +1175,7 @@
"--static-lib",
"--merge-only",
"--auto-add-overlay",
+ "--no-static-lib-packages",
}
linkFlags = append(linkFlags, "--manifest "+a.manifest.String())
@@ -1250,6 +1249,7 @@
TransitiveStaticLibsHeaderJars: a.transitiveStaticLibsHeaderJars,
ImplementationAndResourcesJars: android.PathsIfNonNil(a.classpathFile),
ImplementationJars: android.PathsIfNonNil(a.classpathFile),
+ StubsLinkType: Implementation,
// TransitiveAconfigFiles: // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
})
diff --git a/java/android_manifest.go b/java/android_manifest.go
index 082b00e..8599003 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -152,9 +152,10 @@
if params.SdkContext != nil {
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params)
- if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
- targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
- deps = append(deps, ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
+ UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
+ targetSdkVersion = fingerprintTargetSdkVersion
+ deps = append(deps, fingerprintDeps)
}
args = append(args, "--targetSdkVersion ", targetSdkVersion)
@@ -169,9 +170,10 @@
ctx.ModuleErrorf("invalid ReplaceMaxSdkVersionPlaceholder: %s", err)
}
- if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
- minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
- deps = append(deps, ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
+ UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
+ minSdkVersion = fingerprintMinSdkVersion
+ deps = append(deps, fingerprintDeps)
}
if err != nil {
diff --git a/java/app.go b/java/app.go
index 0c56d81..9736ffd 100755
--- a/java/app.go
+++ b/java/app.go
@@ -472,8 +472,9 @@
// Add TARGET_AAPT_CHARACTERISTICS values to AAPT link flags if they exist and --product flags were not provided.
autogenerateRRO := proptools.Bool(a.appProperties.Generate_product_characteristics_rro)
hasProduct := android.PrefixInList(a.aaptProperties.Aaptflags, "--product")
- if !autogenerateRRO && !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
- aaptLinkFlags = append(aaptLinkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
+ characteristics := ctx.Config().ProductAAPTCharacteristics()
+ if !autogenerateRRO && !hasProduct && len(characteristics) > 0 && characteristics != "default" {
+ aaptLinkFlags = append(aaptLinkFlags, "--product", characteristics)
}
if !Bool(a.aaptProperties.Aapt_include_all_resources) {
@@ -777,6 +778,9 @@
a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir)
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ if a.usesLibrary.shouldDisableDexpreopt {
+ a.dexpreopter.disableDexpreopt()
+ }
var noticeAssetPath android.WritablePath
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
@@ -920,15 +924,39 @@
shouldCollectRecursiveNativeDeps bool,
checkNativeSdkVersion bool) ([]jniLib, android.Paths, []Certificate) {
- var jniLibs []jniLib
- var prebuiltJniPackages android.Paths
- var certificates []Certificate
- seenModulePaths := make(map[string]bool)
-
if checkNativeSdkVersion {
checkNativeSdkVersion = app.SdkVersion(ctx).Specified() &&
app.SdkVersion(ctx).Kind != android.SdkCorePlatform && !app.RequiresStableAPIs(ctx)
}
+ jniLib, prebuiltJniPackages := collectJniDeps(ctx, shouldCollectRecursiveNativeDeps,
+ checkNativeSdkVersion, func(dep cc.LinkableInterface) bool {
+ return !dep.IsNdk(ctx.Config()) && !dep.IsStubs()
+ })
+
+ var certificates []Certificate
+
+ ctx.VisitDirectDeps(func(module android.Module) {
+ otherName := ctx.OtherModuleName(module)
+ tag := ctx.OtherModuleDependencyTag(module)
+
+ if tag == certificateTag {
+ if dep, ok := module.(*AndroidAppCertificate); ok {
+ certificates = append(certificates, dep.Certificate)
+ } else {
+ ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", otherName)
+ }
+ }
+ })
+ return jniLib, prebuiltJniPackages, certificates
+}
+
+func collectJniDeps(ctx android.ModuleContext,
+ shouldCollectRecursiveNativeDeps bool,
+ checkNativeSdkVersion bool,
+ filter func(cc.LinkableInterface) bool) ([]jniLib, android.Paths) {
+ var jniLibs []jniLib
+ var prebuiltJniPackages android.Paths
+ seenModulePaths := make(map[string]bool)
ctx.WalkDeps(func(module android.Module, parent android.Module) bool {
otherName := ctx.OtherModuleName(module)
@@ -936,7 +964,7 @@
if IsJniDepTag(tag) || cc.IsSharedDepTag(tag) {
if dep, ok := module.(cc.LinkableInterface); ok {
- if dep.IsNdk(ctx.Config()) || dep.IsStubs() {
+ if filter != nil && !filter(dep) {
return false
}
@@ -977,18 +1005,10 @@
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
- if tag == certificateTag {
- if dep, ok := module.(*AndroidAppCertificate); ok {
- certificates = append(certificates, dep.Certificate)
- } else {
- ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", otherName)
- }
- }
-
return false
})
- return jniLibs, prebuiltJniPackages, certificates
+ return jniLibs, prebuiltJniPackages
}
func (a *AndroidApp) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
@@ -1096,6 +1116,8 @@
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":
@@ -1190,10 +1212,10 @@
Cmd *string
}{
Name: proptools.StringPtr(rroManifestName),
- Tools: []string{"characteristics_rro_generator"},
+ Tools: []string{"characteristics_rro_generator", "aapt2"},
Out: []string{"AndroidManifest.xml"},
- Srcs: []string{":" + a.Name() + "{.manifest.xml}"},
- Cmd: proptools.StringPtr("$(location characteristics_rro_generator) $(in) $(out)"),
+ Srcs: []string{":" + a.Name() + "{.apk}"},
+ Cmd: proptools.StringPtr("$(location characteristics_rro_generator) $$($(location aapt2) dump packagename $(in)) $(out)"),
}
ctx.CreateModule(genrule.GenRuleFactory, &rroManifestProperties)
@@ -1547,6 +1569,9 @@
// Whether to enforce verify_uses_library check.
enforce bool
+
+ // Whether dexpreopt should be disabled
+ shouldDisableDexpreopt bool
}
func (u *usesLibrary) addLib(lib string, optional bool) {
@@ -1628,6 +1653,15 @@
}
}
+ // Skip java_sdk_library dependencies that provide stubs, but not an implementation.
+ // This will be restricted to optional_uses_libs
+ if sdklib, ok := m.(SdkLibraryDependency); ok {
+ if tag == usesLibOptTag && sdklib.DexJarBuildPath(ctx).PathOrNil() == nil {
+ u.shouldDisableDexpreopt = true
+ return
+ }
+ }
+
if lib, ok := m.(UsesLibraryDependency); ok {
libName := dep
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
diff --git a/java/app_import.go b/java/app_import.go
index 12ead0a..8c90e4c 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -70,9 +70,10 @@
android.ApexModuleBase
prebuilt android.Prebuilt
- properties AndroidAppImportProperties
- dpiVariants interface{}
- archVariants interface{}
+ properties AndroidAppImportProperties
+ dpiVariants interface{}
+ archVariants interface{}
+ arch_dpiVariants interface{}
outputFile android.Path
certificate Certificate
@@ -155,8 +156,8 @@
// soong config variables are applied.
func (a *AndroidAppImport) processVariants(ctx android.DefaultableHookContext) {
config := ctx.Config()
+ dpiProps := reflect.ValueOf(a.dpiVariants).Elem().FieldByName(DpiGroupName)
- dpiProps := reflect.ValueOf(a.dpiVariants).Elem().FieldByName("Dpi_variants")
// Try DPI variant matches in the reverse-priority order so that the highest priority match
// overwrites everything else.
// TODO(jungjw): Can we optimize this by making it priority order?
@@ -166,11 +167,27 @@
if config.ProductAAPTPreferredConfig() != "" {
MergePropertiesFromVariant(ctx, &a.properties, dpiProps, config.ProductAAPTPreferredConfig())
}
-
- archProps := reflect.ValueOf(a.archVariants).Elem().FieldByName("Arch")
+ archProps := reflect.ValueOf(a.archVariants).Elem().FieldByName(ArchGroupName)
archType := ctx.Config().AndroidFirstDeviceTarget.Arch.ArchType
MergePropertiesFromVariant(ctx, &a.properties, archProps, archType.Name)
+ // Process "arch" includes "dpi_variants"
+ archStructPtr := reflect.ValueOf(a.arch_dpiVariants).Elem().FieldByName(ArchGroupName)
+ if archStruct := archStructPtr.Elem(); archStruct.IsValid() {
+ archPartPropsPtr := archStruct.FieldByName(proptools.FieldNameForProperty(archType.Name))
+ if archPartProps := archPartPropsPtr.Elem(); archPartProps.IsValid() {
+ archDpiPropsPtr := archPartProps.FieldByName(DpiGroupName)
+ if archDpiProps := archDpiPropsPtr.Elem(); archDpiProps.IsValid() {
+ for i := len(config.ProductAAPTPrebuiltDPI()) - 1; i >= 0; i-- {
+ MergePropertiesFromVariant(ctx, &a.properties, archDpiProps, config.ProductAAPTPrebuiltDPI()[i])
+ }
+ if config.ProductAAPTPreferredConfig() != "" {
+ MergePropertiesFromVariant(ctx, &a.properties, archDpiProps, config.ProductAAPTPreferredConfig())
+ }
+ }
+ }
+ }
+
if String(a.properties.Apk) == "" {
// Disable this module since the apk property is still empty after processing all matching
// variants. This likely means there is no matching variant, and the default variant doesn't
@@ -319,6 +336,9 @@
a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ if a.usesLibrary.shouldDisableDexpreopt {
+ a.dexpreopter.disableDexpreopt()
+ }
if a.usesLibrary.enforceUsesLibraries() {
a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
@@ -448,18 +468,25 @@
return android.OptionalPath{}
}
+const (
+ ArchGroupName = "Arch"
+ DpiGroupName = "Dpi_variants"
+)
+
var dpiVariantGroupType reflect.Type
var archVariantGroupType reflect.Type
+var archdpiVariantGroupType reflect.Type
var supportedDpis = []string{"ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"}
func initAndroidAppImportVariantGroupTypes() {
- dpiVariantGroupType = createVariantGroupType(supportedDpis, "Dpi_variants")
+ dpiVariantGroupType = createVariantGroupType(supportedDpis, DpiGroupName)
archNames := make([]string, len(android.ArchTypeList()))
for i, archType := range android.ArchTypeList() {
archNames[i] = archType.Name
}
- archVariantGroupType = createVariantGroupType(archNames, "Arch")
+ archVariantGroupType = createVariantGroupType(archNames, ArchGroupName)
+ archdpiVariantGroupType = createArchDpiVariantGroupType(archNames, supportedDpis)
}
// Populates all variant struct properties at creation time.
@@ -469,6 +496,9 @@
a.archVariants = reflect.New(archVariantGroupType).Interface()
a.AddProperties(a.archVariants)
+
+ a.arch_dpiVariants = reflect.New(archdpiVariantGroupType).Interface()
+ a.AddProperties(a.arch_dpiVariants)
}
func (a *AndroidAppImport) Privileged() bool {
@@ -523,6 +553,42 @@
})
}
+func createArchDpiVariantGroupType(archNames []string, dpiNames []string) reflect.Type {
+ props := reflect.TypeOf((*AndroidAppImportProperties)(nil))
+
+ dpiVariantFields := make([]reflect.StructField, len(dpiNames))
+ for i, variant_dpi := range dpiNames {
+ dpiVariantFields[i] = reflect.StructField{
+ Name: proptools.FieldNameForProperty(variant_dpi),
+ Type: props,
+ }
+ }
+ dpiVariantGroupStruct := reflect.StructOf(dpiVariantFields)
+ dpi_struct := reflect.StructOf([]reflect.StructField{
+ {
+ Name: DpiGroupName,
+ Type: reflect.PointerTo(dpiVariantGroupStruct),
+ },
+ })
+
+ archVariantFields := make([]reflect.StructField, len(archNames))
+ for i, variant_arch := range archNames {
+ archVariantFields[i] = reflect.StructField{
+ Name: proptools.FieldNameForProperty(variant_arch),
+ Type: reflect.PointerTo(dpi_struct),
+ }
+ }
+ archVariantGroupStruct := reflect.StructOf(archVariantFields)
+
+ return_struct := reflect.StructOf([]reflect.StructField{
+ {
+ Name: ArchGroupName,
+ Type: reflect.PointerTo(archVariantGroupStruct),
+ },
+ })
+ return return_struct
+}
+
// android_app_import imports a prebuilt apk with additional processing specified in the module.
// DPI-specific apk source files can be specified using dpi_variants. Example:
//
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 44f8f16..5de50e7 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -472,6 +472,35 @@
artifactPath: "prebuilts/apk/app_arm.apk",
installPath: "/system/app/foo/foo.apk",
},
+ {
+ name: "matching arch and dpi_variants",
+ bp: `
+ android_app_import {
+ name: "foo",
+ apk: "prebuilts/apk/app.apk",
+ arch: {
+ arm64: {
+ apk: "prebuilts/apk/app_arm64.apk",
+ dpi_variants: {
+ mdpi: {
+ apk: "prebuilts/apk/app_arm64_mdpi.apk",
+ },
+ xhdpi: {
+ apk: "prebuilts/apk/app_arm64_xhdpi.apk",
+ },
+ },
+ },
+ },
+ presigned: true,
+ dex_preopt: {
+ enabled: true,
+ },
+ }
+ `,
+ expected: "verify_uses_libraries/apk/app_arm64_xhdpi.apk",
+ artifactPath: "prebuilts/apk/app_arm64_xhdpi.apk",
+ installPath: "/system/app/foo/foo.apk",
+ },
}
for _, test := range testCases {
diff --git a/java/app_test.go b/java/app_test.go
index 362bef9..125c971 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4378,3 +4378,26 @@
"--feature-flags @out/soong/.intermediates/bar/intermediate.txt --feature-flags @out/soong/.intermediates/baz/intermediate.txt",
)
}
+
+// Test that dexpreopt is disabled if an optional_uses_libs exists, but does not provide an implementation.
+func TestNoDexpreoptOptionalUsesLibDoesNotHaveImpl(t *testing.T) {
+ bp := `
+ java_sdk_library_import {
+ name: "sdklib_noimpl",
+ public: {
+ jars: ["stub.jar"],
+ },
+ }
+ android_app {
+ name: "app",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ optional_uses_libs: [
+ "sdklib_noimpl",
+ ],
+ }
+ `
+ result := prepareForJavaTest.RunTestWithBp(t, bp)
+ dexpreopt := result.ModuleForTests("app", "android_common").MaybeRule("dexpreopt").Rule
+ android.AssertBoolEquals(t, "dexpreopt should be disabled if optional_uses_libs does not have an implementation", true, dexpreopt == nil)
+}
diff --git a/java/base.go b/java/base.go
index 4e2366f..7f4ea08 100644
--- a/java/base.go
+++ b/java/base.go
@@ -26,6 +26,7 @@
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
+ "android/soong/aconfig"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java/config"
@@ -205,6 +206,13 @@
// Note that currently not all actions implemented by android_apps are sandboxed, so you
// may only see this being necessary in lint builds.
Compile_data []string `android:"path"`
+
+ // Property signifying whether the module compiles stubs or not.
+ // Should be set to true when srcs of this module are stub files.
+ // This property does not need to be set to true when the module depends on
+ // the stubs via libs, but should be set to true when the module depends on
+ // the stubs via static libs.
+ Is_stubs_module *bool
}
// Properties that are specific to device modules. Host module factories should not add these when
@@ -532,6 +540,8 @@
// Values that will be set in the JarJarProvider data for jarjar repackaging,
// and merged with our dependencies' rules.
jarjarRenameRules map[string]string
+
+ stubsLinkType StubsLinkType
}
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
@@ -1212,6 +1222,7 @@
ExportedPlugins: j.exportedPluginJars,
ExportedPluginClasses: j.exportedPluginClasses,
ExportedPluginDisableTurbine: j.exportedDisableTurbine,
+ StubsLinkType: j.stubsLinkType,
})
j.outputFile = j.headerJarFile
@@ -1729,6 +1740,7 @@
ExportedPluginClasses: j.exportedPluginClasses,
ExportedPluginDisableTurbine: j.exportedDisableTurbine,
JacocoReportClassesFile: j.jacocoReportClassesFile,
+ StubsLinkType: j.stubsLinkType,
})
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
@@ -2372,11 +2384,26 @@
// classes until a module with jarjar_prefix is reached, and all as yet unrenamed classes will then
// be renamed from that module.
// TODO: Add another property to suppress the forwarding of
+type DependencyUse int
+
+const (
+ RenameUseInvalid DependencyUse = iota
+ RenameUseInclude
+ RenameUseExclude
+)
+
+type RenameUseElement struct {
+ DepName string
+ RenameUse DependencyUse
+ Why string // token for determining where in the logic the decision was made.
+}
+
type JarJarProviderData struct {
// Mapping of class names: original --> renamed. If the value is "", the class will be
// renamed by the next rdep that has the jarjar_prefix attribute (or this module if it has
// attribute). Rdeps of that module will inherit the renaming.
- Rename map[string]string
+ Rename map[string]string
+ RenameUse []RenameUseElement
}
func (this JarJarProviderData) GetDebugString() string {
@@ -2440,17 +2467,114 @@
func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProviderData) {
// Gather repackage information from deps
// If the dep jas a JarJarProvider, it is used. Otherwise, any BaseJarJarProvider is used.
+
+ module := ctx.Module()
+ moduleName := module.Name()
+
ctx.VisitDirectDepsIgnoreBlueprint(func(m android.Module) {
- if ctx.OtherModuleDependencyTag(m) == proguardRaiseTag {
- return
- }
- merge := func(theirs *JarJarProviderData) {
- for orig, renamed := range theirs.Rename {
- if result == nil {
- result = &JarJarProviderData{
- Rename: make(map[string]string),
+ tag := ctx.OtherModuleDependencyTag(m)
+ // This logic mirrors that in (*Module).collectDeps above. There are several places
+ // where we explicitly return RenameUseExclude, even though it is the default, to
+ // indicate that it has been verified to be the case.
+ //
+ // Note well: there are probably cases that are getting to the unconditional return
+ // and are therefore wrong.
+ shouldIncludeRenames := func() (DependencyUse, string) {
+ if moduleName == m.Name() {
+ return RenameUseInclude, "name" // If we have the same module name, include the renames.
+ }
+ if sc, ok := module.(android.SdkContext); ok {
+ if ctx.Device() {
+ sdkDep := decodeSdkDep(ctx, sc)
+ if !sdkDep.invalidVersion && sdkDep.useFiles {
+ return RenameUseExclude, "useFiles"
}
}
+ }
+ if IsJniDepTag(tag) || tag == certificateTag || tag == proguardRaiseTag {
+ return RenameUseExclude, "tags"
+ }
+ if _, ok := m.(SdkLibraryDependency); ok {
+ switch tag {
+ case sdkLibTag, libTag:
+ return RenameUseExclude, "sdklibdep" // matches collectDeps()
+ }
+ return RenameUseInvalid, "sdklibdep" // dep is not used in collectDeps()
+ } else if ji, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
+ switch ji.StubsLinkType {
+ case Stubs:
+ return RenameUseExclude, "info"
+ case Implementation:
+ return RenameUseInclude, "info"
+ default:
+ //fmt.Printf("LJ: %v -> %v StubsLinkType unknown\n", module, m)
+ // Fall through to the heuristic logic.
+ }
+ switch reflect.TypeOf(m).String() {
+ case "*java.GeneratedJavaLibraryModule":
+ // Probably a java_aconfig_library module.
+ // TODO: make this check better.
+ return RenameUseInclude, "reflect"
+ }
+ switch tag {
+ case bootClasspathTag:
+ return RenameUseExclude, "tagswitch"
+ case sdkLibTag, libTag, instrumentationForTag:
+ return RenameUseInclude, "tagswitch"
+ case java9LibTag:
+ return RenameUseExclude, "tagswitch"
+ case staticLibTag:
+ return RenameUseInclude, "tagswitch"
+ case pluginTag:
+ return RenameUseInclude, "tagswitch"
+ case errorpronePluginTag:
+ return RenameUseInclude, "tagswitch"
+ case exportedPluginTag:
+ return RenameUseInclude, "tagswitch"
+ case kotlinStdlibTag, kotlinAnnotationsTag:
+ return RenameUseExclude, "tagswitch"
+ case kotlinPluginTag:
+ return RenameUseInclude, "tagswitch"
+ default:
+ return RenameUseExclude, "tagswitch"
+ }
+ } else if _, ok := m.(android.SourceFileProducer); ok {
+ switch tag {
+ case sdkLibTag, libTag, staticLibTag:
+ return RenameUseInclude, "srcfile"
+ default:
+ return RenameUseExclude, "srcfile"
+ }
+ } else if _, ok := android.OtherModuleProvider(ctx, m, aconfig.CodegenInfoProvider); ok {
+ return RenameUseInclude, "aconfig_declarations_group"
+ } else {
+ switch tag {
+ case bootClasspathTag:
+ return RenameUseExclude, "else"
+ case systemModulesTag:
+ return RenameUseInclude, "else"
+ }
+ }
+ // If we got here, choose the safer option, which may lead to a build failure, rather
+ // than runtime failures on the device.
+ return RenameUseExclude, "end"
+ }
+
+ if result == nil {
+ result = &JarJarProviderData{
+ Rename: make(map[string]string),
+ RenameUse: make([]RenameUseElement, 0),
+ }
+ }
+ how, why := shouldIncludeRenames()
+ result.RenameUse = append(result.RenameUse, RenameUseElement{DepName: m.Name(), RenameUse: how, Why: why})
+ if how != RenameUseInclude {
+ // Nothing to merge.
+ return
+ }
+
+ merge := func(theirs *JarJarProviderData) {
+ for orig, renamed := range theirs.Rename {
if preexisting, exists := (*result).Rename[orig]; !exists || preexisting == "" {
result.Rename[orig] = renamed
} else if preexisting != "" && renamed != "" && preexisting != renamed {
diff --git a/java/builder.go b/java/builder.go
index 085e7a1..74a05f2 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -277,7 +277,7 @@
gatherReleasedFlaggedApisRule = pctx.AndroidStaticRule("gatherReleasedFlaggedApisRule",
blueprint.RuleParams{
- Command: `${aconfig} dump-cache --format='{fully_qualified_name}={state:bool}' ` +
+ Command: `${aconfig} dump-cache --dedup --format='{fully_qualified_name}={state:bool}' ` +
`--out ${out} ` +
`${flags_path} ` +
`${filter_args} `,
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index efd13b8..3f8735c 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -137,6 +137,7 @@
ResourceJars: d.resourceJars,
SrcJarArgs: d.srcJarArgs,
SrcJarDeps: d.srcJarDeps,
+ StubsLinkType: Implementation,
// TODO: Not sure if aconfig flags that have been moved between device and host variants
// make sense.
})
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 9db9b1b..1cfa642 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -102,6 +102,11 @@
dexpreoptProperties DexpreoptProperties
importDexpreoptProperties ImportDexpreoptProperties
+ // If true, the dexpreopt rules will not be generated
+ // Unlike Dex_preopt.Enabled which is user-facing,
+ // shouldDisableDexpreopt is a mutated propery.
+ shouldDisableDexpreopt bool
+
installPath android.InstallPath
uncompressedDex bool
isSDKLibrary bool
@@ -197,6 +202,10 @@
return true
}
+ if d.shouldDisableDexpreopt {
+ return true
+ }
+
// If the module is from a prebuilt APEX, it shouldn't be installable, but it can still be
// dexpreopted.
if !ctx.Module().(DexpreopterInterface).IsInstallable() && !forPrebuiltApex(ctx) {
@@ -528,3 +537,7 @@
func (d *dexpreopter) OutputProfilePathOnHost() android.Path {
return d.outputProfilePathOnHost
}
+
+func (d *dexpreopter) disableDexpreopt() {
+ d.shouldDisableDexpreopt = true
+}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index cfbf2b4..df40d01 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -21,6 +21,7 @@
"github.com/google/blueprint/proptools"
+ "android/soong/aconfig"
"android/soong/android"
"android/soong/java/config"
)
@@ -221,6 +222,8 @@
stubsSrcJar android.WritablePath
exportableStubsSrcJar android.WritablePath
+
+ runtimeStubsSrcJar android.WritablePath
}
func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
@@ -413,9 +416,12 @@
case aconfigDeclarationTag:
if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey); ok {
deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPath)
+ } else if dep, ok := android.OtherModuleProvider(ctx, module, aconfig.CodegenInfoProvider); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPaths...)
} else {
- ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
- "flags_packages property, but %s is not aconfig_declarations module type",
+ ctx.ModuleErrorf("Only aconfig_declarations and aconfig_declarations_group "+
+ "module type is allowed for flags_packages property, but %s is neither "+
+ "of these supported module types",
module.Name(),
)
}
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 56ae427..b112614 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -214,6 +214,7 @@
type annotationFlagsParams struct {
migratingNullability bool
validatingNullability bool
+ extractAnnotations bool
nullabilityWarningsFile android.WritablePath
annotationsZip android.WritablePath
}
@@ -229,16 +230,19 @@
stubConfig stubsCommandConfigParams
}
type stubsCommandConfigParams struct {
- stubsType StubsType
- javaVersion javaVersion
- deps deps
- checkApi bool
- generateStubs bool
- doApiLint bool
- doCheckReleased bool
- writeSdkValues bool
- migratingNullability bool
- validatingNullability bool
+ stubsType StubsType
+ javaVersion javaVersion
+ deps deps
+ checkApi bool
+ generateStubs bool
+ doApiLint bool
+ doCheckReleased bool
+ writeSdkValues bool
+ migratingNullability bool
+ validatingNullability bool
+ annotationsEnabled bool
+ apiLevelsAnnotationsEnabled bool
+ extractAnnotations bool
}
// droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be
@@ -508,30 +512,30 @@
}
func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) {
- if Bool(d.properties.Annotations_enabled) {
- cmd.Flag(config.MetalavaAnnotationsFlags)
+ cmd.Flag(config.MetalavaAnnotationsFlags)
- if params.migratingNullability {
- previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
- cmd.FlagWithInput("--migrate-nullness ", previousApi)
- }
-
- if s := String(d.properties.Validate_nullability_from_list); s != "" {
- cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
- }
-
- if params.validatingNullability {
- cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
- }
-
- cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip)
-
- if len(d.properties.Merge_annotations_dirs) != 0 {
- d.mergeAnnoDirFlags(ctx, cmd)
- }
-
- cmd.Flag(config.MetalavaAnnotationsWarningsFlags)
+ if params.migratingNullability {
+ previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
+ cmd.FlagWithInput("--migrate-nullness ", previousApi)
}
+
+ if s := String(d.properties.Validate_nullability_from_list); s != "" {
+ cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
+ }
+
+ if params.validatingNullability {
+ cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
+ }
+
+ if params.extractAnnotations {
+ cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip)
+ }
+
+ if len(d.properties.Merge_annotations_dirs) != 0 {
+ d.mergeAnnoDirFlags(ctx, cmd)
+ }
+
+ cmd.Flag(config.MetalavaAnnotationsWarningsFlags)
}
func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
@@ -556,9 +560,11 @@
})
}
-func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
+func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params stubsCommandParams) {
var apiVersions android.Path
- if proptools.Bool(d.properties.Api_levels_annotations_enabled) {
+ stubsType := params.stubConfig.stubsType
+ apiVersionsXml := params.apiVersionsXml
+ if params.stubConfig.apiLevelsAnnotationsEnabled {
d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
apiVersions = apiVersionsXml
} else {
@@ -569,7 +575,9 @@
} else if stubsType == Exportable {
apiVersions = s.exportableArtifacts.apiVersionsXml
} else {
- ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String())
+ // if the stubs type does not generate api-versions.xml file, default to using the
+ // everything artifacts
+ apiVersions = s.everythingArtifacts.apiVersionsXml
}
} else {
ctx.PropertyErrorf("api_levels_module",
@@ -744,8 +752,14 @@
filterArgs = "--filter='state:ENABLED+permission:READ_ONLY' --filter='permission:READ_WRITE'"
case Exportable:
- filterArgs = "--filter='state:ENABLED+permission:READ_ONLY'"
-
+ // When the build flag RELEASE_EXPORT_RUNTIME_APIS is set to true, apis marked with
+ // the flagged apis that have read_write permissions are exposed on top of the enabled
+ // and read_only apis. This is to support local override of flag values at runtime.
+ if ctx.Config().ReleaseExportRuntimeApis() {
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY' --filter='permission:READ_WRITE'"
+ } else {
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY'"
+ }
}
ctx.Build(pctx, android.BuildParams{
@@ -797,13 +811,16 @@
annotationParams := annotationFlagsParams{
migratingNullability: params.stubConfig.migratingNullability,
validatingNullability: params.stubConfig.validatingNullability,
+ extractAnnotations: params.stubConfig.extractAnnotations,
nullabilityWarningsFile: params.nullabilityWarningsFile,
annotationsZip: params.annotationsZip,
}
- d.annotationsFlags(ctx, cmd, annotationParams)
+ if params.stubConfig.annotationsEnabled {
+ d.annotationsFlags(ctx, cmd, annotationParams)
+ }
d.inclusionAnnotationsFlags(ctx, cmd)
- d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml)
+ d.apiLevelsAnnotationsFlags(ctx, cmd, params)
d.expandArgs(ctx, cmd)
@@ -833,13 +850,13 @@
d.everythingArtifacts.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip")
}
- if Bool(d.properties.Annotations_enabled) {
+ if params.annotationsEnabled {
if params.validatingNullability {
d.everythingArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt")
}
d.everythingArtifacts.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip")
}
- if Bool(d.properties.Api_levels_annotations_enabled) {
+ if params.apiLevelsAnnotationsEnabled {
d.everythingArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml")
}
@@ -1017,7 +1034,7 @@
optionalCmdParams.metadataDir = d.exportableArtifacts.metadataDir
}
- if Bool(d.properties.Annotations_enabled) {
+ if params.annotationsEnabled {
if params.validatingNullability {
d.exportableArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt")
optionalCmdParams.nullabilityWarningsFile = d.exportableArtifacts.nullabilityWarningsFile
@@ -1025,7 +1042,7 @@
d.exportableArtifacts.annotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip")
optionalCmdParams.annotationsZip = d.exportableArtifacts.annotationsZip
}
- if Bool(d.properties.Api_levels_annotations_enabled) {
+ if params.apiLevelsAnnotationsEnabled {
d.exportableArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml")
optionalCmdParams.apiVersionsXml = d.exportableArtifacts.apiVersionsXml
}
@@ -1043,6 +1060,38 @@
d.optionalStubCmd(ctx, optionalCmdParams)
}
+// Sandbox rule for generating runtime stubs
+func (d *Droidstubs) runtimeStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+
+ // We are only interested in generating the stubs srcjar,
+ // not other artifacts for the runtime stubs
+ params.checkApi = false
+ params.writeSdkValues = false
+ params.validatingNullability = false
+ params.extractAnnotations = false
+ params.apiLevelsAnnotationsEnabled = false
+
+ optionalCmdParams := stubsCommandParams{
+ stubConfig: params,
+ }
+
+ d.Javadoc.runtimeStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ optionalCmdParams.stubsSrcJar = d.Javadoc.runtimeStubsSrcJar
+
+ // If aconfig_declarations property is not defined, all flagged apis symbols are stripped
+ // as no aconfig flags are enabled. In such case, the runtime stubs are identical to the
+ // exportable stubs, thus no additional metalava invocation is needed.
+ if len(d.properties.Aconfig_declarations) == 0 {
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Command().
+ Text("cp").Flag("-f").
+ Input(d.exportableStubsSrcJar).Output(d.runtimeStubsSrcJar)
+ rule.Build(fmt.Sprintf("metalava_%s", params.stubsType.String()), "metalava merged")
+ } else {
+ d.optionalStubCmd(ctx, optionalCmdParams)
+ }
+}
+
func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) {
params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars")
@@ -1114,6 +1163,8 @@
annotationsEnabled := Bool(d.properties.Annotations_enabled)
+ extractAnnotations := annotationsEnabled
+
migratingNullability := annotationsEnabled && String(d.properties.Previous_api) != ""
validatingNullability := annotationsEnabled && (strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
String(d.properties.Validate_nullability_from_list) != "")
@@ -1121,27 +1172,40 @@
checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+ apiLevelsAnnotationsEnabled := proptools.Bool(d.properties.Api_levels_annotations_enabled)
+
stubCmdParams := stubsCommandConfigParams{
- javaVersion: javaVersion,
- deps: deps,
- checkApi: checkApi,
- generateStubs: generateStubs,
- doApiLint: doApiLint,
- doCheckReleased: doCheckReleased,
- writeSdkValues: writeSdkValues,
- migratingNullability: migratingNullability,
- validatingNullability: validatingNullability,
+ javaVersion: javaVersion,
+ deps: deps,
+ checkApi: checkApi,
+ generateStubs: generateStubs,
+ doApiLint: doApiLint,
+ doCheckReleased: doCheckReleased,
+ writeSdkValues: writeSdkValues,
+ migratingNullability: migratingNullability,
+ validatingNullability: validatingNullability,
+ annotationsEnabled: annotationsEnabled,
+ apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled,
+ extractAnnotations: extractAnnotations,
}
stubCmdParams.stubsType = Everything
// Create default (i.e. "everything" stubs) rule for metalava
d.everythingStubCmd(ctx, stubCmdParams)
- // The module generates "exportable" (and "runtime" eventually) stubs regardless of whether
+ // The module generates "exportable" stubs regardless of whether
// aconfig_declarations property is defined or not. If the property is not defined, the module simply
// strips all flagged apis to generate the "exportable" stubs
stubCmdParams.stubsType = Exportable
d.exportableStubCmd(ctx, stubCmdParams)
+ // "runtime" stubs do not generate any other artifacts than the stubs.
+ // Therefore, metalava does not have to run for "runtime" configuration
+ // when the module does not generate stubs.
+ if stubCmdParams.generateStubs {
+ stubCmdParams.stubsType = Runtime
+ d.runtimeStubCmd(ctx, stubCmdParams)
+ }
+
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
if len(d.Javadoc.properties.Out) > 0 {
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 52cd1c5..ca34e0e 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -22,6 +22,8 @@
"testing"
"android/soong/android"
+
+ "github.com/google/blueprint/proptools"
)
func TestDroidstubs(t *testing.T) {
@@ -394,21 +396,90 @@
"bar",
],
}
+ droidstubs {
+ name: "baz",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ }
`)
// Check that droidstubs depend on aconfig_declarations
android.AssertBoolEquals(t, "foo expected to depend on bar",
CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true)
- m := result.ModuleForTests("foo", "android_common")
+ fooModule := result.ModuleForTests("foo", "android_common")
android.AssertStringDoesContain(t, "foo generates revert annotations file",
- strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt")
+ strings.Join(fooModule.AllOutputs(), ""), "revert-annotations-exportable.txt")
// revert-annotations.txt passed to exportable stubs generation metalava command
- manifest := m.Output("metalava_exportable.sbox.textproto")
- cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
- android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
+ exportableManifest := fooModule.Output("metalava_exportable.sbox.textproto")
+ exportableCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, exportableManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", exportableCmdline, "revert-annotations-exportable.txt")
android.AssertStringDoesContain(t, "foo generates exportable stubs jar",
- strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+ strings.Join(fooModule.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+
+ // revert-annotations.txt passed to runtime stubs generation metalava command
+ runtimeManifest := fooModule.Output("metalava_runtime.sbox.textproto")
+ runtimeCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, runtimeManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", runtimeCmdline, "revert-annotations-runtime.txt")
+
+ android.AssertStringDoesContain(t, "foo generates runtime stubs jar",
+ strings.Join(fooModule.AllOutputs(), ""), "runtime/foo-stubs.srcjar")
+
+ // If aconfig_declarations property is not defined, the runtime stubs is a copy of the exportable stubs
+ bazModule := result.ModuleForTests("baz", "android_common")
+ bazRuntimeCmdline := bazModule.Rule("metalava_runtime").RuleParams.Command
+ android.AssertStringDoesContain(t, "copy command should include the input stub", bazRuntimeCmdline, "exportable/baz-stubs.srcjar")
+}
+
+func TestReleaseExportRuntimeApis(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ variables.ExportRuntimeApis = proptools.BoolPtr(true)
+ }),
+ android.FixtureMergeMockFs(map[string][]byte{
+ "a/A.java": nil,
+ "a/current.txt": nil,
+ "a/removed.txt": nil,
+ }),
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ droidstubs {
+ name: "foo",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ aconfig_declarations: [
+ "bar",
+ ],
+ }
+ `)
+
+ m := result.ModuleForTests("foo", "android_common")
+
+ rule := m.Output("released-flagged-apis-exportable.txt")
+ exposeWritableApisFilter := "--filter='state:ENABLED+permission:READ_ONLY' --filter='permission:READ_WRITE'"
+ android.AssertStringEquals(t, "Filter argument expected to contain READ_WRITE permissions", exposeWritableApisFilter, rule.Args["filter_args"])
}
diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go
index a61018d..1e30c5f 100644
--- a/java/hiddenapi_monolithic.go
+++ b/java/hiddenapi_monolithic.go
@@ -68,7 +68,7 @@
case *ClasspathFragmentElement:
fragment := e.Module()
if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
- monolithicInfo.append(&info)
+ monolithicInfo.append(ctx, fragment, &info)
} else {
ctx.ModuleErrorf("%s does not provide hidden API information", fragment)
}
@@ -79,14 +79,25 @@
}
// append appends all the files from the supplied info to the corresponding files in this struct.
-func (i *MonolithicHiddenAPIInfo) append(other *HiddenAPIInfo) {
+func (i *MonolithicHiddenAPIInfo) append(ctx android.ModuleContext, otherModule android.Module, other *HiddenAPIInfo) {
i.FlagsFilesByCategory.append(other.FlagFilesByCategory)
i.AnnotationFlagsPaths = append(i.AnnotationFlagsPaths, other.AnnotationFlagsPath)
i.MetadataPaths = append(i.MetadataPaths, other.MetadataPath)
i.IndexPaths = append(i.IndexPaths, other.IndexPath)
- i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
- i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
+ apexInfo, ok := android.OtherModuleProvider(ctx, otherModule, android.ApexInfoProvider)
+ if !ok {
+ ctx.ModuleErrorf("Could not determine min_version_version of %s\n", otherModule.Name())
+ return
+ }
+ if apexInfo.MinSdkVersion.LessThanOrEqualTo(android.ApiLevelR) {
+ // Restrict verify_overlaps to R and older modules.
+ // The runtime in S does not have the same restriction that
+ // requires the hiddenapi flags to be generated in a monolithic
+ // invocation.
+ i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
+ i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
+ }
}
var MonolithicHiddenAPIInfoProvider = blueprint.NewProvider[MonolithicHiddenAPIInfo]()
diff --git a/java/java.go b/java/java.go
index d7d271c..af4c3be 100644
--- a/java/java.go
+++ b/java/java.go
@@ -87,6 +87,14 @@
android.RegisterSdkMemberType(javaTestSdkMemberType)
}
+type StubsLinkType int
+
+const (
+ Unknown StubsLinkType = iota
+ Stubs
+ Implementation
+)
+
var (
// Supports adding java header libraries to module_exports and sdk.
javaHeaderLibsSdkMemberType = &librarySdkMemberType{
@@ -296,6 +304,11 @@
// JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be
// instrumented by jacoco.
JacocoReportClassesFile android.Path
+
+ // StubsLinkType provides information about whether the provided jars are stub jars or
+ // implementation jars. If the provider is set by java_sdk_library, the link type is "unknown"
+ // and selection between the stub jar vs implementation jar is deferred to SdkLibrary.sdkJars(...)
+ StubsLinkType StubsLinkType
}
var JavaInfoProvider = blueprint.NewProvider[JavaInfo]()
@@ -686,14 +699,195 @@
}
}
-func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+// list of java_library modules that set platform_apis: true
+// this property is a no-op for java_library
+// TODO (b/215379393): Remove this allowlist
+var (
+ aospPlatformApiAllowlist = map[string]bool{
+ "adservices-test-scenarios": true,
+ "aidl-cpp-java-test-interface-java": true,
+ "aidl-test-extras-java": true,
+ "aidl-test-interface-java": true,
+ "aidl-test-interface-permission-java": true,
+ "aidl_test_java_client_permission": true,
+ "aidl_test_java_client_sdk1": true,
+ "aidl_test_java_client_sdk29": true,
+ "aidl_test_java_client": true,
+ "aidl_test_java_service_permission": true,
+ "aidl_test_java_service_sdk1": true,
+ "aidl_test_java_service_sdk29": true,
+ "aidl_test_java_service": true,
+ "aidl_test_loggable_interface-java": true,
+ "aidl_test_nonvintf_parcelable-V1-java": true,
+ "aidl_test_nonvintf_parcelable-V2-java": true,
+ "aidl_test_unstable_parcelable-java": true,
+ "aidl_test_vintf_parcelable-V1-java": true,
+ "aidl_test_vintf_parcelable-V2-java": true,
+ "android.aidl.test.trunk-V1-java": true,
+ "android.aidl.test.trunk-V2-java": true,
+ "android.frameworks.location.altitude-V1-java": true,
+ "android.frameworks.location.altitude-V2-java": true,
+ "android.frameworks.stats-V1-java": true,
+ "android.frameworks.stats-V2-java": true,
+ "android.frameworks.stats-V3-java": true,
+ "android.hardware.authsecret-V1-java": true,
+ "android.hardware.authsecret-V2-java": true,
+ "android.hardware.biometrics.common-V1-java": true,
+ "android.hardware.biometrics.common-V2-java": true,
+ "android.hardware.biometrics.common-V3-java": true,
+ "android.hardware.biometrics.common-V4-java": true,
+ "android.hardware.biometrics.face-V1-java": true,
+ "android.hardware.biometrics.face-V2-java": true,
+ "android.hardware.biometrics.face-V3-java": true,
+ "android.hardware.biometrics.face-V4-java": true,
+ "android.hardware.biometrics.fingerprint-V1-java": true,
+ "android.hardware.biometrics.fingerprint-V2-java": true,
+ "android.hardware.biometrics.fingerprint-V3-java": true,
+ "android.hardware.biometrics.fingerprint-V4-java": true,
+ "android.hardware.bluetooth.lmp_event-V1-java": true,
+ "android.hardware.confirmationui-V1-java": true,
+ "android.hardware.confirmationui-V2-java": true,
+ "android.hardware.gatekeeper-V1-java": true,
+ "android.hardware.gatekeeper-V2-java": true,
+ "android.hardware.gnss-V1-java": true,
+ "android.hardware.gnss-V2-java": true,
+ "android.hardware.gnss-V3-java": true,
+ "android.hardware.gnss-V4-java": true,
+ "android.hardware.graphics.common-V1-java": true,
+ "android.hardware.graphics.common-V2-java": true,
+ "android.hardware.graphics.common-V3-java": true,
+ "android.hardware.graphics.common-V4-java": true,
+ "android.hardware.graphics.common-V5-java": true,
+ "android.hardware.identity-V1-java": true,
+ "android.hardware.identity-V2-java": true,
+ "android.hardware.identity-V3-java": true,
+ "android.hardware.identity-V4-java": true,
+ "android.hardware.identity-V5-java": true,
+ "android.hardware.identity-V6-java": true,
+ "android.hardware.keymaster-V1-java": true,
+ "android.hardware.keymaster-V2-java": true,
+ "android.hardware.keymaster-V3-java": true,
+ "android.hardware.keymaster-V4-java": true,
+ "android.hardware.keymaster-V5-java": true,
+ "android.hardware.oemlock-V1-java": true,
+ "android.hardware.oemlock-V2-java": true,
+ "android.hardware.power.stats-V1-java": true,
+ "android.hardware.power.stats-V2-java": true,
+ "android.hardware.power.stats-V3-java": true,
+ "android.hardware.power-V1-java": true,
+ "android.hardware.power-V2-java": true,
+ "android.hardware.power-V3-java": true,
+ "android.hardware.power-V4-java": true,
+ "android.hardware.power-V5-java": true,
+ "android.hardware.rebootescrow-V1-java": true,
+ "android.hardware.rebootescrow-V2-java": true,
+ "android.hardware.security.authgraph-V1-java": true,
+ "android.hardware.security.keymint-V1-java": true,
+ "android.hardware.security.keymint-V2-java": true,
+ "android.hardware.security.keymint-V3-java": true,
+ "android.hardware.security.keymint-V4-java": true,
+ "android.hardware.security.secureclock-V1-java": true,
+ "android.hardware.security.secureclock-V2-java": true,
+ "android.hardware.thermal-V1-java": true,
+ "android.hardware.thermal-V2-java": true,
+ "android.hardware.threadnetwork-V1-java": true,
+ "android.hardware.weaver-V1-java": true,
+ "android.hardware.weaver-V2-java": true,
+ "android.hardware.weaver-V3-java": true,
+ "android.security.attestationmanager-java": true,
+ "android.security.authorization-java": true,
+ "android.security.compat-java": true,
+ "android.security.legacykeystore-java": true,
+ "android.security.maintenance-java": true,
+ "android.security.metrics-java": true,
+ "android.system.keystore2-V1-java": true,
+ "android.system.keystore2-V2-java": true,
+ "android.system.keystore2-V3-java": true,
+ "android.system.keystore2-V4-java": true,
+ "binderReadParcelIface-java": true,
+ "binderRecordReplayTestIface-java": true,
+ "car-experimental-api-static-lib": true,
+ "collector-device-lib-platform": true,
+ "com.android.car.oem": true,
+ "com.google.hardware.pixel.display-V10-java": true,
+ "com.google.hardware.pixel.display-V1-java": true,
+ "com.google.hardware.pixel.display-V2-java": true,
+ "com.google.hardware.pixel.display-V3-java": true,
+ "com.google.hardware.pixel.display-V4-java": true,
+ "com.google.hardware.pixel.display-V5-java": true,
+ "com.google.hardware.pixel.display-V6-java": true,
+ "com.google.hardware.pixel.display-V7-java": true,
+ "com.google.hardware.pixel.display-V8-java": true,
+ "com.google.hardware.pixel.display-V9-java": true,
+ "conscrypt-support": true,
+ "cts-keystore-test-util": true,
+ "cts-keystore-user-auth-helper-library": true,
+ "ctsmediautil": true,
+ "CtsNetTestsNonUpdatableLib": true,
+ "DpmWrapper": true,
+ "flickerlib-apphelpers": true,
+ "flickerlib-helpers": true,
+ "flickerlib-parsers": true,
+ "flickerlib": true,
+ "hardware.google.bluetooth.ccc-V1-java": true,
+ "hardware.google.bluetooth.sar-V1-java": true,
+ "monet": true,
+ "pixel-power-ext-V1-java": true,
+ "pixel-power-ext-V2-java": true,
+ "pixel_stateresidency_provider_aidl_interface-java": true,
+ "pixel-thermal-ext-V1-java": true,
+ "protolog-lib": true,
+ "RkpRegistrationCheck": true,
+ "rotary-service-javastream-protos": true,
+ "service_based_camera_extensions": true,
+ "statsd-helper-test": true,
+ "statsd-helper": true,
+ "test-piece-2-V1-java": true,
+ "test-piece-2-V2-java": true,
+ "test-piece-3-V1-java": true,
+ "test-piece-3-V2-java": true,
+ "test-piece-3-V3-java": true,
+ "test-piece-4-V1-java": true,
+ "test-piece-4-V2-java": true,
+ "test-root-package-V1-java": true,
+ "test-root-package-V2-java": true,
+ "test-root-package-V3-java": true,
+ "test-root-package-V4-java": true,
+ "testServiceIface-java": true,
+ "wm-flicker-common-app-helpers": true,
+ "wm-flicker-common-assertions": true,
+ "wm-shell-flicker-utils": true,
+ "wycheproof-keystore": true,
+ }
+ // Union of aosp and internal allowlists
+ PlatformApiAllowlist = map[string]bool{}
+)
+
+func init() {
+ for k, v := range aospPlatformApiAllowlist {
+ PlatformApiAllowlist[k] = v
+ }
+}
+
+func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.provideHiddenAPIPropertyInfo(ctx)
j.sdkVersion = j.SdkVersion(ctx)
j.minSdkVersion = j.MinSdkVersion(ctx)
j.maxSdkVersion = j.MaxSdkVersion(ctx)
+ // SdkLibrary.GenerateAndroidBuildActions(ctx) sets the stubsLinkType to Unknown.
+ // If the stubsLinkType has already been set to Unknown, the stubsLinkType should
+ // not be overridden.
+ if j.stubsLinkType != Unknown {
+ if proptools.Bool(j.properties.Is_stubs_module) {
+ j.stubsLinkType = Stubs
+ } else {
+ j.stubsLinkType = Implementation
+ }
+ }
+
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
proguardSpecInfo := j.collectProguardSpecInfo(ctx)
@@ -719,6 +913,9 @@
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
j.classLoaderContexts = j.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ if j.usesLibrary.shouldDisableDexpreopt {
+ j.dexpreopter.disableDexpreopt()
+ }
}
j.compile(ctx, nil, nil, nil)
@@ -2018,6 +2215,7 @@
ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar),
ImplementationJars: android.PathsIfNonNil(al.stubsJar),
AidlIncludeDirs: android.Paths{},
+ StubsLinkType: Stubs,
// No aconfig libraries on api libraries
})
}
@@ -2102,6 +2300,9 @@
// The name is the undecorated name of the java_sdk_library as it appears in the blueprint file
// (without any prebuilt_ prefix)
Created_by_java_sdk_library_name *string `blueprint:"mutated"`
+
+ // Property signifying whether the module provides stubs jar or not.
+ Is_stubs_module *bool
}
type Import struct {
@@ -2132,6 +2333,8 @@
sdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
+
+ stubsLinkType StubsLinkType
}
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
@@ -2226,6 +2429,12 @@
if ctx.Windows() {
j.HideFromMake()
}
+
+ if proptools.Bool(j.properties.Is_stubs_module) {
+ j.stubsLinkType = Stubs
+ } else {
+ j.stubsLinkType = Implementation
+ }
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -2359,6 +2568,7 @@
ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile),
ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile),
AidlIncludeDirs: j.exportAidlIncludeDirs,
+ StubsLinkType: j.stubsLinkType,
// TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
})
}
diff --git a/java/ravenwood.go b/java/ravenwood.go
new file mode 100644
index 0000000..908619d
--- /dev/null
+++ b/java/ravenwood.go
@@ -0,0 +1,278 @@
+// Copyright 2023 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"
+ "android/soong/tradefed"
+
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
+)
+
+func init() {
+ RegisterRavenwoodBuildComponents(android.InitRegistrationContext)
+}
+
+func RegisterRavenwoodBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("android_ravenwood_test", ravenwoodTestFactory)
+ ctx.RegisterModuleType("android_ravenwood_libgroup", ravenwoodLibgroupFactory)
+}
+
+var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"}
+var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"}
+var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"}
+
+const ravenwoodUtilsName = "ravenwood-utils"
+const ravenwoodRuntimeName = "ravenwood-runtime"
+
+type ravenwoodLibgroupJniDepProviderInfo struct {
+ // All the jni_libs module names with transient dependencies.
+ names map[string]bool
+}
+
+var ravenwoodLibgroupJniDepProvider = blueprint.NewProvider[ravenwoodLibgroupJniDepProviderInfo]()
+
+func getLibPath(archType android.ArchType) string {
+ if archType.Multilib == "lib64" {
+ return "lib64"
+ }
+ return "lib"
+}
+
+type ravenwoodTestProperties struct {
+ Jni_libs []string
+}
+
+type ravenwoodTest struct {
+ Library
+
+ ravenwoodTestProperties ravenwoodTestProperties
+
+ testProperties testProperties
+ testConfig android.Path
+
+ forceOSType android.OsType
+ forceArchType android.ArchType
+}
+
+func ravenwoodTestFactory() android.Module {
+ module := &ravenwoodTest{}
+
+ module.addHostAndDeviceProperties()
+ module.AddProperties(&module.testProperties, &module.ravenwoodTestProperties)
+
+ module.Module.dexpreopter.isTest = true
+ module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+
+ module.testProperties.Test_suites = []string{
+ "general-tests",
+ "ravenwood-tests",
+ }
+ module.testProperties.Test_options.Unit_test = proptools.BoolPtr(false)
+
+ InitJavaModule(module, android.DeviceSupported)
+ android.InitDefaultableModule(module)
+
+ return module
+}
+
+func (r *ravenwoodTest) InstallInTestcases() bool { return true }
+func (r *ravenwoodTest) InstallForceOS() (*android.OsType, *android.ArchType) {
+ return &r.forceOSType, &r.forceArchType
+}
+func (r *ravenwoodTest) TestSuites() []string {
+ return r.testProperties.Test_suites
+}
+
+func (r *ravenwoodTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ r.Library.DepsMutator(ctx)
+
+ // Generically depend on the runtime so that it's installed together with us
+ ctx.AddVariationDependencies(nil, ravenwoodRuntimeTag, ravenwoodRuntimeName)
+
+ // Directly depend on any utils so that we link against them
+ utils := ctx.AddVariationDependencies(nil, ravenwoodUtilsTag, ravenwoodUtilsName)[0]
+ if utils != nil {
+ for _, lib := range utils.(*ravenwoodLibgroup).ravenwoodLibgroupProperties.Libs {
+ ctx.AddVariationDependencies(nil, libTag, lib)
+ }
+ }
+
+ // Add jni libs
+ for _, lib := range r.ravenwoodTestProperties.Jni_libs {
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
+ }
+}
+
+func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ r.forceOSType = ctx.Config().BuildOS
+ r.forceArchType = ctx.Config().BuildArch
+
+ r.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
+ TestConfigProp: r.testProperties.Test_config,
+ TestConfigTemplateProp: r.testProperties.Test_config_template,
+ TestSuites: r.testProperties.Test_suites,
+ AutoGenConfig: r.testProperties.Auto_gen_config,
+ DeviceTemplate: "${RavenwoodTestConfigTemplate}",
+ HostTemplate: "${RavenwoodTestConfigTemplate}",
+ })
+
+ r.Library.GenerateAndroidBuildActions(ctx)
+
+ // Start by depending on all files installed by dependencies
+ var installDeps android.InstallPaths
+
+ // All JNI libraries included in the runtime
+ var runtimeJniModuleNames map[string]bool
+
+ if utils := ctx.GetDirectDepsWithTag(ravenwoodUtilsTag)[0]; utils != nil {
+ for _, installFile := range utils.FilesToInstall() {
+ installDeps = append(installDeps, installFile)
+ }
+ jniDeps, ok := android.OtherModuleProvider(ctx, utils, ravenwoodLibgroupJniDepProvider)
+ if ok {
+ runtimeJniModuleNames = jniDeps.names
+ }
+ }
+
+ if runtime := ctx.GetDirectDepsWithTag(ravenwoodRuntimeTag)[0]; runtime != nil {
+ for _, installFile := range runtime.FilesToInstall() {
+ installDeps = append(installDeps, installFile)
+ }
+ jniDeps, ok := android.OtherModuleProvider(ctx, runtime, ravenwoodLibgroupJniDepProvider)
+ if ok {
+ runtimeJniModuleNames = jniDeps.names
+ }
+ }
+
+ // Also remember what JNI libs are in the runtime.
+
+ // Also depend on our config
+ installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
+ installConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig)
+ installDeps = append(installDeps, installConfig)
+
+ // Depend on the JNI libraries, but don't install the ones that the runtime already
+ // contains.
+ soInstallPath := installPath.Join(ctx, getLibPath(r.forceArchType))
+ for _, jniLib := range collectTransitiveJniDeps(ctx) {
+ if _, ok := runtimeJniModuleNames[jniLib.name]; ok {
+ continue // Runtime already includes it.
+ }
+ installJni := ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
+ installDeps = append(installDeps, installJni)
+ }
+
+ // Install our JAR with all dependencies
+ ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...)
+}
+
+func (r *ravenwoodTest) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := r.Library.AndroidMkEntries()
+ entries := &entriesList[0]
+ entries.ExtraEntries = append(entries.ExtraEntries,
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
+ entries.AddStrings("LOCAL_COMPATIBILITY_SUITE",
+ "general-tests", "ravenwood-tests")
+ if r.testConfig != nil {
+ entries.SetPath("LOCAL_FULL_TEST_CONFIG", r.testConfig)
+ }
+ })
+ return entriesList
+}
+
+type ravenwoodLibgroupProperties struct {
+ Libs []string
+
+ Jni_libs []string
+}
+
+type ravenwoodLibgroup struct {
+ android.ModuleBase
+
+ ravenwoodLibgroupProperties ravenwoodLibgroupProperties
+
+ forceOSType android.OsType
+ forceArchType android.ArchType
+}
+
+func ravenwoodLibgroupFactory() android.Module {
+ module := &ravenwoodLibgroup{}
+ module.AddProperties(&module.ravenwoodLibgroupProperties)
+
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ return module
+}
+
+func (r *ravenwoodLibgroup) InstallInTestcases() bool { return true }
+func (r *ravenwoodLibgroup) InstallForceOS() (*android.OsType, *android.ArchType) {
+ return &r.forceOSType, &r.forceArchType
+}
+func (r *ravenwoodLibgroup) TestSuites() []string {
+ return []string{
+ "general-tests",
+ "ravenwood-tests",
+ }
+}
+
+func (r *ravenwoodLibgroup) DepsMutator(ctx android.BottomUpMutatorContext) {
+ // Always depends on our underlying libs
+ for _, lib := range r.ravenwoodLibgroupProperties.Libs {
+ ctx.AddVariationDependencies(nil, ravenwoodLibContentTag, lib)
+ }
+ for _, lib := range r.ravenwoodLibgroupProperties.Jni_libs {
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
+ }
+}
+
+func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ r.forceOSType = ctx.Config().BuildOS
+ r.forceArchType = ctx.Config().BuildArch
+
+ // Collect the JNI dependencies, including the transitive deps.
+ jniDepNames := make(map[string]bool)
+ jniLibs := collectTransitiveJniDeps(ctx)
+
+ for _, jni := range jniLibs {
+ jniDepNames[jni.name] = true
+ }
+ android.SetProvider(ctx, ravenwoodLibgroupJniDepProvider, ravenwoodLibgroupJniDepProviderInfo{
+ names: jniDepNames,
+ })
+
+ // Install our runtime into expected location for packaging
+ installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
+ for _, lib := range r.ravenwoodLibgroupProperties.Libs {
+ libModule := ctx.GetDirectDepWithTag(lib, ravenwoodLibContentTag)
+ libJar := android.OutputFileForModule(ctx, libModule, "")
+ ctx.InstallFile(installPath, lib+".jar", libJar)
+ }
+ soInstallPath := android.PathForModuleInstall(ctx, r.BaseModuleName()).Join(ctx, getLibPath(r.forceArchType))
+
+ for _, jniLib := range jniLibs {
+ ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
+ }
+
+ // Normal build should perform install steps
+ ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install"))
+}
+
+// collectTransitiveJniDeps returns all JNI dependencies, including transitive
+// ones, including NDK / stub libs. (Because Ravenwood has no "preinstalled" libraries)
+func collectTransitiveJniDeps(ctx android.ModuleContext) []jniLib {
+ libs, _ := collectJniDeps(ctx, true, false, nil)
+ return libs
+}
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
new file mode 100644
index 0000000..5961264
--- /dev/null
+++ b/java/ravenwood_test.go
@@ -0,0 +1,186 @@
+// Copyright 2022 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 prepareRavenwoodRuntime = android.GroupFixturePreparers(
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ RegisterRavenwoodBuildComponents(ctx)
+ }),
+ android.FixtureAddTextFile("ravenwood/Android.bp", `
+ cc_library_shared {
+ name: "ravenwood-runtime-jni1",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ }
+ cc_library_shared {
+ name: "ravenwood-runtime-jni2",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ stem: "libred",
+ shared_libs: [
+ "ravenwood-runtime-jni3",
+ ],
+ }
+ cc_library_shared {
+ name: "ravenwood-runtime-jni3",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ }
+ java_library_static {
+ name: "framework-minus-apex.ravenwood",
+ srcs: ["Framework.java"],
+ }
+ java_library_static {
+ name: "framework-services.ravenwood",
+ srcs: ["Services.java"],
+ }
+ java_library_static {
+ name: "framework-rules.ravenwood",
+ srcs: ["Rules.java"],
+ }
+ android_ravenwood_libgroup {
+ name: "ravenwood-runtime",
+ libs: [
+ "framework-minus-apex.ravenwood",
+ "framework-services.ravenwood",
+ ],
+ jni_libs: [
+ "ravenwood-runtime-jni1",
+ "ravenwood-runtime-jni2",
+ ],
+ }
+ android_ravenwood_libgroup {
+ name: "ravenwood-utils",
+ libs: [
+ "framework-rules.ravenwood",
+ ],
+ }
+ `),
+)
+
+var installPathPrefix = "out/soong/host/linux-x86/testcases"
+
+func TestRavenwoodRuntime(t *testing.T) {
+ if runtime.GOOS != "linux" {
+ t.Skip("requires linux")
+ }
+
+ ctx := android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithJava,
+ prepareRavenwoodRuntime,
+ ).RunTest(t)
+
+ // Verify that our runtime depends on underlying libs
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-runtime", "android_common", "framework-minus-apex.ravenwood")
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-runtime", "android_common", "framework-services.ravenwood")
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-runtime", "android_common", "ravenwood-runtime-jni")
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-utils", "android_common", "framework-rules.ravenwood")
+
+ // Verify that we've emitted artifacts in expected location
+ runtime := ctx.ModuleForTests("ravenwood-runtime", "android_common")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-minus-apex.ravenwood.jar")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-services.ravenwood.jar")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/libred.so")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
+ utils := ctx.ModuleForTests("ravenwood-utils", "android_common")
+ utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar")
+}
+
+func TestRavenwoodTest(t *testing.T) {
+ if runtime.GOOS != "linux" {
+ t.Skip("requires linux")
+ }
+
+ ctx := android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithJava,
+ prepareRavenwoodRuntime,
+ ).RunTestWithBp(t, `
+ cc_library_shared {
+ name: "jni-lib1",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ }
+ cc_library_shared {
+ name: "jni-lib2",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ stem: "libblue",
+ shared_libs: [
+ "jni-lib3",
+ ],
+ }
+ cc_library_shared {
+ name: "jni-lib3",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ stem: "libpink",
+ }
+ android_ravenwood_test {
+ name: "ravenwood-test",
+ srcs: ["Test.java"],
+ jni_libs: [
+ "jni-lib1",
+ "jni-lib2",
+ "ravenwood-runtime-jni2",
+ ],
+ sdk_version: "test_current",
+ }
+ `)
+
+ // Verify that our test depends on underlying libs
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-test", "android_common", "ravenwood-buildtime")
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-test", "android_common", "ravenwood-utils")
+ CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-test", "android_common", "jni-lib")
+
+ module := ctx.ModuleForTests("ravenwood-test", "android_common")
+ classpath := module.Rule("javac").Args["classpath"]
+
+ // Verify that we're linking against test_current
+ android.AssertStringDoesContain(t, "classpath", classpath, "android_test_stubs_current.jar")
+ // Verify that we're linking against utils
+ android.AssertStringDoesContain(t, "classpath", classpath, "framework-rules.ravenwood.jar")
+ // Verify that we're *NOT* linking against runtime
+ android.AssertStringDoesNotContain(t, "classpath", classpath, "framework-minus-apex.ravenwood.jar")
+ android.AssertStringDoesNotContain(t, "classpath", classpath, "framework-services.ravenwood.jar")
+
+ // Verify that we've emitted test artifacts in expected location
+ outputJar := module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.jar")
+ module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.config")
+ module.Output(installPathPrefix + "/ravenwood-test/lib64/jni-lib1.so")
+ module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so")
+ module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so")
+
+ // ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted.
+ for _, o := range module.AllOutputs() {
+ android.AssertStringDoesNotContain(t, "runtime libs shouldn't be included", o, "/ravenwood-test/lib64/ravenwood-runtime")
+ }
+
+ // Verify that we're going to install underlying libs
+ orderOnly := outputJar.OrderOnly.Strings()
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-minus-apex.ravenwood.jar")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-services.ravenwood.jar")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/libred.so")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar")
+}
diff --git a/java/sdk.go b/java/sdk.go
index 81be991..3591ccd 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -33,13 +33,26 @@
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
-func UseApiFingerprint(ctx android.BaseModuleContext) bool {
- if ctx.Config().UnbundledBuild() &&
- !ctx.Config().AlwaysUsePrebuiltSdks() &&
- ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
- return true
+func UseApiFingerprint(ctx android.BaseModuleContext) (useApiFingerprint bool, fingerprintSdkVersion string, fingerprintDeps android.OutputPath) {
+ if ctx.Config().UnbundledBuild() && !ctx.Config().AlwaysUsePrebuiltSdks() {
+ apiFingerprintTrue := ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT")
+ dessertShaIsSet := ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA") != ""
+
+ // Error when both UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT and UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA are set
+ if apiFingerprintTrue && dessertShaIsSet {
+ ctx.ModuleErrorf("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true cannot be set alongside with UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
+ }
+
+ useApiFingerprint = apiFingerprintTrue || dessertShaIsSet
+ if apiFingerprintTrue {
+ fingerprintSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
+ fingerprintDeps = ApiFingerprintPath(ctx)
+ }
+ if dessertShaIsSet {
+ fingerprintSdkVersion = ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
+ }
}
- return false
+ return useApiFingerprint, fingerprintSdkVersion, fingerprintDeps
}
func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpec) javaVersion {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index fbde042..d532aaa 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1572,6 +1572,8 @@
// Only build an implementation library if required.
if module.requiresRuntimeImplementationLibrary() {
+ // stubsLinkType must be set before calling Library.GenerateAndroidBuildActions
+ module.Library.stubsLinkType = Unknown
module.Library.GenerateAndroidBuildActions(ctx)
}
@@ -1797,6 +1799,7 @@
Dir *string
Tag *string
}
+ Is_stubs_module *bool
}
func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
@@ -1821,6 +1824,7 @@
// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential
// interop with older developer tools that don't support 1.9.
props.Java_version = proptools.StringPtr("1.8")
+ props.Is_stubs_module = proptools.BoolPtr(true)
return props
}
@@ -1993,8 +1997,10 @@
tag string
pattern string
}{
- {tag: ".api.txt", pattern: "%s.txt"},
- {tag: ".removed-api.txt", pattern: "%s-removed.txt"},
+ // "exportable" api files are copied to the dist directory instead of the
+ // "everything" api files.
+ {tag: ".exportable.api.txt", pattern: "%s.txt"},
+ {tag: ".exportable.removed-api.txt", pattern: "%s-removed.txt"},
} {
props.Dists = append(props.Dists, android.Dist{
Targets: []string{"sdk", "win_sdk"},
@@ -2709,6 +2715,7 @@
Libs []string
Jars []string
Compile_dex *bool
+ Is_stubs_module *bool
android.UserSuppliedPrebuiltProperties
}{}
@@ -2730,6 +2737,7 @@
compileDex = proptools.BoolPtr(true)
}
props.Compile_dex = compileDex
+ props.Is_stubs_module = proptools.BoolPtr(true)
mctx.CreateModule(ImportFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
diff --git a/python/scripts/precompile_python.py b/python/scripts/precompile_python.py
index 80e7c76..aa1a5df 100644
--- a/python/scripts/precompile_python.py
+++ b/python/scripts/precompile_python.py
@@ -24,7 +24,12 @@
# This file needs to support both python 2 and 3.
-def process_one_file(info, infile, outzip):
+def process_one_file(name, infile, outzip):
+ # Create a ZipInfo instance with a fixed date to ensure a deterministic output.
+ # Date was chosen to be the same as
+ # https://cs.android.com/android/platform/superproject/main/+/main:build/soong/jar/jar.go;l=36;drc=2863e4535eb65e15f955dc8ed48fa99b1d2a1db5
+ info = zipfile.ZipInfo(filename=name, date_time=(2008, 1, 1, 0, 0, 0))
+
if not info.filename.endswith('.py'):
outzip.writestr(info, infile.read())
return
@@ -37,17 +42,15 @@
with tempfile.NamedTemporaryFile(prefix="Soong_precompile_", delete=False) as tmp:
out_name = tmp.name
try:
- # Ensure deterministic pyc by using the hash rather than timestamp.
- # This is required to improve caching in accelerated builds.
- # Only works on Python 3.7+ (see https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode)
- # which should cover most updated branches and developer machines.
+ # Ensure a deterministic .pyc output by using the hash rather than the timestamp.
+ # Only works on Python 3.7+
+ # See https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode
if sys.version_info >= (3, 7):
py_compile.compile(in_name, out_name, info.filename, doraise=True, invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH)
else:
py_compile.compile(in_name, out_name, info.filename, doraise=True)
with open(out_name, 'rb') as f:
info.filename = info.filename + 'c'
- # Use ZipInfo rather than str to reuse timestamps for deterministic zip files.
outzip.writestr(info, f.read())
finally:
os.remove(in_name)
@@ -62,9 +65,9 @@
with open(args.dst_zip, 'wb') as outf, open(args.src_zip, 'rb') as inf:
with zipfile.ZipFile(outf, mode='w') as outzip, zipfile.ZipFile(inf, mode='r') as inzip:
- for info in inzip.infolist():
- with inzip.open(info.filename, mode='r') as inzipf:
- process_one_file(info, inzipf, outzip)
+ for name in inzip.namelist():
+ with inzip.open(name, mode='r') as inzipf:
+ process_one_file(name, inzipf, outzip)
if __name__ == "__main__":
diff --git a/rust/afdo.go b/rust/afdo.go
index 323ee36..6116c5e 100644
--- a/rust/afdo.go
+++ b/rust/afdo.go
@@ -44,14 +44,14 @@
if err != nil {
ctx.ModuleErrorf("%s", err.Error())
}
- if fdoProfileName != nil {
+ if fdoProfileName != "" {
actx.AddFarVariationDependencies(
[]blueprint.Variation{
{Mutator: "arch", Variation: actx.Target().ArchVariation()},
{Mutator: "os", Variation: "android"},
},
cc.FdoProfileTag,
- []string{*fdoProfileName}...,
+ []string{fdoProfileName}...,
)
}
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 85cc220..454dd87 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -263,10 +263,9 @@
// clang: error: '-x c' after last input file has no effect [-Werror,-Wunused-command-line-argument]
cflags = append(cflags, "-Wno-unused-command-line-argument")
- // LLVM_NEXT may contain flags that bindgen doesn't recognise. Turn off unknown flags warning.
- if ctx.Config().IsEnvTrue("LLVM_NEXT") {
- cflags = append(cflags, "-Wno-unknown-warning-option")
- }
+ // The Clang version used by CXX can be newer than the one used by Bindgen, and uses warning related flags that
+ // it cannot recognize. Turn off unknown warning flags warning.
+ cflags = append(cflags, "-Wno-unknown-warning-option")
outputFile := android.PathForModuleOut(ctx, b.BaseSourceProvider.getStem(ctx)+".rs")
diff --git a/rust/config/global.go b/rust/config/global.go
index aebbb1b..418eca4 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -25,7 +25,7 @@
pctx = android.NewPackageContext("android/soong/rust/config")
ExportedVars = android.NewExportedVariables(pctx)
- RustDefaultVersion = "1.74.1"
+ RustDefaultVersion = "1.75.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/rust/config/lints.go b/rust/config/lints.go
index 9322981..7770af0 100644
--- a/rust/config/lints.go
+++ b/rust/config/lints.go
@@ -44,6 +44,7 @@
// Default Rust lints that applies to Google-authored modules.
defaultRustcLints = []string{
"-A deprecated",
+ "-A unknown_lints",
"-D missing-docs",
"-D warnings",
"-D unsafe_op_in_unsafe_fn",
@@ -53,6 +54,7 @@
// deny.
defaultClippyLints = []string{
"-A clippy::type-complexity",
+ "-A clippy::unnecessary_fallible_conversions",
"-A clippy::unnecessary-wraps",
"-A clippy::unusual-byte-groupings",
"-A clippy::upper-case-acronyms",
diff --git a/rust/sanitize.go b/rust/sanitize.go
index 9dda43f..3c08cd8 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -56,6 +56,8 @@
}
var fuzzerFlags = []string{
+ "-Z external-clangrt=true",
+
"-C passes='sancov-module'",
"--cfg fuzzing",
@@ -73,11 +75,13 @@
}
var asanFlags = []string{
+ "-Z external-clangrt=true",
"-Z sanitizer=address",
}
// See cc/sanitize.go's hwasanGlobalOptions for global hwasan options.
var hwasanFlags = []string{
+ "-Z external-clangrt=true",
"-Z sanitizer=hwaddress",
"-C target-feature=+tagged-globals",
@@ -203,11 +207,6 @@
s.Address = nil
}
- // TODO: Remove once b/304507701 is resolved
- if Bool(s.Address) && ctx.Host() {
- s.Address = nil
- }
-
// Memtag_heap is only implemented on AArch64.
if ctx.Arch().ArchType != android.Arm64 || !ctx.Os().Bionic() {
s.Memtag_heap = nil
diff --git a/rust/testing.go b/rust/testing.go
index 0b34c97..d9cacdc 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -75,6 +75,7 @@
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
min_sdk_version: "29",
vendor_available: true,
+ host_supported: true,
recovery_available: true,
llndk: {
symbol_file: "liblog.map.txt",
diff --git a/sysprop/Android.bp b/sysprop/Android.bp
index 1d5eb31..a00a5e4 100644
--- a/sysprop/Android.bp
+++ b/sysprop/Android.bp
@@ -11,6 +11,7 @@
"soong-android",
"soong-cc",
"soong-java",
+ "soong-rust",
],
srcs: [
"sysprop_library.go",
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 766f3e7..2258232 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -21,6 +21,7 @@
"io"
"os"
"path"
+ "strings"
"sync"
"github.com/google/blueprint"
@@ -29,6 +30,7 @@
"android/soong/android"
"android/soong/cc"
"android/soong/java"
+ "android/soong/rust"
)
type dependencyTag struct {
@@ -51,7 +53,16 @@
genSrcjars android.Paths
}
+type syspropRustGenRule struct {
+ android.ModuleBase
+
+ properties syspropGenProperties
+
+ genSrcs android.Paths
+}
+
var _ android.OutputFileProducer = (*syspropJavaGenRule)(nil)
+var _ android.OutputFileProducer = (*syspropRustGenRule)(nil)
var (
syspropJava = pctx.AndroidStaticRule("syspropJava",
@@ -64,11 +75,20 @@
"$soongZipCmd",
},
}, "scope")
+ syspropRust = pctx.AndroidStaticRule("syspropRust",
+ blueprint.RuleParams{
+ Command: `rm -rf $out_dir && mkdir -p $out_dir && ` +
+ `$syspropRustCmd --scope $scope --rust-output-dir $out_dir $in`,
+ CommandDeps: []string{
+ "$syspropRustCmd",
+ },
+ }, "scope", "out_dir")
)
func init() {
pctx.HostBinToolVariable("soongZipCmd", "soong_zip")
pctx.HostBinToolVariable("syspropJavaCmd", "sysprop_java")
+ pctx.HostBinToolVariable("syspropRustCmd", "sysprop_rust")
}
// syspropJavaGenRule module generates srcjar containing generated java APIs.
@@ -122,6 +142,56 @@
return g
}
+// syspropRustGenRule module generates rust source files containing generated rust APIs.
+// It also depends on check api rule, so api check has to pass to use sysprop_library.
+func (g *syspropRustGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ var checkApiFileTimeStamp android.WritablePath
+
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ if m, ok := dep.(*syspropLibrary); ok {
+ checkApiFileTimeStamp = m.checkApiFileTimeStamp
+ }
+ })
+
+ for _, syspropFile := range android.PathsForModuleSrc(ctx, g.properties.Srcs) {
+ syspropDir := strings.TrimSuffix(syspropFile.String(), syspropFile.Ext())
+ outputDir := android.PathForModuleGen(ctx, syspropDir, "src")
+ libPath := android.PathForModuleGen(ctx, syspropDir, "src", "lib.rs")
+ parsersPath := android.PathForModuleGen(ctx, syspropDir, "src", "gen_parsers_and_formatters.rs")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: syspropRust,
+ Description: "sysprop_rust " + syspropFile.Rel(),
+ Outputs: android.WritablePaths{libPath, parsersPath},
+ Input: syspropFile,
+ Implicit: checkApiFileTimeStamp,
+ Args: map[string]string{
+ "scope": g.properties.Scope,
+ "out_dir": outputDir.String(),
+ },
+ })
+
+ g.genSrcs = append(g.genSrcs, libPath, parsersPath)
+ }
+}
+
+func (g *syspropRustGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
+ // Add a dependency from the stubs to sysprop library so that the generator rule can depend on
+ // the check API rule of the sysprop library.
+ ctx.AddFarVariationDependencies(nil, nil, proptools.String(g.properties.Check_api))
+}
+
+func (g *syspropRustGenRule) OutputFiles(_ string) (android.Paths, error) {
+ return g.genSrcs, nil
+}
+
+func syspropRustGenFactory() android.Module {
+ g := &syspropRustGenRule{}
+ g.AddProperties(&g.properties)
+ android.InitAndroidModule(g)
+ return g
+}
+
type syspropLibrary struct {
android.ModuleBase
android.ApexModuleBase
@@ -180,6 +250,12 @@
// Forwarded to java_library.min_sdk_version
Min_sdk_version *string
}
+
+ Rust struct {
+ // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
+ // Forwarded to rust_library.min_sdk_version
+ Min_sdk_version *string
+ }
}
var (
@@ -233,6 +309,21 @@
return m.BaseModuleName() + "_java_gen_public"
}
+func (m *syspropLibrary) rustGenModuleName() string {
+ return m.rustCrateName() + "_rust_gen"
+}
+
+func (m *syspropLibrary) rustGenStubName() string {
+ return "lib" + m.rustCrateName() + "_rust"
+}
+
+func (m *syspropLibrary) rustCrateName() string {
+ moduleName := strings.ToLower(m.BaseModuleName())
+ moduleName = strings.ReplaceAll(moduleName, "-", "_")
+ moduleName = strings.ReplaceAll(moduleName, ".", "_")
+ return moduleName
+}
+
func (m *syspropLibrary) BaseModuleName() string {
return m.ModuleBase.Name()
}
@@ -436,6 +527,18 @@
Min_sdk_version *string
}
+type rustLibraryProperties struct {
+ Name *string
+ Srcs []string
+ Installable *bool
+ Crate_name string
+ Rustlibs []string
+ Vendor_available *bool
+ Product_available *bool
+ Apex_available []string
+ Min_sdk_version *string
+}
+
func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
if len(m.properties.Srcs) == 0 {
ctx.PropertyErrorf("srcs", "sysprop_library must specify srcs")
@@ -564,6 +667,28 @@
})
}
+ // Generate a Rust implementation library.
+ ctx.CreateModule(syspropRustGenFactory, &syspropGenProperties{
+ Srcs: m.properties.Srcs,
+ Scope: scope,
+ Name: proptools.StringPtr(m.rustGenModuleName()),
+ Check_api: proptools.StringPtr(ctx.ModuleName()),
+ })
+ rustProps := rustLibraryProperties{
+ Name: proptools.StringPtr(m.rustGenStubName()),
+ Srcs: []string{":" + m.rustGenModuleName()},
+ Installable: proptools.BoolPtr(false),
+ Crate_name: m.rustCrateName(),
+ Rustlibs: []string{
+ "librustutils",
+ },
+ Vendor_available: m.properties.Vendor_available,
+ Product_available: m.properties.Product_available,
+ Apex_available: m.ApexProperties.Apex_available,
+ Min_sdk_version: proptools.StringPtr("29"),
+ }
+ ctx.CreateModule(rust.RustLibraryFactory, &rustProps)
+
// syspropLibraries will be used by property_contexts to check types.
// Record absolute paths of sysprop_library to prevent soong_namespace problem.
if m.ExportedToMake() {
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index e5b3dea..9dd696f 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -22,6 +22,7 @@
"android/soong/android"
"android/soong/cc"
"android/soong/java"
+ "android/soong/rust"
"github.com/google/blueprint/proptools"
)
@@ -46,18 +47,6 @@
recovery_available: true,
}
- cc_library {
- name: "liblog",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- recovery_available: true,
- host_supported: true,
- llndk: {
- symbol_file: "liblog.map.txt",
- }
- }
-
java_library {
name: "sysprop-library-stub-platform",
sdk_version: "core_current",
@@ -74,6 +63,15 @@
product_specific: true,
sdk_version: "core_current",
}
+
+ rust_library {
+ name: "librustutils",
+ crate_name: "rustutils",
+ srcs: ["librustutils/lib.rs"],
+ product_available: true,
+ vendor_available: true,
+ min_sdk_version: "29",
+ }
`
mockFS := android.MockFS{
@@ -115,11 +113,14 @@
"android/sysprop/PlatformProperties.sysprop": nil,
"com/android/VendorProperties.sysprop": nil,
"com/android2/OdmProperties.sysprop": nil,
+
+ "librustutils/lib.rs": nil,
}
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
java.PrepareForTestWithJavaDefaultModules,
+ rust.PrepareForTestWithRustDefaultModules,
PrepareForTestWithSyspropBuildComponents,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.DeviceSystemSdkVersions = []string{"28"}
@@ -356,6 +357,10 @@
javaModule := result.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library)
propFromJava := javaModule.ApexProperties.Apex_available
android.AssertDeepEquals(t, "apex_available forwarding to java module", expected, propFromJava)
+
+ rustModule := result.ModuleForTests("libsysprop_platform_rust", "android_arm64_armv8-a_rlib_rlib-std").Module().(*rust.Module)
+ propFromRust := rustModule.ApexProperties.Apex_available
+ android.AssertDeepEquals(t, "apex_available forwarding to rust module", expected, propFromRust)
}
func TestMinSdkVersionIsForwarded(t *testing.T) {
@@ -371,6 +376,9 @@
java: {
min_sdk_version: "30",
},
+ rust: {
+ min_sdk_version: "29",
+ }
}
`)
@@ -381,4 +389,8 @@
javaModule := result.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library)
propFromJava := javaModule.MinSdkVersionString()
android.AssertStringEquals(t, "min_sdk_version forwarding to java module", "30", propFromJava)
+
+ rustModule := result.ModuleForTests("libsysprop_platform_rust", "android_arm64_armv8-a_rlib_rlib-std").Module().(*rust.Module)
+ propFromRust := proptools.String(rustModule.Properties.Min_sdk_version)
+ android.AssertStringEquals(t, "min_sdk_version forwarding to rust module", "29", propFromRust)
}
diff --git a/tradefed/config.go b/tradefed/config.go
index 326a006..b015034 100644
--- a/tradefed/config.go
+++ b/tradefed/config.go
@@ -33,6 +33,7 @@
pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml")
pctx.SourcePathVariable("PythonBinaryHostMoblyTestConfigTemplate", "build/make/core/python_binary_host_mobly_test_config_template.xml")
pctx.SourcePathVariable("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml")
+ pctx.SourcePathVariable("RavenwoodTestConfigTemplate", "build/make/core/ravenwood_test_config_template.xml")
pctx.SourcePathVariable("RustDeviceTestConfigTemplate", "build/make/core/rust_device_test_config_template.xml")
pctx.SourcePathVariable("RustHostTestConfigTemplate", "build/make/core/rust_host_test_config_template.xml")
pctx.SourcePathVariable("RustDeviceBenchmarkConfigTemplate", "build/make/core/rust_device_benchmark_config_template.xml")
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
index 9aeaf9d..e7896ab 100644
--- a/ui/build/androidmk_denylist.go
+++ b/ui/build/androidmk_denylist.go
@@ -30,7 +30,8 @@
"libcore/",
"libnativehelper/",
"pdk/",
- "toolchain/",
+ // Add back toolchain/ once defensive Android.mk files are removed
+ //"toolchain/",
}
func blockAndroidMks(ctx Context, androidMks []string) {
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index d364542..e17bd54 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -237,7 +237,6 @@
"BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST",
// Not used, but useful to be in the soong.log
- "BOARD_VNDK_VERSION",
"TARGET_BUILD_TYPE",
"HOST_ARCH",
"HOST_2ND_ARCH",