Merge "Revert "Commend out dcla_apex_comparison_test.sh""
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index ad72323..d320599 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -1598,11 +1598,6 @@
"test_com.android.neuralnetworks",
"libneuralnetworks",
"libneuralnetworks_static",
- // M13: media.swcodec launch
- "com.android.media.swcodec",
- "test_com.android.media.swcodec",
- "libstagefright_foundation",
- "libcodec2_hidl@1.0",
}
// Staging-mode allowlist. Modules in this list are only built
@@ -1610,7 +1605,13 @@
// which will soon be added to the prod allowlist.
// It is implicit that all modules in ProdMixedBuildsEnabledList will
// also be built - do not add them to this list.
- StagingMixedBuildsEnabledList = []string{}
+ StagingMixedBuildsEnabledList = []string{
+ // M13: media.swcodec launch
+ "com.android.media.swcodec",
+ "test_com.android.media.swcodec",
+ "libstagefright_foundation",
+ "libcodec2_hidl@1.0",
+ }
// These should be the libs that are included by the apexes in the ProdMixedBuildsEnabledList
ProdDclaMixedBuildsEnabledList = []string{
@@ -1618,12 +1619,13 @@
"libc++",
"libcrypto",
"libcutils",
- "libstagefright_flacdec",
- "libutils",
}
// These should be the libs that are included by the apexes in the StagingMixedBuildsEnabledList
- StagingDclaMixedBuildsEnabledList = []string{}
+ StagingDclaMixedBuildsEnabledList = []string{
+ "libstagefright_flacdec",
+ "libutils",
+ }
// TODO(b/269342245): Enable the rest of the DCLA libs
// "libssl",
diff --git a/android/config.go b/android/config.go
index 839ff05..fa43962 100644
--- a/android/config.go
+++ b/android/config.go
@@ -701,6 +701,10 @@
if c.productVariables.DeviceArch != nil && *c.productVariables.DeviceArch == "riscv64" {
return false
}
+ // Disable Bazel when Kythe is running
+ if c.EmitXrefRules() {
+ return false
+ }
if c.IsEnvTrue("GLOBAL_THINLTO") {
return false
}
diff --git a/build_kzip.bash b/build_kzip.bash
index eeef7d4..dddcd3f 100755
--- a/build_kzip.bash
+++ b/build_kzip.bash
@@ -35,8 +35,16 @@
# sufficiently many files were generated.
declare -r out="${OUT_DIR:-out}"
-# Build extraction files for C++ and Java. Build `merge_zips` which we use later.
-build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java xref_rust
+# Build extraction files and `merge_zips` which we use later.
+kzip_targets=(
+ merge_zips
+ xref_cxx
+ xref_java
+ # TODO: b/286390153 - reenable rust
+ # xref_rust
+)
+
+build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k "${kzip_targets[@]}"
# Build extraction file for Go the files in build/{blueprint,soong} directories.
declare -r abspath_out=$(realpath "${out}")
@@ -66,7 +74,6 @@
(($kzip_count>100000)) || { printf "Too few kzip files were generated: %d\n" $kzip_count; exit 1; }
# Pack
-# TODO(asmundak): this should be done by soong.
declare -r allkzip="$KZIP_NAME.kzip"
"$out/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find "$out" -name '*.kzip')
diff --git a/cc/afdo.go b/cc/afdo.go
index 137ea97..bc7cd52 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -34,7 +34,8 @@
var afdoProfileProjectsConfigKey = android.NewOnceKey("AfdoProfileProjects")
-const afdoCFlagsFormat = "-fprofile-sample-use=%s"
+// This flag needs to be in both CFlags and LdFlags to ensure correct symbol ordering
+const afdoFlagsFormat = "-fprofile-sample-use=%s"
func recordMissingAfdoProfileFile(ctx android.BaseModuleContext, missing string) {
getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true)
@@ -86,7 +87,7 @@
}
if path := afdo.Properties.FdoProfilePath; path != nil {
// The flags are prepended to allow overriding.
- profileUseFlag := fmt.Sprintf(afdoCFlagsFormat, *path)
+ profileUseFlag := fmt.Sprintf(afdoFlagsFormat, *path)
flags.Local.CFlags = append([]string{profileUseFlag}, flags.Local.CFlags...)
flags.Local.LdFlags = append([]string{profileUseFlag, "-Wl,-mllvm,-no-warn-sample-unused=true"}, flags.Local.LdFlags...)
diff --git a/cc/lto.go b/cc/lto.go
index 547ebff..510dd79 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -76,43 +76,44 @@
return flags
}
if lto.Properties.LtoEnabled {
- var ltoCFlag string
- var ltoLdFlag string
- if lto.ThinLTO() {
- ltoCFlag = "-flto=thin -fsplit-lto-unit"
- } else {
- ltoCFlag = "-flto=thin -fsplit-lto-unit"
- ltoLdFlag = "-Wl,--lto-O0"
+ ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
+ var ltoLdFlags []string
+
+ // The module did not explicitly turn on LTO. Only leverage LTO's
+ // better dead code elinmination and CFG simplification, but do
+ // not perform costly optimizations for a balance between compile
+ // time, binary size and performance.
+ if !lto.ThinLTO() {
+ ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}
- flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlag)
- flags.Local.AsFlags = append(flags.Local.AsFlags, ltoCFlag)
- flags.Local.LdFlags = append(flags.Local.LdFlags, ltoCFlag)
- flags.Local.LdFlags = append(flags.Local.LdFlags, ltoLdFlag)
-
if Bool(lto.Properties.Whole_program_vtables) {
- flags.Local.CFlags = append(flags.Local.CFlags, "-fwhole-program-vtables")
+ ltoCFlags = append(ltoCFlags, "-fwhole-program-vtables")
}
if ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") {
// Set appropriate ThinLTO cache policy
cacheDirFormat := "-Wl,--thinlto-cache-dir="
cacheDir := android.PathForOutput(ctx, "thinlto-cache").String()
- flags.Local.LdFlags = append(flags.Local.LdFlags, cacheDirFormat+cacheDir)
+ ltoLdFlags = append(ltoLdFlags, cacheDirFormat+cacheDir)
// Limit the size of the ThinLTO cache to the lesser of 10% of available
// disk space and 10GB.
cachePolicyFormat := "-Wl,--thinlto-cache-policy="
policy := "cache_size=10%:cache_size_bytes=10g"
- flags.Local.LdFlags = append(flags.Local.LdFlags, cachePolicyFormat+policy)
+ ltoLdFlags = append(ltoLdFlags, cachePolicyFormat+policy)
}
// If the module does not have a profile, be conservative and limit cross TU inline
// limit to 5 LLVM IR instructions, to balance binary size increase and performance.
if !ctx.Darwin() && !ctx.isPgoCompile() && !ctx.isAfdoCompile() {
- flags.Local.LdFlags = append(flags.Local.LdFlags,
- "-Wl,-plugin-opt,-import-instr-limit=5")
+ ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")
}
+
+ flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlags...)
+ flags.Local.AsFlags = append(flags.Local.AsFlags, ltoCFlags...)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, ltoCFlags...)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, ltoLdFlags...)
}
return flags
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 35f6097..2b0f57e 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -789,7 +789,6 @@
Flag("--generate-build-id").
Flag("--image-format=lz4hc").
FlagWithArg("--oat-symbols=", symbolsFile.String()).
- Flag("--strip").
FlagWithArg("--oat-file=", outputPath.String()).
FlagWithArg("--oat-location=", oatLocation).
FlagWithArg("--image=", imagePath.String()).
@@ -799,6 +798,11 @@
Flag("--force-determinism").
Flag("--abort-on-hard-verifier-error")
+ // We don't strip on host to make perf tools work.
+ if image.target.Os == android.Android {
+ cmd.Flag("--strip")
+ }
+
// If the image is profile-guided but the profile is disabled, we omit "--compiler-filter" to
// leave the decision to dex2oat to pick the compiler filter.
if !(image.isProfileGuided() && global.DisableGenerateProfile) {
diff --git a/java/java.go b/java/java.go
index caafaa2..50d48ab 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1624,13 +1624,6 @@
})
}
-type JavaApiLibraryDepsInfo struct {
- JavaInfo
- StubsSrcJar android.Path
-}
-
-var JavaApiLibraryDepsProvider = blueprint.NewProvider(JavaApiLibraryDepsInfo{})
-
type ApiLibrary struct {
android.ModuleBase
android.DefaultableModuleBase
@@ -1672,10 +1665,11 @@
// merge zipped after metalava invocation
Static_libs []string
- // Java Api library to provide the full API surface text files and jar file.
- // If this property is set, the provided full API surface text files and
- // jar file are passed to metalava invocation.
- Dep_api_srcs *string
+ // Java Api library to provide the full API surface stub jar file.
+ // If this property is set, the stub jar of this module is created by
+ // extracting the compiled class files provided by the
+ // full_api_surface_stub module.
+ Full_api_surface_stub *string
}
func ApiLibraryFactory() android.Module {
@@ -1762,35 +1756,37 @@
}
}
-// This method extracts the stub java files from the srcjar file provided from dep_api_srcs module
-// and replaces the java stubs generated by invoking metalava in this module.
+// This method extracts the stub class files from the stub jar file provided
+// from full_api_surface_stub module instead of compiling the srcjar generated from invoking metalava.
// This method is used because metalava can generate compilable from-text stubs only when
-// the codebase encompasses all classes listed in the input API text file, but a class can extend
+// the codebase encompasses all classes listed in the input API text file, and a class can extend
// a class that is not within the same API domain.
-func (al *ApiLibrary) extractApiSrcs(ctx android.ModuleContext, rule *android.RuleBuilder, stubsDir android.OptionalPath, depApiSrcsSrcJar android.Path) {
- generatedStubsList := android.PathForModuleOut(ctx, "metalava", "sources.txt")
+func (al *ApiLibrary) extractApiSrcs(ctx android.ModuleContext, rule *android.RuleBuilder, stubsDir android.OptionalPath, fullApiSurfaceStubJar android.Path) {
+ classFilesList := android.PathForModuleOut(ctx, "metalava", "classes.txt")
unzippedSrcJarDir := android.PathForModuleOut(ctx, "metalava", "unzipDir")
rule.Command().
BuiltTool("list_files").
Text(stubsDir.String()).
- FlagWithOutput("--out ", generatedStubsList).
+ FlagWithOutput("--out ", classFilesList).
FlagWithArg("--extensions ", ".java").
- FlagWithArg("--root ", unzippedSrcJarDir.String())
+ FlagWithArg("--root ", unzippedSrcJarDir.String()).
+ Flag("--classes")
rule.Command().
Text("unzip").
Flag("-q").
- Input(depApiSrcsSrcJar).
+ Input(fullApiSurfaceStubJar).
FlagWithArg("-d ", unzippedSrcJarDir.String())
rule.Command().
BuiltTool("soong_zip").
- Flag("-srcjar").
+ Flag("-jar").
Flag("-write_if_changed").
+ Flag("-ignore_missing_files").
FlagWithArg("-C ", unzippedSrcJarDir.String()).
- FlagWithInput("-l ", generatedStubsList).
- FlagWithOutput("-o ", al.stubsSrcJar)
+ FlagWithInput("-l ", classFilesList).
+ FlagWithOutput("-o ", al.stubsJarWithoutStaticLibs)
}
func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -1800,8 +1796,8 @@
}
ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
- if al.properties.Dep_api_srcs != nil {
- ctx.AddVariationDependencies(nil, depApiSrcsTag, String(al.properties.Dep_api_srcs))
+ if al.properties.Full_api_surface_stub != nil {
+ ctx.AddVariationDependencies(nil, depApiSrcsTag, String(al.properties.Full_api_surface_stub))
}
}
@@ -1823,7 +1819,7 @@
var srcFiles android.Paths
var classPaths android.Paths
var staticLibs android.Paths
- var depApiSrcsStubsSrcJar android.Path
+ var depApiSrcsStubsJar android.Path
ctx.VisitDirectDeps(func(dep android.Module) {
tag := ctx.OtherModuleDependencyTag(dep)
switch tag {
@@ -1841,9 +1837,8 @@
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
staticLibs = append(staticLibs, provider.HeaderJars...)
case depApiSrcsTag:
- provider := ctx.OtherModuleProvider(dep, JavaApiLibraryDepsProvider).(JavaApiLibraryDepsInfo)
- classPaths = append(classPaths, provider.HeaderJars...)
- depApiSrcsStubsSrcJar = provider.StubsSrcJar
+ provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ depApiSrcsStubsJar = provider.HeaderJars[0]
}
})
@@ -1861,31 +1856,31 @@
al.stubsFlags(ctx, cmd, stubsDir)
al.stubsSrcJar = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-"+"stubs.srcjar")
+ al.stubsJarWithoutStaticLibs = android.PathForModuleOut(ctx, "metalava", "stubs.jar")
+ al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), fmt.Sprintf("%s.jar", ctx.ModuleName()))
- if depApiSrcsStubsSrcJar != nil {
- al.extractApiSrcs(ctx, rule, stubsDir, depApiSrcsStubsSrcJar)
- } else {
- rule.Command().
- BuiltTool("soong_zip").
- Flag("-write_if_changed").
- Flag("-jar").
- FlagWithOutput("-o ", al.stubsSrcJar).
- FlagWithArg("-C ", stubsDir.String()).
- FlagWithArg("-D ", stubsDir.String())
+ if depApiSrcsStubsJar != nil {
+ al.extractApiSrcs(ctx, rule, stubsDir, depApiSrcsStubsJar)
}
+ rule.Command().
+ BuiltTool("soong_zip").
+ Flag("-write_if_changed").
+ Flag("-jar").
+ FlagWithOutput("-o ", al.stubsSrcJar).
+ FlagWithArg("-C ", stubsDir.String()).
+ FlagWithArg("-D ", stubsDir.String())
rule.Build("metalava", "metalava merged")
- al.stubsJarWithoutStaticLibs = android.PathForModuleOut(ctx, ctx.ModuleName(), "stubs.jar")
- al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), fmt.Sprintf("%s.jar", ctx.ModuleName()))
+ if depApiSrcsStubsJar == nil {
+ var flags javaBuilderFlags
+ flags.javaVersion = getStubsJavaVersion()
+ flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
+ flags.classpath = classpath(classPaths)
- var flags javaBuilderFlags
- flags.javaVersion = getStubsJavaVersion()
- flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
- flags.classpath = classpath(classPaths)
-
- TransformJavaToClasses(ctx, al.stubsJarWithoutStaticLibs, 0, android.Paths{},
- android.Paths{al.stubsSrcJar}, flags, android.Paths{})
+ TransformJavaToClasses(ctx, al.stubsJarWithoutStaticLibs, 0, android.Paths{},
+ android.Paths{al.stubsSrcJar}, flags, android.Paths{})
+ }
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().
@@ -1917,13 +1912,6 @@
ImplementationJars: android.PathsIfNonNil(al.stubsJar),
AidlIncludeDirs: android.Paths{},
})
-
- ctx.SetProvider(JavaApiLibraryDepsProvider, JavaApiLibraryDepsInfo{
- JavaInfo: JavaInfo{
- HeaderJars: android.PathsIfNonNil(al.stubsJar),
- },
- StubsSrcJar: al.stubsSrcJar,
- })
}
func (al *ApiLibrary) DexJarBuildPath() OptionalDexJarPath {
diff --git a/java/java_test.go b/java/java_test.go
index 561b187..4738304 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2208,7 +2208,7 @@
}
}
-func TestJavaApiLibraryDepApiSrcs(t *testing.T) {
+func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2234,7 +2234,7 @@
name: "bar1",
api_surface: "public",
api_contributions: ["foo1"],
- dep_api_srcs: "lib1",
+ full_api_surface_stub: "lib1",
}
`,
map[string][]byte{
@@ -2247,9 +2247,7 @@
manifest := m.Output("metalava.sbox.textproto")
sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
-
- android.AssertStringDoesContain(t, "Command expected to contain module srcjar file", manifestCommand, "bar1-stubs.srcjar")
- android.AssertStringDoesContain(t, "Command expected to contain output files list text file flag", manifestCommand, "--out __SBOX_SANDBOX_DIR__/out/sources.txt")
+ android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar")
}
func TestJavaApiLibraryFilegroupInput(t *testing.T) {
diff --git a/java/resourceshrinker.go b/java/resourceshrinker.go
index 6d59601..bf1b04d 100644
--- a/java/resourceshrinker.go
+++ b/java/resourceshrinker.go
@@ -22,7 +22,8 @@
var shrinkResources = pctx.AndroidStaticRule("shrinkResources",
blueprint.RuleParams{
- Command: `${config.ResourceShrinkerCmd} --output $out --input $in --raw_resources $raw_resources`,
+ // Note that we suppress stdout to avoid successful log confirmations.
+ Command: `${config.ResourceShrinkerCmd} --output $out --input $in --raw_resources $raw_resources >/dev/null`,
CommandDeps: []string{"${config.ResourceShrinkerCmd}"},
}, "raw_resources")
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a3d81ce..dbb2f02 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1780,12 +1780,12 @@
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
props := struct {
- Name *string
- Visibility []string
- Api_contributions []string
- Libs []string
- Static_libs []string
- Dep_api_srcs *string
+ Name *string
+ Visibility []string
+ Api_contributions []string
+ Libs []string
+ Static_libs []string
+ Full_api_surface_stub *string
}{}
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
@@ -1807,12 +1807,12 @@
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
props.Libs = append(props.Libs, "stub-annotations")
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
- props.Dep_api_srcs = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + ".from-text")
+ props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + ".from-text")
// android_module_lib_stubs_current.from-text only comprises api contributions from art, conscrypt and i18n.
// Thus, replace with android_module_lib_stubs_current_full.from-text, which comprises every api domains.
if apiScope.kind == android.SdkModule {
- props.Dep_api_srcs = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + "_full.from-text")
+ props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + "_full.from-text")
}
mctx.CreateModule(ApiLibraryFactory, &props)
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 7ba1f6d..c22b980 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1442,35 +1442,35 @@
`)
testCases := []struct {
- scope *apiScope
- apiContributions []string
- depApiSrcs string
+ scope *apiScope
+ apiContributions []string
+ fullApiSurfaceStub string
}{
{
- scope: apiScopePublic,
- apiContributions: []string{"foo.stubs.source.api.contribution"},
- depApiSrcs: "android_stubs_current.from-text",
+ scope: apiScopePublic,
+ apiContributions: []string{"foo.stubs.source.api.contribution"},
+ fullApiSurfaceStub: "android_stubs_current.from-text",
},
{
- scope: apiScopeSystem,
- apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
- depApiSrcs: "android_system_stubs_current.from-text",
+ scope: apiScopeSystem,
+ apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ fullApiSurfaceStub: "android_system_stubs_current.from-text",
},
{
- scope: apiScopeTest,
- apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
- depApiSrcs: "android_test_stubs_current.from-text",
+ scope: apiScopeTest,
+ apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ fullApiSurfaceStub: "android_test_stubs_current.from-text",
},
{
- scope: apiScopeModuleLib,
- apiContributions: []string{"foo.stubs.source.module_lib.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
- depApiSrcs: "android_module_lib_stubs_current_full.from-text",
+ scope: apiScopeModuleLib,
+ apiContributions: []string{"foo.stubs.source.module_lib.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ fullApiSurfaceStub: "android_module_lib_stubs_current_full.from-text",
},
}
for _, c := range testCases {
m := result.ModuleForTests(c.scope.apiLibraryModuleName("foo"), "android_common").Module().(*ApiLibrary)
android.AssertArrayString(t, "Module expected to contain api contributions", c.apiContributions, m.properties.Api_contributions)
- android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.depApiSrcs, *m.properties.Dep_api_srcs)
+ android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.fullApiSurfaceStub, *m.properties.Full_api_surface_stub)
}
}
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 894109a..d830968 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -1194,3 +1194,58 @@
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "")
})
}
+
+func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"),
+ java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"),
+ prepareForSdkTestWithApex,
+ // Add a platform_bootclasspath that depends on the fragment.
+ fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
+ android.FixtureMergeEnv(map[string]string{
+ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
+ }),
+ android.FixtureWithRootAndroidBp(`
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "S",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary", "mynewsdklibrary"],
+ hidden_api: {
+ split_packages: [],
+ },
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ shared_library: false,
+ public: {enabled: true},
+ min_sdk_version: "Tiramisu",
+ }
+ java_sdk_library {
+ name: "mynewsdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ compile_dex: true,
+ public: {enabled: true},
+ min_sdk_version: "Tiramisu",
+ permitted_packages: ["mynewsdklibrary"],
+ }
+ `),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`))
+}
diff --git a/sdk/bp.go b/sdk/bp.go
index 7ff85a1..57eb2ca 100644
--- a/sdk/bp.go
+++ b/sdk/bp.go
@@ -311,13 +311,15 @@
}
func (m *bpModule) deepCopy() *bpModule {
- return m.transform(deepCopyTransformer)
+ return transformModule(m, deepCopyTransformer)
}
-func (m *bpModule) transform(transformer bpTransformer) *bpModule {
+func transformModule(m *bpModule, transformer bpTransformer) *bpModule {
transformedModule := transformer.transformModule(m)
- // Copy the contents of the returned property set into the module and then transform that.
- transformedModule.bpPropertySet, _ = transformPropertySet(transformer, "", transformedModule.bpPropertySet, nil)
+ if transformedModule != nil {
+ // Copy the contents of the returned property set into the module and then transform that.
+ transformedModule.bpPropertySet, _ = transformPropertySet(transformer, "", transformedModule.bpPropertySet, nil)
+ }
return transformedModule
}
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 66c44c8..7ccc114 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -86,6 +86,51 @@
)
}
+func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
+ commonSdk := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "Tiramisu",
+ systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+ systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "34", // UpsideDownCake
+ }
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ `
+
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary"),
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:mysdklibrary"),
+ android.FixtureModifyEnv(func(env map[string]string) {
+ // targeting Tiramisu here means that we won't export mysdklibrary
+ env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = "Tiramisu"
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake"}
+ }),
+ prepareForSdkTestWithApex,
+ android.FixtureWithRootAndroidBp(commonSdk),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`))
+}
+
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
commonSdk := `
diff --git a/sdk/update.go b/sdk/update.go
index d3c59b0..4c39fae 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -455,11 +455,14 @@
for _, module := range builder.prebuiltOrder {
// Prune any empty property sets.
- module = module.transform(pruneEmptySetTransformer{})
+ module = transformModule(module, pruneEmptySetTransformer{})
// Transform the module module to make it suitable for use in the snapshot.
- module.transform(snapshotTransformer)
- bpFile.AddModule(module)
+ module = transformModule(module, snapshotTransformer)
+ module = transformModule(module, emptyClasspathContentsTransformation{})
+ if module != nil {
+ bpFile.AddModule(module)
+ }
}
// generate Android.bp
@@ -835,9 +838,11 @@
}
func (t snapshotTransformation) transformModule(module *bpModule) *bpModule {
- // If the module is an internal member then use a unique name for it.
- name := module.Name()
- module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ if module != nil {
+ // If the module is an internal member then use a unique name for it.
+ name := module.Name()
+ module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ }
return module
}
@@ -850,6 +855,25 @@
}
}
+type emptyClasspathContentsTransformation struct {
+ identityTransformation
+}
+
+func (t emptyClasspathContentsTransformation) transformModule(module *bpModule) *bpModule {
+ classpathModuleTypes := []string{
+ "prebuilt_bootclasspath_fragment",
+ "prebuilt_systemserverclasspath_fragment",
+ }
+ if module != nil && android.InList(module.moduleType, classpathModuleTypes) {
+ if contents, ok := module.bpPropertySet.properties["contents"].([]string); ok {
+ if len(contents) == 0 {
+ return nil
+ }
+ }
+ }
+ return module
+}
+
type pruneEmptySetTransformer struct {
identityTransformation
}
diff --git a/ui/build/config.go b/ui/build/config.go
index e642772..fb5f7dd 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -1375,10 +1375,15 @@
}
func (c *configImpl) UseRBE() bool {
+ // These alternate modes of running Soong do not use RBE / reclient.
+ if c.Bp2Build() || c.Queryview() || c.ApiBp2build() || c.JsonModuleGraph() {
+ return false
+ }
+
authType, _ := c.rbeAuth()
// Do not use RBE with prod credentials in scenarios when stubby doesn't exist, since
// its unlikely that we will be able to obtain necessary creds without stubby.
- if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds"){
+ if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") {
return false
}
if v, ok := c.Environment().Get("USE_RBE"); ok {