Merge "Shorten the -checks flag in clang-tidy rules"
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 4d9423a..8ab003c 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -878,7 +878,7 @@
}
// The actual Bazel action.
- cmd.Text(" " + buildStatement.Command)
+ cmd.Text(buildStatement.Command)
for _, outputPath := range buildStatement.OutputPaths {
cmd.ImplicitOutput(PathForBazelOut(ctx, outputPath))
diff --git a/android/makevars.go b/android/makevars.go
index ece7091..a74185a 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -472,7 +472,8 @@
fmt.Fprintf(buf, "\tchmod +x $@\n")
}
if extraFiles := install.extraFiles; extraFiles != nil {
- fmt.Fprintf(buf, "\tunzip -qDD -d '%s' '%s'\n", extraFiles.dir.String(), extraFiles.zip.String())
+ fmt.Fprintf(buf, "\t( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} ) || \\\n", extraFiles.dir.String(), extraFiles.zip.String())
+ fmt.Fprintf(buf, "\t ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )\n")
}
fmt.Fprintln(buf)
}
diff --git a/android/module.go b/android/module.go
index 8bbfd8a..ad01e9e 100644
--- a/android/module.go
+++ b/android/module.go
@@ -3282,8 +3282,9 @@
extraCmds := ""
if extraZip != nil {
- extraCmds += fmt.Sprintf(" && unzip -qDD -d '%s' '%s'",
+ extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )",
extraZip.dir.String(), extraZip.zip.String())
+ extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )"
implicitDeps = append(implicitDeps, extraZip.zip)
}
diff --git a/apex/apex.go b/apex/apex.go
index 21725ff..7a2a04a 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2530,6 +2530,22 @@
if overridableProperties.Compressible != nil {
attrs.Compressible = bazel.BoolAttribute{Value: overridableProperties.Compressible}
}
+
+ // Package name
+ //
+ // e.g. com.android.adbd's package name is com.android.adbd, but
+ // com.google.android.adbd overrides the package name to com.google.android.adbd
+ //
+ // TODO: this can be overridden from the product configuration, see
+ // getOverrideManifestPackageName and
+ // PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES.
+ //
+ // Instead of generating the BUILD files differently based on the product config
+ // at the point of conversion, this should be handled by the BUILD file loading
+ // from the soong_injection's product_vars, so product config is decoupled from bp2build.
+ if overridableProperties.Package_name != "" {
+ attrs.Package_name = &overridableProperties.Package_name
+ }
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: o.Name()}, &attrs)
@@ -3471,6 +3487,7 @@
Native_shared_libs_32 bazel.LabelListAttribute
Native_shared_libs_64 bazel.LabelListAttribute
Compressible bazel.BoolAttribute
+ Package_name *string
}
type convertedNativeSharedLibs struct {
@@ -3565,6 +3582,11 @@
compressibleAttribute.Value = a.overridableProperties.Compressible
}
+ var packageName *string
+ if a.overridableProperties.Package_name != "" {
+ packageName = &a.overridableProperties.Package_name
+ }
+
attrs := bazelApexBundleAttributes{
Manifest: manifestLabelAttribute,
Android_manifest: androidManifestLabelAttribute,
@@ -3579,6 +3601,7 @@
Binaries: binariesLabelListAttribute,
Prebuilts: prebuiltsLabelListAttribute,
Compressible: compressibleAttribute,
+ Package_name: packageName,
}
props := bazel.BazelTargetModuleProperties{
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 07372a3..7905710 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -6227,6 +6227,9 @@
name: "mybootclasspath_fragment",
contents: ["bcplib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -6241,6 +6244,9 @@
name: "override_bootclasspath_fragment",
contents: ["override_bcplib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -7294,6 +7300,9 @@
apex_available: [
"some-non-updatable-apex",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -7352,6 +7361,9 @@
apex_available: [
"com.android.art.debug",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex_key {
@@ -8695,6 +8707,9 @@
name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -9015,6 +9030,9 @@
name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_sdk_library {
@@ -9115,6 +9133,9 @@
name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_sdk_library {
@@ -9334,6 +9355,9 @@
name: "mybootclasspathfragment",
contents: ["myjavalib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
name: "myjavalib",
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index ce6b7f7..b298dac 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -110,6 +110,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`,
)
@@ -209,6 +212,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
bootclasspath_fragment {
@@ -220,6 +226,9 @@
module: "art-bootclasspath-fragment",
},
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`,
)
@@ -361,6 +370,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`, contentsInsert(contents))
@@ -853,6 +865,9 @@
apex_available: [
"myapex",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`)
@@ -959,6 +974,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex {
@@ -1010,6 +1028,9 @@
module: "art-bootclasspath-fragment",
},
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`)
@@ -1123,6 +1144,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex {
@@ -1175,6 +1199,9 @@
module: "art-bootclasspath-fragment",
},
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`)
@@ -1282,6 +1309,9 @@
apex_available: [
"com.android.art",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex {
@@ -1334,6 +1364,9 @@
module: "art-bootclasspath-fragment",
},
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
`)
diff --git a/apex/classpath_element_test.go b/apex/classpath_element_test.go
index 60f18bd..9142eed 100644
--- a/apex/classpath_element_test.go
+++ b/apex/classpath_element_test.go
@@ -88,6 +88,9 @@
"baz",
"quuz",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -134,6 +137,9 @@
contents: [
"bar",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 06c39ee..4b48da8 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -125,6 +125,7 @@
unsupported_packages: [
"bar-unsupported-packages.txt",
],
+ split_packages: ["*"],
},
}
@@ -274,6 +275,9 @@
"baz",
"quuz",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -317,6 +321,9 @@
name: "my-bootclasspath-fragment",
contents: ["bar"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex_key {
@@ -482,6 +489,9 @@
contents: [
"foo", "bar",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
prebuilt_bootclasspath_fragment {
@@ -599,6 +609,9 @@
generate_classpaths_proto: false,
contents: ["foo"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -656,6 +669,9 @@
contents: [
"foo",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
platform_bootclasspath {
@@ -696,6 +712,9 @@
bootclasspath_fragment {
name: "not-in-apex-fragment",
contents: ["foo"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
platform_bootclasspath {
@@ -746,6 +765,9 @@
name: "apex-fragment",
contents: ["foo", "bar"],
apex_available:[ "myapex" ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
platform_bootclasspath {
diff --git a/bazel/aquery.go b/bazel/aquery.go
index ab31581..433d502 100644
--- a/bazel/aquery.go
+++ b/bazel/aquery.go
@@ -16,6 +16,7 @@
import (
"crypto/sha256"
+ "encoding/base64"
"encoding/json"
"fmt"
"path/filepath"
@@ -295,7 +296,7 @@
a.depsetHashToArtifactPathsCache[depsetHash] = result
return result, nil
} else {
- return nil, fmt.Errorf("undefined input depset hash %d", depsetHash)
+ return nil, fmt.Errorf("undefined input depset hash %s", depsetHash)
}
}
@@ -390,8 +391,8 @@
h := sha256.New()
// Use newline as delimiter, as paths cannot contain newline.
h.Write([]byte(strings.Join(directPaths, "\n")))
- h.Write([]byte(strings.Join(transitiveDepsetHashes, "\n")))
- fullHash := fmt.Sprintf("%016x", h.Sum(nil))
+ h.Write([]byte(strings.Join(transitiveDepsetHashes, "")))
+ fullHash := base64.RawURLEncoding.EncodeToString(h.Sum(nil))
return fullHash
}
diff --git a/bazel/aquery_test.go b/bazel/aquery_test.go
index 740a1f1..c9c8909 100644
--- a/bazel/aquery_test.go
+++ b/bazel/aquery_test.go
@@ -847,8 +847,8 @@
}
expectedDepsetFiles := [][]string{
- []string{"middleinput_one", "middleinput_two"},
- []string{"middleinput_one", "middleinput_two", "maininput_one", "maininput_two"},
+ {"middleinput_one", "middleinput_two", "maininput_one", "maininput_two"},
+ {"middleinput_one", "middleinput_two"},
}
assertFlattenedDepsets(t, actualDepsets, expectedDepsetFiles)
@@ -897,7 +897,7 @@
func assertFlattenedDepsets(t *testing.T, actualDepsets []AqueryDepset, expectedDepsetFiles [][]string) {
t.Helper()
if len(actualDepsets) != len(expectedDepsetFiles) {
- t.Errorf("Expected %d depsets, but got %d depsets", expectedDepsetFiles, actualDepsets)
+ t.Errorf("Expected %s depsets, but got %s depsets", expectedDepsetFiles, actualDepsets)
}
for i, actualDepset := range actualDepsets {
actualFlattenedInputs := flattenDepsets([]string{actualDepset.ContentHash}, actualDepsets)
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go
index d15dc0c..3f1349f 100644
--- a/bp2build/apex_conversion_test.go
+++ b/bp2build/apex_conversion_test.go
@@ -133,6 +133,7 @@
"pretend_prebuilt_1",
"pretend_prebuilt_2",
],
+ package_name: "com.android.apogee.test.package",
}
`,
expectedBazelTargets: []string{
@@ -169,6 +170,7 @@
]`,
"updatable": "False",
"compressible": "False",
+ "package_name": `"com.android.apogee.test.package"`,
}),
}})
}
@@ -782,3 +784,37 @@
}),
}})
}
+
+func TestApexBundleSimple_packageNameOverride(t *testing.T) {
+ runOverrideApexTestCase(t, bp2buildTestCase{
+ description: "override_apex - override package name",
+ moduleTypeUnderTest: "override_apex",
+ moduleTypeUnderTestFactory: apex.OverrideApexFactory,
+ filesystem: map[string]string{
+ "system/sepolicy/apex/Android.bp": `
+filegroup {
+ name: "com.android.apogee-file_contexts",
+ srcs: [ "apogee-file_contexts", ],
+ bazel_module: { bp2build_available: false },
+}`,
+ },
+ blueprint: `
+apex {
+ name: "com.android.apogee",
+ bazel_module: { bp2build_available: false },
+}
+
+override_apex {
+ name: "com.google.android.apogee",
+ base: ":com.android.apogee",
+ package_name: "com.google.android.apogee",
+}
+`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
+ "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
+ "package_name": `"com.google.android.apogee"`,
+ }),
+ }})
+}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index b7de452..555f5a7 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1879,76 +1879,78 @@
// not set, only emit if gnu_extensions is disabled. the default (gnu+17
// is set in the toolchain.)
{cpp_std: "", gnu_extensions: "", bazel_cpp_std: ""},
- {cpp_std: "", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c99"},
+ {cpp_std: "", gnu_extensions: "false", bazel_cpp_std: "cpp_std_default_no_gnu", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "", gnu_extensions: "true", bazel_cpp_std: ""},
// experimental defaults to gnu++2a
- {cpp_std: "experimental", gnu_extensions: "", bazel_cpp_std: "gnu++2a"},
- {cpp_std: "experimental", gnu_extensions: "false", bazel_cpp_std: "c++2a", bazel_c_std: "c99"},
- {cpp_std: "experimental", gnu_extensions: "true", bazel_cpp_std: "gnu++2a"},
+ {cpp_std: "experimental", gnu_extensions: "", bazel_cpp_std: "cpp_std_experimental"},
+ {cpp_std: "experimental", gnu_extensions: "false", bazel_cpp_std: "cpp_std_experimental_no_gnu", bazel_c_std: "c_std_default_no_gnu"},
+ {cpp_std: "experimental", gnu_extensions: "true", bazel_cpp_std: "cpp_std_experimental"},
// Explicitly setting a c++ std does not use replace gnu++ std even if
// gnu_extensions is true.
// "c++11",
{cpp_std: "c++11", gnu_extensions: "", bazel_cpp_std: "c++11"},
- {cpp_std: "c++11", gnu_extensions: "false", bazel_cpp_std: "c++11", bazel_c_std: "c99"},
+ {cpp_std: "c++11", gnu_extensions: "false", bazel_cpp_std: "c++11", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "c++11", gnu_extensions: "true", bazel_cpp_std: "c++11"},
// "c++17",
{cpp_std: "c++17", gnu_extensions: "", bazel_cpp_std: "c++17"},
- {cpp_std: "c++17", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c99"},
+ {cpp_std: "c++17", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "c++17", gnu_extensions: "true", bazel_cpp_std: "c++17"},
// "c++2a",
{cpp_std: "c++2a", gnu_extensions: "", bazel_cpp_std: "c++2a"},
- {cpp_std: "c++2a", gnu_extensions: "false", bazel_cpp_std: "c++2a", bazel_c_std: "c99"},
+ {cpp_std: "c++2a", gnu_extensions: "false", bazel_cpp_std: "c++2a", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "c++2a", gnu_extensions: "true", bazel_cpp_std: "c++2a"},
// "c++98",
{cpp_std: "c++98", gnu_extensions: "", bazel_cpp_std: "c++98"},
- {cpp_std: "c++98", gnu_extensions: "false", bazel_cpp_std: "c++98", bazel_c_std: "c99"},
+ {cpp_std: "c++98", gnu_extensions: "false", bazel_cpp_std: "c++98", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "c++98", gnu_extensions: "true", bazel_cpp_std: "c++98"},
// gnu++ is replaced with c++ if gnu_extensions is explicitly false.
// "gnu++11",
{cpp_std: "gnu++11", gnu_extensions: "", bazel_cpp_std: "gnu++11"},
- {cpp_std: "gnu++11", gnu_extensions: "false", bazel_cpp_std: "c++11", bazel_c_std: "c99"},
+ {cpp_std: "gnu++11", gnu_extensions: "false", bazel_cpp_std: "c++11", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "gnu++11", gnu_extensions: "true", bazel_cpp_std: "gnu++11"},
// "gnu++17",
{cpp_std: "gnu++17", gnu_extensions: "", bazel_cpp_std: "gnu++17"},
- {cpp_std: "gnu++17", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c99"},
+ {cpp_std: "gnu++17", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c_std_default_no_gnu"},
{cpp_std: "gnu++17", gnu_extensions: "true", bazel_cpp_std: "gnu++17"},
// some c_std test cases
- {c_std: "experimental", gnu_extensions: "", bazel_c_std: "gnu17"},
- {c_std: "experimental", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c17"},
- {c_std: "experimental", gnu_extensions: "true", bazel_c_std: "gnu17"},
+ {c_std: "experimental", gnu_extensions: "", bazel_c_std: "c_std_experimental"},
+ {c_std: "experimental", gnu_extensions: "false", bazel_cpp_std: "cpp_std_default_no_gnu", bazel_c_std: "c_std_experimental_no_gnu"},
+ {c_std: "experimental", gnu_extensions: "true", bazel_c_std: "c_std_experimental"},
{c_std: "gnu11", cpp_std: "gnu++17", gnu_extensions: "", bazel_cpp_std: "gnu++17", bazel_c_std: "gnu11"},
{c_std: "gnu11", cpp_std: "gnu++17", gnu_extensions: "false", bazel_cpp_std: "c++17", bazel_c_std: "c11"},
{c_std: "gnu11", cpp_std: "gnu++17", gnu_extensions: "true", bazel_cpp_std: "gnu++17", bazel_c_std: "gnu11"},
}
for i, tc := range testCases {
- name_prefix := fmt.Sprintf("a_%v", i)
- cppStdProp := ""
- if tc.cpp_std != "" {
- cppStdProp = fmt.Sprintf(" cpp_std: \"%s\",", tc.cpp_std)
- }
- cStdProp := ""
- if tc.c_std != "" {
- cStdProp = fmt.Sprintf(" c_std: \"%s\",", tc.c_std)
- }
- gnuExtensionsProp := ""
- if tc.gnu_extensions != "" {
- gnuExtensionsProp = fmt.Sprintf(" gnu_extensions: %s,", tc.gnu_extensions)
- }
- attrs := attrNameToString{}
- if tc.bazel_cpp_std != "" {
- attrs["cpp_std"] = fmt.Sprintf(`"%s"`, tc.bazel_cpp_std)
- }
- if tc.bazel_c_std != "" {
- attrs["c_std"] = fmt.Sprintf(`"%s"`, tc.bazel_c_std)
- }
+ name := fmt.Sprintf("cpp std: %q, c std: %q, gnu_extensions: %q", tc.cpp_std, tc.c_std, tc.gnu_extensions)
+ t.Run(name, func(t *testing.T) {
+ name_prefix := fmt.Sprintf("a_%v", i)
+ cppStdProp := ""
+ if tc.cpp_std != "" {
+ cppStdProp = fmt.Sprintf(" cpp_std: \"%s\",", tc.cpp_std)
+ }
+ cStdProp := ""
+ if tc.c_std != "" {
+ cStdProp = fmt.Sprintf(" c_std: \"%s\",", tc.c_std)
+ }
+ gnuExtensionsProp := ""
+ if tc.gnu_extensions != "" {
+ gnuExtensionsProp = fmt.Sprintf(" gnu_extensions: %s,", tc.gnu_extensions)
+ }
+ attrs := attrNameToString{}
+ if tc.bazel_cpp_std != "" {
+ attrs["cpp_std"] = fmt.Sprintf(`"%s"`, tc.bazel_cpp_std)
+ }
+ if tc.bazel_c_std != "" {
+ attrs["c_std"] = fmt.Sprintf(`"%s"`, tc.bazel_c_std)
+ }
- runCcLibraryTestCase(t, bp2buildTestCase{
- description: fmt.Sprintf(
- "cc_library with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
- moduleTypeUnderTest: "cc_library",
- moduleTypeUnderTestFactory: cc.LibraryFactory,
- blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ description: fmt.Sprintf(
+ "cc_library with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
cc_library {
name: "%s_full",
%s // cpp_std: *string
@@ -1957,15 +1959,15 @@
include_build_directory: false,
}
`, name_prefix, cppStdProp, cStdProp, gnuExtensionsProp),
- expectedBazelTargets: makeCcLibraryTargets(name_prefix+"_full", attrs),
- })
+ expectedBazelTargets: makeCcLibraryTargets(name_prefix+"_full", attrs),
+ })
- runCcLibraryStaticTestCase(t, bp2buildTestCase{
- description: fmt.Sprintf(
- "cc_library_static with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
- moduleTypeUnderTest: "cc_library_static",
- moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
- blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
+ runCcLibraryStaticTestCase(t, bp2buildTestCase{
+ description: fmt.Sprintf(
+ "cc_library_static with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
+ moduleTypeUnderTest: "cc_library_static",
+ moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
+ blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
cc_library_static {
name: "%s_static",
%s // cpp_std: *string
@@ -1974,17 +1976,17 @@
include_build_directory: false,
}
`, name_prefix, cppStdProp, cStdProp, gnuExtensionsProp),
- expectedBazelTargets: []string{
- makeBazelTarget("cc_library_static", name_prefix+"_static", attrs),
- },
- })
+ expectedBazelTargets: []string{
+ makeBazelTarget("cc_library_static", name_prefix+"_static", attrs),
+ },
+ })
- runCcLibrarySharedTestCase(t, bp2buildTestCase{
- description: fmt.Sprintf(
- "cc_library_shared with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
- moduleTypeUnderTest: "cc_library_shared",
- moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
- blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
+ runCcLibrarySharedTestCase(t, bp2buildTestCase{
+ description: fmt.Sprintf(
+ "cc_library_shared with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
+ moduleTypeUnderTest: "cc_library_shared",
+ moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
cc_library_shared {
name: "%s_shared",
%s // cpp_std: *string
@@ -1993,9 +1995,10 @@
include_build_directory: false,
}
`, name_prefix, cppStdProp, cStdProp, gnuExtensionsProp),
- expectedBazelTargets: []string{
- makeBazelTarget("cc_library_shared", name_prefix+"_shared", attrs),
- },
+ expectedBazelTargets: []string{
+ makeBazelTarget("cc_library_shared", name_prefix+"_shared", attrs),
+ },
+ })
})
}
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index ba02b7e..70dcf40 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -444,32 +444,33 @@
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), anySrcs
}
-func bp2buildResolveCppStdValue(c_std *string, cpp_std *string, gnu_extensions *bool) (*string, *string) {
- var cStdVal, cppStdVal string
+func bp2buildStdVal(std *string, prefix string, useGnu bool) *string {
+ defaultVal := prefix + "_std_default"
// If c{,pp}std properties are not specified, don't generate them in the BUILD file.
// Defaults are handled by the toolchain definition.
// However, if gnu_extensions is false, then the default gnu-to-c version must be specified.
- if cpp_std != nil {
- cppStdVal = parseCppStd(cpp_std)
- } else if gnu_extensions != nil && !*gnu_extensions {
- cppStdVal = "c++17"
- }
- if c_std != nil {
- cStdVal = parseCStd(c_std)
- } else if gnu_extensions != nil && !*gnu_extensions {
- cStdVal = "c99"
+ stdVal := proptools.StringDefault(std, defaultVal)
+ if stdVal == "experimental" || stdVal == defaultVal {
+ if stdVal == "experimental" {
+ stdVal = prefix + "_std_experimental"
+ }
+ if !useGnu {
+ stdVal += "_no_gnu"
+ }
+ } else if !useGnu {
+ stdVal = gnuToCReplacer.Replace(stdVal)
}
- cStdVal, cppStdVal = maybeReplaceGnuToC(gnu_extensions, cStdVal, cppStdVal)
- var c_std_prop, cpp_std_prop *string
- if cStdVal != "" {
- c_std_prop = &cStdVal
+ if stdVal == defaultVal {
+ return nil
}
- if cppStdVal != "" {
- cpp_std_prop = &cppStdVal
- }
+ return &stdVal
+}
- return c_std_prop, cpp_std_prop
+func bp2buildResolveCppStdValue(c_std *string, cpp_std *string, gnu_extensions *bool) (*string, *string) {
+ useGnu := useGnuExtensions(gnu_extensions)
+
+ return bp2buildStdVal(c_std, "c", useGnu), bp2buildStdVal(cpp_std, "cpp", useGnu)
}
// packageFromLabel extracts package from a fully-qualified or relative Label and whether the label
diff --git a/cc/compiler.go b/cc/compiler.go
index 773a642..c7e9c9a 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -295,8 +295,12 @@
getNamedMapForConfig(ctx.Config(), key).Store(module, true)
}
+func useGnuExtensions(gnuExtensions *bool) bool {
+ return proptools.BoolDefault(gnuExtensions, true)
+}
+
func maybeReplaceGnuToC(gnuExtensions *bool, cStd string, cppStd string) (string, string) {
- if gnuExtensions != nil && *gnuExtensions == false {
+ if !useGnuExtensions(gnuExtensions) {
cStd = gnuToCReplacer.Replace(cStd)
cppStd = gnuToCReplacer.Replace(cppStd)
}
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index dfe143f..66087e6 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -33,9 +33,7 @@
},
"armv8-a-branchprot": []string{
"-march=armv8-a",
- // Disable BTI until drm vendors stop using OS libraries as sources
- // of gadgets (https://issuetracker.google.com/216395195).
- "-mbranch-protection=pac-ret",
+ "-mbranch-protection=standard",
},
"armv8-2a": []string{
"-march=armv8.2-a",
diff --git a/cc/config/global.go b/cc/config/global.go
index 178e80b..b09598a 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -370,6 +370,11 @@
exportedVars.ExportStringListStaticVariable("CommonGlobalCppflags", commonGlobalCppflags)
exportedVars.ExportStringListStaticVariable("ExternalCflags", extraExternalCflags)
+ exportedVars.ExportString("CStdVersion", CStdVersion)
+ exportedVars.ExportString("CppStdVersion", CppStdVersion)
+ exportedVars.ExportString("ExperimentalCStdVersion", ExperimentalCStdVersion)
+ exportedVars.ExportString("ExperimentalCppStdVersion", ExperimentalCppStdVersion)
+
// Everything in these lists is a crime against abstraction and dependency tracking.
// Do not add anything to this list.
commonGlobalIncludes := []string{
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index 492cd98..dd612ce 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -17,100 +17,9 @@
// List of VNDK libraries that have different core variant and vendor variant.
// For these libraries, the vendor variants must be installed even if the device
// has VndkUseCoreVariant set.
-// TODO(b/150578172): clean up unstable and non-versioned aidl module
+// Note that AIDL-generated modules must use vendor variants by default.
var VndkMustUseVendorVariantList = []string{
- "android.hardware.authsecret-V1-ndk",
- "android.hardware.authsecret-V1-ndk_platform",
- "android.hardware.authsecret-ndk_platform",
- "android.hardware.authsecret-unstable-ndk_platform",
- "android.hardware.automotive.occupant_awareness-V1-ndk",
- "android.hardware.automotive.occupant_awareness-V1-ndk_platform",
- "android.hardware.automotive.occupant_awareness-ndk_platform",
- "android.hardware.gnss-V1-ndk",
- "android.hardware.gnss-V1-ndk_platform",
- "android.hardware.gnss-ndk_platform",
- "android.hardware.gnss-unstable-ndk_platform",
- "android.hardware.health-V1-ndk",
- "android.hardware.health-ndk",
- "android.hardware.health.storage-V1-ndk",
- "android.hardware.health.storage-V1-ndk_platform",
- "android.hardware.health.storage-ndk_platform",
- "android.hardware.health.storage-unstable-ndk_platform",
- "android.hardware.identity-V2-ndk_platform",
- "android.hardware.identity-V3-ndk",
- "android.hardware.identity-V3-ndk_platform",
- "android.hardware.identity-ndk_platform",
- "android.hardware.light-V1-ndk",
- "android.hardware.light-V1-ndk_platform",
- "android.hardware.light-ndk_platform",
- "android.hardware.memtrack-V1-ndk",
- "android.hardware.memtrack-V1-ndk_platform",
- "android.hardware.memtrack-ndk_platform",
- "android.hardware.memtrack-unstable-ndk_platform",
"android.hardware.nfc@1.2",
- "android.hardware.oemlock-V1-ndk",
- "android.hardware.oemlock-V1-ndk_platform",
- "android.hardware.oemlock-ndk_platform",
- "android.hardware.oemlock-unstable-ndk_platform",
- "android.hardware.power-V1-ndk_platform",
- "android.hardware.power-V2-ndk",
- "android.hardware.power-V2-ndk_platform",
- "android.hardware.power-ndk_platform",
- "android.hardware.power.stats-V1-ndk",
- "android.hardware.power.stats-V1-ndk_platform",
- "android.hardware.power.stats-ndk_platform",
- "android.hardware.power.stats-unstable-ndk_platform",
- "android.hardware.rebootescrow-V1-ndk",
- "android.hardware.rebootescrow-V1-ndk_platform",
- "android.hardware.rebootescrow-ndk_platform",
- "android.hardware.radio-V1-ndk",
- "android.hardware.radio-V1-ndk_platform",
- "android.hardware.radio.config-V1-ndk",
- "android.hardware.radio.config-V1-ndk_platform",
- "android.hardware.radio.data-V1-ndk",
- "android.hardware.radio.data-V1-ndk_platform",
- "android.hardware.radio.messaging-V1-ndk",
- "android.hardware.radio.messaging-V1-ndk_platform",
- "android.hardware.radio.modem-V1-ndk",
- "android.hardware.radio.modem-V1-ndk_platform",
- "android.hardware.radio.network-V1-ndk",
- "android.hardware.radio.network-V1-ndk_platform",
- "android.hardware.radio.sim-V1-ndk",
- "android.hardware.radio.sim-V1-ndk_platform",
- "android.hardware.radio.voice-V1-ndk",
- "android.hardware.radio.voice-V1-ndk_platform",
- "android.hardware.security.keymint-V1-ndk",
- "android.hardware.security.keymint-V1-ndk_platform",
- "android.hardware.security.keymint-ndk_platform",
- "android.hardware.security.keymint-unstable-ndk_platform",
- "android.hardware.security.secureclock-V1-ndk",
- "android.hardware.security.secureclock-V1-ndk_platform",
- "android.hardware.security.secureclock-ndk_platform",
- "android.hardware.security.secureclock-unstable-ndk_platform",
- "android.hardware.security.sharedsecret-V1-ndk",
- "android.hardware.security.sharedsecret-V1-ndk_platform",
- "android.hardware.security.sharedsecret-ndk_platform",
- "android.hardware.security.sharedsecret-unstable-ndk_platform",
- "android.hardware.vibrator-V1-ndk_platform",
- "android.hardware.vibrator-V2-ndk",
- "android.hardware.vibrator-V2-ndk_platform",
- "android.hardware.vibrator-ndk_platform",
- "android.hardware.weaver-V1-ndk",
- "android.hardware.weaver-V1-ndk_platform",
- "android.hardware.weaver-ndk_platform",
- "android.hardware.weaver-unstable-ndk_platform",
- "android.system.suspend-V1-ndk",
- "android.system.keystore2-V1-ndk",
- "android.se.omapi-V1-ndk_platform",
- "android.se.omapi-ndk_platform",
- "android.se.omapi-unstable-ndk_platform",
- "android.hardware.wifi.hostapd-V1-ndk",
- "android.hardware.wifi.hostapd-V1-ndk_platform",
- "android.hardware.wifi.supplicant-V1-ndk",
- "android.system.keystore2-V1-ndk_platform",
- "android.system.keystore2-ndk_platform",
- "android.system.keystore2-unstable-ndk_platform",
- "android.system.suspend-V1-ndk_platform",
"libbinder",
"libcrypto",
"libexpat",
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 42a112e..8cf61fa 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -722,11 +722,6 @@
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
}
- if enableMinimalRuntime(sanitize) {
- flags.Local.CFlags = append(flags.Local.CFlags, strings.Join(minimalRuntimeFlags, " "))
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
- }
-
if Bool(sanitize.Properties.Sanitize.Fuzzer) {
// When fuzzing, we wish to crash with diagnostics on any bug.
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-trap=all", "-fno-sanitize-recover=all")
@@ -735,6 +730,12 @@
} else {
flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
}
+
+ if enableMinimalRuntime(sanitize) {
+ flags.Local.CFlags = append(flags.Local.CFlags, strings.Join(minimalRuntimeFlags, " "))
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
+ }
+
// http://b/119329758, Android core does not boot up with this sanitizer yet.
if toDisableImplicitIntegerChange(flags.Local.CFlags) {
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=implicit-integer-sign-change")
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index b28d70c..0591012 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -858,11 +858,18 @@
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
- if splitPackages == nil {
- splitPackages = []string{"*"}
- }
output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
+ } else if !b.isTestFragment() {
+ ctx.ModuleErrorf(`Must specify at least one of the split_packages, package_prefixes and single_packages properties
+ If this is a new bootclasspath_fragment or you are unsure what to do add the
+ the following to the bootclasspath_fragment:
+ hidden_api: {split_packages: ["*"]},
+ and then run the following:
+ m analyze_bcpf && analyze_bcpf --bcpf %q
+ it will analyze the bootclasspath_fragment and provide hints as to what you
+ should specify here. If you are happy with its suggestions then you can add
+ the --fix option and it will fix them for you.`, b.BaseModuleName())
}
return output
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 8ffe99a..83beb6d 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -121,6 +121,9 @@
],
},
},
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -201,6 +204,9 @@
core_platform_api: {
stub_libs: ["mycoreplatform.stubs"],
},
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
diff --git a/rust/config/global.go b/rust/config/global.go
index 554cfe2..647a7cf 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var pctx = android.NewPackageContext("android/soong/rust/config")
var (
- RustDefaultVersion = "1.61.0"
+ RustDefaultVersion = "1.61.0.p1"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py
index c8d4f76..0216fc0 100755
--- a/scripts/manifest_check.py
+++ b/scripts/manifest_check.py
@@ -20,9 +20,11 @@
import argparse
import json
+import os
import re
import subprocess
import sys
+from collections import OrderedDict
from xml.dom import minidom
from manifest import android_ns
@@ -43,11 +45,13 @@
'--uses-library',
dest='uses_libraries',
action='append',
+ default=[],
help='specify uses-library entries known to the build system')
parser.add_argument(
'--optional-uses-library',
dest='optional_uses_libraries',
action='append',
+ default=[],
help='specify uses-library entries known to the build system with '
'required:false'
)
@@ -74,9 +78,14 @@
help='print the targetSdkVersion from the manifest')
parser.add_argument(
'--dexpreopt-config',
- dest='dexpreopt_configs',
+ dest='dexpreopt_config',
+ help='a path to dexpreopt.config file for this library/app')
+ parser.add_argument(
+ '--dexpreopt-dep-config',
+ dest='dexpreopt_dep_configs',
action='append',
- help='a paths to a dexpreopt.config of some library')
+ default=[],
+ help='a path to dexpreopt.config file for a dependency library')
parser.add_argument('--aapt', dest='aapt', help='path to aapt executable')
parser.add_argument(
'--output', '-o', dest='output', help='output AndroidManifest.xml file')
@@ -295,25 +304,53 @@
return target_attr.value
-def load_dexpreopt_configs(configs):
+def remove_duplicates(l):
+ return list(OrderedDict.fromkeys(l))
+
+
+def load_dexpreopt_configs(args):
"""Load dexpreopt.config files and map module names to library names."""
module_to_libname = {}
- if configs is None:
- configs = []
+ # Go over dexpreopt.config files for uses-library dependencies and create
+ # a mapping from module name to real library name (they may differ).
+ for config in args.dexpreopt_dep_configs:
+ # Empty dexpreopt.config files are expected for some dependencies.
+ if os.stat(config).st_size != 0:
+ with open(config, 'r') as f:
+ contents = json.load(f)
+ module_to_libname[contents['Name']] = contents['ProvidesUsesLibrary']
- for config in configs:
- with open(config, 'r') as f:
+ required = translate_libnames(args.uses_libraries, module_to_libname)
+ optional = translate_libnames(args.optional_uses_libraries, module_to_libname)
+
+ # Add extra uses-libraries from the library/app's own dexpreopt.config.
+ # Extra libraries may be propagated via dependencies' dexpreopt.config files
+ # (not only uses-library ones, but also transitively via static libraries).
+ if args.dexpreopt_config:
+ with open(args.dexpreopt_config, 'r') as f:
contents = json.load(f)
- module_to_libname[contents['Name']] = contents['ProvidesUsesLibrary']
+ for clc in contents['ClassLoaderContexts']['any']:
+ ulib = clc['Name']
+ if clc['Optional']:
+ optional.append(ulib)
+ else:
+ required.append(ulib)
- return module_to_libname
+ required = remove_duplicates(required)
+ optional = remove_duplicates(optional)
+
+ # If the same library is both in optional and required, prefer required.
+ # This may happen for compatibility libraries, e.g. org.apache.http.legacy.
+ for lib in required:
+ if lib in optional:
+ optional.remove(lib)
+
+ return required, optional
def translate_libnames(modules, module_to_libname):
"""Translate module names into library names using the mapping."""
- if modules is None:
- modules = []
libnames = []
for name in modules:
@@ -346,10 +383,7 @@
# `optional_uses_libs`, `LOCAL_USES_LIBRARIES`,
# `LOCAL_OPTIONAL_LIBRARY_NAMES` all contain module names), while
# the manifest addresses libraries by their name.
- mod_to_lib = load_dexpreopt_configs(args.dexpreopt_configs)
- required = translate_libnames(args.uses_libraries, mod_to_lib)
- optional = translate_libnames(args.optional_uses_libraries,
- mod_to_lib)
+ required, optional = load_dexpreopt_configs(args)
# Check if the <uses-library> lists in the build system agree with
# those in the manifest. Raise an exception on mismatch, unless the
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index a60039a..93ad172 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -101,6 +101,9 @@
image_name: "art",
contents: ["mybootlib"],
apex_available: ["com.android.art"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
apex_key {
@@ -235,6 +238,9 @@
// This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
stub_libs: ["mycoreplatform"],
},
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -453,6 +459,9 @@
contents: [
"myotherlib",
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -482,6 +491,9 @@
module: "myotherbootclasspathfragment"
},
],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_sdk_library {
@@ -561,6 +573,9 @@
image_name: "art",
contents: ["mybootlib"],
apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_library {
@@ -668,6 +683,7 @@
unsupported_packages: [
"my-unsupported-packages.txt",
],
+ split_packages: ["*"],
},
}
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index e230d5c..1ec12c3 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -473,6 +473,9 @@
name: "mybootclasspathfragment",
apex_available: ["myapex"],
contents: ["mysdklibrary"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
}
java_sdk_library {