Merge "Allow actions to read BUILD_BROKEN_INCORRECT_PARTITION_IMAGES" into main
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 2438726..ad7f8d8 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -228,6 +228,7 @@
"frameworks/base/services/tests/servicestests/aidl": Bp2BuildDefaultTrue,
"frameworks/base/startop/apps/test": Bp2BuildDefaultTrue,
"frameworks/base/tests/appwidgets/AppWidgetHostTest": Bp2BuildDefaultTrueRecursively,
+ "frameworks/base/tools/aapt": Bp2BuildDefaultTrue,
"frameworks/base/tools/aapt2": Bp2BuildDefaultTrue,
"frameworks/base/tools/codegen": Bp2BuildDefaultTrueRecursively,
"frameworks/base/tools/streaming_proto": Bp2BuildDefaultTrueRecursively,
@@ -421,7 +422,7 @@
"tools/apifinder": Bp2BuildDefaultTrue,
"tools/apksig": Bp2BuildDefaultTrue,
"tools/external_updater": Bp2BuildDefaultTrueRecursively,
- "tools/metalava": Bp2BuildDefaultTrue,
+ "tools/metalava": Bp2BuildDefaultTrueRecursively,
"tools/platform-compat/java/android/compat": Bp2BuildDefaultTrueRecursively,
"tools/tradefederation/prebuilts/filegroups": Bp2BuildDefaultTrueRecursively,
}
diff --git a/android/bazel.go b/android/bazel.go
index 94b36e3..e764b18 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -510,12 +510,6 @@
}
module := p.module
- // In api_bp2build mode, all soong modules that can provide API contributions should be converted
- // This is irrespective of its presence/absence in bp2build allowlists
- if ctx.Config().BuildMode == ApiBp2build {
- _, providesApis := module.(ApiProvider)
- return providesApis
- }
propValue := b.bazelProperties.Bazel_module.Bp2build_available
packagePath := moduleDirWithPossibleOverride(ctx, module, p.moduleDir)
@@ -533,13 +527,13 @@
moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[p.moduleType]
allowlistConvert := moduleNameAllowed || moduleTypeAllowed
if moduleNameAllowed && moduleTypeAllowed {
- ctx.ModuleErrorf("A module cannot be in moduleAlwaysConvert and also be in moduleTypeAlwaysConvert")
+ ctx.ModuleErrorf("A module %q of type %q cannot be in moduleAlwaysConvert and also be in moduleTypeAlwaysConvert", moduleName, p.moduleType)
return false
}
if allowlist.moduleDoNotConvert[moduleName] {
if moduleNameAllowed {
- ctx.ModuleErrorf("a module cannot be in moduleDoNotConvert and also be in moduleAlwaysConvert")
+ ctx.ModuleErrorf("a module %q cannot be in moduleDoNotConvert and also be in moduleAlwaysConvert", moduleName)
}
return false
}
diff --git a/android/bazel_test.go b/android/bazel_test.go
index 194a6b3..15d3a6b 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -252,7 +252,7 @@
{
description: "module in name allowlist and type allowlist fails",
shouldConvert: false,
- expectedErrors: []string{"A module cannot be in moduleAlwaysConvert and also be in moduleTypeAlwaysConvert"},
+ expectedErrors: []string{"A module \"foo\" of type \"rule1\" cannot be in moduleAlwaysConvert and also be in moduleTypeAlwaysConvert"},
module: TestBazelModule{
TestModuleInfo: bazel.TestModuleInfo{
ModuleName: "foo",
@@ -273,7 +273,7 @@
{
description: "module in allowlist and denylist fails",
shouldConvert: false,
- expectedErrors: []string{"a module cannot be in moduleDoNotConvert and also be in moduleAlwaysConvert"},
+ expectedErrors: []string{"a module \"foo\" cannot be in moduleDoNotConvert and also be in moduleAlwaysConvert"},
module: TestBazelModule{
TestModuleInfo: bazel.TestModuleInfo{
ModuleName: "foo",
diff --git a/android/config.go b/android/config.go
index 1a3b539..645a263 100644
--- a/android/config.go
+++ b/android/config.go
@@ -87,7 +87,6 @@
SymlinkForestMarker string
Bp2buildMarker string
BazelQueryViewDir string
- BazelApiBp2buildDir string
ModuleGraphFile string
ModuleActionsFile string
DocFile string
@@ -121,9 +120,6 @@
// express build semantics.
GenerateQueryView
- // Generate BUILD files for API contributions to API surfaces
- ApiBp2build
-
// Create a JSON representation of the module graph and exit.
GenerateModuleGraph
@@ -641,7 +637,6 @@
setBuildMode(cmdArgs.SymlinkForestMarker, SymlinkForest)
setBuildMode(cmdArgs.Bp2buildMarker, Bp2build)
setBuildMode(cmdArgs.BazelQueryViewDir, GenerateQueryView)
- setBuildMode(cmdArgs.BazelApiBp2buildDir, ApiBp2build)
setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph)
setBuildMode(cmdArgs.DocFile, GenerateDocFile)
setBazelMode(cmdArgs.BazelMode, "--bazel-mode", BazelProdMode)
@@ -1662,11 +1657,18 @@
return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) && !c.MemtagHeapDisabledForPath(path)
}
+func (c *config) HWASanDisabledForPath(path string) bool {
+ if len(c.productVariables.HWASanExcludePaths) == 0 {
+ return false
+ }
+ return HasAnyPrefix(path, c.productVariables.HWASanExcludePaths)
+}
+
func (c *config) HWASanEnabledForPath(path string) bool {
if len(c.productVariables.HWASanIncludePaths) == 0 {
return false
}
- return HasAnyPrefix(path, c.productVariables.HWASanIncludePaths)
+ return HasAnyPrefix(path, c.productVariables.HWASanIncludePaths) && !c.HWASanDisabledForPath(path)
}
func (c *config) VendorConfig(name string) VendorConfig {
diff --git a/android/module.go b/android/module.go
index 19502ba..516810f 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1371,7 +1371,7 @@
for _, axis := range enabledPropertyOverrides.SortedConfigurationAxes() {
configToBools := enabledPropertyOverrides.ConfigurableValues[axis]
for cfg, val := range configToBools {
- if axis != bazel.OsConfigurationAxis || osSupport[cfg] {
+ if axis != bazel.OsConfigurationAxis || osSupport[cfg] || val /*If enabled is explicitly requested via overrides */ {
enabledProperty.SetSelectValue(axis, cfg, &val)
}
}
@@ -1418,10 +1418,42 @@
moduleEnableConstraints := bazel.LabelListAttribute{}
moduleEnableConstraints.Append(platformEnabledAttribute)
moduleEnableConstraints.Append(productConfigEnabledAttribute)
+ addCompatibilityConstraintForCompileMultilib(ctx, &moduleEnableConstraints)
return constraintAttributes{Target_compatible_with: moduleEnableConstraints}
}
+var (
+ incompatible = bazel.LabelList{[]bazel.Label{{Label: "@platforms//:incompatible"}}, nil}
+)
+
+// If compile_mulitilib is set to
+// 1. 32: Add an incompatibility constraint for non-32 arches
+// 1. 64: Add an incompatibility constraint for non-64 arches
+func addCompatibilityConstraintForCompileMultilib(ctx *topDownMutatorContext, enabled *bazel.LabelListAttribute) {
+ mod := ctx.Module().base()
+ multilib, _ := decodeMultilib(mod, mod.commonProperties.CompileOS, ctx.Config().IgnorePrefer32OnDevice())
+
+ switch multilib {
+ case "32":
+ // Add an incompatibility constraint for all known 64-bit arches
+ enabled.SetSelectValue(bazel.ArchConfigurationAxis, "arm64", incompatible)
+ enabled.SetSelectValue(bazel.ArchConfigurationAxis, "x86_64", incompatible)
+ enabled.SetSelectValue(bazel.ArchConfigurationAxis, "riscv64", incompatible)
+ case "64":
+ // Add an incompatibility constraint for all known 32-bit arches
+ enabled.SetSelectValue(bazel.ArchConfigurationAxis, "arm", incompatible)
+ enabled.SetSelectValue(bazel.ArchConfigurationAxis, "x86", incompatible)
+ case "both":
+ // Do nothing: "both" is trivially compatible with 32-bit and 64-bit
+ // The top level rule (e.g. apex/partition) will be responsible for building this module in both variants via an
+ // outgoing_transition.
+ default: // e.g. first, common
+ // TODO - b/299135307: Add bp2build support for these properties.
+ }
+
+}
+
// Check product variables for `enabled: true` flag override.
// Returns a list of the constraint_value targets who enable this override.
func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
diff --git a/android/proto.go b/android/proto.go
index 7c418c6..fc21d01 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -408,6 +408,11 @@
// As a workarounds, delete `target_compatible_with`
alwaysEnabled := bazel.BoolAttribute{}
alwaysEnabled.Value = proptools.BoolPtr(true)
+ // Add android and linux explicitly so that fillcommonbp2buildmoduleattrs can override these configs
+ // When we extend b support for other os'es (darwin/windows), we should add those configs here as well
+ alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid, proptools.BoolPtr(true))
+ alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsLinux, proptools.BoolPtr(true))
+
ctx.CreateBazelTargetModuleWithRestrictions(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
CommonAttributes{
diff --git a/android/register.go b/android/register.go
index 64b0207..df97c75 100644
--- a/android/register.go
+++ b/android/register.go
@@ -197,13 +197,6 @@
RegisterMutatorsForBazelConversion(ctx, bp2buildPreArchMutators)
}
-// RegisterForApiBazelConversion is similar to RegisterForBazelConversion except that
-// it only generates API targets in the generated workspace
-func (ctx *Context) RegisterForApiBazelConversion() {
- registerModuleTypes(ctx)
- RegisterMutatorsForApiBazelConversion(ctx, bp2buildPreArchMutators)
-}
-
// Register the pipeline of singletons, module types, and mutators for
// generating build.ninja and other files for Kati, from Android.bp files.
func (ctx *Context) Register() {
diff --git a/android/testing.go b/android/testing.go
index 5ad7ad0..32357db 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -467,12 +467,6 @@
RegisterMutatorsForBazelConversion(ctx.Context, ctx.bp2buildPreArch)
}
-// RegisterForApiBazelConversion prepares a test context for API bp2build conversion.
-func (ctx *TestContext) RegisterForApiBazelConversion() {
- ctx.config.BuildMode = ApiBp2build
- RegisterMutatorsForApiBazelConversion(ctx.Context, ctx.bp2buildPreArch)
-}
-
func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
// This function adapts the old style ParseFileList calls that are spread throughout the tests
// to the new style that takes a config.
diff --git a/android/variable.go b/android/variable.go
index 89ac915..02eff25 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -315,6 +315,7 @@
MemtagHeapSyncIncludePaths []string `json:",omitempty"`
HWASanIncludePaths []string `json:",omitempty"`
+ HWASanExcludePaths []string `json:",omitempty"`
VendorPath *string `json:",omitempty"`
OdmPath *string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index 52a5e20..1e65b0f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2008,6 +2008,9 @@
// If a module is directly included and also transitively depended on
// consider it as directly included.
e.transitiveDep = e.transitiveDep && f.transitiveDep
+ // If a module is added as both a JNI library and a regular shared library, consider it as a
+ // JNI library.
+ e.isJniLib = e.isJniLib || f.isJniLib
encountered[dest] = e
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 1717f3e..9475f5d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -7977,7 +7977,8 @@
apex {
name: "myapex",
key: "myapex.key",
- jni_libs: ["mylib", "libfoo.rust"],
+ binaries: ["mybin"],
+ jni_libs: ["mylib", "mylib3", "libfoo.rust"],
updatable: false,
}
@@ -8004,6 +8005,24 @@
apex_available: [ "myapex" ],
}
+ // Used as both a JNI library and a regular shared library.
+ cc_library {
+ name: "mylib3",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [ "myapex" ],
+ }
+
+ cc_binary {
+ name: "mybin",
+ srcs: ["mybin.cpp"],
+ shared_libs: ["mylib3"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [ "myapex" ],
+ }
+
rust_ffi_shared {
name: "libfoo.rust",
crate_name: "foo",
@@ -8027,10 +8046,12 @@
rule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule")
// Notice mylib2.so (transitive dep) is not added as a jni_lib
- ensureEquals(t, rule.Args["opt"], "-a jniLibs libfoo.rust.so mylib.so")
+ ensureEquals(t, rule.Args["opt"], "-a jniLibs libfoo.rust.so mylib.so mylib3.so")
ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{
+ "bin/mybin",
"lib64/mylib.so",
"lib64/mylib2.so",
+ "lib64/mylib3.so",
"lib64/libfoo.rust.so",
"lib64/libc++.so", // auto-added to libfoo.rust by Soong
"lib64/liblog.so", // auto-added to libfoo.rust by Soong
diff --git a/bp2build/Android.bp b/bp2build/Android.bp
index c104833..b675e5e 100644
--- a/bp2build/Android.bp
+++ b/bp2build/Android.bp
@@ -32,6 +32,7 @@
"soong-genrule",
"soong-linkerconfig",
"soong-python",
+ "soong-rust",
"soong-sh",
"soong-shared",
"soong-starlark-format",
@@ -61,7 +62,6 @@
"cc_test_conversion_test.go",
"cc_yasm_conversion_test.go",
"conversion_test.go",
- "droidstubs_conversion_test.go",
"filegroup_conversion_test.go",
"genrule_conversion_test.go",
"gensrcs_conversion_test.go",
@@ -82,6 +82,10 @@
"python_binary_conversion_test.go",
"python_library_conversion_test.go",
"python_test_conversion_test.go",
+ "rust_binary_conversion_test.go",
+ "rust_library_conversion_test.go",
+ "rust_proc_macro_conversion_test.go",
+ "rust_protobuf_conversion_test.go",
"sh_conversion_test.go",
"sh_test_conversion_test.go",
"soong_config_module_type_conversion_test.go",
diff --git a/bp2build/bp2build_product_config.go b/bp2build/bp2build_product_config.go
index e8c2ef7..7717993 100644
--- a/bp2build/bp2build_product_config.go
+++ b/bp2build/bp2build_product_config.go
@@ -1,9 +1,6 @@
package bp2build
import (
- "android/soong/android"
- "android/soong/android/soongconfig"
- "android/soong/starlark_import"
"encoding/json"
"fmt"
"os"
@@ -11,6 +8,10 @@
"reflect"
"strings"
+ "android/soong/android"
+ "android/soong/android/soongconfig"
+ "android/soong/starlark_import"
+
"github.com/google/blueprint/proptools"
"go.starlark.net/starlark"
)
@@ -258,12 +259,16 @@
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_name=%s\n", proptools.String(productVariables.DeviceName)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_page_size_agnostic=%t\n", proptools.Bool(productVariables.DevicePageSizeAgnostic)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_product=%s\n", proptools.String(productVariables.DeviceProduct)))
+ result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_platform=%s\n", label))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:enable_cfi=%t\n", proptools.BoolDefault(productVariables.EnableCFI, true)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:enforce_vintf_manifest=%t\n", proptools.Bool(productVariables.Enforce_vintf_manifest)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:eng=%t\n", proptools.Bool(productVariables.Eng)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_not_svelte=%t\n", proptools.Bool(productVariables.Malloc_not_svelte)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_pattern_fill_contents=%t\n", proptools.Bool(productVariables.Malloc_pattern_fill_contents)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_zero_contents=%t\n", proptools.Bool(productVariables.Malloc_zero_contents)))
+ result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:memtag_heap_exclude_paths=%s\n", strings.Join(productVariables.MemtagHeapExcludePaths, ",")))
+ result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:memtag_heap_async_include_paths=%s\n", strings.Join(productVariables.MemtagHeapAsyncIncludePaths, ",")))
+ result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:memtag_heap_sync_include_paths=%s\n", strings.Join(productVariables.MemtagHeapSyncIncludePaths, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:manifest_package_name_overrides=%s\n", strings.Join(productVariables.ManifestPackageNameOverrides, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:native_coverage=%t\n", proptools.Bool(productVariables.Native_coverage)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_version_name=%s\n", proptools.String(productVariables.Platform_version_name)))
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index cd1bc7f..9060363 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -175,9 +175,6 @@
// This mode is used for discovering and introspecting the existing Soong
// module graph.
QueryView
-
- // ApiBp2build - generate BUILD files for API contribution targets
- ApiBp2build
)
type unconvertedDepsMode int
@@ -196,8 +193,6 @@
return "Bp2Build"
case QueryView:
return "QueryView"
- case ApiBp2build:
- return "ApiBp2build"
default:
return fmt.Sprintf("%d", mode)
}
@@ -774,10 +769,6 @@
errs = append(errs, err)
}
targets = append(targets, t)
- case ApiBp2build:
- if aModule, ok := m.(android.Module); ok && aModule.IsConvertedByBp2build() {
- targets, errs = generateBazelTargets(bpCtx, aModule)
- }
default:
errs = append(errs, fmt.Errorf("Unknown code-generation mode: %s", ctx.Mode()))
return
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index 8ee0439..3887c5d 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -1879,30 +1879,6 @@
})
}
-func TestGenerateApiBazelTargets(t *testing.T) {
- bp := `
- custom {
- name: "foo",
- api: "foo.txt",
- }
- `
- expectedBazelTarget := MakeBazelTarget(
- "custom_api_contribution",
- "foo",
- AttrNameToString{
- "api": `"foo.txt"`,
- },
- )
- registerCustomModule := func(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("custom", customModuleFactoryHostAndDevice)
- }
- RunApiBp2BuildTestCase(t, registerCustomModule, Bp2buildTestCase{
- Blueprint: bp,
- ExpectedBazelTargets: []string{expectedBazelTarget},
- Description: "Generating API contribution Bazel targets for custom module",
- })
-}
-
func TestGenerateConfigSetting(t *testing.T) {
bp := `
custom {
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 02ed57a..246f169 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2839,205 +2839,6 @@
)
}
-func TestCcApiContributionsWithHdrs(t *testing.T) {
- bp := `
- cc_library {
- name: "libfoo",
- stubs: { symbol_file: "libfoo.map.txt", versions: ["28", "29", "current"] },
- llndk: { symbol_file: "libfoo.map.txt", override_export_include_dirs: ["dir2"]},
- export_include_dirs: ["dir1"],
- }
- `
- expectedBazelTargets := []string{
- MakeBazelTarget(
- "cc_api_library_headers",
- "libfoo.module-libapi.headers",
- AttrNameToString{
- "export_includes": `["dir1"]`,
- }),
- MakeBazelTarget(
- "cc_api_library_headers",
- "libfoo.vendorapi.headers",
- AttrNameToString{
- "export_includes": `["dir2"]`,
- }),
- MakeBazelTarget(
- "cc_api_contribution",
- "libfoo.contribution",
- AttrNameToString{
- "api": `"libfoo.map.txt"`,
- "library_name": `"libfoo"`,
- "api_surfaces": `[
- "module-libapi",
- "vendorapi",
- ]`,
- "hdrs": `[
- ":libfoo.module-libapi.headers",
- ":libfoo.vendorapi.headers",
- ]`,
- }),
- }
- RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
- Blueprint: bp,
- Description: "cc API contributions to module-libapi and vendorapi",
- ExpectedBazelTargets: expectedBazelTargets,
- })
-}
-
-func TestCcApiSurfaceCombinations(t *testing.T) {
- testCases := []struct {
- bp string
- expectedApi string
- expectedApiSurfaces string
- description string
- }{
- {
- bp: `
- cc_library {
- name: "a",
- stubs: {symbol_file: "a.map.txt"},
- }`,
- expectedApi: `"a.map.txt"`,
- expectedApiSurfaces: `["module-libapi"]`,
- description: "Library that contributes to module-libapi",
- },
- {
- bp: `
- cc_library {
- name: "a",
- llndk: {symbol_file: "a.map.txt"},
- }`,
- expectedApi: `"a.map.txt"`,
- expectedApiSurfaces: `["vendorapi"]`,
- description: "Library that contributes to vendorapi",
- },
- {
- bp: `
- cc_library {
- name: "a",
- llndk: {symbol_file: "a.map.txt"},
- stubs: {symbol_file: "a.map.txt"},
- }`,
- expectedApi: `"a.map.txt"`,
- expectedApiSurfaces: `[
- "module-libapi",
- "vendorapi",
- ]`,
- description: "Library that contributes to module-libapi and vendorapi",
- },
- }
- for _, testCase := range testCases {
- expectedBazelTargets := []string{
- MakeBazelTarget(
- "cc_api_contribution",
- "a.contribution",
- AttrNameToString{
- "library_name": `"a"`,
- "hdrs": `[]`,
- "api": testCase.expectedApi,
- "api_surfaces": testCase.expectedApiSurfaces,
- },
- ),
- }
- RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
- Blueprint: testCase.bp,
- Description: testCase.description,
- ExpectedBazelTargets: expectedBazelTargets,
- })
- }
-}
-
-// llndk struct property in Soong provides users with several options to configure the exported include dirs
-// Test the generated bazel targets for the different configurations
-func TestCcVendorApiHeaders(t *testing.T) {
- testCases := []struct {
- bp string
- expectedIncludes string
- expectedSystemIncludes string
- description string
- }{
- {
- bp: `
- cc_library {
- name: "a",
- export_include_dirs: ["include"],
- export_system_include_dirs: ["base_system_include"],
- llndk: {
- symbol_file: "a.map.txt",
- export_headers_as_system: true,
- },
- }
- `,
- expectedIncludes: "",
- expectedSystemIncludes: `[
- "base_system_include",
- "include",
- ]`,
- description: "Headers are exported as system to API surface",
- },
- {
- bp: `
- cc_library {
- name: "a",
- export_include_dirs: ["include"],
- export_system_include_dirs: ["base_system_include"],
- llndk: {
- symbol_file: "a.map.txt",
- override_export_include_dirs: ["llndk_include"],
- },
- }
- `,
- expectedIncludes: `["llndk_include"]`,
- expectedSystemIncludes: `["base_system_include"]`,
- description: "Non-system Headers are ovverriden before export to API surface",
- },
- {
- bp: `
- cc_library {
- name: "a",
- export_include_dirs: ["include"],
- export_system_include_dirs: ["base_system_include"],
- llndk: {
- symbol_file: "a.map.txt",
- override_export_include_dirs: ["llndk_include"],
- export_headers_as_system: true,
- },
- }
- `,
- expectedIncludes: "", // includes are set to nil
- expectedSystemIncludes: `[
- "base_system_include",
- "llndk_include",
- ]`,
- description: "System Headers are extended before export to API surface",
- },
- }
- for _, testCase := range testCases {
- attrs := AttrNameToString{}
- if testCase.expectedIncludes != "" {
- attrs["export_includes"] = testCase.expectedIncludes
- }
- if testCase.expectedSystemIncludes != "" {
- attrs["export_system_includes"] = testCase.expectedSystemIncludes
- }
-
- expectedBazelTargets := []string{
- MakeBazelTarget("cc_api_library_headers", "a.vendorapi.headers", attrs),
- // Create a target for cc_api_contribution target
- MakeBazelTarget("cc_api_contribution", "a.contribution", AttrNameToString{
- "api": `"a.map.txt"`,
- "api_surfaces": `["vendorapi"]`,
- "hdrs": `[":a.vendorapi.headers"]`,
- "library_name": `"a"`,
- }),
- }
- RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
- Blueprint: testCase.bp,
- ExpectedBazelTargets: expectedBazelTargets,
- })
- }
-}
-
func TestCcLibraryStubsAcrossConfigsDuplicatesRemoved(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "stub target generation of the same lib across configs should not result in duplicates",
@@ -5241,3 +5042,96 @@
}
runCcLibraryTestCase(t, tc)
}
+
+// `foo_device` and `bar_host` can depend on .proto files of a specific dir,
+// the dynamically generated proto_library should not have any target_compatible_with
+func TestProtoLibraryForIncludeDirsIsOsAgnostic(t *testing.T) {
+ tc := Bp2buildTestCase{
+ Description: "proto_library generated for proto.include_dirs is compatible for all axes",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: simpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite") + `
+cc_library {
+ name: "foo_device",
+ device_supported: true, // this is the default behavior, but added explicitly here for illustration
+ host_supported: false,
+ proto: {include_dirs: ["dir"]},
+}
+cc_library {
+ name: "bar_host",
+ device_supported: false,
+ host_supported: true,
+ srcs: ["bar.proto"],
+ proto: {include_dirs: ["dir"]},
+}
+`,
+ Filesystem: map[string]string{
+ "dir/Android.bp": "",
+ "dir/dir.proto": "",
+ },
+ Dir: "dir", // check for the generated proto_library
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("proto_library", "dir.include_dir_bp2build_generated_proto", AttrNameToString{
+ "srcs": `["dir.proto"]`,
+ "strip_import_prefix": `""`,
+ "tags": `["manual"]`,
+ }),
+ },
+ }
+ runCcLibraryTestCase(t, tc)
+}
+
+func TestCcCompileMultilibConversion(t *testing.T) {
+ tc := Bp2buildTestCase{
+ Description: "cc_library with compile_multilib",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "lib32",
+ compile_multilib: "32",
+}
+cc_library {
+ name: "lib64",
+ compile_multilib: "64",
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("cc_library_shared", "lib32", AttrNameToString{
+ "local_includes": `["."]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
+ "//build/bazel/platforms/arch:arm64": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:riscv64": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:x86_64": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTargetNoRestrictions("cc_library_static", "lib32_bp2build_cc_library_static", AttrNameToString{
+ "local_includes": `["."]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
+ "//build/bazel/platforms/arch:arm64": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:riscv64": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:x86_64": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTargetNoRestrictions("cc_library_shared", "lib64", AttrNameToString{
+ "local_includes": `["."]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
+ "//build/bazel/platforms/arch:arm": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:x86": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTargetNoRestrictions("cc_library_static", "lib64_bp2build_cc_library_static", AttrNameToString{
+ "local_includes": `["."]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
+ "//build/bazel/platforms/arch:arm": ["@platforms//:incompatible"],
+ "//build/bazel/platforms/arch:x86": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ }
+ runCcLibraryTestCase(t, tc)
+}
diff --git a/bp2build/cc_library_headers_conversion_test.go b/bp2build/cc_library_headers_conversion_test.go
index 072f5b3..a592ca9 100644
--- a/bp2build/cc_library_headers_conversion_test.go
+++ b/bp2build/cc_library_headers_conversion_test.go
@@ -123,69 +123,6 @@
})
}
-func TestCcApiHeaders(t *testing.T) {
- fs := map[string]string{
- "bar/Android.bp": `cc_library_headers { name: "bar_headers", }`,
- }
- bp := `
- cc_library_headers {
- name: "foo_headers",
- export_include_dirs: ["dir1", "dir2"],
- export_header_lib_headers: ["bar_headers"],
-
- arch: {
- arm: {
- export_include_dirs: ["dir_arm"],
- },
- x86: {
- export_include_dirs: ["dir_x86"],
- },
- },
-
- target: {
- android: {
- export_include_dirs: ["dir1", "dir_android"],
- },
- windows: {
- export_include_dirs: ["dir_windows"],
- },
- }
- }
- `
- expectedBazelTargets := []string{
- MakeBazelTarget("cc_api_library_headers", "foo_headers.contribution.arm", AttrNameToString{
- "export_includes": `["dir_arm"]`,
- "arch": `"arm"`,
- }),
- MakeBazelTarget("cc_api_library_headers", "foo_headers.contribution.x86", AttrNameToString{
- "export_includes": `["dir_x86"]`,
- "arch": `"x86"`,
- }),
- MakeBazelTarget("cc_api_library_headers", "foo_headers.contribution.androidos", AttrNameToString{
- "export_includes": `["dir_android"]`, // common includes are deduped
- }),
- // Windows headers are not exported
- MakeBazelTarget("cc_api_library_headers", "foo_headers.contribution", AttrNameToString{
- "export_includes": `[
- "dir1",
- "dir2",
- ]`,
- "deps": `[
- "//bar:bar_headers.contribution",
- ":foo_headers.contribution.arm",
- ":foo_headers.contribution.x86",
- ":foo_headers.contribution.androidos",
- ]`,
- }),
- }
- RunApiBp2BuildTestCase(t, cc.RegisterLibraryHeadersBuildComponents, Bp2buildTestCase{
- Blueprint: bp,
- Description: "Header library contributions to API surfaces",
- ExpectedBazelTargets: expectedBazelTargets,
- Filesystem: fs,
- })
-}
-
// header_libs has "variant_prepend" tag. In bp2build output,
// variant info(select) should go before general info.
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index 35a1400..da4b5cf 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -145,7 +145,7 @@
targets.sort()
var content string
- if mode == Bp2Build || mode == ApiBp2build {
+ if mode == Bp2Build {
content = `# READ THIS FIRST:
# This file was automatically generated by bp2build for the Bazel migration project.
# Feel free to edit or test it, but do *not* check it into your version control system.
diff --git a/bp2build/droidstubs_conversion_test.go b/bp2build/droidstubs_conversion_test.go
deleted file mode 100644
index 12c1cfe..0000000
--- a/bp2build/droidstubs_conversion_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2022 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package bp2build
-
-import (
- "testing"
-
- "android/soong/android"
- "android/soong/java"
-)
-
-func registerJavaApiModules(ctx android.RegistrationContext) {
- java.RegisterSdkLibraryBuildComponents(ctx)
- java.RegisterStubsBuildComponents(ctx)
-}
-
-func TestDroidstubsApiContributions(t *testing.T) {
- bp := `
- droidstubs {
- name: "framework-stubs",
- check_api: {
- current: {
- api_file: "framework.current.txt",
- },
- },
- }
-
- // Modules without check_api should not generate a Bazel API target
- droidstubs {
- name: "framework-docs",
- }
-
- // java_sdk_library is a macro that creates droidstubs
- java_sdk_library {
- name: "module-stubs",
- srcs: ["A.java"],
-
- // These api surfaces are added by default, but add them explicitly to make
- // this test hermetic
- public: {
- enabled: true,
- },
- system: {
- enabled: true,
- },
-
- // Disable other api surfaces to keep unit test scope limited
- module_lib: {
- enabled: false,
- },
- test: {
- enabled: false,
- },
- }
- `
- expectedBazelTargets := []string{
- MakeBazelTargetNoRestrictions(
- "java_api_contribution",
- "framework-stubs.contribution",
- AttrNameToString{
- "api": `"framework.current.txt"`,
- "api_surface": `"publicapi"`,
- "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
- }),
- MakeBazelTargetNoRestrictions(
- "java_api_contribution",
- "module-stubs.stubs.source.contribution",
- AttrNameToString{
- "api": `"api/current.txt"`,
- "api_surface": `"publicapi"`,
- "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
- }),
- MakeBazelTargetNoRestrictions(
- "java_api_contribution",
- "module-stubs.stubs.source.system.contribution",
- AttrNameToString{
- "api": `"api/system-current.txt"`,
- "api_surface": `"systemapi"`,
- "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
- }),
- }
- RunApiBp2BuildTestCase(t, registerJavaApiModules, Bp2buildTestCase{
- Blueprint: bp,
- ExpectedBazelTargets: expectedBazelTargets,
- Filesystem: map[string]string{
- "api/current.txt": "",
- "api/removed.txt": "",
- "api/system-current.txt": "",
- "api/system-removed.txt": "",
- },
- })
-}
diff --git a/bp2build/rust_binary_conversion_test.go b/bp2build/rust_binary_conversion_test.go
index 3364401..a5abbdb 100644
--- a/bp2build/rust_binary_conversion_test.go
+++ b/bp2build/rust_binary_conversion_test.go
@@ -1,3 +1,17 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package bp2build
import (
diff --git a/bp2build/rust_library_conversion_test.go b/bp2build/rust_library_conversion_test.go
index b860b76..0bc80df 100644
--- a/bp2build/rust_library_conversion_test.go
+++ b/bp2build/rust_library_conversion_test.go
@@ -1,3 +1,17 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package bp2build
import (
diff --git a/bp2build/rust_proc_macro_conversion_test.go b/bp2build/rust_proc_macro_conversion_test.go
index 82e080d..7df37ec 100644
--- a/bp2build/rust_proc_macro_conversion_test.go
+++ b/bp2build/rust_proc_macro_conversion_test.go
@@ -1,3 +1,17 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package bp2build
import (
@@ -17,7 +31,7 @@
}
func TestRustProcMacroLibrary(t *testing.T) {
- runRustLibraryTestCase(t, Bp2buildTestCase{
+ rustRustProcMacroTestCase(t, Bp2buildTestCase{
Dir: "external/rust/crates/foo",
Blueprint: "",
Filesystem: map[string]string{
diff --git a/bp2build/rust_protobuf_conversion_test.go b/bp2build/rust_protobuf_conversion_test.go
index a779c36..cf256aa 100644
--- a/bp2build/rust_protobuf_conversion_test.go
+++ b/bp2build/rust_protobuf_conversion_test.go
@@ -1,3 +1,17 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package bp2build
import (
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 42d955e..997df64 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -108,15 +108,6 @@
runBp2BuildTestCaseWithSetup(t, bp2buildSetup, tc)
}
-func RunApiBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc Bp2buildTestCase) {
- t.Helper()
- apiBp2BuildSetup := android.GroupFixturePreparers(
- android.FixtureRegisterWithContext(registerModuleTypes),
- SetApiBp2BuildTestRunner,
- )
- runBp2BuildTestCaseWithSetup(t, apiBp2BuildSetup, tc)
-}
-
func runBp2BuildTestCaseWithSetup(t *testing.T, extraPreparer android.FixturePreparer, tc Bp2buildTestCase) {
t.Helper()
dir := "."
@@ -180,27 +171,14 @@
}
// SetBp2BuildTestRunner customizes the test fixture mechanism to run tests in Bp2Build mode.
-var SetBp2BuildTestRunner = android.FixtureSetTestRunner(&bazelTestRunner{Bp2Build})
+var SetBp2BuildTestRunner = android.FixtureSetTestRunner(&bazelTestRunner{})
-// SetApiBp2BuildTestRunner customizes the test fixture mechanism to run tests in ApiBp2build mode.
-var SetApiBp2BuildTestRunner = android.FixtureSetTestRunner(&bazelTestRunner{ApiBp2build})
-
-// bazelTestRunner customizes the test fixture mechanism to run tests of the bp2build and
-// apiBp2build build modes.
-type bazelTestRunner struct {
- mode CodegenMode
-}
+// bazelTestRunner customizes the test fixture mechanism to run tests of the bp2build build mode.
+type bazelTestRunner struct{}
func (b *bazelTestRunner) FinalPreparer(result *android.TestResult) android.CustomTestResult {
ctx := result.TestContext
- switch b.mode {
- case Bp2Build:
- ctx.RegisterForBazelConversion()
- case ApiBp2build:
- ctx.RegisterForApiBazelConversion()
- default:
- panic(fmt.Errorf("unknown build mode: %d", b.mode))
- }
+ ctx.RegisterForBazelConversion()
return &BazelTestResult{TestResult: result}
}
@@ -214,11 +192,7 @@
return
}
- codegenMode := Bp2Build
- if ctx.Config().BuildMode == android.ApiBp2build {
- codegenMode = ApiBp2build
- }
- codegenCtx := NewCodegenContext(config, ctx.Context, codegenMode, "")
+ codegenCtx := NewCodegenContext(config, ctx.Context, Bp2Build, "")
res, errs := GenerateBazelTargets(codegenCtx, false)
if bazelResult.CollateErrs(errs) {
return
diff --git a/cc/config/OWNERS b/cc/config/OWNERS
index 580f215..c78b6d5 100644
--- a/cc/config/OWNERS
+++ b/cc/config/OWNERS
@@ -1,3 +1,3 @@
per-file vndk.go = smoreland@google.com, victoryang@google.com
-per-file clang.go,global.go,tidy.go = srhines@google.com, chh@google.com, pirama@google.com, yikong@google.com
+per-file clang.go,global.go,tidy.go = appujee@google.com, pirama@google.com, srhines@google.com, yabinc@google.com, yikong@google.com, zijunzhao@google.com
diff --git a/cc/config/global.go b/cc/config/global.go
index 472ce40..174b12c 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -45,7 +45,6 @@
"-UDEBUG",
"-fno-exceptions",
- "-Wno-multichar",
"-O2",
"-fdebug-default-version=5",
@@ -140,6 +139,9 @@
"-Werror=format-security",
"-nostdlibinc",
+ // Enable MLGO for register allocation.
+ "-mllvm -regalloc-enable-advisor=release",
+
// Emit additional debug info for AutoFDO
"-fdebug-info-for-profiling",
}
@@ -167,6 +169,8 @@
"-Wl,--exclude-libs,libgcc_stripped.a",
"-Wl,--exclude-libs,libunwind_llvm.a",
"-Wl,--exclude-libs,libunwind.a",
+ // Enable MLGO for register allocation.
+ "-Wl,-mllvm,-regalloc-enable-advisor=release",
}
deviceGlobalLldflags = append(deviceGlobalLdflags, commonGlobalLldflags...)
@@ -251,9 +255,6 @@
noOverrideExternalGlobalCflags = []string{
// http://b/191699019
"-Wno-format-insufficient-args",
- // http://b/296422292
- // Usually signals a mistake and should be a hard error.
- "-Wno-sizeof-array-div",
// http://b/296321145
// Indicates potential memory or stack corruption, so should be changed
// to a hard error. Currently triggered by some vendor code.
diff --git a/cc/lto.go b/cc/lto.go
index 820c1f0..df9ca0a 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -162,7 +162,7 @@
}
func GlobalThinLTO(ctx android.BaseModuleContext) bool {
- return ctx.Config().IsEnvTrue("GLOBAL_THINLTO")
+ return !ctx.Config().IsEnvFalse("GLOBAL_THINLTO")
}
// Propagate lto requirements down from binaries
diff --git a/cc/sanitize.go b/cc/sanitize.go
index f37b5c7..0abdafc 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -553,7 +553,9 @@
}
if found, globalSanitizers = removeFromList("hwaddress", globalSanitizers); found && s.Hwaddress == nil {
- s.Hwaddress = proptools.BoolPtr(true)
+ if !ctx.Config().HWASanDisabledForPath(ctx.ModuleDir()) {
+ s.Hwaddress = proptools.BoolPtr(true)
+ }
}
if found, globalSanitizers = removeFromList("writeonly", globalSanitizers); found && s.Writeonly == nil {
diff --git a/cc/test.go b/cc/test.go
index c643862..ae62128 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -395,7 +395,7 @@
useVendor := ctx.inVendor() || ctx.useVndk()
testInstallBase := getTestInstallBase(useVendor)
- configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx))
+ configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
TestConfigProp: test.Properties.Test_config,
@@ -435,22 +435,24 @@
return testInstallBase
}
-func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBinaryProperties, isolated bool) []tradefed.Config {
+func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBinaryProperties, isolated bool, device bool) []tradefed.Config {
var configs []tradefed.Config
for _, module := range properties.Test_mainline_modules {
configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module})
}
- if Bool(properties.Require_root) {
- configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
- } else {
- var options []tradefed.Option
- options = append(options, tradefed.Option{Name: "force-root", Value: "false"})
- configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
- }
- if Bool(properties.Disable_framework) {
- var options []tradefed.Option
- configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.StopServicesSetup", options})
+ if device {
+ if Bool(properties.Require_root) {
+ configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
+ } else {
+ var options []tradefed.Option
+ options = append(options, tradefed.Option{Name: "force-root", Value: "false"})
+ configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
+ }
+ if Bool(properties.Disable_framework) {
+ var options []tradefed.Option
+ configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.StopServicesSetup", options})
+ }
}
if isolated {
configs = append(configs, tradefed.Option{Name: "not-shardable", Value: "true"})
@@ -760,7 +762,7 @@
p.Auto_gen_config,
p.Test_options.Test_suite_tag,
p.Test_config_template,
- getTradefedConfigOptions(ctx, p, gtestIsolated),
+ getTradefedConfigOptions(ctx, p, gtestIsolated, true),
&testInstallBase,
)
testBinaryAttrs.TestConfigAttributes = testConfigAttributes
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 20e366e..626f076 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -27,7 +27,6 @@
"android/soong/android"
"android/soong/android/allowlists"
- "android/soong/bazel"
"android/soong/bp2build"
"android/soong/shared"
"android/soong/ui/metrics/bp2build_metrics_proto"
@@ -76,7 +75,6 @@
flag.StringVar(&cmdlineArgs.ModuleActionsFile, "module_actions_file", "", "JSON file to output inputs/outputs of actions of modules")
flag.StringVar(&cmdlineArgs.DocFile, "soong_docs", "", "build documentation file to output")
flag.StringVar(&cmdlineArgs.BazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory relative to --top")
- flag.StringVar(&cmdlineArgs.BazelApiBp2buildDir, "bazel_api_bp2build_dir", "", "path to the bazel api_bp2build directory relative to --top")
flag.StringVar(&cmdlineArgs.Bp2buildMarker, "bp2build_marker", "", "If set, run bp2build, touch the specified marker file then exit")
flag.StringVar(&cmdlineArgs.SymlinkForestMarker, "symlink_forest_marker", "", "If set, create the bp2build symlink forest, touch the specified marker file, then exit")
flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output")
@@ -169,120 +167,6 @@
touch(shared.JoinPath(topDir, queryviewMarker))
}
-// Run the code-generation phase to convert API contributions to BUILD files.
-// Return marker file for the new synthetic workspace
-func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string {
- ctx.EventHandler.Begin("api_bp2build")
- defer ctx.EventHandler.End("api_bp2build")
- // api_bp2build does not run the typical pipeline of soong mutators.
- // Hoevever, it still runs the defaults mutator which can create dependencies.
- // These dependencies might not always exist (e.g. in tests)
- ctx.SetAllowMissingDependencies(ctx.Config().AllowMissingDependencies())
- ctx.RegisterForApiBazelConversion()
-
- // Register the Android.bp files in the tree
- // Add them to the workspace's .d file
- ctx.SetModuleListFile(cmdlineArgs.ModuleListFile)
- if paths, err := ctx.ListModulePaths("."); err == nil {
- extraNinjaDeps = append(extraNinjaDeps, paths...)
- } else {
- panic(err)
- }
-
- // Run the loading and analysis phase
- ninjaDeps, err := bootstrap.RunBlueprint(cmdlineArgs.Args,
- bootstrap.StopBeforePrepareBuildActions,
- ctx.Context,
- ctx.Config())
- maybeQuit(err, "")
- ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
-
- // Add the globbed dependencies
- ninjaDeps = append(ninjaDeps, writeBuildGlobsNinjaFile(ctx)...)
-
- // Run codegen to generate BUILD files
- codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.ApiBp2build, topDir)
- absoluteApiBp2buildDir := shared.JoinPath(topDir, cmdlineArgs.BazelApiBp2buildDir)
- // Always generate bp2build_all_srcs filegroups in api_bp2build.
- // This is necessary to force each Android.bp file to create an equivalent BUILD file
- // and prevent package boundray issues.
- // e.g.
- // Source
- // f/b/Android.bp
- // java_library{
- // name: "foo",
- // api: "api/current.txt",
- // }
- //
- // f/b/api/Android.bp <- will cause package boundary issues
- //
- // Gen
- // f/b/BUILD
- // java_contribution{
- // name: "foo.contribution",
- // api: "//f/b/api:current.txt",
- // }
- //
- // If we don't generate f/b/api/BUILD, foo.contribution will be unbuildable.
- err = createBazelWorkspace(codegenContext, absoluteApiBp2buildDir, true)
- maybeQuit(err, "")
- ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
-
- // Create soong_injection repository
- soongInjectionFiles, workspaceFiles, err := bp2build.CreateSoongInjectionDirFiles(codegenContext, bp2build.CreateCodegenMetrics())
- maybeQuit(err, "")
- absoluteSoongInjectionDir := shared.JoinPath(topDir, ctx.Config().SoongOutDir(), bazel.SoongInjectionDirName)
- for _, file := range soongInjectionFiles {
- // The API targets in api_bp2build workspace do not have any dependency on api_bp2build.
- // But we need to create these files to prevent errors during Bazel analysis.
- // These need to be created in Read-Write mode.
- // This is because the subsequent step (bp2build in api domain analysis) creates them in Read-Write mode
- // to allow users to edit/experiment in the synthetic workspace.
- writeReadWriteFile(absoluteSoongInjectionDir, file)
- }
- for _, file := range workspaceFiles {
- writeReadWriteFile(absoluteApiBp2buildDir, file)
- }
-
- workspace := shared.JoinPath(ctx.Config().SoongOutDir(), "api_bp2build")
- // Create the symlink forest
- symlinkDeps, _, _ := bp2build.PlantSymlinkForest(
- ctx.Config().IsEnvTrue("BP2BUILD_VERBOSE"),
- topDir,
- workspace,
- cmdlineArgs.BazelApiBp2buildDir,
- apiBuildFileExcludes(ctx))
- ninjaDeps = append(ninjaDeps, symlinkDeps...)
-
- workspaceMarkerFile := workspace + ".marker"
- writeDepFile(workspaceMarkerFile, ctx.EventHandler, ninjaDeps)
- touch(shared.JoinPath(topDir, workspaceMarkerFile))
- return workspaceMarkerFile
-}
-
-// With some exceptions, api_bp2build does not have any dependencies on the checked-in BUILD files
-// Exclude them from the generated workspace to prevent unrelated errors during the loading phase
-func apiBuildFileExcludes(ctx *android.Context) []string {
- ret := bazelArtifacts()
- srcs, err := getExistingBazelRelatedFiles(topDir)
- maybeQuit(err, "Error determining existing Bazel-related files")
- for _, src := range srcs {
- // Exclude all src BUILD files
- if src != "WORKSPACE" &&
- src != "BUILD" &&
- src != "BUILD.bazel" &&
- !strings.HasPrefix(src, "build/bazel") &&
- !strings.HasPrefix(src, "external/bazel-skylib") &&
- !strings.HasPrefix(src, "prebuilts/clang") {
- ret = append(ret, src)
- }
- }
- // Android.bp files for api surfaces are mounted to out/, but out/ should not be a
- // dep for api_bp2build. Otherwise, api_bp2build will be run every single time
- ret = append(ret, ctx.Config().OutDir())
- return ret
-}
-
func writeNinjaHint(ctx *android.Context) error {
ctx.BeginEvent("ninja_hint")
defer ctx.EndEvent("ninja_hint")
@@ -551,9 +435,6 @@
// Run the alternate pipeline of bp2build mutators and singleton to convert
// Blueprint to BUILD files before everything else.
finalOutputFile = runBp2Build(ctx, extraNinjaDeps, metricsDir)
- case android.ApiBp2build:
- finalOutputFile = runApiBp2build(ctx, extraNinjaDeps)
- writeMetrics(configuration, ctx.EventHandler, metricsDir)
default:
ctx.Register()
isMixedBuildsEnabled := configuration.IsMixedBuildsEnabled()
diff --git a/etc/Android.bp b/etc/Android.bp
index c670236..cefd717 100644
--- a/etc/Android.bp
+++ b/etc/Android.bp
@@ -14,10 +14,12 @@
srcs: [
"prebuilt_etc.go",
"snapshot_etc.go",
+ "install_symlink.go",
],
testSrcs: [
"prebuilt_etc_test.go",
"snapshot_etc_test.go",
+ "install_symlink_test.go",
],
pluginFor: ["soong_build"],
}
diff --git a/etc/install_symlink.go b/etc/install_symlink.go
new file mode 100644
index 0000000..2182b86
--- /dev/null
+++ b/etc/install_symlink.go
@@ -0,0 +1,92 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package etc
+
+import (
+ "android/soong/android"
+ "path/filepath"
+ "strings"
+)
+
+func init() {
+ RegisterInstallSymlinkBuildComponents(android.InitRegistrationContext)
+}
+
+func RegisterInstallSymlinkBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("install_symlink", InstallSymlinkFactory)
+}
+
+// install_symlink can be used to install an symlink with an arbitrary target to an arbitrary path
+// on the device.
+func InstallSymlinkFactory() android.Module {
+ module := &InstallSymlink{}
+ module.AddProperties(&module.properties)
+ android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ return module
+}
+
+type InstallSymlinkProperties struct {
+ // Where to install this symlink, relative to the partition it's installed on.
+ // Which partition it's installed on can be controlled by the vendor, system_ext, ramdisk, etc.
+ // properties.
+ Installed_location string
+ // The target of the symlink, aka where the symlink points.
+ Symlink_target string
+}
+
+type InstallSymlink struct {
+ android.ModuleBase
+ properties InstallSymlinkProperties
+
+ output android.Path
+ installedPath android.InstallPath
+}
+
+func (m *InstallSymlink) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if filepath.Clean(m.properties.Symlink_target) != m.properties.Symlink_target {
+ ctx.PropertyErrorf("symlink_target", "Should be a clean filepath")
+ return
+ }
+ if filepath.Clean(m.properties.Installed_location) != m.properties.Installed_location {
+ ctx.PropertyErrorf("installed_location", "Should be a clean filepath")
+ return
+ }
+ if strings.HasPrefix(m.properties.Installed_location, "../") || strings.HasPrefix(m.properties.Installed_location, "/") {
+ ctx.PropertyErrorf("installed_location", "Should not start with / or ../")
+ return
+ }
+
+ out := android.PathForModuleOut(ctx, "out.txt")
+ android.WriteFileRuleVerbatim(ctx, out, "")
+ m.output = out
+
+ name := filepath.Base(m.properties.Installed_location)
+ installDir := android.PathForModuleInstall(ctx, filepath.Dir(m.properties.Installed_location))
+ m.installedPath = ctx.InstallAbsoluteSymlink(installDir, name, m.properties.Symlink_target)
+}
+
+func (m *InstallSymlink) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{{
+ Class: "FAKE",
+ // Need at least one output file in order for this to take effect.
+ OutputFile: android.OptionalPathForPath(m.output),
+ Include: "$(BUILD_PHONY_PACKAGE)",
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.AddStrings("LOCAL_SOONG_INSTALL_SYMLINKS", m.installedPath.String())
+ },
+ },
+ }}
+}
diff --git a/etc/install_symlink_test.go b/etc/install_symlink_test.go
new file mode 100644
index 0000000..d7165e5
--- /dev/null
+++ b/etc/install_symlink_test.go
@@ -0,0 +1,135 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package etc
+
+import (
+ "android/soong/android"
+ "strings"
+ "testing"
+)
+
+var prepareForInstallSymlinkTest = android.GroupFixturePreparers(
+ android.PrepareForTestWithArchMutator,
+ android.FixtureRegisterWithContext(RegisterInstallSymlinkBuildComponents),
+)
+
+func TestInstallSymlinkBasic(t *testing.T) {
+ result := prepareForInstallSymlinkTest.RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "bin/foo",
+ symlink_target: "/system/system_ext/bin/foo",
+ }
+ `)
+
+ foo_variants := result.ModuleVariantsForTests("foo")
+ if len(foo_variants) != 1 {
+ t.Fatalf("expected 1 variant, got %#v", foo_variants)
+ }
+
+ foo := result.ModuleForTests("foo", "android_common").Module()
+ androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo)
+ if len(androidMkEntries) != 1 {
+ t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries))
+ }
+
+ symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"]
+ if len(symlinks) != 1 {
+ t.Fatalf("Expected 1 symlink, got %d", len(symlinks))
+ }
+
+ if !strings.HasSuffix(symlinks[0], "system/bin/foo") {
+ t.Fatalf("Expected symlink install path to end in system/bin/foo, got: %s", symlinks[0])
+ }
+}
+
+func TestInstallSymlinkToRecovery(t *testing.T) {
+ result := prepareForInstallSymlinkTest.RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "bin/foo",
+ symlink_target: "/system/system_ext/bin/foo",
+ recovery: true,
+ }
+ `)
+
+ foo_variants := result.ModuleVariantsForTests("foo")
+ if len(foo_variants) != 1 {
+ t.Fatalf("expected 1 variant, got %#v", foo_variants)
+ }
+
+ foo := result.ModuleForTests("foo", "android_common").Module()
+ androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo)
+ if len(androidMkEntries) != 1 {
+ t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries))
+ }
+
+ symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"]
+ if len(symlinks) != 1 {
+ t.Fatalf("Expected 1 symlink, got %d", len(symlinks))
+ }
+
+ if !strings.HasSuffix(symlinks[0], "recovery/root/system/bin/foo") {
+ t.Fatalf("Expected symlink install path to end in recovery/root/system/bin/foo, got: %s", symlinks[0])
+ }
+}
+
+func TestErrorOnNonCleanTarget(t *testing.T) {
+ prepareForInstallSymlinkTest.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should be a clean filepath")).
+ RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "bin/foo",
+ symlink_target: "/system/system_ext/../bin/foo",
+ }
+ `)
+}
+
+func TestErrorOnNonCleanInstalledLocation(t *testing.T) {
+ prepareForInstallSymlinkTest.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should be a clean filepath")).
+ RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "bin/../foo",
+ symlink_target: "/system/system_ext/bin/foo",
+ }
+ `)
+}
+
+func TestErrorOnInstalledPathStartingWithDotDot(t *testing.T) {
+ prepareForInstallSymlinkTest.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should not start with / or \\.\\./")).
+ RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "../bin/foo",
+ symlink_target: "/system/system_ext/bin/foo",
+ }
+ `)
+}
+
+func TestErrorOnInstalledPathStartingWithSlash(t *testing.T) {
+ prepareForInstallSymlinkTest.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should not start with / or \\.\\./")).
+ RunTestWithBp(t, `
+ install_symlink {
+ name: "foo",
+ installed_location: "/bin/foo",
+ symlink_target: "/system/system_ext/bin/foo",
+ }
+ `)
+}
diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go
index df7664d..5c4e222 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -83,7 +83,7 @@
baz_variants := result.ModuleVariantsForTests("baz.conf")
if len(baz_variants) != 1 {
- t.Errorf("expected 1, got %#v", bar_variants)
+ t.Errorf("expected 1, got %#v", baz_variants)
}
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index b1ddde0..d1620af 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1633,7 +1633,7 @@
}{}
props.Name = proptools.StringPtr(module.sourceStubLibraryModuleName(apiScope))
- props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
+ props.Visibility = []string{"//visibility:override", "//visibility:private"}
// sources are generated from the droiddoc
props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
@@ -1829,7 +1829,7 @@
}{}
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
- props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
+ props.Visibility = []string{"//visibility:override", "//visibility:private"}
apiContributions := []string{}
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 118f8b6..868d697 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1474,3 +1474,32 @@
android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.fullApiSurfaceStub, *m.properties.Full_api_surface_stub)
}
}
+
+func TestStaticDepStubLibrariesVisibility(t *testing.T) {
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ android.FixtureMergeMockFs(
+ map[string][]byte{
+ "A.java": nil,
+ "dir/Android.bp": []byte(
+ `
+ java_library {
+ name: "bar",
+ srcs: ["A.java"],
+ libs: ["foo.stubs.from-source"],
+ }
+ `),
+ "dir/A.java": nil,
+ },
+ ).ExtendWithErrorHandler(
+ android.FixtureExpectsAtLeastOneErrorMatchingPattern(
+ `module "bar" variant "android_common": depends on //.:foo.stubs.from-source which is not visible to this module`)),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["A.java"],
+ }
+ `)
+}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 407f275..a80a587 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -29,7 +29,7 @@
defaultBindgenFlags = []string{""}
// bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures.
- bindgenClangVersion = "clang-r498229"
+ bindgenClangVersion = "clang-r498229b"
_ = pctx.VariableFunc("bindgenClangVersion", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("LLVM_BINDGEN_PREBUILTS_VERSION"); override != "" {
diff --git a/rust/sanitize.go b/rust/sanitize.go
index cc19e6e..2f5afd7 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -208,6 +208,11 @@
s.Memtag_heap = nil
}
+ // Disable sanitizers for musl x86 modules, rustc does not support any sanitizers.
+ if ctx.Os() == android.LinuxMusl && ctx.Arch().ArchType == android.X86 {
+ s.Never = boolPtr(true)
+ }
+
// TODO:(b/178369775)
// For now sanitizing is only supported on non-windows targets
if ctx.Os() != android.Windows && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) {
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 7ccc114..3c0b8ae 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -86,6 +86,98 @@
)
}
+func TestSnapshotWithPartialSystemServerClasspathFragment(t *testing.T) {
+ commonSdk := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "Tiramisu",
+ systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+ systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ apex_available: ["myapex"],
+ contents: [
+ "mysdklibrary",
+ "mysdklibrary-future",
+ ],
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "33", // Tiramisu
+ }
+ java_sdk_library {
+ name: "mysdklibrary-future",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "34", // UpsideDownCake
+ }
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ `
+
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "mysdklibrary-future"),
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:mysdklibrary", "myapex:mysdklibrary-future"),
+ android.FixtureModifyEnv(func(env map[string]string) {
+ // targeting Tiramisu here means that we won't export mysdklibrary-future
+ env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = "Tiramisu"
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake"}
+ }),
+ prepareForSdkTestWithApex,
+ android.FixtureWithRootAndroidBp(commonSdk),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(
+ `// This is auto-generated. DO NOT EDIT.
+
+java_sdk_library_import {
+ name: "mysdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ shared_library: true,
+ public: {
+ jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/public/mysdklibrary.txt",
+ removed_api: "sdk_library/public/mysdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+ system: {
+ jars: ["sdk_library/system/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/system/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/system/mysdklibrary.txt",
+ removed_api: "sdk_library/system/mysdklibrary-removed.txt",
+ sdk_version: "system_current",
+ },
+ test: {
+ jars: ["sdk_library/test/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/test/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/test/mysdklibrary.txt",
+ removed_api: "sdk_library/test/mysdklibrary-removed.txt",
+ sdk_version: "test_current",
+ },
+}
+
+prebuilt_systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+} `))
+}
+
func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
commonSdk := `
apex {
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
index 090114b..8a64a56 100755
--- a/tests/bp2build_bazel_test.sh
+++ b/tests/bp2build_bazel_test.sh
@@ -407,38 +407,6 @@
fi
}
-# Smoke test to verify api_bp2build worksapce does not contain any errors
-function test_api_bp2build_empty_build() {
- setup
- run_soong api_bp2build
- run_bazel build --config=android --config=api_bp2build //:empty
-}
-
-# Verify that an *_api_contribution target can refer to an api file from
-# another Bazel package.
-function test_api_export_from_another_bazel_package() {
- setup
- # Parent dir Android.bp
- mkdir -p foo
- cat > foo/Android.bp << 'EOF'
-cc_library {
- name: "libfoo",
- stubs: {
- symbol_file: "api/libfoo.map.txt",
- },
-}
-EOF
- # Child dir Android.bp
- mkdir -p foo/api
- cat > foo/api/Android.bp << 'EOF'
-package{}
-EOF
- touch foo/api/libfoo.map.txt
- # Run test
- run_soong api_bp2build
- run_bazel build --config=android --config=api_bp2build //foo:libfoo.contribution
-}
-
function test_bazel_standalone_output_paths_contain_product_name {
setup
mkdir -p a
diff --git a/tests/sbom_test.sh b/tests/sbom_test.sh
index 9ba19cf..9de9b97 100755
--- a/tests/sbom_test.sh
+++ b/tests/sbom_test.sh
@@ -85,47 +85,7 @@
lz4=$out_dir/host/linux-x86/bin/lz4
declare -A diff_excludes
- diff_excludes[vendor]="\
- -I /vendor/lib64/libkeystore2_crypto.so \
- -I /vendor/lib64/libvsock_utils.so"
- diff_excludes[system]="\
- -I /system/bin/assemble_cvd \
- -I /system/bin/console_forwarder \
- -I /system/bin/hwservicemanager \
- -I /system/bin/kernel_log_monitor \
- -I /system/bin/logcat_receiver \
- -I /system/bin/mkenvimage_slim \
- -I /system/bin/run_cvd \
- -I /system/bin/simg2img \
- -I /system/bin/log_tee \
- -I /system/lib64/android.hardware.confirmationui@1.0.so \
- -I /system/lib64/android.hardware.confirmationui-V1-ndk.so \
- -I /system/lib64/android.hardware.keymaster@4.1.so \
- -I /system/lib64/android.hardware.security.rkp-V3-ndk.so \
- -I /system/lib64/android.hardware.security.sharedsecret-V1-ndk.so \
- -I /system/lib64/android.security.compat-ndk.so \
- -I /system/lib64/libcuttlefish_allocd_utils.so \
- -I /system/lib64/libcuttlefish_device_config_proto.so \
- -I /system/lib64/libcuttlefish_device_config.so \
- -I /system/lib64/libcuttlefish_fs.so \
- -I /system/lib64/libcuttlefish_kernel_log_monitor_utils.so \
- -I /system/lib64/libcuttlefish_utils.so \
- -I /system/lib64/libfruit.so \
- -I /system/lib64/libgflags.so \
- -I /system/lib64/libkeymaster4_1support.so \
- -I /system/lib64/libkeymaster4support.so \
- -I /system/lib64/libkeymint.so \
- -I /system/lib64/libkeystore2_aaid.so \
- -I /system/lib64/libkeystore2_apc_compat.so \
- -I /system/lib64/libkeystore2_crypto.so \
- -I /system/lib64/libkeystore-attestation-application-id.so \
- -I /system/lib64/libkm_compat_service.so \
- -I /system/lib64/libkm_compat.so \
- -I /system/lib64/vndk-29 \
- -I /system/lib64/vndk-sp-29 \
- -I /system/lib/vndk-29 \
- -I /system/lib/vndk-sp-29 \
- -I /system/usr/icu"
+ diff_excludes[system]="-I /system/bin/hwservicemanager"
# Example output of dump.erofs is as below, and the data used in the test start
# at line 11. Column 1 is inode id, column 2 is inode type and column 3 is name.
diff --git a/ui/build/config.go b/ui/build/config.go
index 5d1505a..084d28d 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -70,7 +70,6 @@
checkbuild bool
dist bool
jsonModuleGraph bool
- apiBp2build bool // Generate BUILD files for Soong modules that contribute APIs
bp2build bool
queryview bool
reportMkMetrics bool // Collect and report mk2bp migration progress metrics.
@@ -869,8 +868,6 @@
c.jsonModuleGraph = true
} else if arg == "bp2build" {
c.bp2build = true
- } else if arg == "api_bp2build" {
- c.apiBp2build = true
} else if arg == "queryview" {
c.queryview = true
} else if arg == "soong_docs" {
@@ -970,7 +967,7 @@
return true
}
- if !c.JsonModuleGraph() && !c.Bp2Build() && !c.Queryview() && !c.SoongDocs() && !c.ApiBp2build() {
+ if !c.JsonModuleGraph() && !c.Bp2Build() && !c.Queryview() && !c.SoongDocs() {
// Command line was empty, the default Ninja target is built
return true
}
@@ -1068,10 +1065,6 @@
return shared.JoinPath(c.SoongOutDir(), "queryview.marker")
}
-func (c *configImpl) ApiBp2buildMarkerFile() string {
- return shared.JoinPath(c.SoongOutDir(), "api_bp2build.marker")
-}
-
func (c *configImpl) ModuleGraphFile() string {
return shared.JoinPath(c.SoongOutDir(), "module-graph.json")
}
@@ -1113,10 +1106,6 @@
return c.bp2build
}
-func (c *configImpl) ApiBp2build() bool {
- return c.apiBp2build
-}
-
func (c *configImpl) Queryview() bool {
return c.queryview
}
@@ -1308,7 +1297,7 @@
func (c *configImpl) UseRBE() bool {
// These alternate modes of running Soong do not use RBE / reclient.
- if c.Bp2Build() || c.Queryview() || c.ApiBp2build() || c.JsonModuleGraph() {
+ if c.Bp2Build() || c.Queryview() || c.JsonModuleGraph() {
return false
}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index b8543d9..44c20a0 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -41,7 +41,6 @@
bp2buildWorkspaceTag = "bp2build_workspace"
jsonModuleGraphTag = "modulegraph"
queryviewTag = "queryview"
- apiBp2buildTag = "api_bp2build"
soongDocsTag = "soong_docs"
// bootstrapEpoch is used to determine if an incremental build is incompatible with the current
@@ -264,7 +263,6 @@
config.NamedGlobFile(bp2buildFilesTag),
config.NamedGlobFile(jsonModuleGraphTag),
config.NamedGlobFile(queryviewTag),
- config.NamedGlobFile(apiBp2buildTag),
config.NamedGlobFile(soongDocsTag),
}
}
@@ -305,9 +303,6 @@
}
queryviewDir := filepath.Join(config.SoongOutDir(), "queryview")
- // The BUILD files will be generated in out/soong/.api_bp2build (no symlinks to src files)
- // The final workspace will be generated in out/soong/api_bp2build
- apiBp2buildDir := filepath.Join(config.SoongOutDir(), ".api_bp2build")
pbfs := []PrimaryBuilderFactory{
{
@@ -355,15 +350,6 @@
),
},
{
- name: apiBp2buildTag,
- description: fmt.Sprintf("generating BUILD files for API contributions at %s", apiBp2buildDir),
- config: config,
- output: config.ApiBp2buildMarkerFile(),
- specificArgs: append(baseArgs,
- "--bazel_api_bp2build_dir", apiBp2buildDir,
- ),
- },
- {
name: soongDocsTag,
description: fmt.Sprintf("generating Soong docs at %s", config.SoongDocsHtml()),
config: config,
@@ -533,10 +519,6 @@
checkEnvironmentFile(ctx, soongBuildEnv, config.UsedEnvFile(queryviewTag))
}
- if config.ApiBp2build() {
- checkEnvironmentFile(ctx, soongBuildEnv, config.UsedEnvFile(apiBp2buildTag))
- }
-
if config.SoongDocs() {
checkEnvironmentFile(ctx, soongBuildEnv, config.UsedEnvFile(soongDocsTag))
}
@@ -608,10 +590,6 @@
targets = append(targets, config.QueryviewMarkerFile())
}
- if config.ApiBp2build() {
- targets = append(targets, config.ApiBp2buildMarkerFile())
- }
-
if config.SoongDocs() {
targets = append(targets, config.SoongDocsHtml())
}
diff --git a/ui/status/ninja.go b/ui/status/ninja.go
index fb760ac..7b25d50 100644
--- a/ui/status/ninja.go
+++ b/ui/status/ninja.go
@@ -40,10 +40,11 @@
}
n := &NinjaReader{
- status: status,
- fifo: fifo,
- done: make(chan bool),
- cancel: make(chan bool),
+ status: status,
+ fifo: fifo,
+ forceClose: make(chan bool),
+ done: make(chan bool),
+ cancelOpen: make(chan bool),
}
go n.run()
@@ -52,10 +53,11 @@
}
type NinjaReader struct {
- status ToolStatus
- fifo string
- done chan bool
- cancel chan bool
+ status ToolStatus
+ fifo string
+ forceClose chan bool
+ done chan bool
+ cancelOpen chan bool
}
const NINJA_READER_CLOSE_TIMEOUT = 5 * time.Second
@@ -63,18 +65,34 @@
// Close waits for NinjaReader to finish reading from the fifo, or 5 seconds.
func (n *NinjaReader) Close() {
// Signal the goroutine to stop if it is blocking opening the fifo.
- close(n.cancel)
+ close(n.cancelOpen)
+ // Ninja should already have exited or been killed, wait 5 seconds for the FIFO to be closed and any
+ // remaining messages to be processed through the NinjaReader.run goroutine.
timeoutCh := time.After(NINJA_READER_CLOSE_TIMEOUT)
-
select {
case <-n.done:
- // Nothing
+ return
case <-timeoutCh:
- n.status.Error(fmt.Sprintf("ninja fifo didn't finish after %s", NINJA_READER_CLOSE_TIMEOUT.String()))
+ // Channel is not closed yet
}
- return
+ n.status.Error(fmt.Sprintf("ninja fifo didn't finish after %s", NINJA_READER_CLOSE_TIMEOUT.String()))
+
+ // Force close the reader even if the FIFO didn't close.
+ close(n.forceClose)
+
+ // Wait again for the reader thread to acknowledge the close before giving up and assuming it isn't going
+ // to send anything else.
+ timeoutCh = time.After(NINJA_READER_CLOSE_TIMEOUT)
+ select {
+ case <-n.done:
+ return
+ case <-timeoutCh:
+ // Channel is not closed yet
+ }
+
+ n.status.Verbose(fmt.Sprintf("ninja fifo didn't finish even after force closing after %s", NINJA_READER_CLOSE_TIMEOUT.String()))
}
func (n *NinjaReader) run() {
@@ -98,7 +116,7 @@
select {
case f = <-fileCh:
// Nothing
- case <-n.cancel:
+ case <-n.cancelOpen:
return
}
@@ -108,33 +126,58 @@
running := map[uint32]*Action{}
+ msgChan := make(chan *ninja_frontend.Status)
+
+ // Read from the ninja fifo and decode the protobuf in a goroutine so the main NinjaReader.run goroutine
+ // can listen
+ go func() {
+ defer close(msgChan)
+ for {
+ size, err := readVarInt(r)
+ if err != nil {
+ if err != io.EOF {
+ n.status.Error(fmt.Sprintf("Got error reading from ninja: %s", err))
+ }
+ return
+ }
+
+ buf := make([]byte, size)
+ _, err = io.ReadFull(r, buf)
+ if err != nil {
+ if err == io.EOF {
+ n.status.Print(fmt.Sprintf("Missing message of size %d from ninja\n", size))
+ } else {
+ n.status.Error(fmt.Sprintf("Got error reading from ninja: %s", err))
+ }
+ return
+ }
+
+ msg := &ninja_frontend.Status{}
+ err = proto.Unmarshal(buf, msg)
+ if err != nil {
+ n.status.Print(fmt.Sprintf("Error reading message from ninja: %v", err))
+ continue
+ }
+
+ msgChan <- msg
+ }
+ }()
+
for {
- size, err := readVarInt(r)
- if err != nil {
- if err != io.EOF {
- n.status.Error(fmt.Sprintf("Got error reading from ninja: %s", err))
- }
- return
+ var msg *ninja_frontend.Status
+ var msgOk bool
+ select {
+ case <-n.forceClose:
+ // Close() has been called, but the reader goroutine didn't get EOF after 5 seconds
+ break
+ case msg, msgOk = <-msgChan:
+ // msg is ready or closed
}
- buf := make([]byte, size)
- _, err = io.ReadFull(r, buf)
- if err != nil {
- if err == io.EOF {
- n.status.Print(fmt.Sprintf("Missing message of size %d from ninja\n", size))
- } else {
- n.status.Error(fmt.Sprintf("Got error reading from ninja: %s", err))
- }
- return
+ if !msgOk {
+ // msgChan is closed
+ break
}
-
- msg := &ninja_frontend.Status{}
- err = proto.Unmarshal(buf, msg)
- if err != nil {
- n.status.Print(fmt.Sprintf("Error reading message from ninja: %v", err))
- continue
- }
-
// Ignore msg.BuildStarted
if msg.TotalEdges != nil {
n.status.SetTotalActions(int(msg.TotalEdges.GetTotalEdges()))