Merge "Revert "Fix test to use --experimental_platform_in_output_dir.""
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 5d7a1be..4a5373f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -8289,6 +8289,75 @@
`)
}
+func TestAndroidMk_DexpreoptBuiltInstalledForApex(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ updatable: false,
+ java_libs: ["foo"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_library {
+ name: "foo",
+ srcs: ["foo.java"],
+ apex_available: ["myapex"],
+ installable: true,
+ }
+ `,
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
+ )
+
+ apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
+ data := android.AndroidMkDataForTest(t, ctx, apexBundle)
+ var builder strings.Builder
+ data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
+ androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex")
+}
+
+func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) {
+ ctx := testApex(t, `
+ prebuilt_apex {
+ name: "myapex",
+ arch: {
+ arm64: {
+ src: "myapex-arm64.apex",
+ },
+ arm: {
+ src: "myapex-arm.apex",
+ },
+ },
+ exported_java_libs: ["foo"],
+ }
+
+ java_import {
+ name: "foo",
+ jars: ["foo.jar"],
+ installable: true,
+ }
+ `,
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
+ )
+
+ prebuilt := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*Prebuilt)
+ entriesList := android.AndroidMkEntriesForTest(t, ctx, prebuilt)
+ mainModuleEntries := entriesList[0]
+ android.AssertArrayString(t,
+ "LOCAL_REQUIRED_MODULES",
+ mainModuleEntries.EntryMap["LOCAL_REQUIRED_MODULES"],
+ []string{
+ "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex",
+ "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex",
+ })
+}
+
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 53ef4d7..61e7a0b 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -264,17 +264,6 @@
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
// we will have foo.jar.jar
entries.SetString("LOCAL_MODULE_STEM", strings.TrimSuffix(fi.stem(), ".jar"))
- var classesJar android.Path
- var headerJar android.Path
- if javaModule, ok := fi.module.(java.ApexDependency); ok {
- classesJar = javaModule.ImplementationAndResourcesJars()[0]
- headerJar = javaModule.HeaderJars()[0]
- } else {
- classesJar = fi.builtFile
- headerJar = fi.builtFile
- }
- entries.SetString("LOCAL_SOONG_CLASSES_JAR", classesJar.String())
- entries.SetString("LOCAL_SOONG_HEADER_JAR", headerJar.String())
entries.SetString("LOCAL_SOONG_DEX_JAR", fi.builtFile.String())
entries.SetString("LOCAL_DEX_PREOPT", "false")
},
diff --git a/bazel/properties.go b/bazel/properties.go
index ee32e73..6a06c1b 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -164,48 +164,36 @@
// Subtract needle from haystack
func SubtractStrings(haystack []string, needle []string) []string {
// This is really a set
- remainder := make(map[string]bool)
-
- for _, s := range haystack {
- remainder[s] = true
- }
+ needleMap := make(map[string]bool)
for _, s := range needle {
- delete(remainder, s)
+ needleMap[s] = true
}
var strings []string
- for s, _ := range remainder {
- strings = append(strings, s)
+ for _, s := range haystack {
+ if exclude := needleMap[s]; !exclude {
+ strings = append(strings, s)
+ }
}
- sort.SliceStable(strings, func(i, j int) bool {
- return strings[i] < strings[j]
- })
-
return strings
}
// Subtract needle from haystack
func SubtractBazelLabels(haystack []Label, needle []Label) []Label {
// This is really a set
- remainder := make(map[Label]bool)
-
- for _, label := range haystack {
- remainder[label] = true
- }
- for _, label := range needle {
- delete(remainder, label)
+ needleMap := make(map[Label]bool)
+ for _, s := range needle {
+ needleMap[s] = true
}
var labels []Label
- for label, _ := range remainder {
- labels = append(labels, label)
+ for _, label := range haystack {
+ if exclude := needleMap[label]; !exclude {
+ labels = append(labels, label)
+ }
}
- sort.SliceStable(labels, func(i, j int) bool {
- return labels[i].Label < labels[j].Label
- })
-
return labels
}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 134e1d7..266b118 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1669,21 +1669,21 @@
srcs = ["base.cpp"] + select({
"//build/bazel/platforms/os:android": [
"android.cpp",
- "bionic.cpp",
"linux.cpp",
+ "bionic.cpp",
],
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
"//build/bazel/platforms/os:linux": [
- "linux.cpp",
"linux_glibc.cpp",
+ "linux.cpp",
],
"//build/bazel/platforms/os:linux_bionic": [
- "bionic.cpp",
"linux.cpp",
+ "bionic.cpp",
],
"//build/bazel/platforms/os:linux_musl": [
- "linux.cpp",
"linux_musl.cpp",
+ "linux.cpp",
],
"//build/bazel/platforms/os:windows": ["windows.cpp"],
"//conditions:default": [],
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 3289391..9f6f450 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -641,12 +641,12 @@
name = "foo_static",
srcs_c = ["common.c"] + select({
"//build/bazel/platforms/arch:arm": [
- "for-arm.c",
"not-for-x86.c",
+ "for-arm.c",
],
"//build/bazel/platforms/arch:x86": [
- "for-x86.c",
"not-for-arm.c",
+ "for-x86.c",
],
"//conditions:default": [
"not-for-arm.c",
@@ -691,28 +691,28 @@
name = "foo_static",
srcs_c = ["common.c"] + select({
"//build/bazel/platforms/arch:arm": [
- "for-arm.c",
"not-for-arm64.c",
"not-for-x86.c",
"not-for-x86_64.c",
+ "for-arm.c",
],
"//build/bazel/platforms/arch:arm64": [
- "for-arm64.c",
"not-for-arm.c",
"not-for-x86.c",
"not-for-x86_64.c",
+ "for-arm64.c",
],
"//build/bazel/platforms/arch:x86": [
- "for-x86.c",
"not-for-arm.c",
"not-for-arm64.c",
"not-for-x86_64.c",
+ "for-x86.c",
],
"//build/bazel/platforms/arch:x86_64": [
- "for-x86_64.c",
"not-for-arm.c",
"not-for-arm64.c",
"not-for-x86.c",
+ "for-x86_64.c",
],
"//conditions:default": [
"not-for-arm.c",
@@ -875,20 +875,20 @@
name = "foo_static2",
srcs_c = ["common.c"] + select({
"//build/bazel/platforms/arch:arm": [
- "for-lib32.c",
"not-for-lib64.c",
+ "for-lib32.c",
],
"//build/bazel/platforms/arch:arm64": [
- "for-lib64.c",
"not-for-lib32.c",
+ "for-lib64.c",
],
"//build/bazel/platforms/arch:x86": [
- "for-lib32.c",
"not-for-lib64.c",
+ "for-lib32.c",
],
"//build/bazel/platforms/arch:x86_64": [
- "for-lib64.c",
"not-for-lib32.c",
+ "for-lib64.c",
],
"//conditions:default": [
"not-for-lib32.c",
@@ -942,36 +942,36 @@
name = "foo_static3",
srcs_c = ["common.c"] + select({
"//build/bazel/platforms/arch:arm": [
+ "not-for-arm64.c",
+ "not-for-lib64.c",
+ "not-for-x86.c",
+ "not-for-x86_64.c",
"for-arm.c",
"for-lib32.c",
- "not-for-arm64.c",
- "not-for-lib64.c",
- "not-for-x86.c",
- "not-for-x86_64.c",
],
"//build/bazel/platforms/arch:arm64": [
- "for-arm64.c",
- "for-lib64.c",
"not-for-arm.c",
"not-for-lib32.c",
"not-for-x86.c",
"not-for-x86_64.c",
+ "for-arm64.c",
+ "for-lib64.c",
],
"//build/bazel/platforms/arch:x86": [
- "for-lib32.c",
- "for-x86.c",
"not-for-arm.c",
"not-for-arm64.c",
"not-for-lib64.c",
"not-for-x86_64.c",
+ "for-x86.c",
+ "for-lib32.c",
],
"//build/bazel/platforms/arch:x86_64": [
- "for-lib64.c",
- "for-x86_64.c",
"not-for-arm.c",
"not-for-arm64.c",
"not-for-lib32.c",
"not-for-x86.c",
+ "for-x86_64.c",
+ "for-lib64.c",
],
"//conditions:default": [
"not-for-arm.c",
@@ -1066,19 +1066,19 @@
expectedBazelTargets: []string{`cc_library_static(
name = "foo_static3",
srcs = [
- "//dep:generated_hdr_other_pkg",
- "//dep:generated_src_other_pkg",
- ":generated_hdr",
- ":generated_src",
"common.cpp",
+ ":generated_hdr",
+ "//dep:generated_hdr_other_pkg",
+ ":generated_src",
+ "//dep:generated_src_other_pkg",
] + select({
"//build/bazel/platforms/arch:x86": [
- "//dep:generated_hdr_other_pkg_x86",
"for-x86.cpp",
+ "//dep:generated_hdr_other_pkg_x86",
],
"//conditions:default": [
- ":generated_src_not_x86",
"not-for-x86.cpp",
+ ":generated_src_not_x86",
],
}) + select({
"//build/bazel/platforms/os:android": [
diff --git a/bp2build/cc_object_conversion_test.go b/bp2build/cc_object_conversion_test.go
index 63a0b8a..c4b276a 100644
--- a/bp2build/cc_object_conversion_test.go
+++ b/bp2build/cc_object_conversion_test.go
@@ -439,13 +439,13 @@
copts = ["-fno-addrsig"],
srcs = ["base.cpp"] + select({
"//build/bazel/platforms/os_arch:android_arm64": [
- "bionic_arm64.cpp",
"linux_arm64.cpp",
+ "bionic_arm64.cpp",
],
"//build/bazel/platforms/os_arch:android_x86": ["linux_x86.cpp"],
"//build/bazel/platforms/os_arch:linux_bionic_arm64": [
- "bionic_arm64.cpp",
"linux_arm64.cpp",
+ "bionic_arm64.cpp",
],
"//build/bazel/platforms/os_arch:linux_glibc_x86": ["linux_x86.cpp"],
"//build/bazel/platforms/os_arch:linux_musl_x86": ["linux_x86.cpp"],
diff --git a/cc/config/global.go b/cc/config/global.go
index 5f41f9e..ba10491 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -77,10 +77,6 @@
// TODO: can we remove this now?
"-Wno-reserved-id-macro",
- // Workaround for ccache with clang.
- // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
- "-Wno-unused-command-line-argument",
-
// Force clang to always output color diagnostics. Ninja will strip the ANSI
// color codes if it is not running in a terminal.
"-fcolor-diagnostics",
@@ -329,6 +325,12 @@
// Default to zero initialization.
flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang")
}
+
+ // Workaround for ccache with clang.
+ // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
+ if ctx.Config().IsEnvTrue("USE_CCACHE") {
+ flags = append(flags, "-Wno-unused-command-line-argument")
+ }
return strings.Join(flags, " ")
})
diff --git a/scripts/get_clang_version.py b/scripts/get_clang_version.py
index 64d922a..691c45d 100755
--- a/scripts/get_clang_version.py
+++ b/scripts/get_clang_version.py
@@ -34,7 +34,7 @@
with open(global_go) as infile:
contents = infile.read()
- regex_rev = r'\tClangDefaultVersion\s+= "(?P<rev>clang-r\d+[a-z]?\d?)"'
+ regex_rev = r'\tClangDefaultVersion\s+= "(?P<rev>clang-.*)"'
match_rev = re.search(regex_rev, contents)
if match_rev is None:
raise RuntimeError('Parsing clang info failed')