Merge "Revert "Update clang version to clang-r475365""
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 24731e8..0718da3 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -364,6 +364,7 @@
"external/guava":/* recursive = */ true,
"external/jsr305":/* recursive = */ true,
"external/protobuf":/* recursive = */ false,
+ "external/python/absl-py":/* recursive = */ true,
// this BUILD file is globbed by //external/icu/icu4c/source:icu4c_test_data's "data/**/*".
"external/icu/icu4c/source/data/unidata/norm2":/* recursive = */ false,
diff --git a/android/bazel.go b/android/bazel.go
index 60989f6..3731dfe 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -383,6 +383,9 @@
// mixedBuildPossible returns true if a module is ready to be replaced by a
// converted or handcrafted Bazel target.
func mixedBuildPossible(ctx BaseModuleContext) bool {
+ if !ctx.Config().IsMixedBuildsEnabled() {
+ return false
+ }
if ctx.Os() == Windows {
// Windows toolchains are not currently supported.
return false
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 9ed8f78..acb81a4 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -81,7 +81,7 @@
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
- // - `target` is the only parameter to this function (a configured target).
+ // - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
StarlarkFunctionBody() string
@@ -743,12 +743,12 @@
}
`
functionDefFormatString := `
-def %s(target):
+def %s(target, id_string):
%s
`
mainSwitchSectionFormatString := `
if id_string in %s:
- return id_string + ">>" + %s(target)
+ return id_string + ">>" + %s(target, id_string)
`
for requestType := range requestTypeToCqueryIdEntries {
diff --git a/android/config.go b/android/config.go
index 1deb7d4..52a8f13 100644
--- a/android/config.go
+++ b/android/config.go
@@ -536,7 +536,17 @@
// Returns true if "Bazel builds" is enabled. In this mode, part of build
// analysis is handled by Bazel.
func (c *config) IsMixedBuildsEnabled() bool {
- return c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode || c.BuildMode == BazelStagingMode
+ globalMixedBuildsSupport := c.Once(OnceKey{"globalMixedBuildsSupport"}, func() interface{} {
+ if c.productVariables.DeviceArch != nil && *c.productVariables.DeviceArch == "riscv64" {
+ fmt.Fprintln(os.Stderr, "unsupported device arch 'riscv64' for Bazel: falling back to non-mixed build")
+ return false
+ }
+ // TODO(b/253664931): Add other fallback criteria below.
+ return true
+ }).(bool)
+
+ bazelModeEnabled := c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode || c.BuildMode == BazelStagingMode
+ return globalMixedBuildsSupport && bazelModeEnabled
}
func (c *config) SetAllowMissingDependencies() {
diff --git a/android/test_config.go b/android/test_config.go
index de546c4..70c319a 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -62,6 +62,7 @@
TestAllowNonExistentPaths: true,
BazelContext: noopBazelContext{},
+ BuildMode: BazelProdMode,
mixedBuildDisabledModules: make(map[string]struct{}),
mixedBuildEnabledModules: make(map[string]struct{}),
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index ea3e734..883c3c8 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -8413,6 +8413,30 @@
}
}
+func TestApexSet_NativeBridge(t *testing.T) {
+ ctx := testApex(t, `
+ apex_set {
+ name: "myapex",
+ set: "myapex.apks",
+ filename: "foo_v2.apex",
+ overrides: ["foo"],
+ }
+ `,
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.Targets[android.Android] = []android.Target{
+ {Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "", Abi: []string{"x86_64"}}},
+ {Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridge: android.NativeBridgeEnabled},
+ }
+ }),
+ )
+
+ m := ctx.ModuleForTests("myapex.apex.extractor", "android_common")
+
+ // Check extract_apks tool parameters. No native bridge arch expected
+ extractedApex := m.Output("extracted/myapex.apks")
+ android.AssertStringEquals(t, "abis", "X86_64", extractedApex.Args["abis"])
+}
+
func TestNoStaticLinkingToStubsLib(t *testing.T) {
testApexError(t, `.*required by "mylib" is a native library providing stub.*`, `
apex {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 39446a1..6fdd50a 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -24,6 +24,7 @@
"android/soong/android"
"android/soong/java"
"android/soong/provenance"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -831,6 +832,8 @@
}
apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set")
p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base())
+ // Filter out NativeBridge archs (b/260115309)
+ abis := java.SupportedAbis(ctx, true)
ctx.Build(pctx,
android.BuildParams{
Rule: extractMatchingApex,
@@ -838,7 +841,7 @@
Inputs: android.Paths{apexSet},
Output: p.extractedApex,
Args: map[string]string{
- "abis": strings.Join(java.SupportedAbis(ctx), ","),
+ "abis": strings.Join(abis, ","),
"allow-prereleased": strconv.FormatBool(proptools.Bool(p.properties.Prerelease)),
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
},
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index b675f17..e4830d3 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -50,7 +50,7 @@
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
-// - `target` is the only parameter to this function (a configured target).
+// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
func (g getOutputFilesRequestType) StarlarkFunctionBody() string {
@@ -75,7 +75,7 @@
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
-// - `target` is the only parameter to this function (a configured target).
+// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
func (g getPythonBinaryRequestType) StarlarkFunctionBody() string {
@@ -102,13 +102,16 @@
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
-// - `target` is the only parameter to this function (a configured target).
+// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
func (g getCcInfoType) StarlarkFunctionBody() string {
return `
outputFiles = [f.path for f in target.files.to_list()]
-cc_info = providers(target)["CcInfo"]
+p = providers(target)
+cc_info = p.get("CcInfo")
+if not cc_info:
+ fail("%s did not provide CcInfo" % id_string)
includes = cc_info.compilation_context.includes.to_list()
system_includes = cc_info.compilation_context.system_includes.to_list()
@@ -120,8 +123,8 @@
linker_inputs = cc_info.linking_context.linker_inputs.to_list()
static_info_tag = "//build/bazel/rules/cc:cc_library_static.bzl%CcStaticLibraryInfo"
-if static_info_tag in providers(target):
- static_info = providers(target)[static_info_tag]
+if static_info_tag in p:
+ static_info = p[static_info_tag]
ccObjectFiles = [f.path for f in static_info.objects]
rootStaticArchives = [static_info.root_static_archive.path]
else:
@@ -141,14 +144,14 @@
unstripped_tag = "//build/bazel/rules/cc:stripped_cc_common.bzl%CcUnstrippedInfo"
unstripped = ""
-if shared_info_tag in providers(target):
- shared_info = providers(target)[shared_info_tag]
+if shared_info_tag in p:
+ shared_info = p[shared_info_tag]
path = shared_info.output_file.path
sharedLibraries.append(path)
rootSharedLibraries += [path]
unstripped = path
- if unstripped_tag in providers(target):
- unstripped = providers(target)[unstripped_tag].unstripped.path
+ if unstripped_tag in p:
+ unstripped = p[unstripped_tag].unstripped.path
else:
for linker_input in linker_inputs:
for library in linker_input.libraries:
@@ -160,14 +163,13 @@
toc_file = ""
toc_file_tag = "//build/bazel/rules/cc:generate_toc.bzl%CcTocInfo"
-if toc_file_tag in providers(target):
- toc_file = providers(target)[toc_file_tag].toc.path
+if toc_file_tag in p:
+ toc_file = p[toc_file_tag].toc.path
else:
# NOTE: It's OK if there's no ToC, as Soong just uses it for optimization
pass
tidy_files = []
-p = providers(target)
clang_tidy_info = p.get("//build/bazel/rules/cc:clang_tidy.bzl%ClangTidyInfo")
if clang_tidy_info:
tidy_files = [v.path for v in clang_tidy_info.tidy_files.to_list()]
@@ -213,11 +215,14 @@
// The returned string is the body of a Starlark function which obtains
// all request-relevant information about a target and returns a string containing
// this information. The function should have the following properties:
-// - `target` is the only parameter to this function (a configured target).
+// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
func (g getApexInfoType) StarlarkFunctionBody() string {
- return `info = providers(target)["//build/bazel/rules/apex:apex.bzl%ApexInfo"]
+ return `
+info = providers(target).get("//build/bazel/rules/apex:apex.bzl%ApexInfo")
+if not info:
+ fail("%s did not provide ApexInfo" % id_string)
bundle_key_info = info.bundle_key_info
container_key_info = info.container_key_info
return json_encode({
diff --git a/cc/config/global.go b/cc/config/global.go
index e5c0a8e..8047d8e 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -240,7 +240,6 @@
// New warnings to be fixed after clang-r458507
"-Wno-error=unqualified-std-cast-call", // http://b/239662094
// New warnings to be fixed after clang-r468909
- "-Wno-error=array-parameter", // http://b/241941550
"-Wno-error=deprecated-builtins", // http://b/241601211
"-Wno-error=deprecated", // in external/googletest/googletest
}
@@ -253,6 +252,8 @@
"-Wno-bitwise-instead-of-logical",
// http://b/232926688
"-Wno-misleading-indentation",
+ // http://b/241941550
+ "-Wno-array-parameter",
}
// Extra cflags for external third-party projects to disable warnings that
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 19166d2..f7689b9 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -183,6 +183,7 @@
buildErrorFile := filepath.Join(logsDir, c.logsPrefix+"build_error")
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
+ bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
build.PrintOutDirWarning(buildCtx, config)
@@ -210,6 +211,7 @@
files := []string{
buildErrorFile, // build error strings
rbeMetricsFile, // high level metrics related to remote build execution.
+ bp2buildMetricsFile, // high level metrics related to bp2build.
soongMetricsFile, // high level metrics related to this build system.
config.BazelMetricsDir(), // directory that contains a set of bazel metrics.
}
diff --git a/java/app_set.go b/java/app_set.go
index d8c2a8d..0f55b77 100644
--- a/java/app_set.go
+++ b/java/app_set.go
@@ -98,7 +98,7 @@
"x86_64": "X86_64",
}
-func SupportedAbis(ctx android.ModuleContext) []string {
+func SupportedAbis(ctx android.ModuleContext, excludeNativeBridgeAbis bool) []string {
abiName := func(targetIdx int, deviceArch string) string {
if abi, found := TargetCpuAbi[deviceArch]; found {
return abi
@@ -109,6 +109,9 @@
var result []string
for i, target := range ctx.Config().Targets[android.Android] {
+ if target.NativeBridge == android.NativeBridgeEnabled && excludeNativeBridgeAbis {
+ continue
+ }
result = append(result, abiName(i, target.Arch.ArchType.String()))
}
return result
@@ -135,7 +138,7 @@
ImplicitOutputs: android.WritablePaths{as.packedOutput, as.apkcertsFile},
Inputs: android.Paths{as.prebuilt.SingleSourcePath(ctx)},
Args: map[string]string{
- "abis": strings.Join(SupportedAbis(ctx), ","),
+ "abis": strings.Join(SupportedAbis(ctx, false), ","),
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
"screen-densities": screenDensities,
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 0adaf99..77cbe9c 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -269,8 +269,10 @@
targets = append(targets, target)
}
}
- if isSystemServerJar && !d.isSDKLibrary {
- // If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
+ if isSystemServerJar && moduleName(ctx) != "com.android.location.provider" {
+ // If the module is a system server jar, only preopt for the primary arch because the jar can
+ // only be loaded by system server. "com.android.location.provider" is a special case because
+ // it's also used by apps as a shared library.
targets = targets[:1]
}
}
diff --git a/java/java.go b/java/java.go
index 25b6349..6eeb95d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -764,6 +764,9 @@
// The list of permitted packages that need to be passed to the prebuilts as they are used to
// create the updatable-bcp-packages.txt file.
PermittedPackages []string
+
+ // The value of the min_sdk_version property, translated into a number where possible.
+ MinSdkVersion *string `supported_build_releases:"Tiramisu+"`
}
func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@@ -774,6 +777,13 @@
p.AidlIncludeDirs = j.AidlIncludeDirs()
p.PermittedPackages = j.PermittedPackagesForUpdatableBootJars()
+
+ // If the min_sdk_version was set then add the canonical representation of the API level to the
+ // snapshot.
+ if j.deviceProperties.Min_sdk_version != nil {
+ canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String())
+ p.MinSdkVersion = proptools.StringPtr(canonical)
+ }
}
func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -792,6 +802,10 @@
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
}
+ if p.MinSdkVersion != nil {
+ propertySet.AddProperty("min_sdk_version", *p.MinSdkVersion)
+ }
+
if len(p.PermittedPackages) > 0 {
propertySet.AddProperty("permitted_packages", p.PermittedPackages)
}
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 1b64130..92ecd5e 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -358,6 +358,7 @@
visibility: ["//visibility:public"],
apex_available: ["myapex"],
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
+ min_sdk_version: "2",
permitted_packages: ["mybootlib"],
}
@@ -877,6 +878,7 @@
visibility: ["//visibility:public"],
apex_available: ["myapex"],
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
+ min_sdk_version: "1",
permitted_packages: ["mybootlib"],
}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 51903ce3..2ade146 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -352,6 +352,73 @@
})
}
+func TestSnapshotWithJavaLibrary_MinSdkVersion(t *testing.T) {
+ runTest := func(t *testing.T, targetBuildRelease, minSdkVersion, expectedMinSdkVersion string) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"S", "Tiramisu", "Unfinalized"}
+ }),
+ android.FixtureMergeEnv(map[string]string{
+ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease,
+ }),
+ ).RunTestWithBp(t, fmt.Sprintf(`
+ sdk {
+ name: "mysdk",
+ java_header_libs: ["mylib"],
+ }
+
+ java_library {
+ name: "mylib",
+ srcs: ["Test.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ min_sdk_version: "%s",
+ }
+ `, minSdkVersion))
+
+ expectedMinSdkVersionLine := ""
+ if expectedMinSdkVersion != "" {
+ expectedMinSdkVersionLine = fmt.Sprintf(" min_sdk_version: %q,\n", expectedMinSdkVersion)
+ }
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkAndroidBpContents(fmt.Sprintf(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mylib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ jars: ["java/mylib.jar"],
+%s}
+`, expectedMinSdkVersionLine)),
+ )
+ }
+
+ t.Run("min_sdk_version=S in S", func(t *testing.T) {
+ // min_sdk_version was not added to java_import until Tiramisu.
+ runTest(t, "S", "S", "")
+ })
+
+ t.Run("min_sdk_version=S in Tiramisu", func(t *testing.T) {
+ // The canonical form of S is 31.
+ runTest(t, "Tiramisu", "S", "31")
+ })
+
+ t.Run("min_sdk_version=24 in Tiramisu", func(t *testing.T) {
+ // A numerical min_sdk_version is already in canonical form.
+ runTest(t, "Tiramisu", "24", "24")
+ })
+
+ t.Run("min_sdk_version=Unfinalized in latest", func(t *testing.T) {
+ // An unfinalized min_sdk_version has no numeric value yet.
+ runTest(t, "", "Unfinalized", "Unfinalized")
+ })
+}
+
func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 1ac405d..2a17cdc 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -120,6 +120,7 @@
visibility: ["//visibility:public"],
apex_available: ["myapex"],
jars: ["java_systemserver_libs/snapshot/jars/are/invalid/mylib.jar"],
+ min_sdk_version: "2",
permitted_packages: ["mylib"],
}
@@ -181,6 +182,7 @@
visibility: ["//visibility:public"],
apex_available: ["myapex"],
jars: ["java_systemserver_libs/snapshot/jars/are/invalid/mylib.jar"],
+ min_sdk_version: "2",
permitted_packages: ["mylib"],
}
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
index 679ac55..32cb003 100755
--- a/tests/bp2build_bazel_test.sh
+++ b/tests/bp2build_bazel_test.sh
@@ -65,7 +65,7 @@
outdir=out2
trap "rm -rf $outdir" EXIT
# Modify OUT_DIR in a subshell so it doesn't affect the top level one.
- (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build //a:g)
+ (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
}
test_different_relative_outdir
@@ -87,7 +87,7 @@
outdir=$(mktemp -t -d st.XXXXX)
trap 'rm -rf $outdir' EXIT
# Modify OUT_DIR in a subshell so it doesn't affect the top level one.
- (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build //a:g)
+ (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
}
test_different_absolute_outdir
@@ -146,7 +146,7 @@
fi
# NOTE: We don't actually use the extra BUILD file for anything here
- run_bazel build --config=android --package_path=out/soong/workspace //foo/...
+ run_bazel build --config=android --config=bp2build --config=ci //foo/...
local the_answer_file="bazel-out/android_target-fastbuild/bin/foo/convertible_soong_module/the_answer.txt"
if [[ ! -f "${the_answer_file}" ]]; then
@@ -191,10 +191,10 @@
run_soong bp2build
- run_bazel build --config=android --package_path=out/soong/workspace //a:qq
+ run_bazel build --config=android --config=bp2build --config=ci //a:qq
local -r output_mtime1=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
- run_bazel build --config=android --package_path=out/soong/workspace //a:qq
+ run_bazel build --config=android --config=bp2build --config=ci //a:qq
local -r output_mtime2=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
if [[ "$output_mtime1" != "$output_mtime2" ]]; then
@@ -205,7 +205,7 @@
#define QQ 2
EOF
- run_bazel build --config=android --package_path=out/soong/workspace //a:qq
+ run_bazel build --config=android --config=bp2build --config=ci //a:qq
local -r output_mtime3=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
if [[ "$output_mtime1" == "$output_mtime3" ]]; then
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index 1e07727..dbab7ec 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -12,4 +12,5 @@
# The following tests build against the full source tree and don't rely on the
# mock client.
-"$TOP/build/soong/tests/apex_comparison_tests.sh"
+# TODO(b/260278287) the bazel server won't shut down for some reason when run on the build server
+# "$TOP/build/soong/tests/apex_comparison_tests.sh"