Merge "update docs for apex_available_name"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index bd2d973..a5fcee4 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -477,6 +477,7 @@
"code_coverage.policy",
"code_coverage.policy.other",
"codec2_soft_exports",
+ "compatibility_matrix_schema",
"flatbuffer_headers",
"framework-connectivity-protos",
"gemmlowp_headers",
@@ -769,6 +770,24 @@
// Used by xsd_config
"xsdc",
+
+ // cc_test that can be run by b test
+ "binderRpcWireProtocolTest",
+ "binderUnitTest",
+ "cpu_features-bit_utils_test",
+ "liblp_test",
+ "android.hardware.audio.common.test.utility_tests",
+ "HalAudioStreamWorkerTest",
+ "libjavacore-unit-tests",
+ "NeuralNetworksTest_utils",
+ "NeuralNetworksTest_logtag",
+ "NeuralNetworksTest_operations",
+ "nanoapp_chqts_shared_tests",
+ "fakeservicemanager_test",
+ "tristate_test",
+ "binderUtilsHostTest",
+ "run_dex2oat_test",
+ "bluetooth-address-unit-tests",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -781,6 +800,7 @@
"java_import_host",
"java_sdk_library",
"sysprop_library",
+ "xsd_config",
}
// Add the names of modules that bp2build should never convert, if it is
@@ -850,9 +870,6 @@
"host_bionic_linker_asm", // depends on extract_linker, a go binary.
"host_bionic_linker_script", // depends on extract_linker, a go binary.
- // in cmd attribute of genrule rule //system/timezone/output_data:robolectric_tzdata: label '//system/timezone/output_data:iana/tzdata' in $(location) expression is not a declared prerequisite of this rule
- "robolectric_tzdata",
-
// rust support
"libtombstoned_client_rust_bridge_code", "libtombstoned_client_wrapper", // rust conversions are not supported
@@ -900,8 +917,6 @@
"static_crasher", // depends on unconverted modules: libdebuggerd_handler
"test_fips", // depends on unconverted modules: adb
"timezone-host", // depends on unconverted modules: art.module.api.annotations
- "truth-host-prebuilt", // depends on unconverted modules: truth-prebuilt
- "truth-prebuilt", // depends on unconverted modules: asm-7.0, guava
// '//bionic/libc:libc_bp2build_cc_library_static' is duplicated in the 'deps' attribute of rule
"toybox-static",
@@ -948,12 +963,10 @@
"svcenc", "svcdec",
// Failing host cc_tests
- "memunreachable_unit_test",
"libprocinfo_test",
"ziparchive-tests",
"gtest_isolated_tests",
"libunwindstack_unit_test",
- "task_profiles_test",
"power_tests", // failing test on server, but not on host
// reflect: call of reflect.Value.NumField on interface Value
@@ -1033,7 +1046,6 @@
"libBionicLoaderTests", // depends on unconverted modules: libmeminfo
"libapexutil_tests", // depends on unconverted modules: apex-info-list-tinyxml, libapexutil
"libcutils_sockets_test",
- "libexpectedutils_test",
"libhwbinder_latency",
"liblog-host-test", // failing tests
"libminijail_test",
@@ -1070,7 +1082,6 @@
"scudo_unit_tests",
"stats-log-api-gen-test", // depends on unconverted modules: libstats_proto_host
"syscall_filter_unittest_gtest",
- "sysprop_test", // depends on unconverted modules: libcom.android.sysprop.tests
"thread_exit_cb_helper",
"tls_properties_helper",
"ulp",
@@ -1476,7 +1487,7 @@
"permissive_mte_test",
"ICU4CTestRunner",
- "HelloWorldHostTest", // TODO(b/280452825): Convert HelloWorldHostTest to b test
+ "HelloWorldHostTest", // TODO(b/280452825): Convert HelloWorldHostTest to b test
}
MixedBuildsDisabledList = []string{
@@ -1595,12 +1606,13 @@
}
// These should be the libs that are included by the apexes in the StagingMixedBuildsEnabledList
- StagingDclaMixedBuildsEnabledList = []string{}
+ StagingDclaMixedBuildsEnabledList = []string{
+ "libstagefright_flacdec",
+ "libutils",
+ }
// TODO(b/269342245): Enable the rest of the DCLA libs
// "libssl",
- // "libstagefright_flacdec",
- // "libutils",
// The list of module types which are expected to spend lots of build time.
// With `--ninja_weight_source=soong`, ninja builds these module types and deps first.
diff --git a/android/bazel_paths.go b/android/bazel_paths.go
index ddbdbd4..872e908 100644
--- a/android/bazel_paths.go
+++ b/android/bazel_paths.go
@@ -242,6 +242,11 @@
// Don't transform OriginalModuleName
newPath.OriginalModuleName = path.OriginalModuleName
+ // if it wasn't a module, store the original path. We may need the original path to replace
+ // references if it is actually in another package
+ if path.OriginalModuleName == "" {
+ newPath.OriginalModuleName = path.Label
+ }
if strings.HasPrefix(path.Label, "//") {
// Assume absolute labels are already correct (e.g. //path/to/some/package:foo.h)
diff --git a/android/config.go b/android/config.go
index 14fc04d..d4703ff 100644
--- a/android/config.go
+++ b/android/config.go
@@ -517,6 +517,8 @@
config: config,
}
+ config.productVariables.Build_from_text_stub = boolPtr(config.buildFromTextStub)
+
// Soundness check of the build and source directories. This won't catch strange
// configurations with symlinks, but at least checks the obvious case.
absBuildDir, err := filepath.Abs(cmdArgs.SoongOutDir)
@@ -1925,6 +1927,10 @@
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
}
+func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
+ return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
+}
+
func (c *deviceConfig) GenruleSandboxing() bool {
return Bool(c.config.productVariables.GenruleSandboxing)
}
@@ -1937,10 +1943,6 @@
return c.productVariables.SelinuxIgnoreNeverallows
}
-func (c *deviceConfig) SepolicySplit() bool {
- return c.config.productVariables.SepolicySplit
-}
-
func (c *deviceConfig) SepolicyFreezeTestExtraDirs() []string {
return c.config.productVariables.SepolicyFreezeTestExtraDirs
}
@@ -2017,6 +2019,7 @@
func (c *config) SetBuildFromTextStub(b bool) {
c.buildFromTextStub = b
+ c.productVariables.Build_from_text_stub = boolPtr(b)
}
func (c *config) AddForceEnabledModules(forceEnabled []string) {
diff --git a/android/module.go b/android/module.go
index 98084f3..ba32710 100644
--- a/android/module.go
+++ b/android/module.go
@@ -4014,3 +4014,53 @@
WriteFileRule(ctx, outFile, string(j))
ctx.Phony("soong_config_trace", outFile)
}
+
+// Interface implemented by xsd_config which has 1:many mappings in bp2build workspace
+// This interface exists because we want to
+// 1. Determine the name of the additional targets generated by the primary soong module
+// 2. Enable distinguishing an xsd_config module from other Soong modules using type assertion
+type XsdConfigBp2buildTargets interface {
+ CppBp2buildTargetName() string
+ JavaBp2buildTargetName() string
+}
+
+// PartitionXsdSrcs partitions srcs into xsd_config modules and others
+// Since xsd_config are soong modules, we cannot use file extension for partitioning
+func PartitionXsdSrcs(ctx BazelConversionPathContext, srcs []string) ([]string, []string) {
+ //isXsd returns true if src is a soong module of type xsd_config
+ isXsd := func(src string) bool {
+ mod, exists := ctx.ModuleFromName(src)
+ if !exists {
+ return false
+ }
+ _, _isXsd := mod.(XsdConfigBp2buildTargets)
+ return _isXsd
+ }
+ nonXsd := []string{}
+ xsd := []string{}
+
+ for _, src := range srcs {
+ if isXsd(src) {
+ xsd = append(xsd, src)
+ } else {
+ nonXsd = append(nonXsd, src)
+ }
+ }
+
+ return nonXsd, xsd
+}
+
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-{cpp|java}
+// The new target name is provided by the `targetName` callback function
+func XsdConfigBp2buildTarget(ctx BazelConversionPathContext, mod blueprint.Module, targetName func(xsd XsdConfigBp2buildTargets) string) string {
+ xsd, isXsd := mod.(XsdConfigBp2buildTargets)
+ if !isXsd {
+ ctx.ModuleErrorf("xsdConfigJavaTarget called on %v, which is not an xsd_config", mod)
+ }
+ ret := BazelModuleLabel(ctx, mod)
+ // Remove the base module name
+ ret = strings.TrimSuffix(ret, mod.Name())
+ // Append the language specific target name
+ ret += targetName(xsd)
+ return ret
+}
diff --git a/android/neverallow.go b/android/neverallow.go
index 5b5e613..f2e8c85 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -59,6 +59,7 @@
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
AddNeverAllowRules(createBp2BuildRule())
AddNeverAllowRules(createCcStubsRule())
+ AddNeverAllowRules(createJavaExcludeStaticLibsRule())
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -253,6 +254,14 @@
}
}
+func createJavaExcludeStaticLibsRule() Rule {
+ return NeverAllow().
+ NotIn("build/soong").
+ ModuleType("java_library").
+ WithMatcher("exclude_static_libs", isSetMatcherInstance).
+ Because("exclude_static_libs property is only allowed for java modules defined in build/soong")
+}
+
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index ddd982d..1639bbf 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -344,6 +344,23 @@
`module "outside_allowed_list": violates neverallow`,
},
},
+ // Test for the rule restricting use of exclude_static_libs
+ {
+ name: `"exclude_static_libs" outside allowed directory`,
+ fs: map[string][]byte{
+ "a/b/Android.bp": []byte(`
+ java_library {
+ name: "baz",
+ exclude_static_libs: [
+ "bar",
+ ],
+ }
+ `),
+ },
+ expectedErrors: []string{
+ `exclude_static_libs property is only allowed for java modules defined in build/soong`,
+ },
+ },
}
var prepareForNeverAllowTest = GroupFixturePreparers(
@@ -430,9 +447,10 @@
}
type mockJavaLibraryProperties struct {
- Libs []string
- Sdk_version *string
- Uncompress_dex *bool
+ Libs []string
+ Sdk_version *string
+ Uncompress_dex *bool
+ Exclude_static_libs []string
}
type mockJavaLibraryModule struct {
diff --git a/android/sdk_version.go b/android/sdk_version.go
index 08762ef..80aeb2e 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -84,12 +84,6 @@
}
}
-// JavaLibraryName returns the soong module containing the Java APIs of that API surface.
-func (k SdkKind) JavaLibraryName(c Config) string {
- name := k.DefaultJavaLibraryName()
- return JavaApiLibraryName(c, name)
-}
-
// JavaApiLibraryName returns the name of .txt equivalent of a java_library, but does
// not check if either module exists.
// TODO: Return .txt (single-tree or multi-tree equivalents) based on config
@@ -335,11 +329,10 @@
// Export the name of the soong modules representing the various Java API surfaces.
func javaSdkMakeVars(ctx MakeVarsContext) {
- ctx.Strict("ANDROID_PUBLIC_STUBS", SdkPublic.JavaLibraryName(ctx.Config()))
- ctx.Strict("ANDROID_SYSTEM_STUBS", SdkSystem.JavaLibraryName(ctx.Config()))
- ctx.Strict("ANDROID_TEST_STUBS", SdkTest.JavaLibraryName(ctx.Config()))
- ctx.Strict("ANDROID_MODULE_LIB_STUBS", SdkModule.JavaLibraryName(ctx.Config()))
- ctx.Strict("ANDROID_SYSTEM_SERVER_STUBS", SdkSystemServer.JavaLibraryName(ctx.Config()))
- // TODO (jihoonkang): Create a .txt equivalent for core.current.stubs
- ctx.Strict("ANDROID_CORE_STUBS", SdkCore.JavaLibraryName(ctx.Config()))
+ ctx.Strict("ANDROID_PUBLIC_STUBS", SdkPublic.DefaultJavaLibraryName())
+ ctx.Strict("ANDROID_SYSTEM_STUBS", SdkSystem.DefaultJavaLibraryName())
+ ctx.Strict("ANDROID_TEST_STUBS", SdkTest.DefaultJavaLibraryName())
+ ctx.Strict("ANDROID_MODULE_LIB_STUBS", SdkModule.DefaultJavaLibraryName())
+ ctx.Strict("ANDROID_SYSTEM_SERVER_STUBS", SdkSystemServer.DefaultJavaLibraryName())
+ ctx.Strict("ANDROID_CORE_STUBS", SdkCore.DefaultJavaLibraryName())
}
diff --git a/android/variable.go b/android/variable.go
index 972663b..6362953 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -109,6 +109,11 @@
Cflags []string
}
+ Build_from_text_stub struct {
+ Static_libs []string
+ Exclude_static_libs []string
+ }
+
// debuggable is true for eng and userdebug builds, and can be used to turn on additional
// debugging features that don't significantly impact runtime behavior. userdebug builds
// are used for dogfooding and performance testing, and should be as similar to user builds
@@ -286,6 +291,7 @@
Uml *bool `json:",omitempty"`
Arc *bool `json:",omitempty"`
MinimizeJavaDebugInfo *bool `json:",omitempty"`
+ Build_from_text_stub *bool `json:",omitempty"`
Check_elf_files *bool `json:",omitempty"`
@@ -449,14 +455,14 @@
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"`
+ BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"`
+
BuildDebugfsRestrictionsEnabled bool `json:",omitempty"`
RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"`
SelinuxIgnoreNeverallows bool `json:",omitempty"`
- SepolicySplit bool `json:",omitempty"`
-
SepolicyFreezeTestExtraDirs []string `json:",omitempty"`
SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"`
@@ -526,6 +532,7 @@
Malloc_pattern_fill_contents: boolPtr(false),
Safestack: boolPtr(false),
TrimmedApex: boolPtr(false),
+ Build_from_text_stub: boolPtr(false),
BootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}},
ApexBootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}},
diff --git a/apex/apex.go b/apex/apex.go
index 5f72441..32d7250 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -224,6 +224,9 @@
// Name that dependencies can specify in their apex_available properties to refer to this module.
// If not specified, this defaults to Soong module name. This must be the name of a Soong module.
Apex_available_name *string
+
+ // Variant version of the mainline module. Must be an integer between 0-9
+ Variant_version *string
}
type ApexNativeDependencies struct {
@@ -3527,6 +3530,8 @@
Logging_parent *string
Tests bazel.LabelListAttribute
Base_apex_name *string
+ Apex_available_name *string
+ Variant_version *string
}
type convertedNativeSharedLibs struct {
@@ -3677,6 +3682,8 @@
Package_name: packageName,
Logging_parent: loggingParent,
Tests: testsAttrs,
+ Apex_available_name: a.properties.Apex_available_name,
+ Variant_version: a.properties.Variant_version,
}
props := bazel.BazelTargetModuleProperties{
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 0598836..c781be4 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -6717,6 +6717,89 @@
}`)
}
+func TestApexAvailable_ApexAvailableNameWithVersionCodeError(t *testing.T) {
+ t.Run("negative variant_version produces error", func(t *testing.T) {
+ testApexError(t, "expected an integer between 0-9; got -1", `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ apex_available_name: "com.android.foo",
+ variant_version: "-1",
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+ })
+
+ t.Run("variant_version greater than 9 produces error", func(t *testing.T) {
+ testApexError(t, "expected an integer between 0-9; got 10", `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ apex_available_name: "com.android.foo",
+ variant_version: "10",
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+ })
+}
+
+func TestApexAvailable_ApexAvailableNameWithVersionCode(t *testing.T) {
+ context := android.GroupFixturePreparers(
+ android.PrepareForIntegrationTestWithAndroid,
+ PrepareForTestWithApexBuildComponents,
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/foo-file_contexts": nil,
+ "system/sepolicy/apex/bar-file_contexts": nil,
+ }),
+ )
+ result := context.RunTestWithBp(t, `
+ apex {
+ name: "foo",
+ key: "myapex.key",
+ apex_available_name: "com.android.foo",
+ variant_version: "0",
+ updatable: false,
+ }
+ apex {
+ name: "bar",
+ key: "myapex.key",
+ apex_available_name: "com.android.foo",
+ variant_version: "3",
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+
+ fooManifestRule := result.ModuleForTests("foo", "android_common_foo_image").Rule("apexManifestRule")
+ fooExpectedDefaultVersion := android.DefaultUpdatableModuleVersion
+ fooActualDefaultVersion := fooManifestRule.Args["default_version"]
+ if fooActualDefaultVersion != fooExpectedDefaultVersion {
+ t.Errorf("expected to find defaultVersion %q; got %q", fooExpectedDefaultVersion, fooActualDefaultVersion)
+ }
+
+ barManifestRule := result.ModuleForTests("bar", "android_common_bar_image").Rule("apexManifestRule")
+ defaultVersionInt, _ := strconv.Atoi(android.DefaultUpdatableModuleVersion)
+ barExpectedDefaultVersion := fmt.Sprint(defaultVersionInt + 3)
+ barActualDefaultVersion := barManifestRule.Args["default_version"]
+ if barActualDefaultVersion != barExpectedDefaultVersion {
+ t.Errorf("expected to find defaultVersion %q; got %q", barExpectedDefaultVersion, barActualDefaultVersion)
+ }
+}
+
func TestApexAvailable_ApexAvailableName(t *testing.T) {
t.Run("using name of apex that sets apex_available_name is not allowed", func(t *testing.T) {
testApexError(t, "Consider adding \"myapex\" to 'apex_available' property of \"AppFoo\"", `
diff --git a/apex/builder.go b/apex/builder.go
index 7c6522d..c691a33 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -275,6 +275,22 @@
manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json")
defaultVersion := android.DefaultUpdatableModuleVersion
+ if a.properties.Variant_version != nil {
+ defaultVersionInt, err := strconv.Atoi(defaultVersion)
+ if err != nil {
+ ctx.ModuleErrorf("expected DefaultUpdatableModuleVersion to be an int, but got %s", defaultVersion)
+ }
+ if defaultVersionInt%10 != 0 {
+ ctx.ModuleErrorf("expected DefaultUpdatableModuleVersion to end in a zero, but got %s", defaultVersion)
+ }
+ variantVersion := []rune(*a.properties.Variant_version)
+ if len(variantVersion) != 1 || variantVersion[0] < '0' || variantVersion[0] > '9' {
+ ctx.PropertyErrorf("variant_version", "expected an integer between 0-9; got %s", *a.properties.Variant_version)
+ }
+ defaultVersionRunes := []rune(defaultVersion)
+ defaultVersionRunes[len(defaultVersion)-1] = []rune(variantVersion)[0]
+ defaultVersion = string(defaultVersionRunes)
+ }
if override := ctx.Config().Getenv("OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION"); override != "" {
defaultVersion = override
}
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 8a83cc0..610a9ca 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -1036,3 +1036,73 @@
},
})
}
+
+func TestCcBinaryWithCfi(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
+
+func TestCcBinaryWithCfiOsSpecific(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled for specific variants",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
+
+func TestCcBinaryWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled with cfi assembly support",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 3dd9373..c2dba67 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -4718,3 +4718,97 @@
},
})
}
+
+func TestCcLibraryWithCfi(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithCfiOsSpecific(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled for specific variants",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled with cfi_assembly_support",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 6c9f9a1..7f0ba44 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -1445,3 +1445,73 @@
},
})
}
+
+func TestCcLibrarySharedWithCfi(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled for specific variants",
+ Blueprint: `
+cc_library_shared {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibrarySharedWithCfiOsSpecific(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled",
+ Blueprint: `
+cc_library_shared {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibrarySharedWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 2705aaf..f537871 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -2075,3 +2075,73 @@
},
})
}
+
+func TestCcLibraryStaticWithCfi(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryStaticWithCfiOsSpecific(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled for specific variants",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryStaticWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled with cfi_assembly_support",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go
index 3490881..5cf4fb2 100644
--- a/bp2build/genrule_conversion_test.go
+++ b/bp2build/genrule_conversion_test.go
@@ -49,6 +49,7 @@
srcs: ["other_tool.in"],
cmd: "cp $(in) $(out)",
}`, genruleTarget, genruleTarget),
+ "other/file.txt": "",
}
}
@@ -293,17 +294,20 @@
bp := `%s {
name: "foo",
out: ["foo.out"],
- srcs: [":other.tool"],
+ srcs: [":other.tool", "other/file.txt",],
tool_files: [":foo.tool"],
- cmd: "$(locations :foo.tool) -s $(out) $(location :other.tool)",
+ cmd: "$(locations :foo.tool) $(location other/file.txt) -s $(out) $(location :other.tool)",
bazel_module: { bp2build_available: true },
}`
for _, tc := range testCases {
moduleAttrs := AttrNameToString{
- "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`,
- "outs": `["foo.out"]`,
- "srcs": `["//other:other.tool"]`,
+ "cmd": `"$(locations //other:foo.tool) $(location //other:file.txt) -s $(OUTS) $(location //other:other.tool)"`,
+ "outs": `["foo.out"]`,
+ "srcs": `[
+ "//other:other.tool",
+ "//other:file.txt",
+ ]`,
"tools": `["//other:foo.tool"]`,
}
diff --git a/cc/afdo.go b/cc/afdo.go
index 49f6987..137ea97 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -34,7 +34,7 @@
var afdoProfileProjectsConfigKey = android.NewOnceKey("AfdoProfileProjects")
-const afdoCFlagsFormat = "-fprofile-sample-accurate -fprofile-sample-use=%s"
+const afdoCFlagsFormat = "-fprofile-sample-use=%s"
func recordMissingAfdoProfileFile(ctx android.BaseModuleContext, missing string) {
getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true)
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 259ba39..34cc574 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -591,7 +591,8 @@
anySrcs := false
// Add srcs-like dependencies such as generated files.
// First create a LabelList containing these dependencies, then merge the values with srcs.
- generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, props.Generated_sources, props.Exclude_generated_sources)
+ genSrcs, _ := android.PartitionXsdSrcs(ctx, props.Generated_sources)
+ generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, genSrcs, props.Exclude_generated_sources)
if len(props.Generated_sources) > 0 || len(props.Exclude_generated_sources) > 0 {
anySrcs = true
}
@@ -716,6 +717,14 @@
return ret
}
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-cpp
+func xsdConfigCppTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
+ callback := func(xsd android.XsdConfigBp2buildTargets) string {
+ return xsd.CppBp2buildTargetName()
+ }
+ return android.XsdConfigBp2buildTarget(ctx, mod, callback)
+}
+
// bp2BuildParseBaseProps returns all compiler, linker, library attributes of a cc module..
func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) baseAttributes {
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
@@ -754,7 +763,14 @@
for cfg := range configs {
var allHdrs []string
if baseCompilerProps, ok := archVariantCompilerProps[axis][cfg].(*BaseCompilerProperties); ok {
- allHdrs = baseCompilerProps.Generated_headers
+ ah, allHdrsXsd := android.PartitionXsdSrcs(ctx, baseCompilerProps.Generated_headers)
+ allHdrs = ah
+ // in the synthetic bp2build workspace, xsd sources are compiled to a static library
+ xsdCppConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, allHdrsXsd, xsdConfigCppTarget)
+ iwad := linkerAttrs.implementationWholeArchiveDeps.SelectValue(axis, cfg)
+ (&iwad).Append(xsdCppConfigLibraryLabels)
+ linkerAttrs.implementationWholeArchiveDeps.SetSelectValue(axis, cfg, bazel.FirstUniqueBazelLabelList(iwad))
+
if baseCompilerProps.Lex != nil {
compilerAttrs.lexopts.SetSelectValue(axis, cfg, baseCompilerProps.Lex.Flags)
}
@@ -1757,6 +1773,12 @@
for _, sanitizer := range sanitizerProps.Sanitize.Misc_undefined {
features = append(features, "ubsan_"+sanitizer)
}
+ if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
+ features = append(features, "android_cfi")
+ if proptools.Bool(sanitizerProps.Sanitize.Config.Cfi_assembly_support) {
+ features = append(features, "android_cfi_assembly_support")
+ }
+ }
sanitizerFeatures.SetSelectValue(axis, config, features)
}
})
diff --git a/cc/cc.go b/cc/cc.go
index c9f00e2..426bac8 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -524,6 +524,7 @@
isAfdoCompile() bool
isPgoCompile() bool
isCfi() bool
+ isFuzzer() bool
isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
isForPlatform() bool
@@ -1365,6 +1366,13 @@
return false
}
+func (c *Module) isFuzzer() bool {
+ if sanitize := c.sanitize; sanitize != nil {
+ return Bool(sanitize.Properties.SanitizeMutated.Fuzzer)
+ }
+ return false
+}
+
func (c *Module) isNDKStubLibrary() bool {
if _, ok := c.compiler.(*stubDecorator); ok {
return true
@@ -1660,6 +1668,10 @@
return ctx.mod.isCfi()
}
+func (ctx *moduleContextImpl) isFuzzer() bool {
+ return ctx.mod.isFuzzer()
+}
+
func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
return ctx.mod.isNDKStubLibrary()
}
@@ -1916,7 +1928,6 @@
unsupportedSanitizers := []*bool{
sanitizeProps.Safestack,
- sanitizeProps.Cfi,
sanitizeProps.Scudo,
BoolPtr(len(c.sanitize.Properties.Sanitize.Recover) > 0),
BoolPtr(c.sanitize.Properties.Sanitize.Blocklist != nil),
@@ -1935,6 +1946,8 @@
if ubsanEnabled && !c.MinimalRuntimeNeeded() {
return false
}
+ } else if san == cfi {
+ continue
} else if c.sanitize.isSanitizerEnabled(san) {
return false
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 173911b..701c3bb 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -5538,7 +5538,7 @@
name: "foo_cfi",
variant: "android_arm64_armv8-a_static_cfi_apex28",
expectedOutputPaths: []string{
- "out/soong/.intermediates/foo_cfi/android_arm64_armv8-a_static_cfi_apex28/foo_cfi.a",
+ "outputbase/execroot/__main__/foo_cfi.a",
},
},
{
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index d55a13d..efa4549 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -42,6 +42,8 @@
"-bugprone-unchecked-optional-access",
// http://b/265438407
"-misc-use-anonymous-namespace",
+ // http://b/285005947
+ "-performance-avoid-endl",
}
// Some clang-tidy checks are included in some tidy_checks_as_errors lists,
@@ -56,6 +58,14 @@
"-bugprone-signed-char-misuse",
// http://b/241819232
"-misc-const-correctness",
+ // http://b/285356805
+ "-bugprone-unsafe-functions",
+ "-cert-msc24-c",
+ "-cert-msc33-c",
+ // http://b/285356799
+ "-modernize-type-traits",
+ // http://b/285361108
+ "-readability-avoid-unconditional-preprocessor-if",
}
extraArgFlags = []string{
diff --git a/cc/lto.go b/cc/lto.go
index a8bed23..8d6e3e7 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -74,7 +74,7 @@
func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// TODO(b/131771163): Disable LTO when using explicit fuzzing configurations.
// LTO breaks fuzzer builds.
- if inList("-fsanitize=fuzzer-no-link", flags.Local.CFlags) {
+ if ctx.isFuzzer() {
return flags
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 6e732b6..a5691ee 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -64,13 +64,14 @@
cfiBlocklistPath = "external/compiler-rt/lib/cfi"
cfiBlocklistFilename = "cfi_blocklist.txt"
+ cfiEnableFlag = "-fsanitize=cfi"
cfiCrossDsoFlag = "-fsanitize-cfi-cross-dso"
cfiCflags = []string{"-flto", cfiCrossDsoFlag,
"-fsanitize-ignorelist=" + cfiBlocklistPath + "/" + cfiBlocklistFilename}
// -flto and -fvisibility are required by clang when -fsanitize=cfi is
// used, but have no effect on assembly files
cfiAsflags = []string{"-flto", "-fvisibility=default"}
- cfiLdflags = []string{"-flto", cfiCrossDsoFlag, "-fsanitize=cfi",
+ cfiLdflags = []string{"-flto", cfiCrossDsoFlag, cfiEnableFlag,
"-Wl,-plugin-opt,O1"}
cfiExportsMapPath = "build/soong/cc/config"
cfiExportsMapFilename = "cfi_exports.map"
@@ -395,8 +396,8 @@
// Leave out "-flto" from the slices exported to bazel, as we will use the
// dedicated LTO feature for this. For C Flags and Linker Flags, also leave
- // out the cross DSO flag which will be added separately by transitions.
- exportedVars.ExportStringList("CfiCFlags", cfiCflags[2:])
+ // out the cross DSO flag which will be added separately under the correct conditions.
+ exportedVars.ExportStringList("CfiCFlags", append(cfiCflags[2:], cfiEnableFlag))
exportedVars.ExportStringList("CfiLdFlags", cfiLdflags[2:])
exportedVars.ExportStringList("CfiAsFlags", cfiAsflags[1:])
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index d589925..2e6b6d4 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -16,6 +16,7 @@
import (
"bytes"
+ "errors"
"flag"
"fmt"
"os"
@@ -135,12 +136,24 @@
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
- if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") {
+ if needToWriteNinjaHint(ctx) {
writeNinjaHint(ctx)
}
return cmdlineArgs.OutFile
}
+func needToWriteNinjaHint(ctx *android.Context) bool {
+ switch ctx.Config().GetenvWithDefault("SOONG_GENERATES_NINJA_HINT", "") {
+ case "always":
+ return true
+ case "depend":
+ if _, err := os.Stat(filepath.Join(ctx.Config().OutDir(), ".ninja_log")); errors.Is(err, os.ErrNotExist) {
+ return true
+ }
+ }
+ return false
+}
+
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) {
ctx.EventHandler.Begin("queryview")
@@ -460,7 +473,7 @@
// The actual output (build.ninja) was written in the RunBlueprint() call
// above
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
- if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") {
+ if needToWriteNinjaHint(ctx) {
writeNinjaHint(ctx)
}
return cmdlineArgs.OutFile
diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go
index 2a1b404..b470304 100644
--- a/fuzz/fuzz_common.go
+++ b/fuzz/fuzz_common.go
@@ -170,6 +170,27 @@
return false
}
+type UsePlatformLibs string
+
+const (
+ unknown_use_platform_libs UsePlatformLibs = "unknown_use_platform_libs"
+ // Use the native libraries on the device, typically in /system directory
+ use_platform_libs = "use_platform_libs"
+ // Do not use any native libraries (ART will not be initialized)
+ use_none = "use_none"
+)
+
+func (use_platform_libs UsePlatformLibs) isValidUsePlatformLibs() bool {
+ switch use_platform_libs {
+ case "",
+ unknown_use_platform_libs,
+ use_platform_libs,
+ use_none:
+ return true
+ }
+ return false
+}
+
type UserData string
const (
@@ -284,6 +305,10 @@
if !config.Automatically_route_to.isValidAutomaticallyRouteTo() {
panic(fmt.Errorf("Invalid automatically_route_to in fuzz config in %s", moduleName))
}
+
+ if !config.Use_platform_libs.isValidUsePlatformLibs() {
+ panic(fmt.Errorf("Invalid use_platform_libs in fuzz config in %s", moduleName))
+ }
}
return true
}
@@ -341,6 +366,8 @@
Target_modules []string `json:"target_modules,omitempty"`
// Specifies a bug assignee to replace default ISE assignment
Triage_assignee string `json:"triage_assignee,omitempty"`
+ // Specifies libs used to initialize ART (java only, 'use_none' for no initialization)
+ Use_platform_libs UsePlatformLibs `json:"use_platform_libs,omitempty"`
}
type FuzzFrameworks struct {
diff --git a/java/app.go b/java/app.go
index 58580d4..d9272e4 100755
--- a/java/app.go
+++ b/java/app.go
@@ -289,7 +289,13 @@
}
if a.appProperties.Privapp_allowlist != nil && !Bool(a.appProperties.Privileged) {
- ctx.PropertyErrorf("privapp_allowlist", "privileged must be set in order to use privapp_allowlist")
+ // There are a few uids that are explicitly considered privileged regardless of their
+ // app's location. Bluetooth is one such app. It should arguably be moved to priv-app,
+ // but for now, allow it not to be in priv-app.
+ privilegedBecauseOfUid := ctx.ModuleName() == "Bluetooth"
+ if !privilegedBecauseOfUid {
+ ctx.PropertyErrorf("privapp_allowlist", "privileged must be set in order to use privapp_allowlist (with a few exceptions)")
+ }
}
for _, cert := range a.appProperties.Additional_certificates {
@@ -1396,7 +1402,7 @@
func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string {
optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool {
exists := ctx.OtherModuleExists(s)
- if !exists {
+ if !exists && !android.InList(ctx.ModuleName(), ctx.Config().BuildWarningBadOptionalUsesLibsAllowlist()) {
fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s)
}
return exists
diff --git a/java/app_test.go b/java/app_test.go
index 5aed178..cf7d174 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2644,6 +2644,9 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildWarningBadOptionalUsesLibsAllowlist = []string{"app", "prebuilt"}
+ }),
).RunTestWithBp(t, bp)
app := result.ModuleForTests("app", "android_common")
diff --git a/java/base.go b/java/base.go
index dd02ef8..ed61e12 100644
--- a/java/base.go
+++ b/java/base.go
@@ -79,6 +79,9 @@
// list of java libraries that will be compiled into the resulting jar
Static_libs []string `android:"arch_variant"`
+ // list of java libraries that should not be used to build this module
+ Exclude_static_libs []string `android:"arch_variant"`
+
// manifest file to be included in resulting jar
Manifest *string `android:"path"`
@@ -724,6 +727,8 @@
}
libDeps := ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
+
+ j.properties.Static_libs = android.RemoveListFromList(j.properties.Static_libs, j.properties.Exclude_static_libs)
ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
// Add dependency on libraries that provide additional hidden api annotations.
@@ -1923,22 +1928,22 @@
func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret sdkLinkType, stubs bool) {
switch name {
- case android.SdkCore.JavaLibraryName(ctx.Config()),
- android.JavaApiLibraryName(ctx.Config(), "legacy.core.platform.api.stubs"),
- android.JavaApiLibraryName(ctx.Config(), "stable.core.platform.api.stubs"),
+ case android.SdkCore.DefaultJavaLibraryName(),
+ "legacy.core.platform.api.stubs",
+ "stable.core.platform.api.stubs",
"stub-annotations", "private-stub-annotations-jar",
- android.JavaApiLibraryName(ctx.Config(), "core-lambda-stubs"),
+ "core-lambda-stubs",
"core-generated-annotation-stubs":
return javaCore, true
- case android.SdkPublic.JavaLibraryName(ctx.Config()):
+ case android.SdkPublic.DefaultJavaLibraryName():
return javaSdk, true
- case android.SdkSystem.JavaLibraryName(ctx.Config()):
+ case android.SdkSystem.DefaultJavaLibraryName():
return javaSystem, true
- case android.SdkModule.JavaLibraryName(ctx.Config()):
+ case android.SdkModule.DefaultJavaLibraryName():
return javaModule, true
- case android.SdkSystemServer.JavaLibraryName(ctx.Config()):
+ case android.SdkSystemServer.DefaultJavaLibraryName():
return javaSystemServer, true
- case android.SdkTest.JavaLibraryName(ctx.Config()):
+ case android.SdkTest.DefaultJavaLibraryName():
return javaSystem, true
}
diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp
index 958f4ce..eadd9c6 100644
--- a/java/core-libraries/Android.bp
+++ b/java/core-libraries/Android.bp
@@ -33,19 +33,45 @@
"win_sdk",
]
-java_library {
- name: "core.current.stubs",
+java_defaults {
+ name: "core.current.stubs.defaults",
visibility: ["//visibility:public"],
+ sdk_version: "none",
+ system_modules: "none",
+ dist: {
+ targets: dist_targets,
+ },
+}
+
+java_library {
+ name: "core.current.stubs.from-source",
+ defaults: [
+ "core.current.stubs.defaults",
+ ],
static_libs: [
"art.module.public.api.stubs",
"conscrypt.module.public.api.stubs",
"i18n.module.public.api.stubs",
],
- sdk_version: "none",
- system_modules: "none",
+}
- dist: {
- targets: dist_targets,
+java_library {
+ name: "core.current.stubs",
+ defaults: [
+ "core.current.stubs.defaults",
+ ],
+ static_libs: [
+ "core.current.stubs.from-source",
+ ],
+ product_variables: {
+ build_from_text_stub: {
+ static_libs: [
+ "core.current.stubs.from-text",
+ ],
+ exclude_static_libs: [
+ "core.current.stubs.from-source",
+ ],
+ },
},
}
@@ -199,18 +225,46 @@
// API annotations are available to the dex tools that enable enforcement of runtime
// accessibility. b/119068555
java_library {
- name: "legacy.core.platform.api.stubs",
+ name: "legacy.core.platform.api.stubs.from-source",
visibility: core_platform_visibility,
- hostdex: true,
- compile_dex: true,
-
- sdk_version: "none",
- system_modules: "none",
+ defaults: [
+ "core.platform.api.stubs.defaults",
+ ],
static_libs: [
"art.module.public.api.stubs.module_lib",
"conscrypt.module.platform.api.stubs",
"legacy.i18n.module.platform.api.stubs",
],
+}
+
+java_library {
+ name: "legacy.core.platform.api.stubs",
+ visibility: core_platform_visibility,
+ defaults: [
+ "core.platform.api.stubs.defaults",
+ ],
+ static_libs: [
+ "legacy.core.platform.api.stubs.from-source",
+ ],
+ product_variables: {
+ build_from_text_stub: {
+ static_libs: [
+ "stable.core.platform.api.stubs.from-text",
+ ],
+ exclude_static_libs: [
+ "stable.core.platform.api.stubs.from-source",
+ ],
+ },
+ },
+}
+
+java_defaults {
+ name: "core.platform.api.stubs.defaults",
+ hostdex: true,
+ compile_dex: true,
+
+ sdk_version: "none",
+ system_modules: "none",
patch_module: "java.base",
}
@@ -233,20 +287,38 @@
}
java_library {
- name: "stable.core.platform.api.stubs",
+ name: "stable.core.platform.api.stubs.from-source",
visibility: core_platform_visibility,
- hostdex: true,
- compile_dex: true,
-
- sdk_version: "none",
- system_modules: "none",
+ defaults: [
+ "core.platform.api.stubs.defaults",
+ ],
static_libs: [
"art.module.public.api.stubs.module_lib",
// conscrypt only has a stable version, so it is okay to depend on it here:
"conscrypt.module.platform.api.stubs",
"stable.i18n.module.platform.api.stubs",
],
- patch_module: "java.base",
+}
+
+java_library {
+ name: "stable.core.platform.api.stubs",
+ visibility: core_platform_visibility,
+ defaults: [
+ "core.platform.api.stubs.defaults",
+ ],
+ static_libs: [
+ "stable.core.platform.api.stubs.from-source",
+ ],
+ product_variables: {
+ build_from_text_stub: {
+ static_libs: [
+ "stable.core.platform.api.stubs.from-text",
+ ],
+ exclude_static_libs: [
+ "stable.core.platform.api.stubs.from-source",
+ ],
+ },
+ },
}
// Same as stable.core.platform.api.stubs, but android annotations are
diff --git a/java/fuzz.go b/java/fuzz.go
index 5dfaacf..b3c2fd4 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -30,8 +30,12 @@
const (
hostString = "host"
targetString = "target"
+ deviceString = "device"
)
+// Any shared libs for these deps will also be packaged
+var artDeps = []string{"libdl_android"}
+
func init() {
RegisterJavaFuzzBuildComponents(android.InitRegistrationContext)
}
@@ -78,7 +82,18 @@
}
func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if j.Os().Class.String() == deviceString {
+ j.testProperties.Jni_libs = append(j.testProperties.Jni_libs, artDeps...)
+ }
+
if len(j.testProperties.Jni_libs) > 0 {
+ if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {
+ config := &fuzz.FuzzConfig{}
+ j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config
+ }
+ // this will be used by the ingestion pipeline to determine the version
+ // of jazzer to add to the fuzzer package
+ j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true)
for _, target := range ctx.MultiTargets() {
sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...)
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index e54275b..da9c997 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -236,12 +236,12 @@
testStubModules = append(testStubModules, "sdk_test_current_android")
} else {
// Use stub modules built from source
- publicStubModules = append(publicStubModules, android.SdkPublic.JavaLibraryName(config))
- systemStubModules = append(systemStubModules, android.SdkSystem.JavaLibraryName(config))
- testStubModules = append(testStubModules, android.SdkTest.JavaLibraryName(config))
+ publicStubModules = append(publicStubModules, android.SdkPublic.DefaultJavaLibraryName())
+ systemStubModules = append(systemStubModules, android.SdkSystem.DefaultJavaLibraryName())
+ testStubModules = append(testStubModules, android.SdkTest.DefaultJavaLibraryName())
}
// We do not have prebuilts of the core platform api yet
- corePlatformStubModules = append(corePlatformStubModules, android.JavaApiLibraryName(config, "legacy.core.platform.api.stubs"))
+ corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs")
// Allow products to define their own stubs for custom product jars that apps can use.
publicStubModules = append(publicStubModules, config.ProductHiddenAPIStubs()...)
diff --git a/java/java.go b/java/java.go
index 4f7b401..a8793fe 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2813,6 +2813,14 @@
hasKotlin bool
}
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-java
+func xsdConfigJavaTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
+ callback := func(xsd android.XsdConfigBp2buildTargets) string {
+ return xsd.JavaBp2buildTargetName()
+ }
+ return android.XsdConfigBp2buildTarget(ctx, mod, callback)
+}
+
// convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with
// converted attributes shared across java_* modules and a bp2BuildJavaInfo struct
// which has other non-attribute information needed for bp2build conversion
@@ -2827,8 +2835,15 @@
for axis, configToProps := range archVariantProps {
for config, _props := range configToProps {
if archProps, ok := _props.(*CommonProperties); ok {
- archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs)
+ srcsNonXsd, srcsXsd := android.PartitionXsdSrcs(ctx, archProps.Srcs)
+ excludeSrcsNonXsd, _ := android.PartitionXsdSrcs(ctx, archProps.Exclude_srcs)
+ archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, srcsNonXsd, excludeSrcsNonXsd)
srcs.SetSelectValue(axis, config, archSrcs)
+
+ // Add to static deps
+ xsdJavaConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, srcsXsd, xsdConfigJavaTarget)
+ staticDeps.Append(xsdJavaConfigLibraryLabels)
+
}
}
}
diff --git a/java/java_test.go b/java/java_test.go
index cd5c343..561b187 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2322,3 +2322,34 @@
t.Errorf("Expected args[\"extraTestRunnerConfigs\"] to equal %q, was %q", expected, args["extraTestRunnerConfigs"])
}
}
+
+func TestJavaExcludeStaticLib(t *testing.T) {
+ ctx, _ := testJava(t, `
+ java_library {
+ name: "bar",
+ }
+ java_library {
+ name: "foo",
+ }
+ java_library {
+ name: "baz",
+ static_libs: [
+ "foo",
+ "bar",
+ ],
+ exclude_static_libs: [
+ "bar",
+ ],
+ }
+ `)
+
+ // "bar" not included as dependency of "baz"
+ CheckModuleDependencies(t, ctx, "baz", "android_common", []string{
+ `core-lambda-stubs`,
+ `ext`,
+ `foo`,
+ `framework`,
+ `stable-core-platform-api-stubs-system-modules`,
+ `stable.core.platform.api.stubs`,
+ })
+}
diff --git a/java/sdk.go b/java/sdk.go
index 7fa604f..7699aab 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -151,7 +151,7 @@
systemModules := android.JavaApiLibraryName(ctx.Config(), fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind))
return sdkDep{
useModule: true,
- bootclasspath: []string{module, android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)},
+ bootclasspath: []string{module, config.DefaultLambdaStubsLibrary},
systemModules: systemModules,
java9Classpath: []string{module},
frameworkResModule: "framework-res",
@@ -193,20 +193,20 @@
noFrameworksLibs: true,
}
case android.SdkPublic, android.SdkSystem, android.SdkTest:
- return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
+ return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
case android.SdkCore:
return sdkDep{
useModule: true,
- bootclasspath: []string{android.SdkCore.JavaLibraryName(ctx.Config()), android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)},
+ bootclasspath: []string{android.SdkCore.DefaultJavaLibraryName(), config.DefaultLambdaStubsLibrary},
systemModules: android.JavaApiLibraryName(ctx.Config(), "core-public-stubs-system-modules"),
noFrameworksLibs: true,
}
case android.SdkModule:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
- return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), nonUpdatableFrameworkAidlPath(ctx))
+ return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), nonUpdatableFrameworkAidlPath(ctx))
case android.SdkSystemServer:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
- return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
+ return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
default:
panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw))
}
@@ -269,9 +269,9 @@
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
func createSdkFrameworkAidl(ctx android.SingletonContext) {
stubsModules := []string{
- android.SdkPublic.JavaLibraryName(ctx.Config()),
- android.SdkTest.JavaLibraryName(ctx.Config()),
- android.SdkSystem.JavaLibraryName(ctx.Config()),
+ android.SdkPublic.DefaultJavaLibraryName(),
+ android.SdkTest.DefaultJavaLibraryName(),
+ android.SdkSystem.DefaultJavaLibraryName(),
}
combinedAidl := sdkFrameworkAidlPath(ctx)
@@ -286,7 +286,7 @@
// Creates a version of framework.aidl for the non-updatable part of the platform.
func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) {
- stubsModules := []string{android.SdkModule.JavaLibraryName(ctx.Config())}
+ stubsModules := []string{android.SdkModule.DefaultJavaLibraryName()}
combinedAidl := nonUpdatableFrameworkAidlPath(ctx)
tempPath := tempPathForRestat(ctx, combinedAidl)
diff --git a/tests/apex_comparison_tests.sh b/tests/apex_comparison_tests.sh
index e350323..8893060 100755
--- a/tests/apex_comparison_tests.sh
+++ b/tests/apex_comparison_tests.sh
@@ -29,7 +29,7 @@
# Test Setup
############
-OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
+OUTPUT_DIR="$(mktemp -d $(pwd)/tmp.XXXXXX)"
SOONG_OUTPUT_DIR="$OUTPUT_DIR/soong"
BAZEL_OUTPUT_DIR="$OUTPUT_DIR/bazel"
@@ -45,6 +45,12 @@
call_bazel clean
rm -rf "${OUTPUT_DIR}"
}
+
+function deapexer() {
+ DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
+ call_bazel run --config=bp2build //system/apex/tools:deapexer -- --debugfs_path=$DEBUGFS_PATH $@
+}
+
trap cleanup EXIT
###########
@@ -72,10 +78,7 @@
BAZEL_MINIMAL="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))"
# # Build debugfs separately, as it's not a dep of apexer, but needs to be an explicit arg.
-call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs //system/apex/tools:deapexer
-DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
-DEAPEXER="bazel-bin/system/apex/tools/deapexer"
-DEAPEXER="$DEAPEXER --debugfs_path=$DEBUGFS_PATH"
+call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs
#######
# Tests
@@ -91,8 +94,8 @@
local SOONG_LIST="$OUTPUT_DIR/soong.list"
local BAZEL_LIST="$OUTPUT_DIR/bazel.list"
- $DEAPEXER list "$SOONG_APEX" > "$SOONG_LIST"
- $DEAPEXER list "$BAZEL_APEX" > "$BAZEL_LIST"
+ deapexer list "$SOONG_APEX" > "$SOONG_LIST"
+ deapexer list "$BAZEL_APEX" > "$BAZEL_LIST"
if cmp -s "$SOONG_LIST" "$BAZEL_LIST"
then
diff --git a/tests/dcla_apex_comparison_test.sh b/tests/dcla_apex_comparison_test.sh
index 667dde0..e3c189f 100755
--- a/tests/dcla_apex_comparison_test.sh
+++ b/tests/dcla_apex_comparison_test.sh
@@ -55,6 +55,8 @@
libc++.so
libcrypto.so
libcutils.so
+ libstagefright_flacdec.so
+ libutils.so
)
if [[ -z ${OUT_DIR+x} ]]; then
diff --git a/ui/build/cleanbuild.go b/ui/build/cleanbuild.go
index ee53327..41cb5ab 100644
--- a/ui/build/cleanbuild.go
+++ b/ui/build/cleanbuild.go
@@ -135,6 +135,7 @@
productOut("obj/NOTICE_FILES"),
productOut("obj/PACKAGING"),
productOut("ramdisk"),
+ productOut("ramdisk_16k"),
productOut("debug_ramdisk"),
productOut("vendor_ramdisk"),
productOut("vendor_debug_ramdisk"),
diff --git a/ui/build/config.go b/ui/build/config.go
index 711774a..697cc66 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -16,6 +16,7 @@
import (
"encoding/json"
+ "errors"
"fmt"
"io/ioutil"
"math/rand"
@@ -136,6 +137,9 @@
EXTERNAL_FILE
// ninja uses a prioritized module list from Soong
HINT_FROM_SOONG
+ // If ninja log exists, use NINJA_LOG, if not, use HINT_FROM_SOONG instead.
+ // We can assume it is an incremental build if ninja log exists.
+ DEFAULT
)
const srcDirFileCheck = "build/soong/root.bp"
@@ -233,7 +237,7 @@
ret := &configImpl{
environ: OsEnvironment(),
sandboxConfig: &SandboxConfig{},
- ninjaWeightListSource: NINJA_LOG,
+ ninjaWeightListSource: DEFAULT,
}
// Default matching ninja
@@ -244,8 +248,21 @@
ret.parseArgs(ctx, args)
if ret.ninjaWeightListSource == HINT_FROM_SOONG {
- ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "true")
+ ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "always")
+ } else if ret.ninjaWeightListSource == DEFAULT {
+ defaultNinjaWeightListSource := NINJA_LOG
+ if _, err := os.Stat(filepath.Join(ret.OutDir(), ninjaLogFileName)); errors.Is(err, os.ErrNotExist) {
+ ctx.Verboseln("$OUT/.ninja_log doesn't exist, use HINT_FROM_SOONG instead")
+ defaultNinjaWeightListSource = HINT_FROM_SOONG
+ } else {
+ ctx.Verboseln("$OUT/.ninja_log exist, use NINJA_LOG")
+ }
+ ret.ninjaWeightListSource = defaultNinjaWeightListSource
+ // soong_build generates ninja hint depending on ninja log existence.
+ // Set it "depend" to avoid soong re-run due to env variable change.
+ ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "depend")
}
+
// Make sure OUT_DIR is set appropriately
if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index b3092ea..b3e871f 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -86,27 +86,29 @@
// This list specifies whether a particular binary from $PATH is allowed to be
// run during the build. For more documentation, see path_interposer.go .
var Configuration = map[string]PathConfig{
- "bash": Allowed,
- "dd": Allowed,
- "diff": Allowed,
- "dlv": Allowed,
- "expr": Allowed,
- "fuser": Allowed,
- "getopt": Allowed,
- "git": Allowed,
- "hexdump": Allowed,
- "jar": Allowed,
- "java": Allowed,
- "javap": Allowed,
- "lsof": Allowed,
- "openssl": Allowed,
- "pstree": Allowed,
- "rsync": Allowed,
- "sh": Allowed,
- "stubby": Allowed,
- "tr": Allowed,
- "unzip": Allowed,
- "zip": Allowed,
+ "bash": Allowed,
+ "dd": Allowed,
+ "diff": Allowed,
+ "dlv": Allowed,
+ "expr": Allowed,
+ "fuser": Allowed,
+ "gcert": Allowed,
+ "getopt": Allowed,
+ "git": Allowed,
+ "hexdump": Allowed,
+ "jar": Allowed,
+ "java": Allowed,
+ "javap": Allowed,
+ "lsof": Allowed,
+ "openssl": Allowed,
+ "prodcertstatus": Allowed,
+ "pstree": Allowed,
+ "rsync": Allowed,
+ "sh": Allowed,
+ "stubby": Allowed,
+ "tr": Allowed,
+ "unzip": Allowed,
+ "zip": Allowed,
// Host toolchain is removed. In-tree toolchain should be used instead.
// GCC also can't find cc1 with this implementation.
diff --git a/ui/metrics/BUILD.bazel b/ui/metrics/BUILD.bazel
index 2dc1ab6..ca39c59 100644
--- a/ui/metrics/BUILD.bazel
+++ b/ui/metrics/BUILD.bazel
@@ -23,6 +23,7 @@
proto_library(
name = "metrics-proto",
srcs = [
+ "bazel_metrics_proto/bazel_metrics.proto",
"bp2build_metrics_proto/bp2build_metrics.proto",
"metrics_proto/metrics.proto",
],