Merge "Revert "Revert "Add tzdata do the Bazel mixed build prod mode allowlist."""
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index bfa0a6e..5658503 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -374,9 +374,12 @@
"packages/apps/Music":/* recursive = */ true,
"packages/apps/QuickSearchBox":/* recursive = */ true,
+ "prebuilts/abi-dumps/platform":/* recursive = */ true,
+ "prebuilts/abi-dumps/ndk":/* recursive = */ true,
"prebuilts/bazel":/* recursive = */ true,
"prebuilts/bundletool":/* recursive = */ true,
"prebuilts/clang/host/linux-x86":/* recursive = */ false,
+ "prebuilts/clang-tools":/* recursive = */ true,
"prebuilts/gcc":/* recursive = */ true,
"prebuilts/build-tools":/* recursive = */ true,
"prebuilts/jdk/jdk11":/* recursive = */ false,
@@ -726,7 +729,6 @@
// aar support
"prebuilt_car-ui-androidx-core-common", // TODO(b/224773339), genrule dependency creates an .aar, not a .jar
- "prebuilt_platform-robolectric-4.4-prebuilt", // aosp/1999250, needs .aar support in Jars
"prebuilt_platform-robolectric-4.5.1-prebuilt", // aosp/1999250, needs .aar support in Jars
// ERROR: The dependencies for the following 1 jar(s) are not complete.
// 1.bazel-out/android_target-fastbuild/bin/prebuilts/tools/common/m2/_aar/robolectric-monitor-1.0.2-alpha1/classes_and_libs_merged.jar
@@ -1345,7 +1347,6 @@
"prebuilt_kotlin-stdlib-jdk8",
"prebuilt_kotlin-test",
// TODO(b/217750501) exclude_files property not supported
- "prebuilt_platform-robolectric-4.4-prebuilt",
"prebuilt_platform-robolectric-4.5.1-prebuilt",
"prebuilt_currysrc_org.eclipse",
}
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..f430b72 100644
--- a/android/config.go
+++ b/android/config.go
@@ -536,7 +536,40 @@
// 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
+ }
+ if c.IsEnvTrue("GLOBAL_THINLTO") {
+ fmt.Fprintln(os.Stderr, "unsupported env var GLOBAL_THINLTO for Bazel: falling back to non-mixed build")
+ return false
+ }
+ if c.IsEnvTrue("CLANG_COVERAGE") {
+ fmt.Fprintln(os.Stderr, "unsupported env var CLANG_COVERAGE for Bazel: falling back to non-mixed build")
+ return false
+ }
+ if len(c.productVariables.SanitizeHost) > 0 {
+ fmt.Fprintln(os.Stderr, "unsupported product var SanitizeHost for Bazel: falling back to non-mixed build")
+ return false
+ }
+ if len(c.productVariables.SanitizeDevice) > 0 {
+ fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDevice for Bazel: falling back to non-mixed build")
+ return false
+ }
+ if len(c.productVariables.SanitizeDeviceDiag) > 0 {
+ fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDeviceDiag for Bazel: falling back to non-mixed build")
+ return false
+ }
+ if len(c.productVariables.SanitizeDeviceArch) > 0 {
+ fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDeviceArch for Bazel: falling back to non-mixed build")
+ return false
+ }
+ return true
+ }).(bool)
+
+ bazelModeEnabled := c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode || c.BuildMode == BazelStagingMode
+ return globalMixedBuildsSupport && bazelModeEnabled
}
func (c *config) SetAllowMissingDependencies() {
diff --git a/android/module.go b/android/module.go
index b41a898..681f724 100644
--- a/android/module.go
+++ b/android/module.go
@@ -2053,7 +2053,7 @@
}
func (m *ModuleBase) InstallInVendor() bool {
- return Bool(m.commonProperties.Vendor)
+ return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Soc_specific) || Bool(m.commonProperties.Proprietary)
}
func (m *ModuleBase) InstallInRoot() bool {
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/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 61acf68..edb0c43 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1409,6 +1409,7 @@
"strip": true,
"inject_bssl_hash": true,
"has_stubs": true,
+ "stubs_symbol_file": true,
"use_version_lib": true,
}
@@ -2710,7 +2711,8 @@
func TestCcLibraryStubs(t *testing.T) {
expectedBazelTargets := makeCcLibraryTargets("a", AttrNameToString{
- "has_stubs": `True`,
+ "has_stubs": `True`,
+ "stubs_symbol_file": `"a.map.txt"`,
})
expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{
"soname": `"a.so"`,
@@ -3600,3 +3602,46 @@
},
})
}
+
+func TestCcLibraryHeaderAbiChecker(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library with header abi checker",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `cc_library {
+ name: "foo",
+ header_abi_checker: {
+ enabled: true,
+ symbol_file: "a.map.txt",
+ exclude_symbol_versions: [
+ "29",
+ "30",
+ ],
+ exclude_symbol_tags: [
+ "tag1",
+ "tag2",
+ ],
+ check_all_apis: true,
+ diff_flags: ["-allow-adding-removing-weak-symbols"],
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{}),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "abi_checker_enabled": `True`,
+ "abi_checker_symbol_file": `"a.map.txt"`,
+ "abi_checker_exclude_symbol_versions": `[
+ "29",
+ "30",
+ ]`,
+ "abi_checker_exclude_symbol_tags": `[
+ "tag1",
+ "tag2",
+ ]`,
+ "abi_checker_check_all_apis": `True`,
+ "abi_checker_diff_flags": `["-allow-adding-removing-weak-symbols"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index b86f607..7e1d111 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -543,7 +543,8 @@
]`,
}),
MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
- "has_stubs": `True`,
+ "has_stubs": `True`,
+ "stubs_symbol_file": `"a.map.txt"`,
}),
},
})
@@ -845,3 +846,43 @@
},
})
}
+
+func TestCcLibrarySharedHeaderAbiChecker(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared with header abi checker",
+ Blueprint: `cc_library_shared {
+ name: "foo",
+ header_abi_checker: {
+ enabled: true,
+ symbol_file: "a.map.txt",
+ exclude_symbol_versions: [
+ "29",
+ "30",
+ ],
+ exclude_symbol_tags: [
+ "tag1",
+ "tag2",
+ ],
+ check_all_apis: true,
+ diff_flags: ["-allow-adding-removing-weak-symbols"],
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "abi_checker_enabled": `True`,
+ "abi_checker_symbol_file": `"a.map.txt"`,
+ "abi_checker_exclude_symbol_versions": `[
+ "29",
+ "30",
+ ]`,
+ "abi_checker_exclude_symbol_tags": `[
+ "tag1",
+ "tag2",
+ ]`,
+ "abi_checker_check_all_apis": `True`,
+ "abi_checker_diff_flags": `["-allow-adding-removing-weak-symbols"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go
index 00056f8..e37fa62 100644
--- a/bp2build/java_library_conversion_test.go
+++ b/bp2build/java_library_conversion_test.go
@@ -53,11 +53,13 @@
ExpectedBazelTargets: []string{
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
"srcs": `["a.java"]`,
- "deps": `[":java-lib-2"]`,
+ "deps": `[":java-lib-2-neverlink"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
"srcs": `["b.java"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
},
})
}
@@ -87,11 +89,12 @@
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
"srcs": `["a.java"]`,
"deps": `[
- ":java-lib-2",
+ ":java-lib-2-neverlink",
":java-lib-3",
]`,
"exports": `[":java-lib-3"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -113,6 +116,7 @@
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
"exports": `[":java-lib-2"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -152,6 +156,7 @@
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
"plugins": `[":java-plugin-1"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
}, func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("java_plugin", java.PluginFactory)
@@ -170,6 +175,7 @@
"srcs": `["a.java"]`,
"javacopts": `["-source 11 -target 11"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -193,6 +199,7 @@
]`,
"srcs": `["a.java"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -212,6 +219,7 @@
"javacopts": `["-Xsuper-fast"]`,
"srcs": `["a.java"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -232,6 +240,7 @@
"javacopts": `["-Xsuper-fast"]`,
"srcs": `["a.java"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -265,6 +274,7 @@
":example_lib_logtags",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
}})
}
@@ -286,6 +296,7 @@
"res/b.res",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -310,6 +321,7 @@
"res/dir1/b.res",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -330,6 +342,7 @@
"resource_strip_prefix": `"res"`,
"resources": `["res/a.res"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -354,6 +367,7 @@
"res/dir1/b.res",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
},
})
}
@@ -406,6 +420,7 @@
"b.java",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
}})
}
@@ -435,6 +450,7 @@
"exports": `[":example_lib_java_aidl_library"]`,
"srcs": `["a.java"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
},
}, func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
@@ -490,6 +506,7 @@
":random_other_files",
]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
MakeBazelTargetNoRestrictions("filegroup", "random_other_files", AttrNameToString{
"srcs": `[
"a.java",
@@ -529,6 +546,7 @@
MakeBazelTarget("java_library", "foo", AttrNameToString{
"exports": `[":foo_java_aidl_library"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "foo"),
},
}, func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
diff --git a/bp2build/java_library_host_conversion_test.go b/bp2build/java_library_host_conversion_test.go
index edd8690..14854c0 100644
--- a/bp2build/java_library_host_conversion_test.go
+++ b/bp2build/java_library_host_conversion_test.go
@@ -48,7 +48,15 @@
ExpectedBazelTargets: []string{
MakeBazelTarget("java_library", "java-lib-host-1", AttrNameToString{
"srcs": `["a.java"]`,
- "deps": `[":java-lib-host-2"]`,
+ "deps": `[":java-lib-host-2-neverlink"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_library", "java-lib-host-1-neverlink", AttrNameToString{
+ "exports": `[":java-lib-host-1"]`,
+ "neverlink": `True`,
"target_compatible_with": `select({
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
"//conditions:default": [],
@@ -62,6 +70,14 @@
"//conditions:default": [],
})`,
}),
+ MakeBazelTarget("java_library", "java-lib-host-2-neverlink", AttrNameToString{
+ "exports": `[":java-lib-host-2"]`,
+ "neverlink": `True`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
},
})
}
diff --git a/bp2build/java_proto_conversion_test.go b/bp2build/java_proto_conversion_test.go
index df0df2f..d25b7c4 100644
--- a/bp2build/java_proto_conversion_test.go
+++ b/bp2build/java_proto_conversion_test.go
@@ -91,6 +91,7 @@
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
"exports": fmt.Sprintf(`[":%s"]`, javaLibraryName),
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-protos"),
},
})
}
@@ -119,6 +120,7 @@
"exports": `[":java-protos_java_proto_lite"]`,
"javacopts": `["-source 1.7 -target 1.7"]`,
}),
+ MakeNeverlinkDuplicateTarget("java_library", "java-protos"),
},
})
}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 0f1a8b2..4e63d19 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -532,3 +532,10 @@
}
return MakeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs)
}
+
+func MakeNeverlinkDuplicateTarget(moduleType string, name string) string {
+ return MakeBazelTarget(moduleType, name+"-neverlink", AttrNameToString{
+ "neverlink": `True`,
+ "exports": `[":` + name + `"]`,
+ })
+}
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/cc/library.go b/cc/library.go
index 0729ff4..673f1ca 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -411,13 +411,15 @@
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
- Strip: stripAttrsFromLinkerAttrs(&linkerAttrs),
- Features: baseAttributes.features,
+ Strip: stripAttrsFromLinkerAttrs(&linkerAttrs),
+ Features: baseAttributes.features,
+ bazelCcHeaderAbiCheckerAttributes: bp2buildParseAbiCheckerProps(ctx, m),
}
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
hasStubs := true
sharedTargetAttrs.Has_stubs.SetValue(&hasStubs)
+ sharedTargetAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
}
sharedTargetAttrs.Suffix = compilerAttrs.suffix
@@ -1735,7 +1737,6 @@
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
-
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
@@ -2757,6 +2758,29 @@
return outputFile
}
+func bp2buildParseAbiCheckerProps(ctx android.TopDownMutatorContext, module *Module) bazelCcHeaderAbiCheckerAttributes {
+ lib, ok := module.linker.(*libraryDecorator)
+ if !ok {
+ return bazelCcHeaderAbiCheckerAttributes{}
+ }
+
+ abiChecker := lib.Properties.Header_abi_checker
+
+ abiCheckerAttrs := bazelCcHeaderAbiCheckerAttributes{
+ Abi_checker_enabled: abiChecker.Enabled,
+ Abi_checker_exclude_symbol_versions: abiChecker.Exclude_symbol_versions,
+ Abi_checker_exclude_symbol_tags: abiChecker.Exclude_symbol_tags,
+ Abi_checker_check_all_apis: abiChecker.Check_all_apis,
+ Abi_checker_diff_flags: abiChecker.Diff_flags,
+ }
+ if abiChecker.Symbol_file != nil {
+ symbolFile := android.BazelLabelForModuleSrcSingle(ctx, *abiChecker.Symbol_file)
+ abiCheckerAttrs.Abi_checker_symbol_file = &symbolFile
+ }
+
+ return abiCheckerAttrs
+}
+
func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module, isStatic bool) {
baseAttributes := bp2BuildParseBaseProps(ctx, module)
compilerAttrs := baseAttributes.compilerAttributes
@@ -2863,10 +2887,13 @@
Features: baseAttributes.features,
Suffix: compilerAttrs.suffix,
+
+ bazelCcHeaderAbiCheckerAttributes: bp2buildParseAbiCheckerProps(ctx, module),
}
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
hasStubs := true
sharedLibAttrs.Has_stubs.SetValue(&hasStubs)
+ sharedLibAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
}
attrs = sharedLibAttrs
}
@@ -2943,11 +2970,14 @@
Features bazel.StringListAttribute
- Has_stubs bazel.BoolAttribute
+ Has_stubs bazel.BoolAttribute
+ Stubs_symbol_file *string
Inject_bssl_hash bazel.BoolAttribute
Suffix bazel.StringAttribute
+
+ bazelCcHeaderAbiCheckerAttributes
}
type bazelCcStubSuiteAttributes struct {
@@ -2958,3 +2988,12 @@
Soname *string
Deps bazel.LabelListAttribute
}
+
+type bazelCcHeaderAbiCheckerAttributes struct {
+ Abi_checker_enabled *bool
+ Abi_checker_symbol_file *bazel.Label
+ Abi_checker_exclude_symbol_versions []string
+ Abi_checker_exclude_symbol_tags []string
+ Abi_checker_check_all_apis *bool
+ Abi_checker_diff_flags []string
+}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index d704e32..2473ba2 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -396,14 +396,14 @@
}
func (this *stubDecorator) diffAbi(ctx ModuleContext) {
- missingPrebuiltError := fmt.Sprintf(
- "Did not find prebuilt ABI dump for %q. Generate with "+
- "//development/tools/ndk/update_ndk_abi.sh.", this.libraryName(ctx))
-
// Catch any ABI changes compared to the checked-in definition of this API
// level.
abiDiffPath := android.PathForModuleOut(ctx, "abidiff.timestamp")
prebuiltAbiDump := this.findPrebuiltAbiDump(ctx, this.apiLevel)
+ missingPrebuiltError := fmt.Sprintf(
+ "Did not find prebuilt ABI dump for %q (%q). Generate with "+
+ "//development/tools/ndk/update_ndk_abi.sh.", this.libraryName(ctx),
+ prebuiltAbiDump.InvalidReason())
if !prebuiltAbiDump.Valid() {
ctx.Build(pctx, android.BuildParams{
Rule: android.ErrorRule,
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index bc2d5cb..3bc311b 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -276,6 +276,7 @@
src != "BUILD" &&
src != "BUILD.bazel" &&
!strings.HasPrefix(src, "build/bazel") &&
+ !strings.HasPrefix(src, "external/bazel-skylib") &&
!strings.HasPrefix(src, "prebuilts/clang") {
ret = append(ret, src)
}
@@ -578,6 +579,17 @@
// FIXME: 'frameworks/compile/slang' has a filegroup error due to an escaping issue
excludes = append(excludes, "frameworks/compile/slang")
+ // FIXME(b/260809113): 'prebuilts/clang/host/linux-x86/clang-dev' is a tool-generated symlink directory that contains a BUILD file.
+ // The bazel files finder code doesn't traverse into symlink dirs, and hence is not aware of this BUILD file and exclude it accordingly
+ // during symlink forest generation when checking against keepExistingBuildFiles allowlist.
+ //
+ // This is necessary because globs in //prebuilts/clang/host/linux-x86/BUILD
+ // currently assume no subpackages (keepExistingBuildFile is not recursive for that directory).
+ //
+ // This is a bandaid until we the symlink forest logic can intelligently exclude BUILD files found in source symlink dirs according
+ // to the keepExistingBuildFile allowlist.
+ excludes = append(excludes, "prebuilts/clang/host/linux-x86/clang-dev")
+
return excludes
}
diff --git a/cmd/soong_build/queryview.go b/cmd/soong_build/queryview.go
index cd1d6fb..a876522 100644
--- a/cmd/soong_build/queryview.go
+++ b/cmd/soong_build/queryview.go
@@ -15,6 +15,7 @@
package main
import (
+ "io/fs"
"io/ioutil"
"os"
"path/filepath"
@@ -35,6 +36,11 @@
filesToWrite := bp2build.CreateBazelFiles(ctx.Config(), ruleShims, res.BuildDirToTargets(),
ctx.Mode())
+ bazelRcFiles, err2 := CopyBazelRcFiles()
+ if err2 != nil {
+ return err2
+ }
+ filesToWrite = append(filesToWrite, bazelRcFiles...)
for _, f := range filesToWrite {
if err := writeReadOnlyFile(outDir, f); err != nil {
return err
@@ -44,6 +50,32 @@
return nil
}
+// CopyBazelRcFiles creates BazelFiles for all the bazelrc files under
+// build/bazel. They're needed because the rc files are still read when running
+// queryview, so they have to be in the queryview workspace.
+func CopyBazelRcFiles() ([]bp2build.BazelFile, error) {
+ result := make([]bp2build.BazelFile, 0)
+ err := filepath.WalkDir(filepath.Join(topDir, "build/bazel"), func(path string, info fs.DirEntry, err error) error {
+ if filepath.Ext(path) == ".bazelrc" {
+ contents, err := os.ReadFile(path)
+ if err != nil {
+ return err
+ }
+ path, err = filepath.Rel(topDir, path)
+ if err != nil {
+ return err
+ }
+ result = append(result, bp2build.BazelFile{
+ Dir: filepath.Dir(path),
+ Basename: filepath.Base(path),
+ Contents: string(contents),
+ })
+ }
+ return nil
+ })
+ return result, err
+}
+
// The auto-conversion directory should be read-only, sufficient for bazel query. The files
// are not intended to be edited by end users.
func writeReadOnlyFile(dir string, f bp2build.BazelFile) error {
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..e37a77e 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)
}
@@ -1648,7 +1662,7 @@
var srcFiles []android.Path
ctx.VisitDirectDepsWithTag(javaApiContributionTag, func(dep android.Module) {
provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
- srcFiles = append(srcFiles, android.PathForModuleSrc(ctx, provider.ApiFile.String()))
+ srcFiles = append(srcFiles, android.PathForSource(ctx, provider.ApiFile.String()))
})
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir)
@@ -1673,6 +1687,8 @@
TransformJavaToClasses(ctx, al.stubsJar, 0, android.Paths{},
android.Paths{al.stubsSrcJar}, flags, android.Paths{})
+
+ ctx.Phony(ctx.ModuleName(), al.stubsJar)
}
//
@@ -2606,7 +2622,7 @@
if m.properties.Libs != nil {
// TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't
- if strings.HasPrefix(ctx.ModuleType(), "java_binary") {
+ if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") {
for _, d := range m.properties.Libs {
neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
@@ -2674,12 +2690,21 @@
Deps: deps,
Exports: depLabels.StaticDeps,
}
+ name := m.Name()
if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
props = bazel.BazelTargetModuleProperties{
Rule_class: "java_library",
Bzl_load_location: "//build/bazel/rules/java:library.bzl",
}
+
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
+ neverlinkProp := true
+ neverLinkAttrs := &javaLibraryAttributes{
+ Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
+ Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
+ }
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs)
} else {
attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
@@ -2687,10 +2712,10 @@
Rule_class: "kt_jvm_library",
Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl",
}
+ // TODO (b/244210934): create neverlink-duplicate target once kt_jvm_library supports neverlink attribute
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
}
- name := m.Name()
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
}
type javaBinaryHostAttributes struct {
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"],
}