Merge "Improve soong stuck ninja detection output" into main
diff --git a/OWNERS b/OWNERS
index 58edc89..01025fb 100644
--- a/OWNERS
+++ b/OWNERS
@@ -12,4 +12,6 @@
mrziwang@google.com
spandandas@google.com
weiwli@google.com
-yudiliu@google.com
\ No newline at end of file
+yudiliu@google.com
+
+per-file build/soong/ui/build/androidmk_denylist.go = joeo@google.com, weiwli@google.com
\ No newline at end of file
diff --git a/README.md b/README.md
index 5e9e04a..f471c47 100644
--- a/README.md
+++ b/README.md
@@ -603,7 +603,7 @@
* [Build Performance](docs/perf.md)
* [Generating CLion Projects](docs/clion.md)
* [Generating YouCompleteMe/VSCode compile\_commands.json file](docs/compdb.md)
-* Make-specific documentation: [build/make/README.md](https://android.googlesource.com/platform/build/+/master/README.md)
+* Make-specific documentation: [build/make/README.md](https://android.googlesource.com/platform/build/+/main/README.md)
## Developing for Soong
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index 3c79f19..402cf16 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -25,6 +25,7 @@
"aconfig_declarations_test.go",
"aconfig_values_test.go",
"aconfig_value_set_test.go",
+ "all_aconfig_declarations_test.go",
],
pluginFor: ["soong_build"],
}
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index b55d7bf..78f506a 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -164,18 +164,3 @@
})
}
-
-func SetAconfigFileMkEntries(m *android.ModuleBase, entries *android.AndroidMkEntries, aconfigFiles map[string]android.Paths) {
- // TODO(b/311155208): The default container here should be system.
- container := ""
-
- if m.SocSpecific() {
- container = "vendor"
- } else if m.ProductSpecific() {
- container = "product"
- } else if m.SystemExtSpecific() {
- container = "system_ext"
- }
-
- entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles[container])
-}
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index 36bea0e..b6c9023 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "fmt"
)
// A singleton module that collects all of the aconfig flags declared in the
@@ -35,6 +36,7 @@
func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// Find all of the aconfig_declarations modules
+ var packages = make(map[string]int)
var cacheFiles android.Paths
ctx.VisitAllModules(func(module android.Module) {
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
@@ -42,8 +44,21 @@
return
}
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
+ packages[decl.Package]++
})
+ var numOffendingPkg = 0
+ for pkg, cnt := range packages {
+ if cnt > 1 {
+ fmt.Printf("%d aconfig_declarations found for package %s\n", cnt, pkg)
+ numOffendingPkg++
+ }
+ }
+
+ if numOffendingPkg > 0 {
+ 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")
ctx.Build(pctx, android.BuildParams{
diff --git a/aconfig/all_aconfig_declarations_test.go b/aconfig/all_aconfig_declarations_test.go
new file mode 100644
index 0000000..0b2021e
--- /dev/null
+++ b/aconfig/all_aconfig_declarations_test.go
@@ -0,0 +1,48 @@
+// 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 aconfig
+
+import (
+ "testing"
+
+ "android/soong/android"
+)
+
+func TestTwoAconfigDeclarationsPerPackage(t *testing.T) {
+ bp := `
+ aconfig_declarations {
+ name: "module_name.foo",
+ package: "com.example.package",
+ container: "com.android.foo",
+ srcs: [
+ "foo.aconfig",
+ ],
+ }
+
+ aconfig_declarations {
+ name: "module_name.bar",
+ package: "com.example.package",
+ container: "com.android.foo",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ `
+ errMsg := "Only one aconfig_declarations allowed for each package."
+ android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents).
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(errMsg)).
+ RunTestWithBp(t, bp)
+}
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 12c2dea..50cd4de 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -40,6 +40,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
@@ -76,8 +77,12 @@
ctx.AddDependency(ctx.Module(), ccDeclarationsTag, declarations)
}
- // Add a dependency for the aconfig flags base library
- deps.SharedLibs = append(deps.SharedLibs, baseLibDep)
+ mode := proptools.StringDefault(this.properties.Mode, "production")
+
+ // Add a dependency for the aconfig flags base library if it is not forced read only
+ if mode != "force-read-only" {
+ deps.SharedLibs = append(deps.SharedLibs, baseLibDep)
+ }
// TODO: It'd be really nice if we could reexport this library and not make everyone do it.
return deps
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index 3de4626..ef92cc8 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -20,6 +20,8 @@
"android/soong/android"
"android/soong/cc"
+
+ "github.com/google/blueprint"
)
var ccCodegenModeTestData = []struct {
@@ -29,6 +31,7 @@
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
+ {"mode: `force-read-only`,", "force-read-only"},
}
func TestCCCodegenMode(t *testing.T) {
@@ -147,6 +150,7 @@
cc_library {
name: "server_configurable_flags",
srcs: ["server_configurable_flags.cc"],
+ vendor_available: true,
}
`
result := android.GroupFixturePreparers(
@@ -154,7 +158,7 @@
cc.PrepareForTestWithCcDefaultModules).
ExtendWithErrorHandler(android.FixtureExpectsNoErrors).RunTestWithBp(t, bp)
- module := result.ModuleForTests("my_cc_library", "android_arm64_armv8-a_shared").Module()
+ module := result.ModuleForTests("my_cc_library", "android_vendor_arm64_armv8-a_shared").Module()
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
@@ -162,3 +166,34 @@
android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 1, len(makeVar))
android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb")
}
+
+func TestForceReadOnly(t *testing.T) {
+ t.Helper()
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents,
+ cc.PrepareForTestWithCcDefaultModules).
+ ExtendWithErrorHandler(android.FixtureExpectsNoErrors).
+ RunTestWithBp(t, fmt.Sprintf(`
+ aconfig_declarations {
+ name: "my_aconfig_declarations",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }
+
+ cc_aconfig_library {
+ name: "my_cc_aconfig_library",
+ aconfig_declarations: "my_aconfig_declarations",
+ mode: "force-read-only",
+ }
+ `))
+
+ module := result.ModuleForTests("my_cc_aconfig_library", "android_arm64_armv8-a_shared").Module()
+ dependOnBaseLib := false
+ result.VisitDirectDeps(module, func(dep blueprint.Module) {
+ if dep.Name() == baseLibDep {
+ dependOnBaseLib = true
+ }
+ })
+ android.AssertBoolEquals(t, "should not have dependency on server_configuriable_flags",
+ dependOnBaseLib, false)
+}
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index c027815..e6817e0 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -30,7 +30,7 @@
var declarationsTag = declarationsTagType{}
-var aconfigSupportedModes = []string{"production", "test", "exported"}
+var aconfigSupportedModes = []string{"production", "test", "exported", "force-read-only"}
type JavaAconfigDeclarationsLibraryProperties struct {
// name of the aconfig_declarations module to generate a library for
@@ -39,6 +39,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go
index 2523abc..7361d44 100644
--- a/aconfig/codegen/java_aconfig_library_test.go
+++ b/aconfig/codegen/java_aconfig_library_test.go
@@ -34,7 +34,7 @@
RunTestWithBp(t, bp+`
aconfig_declarations {
name: "my_aconfig_declarations_foo",
- package: "com.example.package",
+ package: "com.example.package.foo",
srcs: ["foo.aconfig"],
}
@@ -45,7 +45,7 @@
aconfig_declarations {
name: "my_aconfig_declarations_bar",
- package: "com.example.package",
+ package: "com.example.package.bar",
srcs: ["bar.aconfig"],
}
@@ -227,6 +227,10 @@
testCodegenMode(t, "mode: `exported`,", "exported")
}
+func TestForceReadOnlyMode(t *testing.T) {
+ testCodegenMode(t, "mode: `force-read-only`,", "force-read-only")
+}
+
func TestUnsupportedMode(t *testing.T) {
testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode")
}
diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go
index 73b6fec..2ab54b6 100644
--- a/aconfig/codegen/rust_aconfig_library.go
+++ b/aconfig/codegen/rust_aconfig_library.go
@@ -23,6 +23,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go
index c09f701..60bc9f7 100644
--- a/aconfig/codegen/rust_aconfig_library_test.go
+++ b/aconfig/codegen/rust_aconfig_library_test.go
@@ -72,6 +72,7 @@
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
+ {"mode: `force-read-only`,", "force-read-only"},
}
func TestRustCodegenMode(t *testing.T) {
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index ddebec3..4ba1a88 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -49,7 +49,13 @@
if *mergedAconfigFiles == nil {
*mergedAconfigFiles = make(map[string]Paths)
}
- ctx.VisitDirectDeps(func(module Module) {
+ ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+ // Walk our direct dependencies, ignoring blueprint Modules and disabled Android Modules.
+ aModule, _ := module.(Module)
+ if aModule == nil || !aModule.Enabled() {
+ return
+ }
+
if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
return
@@ -62,7 +68,7 @@
})
for container, aconfigFiles := range *mergedAconfigFiles {
- (*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
+ (*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, container, aconfigFiles)
}
SetProvider(ctx, AconfigTransitiveDeclarationsInfoProvider, AconfigTransitiveDeclarationsInfo{
@@ -70,13 +76,13 @@
})
}
-func mergeAconfigFiles(ctx ModuleContext, inputs Paths) Paths {
+func mergeAconfigFiles(ctx ModuleContext, container string, inputs Paths) Paths {
inputs = LastUniquePaths(inputs)
if len(inputs) == 1 {
return Paths{inputs[0]}
}
- output := PathForModuleOut(ctx, "aconfig_merged.pb")
+ output := PathForModuleOut(ctx, container, "aconfig_merged.pb")
ctx.Build(pctx, BuildParams{
Rule: mergeAconfigFilesRule,
@@ -90,3 +96,18 @@
return Paths{output}
}
+
+func SetAconfigFileMkEntries(m *ModuleBase, entries *AndroidMkEntries, aconfigFiles map[string]Paths) {
+ // TODO(b/311155208): The default container here should be system.
+ container := ""
+
+ if m.SocSpecific() {
+ container = "vendor"
+ } else if m.ProductSpecific() {
+ container = "product"
+ } else if m.SystemExtSpecific() {
+ container = "system_ext"
+ }
+
+ entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles[container])
+}
diff --git a/android/androidmk.go b/android/androidmk.go
index f65e084..235d7c0 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -276,14 +276,17 @@
}
// AddCompatibilityTestSuites adds the supplied test suites to the EntryMap, with special handling
-// for partial MTS test suites.
+// for partial MTS and MCTS test suites.
func (a *AndroidMkEntries) AddCompatibilityTestSuites(suites ...string) {
- // MTS supports a full test suite and partial per-module MTS test suites, with naming mts-${MODULE}.
- // To reduce repetition, if we find a partial MTS test suite without an full MTS test suite,
+ // M(C)TS supports a full test suite and partial per-module MTS test suites, with naming mts-${MODULE}.
+ // To reduce repetition, if we find a partial M(C)TS test suite without an full M(C)TS test suite,
// we add the full test suite to our list.
if PrefixInList(suites, "mts-") && !InList("mts", suites) {
suites = append(suites, "mts")
}
+ if PrefixInList(suites, "mcts-") && !InList("mcts", suites) {
+ suites = append(suites, "mcts")
+ }
a.AddStrings("LOCAL_COMPATIBILITY_SUITE", suites...)
}
diff --git a/android/api_levels.go b/android/api_levels.go
index 3f538c0..c019f99 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -336,7 +336,7 @@
// ApiLevelFromUser for more details.
func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) {
// This logic is replicated in starlark, if changing logic here update starlark code too
- // https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=42;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
+ // https://cs.android.com/android/platform/superproject/+/main:build/bazel/rules/common/api.bzl;l=42;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
if raw == "" {
panic("API level string must be non-empty")
}
@@ -449,7 +449,7 @@
err error
}
// This logic is replicated in starlark, if changing logic here update starlark code too
- // https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=30;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
+ // https://cs.android.com/android/platform/superproject/+/main:build/bazel/rules/common/api.bzl;l=30;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
result := config.Once(finalCodenamesMapKey, func() interface{} {
apiLevelsMap, err := getApiLevelsMapReleasedVersions()
@@ -482,7 +482,7 @@
err error
}
// This logic is replicated in starlark, if changing logic here update starlark code too
- // https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=23;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
+ // https://cs.android.com/android/platform/superproject/+/main:build/bazel/rules/common/api.bzl;l=23;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
result := config.Once(apiLevelsMapKey, func() interface{} {
apiLevelsMap, err := getApiLevelsMapReleasedVersions()
if err == nil {
diff --git a/android/arch_list.go b/android/arch_list.go
index ab644a4..801ac49 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -34,6 +34,11 @@
"broadwell",
"goldmont",
"goldmont-plus",
+ // Target arch is goldmont, but without xsaves support.
+ // This ensures efficient execution on a broad range of Intel/AMD CPUs used
+ // in Chromebooks, including those lacking xsaves support.
+ // (e.g. Kaby Lake, Gemini Lake, Alder Lake and AMD Zen series)
+ "goldmont-without-xsaves",
"haswell",
"icelake",
"ivybridge",
@@ -52,6 +57,7 @@
"broadwell",
"goldmont",
"goldmont-plus",
+ "goldmont-without-xsaves",
"haswell",
"icelake",
"ivybridge",
@@ -197,6 +203,15 @@
"popcnt",
"movbe",
},
+ "goldmont-without-xsaves": {
+ "ssse3",
+ "sse4",
+ "sse4_1",
+ "sse4_2",
+ "aes_ni",
+ "popcnt",
+ "movbe",
+ },
"haswell": {
"ssse3",
"sse4",
@@ -358,6 +373,14 @@
"aes_ni",
"popcnt",
},
+ "goldmont-without-xsaves": {
+ "ssse3",
+ "sse4",
+ "sse4_1",
+ "sse4_2",
+ "aes_ni",
+ "popcnt",
+ },
"haswell": {
"ssse3",
"sse4",
diff --git a/android/config.go b/android/config.go
index 24b9b8a..1ea0d94 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1849,6 +1849,10 @@
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
}
+func (c *deviceConfig) BuildBrokenDontCheckSystemSdk() bool {
+ return c.config.productVariables.BuildBrokenDontCheckSystemSdk
+}
+
func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
}
diff --git a/android/filegroup.go b/android/filegroup.go
index 0aabb68..bc881ed 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -55,6 +55,9 @@
DefaultableModuleBase
properties fileGroupProperties
srcs Paths
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]Paths
}
var _ SourceFileProducer = (*fileGroup)(nil)
@@ -93,6 +96,7 @@
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
}
SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
+ CollectDependencyAconfigFiles(ctx, &fg.mergedAconfigFiles)
}
func (fg *fileGroup) Srcs() Paths {
diff --git a/android/module.go b/android/module.go
index 1a428e5..d8f004c 100644
--- a/android/module.go
+++ b/android/module.go
@@ -326,7 +326,7 @@
// defaults module, use the `defaults_visibility` property on the defaults module;
// not to be confused with the `default_visibility` property on the package module.
//
- // See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for
+ // See https://android.googlesource.com/platform/build/soong/+/main/README.md#visibility for
// more details.
Visibility []string
diff --git a/android/packaging.go b/android/packaging.go
index 2506378..8873540 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -240,10 +240,14 @@
// CopySpecsToDir is a helper that will add commands to the rule builder to copy the PackagingSpec
// entries into the specified directory.
func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir WritablePath) (entries []string) {
+ if len(specs) == 0 {
+ return entries
+ }
seenDir := make(map[string]bool)
preparerPath := PathForModuleOut(ctx, "preparer.sh")
cmd := builder.Command().Tool(preparerPath)
var sb strings.Builder
+ sb.WriteString("set -e\n")
for _, k := range SortedKeys(specs) {
ps := specs[k]
destPath := filepath.Join(dir.String(), ps.relPathInPackage)
diff --git a/android/paths.go b/android/paths.go
index 6aabe4f..95f53ea 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -181,13 +181,13 @@
var _ errorfContext = blueprint.SingletonContext(nil)
-// moduleErrorf is the interface containing the ModuleErrorf method matching
+// ModuleErrorfContext is the interface containing the ModuleErrorf method matching
// the ModuleErrorf method in blueprint.ModuleContext.
-type moduleErrorf interface {
+type ModuleErrorfContext interface {
ModuleErrorf(format string, args ...interface{})
}
-var _ moduleErrorf = blueprint.ModuleContext(nil)
+var _ ModuleErrorfContext = blueprint.ModuleContext(nil)
// reportPathError will register an error with the attached context. It
// attempts ctx.ModuleErrorf for a better error message first, then falls
@@ -200,7 +200,7 @@
// attempts ctx.ModuleErrorf for a better error message first, then falls
// back to ctx.Errorf.
func ReportPathErrorf(ctx PathContext, format string, args ...interface{}) {
- if mctx, ok := ctx.(moduleErrorf); ok {
+ if mctx, ok := ctx.(ModuleErrorfContext); ok {
mctx.ModuleErrorf(format, args...)
} else if ectx, ok := ctx.(errorfContext); ok {
ectx.Errorf(format, args...)
diff --git a/android/sdk_version.go b/android/sdk_version.go
index aafcee7..73568af 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "reflect"
"strconv"
"strings"
)
@@ -162,6 +163,17 @@
// If BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES has a numeric value,
// use it instead of "current" for the vendor partition.
currentSdkVersion := ctx.DeviceConfig().CurrentApiLevelForVendorModules()
+ // b/314011075: special case for Java modules in vendor partition. They can no longer use
+ // SDK 35 or later. Their maximum API level is limited to 34 (Android U). This is to
+ // discourage the use of Java APIs in the vendor partition which hasn't been officially
+ // supported since the Project Treble back in Android 10. We would like to eventually
+ // evacuate all Java modules from the partition, but that shall be done progressively.
+ // Note that the check for the availability of SDK 34 is to not break existing tests where
+ // any of the frozen SDK version is unavailable.
+ if isJava(ctx.Module()) && isSdkVersion34AvailableIn(ctx.Config()) {
+ currentSdkVersion = "34"
+ }
+
if currentSdkVersion == "current" {
return s
}
@@ -290,28 +302,79 @@
}
}
+// Checks if the use of this SDK `s` is valid for the given module context `ctx`.
func (s SdkSpec) ValidateSystemSdk(ctx EarlyModuleContext) bool {
- // Ensures that the specified system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor/product Java module)
- // Assuming that BOARD_SYSTEMSDK_VERSIONS := 28 29,
- // sdk_version of the modules in vendor/product that use system sdk must be either system_28, system_29 or system_current
- if s.Kind != SdkSystem || s.ApiLevel.IsPreview() {
+ // Do some early checks. This check is currently only for Java modules. And our only concern
+ // is the use of "system" SDKs.
+ if !isJava(ctx.Module()) || s.Kind != SdkSystem || ctx.DeviceConfig().BuildBrokenDontCheckSystemSdk() {
return true
}
- allowedVersions := ctx.DeviceConfig().PlatformSystemSdkVersions()
- if ctx.DeviceSpecific() || ctx.SocSpecific() || (ctx.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
- systemSdkVersions := ctx.DeviceConfig().SystemSdkVersions()
- if len(systemSdkVersions) > 0 {
- allowedVersions = systemSdkVersions
+
+ inVendor := ctx.DeviceSpecific() || ctx.SocSpecific()
+ inProduct := ctx.ProductSpecific()
+ isProductUnbundled := ctx.Config().EnforceProductPartitionInterface()
+ inApex := false
+ if am, ok := ctx.Module().(ApexModule); ok {
+ inApex = am.InAnyApex()
+ }
+ isUnbundled := inVendor || (inProduct && isProductUnbundled) || inApex
+
+ // Bundled modules can use any SDK
+ if !isUnbundled {
+ return true
+ }
+
+ // Unbundled modules are allowed to use BOARD_SYSTEMSDK_VERSIONS
+ supportedVersions := ctx.DeviceConfig().SystemSdkVersions()
+
+ // b/314011075: special case for vendor modules. Java modules in the vendor partition can
+ // not use SDK 35 or later. This is to discourage the use of Java APIs in the vendor
+ // partition which hasn't been officially supported since the Project Treble back in Android
+ // 10. We would like to eventually evacuate all Java modules from the partition, but that
+ // shall be done progressively.
+ if inVendor {
+ // 28 was the API when BOARD_SYSTEMSDK_VERSIONS was introduced, so that's the oldest
+ // we should allow.
+ supportedVersions = []string{}
+ for v := 28; v <= 34; v++ {
+ supportedVersions = append(supportedVersions, strconv.Itoa(v))
}
}
- if len(allowedVersions) > 0 && !InList(s.ApiLevel.String(), allowedVersions) {
+
+ // APEXes in the system partition are still considered as part of the platform, thus can use
+ // more SDKs from PLATFORM_SYSTEMSDK_VERSIONS
+ if inApex && !inVendor {
+ supportedVersions = ctx.DeviceConfig().PlatformSystemSdkVersions()
+ }
+
+ thisVer, err := s.EffectiveVersion(ctx)
+ if err != nil {
+ ctx.PropertyErrorf("sdk_version", "invalid sdk version %q", s.Raw)
+ return false
+ }
+
+ thisVerString := strconv.Itoa(thisVer.FinalOrPreviewInt())
+ if thisVer.IsPreview() {
+ thisVerString = *ctx.Config().productVariables.Platform_sdk_version_or_codename
+ }
+
+ if !InList(thisVerString, supportedVersions) {
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
- s.Raw, allowedVersions)
+ s.Raw, supportedVersions)
return false
}
return true
}
+func isJava(m Module) bool {
+ moduleType := reflect.TypeOf(m).String()
+ return strings.HasPrefix(moduleType, "*java.")
+}
+
+func isSdkVersion34AvailableIn(c Config) bool {
+ return c.PlatformSdkVersion().FinalInt() >= 34
+}
+
func init() {
RegisterMakeVarsProvider(pctx, javaSdkMakeVars)
}
diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go
index 79bdeb8..a6b2c51 100644
--- a/android/soong_config_modules_test.go
+++ b/android/soong_config_modules_test.go
@@ -376,8 +376,7 @@
prepareForSoongConfigTestModule,
FixtureWithRootAndroidBp(bp),
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
- // TODO(b/171232169): improve the error message for non-existent properties
- `unrecognized property "soong_config_variables`,
+ `unrecognized property "soong_config_variables.feature1.made_up_property`,
})).RunTest(t)
}
diff --git a/android/test_config.go b/android/test_config.go
index 9e1ac70..a15343a 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -39,11 +39,12 @@
DeviceName: stringPtr("test_device"),
DeviceProduct: stringPtr("test_product"),
Platform_sdk_version: intPtr(30),
+ Platform_sdk_version_or_codename: stringPtr("S"),
Platform_sdk_codename: stringPtr("S"),
Platform_base_sdk_extension_version: intPtr(1),
Platform_version_active_codenames: []string{"S", "Tiramisu"},
- DeviceSystemSdkVersions: []string{"14", "15"},
- Platform_systemsdk_versions: []string{"29", "30"},
+ DeviceSystemSdkVersions: []string{"29", "30", "S"},
+ Platform_systemsdk_versions: []string{"29", "30", "S", "Tiramisu"},
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
diff --git a/android/variable.go b/android/variable.go
index fa4cfc1..9844080 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -448,6 +448,7 @@
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenIncorrectPartitionImages bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"`
+ BuildBrokenDontCheckSystemSdk bool `json:",omitempty"`
BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"`
diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go
index 276b9ab..6564911 100644
--- a/androidmk/androidmk/android.go
+++ b/androidmk/androidmk/android.go
@@ -86,6 +86,7 @@
"LOCAL_ANNOTATION_PROCESSOR_CLASSES": skip, // Soong gets the processor classes from the plugin
"LOCAL_CTS_TEST_PACKAGE": skip, // Obsolete
+ "LOCAL_XTS_TEST_PACKAGE": skip, // Obsolete
"LOCAL_JACK_ENABLED": skip, // Obselete
"LOCAL_JACK_FLAGS": skip, // Obselete
}
diff --git a/androidmk/androidmk/androidmk_test.go b/androidmk/androidmk/androidmk_test.go
index 0580ae5..08bbb39 100644
--- a/androidmk/androidmk/androidmk_test.go
+++ b/androidmk/androidmk/androidmk_test.go
@@ -823,6 +823,26 @@
`,
},
{
+ desc: "IGNORE_LOCAL_XTS_TEST_PACKAGE",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_PACKAGE_NAME := FooTest
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_XTS_TEST_PACKAGE := foo.bar
+LOCAL_COMPATIBILITY_SUPPORT_FILES := file1
+include $(BUILD_CTS_PACKAGE)
+`,
+ expected: `
+android_test {
+ name: "FooTest",
+ defaults: ["cts_defaults"],
+ test_suites: ["cts"],
+
+ data: ["file1"],
+}
+`,
+ },
+ {
desc: "BUILD_CTS_*_JAVA_LIBRARY",
in: `
include $(CLEAR_VARS)
diff --git a/apex/apex.go b/apex/apex.go
index c4545d2..b37c495 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -235,6 +235,9 @@
// List of filesystem images that are embedded inside this APEX bundle.
Filesystems []string
+ // List of prebuilt_etcs that are embedded inside this APEX bundle.
+ Prebuilts []string
+
// List of native libraries to exclude from this APEX.
Exclude_native_shared_libs []string
@@ -252,6 +255,9 @@
// List of filesystem images to exclude from this APEX bundle.
Exclude_filesystems []string
+
+ // List of prebuilt_etcs to exclude from this APEX bundle.
+ Exclude_prebuilts []string
}
// Merge combines another ApexNativeDependencies into this one
@@ -262,6 +268,7 @@
a.Binaries = append(a.Binaries, b.Binaries...)
a.Tests = append(a.Tests, b.Tests...)
a.Filesystems = append(a.Filesystems, b.Filesystems...)
+ a.Prebuilts = append(a.Prebuilts, b.Prebuilts...)
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
@@ -269,6 +276,7 @@
a.Exclude_binaries = append(a.Exclude_binaries, b.Exclude_binaries...)
a.Exclude_tests = append(a.Exclude_tests, b.Exclude_tests...)
a.Exclude_filesystems = append(a.Exclude_filesystems, b.Exclude_filesystems...)
+ a.Exclude_prebuilts = append(a.Exclude_prebuilts, b.Exclude_prebuilts...)
}
type apexMultilibProperties struct {
@@ -480,6 +488,9 @@
javaApisUsedByModuleFile android.ModuleOutPath
aconfigFiles []android.Path
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
// apexFileClass represents a type of file that can be included in APEX.
@@ -711,6 +722,8 @@
android.RemoveListFromList(nativeModules.Rust_dyn_libs, nativeModules.Exclude_rust_dyn_libs)...)
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
+ ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
+ android.RemoveListFromList(nativeModules.Prebuilts, nativeModules.Exclude_prebuilts)...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
@@ -719,7 +732,7 @@
// getImageVariationPair returns a pair for the image variation name as its
// prefix and suffix. The prefix indicates whether it's core/vendor/product and the
-// suffix indicates the vndk version when it's vendor or product.
+// suffix indicates the vndk version for vendor/product if vndk is enabled.
// getImageVariation can simply join the result of this function to get the
// image variation name.
func (a *apexBundle) getImageVariationPair(deviceConfig android.DeviceConfig) (string, string) {
@@ -727,8 +740,8 @@
return cc.VendorVariationPrefix, a.vndkVersion(deviceConfig)
}
- var prefix string
- var vndkVersion string
+ prefix := android.CoreVariation
+ vndkVersion := ""
if deviceConfig.VndkVersion() != "" {
if a.SocSpecific() || a.DeviceSpecific() {
prefix = cc.VendorVariationPrefix
@@ -737,15 +750,18 @@
prefix = cc.ProductVariationPrefix
vndkVersion = deviceConfig.PlatformVndkVersion()
}
+ } else {
+ if a.SocSpecific() || a.DeviceSpecific() {
+ prefix = cc.VendorVariation
+ } else if a.ProductSpecific() {
+ prefix = cc.ProductVariation
+ }
}
if vndkVersion == "current" {
vndkVersion = deviceConfig.PlatformVndkVersion()
}
- if vndkVersion != "" {
- return prefix, vndkVersion
- }
- return android.CoreVariation, "" // The usual case
+ return prefix, vndkVersion
}
// getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply
@@ -1625,7 +1641,7 @@
type javaModule interface {
android.Module
BaseModuleName() string
- DexJarBuildPath() java.OptionalDexJarPath
+ DexJarBuildPath(ctx android.ModuleErrorfContext) java.OptionalDexJarPath
JacocoReportClassesFile() android.Path
LintDepSets() java.LintDepSets
Stem() string
@@ -1639,7 +1655,7 @@
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
- return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath().PathOrNil())
+ return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath(ctx).PathOrNil())
}
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
@@ -2143,7 +2159,7 @@
}
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
- if ch.UseVndk() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
+ if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
return false
}
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
@@ -2353,6 +2369,7 @@
return
}
}
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
////////////////////////////////////////////////////////////////////////////////////////////
// 3) some fields in apexBundle struct are configured
@@ -2512,6 +2529,9 @@
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
// apex_defaults provides defaultable properties to other apex modules.
@@ -2534,6 +2554,10 @@
android.OverrideModuleBase
}
+func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
+}
+
func (o *OverrideApex) GenerateAndroidBuildActions(_ android.ModuleContext) {
// All the overrides happen in the base module.
}
@@ -2853,17 +2877,6 @@
//
// Module separator
//
- m["com.android.mediaprovider"] = []string{
- "MediaProvider",
- "MediaProviderGoogle",
- "fmtlib_ndk",
- "libbase_ndk",
- "libfuse",
- "libfuse_jni",
- }
- //
- // Module separator
- //
m["com.android.runtime"] = []string{
"libdebuggerd",
"libdebuggerd_common_headers",
@@ -2882,32 +2895,6 @@
"libz",
"libziparchive",
}
- //
- // Module separator
- //
- m["com.android.wifi"] = []string{
- "PlatformProperties",
- "android.hardware.wifi-V1.0-java",
- "android.hardware.wifi-V1.0-java-constants",
- "android.hardware.wifi-V1.1-java",
- "android.hardware.wifi-V1.2-java",
- "android.hardware.wifi-V1.3-java",
- "android.hardware.wifi-V1.4-java",
- "android.hardware.wifi.hostapd-V1.0-java",
- "android.hardware.wifi.hostapd-V1.1-java",
- "android.hardware.wifi.hostapd-V1.2-java",
- "android.hardware.wifi.supplicant-V1.0-java",
- "android.hardware.wifi.supplicant-V1.1-java",
- "android.hardware.wifi.supplicant-V1.2-java",
- "android.hardware.wifi.supplicant-V1.3-java",
- "bouncycastle-unbundled",
- "framework-wifi-util-lib",
- "ksoap2",
- "libnanohttpd",
- "wifi-lite-protos",
- "wifi-nano-protos",
- "wifi-service-pre-jarjar",
- }
return m
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 1b9fa19..2a15bd3 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5355,6 +5355,13 @@
).RunTest(t)
}
+// A minimal context object for use with DexJarBuildPath
+type moduleErrorfTestCtx struct {
+}
+
+func (ctx moduleErrorfTestCtx) ModuleErrorf(format string, args ...interface{}) {
+}
+
// These tests verify that the prebuilt_apex/deapexer to java_import wiring allows for the
// propagation of paths to dex implementation jars from the former to the latter.
func TestPrebuiltExportDexImplementationJars(t *testing.T) {
@@ -5364,7 +5371,7 @@
t.Helper()
// Make sure the import has been given the correct path to the dex jar.
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
- dexJarBuildPath := p.DexJarBuildPath().PathOrNil()
+ dexJarBuildPath := p.DexJarBuildPath(moduleErrorfTestCtx{}).PathOrNil()
stem := android.RemoveOptionalPrebuiltPrefix(name)
android.AssertStringEquals(t, "DexJarBuildPath should be apex-related path.",
".intermediates/myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar",
@@ -8491,6 +8498,8 @@
PrepareForTestWithApexBuildComponents,
)
+ errCtx := moduleErrorfTestCtx{}
+
bpBase := `
apex_set {
name: "com.android.myapex",
@@ -8540,7 +8549,7 @@
usesLibraryDep := module.(java.UsesLibraryDependency)
android.AssertPathRelativeToTopEquals(t, "dex jar path",
"out/soong/.intermediates/com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
- usesLibraryDep.DexJarBuildPath().Path())
+ usesLibraryDep.DexJarBuildPath(errCtx).Path())
})
t.Run("java_sdk_library_import", func(t *testing.T) {
@@ -8563,7 +8572,7 @@
usesLibraryDep := module.(java.UsesLibraryDependency)
android.AssertPathRelativeToTopEquals(t, "dex jar path",
"out/soong/.intermediates/com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
- usesLibraryDep.DexJarBuildPath().Path())
+ usesLibraryDep.DexJarBuildPath(errCtx).Path())
})
t.Run("prebuilt_bootclasspath_fragment", func(t *testing.T) {
@@ -11097,7 +11106,7 @@
t.Fatalf("Expected 3 commands, got %d in:\n%s", len(aconfigArgs), s)
}
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/aconfig_merged.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
@@ -11105,7 +11114,7 @@
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/aconfig_merged.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")
}
@@ -11244,14 +11253,14 @@
t.Fatalf("Expected 2 commands, got %d in:\n%s", 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/aconfig_merged.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))
}
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/aconfig_merged.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")
}
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 159e9e1..2600169 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -677,7 +677,7 @@
func getDexJarPath(result *android.TestResult, name string) string {
module := result.Module(name, "android_common")
- return module.(java.UsesLibraryDependency).DexJarBuildPath().Path().RelativeToTop().String()
+ return module.(java.UsesLibraryDependency).DexJarBuildPath(moduleErrorfTestCtx{}).Path().RelativeToTop().String()
}
// TestBootclasspathFragment_HiddenAPIList checks to make sure that the correct parameters are
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 188875a..c27b072 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -483,6 +483,9 @@
inputApex android.Path
provenanceMetaDataFile android.OutputPath
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
type ApexFileProperties struct {
@@ -837,6 +840,8 @@
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
+
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *Prebuilt) ProvenanceMetaDataFile() android.OutputPath {
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index af2f550..bd56768 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -446,7 +446,7 @@
if !emitZeroValues && isZero(propertyValue) {
// A property value being set or unset actually matters -- Soong does set default
// values for unset properties, like system_shared_libs = ["libc", "libm", "libdl"] at
- // https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=281-287;drc=f70926eef0b9b57faf04c17a1062ce50d209e480
+ // https://cs.android.com/android/platform/superproject/+/main:build/soong/cc/linker.go;l=281-287;drc=f70926eef0b9b57faf04c17a1062ce50d209e480
//
// In Bazel-parlance, we would use "attr.<type>(default = <default
// value>)" to set the default value of unset attributes. In the cases
diff --git a/cc/androidmk.go b/cc/androidmk.go
index bde096b..7723dc3 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -15,7 +15,6 @@
package cc
import (
- "android/soong/aconfig"
"github.com/google/blueprint/proptools"
"fmt"
@@ -51,6 +50,7 @@
InVendorRamdisk() bool
InRecovery() bool
NotInPlatform() bool
+ InVendorOrProduct() bool
}
type subAndroidMkProvider interface {
@@ -125,7 +125,7 @@
entries.SetString("SOONG_SDK_VARIANT_MODULES",
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
}
- aconfig.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
@@ -294,7 +294,7 @@
// they can be exceptionally used directly when APEXes are not available (e.g. during the
// very early stage in the boot process).
if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
- !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
+ !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.InVendorOrProduct() && !ctx.static() {
if library.buildStubs() && library.isLatestStubVersion() {
entries.SubName = ""
}
diff --git a/cc/cc.go b/cc/cc.go
index 6e920f0..fd7a38a 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -25,6 +25,7 @@
"strings"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -300,8 +301,8 @@
// Set by DepsMutator.
AndroidMkSystemSharedLibs []string `blueprint:"mutated"`
- // The name of the image this module is built for, suffixed with a '.'
- ImageVariationPrefix string `blueprint:"mutated"`
+ // The name of the image this module is built for
+ ImageVariation string `blueprint:"mutated"`
// The VNDK version this module is built against. If empty, the module is not
// build against the VNDK.
@@ -524,6 +525,7 @@
inRamdisk() bool
inVendorRamdisk() bool
inRecovery() bool
+ InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
getVndkExtendsModuleName() string
@@ -1284,7 +1286,7 @@
func (c *Module) canUseSdk() bool {
return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled &&
- !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
+ !c.InVendorOrProduct() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
}
func (c *Module) UseSdk() bool {
@@ -1666,6 +1668,10 @@
return ctx.mod.UseVndk()
}
+func (ctx *moduleContextImpl) InVendorOrProduct() bool {
+ return ctx.mod.InVendorOrProduct()
+}
+
func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
return ctx.mod.IsNdk(config)
}
@@ -1895,7 +1901,7 @@
}
llndk := c.IsLlndk()
- if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
+ if llndk || (c.InVendorOrProduct() && c.HasNonSystemVariants()) {
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
@@ -1948,6 +1954,7 @@
"libdl_android": true,
"libm": true,
"libdl": true,
+ "libz": true,
// art apex
"libandroidio": true,
"libdexfile": true,
@@ -1987,6 +1994,10 @@
return false
}
+func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
+}
+
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// Handle the case of a test module split by `test_per_src` mutator.
//
@@ -2190,7 +2201,7 @@
// is explicitly referenced via .bootstrap suffix or the module is marked with
// 'bootstrap: true').
if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() &&
- !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
+ !c.InRecovery() && !c.InVendorOrProduct() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() && !c.InVendorRamdisk() {
c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable
@@ -2426,9 +2437,9 @@
// Only retrieve the snapshot on demand in order to avoid circular dependencies
// between the modules in the snapshot and the snapshot itself.
var snapshotModule []blueprint.Module
- if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() {
+ if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() && actx.OtherModuleExists("vendor_snapshot") {
snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
- } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
+ } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() && actx.OtherModuleExists("recovery_snapshot") {
snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
}
if len(snapshotModule) > 0 && snapshotModule[0] != nil {
@@ -3432,12 +3443,12 @@
panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
}
- useVndk := false
+ inVendorOrProduct := false
bootstrap := false
if linkable, ok := ctx.Module().(LinkableInterface); !ok {
panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
} else {
- useVndk = linkable.UseVndk()
+ inVendorOrProduct = linkable.InVendorOrProduct()
bootstrap = linkable.Bootstrap()
}
@@ -3445,7 +3456,7 @@
useStubs := false
- if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK
+ if lib := moduleLibraryInterface(dep); lib.buildStubs() && inVendorOrProduct { // LLNDK
if !apexInfo.IsForPlatform() {
// For platform libraries, use current version of LLNDK
// If this is for use_vendor apex we will apply the same rules
@@ -3597,7 +3608,7 @@
// The vendor module is a no-vendor-variant VNDK library. Depend on the
// core module instead.
return libName
- } else if ccDep.UseVndk() && nonSystemVariantsExist {
+ } else if ccDep.InVendorOrProduct() && nonSystemVariantsExist {
// The vendor and product modules in Make will have been renamed to not conflict with the
// core module, so update the dependency name here accordingly.
return libName + ccDep.SubName()
@@ -4068,6 +4079,9 @@
android.ModuleBase
android.DefaultsModuleBase
android.ApexModuleBase
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
// cc_defaults provides a set of properties that can be inherited by other cc
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 5c5275e..321bd38 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -26,6 +26,8 @@
"android/soong/aidl_library"
"android/soong/android"
+
+ "github.com/google/blueprint"
)
func init() {
@@ -45,6 +47,14 @@
}),
)
+// TODO(b/316829758) Update prepareForCcTest with this configuration and remove prepareForCcTestWithoutVndk
+var prepareForCcTestWithoutVndk = android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithCc,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.VendorApiLevel = StringPtr("202404")
+ }),
+)
+
var apexVariationName = "apex28"
var apexVersion = "28"
@@ -2640,6 +2650,7 @@
name: "libexternal_headers",
export_include_dirs: ["include"],
vendor_available: true,
+ product_available: true,
}
cc_library_headers {
name: "libexternal_llndk_headers",
@@ -4784,3 +4795,51 @@
return
}
}
+
+// TODO(b/316829758) Remove this test and do not set VNDK version from other tests
+func TestImageVariantsWithoutVndk(t *testing.T) {
+ t.Parallel()
+
+ bp := `
+ cc_binary {
+ name: "binfoo",
+ srcs: ["binfoo.cc"],
+ vendor_available: true,
+ product_available: true,
+ shared_libs: ["libbar"]
+ }
+ cc_library {
+ name: "libbar",
+ srcs: ["libbar.cc"],
+ vendor_available: true,
+ product_available: true,
+ }
+ `
+
+ ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp)
+
+ hasDep := func(m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ testDepWithVariant := func(imageVariant string) {
+ imageVariantStr := ""
+ if imageVariant != "core" {
+ imageVariantStr = "_" + imageVariant
+ }
+ binFooModule := ctx.ModuleForTests("binfoo", "android"+imageVariantStr+"_arm64_armv8-a").Module()
+ libBarModule := ctx.ModuleForTests("libbar", "android"+imageVariantStr+"_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, "binfoo should have dependency on libbar with image variant "+imageVariant, true, hasDep(binFooModule, libBarModule))
+ }
+
+ testDepWithVariant("core")
+ testDepWithVariant("vendor")
+ testDepWithVariant("product")
+}
diff --git a/cc/compiler.go b/cc/compiler.go
index c9de1b0..c57b72c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -385,7 +385,7 @@
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
}
- if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
+ if !(ctx.useSdk() || ctx.InVendorOrProduct()) || ctx.Host() {
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}",
tc.IncludeFlags())
@@ -402,7 +402,7 @@
"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String())
}
- if ctx.useVndk() {
+ if ctx.InVendorOrProduct() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
if ctx.inVendor() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")
@@ -720,7 +720,7 @@
// Compile files listed in c.Properties.Srcs into objects
objs := compileObjs(ctx, buildFlags, "", srcs,
- android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_disabled_srcs),
+ append(android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_disabled_srcs), compiler.generatedSources...),
android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_timeout_srcs),
pathDeps, compiler.cFlagsDeps)
diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go
index e43848c..ff0a3b7 100644
--- a/cc/config/x86_64_device.go
+++ b/cc/config/x86_64_device.go
@@ -49,6 +49,10 @@
"goldmont-plus": []string{
"-march=goldmont-plus",
},
+ "goldmont-without-xsaves": []string{
+ "-march=goldmont",
+ "-mno-xsaves",
+ },
"haswell": []string{
"-march=core-avx2",
},
diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go
index c826d3c..08be869 100644
--- a/cc/config/x86_device.go
+++ b/cc/config/x86_device.go
@@ -56,6 +56,10 @@
"goldmont-plus": []string{
"-march=goldmont-plus",
},
+ "goldmont-without-xsaves": []string{
+ "-march=goldmont",
+ "-mno-xsaves",
+ },
"haswell": []string{
"-march=core-avx2",
},
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 183849a..2436f33 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -144,20 +144,25 @@
}
func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ subdir := "lib"
+ if ctx.inVendor() {
+ subdir = "lib/vendor"
+ }
+
flags = fuzz.binaryDecorator.linkerFlags(ctx, flags)
// RunPaths on devices isn't instantiated by the base linker. `../lib` for
// installed fuzz targets (both host and device), and `./lib` for fuzz
// target packages.
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/`+subdir)
// When running on device, fuzz targets with vendor: true set will be in
// fuzzer_name/vendor/fuzzer_name (note the extra 'vendor' and thus need to
// link with libraries in ../../lib/. Non-vendor binaries only need to look
// one level up, in ../lib/.
if ctx.inVendor() {
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../../lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../../`+subdir)
} else {
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../`+subdir)
}
return flags
@@ -221,19 +226,27 @@
}
func SharedLibraryInstallLocation(
- libraryBase string, isHost bool, fuzzDir string, archString string) string {
+ libraryBase string, isHost bool, isVendor bool, fuzzDir string, archString string) string {
installLocation := "$(PRODUCT_OUT)/data"
if isHost {
installLocation = "$(HOST_OUT)"
}
+ subdir := "lib"
+ if isVendor {
+ subdir = "lib/vendor"
+ }
installLocation = filepath.Join(
- installLocation, fuzzDir, archString, "lib", libraryBase)
+ installLocation, fuzzDir, archString, subdir, libraryBase)
return installLocation
}
// Get the device-only shared library symbols install directory.
-func SharedLibrarySymbolsInstallLocation(libraryBase string, fuzzDir string, archString string) string {
- return filepath.Join("$(PRODUCT_OUT)/symbols/data/", fuzzDir, archString, "/lib/", libraryBase)
+func SharedLibrarySymbolsInstallLocation(libraryBase string, isVendor bool, fuzzDir string, archString string) string {
+ subdir := "lib"
+ if isVendor {
+ subdir = "lib/vendor"
+ }
+ return filepath.Join("$(PRODUCT_OUT)/symbols/data/", fuzzDir, archString, subdir, libraryBase)
}
func (fuzzBin *fuzzBinary) install(ctx ModuleContext, file android.Path) {
@@ -244,16 +257,29 @@
// Grab the list of required shared libraries.
fuzzBin.sharedLibraries, _ = CollectAllSharedDependencies(ctx)
+ // TODO: does not mirror Android linkernamespaces
+ // the logic here has special cases for vendor, but it would need more work to
+ // work in arbitrary partitions, so just surface errors early for a few cases
+ //
+ // Even without these, there are certain situations across linkernamespaces
+ // that this won't support. For instance, you might have:
+ //
+ // my_fuzzer (vendor) -> libbinder_ndk (core) -> libbinder (vendor)
+ //
+ // This dependency chain wouldn't be possible to express in the current
+ // logic because all the deps currently match the variant of the source
+ // module.
+
for _, ruleBuilderInstall := range fuzzBin.sharedLibraries {
install := ruleBuilderInstall.To
fuzzBin.installedSharedDeps = append(fuzzBin.installedSharedDeps,
SharedLibraryInstallLocation(
- install, ctx.Host(), installBase, ctx.Arch().ArchType.String()))
+ install, ctx.Host(), ctx.inVendor(), installBase, ctx.Arch().ArchType.String()))
// Also add the dependency on the shared library symbols dir.
if !ctx.Host() {
fuzzBin.installedSharedDeps = append(fuzzBin.installedSharedDeps,
- SharedLibrarySymbolsInstallLocation(install, installBase, ctx.Arch().ArchType.String()))
+ SharedLibrarySymbolsInstallLocation(install, ctx.inVendor(), installBase, ctx.Arch().ArchType.String()))
}
}
@@ -412,6 +438,10 @@
}
sharedLibsInstallDirPrefix := "lib"
+ if ccModule.InVendor() {
+ sharedLibsInstallDirPrefix = "lib/vendor"
+ }
+
if !ccModule.IsFuzzModule() {
return
}
@@ -504,7 +534,7 @@
// install it to the output directory. Setup the install destination here,
// which will be used by $(copy-many-files) in the Make backend.
installDestination := SharedLibraryInstallLocation(
- install, module.Host(), fuzzDir, archString)
+ install, module.Host(), module.InVendor(), fuzzDir, archString)
if (*sharedLibraryInstalled)[installDestination] {
continue
}
@@ -522,7 +552,7 @@
// we want symbolization tools (like `stack`) to be able to find the symbols
// in $ANDROID_PRODUCT_OUT/symbols automagically.
if !module.Host() {
- symbolsInstallDestination := SharedLibrarySymbolsInstallLocation(install, fuzzDir, archString)
+ symbolsInstallDestination := SharedLibrarySymbolsInstallLocation(install, module.InVendor(), fuzzDir, archString)
symbolsInstallDestination = strings.ReplaceAll(symbolsInstallDestination, "$", "$$")
s.SharedLibInstallStrings = append(s.SharedLibInstallStrings,
library.String()+":"+symbolsInstallDestination)
diff --git a/cc/gen.go b/cc/gen.go
index 2e72e30..e351fdd 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -225,6 +225,10 @@
// The files that can be used as order only dependencies in order to ensure that the sysprop
// header files are up to date.
syspropOrderOnlyDeps android.Paths
+
+ // List of generated code path.
+ // ex) '*.cpp' files generated from '*.ll / *.yy'.
+ generatedSources android.Paths
}
func genSources(
@@ -254,30 +258,37 @@
return yaccRule_
}
+ var generatedSources android.Paths = nil
+
for i, srcFile := range srcFiles {
switch srcFile.Ext() {
case ".y":
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
srcFiles[i] = cFile
deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc)...)
+ generatedSources = append(generatedSources, cFile)
case ".yy":
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
srcFiles[i] = cppFile
deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc)...)
+ generatedSources = append(generatedSources, cppFile)
case ".l":
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
srcFiles[i] = cFile
genLex(ctx, srcFile, cFile, buildFlags.lex)
+ generatedSources = append(generatedSources, cFile)
case ".ll":
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
srcFiles[i] = cppFile
genLex(ctx, srcFile, cppFile, buildFlags.lex)
+ generatedSources = append(generatedSources, cppFile)
case ".proto":
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
srcFiles[i] = ccFile
info.protoHeaders = append(info.protoHeaders, headerFile)
// Use the generated header as an order only dep to ensure that it is up to date when needed.
info.protoOrderOnlyDeps = append(info.protoOrderOnlyDeps, headerFile)
+ generatedSources = append(generatedSources, ccFile)
case ".aidl":
if aidlRule == nil {
aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"),
@@ -299,10 +310,12 @@
// needed.
// TODO: Reduce the size of the ninja file by using one order only dep for the whole rule
info.aidlOrderOnlyDeps = append(info.aidlOrderOnlyDeps, aidlHeaders...)
+ generatedSources = append(generatedSources, cppFile)
case ".rscript", ".fs":
cppFile := rsGeneratedCppFile(ctx, srcFile)
rsFiles = append(rsFiles, srcFiles[i])
srcFiles[i] = cppFile
+ generatedSources = append(generatedSources, cppFile)
case ".sysprop":
cppFile, headerFiles := genSysprop(ctx, srcFile)
srcFiles[i] = cppFile
@@ -310,9 +323,12 @@
// Use the generated headers as order only deps to ensure that they are up to date when
// needed.
info.syspropOrderOnlyDeps = append(info.syspropOrderOnlyDeps, headerFiles...)
+ generatedSources = append(generatedSources, cppFile)
}
}
+ info.generatedSources = generatedSources
+
for _, aidlLibraryInfo := range aidlLibraryInfos {
if aidlLibraryRule == nil {
aidlLibraryRule = android.NewRuleBuilder(pctx, ctx).Sbox(
diff --git a/cc/genrule.go b/cc/genrule.go
index 0c06ae6..0fb3e2d 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -79,15 +79,7 @@
func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
- if ctx.DeviceConfig().VndkVersion() == "" {
- return true
- }
-
- if ctx.ProductSpecific() {
- return false
- }
-
- return !(ctx.SocSpecific() || ctx.DeviceSpecific())
+ return !(ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific())
}
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -115,26 +107,33 @@
}
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
- if ctx.DeviceConfig().VndkVersion() == "" {
- return nil
- }
-
var variants []string
- if Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
- vndkVersion := ctx.DeviceConfig().VndkVersion()
- // If vndkVersion is current, we can always use PlatformVndkVersion.
- // If not, we assume modules under proprietary paths are compatible for
- // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
- // PLATFORM_VNDK_VERSION.
- if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
- variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
- } else {
- variants = append(variants, VendorVariationPrefix+vndkVersion)
- }
- }
+ vndkVersion := ctx.DeviceConfig().VndkVersion()
+ vendorVariantRequired := Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific()
+ productVariantRequired := Bool(g.Product_available) || ctx.ProductSpecific()
- if Bool(g.Product_available) || ctx.ProductSpecific() {
- variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ if vndkVersion == "" {
+ if vendorVariantRequired {
+ variants = append(variants, VendorVariation)
+ }
+ if productVariantRequired {
+ variants = append(variants, ProductVariation)
+ }
+ } else {
+ if vendorVariantRequired {
+ // If vndkVersion is current, we can always use PlatformVndkVersion.
+ // If not, we assume modules under proprietary paths are compatible for
+ // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
+ // PLATFORM_VNDK_VERSION.
+ if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
+ variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ } else {
+ variants = append(variants, VendorVariationPrefix+vndkVersion)
+ }
+ }
+ if productVariantRequired {
+ variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ }
}
return variants
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index 9295244..05c644f 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -16,6 +16,7 @@
import (
"reflect"
+ "slices"
"testing"
"android/soong/android"
@@ -186,3 +187,26 @@
})
}
}
+
+func TestVendorProductVariantGenrule(t *testing.T) {
+ bp := `
+ cc_genrule {
+ name: "gen",
+ tool_files: ["tool"],
+ cmd: "$(location tool) $(in) $(out)",
+ out: ["out"],
+ vendor_available: true,
+ product_available: true,
+ }
+ `
+ t.Helper()
+ ctx := PrepareForTestWithCcIncludeVndk.RunTestWithBp(t, bp)
+
+ variants := ctx.ModuleVariantsForTests("gen")
+ if !slices.Contains(variants, "android_vendor_arm64_armv8-a") {
+ t.Errorf(`expected vendor variant, but does not exist in %v`, variants)
+ }
+ if !slices.Contains(variants, "android_product_arm64_armv8-a") {
+ t.Errorf(`expected product variant, but does not exist in %v`, variants)
+ }
+}
diff --git a/cc/image.go b/cc/image.go
index 4c0c722..d02a2f3 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -42,10 +42,18 @@
)
const (
+ // VendorVariation is the variant name used for /vendor code that does not
+ // compile against the VNDK.
+ VendorVariation = "vendor"
+
// VendorVariationPrefix is the variant prefix used for /vendor code that compiles
// against the VNDK.
VendorVariationPrefix = "vendor."
+ // ProductVariation is the variant name used for /product code that does not
+ // compile against the VNDK.
+ ProductVariation = "product"
+
// ProductVariationPrefix is the variant prefix used for /product code that compiles
// against the VNDK.
ProductVariationPrefix = "product."
@@ -112,12 +120,18 @@
// Returns true if the module is "product" variant. Usually these modules are installed in /product
func (c *Module) InProduct() bool {
- return c.Properties.ImageVariationPrefix == ProductVariationPrefix
+ return c.Properties.ImageVariation == ProductVariation
}
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
func (c *Module) InVendor() bool {
- return c.Properties.ImageVariationPrefix == VendorVariationPrefix
+ return c.Properties.ImageVariation == VendorVariation
+}
+
+// Returns true if the module is "vendor" or "product" variant. This replaces previous UseVndk usages
+// which were misused to check if the module variant is vendor or product.
+func (c *Module) InVendorOrProduct() bool {
+ return c.InVendor() || c.InProduct()
}
func (c *Module) InRamdisk() bool {
@@ -439,10 +453,8 @@
// and vendor and product variants will be created with LLNDK stubs.
// The LLNDK libraries need vendor variants even if there is no VNDK.
coreVariantNeeded = true
- if platformVndkVersion != "" {
- vendorVariants = append(vendorVariants, platformVndkVersion)
- productVariants = append(productVariants, platformVndkVersion)
- }
+ vendorVariants = append(vendorVariants, platformVndkVersion)
+ productVariants = append(productVariants, platformVndkVersion)
// Generate vendor variants for boardVndkVersion only if the VNDK snapshot does not
// provide the LLNDK stub libraries.
if needVndkVersionVendorVariantForLlndk {
@@ -453,13 +465,7 @@
// for system and product.
coreVariantNeeded = true
vendorVariants = append(vendorVariants, boardVndkVersion)
- if platformVndkVersion != "" {
- productVariants = append(productVariants, platformVndkVersion)
- }
- } else if boardVndkVersion == "" {
- // If the device isn't compiling against the VNDK, we always
- // use the core mode.
- coreVariantNeeded = true
+ productVariants = append(productVariants, platformVndkVersion)
} else if m.IsSnapshotPrebuilt() {
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
// PRODUCT_EXTRA_VNDK_VERSIONS.
@@ -557,11 +563,19 @@
}
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
- m.AppendExtraVariant(VendorVariationPrefix + variant)
+ if variant == "" {
+ m.AppendExtraVariant(VendorVariation)
+ } else {
+ m.AppendExtraVariant(VendorVariationPrefix + variant)
+ }
}
for _, variant := range android.FirstUniqueStrings(productVariants) {
- m.AppendExtraVariant(ProductVariationPrefix + variant)
+ if variant == "" {
+ m.AppendExtraVariant(ProductVariation)
+ } else {
+ m.AppendExtraVariant(ProductVariationPrefix + variant)
+ }
}
m.SetRamdiskVariantNeeded(ramdiskVariantNeeded)
@@ -672,9 +686,12 @@
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
- } else if strings.HasPrefix(variant, VendorVariationPrefix) {
- m.Properties.ImageVariationPrefix = VendorVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
+ } else if strings.HasPrefix(variant, VendorVariation) {
+ m.Properties.ImageVariation = VendorVariation
+
+ if strings.HasPrefix(variant, VendorVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
+ }
squashVendorSrcs(m)
// Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
@@ -684,9 +701,11 @@
m.Properties.HideFromMake = true
m.HideFromMake()
}
- } else if strings.HasPrefix(variant, ProductVariationPrefix) {
- m.Properties.ImageVariationPrefix = ProductVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ } else if strings.HasPrefix(variant, ProductVariation) {
+ m.Properties.ImageVariation = ProductVariation
+ if strings.HasPrefix(variant, ProductVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ }
squashProductSrcs(m)
}
diff --git a/cc/installer.go b/cc/installer.go
index a0b6295..30f9612 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -87,7 +87,7 @@
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if installer.location == InstallInData && ctx.useVndk() {
+ if installer.location == InstallInData && ctx.InVendorOrProduct() {
if ctx.inProduct() {
dir = filepath.Join(dir, "product")
} else {
diff --git a/cc/kernel_headers.go b/cc/kernel_headers.go
index 9ea988a..4f685be 100644
--- a/cc/kernel_headers.go
+++ b/cc/kernel_headers.go
@@ -34,7 +34,7 @@
// kernel_headers retrieves the list of kernel headers directories from
// TARGET_BOARD_KERNEL_HEADERS and TARGET_PRODUCT_KERNEL_HEADERS variables in
// a makefile for compilation. See
-// https://android.googlesource.com/platform/build/+/master/core/config.mk
+// https://android.googlesource.com/platform/build/+/main/core/config.mk
// for more details on them.
func kernelHeadersFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
diff --git a/cc/library.go b/cc/library.go
index 592f70f..28eb80b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -24,6 +24,7 @@
"sync"
"android/soong/android"
+
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
@@ -1342,12 +1343,10 @@
fileName+".lsdump")
}
-func getRefAbiDumpDir(isNdk, isVndk bool) string {
+func getRefAbiDumpDir(isNdk bool) string {
var dirName string
if isNdk {
dirName = "ndk"
- } else if isVndk {
- dirName = "vndk"
} else {
dirName = "platform"
}
@@ -1373,11 +1372,8 @@
}
}
-func currRefAbiDumpVersion(ctx ModuleContext, isVndk bool) string {
- if isVndk {
- // Each version of VNDK is independent, so follow the VNDK version which is the codename or PLATFORM_SDK_VERSION.
- return ctx.Module().(*Module).VndkVersion()
- } else if ctx.Config().PlatformSdkFinal() {
+func currRefAbiDumpVersion(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.
return ctx.Config().PlatformSdkVersion().String()
@@ -1419,20 +1415,20 @@
func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
baseName string, isLlndkOrNdk bool, sourceVersion, prevVersion string) {
- errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/master/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "."
+ errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/main/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "."
library.sourceAbiDiff(ctx, referenceDump, baseName, prevVersion,
isLlndkOrNdk, true /* allowExtensions */, sourceVersion, errorMessage)
}
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
- baseName string, isLlndkOrNdk, allowExtensions bool) {
+ baseName 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, "",
- isLlndkOrNdk, allowExtensions, "current", errorMessage)
+ isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
}
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
@@ -1462,10 +1458,9 @@
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
// The logic must be consistent with classifySourceAbiDump.
- isVndk := ctx.useVndk() && ctx.isVndk()
isNdk := ctx.isNdk(ctx.Config())
isLlndk := ctx.isImplementationForLLNDKPublic()
- currVersion := currRefAbiDumpVersion(ctx, isVndk)
+ currVersion := currRefAbiDumpVersion(ctx)
library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
@@ -1474,26 +1469,24 @@
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
- dumpDir := getRefAbiDumpDir(isNdk, isVndk)
+ dumpDir := getRefAbiDumpDir(isNdk)
binderBitness := ctx.DeviceConfig().BinderBitness()
- // If NDK or PLATFORM library, check against previous version ABI.
- if !isVndk {
- 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 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, ctx.IsVndkExt())
+ fileName, isLlndk || isNdk)
}
// Check against the opt-in reference dumps.
for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs {
@@ -1777,7 +1770,7 @@
}
if Bool(library.Properties.Static_ndk_lib) && library.static() &&
- !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
+ !ctx.InVendorOrProduct() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() &&
ctx.isForPlatform() && !ctx.isPreventInstall() {
installPath := getUnversionedLibraryInstallPath(ctx).Join(ctx, file.Base())
@@ -1897,7 +1890,7 @@
return nil
}
- if library.hasLLNDKStubs() && ctx.Module().(*Module).UseVndk() {
+ if library.hasLLNDKStubs() && ctx.Module().(*Module).InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 1183b29..aab6664 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -48,7 +48,7 @@
return
}
- if m.UseVndk() && apiLibrary.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && apiLibrary.hasLLNDKStubs() {
// Add LLNDK variant dependency
if inList("llndk", apiLibrary.properties.Variants) {
variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "")
@@ -193,7 +193,7 @@
}
}
- if m.UseVndk() && d.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && d.hasLLNDKStubs() {
// LLNDK variant
load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", ""))
} else if m.IsSdkVariant() {
@@ -312,7 +312,7 @@
}
}
- if d.hasLLNDKStubs() && m.UseVndk() {
+ if d.hasLLNDKStubs() && m.InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/linkable.go b/cc/linkable.go
index a009c6c..6f22091 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -218,6 +218,7 @@
ProductSpecific() bool
InProduct() bool
SdkAndPlatformVariantVisibleToMake() bool
+ InVendorOrProduct() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 0fbc8d0..567cb7c 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -182,7 +182,7 @@
}
// Like ndk_headers, but preprocesses the headers with the bionic versioner:
-// https://android.googlesource.com/platform/bionic/+/master/tools/versioner/README.md.
+// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md.
//
// Unlike ndk_headers, we don't operate on a list of sources but rather a whole directory, the
// module does not have the srcs property, and operates on a full directory (the `from` property).
@@ -267,7 +267,7 @@
}
// versioned_ndk_headers preprocesses the headers with the bionic versioner:
-// https://android.googlesource.com/platform/bionic/+/master/tools/versioner/README.md.
+// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md.
// Unlike the ndk_headers soong module, versioned_ndk_headers operates on a
// directory level specified in `from` property. This is only used to process
// the bionic/libc/include directory.
diff --git a/cc/sabi.go b/cc/sabi.go
index 1310685..9f5781f 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -105,30 +105,17 @@
if headerAbiChecker.explicitlyDisabled() {
return ""
}
- // Return NDK if the library is both NDK and LLNDK.
- if m.IsNdk(ctx.Config()) {
- return "NDK"
- }
- if m.isImplementationForLLNDKPublic() {
- return "LLNDK"
- }
- if m.UseVndk() && m.IsVndk() && !m.IsVndkPrivate() {
- if m.IsVndkSp() {
- if m.IsVndkExt() {
- return "VNDK-SP-ext"
- } else {
- return "VNDK-SP"
- }
- } else {
- if m.IsVndkExt() {
- return "VNDK-ext"
- } else {
- return "VNDK-core"
- }
+ if !m.InProduct() && !m.InVendor() {
+ // Return NDK if the library is both NDK and LLNDK.
+ if m.IsNdk(ctx.Config()) {
+ return "NDK"
}
- }
- if m.library.hasStubsVariants() && !m.InProduct() && !m.InVendor() {
- return "PLATFORM"
+ if m.isImplementationForLLNDKPublic() {
+ return "LLNDK"
+ }
+ if m.library.hasStubsVariants() {
+ return "PLATFORM"
+ }
}
if headerAbiChecker.enabled() {
if m.InProduct() {
diff --git a/cc/symbolfile/__init__.py b/cc/symbolfile/__init__.py
index 94c8567..345e9f9 100644
--- a/cc/symbolfile/__init__.py
+++ b/cc/symbolfile/__init__.py
@@ -46,6 +46,15 @@
Arch('x86_64'),
)
+# TODO: it would be nice to dedupe with 'has_*_tag' property methods
+SUPPORTED_TAGS = ALL_ARCHITECTURES + (
+ Tag('apex'),
+ Tag('llndk'),
+ Tag('platform-only'),
+ Tag('systemapi'),
+ Tag('var'),
+ Tag('weak'),
+)
# Arbitrary magic number. We use the same one in api-level.h for this purpose.
FUTURE_API_LEVEL = 10000
@@ -136,6 +145,8 @@
def is_api_level_tag(tag: Tag) -> bool:
"""Returns true if this tag has an API level that may need decoding."""
+ if tag.startswith('llndk-deprecated='):
+ return True
if tag.startswith('introduced='):
return True
if tag.startswith('introduced-'):
@@ -170,6 +181,9 @@
ParseError: An unknown version name was found in a tag.
"""
if not is_api_level_tag(tag):
+ if tag not in SUPPORTED_TAGS:
+ raise ParseError(f'Unsupported tag: {tag}')
+
return tag
name, value = split_tag(tag)
diff --git a/cc/symbolfile/test_symbolfile.py b/cc/symbolfile/test_symbolfile.py
index 856b9d7..83becc2 100644
--- a/cc/symbolfile/test_symbolfile.py
+++ b/cc/symbolfile/test_symbolfile.py
@@ -40,10 +40,20 @@
self.assertEqual(Tags(), symbolfile.get_tags('foo bar baz', {}))
def test_get_tags(self) -> None:
- self.assertEqual(Tags.from_strs(['foo', 'bar']),
- symbolfile.get_tags('# foo bar', {}))
- self.assertEqual(Tags.from_strs(['bar', 'baz']),
- symbolfile.get_tags('foo # bar baz', {}))
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']),
+ symbolfile.get_tags('# llndk apex', {}))
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']),
+ symbolfile.get_tags('foo # llndk apex', {}))
+
+ def test_get_unrecognized_tags(self) -> None:
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# bar', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('foo # bar', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# #', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# apex # llndk', {})
def test_split_tag(self) -> None:
self.assertTupleEqual(('foo', 'bar'),
@@ -425,13 +435,13 @@
def test_parse_version(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
- VERSION_1 { # foo bar
+ VERSION_1 { # weak introduced=35
baz;
- qux; # woodly doodly
+ qux; # apex llndk
};
VERSION_2 {
- } VERSION_1; # asdf
+ } VERSION_1; # not-a-tag
"""))
parser = symbolfile.SymbolFileParser(input_file, {}, self.filter)
@@ -439,11 +449,11 @@
version = parser.parse_version()
self.assertEqual('VERSION_1', version.name)
self.assertIsNone(version.base)
- self.assertEqual(Tags.from_strs(['foo', 'bar']), version.tags)
+ self.assertEqual(Tags.from_strs(['weak', 'introduced=35']), version.tags)
expected_symbols = [
Symbol('baz', Tags()),
- Symbol('qux', Tags.from_strs(['woodly', 'doodly'])),
+ Symbol('qux', Tags.from_strs(['apex', 'llndk'])),
]
self.assertEqual(expected_symbols, version.symbols)
@@ -476,7 +486,7 @@
def test_parse_symbol(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
foo;
- bar; # baz qux
+ bar; # llndk apex
"""))
parser = symbolfile.SymbolFileParser(input_file, {}, self.filter)
@@ -488,7 +498,7 @@
parser.next_line()
symbol = parser.parse_symbol()
self.assertEqual('bar', symbol.name)
- self.assertEqual(Tags.from_strs(['baz', 'qux']), symbol.tags)
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']), symbol.tags)
def test_wildcard_symbol_global(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
@@ -537,13 +547,13 @@
hidden1;
global:
foo;
- bar; # baz
+ bar; # llndk
};
- VERSION_2 { # wasd
+ VERSION_2 { # weak
# Implicit global scope.
woodly;
- doodly; # asdf
+ doodly; # llndk
local:
qwerty;
} VERSION_1;
@@ -554,12 +564,12 @@
expected = [
symbolfile.Version('VERSION_1', None, Tags(), [
Symbol('foo', Tags()),
- Symbol('bar', Tags.from_strs(['baz'])),
+ Symbol('bar', Tags.from_strs(['llndk'])),
]),
symbolfile.Version(
- 'VERSION_2', 'VERSION_1', Tags.from_strs(['wasd']), [
+ 'VERSION_2', 'VERSION_1', Tags.from_strs(['weak']), [
Symbol('woodly', Tags()),
- Symbol('doodly', Tags.from_strs(['asdf'])),
+ Symbol('doodly', Tags.from_strs(['llndk'])),
]),
]
diff --git a/cc/test.go b/cc/test.go
index 347d7c9..3a1a3af 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -430,8 +430,7 @@
}
})
- useVendor := ctx.inVendor() || ctx.useVndk()
- testInstallBase := getTestInstallBase(useVendor)
+ testInstallBase := getTestInstallBase(ctx.InVendorOrProduct())
configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
diff --git a/cc/testing.go b/cc/testing.go
index b1583f1..bac41e7 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -571,6 +571,7 @@
android.MockFS{
"defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.map.txt": nil,
+ "defaults/cc/common/libft2.map.txt": nil,
"defaults/cc/common/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil,
diff --git a/cc/tidy_test.go b/cc/tidy_test.go
index 7036ecb..9481778 100644
--- a/cc/tidy_test.go
+++ b/cc/tidy_test.go
@@ -244,3 +244,30 @@
})
}
}
+
+func TestWithGeneratedCode(t *testing.T) {
+ bp := `
+ cc_library_shared {
+ name: "libfoo",
+ srcs: ["foo_1.y", "foo_2.yy", "foo_3.l", "foo_4.ll", "foo_5.proto",
+ "foo_6.aidl", "foo_7.rscript", "foo_8.fs", "foo_9.sysprop",
+ "foo_src.cpp"],
+ tidy: true,
+ }`
+ variant := "android_arm64_armv8-a_shared"
+
+ testEnv := map[string]string{}
+ testEnv["ALLOW_LOCAL_TIDY_TRUE"] = "1"
+
+ ctx := android.GroupFixturePreparers(prepareForCcTest, android.FixtureMergeEnv(testEnv)).RunTestWithBp(t, bp)
+
+ t.Run("tidy should be only run for source code, not for generated code", func(t *testing.T) {
+ depFiles := ctx.ModuleForTests("libfoo", variant).Rule("ld").Validations.Strings()
+
+ tidyFileForCpp := "out/soong/.intermediates/libfoo/" + variant + "/obj/foo_src.tidy"
+
+ android.AssertArrayString(t,
+ "only one .tidy file for source code should exist for libfoo",
+ []string{tidyFileForCpp}, depFiles)
+ })
+}
diff --git a/cc/vndk.go b/cc/vndk.go
index b2c6e0d..0e0dba9 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -418,11 +418,11 @@
lib, isLib := m.linker.(*libraryDecorator)
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
- if m.UseVndk() && isLib && lib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
}
- if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
}
diff --git a/cmd/path_interposer/main.go b/cmd/path_interposer/main.go
index 8b9de52..c8c1464 100644
--- a/cmd/path_interposer/main.go
+++ b/cmd/path_interposer/main.go
@@ -140,7 +140,7 @@
defer func() { <-waitForLog }()
}
if config.Error {
- return 1, fmt.Errorf("%q is not allowed to be used. See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.", base)
+ return 1, fmt.Errorf("%q is not allowed to be used. See https://android.googlesource.com/platform/build/+/main/Changes.md#PATH_Tools for more information.", base)
}
}
diff --git a/cmd/path_interposer/main_test.go b/cmd/path_interposer/main_test.go
index c89d623..8ae1d7d 100644
--- a/cmd/path_interposer/main_test.go
+++ b/cmd/path_interposer/main_test.go
@@ -138,7 +138,7 @@
args: []string{"path_interposer_test_not_allowed"},
exitCode: 1,
- err: fmt.Errorf(`"path_interposer_test_not_allowed" is not allowed to be used. See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.`),
+ err: fmt.Errorf(`"path_interposer_test_not_allowed" is not allowed to be used. See https://android.googlesource.com/platform/build/+/main/Changes.md#PATH_Tools for more information.`),
logEntry: "path_interposer_test_not_allowed",
},
}
diff --git a/dexpreopt/DEXPREOPT_IMPLEMENTATION.md b/dexpreopt/DEXPREOPT_IMPLEMENTATION.md
index c3a1730..1cb0add 100644
--- a/dexpreopt/DEXPREOPT_IMPLEMENTATION.md
+++ b/dexpreopt/DEXPREOPT_IMPLEMENTATION.md
@@ -237,22 +237,22 @@
app.
-[make/core/dex_preopt.mk]: https://cs.android.com/android/platform/superproject/+/master:build/make/core/dex_preopt.mk
-[make/core/dex_preopt_config.mk]: https://cs.android.com/android/platform/superproject/+/master:build/make/core/dex_preopt_config.mk
-[make/core/dex_preopt_config_merger.py]: https://cs.android.com/android/platform/superproject/+/master:build/make/core/dex_preopt_config_merger.py
-[make/core/dex_preopt_odex_install.mk]: https://cs.android.com/android/platform/superproject/+/master:build/make/core/dex_preopt_odex_install.mk
-[soong/dexpreopt]: https://cs.android.com/android/platform/superproject/+/master:build/soong/dexpreopt
-[soong/dexpreopt/class_loader_context.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/dexpreopt/class_loader_context.go
-[soong/dexpreopt/config.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/dexpreopt/config.go
-[soong/dexpreopt/dexpreopt.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/dexpreopt/dexpreopt.go
-[soong/java]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java
-[soong/java/app.go:deps]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/app.go?q=%22func%20\(u%20*usesLibrary\)%20deps%22
-[soong/java/app.go:verifyUsesLibraries]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/app.go?q=%22func%20\(u%20*usesLibrary\)%20verifyUsesLibraries%22
-[soong/java/bootclasspath_fragment.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/bootclasspath_fragment.go
-[soong/java/dexpreopt.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/dexpreopt.go
-[soong/java/dexpreopt_bootjars.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/dexpreopt_bootjars.go
-[soong/java/dexpreopt_config.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/dexpreopt_config.go
-[soong/java/java.go:addCLCFromDep]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/java.go?q=%22func%20addCLCfromDep%22
-[soong/java/platform_bootclasspath.go]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/platform_bootclasspath.go
-[soong/scripts/construct_context.py]: https://cs.android.com/android/platform/superproject/+/master:build/soong/scripts/construct_context.py
-[soong/scripts/manifest_check.py]: https://cs.android.com/android/platform/superproject/+/master:build/soong/scripts/manifest_check.py
+[make/core/dex_preopt.mk]: https://cs.android.com/android/platform/superproject/+/main:build/make/core/dex_preopt.mk
+[make/core/dex_preopt_config.mk]: https://cs.android.com/android/platform/superproject/+/main:build/make/core/dex_preopt_config.mk
+[make/core/dex_preopt_config_merger.py]: https://cs.android.com/android/platform/superproject/+/main:build/make/core/dex_preopt_config_merger.py
+[make/core/dex_preopt_odex_install.mk]: https://cs.android.com/android/platform/superproject/+/main:build/make/core/dex_preopt_odex_install.mk
+[soong/dexpreopt]: https://cs.android.com/android/platform/superproject/+/main:build/soong/dexpreopt
+[soong/dexpreopt/class_loader_context.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/dexpreopt/class_loader_context.go
+[soong/dexpreopt/config.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/dexpreopt/config.go
+[soong/dexpreopt/dexpreopt.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/dexpreopt/dexpreopt.go
+[soong/java]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java
+[soong/java/app.go:deps]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/app.go?q=%22func%20\(u%20*usesLibrary\)%20deps%22
+[soong/java/app.go:verifyUsesLibraries]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/app.go?q=%22func%20\(u%20*usesLibrary\)%20verifyUsesLibraries%22
+[soong/java/bootclasspath_fragment.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/bootclasspath_fragment.go
+[soong/java/dexpreopt.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/dexpreopt.go
+[soong/java/dexpreopt_bootjars.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/dexpreopt_bootjars.go
+[soong/java/dexpreopt_config.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/dexpreopt_config.go
+[soong/java/java.go:addCLCFromDep]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/java.go?q=%22func%20addCLCfromDep%22
+[soong/java/platform_bootclasspath.go]: https://cs.android.com/android/platform/superproject/+/main:build/soong/java/platform_bootclasspath.go
+[soong/scripts/construct_context.py]: https://cs.android.com/android/platform/superproject/+/main:build/soong/scripts/construct_context.py
+[soong/scripts/manifest_check.py]: https://cs.android.com/android/platform/superproject/+/main:build/soong/scripts/manifest_check.py
diff --git a/docs/best_practices.md b/docs/best_practices.md
index bc760b8..48ed996 100644
--- a/docs/best_practices.md
+++ b/docs/best_practices.md
@@ -285,6 +285,6 @@
and will require ongoing maintenance as the build system is changed; so
plugins should be used only when absolutely required.
-See [art/build/art.go](https://android.googlesource.com/platform/art/+/master/build/art.go)
-or [external/llvm/soong/llvm.go](https://android.googlesource.com/platform/external/llvm/+/master/soong/llvm.go)
+See [art/build/art.go](https://android.googlesource.com/platform/art/+/main/build/art.go)
+or [external/llvm/soong/llvm.go](https://android.googlesource.com/platform/external/llvm/+/main/soong/llvm.go)
for examples of more complex conditionals on product variables or environment variables.
diff --git a/docs/clion.md b/docs/clion.md
index 110891b..8e2c597 100644
--- a/docs/clion.md
+++ b/docs/clion.md
@@ -4,7 +4,7 @@
only. Build should still be done via make/m/mm(a)/mmm(a).
Note: alternatively, you can use
-[aidegen to generate a Clion or VSCode project](https://android.googlesource.com/platform/tools/asuite/+/refs/heads/master/aidegen/README.md)
+[aidegen to generate a Clion or VSCode project](https://android.googlesource.com/platform/tools/asuite/+/refs/heads/main/aidegen/README.md)
with a single command, using the `-i c` flag.
CMakeLists.txt project file generation is enabled via environment variable:
diff --git a/docs/map_files.md b/docs/map_files.md
index 37f91ec..e1ddefc 100644
--- a/docs/map_files.md
+++ b/docs/map_files.md
@@ -5,8 +5,8 @@
semantically meaningful to [gen_stub_libs.py]. For an example of a map file, see
[libc.map.txt].
-[gen_stub_libs.py]: https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/gen_stub_libs.py
-[libc.map.txt]: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/libc.map.txt
+[gen_stub_libs.py]: https://cs.android.com/android/platform/superproject/+/main:build/soong/cc/gen_stub_libs.py
+[libc.map.txt]: https://cs.android.com/android/platform/superproject/+/main:bionic/libc/libc.map.txt
[linker version scripts]: https://www.gnu.org/software/gnulib/manual/html_node/LD-Version-Scripts.html
## Basic format
diff --git a/docs/rbe.md b/docs/rbe.md
index cfe86d7..be60c83 100644
--- a/docs/rbe.md
+++ b/docs/rbe.md
@@ -11,7 +11,7 @@
To enable RBE, you need to set several environment variables before triggering
the build. You can set them through a
-[environment variables config file](https://android.googlesource.com/platform/build/soong/+/master/README.md#environment-variables-config-file).
+[environment variables config file](https://android.googlesource.com/platform/build/soong/+/main/README.md#environment-variables-config-file).
As an example, [build/soong/docs/rbe.json](rbe.json) is a config that enables
RBE in the build. Once the config file is created, you need to let Soong load
the config file by specifying `ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR` environment
diff --git a/docs/tidy.md b/docs/tidy.md
index 2eb8234..ae0ca93 100644
--- a/docs/tidy.md
+++ b/docs/tidy.md
@@ -24,7 +24,7 @@
```
The default global clang-tidy checks and flags are defined in
-[build/soong/cc/config/tidy.go](https://android.googlesource.com/platform/build/soong/+/refs/heads/master/cc/config/tidy.go).
+[build/soong/cc/config/tidy.go](https://android.googlesource.com/platform/build/soong/+/refs/heads/main/cc/config/tidy.go).
## Module clang-tidy properties
@@ -34,7 +34,7 @@
### `tidy`, `tidy_checks`, and `ALLOW_LOCAL_TIDY_TRUE`
For example, in
-[system/bpf/Android.bp](https://android.googlesource.com/platform/system/bpf/+/refs/heads/master/Android.bp),
+[system/bpf/Android.bp](https://android.googlesource.com/platform/system/bpf/+/refs/heads/main/Android.bp),
clang-tidy is enabled explicitly and with a different check list:
```
cc_defaults {
@@ -69,7 +69,7 @@
Some modules might want to disable clang-tidy even when
environment variable `WITH_TIDY=1` is set.
Examples can be found in
-[system/netd/tests/Android.bp](https://android.googlesource.com/platform/system/netd/+/refs/heads/master/tests/Android.bp)
+[system/netd/tests/Android.bp](https://android.googlesource.com/platform/system/netd/+/refs/heads/main/tests/Android.bp)
```
cc_test {
name: "netd_integration_test",
@@ -78,7 +78,7 @@
tidy: false, // cuts test build time by almost 1 minute
```
and in
-[bionic/tests/Android.bp](https://android.googlesource.com/platform/bionic/+/refs/heads/master/tests/Android.bp).
+[bionic/tests/Android.bp](https://android.googlesource.com/platform/bionic/+/refs/heads/main/tests/Android.bp).
```
cc_test_library {
name: "fortify_disabled_for_tidy",
@@ -97,7 +97,7 @@
If a C/C++ module wants to be free of certain clang-tidy warnings,
it can chose those checks to be treated as errors.
For example
-[system/core/libsysutils/Android.bp](https://android.googlesource.com/platform/system/core/+/refs/heads/master/libsysutils/Android.bp)
+[system/core/libsysutils/Android.bp](https://android.googlesource.com/platform/system/core/+/refs/heads/main/libsysutils/Android.bp)
has enabled clang-tidy explicitly, selected its own tidy checks,
and set three groups of tidy checks as errors:
```
@@ -130,7 +130,7 @@
Some other tidy flags examples are `-format-style=` and `-header-filter=`
For example, in
-[art/odrefresh/Android.bp](https://android.googlesource.com/platform/art/+/refs/heads/master/odrefresh/Android.bp),
+[art/odrefresh/Android.bp](https://android.googlesource.com/platform/art/+/refs/heads/main/odrefresh/Android.bp),
we found
```
cc_defaults {
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 66df101..7642378 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -155,6 +155,9 @@
additionalDependencies *android.Paths
makeClass string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
type Defaults struct {
@@ -365,6 +368,7 @@
symlinks: p.properties.Symlinks,
}
p.addInstallRules(ctx, ip)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
type installProperties struct {
@@ -433,11 +437,16 @@
if p.additionalDependencies != nil {
entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
}
+ android.SetAconfigFileMkEntries(p.AndroidModuleBase(), entries, p.mergedAconfigFiles)
},
},
}}
}
+func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
+ return &p.ModuleBase
+}
+
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
p.installDirBase = dirBase
p.AddProperties(&p.properties)
diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go
index 5d7bc2b..47fd8f4 100644
--- a/fuzz/fuzz_common.go
+++ b/fuzz/fuzz_common.go
@@ -525,12 +525,10 @@
builder.Build("create-"+fuzzZip.String(),
"Package "+module.Name()+" for "+archString+"-"+hostOrTargetString)
- // Don't add modules to 'make haiku-rust' that are set to not be
- // exported to the fuzzing infrastructure.
if config := fuzzModule.FuzzProperties.Fuzz_config; config != nil {
if strings.Contains(hostOrTargetString, "host") && !BoolDefault(config.Fuzz_on_haiku_host, true) {
return archDirs[archOs], false
- } else if !BoolDefault(config.Fuzz_on_haiku_device, true) {
+ } else if !strings.Contains(hostOrTargetString, "host") && !BoolDefault(config.Fuzz_on_haiku_device, true) {
return archDirs[archOs], false
}
}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 87f6392..fbda074 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -184,6 +184,9 @@
subName string
subDir string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask
@@ -610,6 +613,24 @@
})
g.outputDeps = android.Paths{phonyFile}
}
+ android.CollectDependencyAconfigFiles(ctx, &g.mergedAconfigFiles)
+}
+
+func (g *Module) AndroidMkEntries() []android.AndroidMkEntries {
+ ret := android.AndroidMkEntries{
+ OutputFile: android.OptionalPathForPath(g.outputFiles[0]),
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ android.SetAconfigFileMkEntries(g.AndroidModuleBase(), entries, g.mergedAconfigFiles)
+ },
+ },
+ }
+
+ return []android.AndroidMkEntries{ret}
+}
+
+func (g *Module) AndroidModuleBase() *android.ModuleBase {
+ return &g.ModuleBase
}
// Collect information for opening IDE project files in java/jdeps.go.
diff --git a/java/Android.bp b/java/Android.bp
index 79cd3f9..2585cd2 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -108,8 +108,9 @@
"prebuilt_apis_test.go",
"proto_test.go",
"rro_test.go",
- "sdk_test.go",
"sdk_library_test.go",
+ "sdk_test.go",
+ "sdk_version_test.go",
"system_modules_test.go",
"systemserver_classpath_fragment_test.go",
"test_spec_test.go",
diff --git a/java/aar.go b/java/aar.go
index eb07e0f..7fc39b6 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -980,6 +980,9 @@
sdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
var _ android.OutputFileProducer = (*AARImport)(nil)
@@ -1274,6 +1277,7 @@
android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: a.jniPackages,
})
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
}
func (a *AARImport) HeaderJars() android.Paths {
@@ -1284,7 +1288,7 @@
return android.Paths{a.classpathFile}
}
-func (a *AARImport) DexJarBuildPath() android.Path {
+func (a *AARImport) DexJarBuildPath(ctx android.ModuleErrorfContext) android.Path {
return nil
}
diff --git a/java/androidmk.go b/java/androidmk.go
index cbf9abb..cc0efe9 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -19,7 +19,6 @@
"io"
"strings"
- "android/soong/aconfig"
"android/soong/android"
"github.com/google/blueprint/proptools"
@@ -129,7 +128,7 @@
if library.dexpreopter.configPath != nil {
entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
}
- aconfig.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
},
},
})
@@ -302,7 +301,7 @@
if len(binary.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
}
- aconfig.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
@@ -455,7 +454,7 @@
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
if app.Name() != "framework-res" {
- aconfig.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
}
},
},
@@ -533,7 +532,7 @@
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
- aconfig.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
})
return entriesList
diff --git a/java/app.go b/java/app.go
index 8b28dac..cb05807 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1639,7 +1639,7 @@
replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
}
clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional,
- lib.DexJarBuildPath().PathOrNil(), lib.DexJarInstallPath(),
+ lib.DexJarBuildPath(ctx).PathOrNil(), lib.DexJarInstallPath(),
lib.ClassLoaderContexts())
} else if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{dep})
diff --git a/java/app_import.go b/java/app_import.go
index ff0f5fe..997274c 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -86,6 +86,9 @@
hideApexVariantFromMake bool
provenanceMetaDataFile android.OutputPath
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
type AndroidAppImportProperties struct {
@@ -377,6 +380,7 @@
artifactPath := android.PathForModuleSrc(ctx, *a.properties.Apk)
a.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, artifactPath, a.installPath)
}
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
// TODO: androidmk converter jni libs
}
diff --git a/java/app_test.go b/java/app_test.go
index 861c047..362bef9 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2109,7 +2109,7 @@
Output("libjni.so").Output.String()
sdkJNI := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").
Output("libjni.so").Output.String()
- vendorJNI := ctx.ModuleForTests("libvendorjni", "android_arm64_armv8-a_shared").
+ vendorJNI := ctx.ModuleForTests("libvendorjni", "android_vendor_arm64_armv8-a_shared").
Output("libvendorjni.so").Output.String()
for _, test := range testCases {
@@ -4347,14 +4347,14 @@
}
aconfig_declarations {
name: "bar",
- package: "com.example.package",
+ package: "com.example.package.bar",
srcs: [
"bar.aconfig",
],
}
aconfig_declarations {
name: "baz",
- package: "com.example.package",
+ package: "com.example.package.baz",
srcs: [
"baz.aconfig",
],
diff --git a/java/base.go b/java/base.go
index 0d3e4db..1ac3d30 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1644,30 +1644,11 @@
}
if ctx.Device() {
- lintSDKVersion := func(apiLevel android.ApiLevel) int {
+ lintSDKVersion := func(apiLevel android.ApiLevel) android.ApiLevel {
if !apiLevel.IsPreview() {
- return apiLevel.FinalInt()
+ return apiLevel
} else {
- // When running metalava, we pass --version-codename. When that value
- // is not REL, metalava will add 1 to the --current-version argument.
- // On old branches, PLATFORM_SDK_VERSION is the latest version (for that
- // branch) and the codename is REL, except potentially on the most
- // recent non-master branch. On that branch, it goes through two other
- // phases before it gets to the phase previously described:
- // - PLATFORM_SDK_VERSION has not been updated yet, and the codename
- // is not rel. This happens for most of the internal branch's life
- // while the branch has been cut but is still under active development.
- // - PLATFORM_SDK_VERSION has been set, but the codename is still not
- // REL. This happens briefly during the release process. During this
- // state the code to add --current-version is commented out, and then
- // that commenting out is reverted after the codename is set to REL.
- // On the master branch, the PLATFORM_SDK_VERSION always represents a
- // prior version and the codename is always non-REL.
- //
- // We need to add one here to match metalava adding 1. Technically
- // this means that in the state described in the second bullet point
- // above, this number is 1 higher than it should be.
- return ctx.Config().PlatformSdkVersion().FinalInt() + 1
+ return ctx.Config().DefaultAppTargetSdk(ctx)
}
}
@@ -1948,7 +1929,7 @@
return android.Paths{j.implementationJarFile}
}
-func (j *Module) DexJarBuildPath() OptionalDexJarPath {
+func (j *Module) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
return j.dexJarFile
}
diff --git a/java/builder.go b/java/builder.go
index d03c8e5..085e7a1 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -274,11 +274,30 @@
` cat $$f; ` +
`done > $out`,
})
+
+ gatherReleasedFlaggedApisRule = pctx.AndroidStaticRule("gatherReleasedFlaggedApisRule",
+ blueprint.RuleParams{
+ Command: `${aconfig} dump-cache --format='{fully_qualified_name}={state:bool}' ` +
+ `--out ${out} ` +
+ `${flags_path} ` +
+ `${filter_args} `,
+ CommandDeps: []string{"${aconfig}"},
+ Description: "aconfig_bool",
+ }, "flags_path", "filter_args")
+
+ generateMetalavaRevertAnnotationsRule = pctx.AndroidStaticRule("generateMetalavaRevertAnnotationsRule",
+ blueprint.RuleParams{
+ Command: `${keep-flagged-apis} ${in} > ${out}`,
+ CommandDeps: []string{"${keep-flagged-apis}"},
+ })
)
func init() {
pctx.Import("android/soong/android")
pctx.Import("android/soong/java/config")
+
+ pctx.HostBinToolVariable("aconfig", "aconfig")
+ pctx.HostBinToolVariable("keep-flagged-apis", "keep-flagged-apis")
}
type javaBuilderFlags struct {
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index 834651f..efd13b8 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -151,7 +151,7 @@
return d.implementationAndResourceJars
}
-func (d *DeviceHostConverter) DexJarBuildPath() android.Path {
+func (d *DeviceHostConverter) DexJarBuildPath(ctx android.ModuleErrorfContext) android.Path {
return nil
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 138c9c3..7a61034 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -208,6 +208,8 @@
docZip android.WritablePath
stubsSrcJar android.WritablePath
+
+ exportableStubsSrcJar android.WritablePath
}
func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
@@ -397,6 +399,15 @@
sm := module.(SystemModulesProvider)
outputDir, outputDeps := sm.OutputDirAndDeps()
deps.systemModules = &systemModules{outputDir, outputDeps}
+ case aconfigDeclarationTag:
+ if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPath)
+ } else {
+ ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
+ "flags_packages property, but %s is not aconfig_declarations module type",
+ module.Name(),
+ )
+ }
}
})
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
diff --git a/java/droidstubs.go b/java/droidstubs.go
index e7ccc1b..04e6be8 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -30,6 +30,28 @@
// The values allowed for Droidstubs' Api_levels_sdk_type
var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"}
+type StubsType int
+
+const (
+ Everything StubsType = iota
+ Runtime
+ Exportable
+ Unavailable
+)
+
+func (s StubsType) String() string {
+ switch s {
+ case Everything:
+ return "everything"
+ case Runtime:
+ return "runtime"
+ case Exportable:
+ return "exportable"
+ default:
+ return ""
+ }
+}
+
func init() {
RegisterStubsBuildComponents(android.InitRegistrationContext)
}
@@ -66,6 +88,17 @@
metadataZip android.WritablePath
metadataDir android.WritablePath
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
+
+ exportableApiFile android.WritablePath
+ exportableRemovedApiFile android.WritablePath
+ exportableNullabilityWarningsFile android.WritablePath
+ exportableAnnotationsZip android.WritablePath
+ exportableApiVersionsXml android.WritablePath
+ exportableMetadataZip android.WritablePath
+ exportableMetadataDir android.WritablePath
}
type DroidstubsProperties struct {
@@ -151,6 +184,10 @@
// API surface of this module. If set, the module contributes to an API surface.
// For the full list of available API surfaces, refer to soong/android/sdk_version.go
Api_surface *string
+
+ // a list of aconfig_declarations module names that the stubs generated in this module
+ // depend on.
+ Aconfig_declarations []string
}
// Used by xsd_config
@@ -175,6 +212,36 @@
CurrentApiTimestamp() android.Path
}
+type annotationFlagsParams struct {
+ migratingNullability bool
+ validatingNullability bool
+ nullabilityWarningsFile android.WritablePath
+ annotationsZip android.WritablePath
+}
+type stubsCommandParams struct {
+ srcJarDir android.ModuleOutPath
+ stubsDir android.OptionalPath
+ stubsSrcJar android.WritablePath
+ metadataZip android.WritablePath
+ metadataDir android.WritablePath
+ apiVersionsXml android.WritablePath
+ nullabilityWarningsFile android.WritablePath
+ annotationsZip android.WritablePath
+ 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
+}
+
// droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be
// documented, filtering out hidden classes and methods. The resulting .java files are intended to be passed to
// a droiddoc module to generate documentation.
@@ -207,21 +274,55 @@
return module
}
+func getStubsTypeAndTag(tag string) (StubsType, string, error) {
+ if len(tag) == 0 {
+ return Everything, "", nil
+ }
+ if tag[0] != '.' {
+ return Unavailable, "", fmt.Errorf("tag must begin with \".\"")
+ }
+
+ stubsType := Everything
+ // Check if the tag has a stubs type prefix (e.g. ".exportable")
+ for st := Everything; st <= Exportable; st++ {
+ if strings.HasPrefix(tag, "."+st.String()) {
+ stubsType = st
+ }
+ }
+
+ return stubsType, strings.TrimPrefix(tag, "."+stubsType.String()), nil
+}
+
+// Droidstubs' tag supports specifying with the stubs type.
+// While supporting the pre-existing tags, it also supports tags with
+// the stubs type prefix. Some examples are shown below:
+// {.annotations.zip} - pre-existing behavior. Returns the path to the
+// annotation zip.
+// {.exportable} - Returns the path to the exportable stubs src jar.
+// {.exportable.annotations.zip} - Returns the path to the exportable
+// annotations zip file.
+// {.runtime.api_versions.xml} - Runtime stubs does not generate api versions
+// xml file. For unsupported combinations, the default everything output file
+// is returned.
func (d *Droidstubs) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
+ stubsType, prefixRemovedTag, err := getStubsTypeAndTag(tag)
+ if err != nil {
+ return nil, err
+ }
+ switch prefixRemovedTag {
case "":
- return android.Paths{d.stubsSrcJar}, nil
+ return d.StubsSrcJarWithStubsType(stubsType)
case ".docs.zip":
- return android.Paths{d.docZip}, nil
+ return d.DocZipWithStubsType(stubsType)
case ".api.txt", android.DefaultDistTag:
// This is the default dist path for dist properties that have no tag property.
- return android.Paths{d.apiFile}, nil
+ return d.ApiFilePathWithStubsType(stubsType)
case ".removed-api.txt":
- return android.Paths{d.removedApiFile}, nil
+ return d.RemovedApiFilePathWithStubsType(stubsType)
case ".annotations.zip":
- return android.Paths{d.annotationsZip}, nil
+ return d.AnnotationsZipWithStubsType(stubsType)
case ".api_versions.xml":
- return android.Paths{d.apiVersionsXml}, nil
+ return d.ApiVersionsXmlFilePathWithStubsType(stubsType)
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
@@ -231,18 +332,96 @@
return d.annotationsZip
}
+func (d *Droidstubs) ExportableAnnotationsZip() android.Path {
+ return d.exportableAnnotationsZip
+}
+
+func (d *Droidstubs) AnnotationsZipWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.AnnotationsZip()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableAnnotationsZip()}, nil
+ default:
+ return nil, fmt.Errorf("annotations zip not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) ApiFilePath() android.Path {
return d.apiFile
}
+func (d *Droidstubs) ExportableApiFilePath() android.Path {
+ return d.exportableApiFile
+}
+
+func (d *Droidstubs) ApiFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.ApiFilePath()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableApiFilePath()}, nil
+ default:
+ return nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
+func (d *Droidstubs) ApiVersionsXmlFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.apiVersionsXml}, nil
+ default:
+ return nil, fmt.Errorf("api versions xml file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
+func (d *Droidstubs) DocZipWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.docZip}, nil
+ default:
+ return nil, fmt.Errorf("docs zip not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) RemovedApiFilePath() android.Path {
return d.removedApiFile
}
+func (d *Droidstubs) ExportableRemovedApiFilePath() android.Path {
+ return d.exportableRemovedApiFile
+}
+
+func (d *Droidstubs) RemovedApiFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.RemovedApiFilePath()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableRemovedApiFilePath()}, nil
+ default:
+ return nil, fmt.Errorf("removed api file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) StubsSrcJar() android.Path {
return d.stubsSrcJar
}
+func (d *Droidstubs) ExportableStubsSrcJar() android.Path {
+ return d.exportableStubsSrcJar
+}
+
+func (d *Droidstubs) StubsSrcJarWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.StubsSrcJar()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableStubsSrcJar()}, nil
+ default:
+ return nil, fmt.Errorf("stubs srcjar not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) CurrentApiTimestamp() android.Path {
return d.checkCurrentApiTimestamp
}
@@ -274,41 +453,52 @@
}
}
+ if len(d.properties.Aconfig_declarations) != 0 {
+ for _, aconfigDeclarationModuleName := range d.properties.Aconfig_declarations {
+ ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfigDeclarationModuleName)
+ }
+ }
+
if d.properties.Api_levels_module != nil {
ctx.AddDependency(ctx.Module(), metalavaAPILevelsModuleTag, proptools.String(d.properties.Api_levels_module))
}
}
-func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath) {
- if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
- apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
- String(d.properties.Api_filename) != "" {
+func (d *Droidstubs) sdkValuesFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, metadataDir android.WritablePath) {
+ cmd.FlagWithArg("--sdk-values ", metadataDir.String())
+}
+
+func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath, stubsType StubsType, checkApi bool) {
+ if checkApi || String(d.properties.Api_filename) != "" {
filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
- uncheckedApiFile := android.PathForModuleOut(ctx, "metalava", filename)
+ uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--api ", uncheckedApiFile)
- d.apiFile = uncheckedApiFile
+
+ if stubsType == Everything {
+ d.apiFile = uncheckedApiFile
+ } else if stubsType == Exportable {
+ d.exportableApiFile = uncheckedApiFile
+ }
} else if sourceApiFile := proptools.String(d.properties.Check_api.Current.Api_file); sourceApiFile != "" {
// If check api is disabled then make the source file available for export.
d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile)
}
- if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
- apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
- String(d.properties.Removed_api_filename) != "" {
+ if checkApi || String(d.properties.Removed_api_filename) != "" {
filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt")
- uncheckedRemovedFile := android.PathForModuleOut(ctx, "metalava", filename)
+ uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile)
- d.removedApiFile = uncheckedRemovedFile
+
+ if stubsType == Everything {
+ d.removedApiFile = uncheckedRemovedFile
+ } else if stubsType == Exportable {
+ d.exportableRemovedApiFile = uncheckedRemovedFile
+ }
} else if sourceRemovedApiFile := proptools.String(d.properties.Check_api.Current.Removed_api_file); sourceRemovedApiFile != "" {
// If check api is disabled then make the source removed api file available for export.
d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile)
}
- if Bool(d.properties.Write_sdk_values) {
- d.metadataDir = android.PathForModuleOut(ctx, "metalava", "metadata")
- cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
- }
-
if stubsDir.Valid() {
if Bool(d.properties.Create_doc_stubs) {
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
@@ -321,16 +511,11 @@
}
}
-func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) {
if Bool(d.properties.Annotations_enabled) {
cmd.Flag(config.MetalavaAnnotationsFlags)
- validatingNullability :=
- strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
- String(d.properties.Validate_nullability_from_list) != ""
-
- migratingNullability := String(d.properties.Previous_api) != ""
- if migratingNullability {
+ if params.migratingNullability {
previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
cmd.FlagWithInput("--migrate-nullness ", previousApi)
}
@@ -339,13 +524,11 @@
cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
}
- if validatingNullability {
- d.nullabilityWarningsFile = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"_nullability_warnings.txt")
- cmd.FlagWithOutput("--nullability-warnings-txt ", d.nullabilityWarningsFile)
+ if params.validatingNullability {
+ cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
}
- d.annotationsZip = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"_annotations.zip")
- cmd.FlagWithOutput("--extract-annotations ", d.annotationsZip)
+ cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip)
if len(d.properties.Merge_annotations_dirs) != 0 {
d.mergeAnnoDirFlags(ctx, cmd)
@@ -377,10 +560,10 @@
})
}
-func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
var apiVersions android.Path
if proptools.Bool(d.properties.Api_levels_annotations_enabled) {
- d.apiLevelsGenerationFlags(ctx, cmd)
+ d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
apiVersions = d.apiVersionsXml
} else {
ctx.VisitDirectDepsWithTag(metalavaAPILevelsModuleTag, func(m android.Module) {
@@ -399,14 +582,13 @@
}
}
-func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
if len(d.properties.Api_levels_annotations_dirs) == 0 {
ctx.PropertyErrorf("api_levels_annotations_dirs",
"has to be non-empty if api levels annotations was enabled!")
}
- d.apiVersionsXml = android.PathForModuleOut(ctx, "metalava", "api-versions.xml")
- cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml)
+ cmd.FlagWithOutput("--generate-api-levels ", apiVersionsXml)
filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar")
@@ -538,47 +720,91 @@
return cmd
}
-func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- deps := d.Javadoc.collectDeps(ctx)
+// Pass flagged apis related flags to metalava. When aconfig_declarations property is not
+// defined for a module, simply revert all flagged apis annotations. If aconfig_declarations
+// property is defined, apply transformations and only revert the flagged apis that are not
+// enabled via release configurations and are not specified in aconfig_declarations
+func (d *Droidstubs) generateRevertAnnotationArgs(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, aconfigFlagsPaths android.Paths) {
- javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), android.SdkContext(d))
+ if len(aconfigFlagsPaths) == 0 {
+ cmd.Flag("--revert-annotation android.annotation.FlaggedApi")
+ return
+ }
- // Create rule for metalava
+ releasedFlaggedApisFile := android.PathForModuleOut(ctx, fmt.Sprintf("released-flagged-apis-%s.txt", stubsType.String()))
+ revertAnnotationsFile := android.PathForModuleOut(ctx, fmt.Sprintf("revert-annotations-%s.txt", stubsType.String()))
- srcJarDir := android.PathForModuleOut(ctx, "metalava", "srcjars")
+ var filterArgs string
+ switch stubsType {
+ // No flagged apis specific flags need to be passed to metalava when generating
+ // everything stubs
+ case Everything:
+ return
- rule := android.NewRuleBuilder(pctx, ctx)
+ case Runtime:
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY' --filter='permission:READ_WRITE'"
- rule.Sbox(android.PathForModuleOut(ctx, "metalava"),
- android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
- SandboxInputs()
+ case Exportable:
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY'"
+ }
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: gatherReleasedFlaggedApisRule,
+ Inputs: aconfigFlagsPaths,
+ Output: releasedFlaggedApisFile,
+ Description: fmt.Sprintf("%s gather aconfig flags", stubsType),
+ Args: map[string]string{
+ "flags_path": android.JoinPathsWithPrefix(aconfigFlagsPaths, "--cache "),
+ "filter_args": filterArgs,
+ },
+ })
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: generateMetalavaRevertAnnotationsRule,
+ Input: releasedFlaggedApisFile,
+ Output: revertAnnotationsFile,
+ Description: fmt.Sprintf("%s revert annotations", stubsType),
+ })
+
+ cmd.FlagWithInput("@", revertAnnotationsFile)
+}
+
+func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
+ params stubsCommandParams) *android.RuleBuilderCommand {
if BoolDefault(d.properties.High_mem, false) {
// This metalava run uses lots of memory, restrict the number of metalava jobs that can run in parallel.
rule.HighMem()
}
- generateStubs := BoolDefault(d.properties.Generate_stubs, true)
- var stubsDir android.OptionalPath
- if generateStubs {
- d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-"+"stubs.srcjar")
- stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, "metalava", "stubsDir"))
- rule.Command().Text("rm -rf").Text(stubsDir.String())
- rule.Command().Text("mkdir -p").Text(stubsDir.String())
+ if params.stubConfig.generateStubs {
+ rule.Command().Text("rm -rf").Text(params.stubsDir.String())
+ rule.Command().Text("mkdir -p").Text(params.stubsDir.String())
}
- srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
+ srcJarList := zipSyncCmd(ctx, rule, params.srcJarDir, d.Javadoc.srcJars)
- homeDir := android.PathForModuleOut(ctx, "metalava", "home")
- cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
- deps.bootClasspath, deps.classpath, homeDir)
+ homeDir := android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "home")
+ cmd := metalavaCmd(ctx, rule, params.stubConfig.javaVersion, d.Javadoc.srcFiles, srcJarList,
+ params.stubConfig.deps.bootClasspath, params.stubConfig.deps.classpath, homeDir)
cmd.Implicits(d.Javadoc.implicits)
- d.stubsFlags(ctx, cmd, stubsDir)
+ d.stubsFlags(ctx, cmd, params.stubsDir, params.stubConfig.stubsType, params.stubConfig.checkApi)
- d.annotationsFlags(ctx, cmd)
+ if params.stubConfig.writeSdkValues {
+ d.sdkValuesFlags(ctx, cmd, params.metadataDir)
+ }
+
+ annotationParams := annotationFlagsParams{
+ migratingNullability: params.stubConfig.migratingNullability,
+ validatingNullability: params.stubConfig.validatingNullability,
+ nullabilityWarningsFile: params.nullabilityWarningsFile,
+ annotationsZip: params.annotationsZip,
+ }
+
+ d.annotationsFlags(ctx, cmd, annotationParams)
d.inclusionAnnotationsFlags(ctx, cmd)
- d.apiLevelsAnnotationsFlags(ctx, cmd)
+ d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml)
d.expandArgs(ctx, cmd)
@@ -586,24 +812,105 @@
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
}
- // Add options for the other optional tasks: API-lint and check-released.
- // We generate separate timestamp files for them.
+ return cmd
+}
- doApiLint := false
- doCheckReleased := false
+// Sandbox rule for generating the everything stubs and other artifacts
+func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+ srcJarDir := android.PathForModuleOut(ctx, Everything.String(), "srcjars")
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Sbox(android.PathForModuleOut(ctx, Everything.String()),
+ android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
+ SandboxInputs()
+
+ var stubsDir android.OptionalPath
+ if params.generateStubs {
+ stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, Everything.String(), "stubsDir"))
+ d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ }
+
+ if params.writeSdkValues {
+ d.metadataDir = android.PathForModuleOut(ctx, Everything.String(), "metadata")
+ d.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip")
+ }
+
+ if Bool(d.properties.Annotations_enabled) {
+ if params.validatingNullability {
+ d.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt")
+ }
+ d.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip")
+ }
+ if Bool(d.properties.Api_levels_annotations_enabled) {
+ d.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml")
+ }
+
+ commonCmdParams := stubsCommandParams{
+ srcJarDir: srcJarDir,
+ stubsDir: stubsDir,
+ stubsSrcJar: d.Javadoc.stubsSrcJar,
+ metadataDir: d.metadataDir,
+ apiVersionsXml: d.apiVersionsXml,
+ nullabilityWarningsFile: d.nullabilityWarningsFile,
+ annotationsZip: d.annotationsZip,
+ stubConfig: params,
+ }
+
+ cmd := d.commonMetalavaStubCmd(ctx, rule, commonCmdParams)
+
+ d.everythingOptionalCmd(ctx, cmd, params.doApiLint, params.doCheckReleased)
+
+ if params.generateStubs {
+ rule.Command().
+ BuiltTool("soong_zip").
+ Flag("-write_if_changed").
+ Flag("-jar").
+ FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
+ FlagWithArg("-C ", stubsDir.String()).
+ FlagWithArg("-D ", stubsDir.String())
+ }
+
+ if params.writeSdkValues {
+ rule.Command().
+ BuiltTool("soong_zip").
+ Flag("-write_if_changed").
+ Flag("-d").
+ FlagWithOutput("-o ", d.metadataZip).
+ FlagWithArg("-C ", d.metadataDir.String()).
+ FlagWithArg("-D ", d.metadataDir.String())
+ }
+
+ // TODO: We don't really need two separate API files, but this is a reminiscence of how
+ // we used to run metalava separately for API lint and the "last_released" check. Unify them.
+ if params.doApiLint {
+ rule.Command().Text("touch").Output(d.apiLintTimestamp)
+ }
+ if params.doCheckReleased {
+ rule.Command().Text("touch").Output(d.checkLastReleasedApiTimestamp)
+ }
+
+ // TODO(b/183630617): rewrapper doesn't support restat rules
+ if !metalavaUseRbe(ctx) {
+ rule.Restat()
+ }
+
+ zipSyncCleanupCmd(rule, srcJarDir)
+
+ rule.Build("metalava", "metalava merged")
+}
+
+// Sandbox rule for generating the everything artifacts that are not run by
+// default but only run based on the module configurations
+func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, doApiLint bool, doCheckReleased bool) {
// Add API lint options.
-
- if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) {
- doApiLint = true
-
+ if doApiLint {
newSince := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.New_since)
if newSince.Valid() {
cmd.FlagWithInput("--api-lint ", newSince.Path())
} else {
cmd.Flag("--api-lint")
}
- d.apiLintReport = android.PathForModuleOut(ctx, "metalava", "api_lint_report.txt")
+ d.apiLintReport = android.PathForModuleOut(ctx, Everything.String(), "api_lint_report.txt")
cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint"
// TODO(b/154317059): Clean up this allowlist by baselining and/or checking in last-released.
@@ -614,8 +921,8 @@
}
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
- updatedBaselineOutput := android.PathForModuleOut(ctx, "metalava", "api_lint_baseline.txt")
- d.apiLintTimestamp = android.PathForModuleOut(ctx, "metalava", "api_lint.timestamp")
+ updatedBaselineOutput := android.PathForModuleOut(ctx, Everything.String(), "api_lint_baseline.txt")
+ d.apiLintTimestamp = android.PathForModuleOut(ctx, Everything.String(), "api_lint.timestamp")
// Note this string includes a special shell quote $' ... ', which decodes the "\n"s.
//
@@ -656,10 +963,7 @@
}
// Add "check released" options. (Detect incompatible API changes from the last public release)
-
- if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") {
- doCheckReleased = true
-
+ if doCheckReleased {
if len(d.Javadoc.properties.Out) > 0 {
ctx.PropertyErrorf("out", "out property may not be combined with check_api")
}
@@ -667,9 +971,9 @@
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Api_file))
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Removed_api_file))
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Last_released.Baseline_file)
- updatedBaselineOutput := android.PathForModuleOut(ctx, "metalava", "last_released_baseline.txt")
+ updatedBaselineOutput := android.PathForModuleOut(ctx, Everything.String(), "last_released_baseline.txt")
- d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "metalava", "check_last_released_api.timestamp")
+ d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_last_released_api.timestamp")
cmd.FlagWithInput("--check-compatibility:api:released ", apiFile)
cmd.FlagWithInput("--check-compatibility:removed:released ", removedApiFile)
@@ -694,35 +998,93 @@
currentApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Api_file))
cmd.FlagWithInput("--use-same-format-as ", currentApiFile)
}
+}
- if generateStubs {
+// Sandbox rule for generating exportable stubs and other artifacts
+func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+ optionalCmdParams := stubsCommandParams{
+ stubConfig: params,
+ }
+
+ d.Javadoc.exportableStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ optionalCmdParams.stubsSrcJar = d.Javadoc.exportableStubsSrcJar
+ if params.writeSdkValues {
+ d.exportableMetadataZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-metadata.zip")
+ d.exportableMetadataDir = android.PathForModuleOut(ctx, params.stubsType.String(), "metadata")
+ optionalCmdParams.metadataZip = d.exportableMetadataZip
+ optionalCmdParams.metadataDir = d.exportableMetadataDir
+ }
+
+ if Bool(d.properties.Annotations_enabled) {
+ if params.validatingNullability {
+ d.exportableNullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt")
+ optionalCmdParams.nullabilityWarningsFile = d.exportableNullabilityWarningsFile
+ }
+ d.exportableAnnotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip")
+ optionalCmdParams.annotationsZip = d.exportableAnnotationsZip
+ }
+ if Bool(d.properties.Api_levels_annotations_enabled) {
+ d.exportableApiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml")
+ optionalCmdParams.apiVersionsXml = d.exportableApiVersionsXml
+ }
+
+ if params.checkApi || String(d.properties.Api_filename) != "" {
+ filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
+ d.exportableApiFile = android.PathForModuleOut(ctx, params.stubsType.String(), filename)
+ }
+
+ if params.checkApi || String(d.properties.Removed_api_filename) != "" {
+ filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_api.txt")
+ d.exportableRemovedApiFile = android.PathForModuleOut(ctx, params.stubsType.String(), filename)
+ }
+
+ d.optionalStubCmd(ctx, optionalCmdParams)
+}
+
+func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) {
+
+ params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars")
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Sbox(android.PathForModuleOut(ctx, params.stubConfig.stubsType.String()),
+ android.PathForModuleOut(ctx, fmt.Sprintf("metalava_%s.sbox.textproto", params.stubConfig.stubsType.String()))).
+ SandboxInputs()
+
+ if params.stubConfig.generateStubs {
+ params.stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "stubsDir"))
+ }
+
+ cmd := d.commonMetalavaStubCmd(ctx, rule, params)
+
+ d.generateRevertAnnotationArgs(ctx, cmd, params.stubConfig.stubsType, params.stubConfig.deps.aconfigProtoFiles)
+
+ if params.stubConfig.doApiLint {
+ // Pass the lint baseline file as an input to resolve the lint errors.
+ // The exportable stubs generation does not update the lint baseline file.
+ // Lint baseline file update is handled by the everything stubs
+ baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
+ if baselineFile.Valid() {
+ cmd.FlagWithInput("--baseline:api-lint ", baselineFile.Path())
+ }
+ }
+
+ if params.stubConfig.generateStubs {
rule.Command().
BuiltTool("soong_zip").
Flag("-write_if_changed").
Flag("-jar").
- FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
- FlagWithArg("-C ", stubsDir.String()).
- FlagWithArg("-D ", stubsDir.String())
+ FlagWithOutput("-o ", params.stubsSrcJar).
+ FlagWithArg("-C ", params.stubsDir.String()).
+ FlagWithArg("-D ", params.stubsDir.String())
}
- if Bool(d.properties.Write_sdk_values) {
- d.metadataZip = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-metadata.zip")
+ if params.stubConfig.writeSdkValues {
rule.Command().
BuiltTool("soong_zip").
Flag("-write_if_changed").
Flag("-d").
- FlagWithOutput("-o ", d.metadataZip).
- FlagWithArg("-C ", d.metadataDir.String()).
- FlagWithArg("-D ", d.metadataDir.String())
- }
-
- // TODO: We don't really need two separate API files, but this is a reminiscence of how
- // we used to run metalava separately for API lint and the "last_released" check. Unify them.
- if doApiLint {
- rule.Command().Text("touch").Output(d.apiLintTimestamp)
- }
- if doCheckReleased {
- rule.Command().Text("touch").Output(d.checkLastReleasedApiTimestamp)
+ FlagWithOutput("-o ", params.metadataZip).
+ FlagWithArg("-C ", params.metadataDir.String()).
+ FlagWithArg("-D ", params.metadataDir.String())
}
// TODO(b/183630617): rewrapper doesn't support restat rules
@@ -730,9 +1092,53 @@
rule.Restat()
}
- zipSyncCleanupCmd(rule, srcJarDir)
+ zipSyncCleanupCmd(rule, params.srcJarDir)
- rule.Build("metalava", "metalava merged")
+ rule.Build(fmt.Sprintf("metalava_%s", params.stubConfig.stubsType.String()), "metalava merged")
+}
+
+func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ deps := d.Javadoc.collectDeps(ctx)
+
+ javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), android.SdkContext(d))
+ generateStubs := BoolDefault(d.properties.Generate_stubs, true)
+
+ // Add options for the other optional tasks: API-lint and check-released.
+ // We generate separate timestamp files for them.
+ doApiLint := BoolDefault(d.properties.Check_api.Api_lint.Enabled, false)
+ doCheckReleased := apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+
+ writeSdkValues := Bool(d.properties.Write_sdk_values)
+
+ annotationsEnabled := Bool(d.properties.Annotations_enabled)
+
+ 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) != "")
+
+ checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
+ apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+
+ stubCmdParams := stubsCommandConfigParams{
+ javaVersion: javaVersion,
+ deps: deps,
+ checkApi: checkApi,
+ generateStubs: generateStubs,
+ doApiLint: doApiLint,
+ doCheckReleased: doCheckReleased,
+ writeSdkValues: writeSdkValues,
+ migratingNullability: migratingNullability,
+ validatingNullability: validatingNullability,
+ }
+ 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
+ // 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)
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
@@ -748,7 +1154,7 @@
ctx.PropertyErrorf("baseline_file", "current API check can't have a baseline file. (module %s)", ctx.ModuleName())
}
- d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "metalava", "check_current_api.timestamp")
+ d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_current_api.timestamp")
rule := android.NewRuleBuilder(pctx, ctx)
@@ -791,7 +1197,7 @@
rule.Build("metalavaCurrentApiCheck", "check current API")
- d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "metalava", "update_current_api.timestamp")
+ d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "update_current_api.timestamp")
// update API rule
rule = android.NewRuleBuilder(pctx, ctx)
@@ -826,7 +1232,7 @@
checkNullabilityWarnings := android.PathForModuleSrc(ctx, String(d.properties.Check_nullability_warnings))
- d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, "metalava", "check_nullability_warnings.timestamp")
+ d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_nullability_warnings.timestamp")
msg := fmt.Sprintf(`\n******************************\n`+
`The warnings encountered during nullability annotation validation did\n`+
@@ -852,6 +1258,7 @@
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
}
func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {
@@ -926,7 +1333,9 @@
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
switch tag {
- case "":
+ // prebuilt droidstubs does not output "exportable" stubs.
+ // Output the "everything" stubs srcjar file if the tag is ".exportable".
+ case "", ".exportable":
return android.Paths{p.stubsSrcJar}, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 7bcaca1..379e240 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -395,3 +395,54 @@
cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--revert-annotation android.annotation.FlaggedApi")
}
+
+func TestAconfigDeclarations(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ }),
+ 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",
+ ],
+ }
+ `)
+
+ // 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")
+ android.AssertStringDoesContain(t, "foo generates revert annotations file",
+ strings.Join(m.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")
+
+ android.AssertStringDoesContain(t, "foo generates exportable stubs jar",
+ strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+}
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index c3caa08..a512860 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -291,7 +291,7 @@
if sdkLibrary, ok := module.(SdkLibraryDependency); ok {
dexJar = sdkLibrary.SdkApiStubDexJar(ctx, kind)
} else if j, ok := module.(UsesLibraryDependency); ok {
- dexJar = j.DexJarBuildPath()
+ dexJar = j.DexJarBuildPath(ctx)
} else {
ctx.ModuleErrorf("dependency %s of module type %s does not support providing a dex jar", module, ctx.OtherModuleType(module))
return nil
@@ -1457,7 +1457,9 @@
// However, under certain conditions, e.g. errors, or special build configurations it will return
// a path to a fake file.
func retrieveEncodedBootDexJarFromModule(ctx android.ModuleContext, module android.Module) android.Path {
- bootDexJar := module.(interface{ DexJarBuildPath() OptionalDexJarPath }).DexJarBuildPath()
+ bootDexJar := module.(interface {
+ DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath
+ }).DexJarBuildPath(ctx)
if !bootDexJar.Valid() {
fake := android.PathForModuleOut(ctx, fmt.Sprintf("fake/encoded-dex/%s.jar", module.Name()))
handleMissingDexBootFile(ctx, module, fake, bootDexJar.InvalidReason())
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go
index ef792f9..37afe29 100644
--- a/java/hiddenapi_singleton_test.go
+++ b/java/hiddenapi_singleton_test.go
@@ -309,7 +309,8 @@
android.AssertStringEquals(t, "encode embedded java_library", unencodedDexJar, actualUnencodedDexJar.String())
// Make sure that the encoded dex jar is the exported one.
- exportedDexJar := moduleForTests.Module().(UsesLibraryDependency).DexJarBuildPath().Path()
+ errCtx := moduleErrorfTestCtx{}
+ exportedDexJar := moduleForTests.Module().(UsesLibraryDependency).DexJarBuildPath(errCtx).Path()
android.AssertPathRelativeToTopEquals(t, "encode embedded java_library", encodedDexJar, exportedDexJar)
}
diff --git a/java/java.go b/java/java.go
index 2a4fafa..4eeded3 100644
--- a/java/java.go
+++ b/java/java.go
@@ -26,6 +26,7 @@
"android/soong/remoteexec"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -315,7 +316,7 @@
// Provides build path and install path to DEX jars.
type UsesLibraryDependency interface {
- DexJarBuildPath() OptionalDexJarPath
+ DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath
DexJarInstallPath() android.Path
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
}
@@ -519,6 +520,7 @@
kotlinStdlib android.Paths
kotlinAnnotations android.Paths
kotlinPlugins android.Paths
+ aconfigProtoFiles android.Paths
disableTurbine bool
}
@@ -2011,7 +2013,7 @@
})
}
-func (al *ApiLibrary) DexJarBuildPath() OptionalDexJarPath {
+func (al *ApiLibrary) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
return al.dexJarFile
}
@@ -2378,9 +2380,9 @@
return android.Paths{j.combinedClasspathFile}
}
-func (j *Import) DexJarBuildPath() OptionalDexJarPath {
+func (j *Import) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
if j.dexJarFileErr != nil {
- panic(j.dexJarFileErr.Error())
+ ctx.ModuleErrorf(j.dexJarFileErr.Error())
}
return j.dexJarFile
}
@@ -2631,7 +2633,7 @@
}
}
-func (j *DexImport) DexJarBuildPath() OptionalDexJarPath {
+func (j *DexImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
return j.dexJarFile
}
@@ -2799,7 +2801,7 @@
// from its CLC should be added to the current CLC.
if sdkLib != nil {
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false,
- dep.DexJarBuildPath().PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
+ dep.DexJarBuildPath(ctx).PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
} else {
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
}
diff --git a/java/java_test.go b/java/java_test.go
index b9dc453..0891ab6 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -528,6 +528,15 @@
}
}
+// A minimal context object for use with DexJarBuildPath
+type moduleErrorfTestCtx struct {
+}
+
+func (ctx moduleErrorfTestCtx) ModuleErrorf(format string, args ...interface{}) {
+}
+
+var _ android.ModuleErrorfContext = (*moduleErrorfTestCtx)(nil)
+
func TestPrebuilts(t *testing.T) {
ctx, _ := testJava(t, `
java_library {
@@ -595,7 +604,8 @@
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barJar.String())
}
- barDexJar := barModule.Module().(*Import).DexJarBuildPath()
+ errCtx := moduleErrorfTestCtx{}
+ barDexJar := barModule.Module().(*Import).DexJarBuildPath(errCtx)
if barDexJar.IsSet() {
t.Errorf("bar dex jar build path expected to be set, got %s", barDexJar)
}
@@ -608,7 +618,7 @@
t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, bazJar.String())
}
- bazDexJar := bazModule.Module().(*Import).DexJarBuildPath().Path()
+ bazDexJar := bazModule.Module().(*Import).DexJarBuildPath(errCtx).Path()
expectedDexJar := "out/soong/.intermediates/baz/android_common/dex/baz.jar"
android.AssertPathRelativeToTopEquals(t, "baz dex jar build path", expectedDexJar, bazDexJar)
@@ -2465,7 +2475,7 @@
}
`)
- currentApiTimestampPath := "api-stubs-docs-non-updatable/android_common/metalava/check_current_api.timestamp"
+ currentApiTimestampPath := "api-stubs-docs-non-updatable/android_common/everything/check_current_api.timestamp"
foo := result.ModuleForTests("foo", "android_common").Module().(*ApiLibrary)
fooValidationPathsString := strings.Join(foo.validationPaths.Strings(), " ")
bar := result.ModuleForTests("bar", "android_common").Module().(*ApiLibrary)
diff --git a/java/lint.go b/java/lint.go
index 5a684a8..c3d723b 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -17,7 +17,6 @@
import (
"fmt"
"sort"
- "strconv"
"strings"
"github.com/google/blueprint/proptools"
@@ -56,7 +55,8 @@
// Modules that provide extra lint checks
Extra_check_modules []string
- // Name of the file that lint uses as the baseline. Defaults to "lint-baseline.xml".
+ // The lint baseline file to use. If specified, lint warnings listed in this file will be
+ // suppressed during lint checks.
Baseline_filename *string
// If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false.
@@ -84,9 +84,9 @@
classes android.Path
extraLintCheckJars android.Paths
library bool
- minSdkVersion int
- targetSdkVersion int
- compileSdkVersion int
+ minSdkVersion android.ApiLevel
+ targetSdkVersion android.ApiLevel
+ compileSdkVersion android.ApiLevel
compileSdkKind android.SdkKind
javaLanguageLevel string
kotlinLanguageLevel string
@@ -357,33 +357,20 @@
Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`).
Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`).
Text(`echo " android:versionCode='1' android:versionName='1' >" &&`).
- Textf(`echo " <uses-sdk android:minSdkVersion='%d' android:targetSdkVersion='%d'/>" &&`,
- l.minSdkVersion, l.targetSdkVersion).
+ Textf(`echo " <uses-sdk android:minSdkVersion='%s' android:targetSdkVersion='%s'/>" &&`,
+ l.minSdkVersion.String(), l.targetSdkVersion.String()).
Text(`echo "</manifest>"`).
Text(") >").Output(manifestPath)
return manifestPath
}
-func (l *linter) getBaselineFilepath(ctx android.ModuleContext) android.OptionalPath {
- var lintBaseline android.OptionalPath
- if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" {
- if String(l.properties.Lint.Baseline_filename) != "" {
- // if manually specified, we require the file to exist
- lintBaseline = android.OptionalPathForPath(android.PathForModuleSrc(ctx, lintFilename))
- } else {
- lintBaseline = android.ExistentPathForSource(ctx, ctx.ModuleDir(), lintFilename)
- }
- }
- return lintBaseline
-}
-
func (l *linter) lint(ctx android.ModuleContext) {
if !l.enabled() {
return
}
- if l.minSdkVersion != l.compileSdkVersion {
+ if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
// Skip lint warning checks for NewApi warnings for libcore where they come from source
// files that reference the API they are adding (b/208656169).
@@ -497,7 +484,7 @@
FlagWithOutput("--html ", html).
FlagWithOutput("--text ", text).
FlagWithOutput("--xml ", xml).
- FlagWithArg("--compile-sdk-version ", strconv.Itoa(l.compileSdkVersion)).
+ FlagWithArg("--compile-sdk-version ", l.compileSdkVersion.String()).
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
@@ -518,9 +505,8 @@
cmd.FlagWithArg("--check ", checkOnly)
}
- lintBaseline := l.getBaselineFilepath(ctx)
- if lintBaseline.Valid() {
- cmd.FlagWithInput("--baseline ", lintBaseline.Path())
+ if l.properties.Lint.Baseline_filename != nil {
+ cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
}
cmd.FlagWithOutput("--write-reference-baseline ", referenceBaseline)
@@ -556,6 +542,10 @@
if l.buildModuleReportZip {
l.reports = BuildModuleLintReportZips(ctx, l.LintDepSets())
}
+
+ // Create a per-module phony target to run the lint check.
+ phonyName := ctx.ModuleName() + "-lint"
+ ctx.Phony(phonyName, xml)
}
func BuildModuleLintReportZips(ctx android.ModuleContext, depSets LintDepSets) android.Paths {
diff --git a/java/lint_test.go b/java/lint_test.go
index 5e6b8bc..b7e6aad 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -21,7 +21,7 @@
"android/soong/android"
)
-func TestJavaLint(t *testing.T) {
+func TestJavaLintDoesntUseBaselineImplicitly(t *testing.T) {
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -40,30 +40,8 @@
foo := ctx.ModuleForTests("foo", "android_common")
sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
- if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
- t.Error("did not pass --baseline flag")
- }
-}
-
-func TestJavaLintWithoutBaseline(t *testing.T) {
- ctx, _ := testJavaWithFS(t, `
- java_library {
- name: "foo",
- srcs: [
- "a.java",
- "b.java",
- "c.java",
- ],
- min_sdk_version: "29",
- sdk_version: "system_current",
- }
- `, map[string][]byte{})
-
- foo := ctx.ModuleForTests("foo", "android_common")
-
- sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
- if strings.Contains(*sboxProto.Commands[0].Command, "--baseline") {
- t.Error("passed --baseline flag for non existent file")
+ if strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
+ t.Error("Passed --baseline flag when baseline_filename was not set")
}
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index ef34fb6..058862b 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -231,6 +231,10 @@
return ".stubs" + scope.moduleSuffix
}
+func (scope *apiScope) exportableStubsLibraryModuleNameSuffix() string {
+ return ".stubs.exportable" + scope.moduleSuffix
+}
+
func (scope *apiScope) apiLibraryModuleName(baseName string) string {
return scope.stubsLibraryModuleName(baseName) + ".from-text"
}
@@ -239,10 +243,18 @@
return scope.stubsLibraryModuleName(baseName) + ".from-source"
}
+func (scope *apiScope) exportableSourceStubsLibraryModuleName(baseName string) string {
+ return scope.exportableStubsLibraryModuleName(baseName) + ".from-source"
+}
+
func (scope *apiScope) stubsLibraryModuleName(baseName string) string {
return baseName + scope.stubsLibraryModuleNameSuffix()
}
+func (scope *apiScope) exportableStubsLibraryModuleName(baseName string) string {
+ return baseName + scope.exportableStubsLibraryModuleNameSuffix()
+}
+
func (scope *apiScope) stubsSourceModuleName(baseName string) string {
return baseName + ".stubs.source" + scope.moduleSuffix
}
@@ -628,6 +640,10 @@
// Defaults to false.
Contribute_to_android_api *bool
+ // a list of aconfig_declarations module names that the stubs generated in this module
+ // depend on.
+ Aconfig_declarations []string
+
// TODO: determines whether to create HTML doc or not
// Html_doc *bool
}
@@ -678,7 +694,7 @@
paths.stubsImplPath = lib.ImplementationJars
libDep := dep.(UsesLibraryDependency)
- paths.stubsDexJarPath = libDep.DexJarBuildPath()
+ paths.stubsDexJarPath = libDep.DexJarBuildPath(ctx)
return nil
} else {
return fmt.Errorf("expected module that has JavaInfoProvider, e.g. java_library")
@@ -891,6 +907,12 @@
return c.namingScheme.stubsLibraryModuleName(apiScope, baseName)
}
+// Name of the java_library module that compiles the exportable stubs source.
+func (c *commonToSdkLibraryAndImport) exportableStubsLibraryModuleName(apiScope *apiScope) string {
+ baseName := c.module.BaseModuleName()
+ return c.namingScheme.exportableStubsLibraryModuleName(apiScope, baseName)
+}
+
// Name of the droidstubs module that generates the stubs source and may also
// generate/check the API.
func (c *commonToSdkLibraryAndImport) stubsSourceModuleName(apiScope *apiScope) string {
@@ -907,9 +929,16 @@
// Name of the java_library module that compiles the stubs
// generated from source Java files.
-func (c *commonToSdkLibraryAndImport) sourceStubLibraryModuleName(apiScope *apiScope) string {
+func (c *commonToSdkLibraryAndImport) sourceStubsLibraryModuleName(apiScope *apiScope) string {
baseName := c.module.BaseModuleName()
- return c.namingScheme.sourceStubLibraryModuleName(apiScope, baseName)
+ return c.namingScheme.sourceStubsLibraryModuleName(apiScope, baseName)
+}
+
+// Name of the java_library module that compiles the exportable stubs
+// generated from source Java files.
+func (c *commonToSdkLibraryAndImport) exportableSourceStubsLibraryModuleName(apiScope *apiScope) string {
+ baseName := c.module.BaseModuleName()
+ return c.namingScheme.exportableSourceStubsLibraryModuleName(apiScope, baseName)
}
// The component names for different outputs of the java_sdk_library.
@@ -1625,36 +1654,34 @@
mctx.CreateModule(LibraryFactory, properties...)
}
-// Creates a static java library that has API stubs
-func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
- props := struct {
- Name *string
- Visibility []string
- Srcs []string
- Installable *bool
- Sdk_version *string
- System_modules *string
- Patch_module *string
- Libs []string
- Static_libs []string
- Compile_dex *bool
- Java_version *string
- Openjdk9 struct {
- Srcs []string
- Javacflags []string
- }
- Dist struct {
- Targets []string
- Dest *string
- Dir *string
- Tag *string
- }
- }{}
+type libraryProperties struct {
+ Name *string
+ Visibility []string
+ Srcs []string
+ Installable *bool
+ Sdk_version *string
+ System_modules *string
+ Patch_module *string
+ Libs []string
+ Static_libs []string
+ Compile_dex *bool
+ Java_version *string
+ Openjdk9 struct {
+ Srcs []string
+ Javacflags []string
+ }
+ Dist struct {
+ Targets []string
+ Dest *string
+ Dir *string
+ Tag *string
+ }
+}
- props.Name = proptools.StringPtr(module.sourceStubLibraryModuleName(apiScope))
+func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
+ props := libraryProperties{}
props.Visibility = []string{"//visibility:override", "//visibility:private"}
// sources are generated from the droiddoc
- props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
props.Sdk_version = proptools.StringPtr(sdkVersion)
props.System_modules = module.deviceProperties.System_modules
@@ -1674,6 +1701,25 @@
// interop with older developer tools that don't support 1.9.
props.Java_version = proptools.StringPtr("1.8")
+ return props
+}
+
+// Creates a static java library that has API stubs
+func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
+
+ props := module.stubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.sourceStubsLibraryModuleName(apiScope))
+ props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
+
+ mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
+}
+
+// Create a static java library that compiles the "exportable" stubs
+func (module *SdkLibrary) createExportableStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
+ props := module.stubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.exportableSourceStubsLibraryModuleName(apiScope))
+ props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope) + "{.exportable}"}
+
mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
@@ -1698,6 +1744,7 @@
Merge_inclusion_annotations_dirs []string
Generate_stubs *bool
Previous_api *string
+ Aconfig_declarations []string
Check_api struct {
Current ApiToCheck
Last_released ApiToCheck
@@ -1742,6 +1789,7 @@
props.Annotations_enabled = module.sdkLibraryProperties.Annotations_enabled
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
+ props.Aconfig_declarations = module.sdkLibraryProperties.Aconfig_declarations
droidstubsArgs := []string{}
if len(module.sdkLibraryProperties.Api_packages) != 0 {
@@ -1902,43 +1950,15 @@
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
-func (module *SdkLibrary) createTopLevelStubsLibrary(
- mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
- props := struct {
- Name *string
- Visibility []string
- Sdk_version *string
- Static_libs []string
- System_modules *string
- Dist struct {
- Targets []string
- Dest *string
- Dir *string
- Tag *string
- }
- Compile_dex *bool
- }{}
- props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
+func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
+ props := libraryProperties{}
+
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
props.Sdk_version = proptools.StringPtr(sdkVersion)
- // Add the stub compiling java_library/java_api_library as static lib based on build config
- staticLib := module.sourceStubLibraryModuleName(apiScope)
- if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
- staticLib = module.apiLibraryModuleName(apiScope)
- }
- props.Static_libs = append(props.Static_libs, staticLib)
props.System_modules = module.deviceProperties.System_modules
- // Dist the class jar artifact for sdk builds.
- if !Bool(module.sdkLibraryProperties.No_dist) {
- props.Dist.Targets = []string{"sdk", "win_sdk"}
- props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
- props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
- props.Dist.Tag = proptools.StringPtr(".jar")
- }
-
// The imports need to be compiled to dex if the java_sdk_library requests it.
compileDex := module.dexProperties.Compile_dex
if module.stubLibrariesCompiledForDex() {
@@ -1946,6 +1966,43 @@
}
props.Compile_dex = compileDex
+ return props
+}
+
+func (module *SdkLibrary) createTopLevelStubsLibrary(
+ mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
+
+ props := module.topLevelStubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
+
+ // Add the stub compiling java_library/java_api_library as static lib based on build config
+ staticLib := module.sourceStubsLibraryModuleName(apiScope)
+ if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
+ staticLib = module.apiLibraryModuleName(apiScope)
+ }
+ props.Static_libs = append(props.Static_libs, staticLib)
+
+ mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
+}
+
+func (module *SdkLibrary) createTopLevelExportableStubsLibrary(
+ mctx android.DefaultableHookContext, apiScope *apiScope) {
+
+ props := module.topLevelStubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.exportableStubsLibraryModuleName(apiScope))
+
+ // Dist the class jar artifact for sdk builds.
+ // "exportable" stubs are copied to dist for sdk builds instead of the "everything" stubs.
+ if !Bool(module.sdkLibraryProperties.No_dist) {
+ props.Dist.Targets = []string{"sdk", "win_sdk"}
+ props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
+ props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
+ props.Dist.Tag = proptools.StringPtr(".jar")
+ }
+
+ staticLib := module.exportableSourceStubsLibraryModuleName(apiScope)
+ props.Static_libs = append(props.Static_libs, staticLib)
+
mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
@@ -2151,6 +2208,7 @@
module.createStubsSourcesAndApi(mctx, scope, module.stubsSourceModuleName(scope), scope.droidstubsArgs)
module.createStubsLibrary(mctx, scope)
+ module.createExportableStubsLibrary(mctx, scope)
alternativeFullApiSurfaceStubLib := ""
if scope == apiScopePublic {
@@ -2162,6 +2220,7 @@
}
module.createTopLevelStubsLibrary(mctx, scope, contributesToApiSurface)
+ module.createTopLevelExportableStubsLibrary(mctx, scope)
}
if module.requiresRuntimeImplementationLibrary() {
@@ -2217,7 +2276,11 @@
apiLibraryModuleName(scope *apiScope, baseName string) string
- sourceStubLibraryModuleName(scope *apiScope, baseName string) string
+ sourceStubsLibraryModuleName(scope *apiScope, baseName string) string
+
+ exportableStubsLibraryModuleName(scope *apiScope, baseName string) string
+
+ exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string
}
type defaultNamingScheme struct {
@@ -2235,34 +2298,47 @@
return scope.apiLibraryModuleName(baseName)
}
-func (s *defaultNamingScheme) sourceStubLibraryModuleName(scope *apiScope, baseName string) string {
+func (s *defaultNamingScheme) sourceStubsLibraryModuleName(scope *apiScope, baseName string) string {
return scope.sourceStubLibraryModuleName(baseName)
}
+func (s *defaultNamingScheme) exportableStubsLibraryModuleName(scope *apiScope, baseName string) string {
+ return scope.exportableStubsLibraryModuleName(baseName)
+}
+
+func (s *defaultNamingScheme) exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string {
+ return scope.exportableSourceStubsLibraryModuleName(baseName)
+}
+
var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil)
+func hasStubsLibrarySuffix(name string, apiScope *apiScope) bool {
+ return strings.HasSuffix(name, apiScope.stubsLibraryModuleNameSuffix()) ||
+ strings.HasSuffix(name, apiScope.exportableStubsLibraryModuleNameSuffix())
+}
+
func moduleStubLinkType(name string) (stub bool, ret sdkLinkType) {
name = strings.TrimSuffix(name, ".from-source")
// This suffix-based approach is fragile and could potentially mis-trigger.
// TODO(b/155164730): Clean this up when modules no longer reference sdk_lib stubs directly.
- if strings.HasSuffix(name, apiScopePublic.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopePublic) {
if name == "hwbinder.stubs" || name == "libcore_private.stubs" {
// Due to a previous bug, these modules were not considered stubs, so we retain that.
return false, javaPlatform
}
return true, javaSdk
}
- if strings.HasSuffix(name, apiScopeSystem.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeSystem) {
return true, javaSystem
}
- if strings.HasSuffix(name, apiScopeModuleLib.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeModuleLib) {
return true, javaModule
}
- if strings.HasSuffix(name, apiScopeTest.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeTest) {
return true, javaSystem
}
- if strings.HasSuffix(name, apiScopeSystemServer.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeSystemServer) {
return true, javaSystemServer
}
return false, javaPlatform
@@ -2752,11 +2828,11 @@
}
// to satisfy UsesLibraryDependency interface
-func (module *SdkLibraryImport) DexJarBuildPath() OptionalDexJarPath {
+func (module *SdkLibraryImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
// The dex implementation jar extracted from the .apex file should be used in preference to the
// source.
if module.dexJarFileErr != nil {
- panic(module.dexJarFileErr.Error())
+ ctx.ModuleErrorf(module.dexJarFileErr.Error())
}
if module.dexJarFile.IsSet() {
return module.dexJarFile
@@ -2764,7 +2840,7 @@
if module.implLibraryModule == nil {
return makeUnsetDexJarPath()
} else {
- return module.implLibraryModule.DexJarBuildPath()
+ return module.implLibraryModule.DexJarBuildPath(ctx)
}
}
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 63419d6..c14f3e6 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1423,7 +1423,7 @@
for _, tt := range testCases {
t.Run(tt.module, func(t *testing.T) {
- m := result.ModuleForTests(tt.module+".stubs", "android_common").Module().(*Library)
+ m := result.ModuleForTests(apiScopePublic.exportableStubsLibraryModuleName(tt.module), "android_common").Module().(*Library)
dists := m.Dists()
if len(dists) != 1 {
t.Fatalf("expected exactly 1 dist entry, got %d", len(dists))
@@ -1693,3 +1693,56 @@
android.AssertStringDoesContain(t, "bar.xml java_sdk_xml command", barPermissions.RuleParams.Command, `dependency=\"foo\"`)
}
+
+func TestSdkLibraryExportableStubsLibrary(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java", "b.java"],
+ api_packages: ["foo"],
+ system: {
+ enabled: true,
+ },
+ module_lib: {
+ enabled: true,
+ },
+ test: {
+ enabled: true,
+ },
+ aconfig_declarations: [
+ "bar",
+ ],
+ }
+ `)
+
+ exportableStubsLibraryModuleName := apiScopePublic.exportableStubsLibraryModuleName("foo")
+ exportableSourceStubsLibraryModuleName := apiScopePublic.exportableSourceStubsLibraryModuleName("foo")
+
+ // Check modules generation
+ topLevelModule := result.ModuleForTests(exportableStubsLibraryModuleName, "android_common")
+ result.ModuleForTests(exportableSourceStubsLibraryModuleName, "android_common")
+
+ // Check static lib dependency
+ android.AssertBoolEquals(t, "exportable top level stubs library module depends on the"+
+ "exportable source stubs library module", true,
+ CheckModuleHasDependency(t, result.TestContext, exportableStubsLibraryModuleName,
+ "android_common", exportableSourceStubsLibraryModuleName),
+ )
+ android.AssertArrayString(t, "exportable source stub library is a static lib of the"+
+ "top level exportable stubs library", []string{exportableSourceStubsLibraryModuleName},
+ topLevelModule.Module().(*Library).properties.Static_libs)
+}
diff --git a/java/sdk_version_test.go b/java/sdk_version_test.go
new file mode 100644
index 0000000..88351d2
--- /dev/null
+++ b/java/sdk_version_test.go
@@ -0,0 +1,66 @@
+// Copyright 2024 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "testing"
+
+ "android/soong/android"
+)
+
+func stringPtr(v string) *string {
+ return &v
+}
+
+func TestSystemSdkFromVendor(t *testing.T) {
+ fixtures := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_sdk_version = intPtr(34)
+ variables.Platform_sdk_codename = stringPtr("VanillaIceCream")
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ variables.Platform_systemsdk_versions = []string{"33", "34", "VanillaIceCream"}
+ variables.DeviceSystemSdkVersions = []string{"VanillaIceCream"}
+ }),
+ FixtureWithPrebuiltApis(map[string][]string{
+ "33": {},
+ "34": {},
+ "35": {},
+ }),
+ )
+
+ fixtures.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("incompatible sdk version")).
+ RunTestWithBp(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ vendor: true,
+ sdk_version: "system_35",
+ }`)
+
+ result := fixtures.RunTestWithBp(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ vendor: true,
+ sdk_version: "system_current",
+ }`)
+ fooModule := result.ModuleForTests("foo", "android_common")
+ fooClasspath := fooModule.Rule("javac").Args["classpath"]
+
+ android.AssertStringDoesContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/34/system/android.jar")
+ android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/35/system/android.jar")
+ android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/current/system/android.jar")
+}
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 8b52d86..78b62d9 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -140,7 +140,7 @@
// linker_config generates protobuf file from json file. This protobuf file will be used from
// linkerconfig while generating ld.config.txt. Format of this file can be found from
-// https://android.googlesource.com/platform/system/linkerconfig/+/master/README.md
+// https://android.googlesource.com/platform/system/linkerconfig/+/main/README.md
func LinkerConfigFactory() android.Module {
m := &linkerConfig{}
m.AddProperties(&m.properties)
diff --git a/linkerconfig/proto/linker_config.proto b/linkerconfig/proto/linker_config.proto
index dccf311..fcbd1c5 100644
--- a/linkerconfig/proto/linker_config.proto
+++ b/linkerconfig/proto/linker_config.proto
@@ -16,7 +16,7 @@
// This format file defines configuration file for linkerconfig. Details on this
// format can be found from
-// https://android.googlesource.com/platform/system/linkerconfig/+/master/README.md
+// https://android.googlesource.com/platform/system/linkerconfig/+/main/README.md
syntax = "proto3";
diff --git a/python/binary.go b/python/binary.go
index 85084a4..d6750c6 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -71,6 +71,9 @@
installedDest android.Path
androidMkSharedLibs []string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
var _ android.AndroidMkEntriesProvider = (*PythonBinaryModule)(nil)
@@ -103,6 +106,7 @@
p.buildBinary(ctx)
p.installedDest = ctx.InstallFile(installDir(ctx, "bin", "", ""),
p.installSource.Base(), p.installSource)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
@@ -166,6 +170,7 @@
entries.SetString("LOCAL_MODULE_STEM", stem)
entries.AddStrings("LOCAL_SHARED_LIBRARIES", p.androidMkSharedLibs...)
entries.SetBool("LOCAL_CHECK_ELF_FILES", false)
+ android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
})
return []android.AndroidMkEntries{entries}
diff --git a/python/test.go b/python/test.go
index 782f39f..7eb9136 100644
--- a/python/test.go
+++ b/python/test.go
@@ -149,6 +149,7 @@
// just use buildBinary() so that the binary is not installed into the location
// it would be for regular binaries.
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
p.buildBinary(ctx)
var configs []tradefed.Option
@@ -228,6 +229,7 @@
}
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
+ android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
p.testProperties.Test_options.SetAndroidMkEntries(entries)
})
diff --git a/rust/androidmk.go b/rust/androidmk.go
index c355a56..17fd2d8 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -17,7 +17,6 @@
import (
"path/filepath"
- "android/soong/aconfig"
"android/soong/android"
)
@@ -67,7 +66,7 @@
if mod.UseVndk() {
entries.SetBool("LOCAL_USE_VNDK", true)
}
- aconfig.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
},
},
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 1cc1574..77ba277 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -170,7 +170,7 @@
cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config."))
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${config.", "${cc_config."))
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
cflags = append(cflags, "-D__ANDROID_VNDK__")
if ctx.RustModule().InVendor() {
cflags = append(cflags, "-D__ANDROID_VENDOR__")
diff --git a/rust/compiler.go b/rust/compiler.go
index a8c5473..c1bdbeb 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -332,7 +332,7 @@
}
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vndk")
if ctx.RustModule().InVendor() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vendor")
@@ -520,7 +520,7 @@
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if compiler.location == InstallInData && ctx.RustModule().UseVndk() {
+ if compiler.location == InstallInData && ctx.RustModule().InVendorOrProduct() {
if ctx.RustModule().InProduct() {
dir = filepath.Join(dir, "product")
} else if ctx.RustModule().InVendor() {
diff --git a/rust/config/x86_64_device.go b/rust/config/x86_64_device.go
index c797eef..cc16704 100644
--- a/rust/config/x86_64_device.go
+++ b/rust/config/x86_64_device.go
@@ -28,15 +28,16 @@
x86_64LinkFlags = []string{}
x86_64ArchVariantRustFlags = map[string][]string{
- "": []string{},
- "broadwell": []string{"-C target-cpu=broadwell"},
- "goldmont": []string{"-C target-cpu=goldmont"},
- "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
- "haswell": []string{"-C target-cpu=haswell"},
- "ivybridge": []string{"-C target-cpu=ivybridge"},
- "sandybridge": []string{"-C target-cpu=sandybridge"},
- "silvermont": []string{"-C target-cpu=silvermont"},
- "skylake": []string{"-C target-cpu=skylake"},
+ "": []string{},
+ "broadwell": []string{"-C target-cpu=broadwell"},
+ "goldmont": []string{"-C target-cpu=goldmont"},
+ "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
+ "goldmont-without-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-xsaves"},
+ "haswell": []string{"-C target-cpu=haswell"},
+ "ivybridge": []string{"-C target-cpu=ivybridge"},
+ "sandybridge": []string{"-C target-cpu=sandybridge"},
+ "silvermont": []string{"-C target-cpu=silvermont"},
+ "skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.
"stoneyridge": []string{""},
"tremont": []string{"-C target-cpu=tremont"},
diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go
index 822f281..e7b575c 100644
--- a/rust/config/x86_device.go
+++ b/rust/config/x86_device.go
@@ -26,16 +26,17 @@
x86LinkFlags = []string{}
x86ArchVariantRustFlags = map[string][]string{
- "": []string{},
- "atom": []string{"-C target-cpu=atom"},
- "broadwell": []string{"-C target-cpu=broadwell"},
- "goldmont": []string{"-C target-cpu=goldmont"},
- "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
- "haswell": []string{"-C target-cpu=haswell"},
- "ivybridge": []string{"-C target-cpu=ivybridge"},
- "sandybridge": []string{"-C target-cpu=sandybridge"},
- "silvermont": []string{"-C target-cpu=silvermont"},
- "skylake": []string{"-C target-cpu=skylake"},
+ "": []string{},
+ "atom": []string{"-C target-cpu=atom"},
+ "broadwell": []string{"-C target-cpu=broadwell"},
+ "goldmont": []string{"-C target-cpu=goldmont"},
+ "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
+ "goldmont-without-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-xsaves"},
+ "haswell": []string{"-C target-cpu=haswell"},
+ "ivybridge": []string{"-C target-cpu=ivybridge"},
+ "sandybridge": []string{"-C target-cpu=sandybridge"},
+ "silvermont": []string{"-C target-cpu=silvermont"},
+ "skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.
"stoneyridge": []string{""},
"tremont": []string{"-C target-cpu=tremont"},
diff --git a/rust/fuzz.go b/rust/fuzz.go
index bacfa2d..1770d2e 100644
--- a/rust/fuzz.go
+++ b/rust/fuzz.go
@@ -142,12 +142,12 @@
fuzz.installedSharedDeps = append(fuzz.installedSharedDeps,
cc.SharedLibraryInstallLocation(
- install, ctx.Host(), installBase, ctx.Arch().ArchType.String()))
+ install, ctx.Host(), ctx.InstallInVendor(), installBase, ctx.Arch().ArchType.String()))
// Also add the dependency on the shared library symbols dir.
if !ctx.Host() {
fuzz.installedSharedDeps = append(fuzz.installedSharedDeps,
- cc.SharedLibrarySymbolsInstallLocation(install, installBase, ctx.Arch().ArchType.String()))
+ cc.SharedLibrarySymbolsInstallLocation(install, ctx.InstallInVendor(), installBase, ctx.Arch().ArchType.String()))
}
}
diff --git a/rust/image.go b/rust/image.go
index d0218f0..530c56e 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -184,12 +184,17 @@
}
func (mod *Module) InProduct() bool {
- return mod.Properties.ImageVariationPrefix == cc.ProductVariationPrefix
+ return mod.Properties.ImageVariation == cc.ProductVariation
}
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
func (mod *Module) InVendor() bool {
- return mod.Properties.ImageVariationPrefix == cc.VendorVariationPrefix
+ return mod.Properties.ImageVariation == cc.VendorVariation
+}
+
+// Returns true if the module is "vendor" or "product" variant.
+func (mod *Module) InVendorOrProduct() bool {
+ return mod.InVendor() || mod.InProduct()
}
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
@@ -198,9 +203,11 @@
m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
- } else if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
- m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
+ } else if strings.HasPrefix(variant, cc.VendorVariation) {
+ m.Properties.ImageVariation = cc.VendorVariation
+ if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
+ }
// Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
// Hide other vendor variants to avoid collision.
@@ -209,9 +216,11 @@
m.Properties.HideFromMake = true
m.HideFromMake()
}
- } else if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
- m.Properties.ImageVariationPrefix = cc.ProductVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
+ } else if strings.HasPrefix(variant, cc.ProductVariation) {
+ m.Properties.ImageVariation = cc.ProductVariation
+ if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
+ }
}
}
diff --git a/rust/rust.go b/rust/rust.go
index 6f4631d..34ce4c5 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -20,6 +20,7 @@
"android/soong/bloaty"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -69,9 +70,9 @@
AndroidMkProcMacroLibs []string `blueprint:"mutated"`
AndroidMkStaticLibs []string `blueprint:"mutated"`
- ImageVariationPrefix string `blueprint:"mutated"`
- VndkVersion string `blueprint:"mutated"`
- SubName string `blueprint:"mutated"`
+ ImageVariation string `blueprint:"mutated"`
+ VndkVersion string `blueprint:"mutated"`
+ SubName string `blueprint:"mutated"`
// SubName is used by CC for tracking image variants / SDK versions. RustSubName is used for Rust-specific
// subnaming which shouldn't be visible to CC modules (such as the rlib stdlinkage subname). This should be
diff --git a/rust/test.go b/rust/test.go
index 6619af6..2583893 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -117,7 +117,7 @@
func (test *testDecorator) install(ctx ModuleContext) {
testInstallBase := "/data/local/tests/unrestricted"
- if ctx.RustModule().InVendor() || ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
testInstallBase = "/data/local/tests/vendor"
}
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index ee1b5db..a89e28e 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -490,14 +490,14 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`)
})
@@ -510,14 +510,14 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`
t.Run("added-via-apex", func(t *testing.T) {
testSnapshotWithBootClasspathFragment_Contents(t, `
@@ -964,11 +964,11 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/mynewlibrary.stubs/android_common/combined/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
+.intermediates/mynewlibrary.stubs.source/android_common/everything/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
+.intermediates/mynewlibrary.stubs.source/android_common/everything/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`),
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
@@ -1096,8 +1096,8 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`
// On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part
@@ -1174,11 +1174,11 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mynewsdklibrary.stubs/android_common/combined/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
+.intermediates/mynewsdklibrary.stubs.source/android_common/everything/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
+.intermediates/mynewsdklibrary.stubs.source/android_common/everything/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
`
// On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 680494f..592c005 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -697,8 +697,8 @@
.intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar
.intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkInfoContents(result.Config, `
[
@@ -942,14 +942,14 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
.intermediates/myjavalib.stubs.test/android_common/combined/myjavalib.stubs.test.jar -> sdk_library/test/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.test/android_common/everything/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
+.intermediates/myjavalib.stubs.source.test/android_common/everything/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1000,8 +1000,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib-foo.stubs/android_common/combined/myjavalib-foo.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib-foo.stubs.source/android_common/everything/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib-foo.stubs.source/android_common/everything/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1053,9 +1053,9 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
)
}
@@ -1101,9 +1101,9 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
@@ -1154,8 +1154,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
@@ -1271,8 +1271,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1319,8 +1319,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1377,11 +1377,11 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1449,14 +1449,14 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
.intermediates/myjavalib.stubs.module_lib/android_common/combined/myjavalib.stubs.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/everything/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/everything/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/module-lib/myjavalib_stub_sources.zip",
@@ -1515,11 +1515,11 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system_server/android_common/combined/myjavalib.stubs.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system_server/android_common/everything/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system_server/android_common/everything/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1569,8 +1569,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1626,8 +1626,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
docs/known_doctags -> doctags/docs/known_doctags
`),
)
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 5a25146..d14c2ba 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -488,8 +488,8 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`),
)
})
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index e51fe39..e5b3dea 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -125,6 +125,12 @@
variables.DeviceSystemSdkVersions = []string{"28"}
variables.DeviceVndkVersion = proptools.StringPtr("current")
variables.Platform_vndk_version = proptools.StringPtr("29")
+ variables.DeviceCurrentApiLevelForVendorModules = proptools.StringPtr("28")
+ }),
+ java.FixtureWithPrebuiltApis(map[string][]string{
+ "28": {},
+ "29": {},
+ "30": {},
}),
mockFS.AddToFixture(),
android.FixtureWithRootAndroidBp(bp),
diff --git a/ui/build/Android.bp b/ui/build/Android.bp
index 21453ba..ee286f6 100644
--- a/ui/build/Android.bp
+++ b/ui/build/Android.bp
@@ -35,6 +35,7 @@
"blueprint",
"blueprint-bootstrap",
"blueprint-microfactory",
+ "soong-android",
"soong-finder",
"soong-remoteexec",
"soong-shared",
@@ -46,6 +47,7 @@
"soong-ui-tracer",
],
srcs: [
+ "androidmk_denylist.go",
"build.go",
"cleanbuild.go",
"config.go",
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
new file mode 100644
index 0000000..b2266b2
--- /dev/null
+++ b/ui/build/androidmk_denylist.go
@@ -0,0 +1,44 @@
+// 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 build
+
+import (
+ "strings"
+
+ "android/soong/android"
+)
+
+var androidmk_denylist []string = []string{
+ "chained_build_config/",
+ "cts/",
+ "dalvik/",
+ "developers/",
+ "kernel/",
+ "libcore/",
+ "libnativehelper/",
+ "pdk/",
+ "toolchain/",
+}
+
+func blockAndroidMks(androidMks []string) []string {
+ return android.FilterListPred(androidMks, func(s string) bool {
+ for _, d := range androidmk_denylist {
+ if strings.HasPrefix(s, d) {
+ return false
+ }
+ }
+ return true
+ })
+}
diff --git a/ui/build/finder.go b/ui/build/finder.go
index d0bcf40..a114079 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -128,6 +128,7 @@
// Stop searching a subdirectory recursively after finding an Android.mk.
androidMks := f.FindFirstNamedAt(".", "Android.mk")
+ androidMks = blockAndroidMks(androidMks)
err := dumpListToFile(ctx, config, androidMks, filepath.Join(dumpDir, "Android.mk.list"))
if err != nil {
ctx.Fatalf("Could not export module list: %v", err)
diff --git a/ui/build/path.go b/ui/build/path.go
index 29128d8..51ebff1 100644
--- a/ui/build/path.go
+++ b/ui/build/path.go
@@ -180,7 +180,7 @@
// Compute the error message along with the process tree, including
// parents, for this log line.
procPrints := []string{
- "See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.",
+ "See https://android.googlesource.com/platform/build/+/main/Changes.md#PATH_Tools for more information.",
}
if len(log.Parents) > 0 {
procPrints = append(procPrints, "Process tree:")
diff --git a/ui/status/ninja_frontend/README b/ui/status/ninja_frontend/README
index 8c4b451..767bbf1 100644
--- a/ui/status/ninja_frontend/README
+++ b/ui/status/ninja_frontend/README
@@ -1,3 +1,3 @@
-This comes from https://android.googlesource.com/platform/external/ninja/+/master/src/frontend.proto
+This comes from https://android.googlesource.com/platform/external/ninja/+/main/src/frontend.proto
The only difference is the specification of a go_package. To regenerate frontend.pb.go, run regen.sh.