summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/config.go4
-rw-r--r--android/defs.go2
-rw-r--r--android/rule_builder.go4
-rw-r--r--android/rule_builder_test.go4
-rw-r--r--android/variable.go10
-rw-r--r--apex/apex_test.go27
-rw-r--r--cc/afdo.go7
-rw-r--r--cc/cc.go3
-rw-r--r--cc/cc_test.go15
-rw-r--r--cc/compiler.go9
-rw-r--r--cc/config/riscv64_device.go3
-rw-r--r--cc/gen_test.go2
-rw-r--r--cc/genrule_test.go2
-rw-r--r--cc/lto.go3
-rw-r--r--cc/testing.go2
-rw-r--r--cc/vendor_snapshot_test.go11
-rw-r--r--genrule/genrule_test.go2
-rw-r--r--java/droidstubs_test.go10
-rw-r--r--java/java_test.go12
-rw-r--r--java/lint_test.go8
-rw-r--r--rust/bindgen.go9
-rw-r--r--ui/build/build.go12
-rw-r--r--ui/build/rbe.go13
23 files changed, 122 insertions, 52 deletions
diff --git a/android/config.go b/android/config.go
index 0aad3bdae..a9fcca5ad 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1426,6 +1426,10 @@ func (c *config) IsVndkDeprecated() bool {
return !Bool(c.productVariables.KeepVndk)
}
+func (c *config) VendorApiLevel() string {
+ return String(c.productVariables.VendorApiLevel)
+}
+
func (c *deviceConfig) Arches() []Arch {
var arches []Arch
for _, target := range c.config.Targets[Android] {
diff --git a/android/defs.go b/android/defs.go
index b28d2fa3d..03968c10d 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -232,7 +232,7 @@ func shellUnescape(s string) string {
// ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use
// in tests.
-func ContentFromFileRuleForTests(t *testing.T, params TestingBuildParams) string {
+func ContentFromFileRuleForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) string {
t.Helper()
if g, w := params.Rule, writeFile; g != w {
t.Errorf("expected params.Rule to be %q, was %q", w, g)
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 5c6dffec1..1a491f708 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -1341,9 +1341,9 @@ func (c *RuleBuilderCommand) String() string {
// RuleBuilderSboxProtoForTests takes the BuildParams for the manifest passed to RuleBuilder.Sbox()
// and returns sbox testproto generated by the RuleBuilder.
-func RuleBuilderSboxProtoForTests(t *testing.T, params TestingBuildParams) *sbox_proto.Manifest {
+func RuleBuilderSboxProtoForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) *sbox_proto.Manifest {
t.Helper()
- content := ContentFromFileRuleForTests(t, params)
+ content := ContentFromFileRuleForTests(t, ctx, params)
manifest := sbox_proto.Manifest{}
err := prototext.Unmarshal([]byte(content), &manifest)
if err != nil {
diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go
index a6b3a27a1..63c35272a 100644
--- a/android/rule_builder_test.go
+++ b/android/rule_builder_test.go
@@ -683,7 +683,7 @@ func TestRuleBuilder_Build(t *testing.T) {
t.Errorf("want Deps = %q, got %q", blueprint.DepsGCC, params.Deps)
}
- rspFile2Content := ContentFromFileRuleForTests(t, rspFile2Params)
+ rspFile2Content := ContentFromFileRuleForTests(t, result.TestContext, rspFile2Params)
AssertStringEquals(t, "rspFile2 content", "rsp_in2\n", rspFile2Content)
}
@@ -797,7 +797,7 @@ func TestRuleBuilderHashInputs(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
t.Run("sbox", func(t *testing.T) {
gen := result.ModuleForTests(test.name+"_sbox", "")
- manifest := RuleBuilderSboxProtoForTests(t, gen.Output("sbox.textproto"))
+ manifest := RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("sbox.textproto"))
hash := manifest.Commands[0].GetInputHash()
AssertStringEquals(t, "hash", test.expectedHash, hash)
diff --git a/android/variable.go b/android/variable.go
index 307deaf32..f4c6e1cd2 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -226,6 +226,8 @@ type ProductVariables struct {
DeviceMaxPageSizeSupported *string `json:",omitempty"`
DevicePageSizeAgnostic *bool `json:",omitempty"`
+ VendorApiLevel *string `json:",omitempty"`
+
RecoverySnapshotVersion *string `json:",omitempty"`
DeviceSecondaryArch *string `json:",omitempty"`
@@ -618,6 +620,14 @@ func (v *ProductVariables) SetDefaultConfig() {
}
}
+func (this *ProductVariables) GetBuildFlagBool(flag string) bool {
+ val, ok := this.BuildFlags[flag]
+ if !ok {
+ return false
+ }
+ return val == "true"
+}
+
// ProductConfigContext requires the access to the Module to get product config properties.
type ProductConfigContext interface {
Module() Module
diff --git a/apex/apex_test.go b/apex/apex_test.go
index ab0c130a9..f14ab8a67 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -597,13 +597,15 @@ func TestBasicApex(t *testing.T) {
t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds)
}
- fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
+ fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt")), "\n")
ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex")
ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib")
ensureListContains(t, fullDepsInfo, " myotherjar(minSdkVersion:(no version)) <- myjar")
ensureListContains(t, fullDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external) <- myjar")
- flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
+ flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt")), "\n")
ensureListContains(t, flatDepsInfo, "myjar(minSdkVersion:(no version))")
ensureListContains(t, flatDepsInfo, "mylib2(minSdkVersion:(no version))")
ensureListContains(t, flatDepsInfo, "myotherjar(minSdkVersion:(no version))")
@@ -1283,10 +1285,12 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
- fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
+ fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt")), "\n")
ensureListContains(t, fullDepsInfo, " libfoo(minSdkVersion:(no version)) (external) <- mylib")
- flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
+ flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt")), "\n")
ensureListContains(t, flatDepsInfo, "libfoo(minSdkVersion:(no version)) (external)")
}
@@ -2032,7 +2036,8 @@ func TestTrackAllowedDeps(t *testing.T) {
"out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt")
myapex := ctx.ModuleForTests("myapex", "android_common_myapex")
- flatlist := strings.Split(myapex.Output("depsinfo/flatlist.txt").BuildParams.Args["content"], "\\n")
+ flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
+ myapex.Output("depsinfo/flatlist.txt")), "\n")
android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep",
flatlist, "libbar(minSdkVersion:(no version)) (external)")
android.AssertStringListDoesNotContain(t, "do not track if not available for platform",
@@ -8222,7 +8227,7 @@ func TestAppBundle(t *testing.T) {
`, withManifestPackageNameOverrides([]string{"AppFoo:com.android.foo"}))
bundleConfigRule := ctx.ModuleForTests("myapex", "android_common_myapex").Output("bundle_config.json")
- content := bundleConfigRule.Args["content"]
+ content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule)
ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`)
ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`)
@@ -8249,7 +8254,7 @@ func TestAppSetBundle(t *testing.T) {
}`)
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
bundleConfigRule := mod.Output("bundle_config.json")
- content := bundleConfigRule.Args["content"]
+ content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule)
ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`)
s := mod.Rule("apexRule").Args["copy_commands"]
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
@@ -9194,7 +9199,7 @@ func TestApexKeysTxt(t *testing.T) {
`)
myapex := ctx.ModuleForTests("myapex", "android_common_myapex")
- content := myapex.Output("apexkeys.txt").BuildParams.Args["content"]
+ content := android.ContentFromFileRuleForTests(t, ctx, myapex.Output("apexkeys.txt"))
ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`)
}
@@ -9234,9 +9239,11 @@ func TestApexKeysTxtOverrides(t *testing.T) {
}
`)
- content := ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt").BuildParams.Args["content"]
+ content := android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt"))
ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`)
- content = ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt").BuildParams.Args["content"]
+ content = android.ContentFromFileRuleForTests(t, ctx,
+ ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt"))
ensureContains(t, content, `name="myapex_set.apex" public_key="PRESIGNED" private_key="PRESIGNED" container_certificate="PRESIGNED" container_private_key="PRESIGNED" partition="system"`)
}
diff --git a/cc/afdo.go b/cc/afdo.go
index 91cf0b8a2..e7dea0e0d 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -64,6 +64,13 @@ func (afdo *afdo) props() []interface{} {
return []interface{}{&afdo.Properties}
}
+func (afdo *afdo) begin(ctx BaseModuleContext) {
+ // Disable on eng builds for faster build.
+ if ctx.Config().Eng() {
+ afdo.Properties.Afdo = false
+ }
+}
+
// afdoEnabled returns true for binaries and shared libraries
// that set afdo prop to True and there is a profile available
func (afdo *afdo) afdoEnabled() bool {
diff --git a/cc/cc.go b/cc/cc.go
index 867a59c03..2e42761c4 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2401,6 +2401,9 @@ func (c *Module) begin(ctx BaseModuleContext) {
if c.coverage != nil {
c.coverage.begin(ctx)
}
+ if c.afdo != nil {
+ c.afdo.begin(ctx)
+ }
if c.lto != nil {
c.lto.begin(ctx)
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index ed13e22d4..710b72b6c 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -40,6 +40,7 @@ func TestMain(m *testing.M) {
var prepareForCcTest = android.GroupFixturePreparers(
PrepareForTestWithCcIncludeVndk,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.VendorApiLevel = StringPtr("202404")
variables.DeviceVndkVersion = StringPtr("current")
variables.Platform_vndk_version = StringPtr("29")
}),
@@ -341,9 +342,9 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
}
}
-func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) {
+func checkWriteFileOutput(t *testing.T, ctx *android.TestContext, params android.TestingBuildParams, expected []string) {
t.Helper()
- content := android.ContentFromFileRuleForTests(t, params)
+ content := android.ContentFromFileRuleForTests(t, ctx, params)
actual := strings.FieldsFunc(content, func(r rune) bool { return r == '\n' })
assertArrayString(t, actual, expected)
}
@@ -351,7 +352,7 @@ func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expec
func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) {
t.Helper()
vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")
- checkWriteFileOutput(t, vndkSnapshot.Output(output), expected)
+ checkWriteFileOutput(t, ctx, vndkSnapshot.Output(output), expected)
}
func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) {
@@ -2131,11 +2132,13 @@ func TestEnforceProductVndkVersion(t *testing.T) {
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VNDK__")
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR__")
ensureStringNotContains(t, vendor_cflags, "-D__ANDROID_PRODUCT__")
+ ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR_API__=202404")
product_cflags := product_static.Rule("cc").Args["cFlags"]
ensureStringContains(t, product_cflags, "-D__ANDROID_VNDK__")
ensureStringContains(t, product_cflags, "-D__ANDROID_PRODUCT__")
ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR__")
+ ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR_API__=202404")
}
func TestEnforceProductVndkVersionErrors(t *testing.T) {
@@ -4302,7 +4305,7 @@ func TestAidlLibraryWithHeaders(t *testing.T) {
libfoo.Rule("aidl_library").Implicits,
)
- manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl_library.sbox.textproto"))
+ manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl_library.sbox.textproto"))
aidlCommand := manifest.Commands[0].GetCommand()
expectedAidlFlags := "-Ipackage_foo/a -Ipackage_bar/x"
@@ -4337,7 +4340,7 @@ func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
`)
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static")
- manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto"))
+ manifest := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, libfoo.Output("aidl.sbox.textproto"))
aidlCommand := manifest.Commands[0].GetCommand()
expectedAidlFlag := "-Werror"
if !strings.Contains(aidlCommand, expectedAidlFlag) {
@@ -4388,7 +4391,7 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
}
`)
libfoo := ctx.ModuleForTests("libfoo", tc.variant)
- manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto"))
+ manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl.sbox.textproto"))
aidlCommand := manifest.Commands[0].GetCommand()
expectedAidlFlag := "--min_sdk_version=" + tc.expected
if !strings.Contains(aidlCommand, expectedAidlFlag) {
diff --git a/cc/compiler.go b/cc/compiler.go
index 490d3cc3d..bb7885bc7 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -406,6 +406,15 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
if ctx.inVendor() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")
+
+ vendorApiLevel := ctx.Config().VendorApiLevel()
+ if vendorApiLevel == "" {
+ // TODO(b/314036847): This is a fallback for UDC targets.
+ // This must be a build failure when UDC is no longer built
+ // from this source tree.
+ vendorApiLevel = ctx.Config().PlatformSdkVersion().String()
+ }
+ flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel)
} else if ctx.inProduct() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_PRODUCT__")
}
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index e82026047..096401531 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -39,6 +39,9 @@ var (
// Equivalent to "-munaligned-access", but our clang doesn't have that yet.
"-Xclang -target-feature -Xclang +unaligned-scalar-mem",
"-Xclang -target-feature -Xclang +unaligned-vector-mem",
+ // We should change the default for this in clang, but for now...
+ // (https://github.com/google/android-riscv64/issues/124)
+ "-mllvm -jump-is-expensive=false",
}
riscv64Lldflags = append(riscv64Ldflags,
diff --git a/cc/gen_test.go b/cc/gen_test.go
index 85df33312..439f0a996 100644
--- a/cc/gen_test.go
+++ b/cc/gen_test.go
@@ -67,7 +67,7 @@ func TestGen(t *testing.T) {
t.Errorf("missing aidl includes in global flags")
}
- aidlCommand := android.RuleBuilderSboxProtoForTests(t, aidlManifest).Commands[0].GetCommand()
+ aidlCommand := android.RuleBuilderSboxProtoForTests(t, ctx, aidlManifest).Commands[0].GetCommand()
if !strings.Contains(aidlCommand, "-Isub") {
t.Errorf("aidl command for c.aidl should contain \"-Isub\", but was %q", aidlCommand)
}
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index 0d16e6261..929524480 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -178,7 +178,7 @@ func TestCmdPrefix(t *testing.T) {
android.OptionalFixturePreparer(tt.preparer),
).RunTestWithBp(t, bp)
gen := result.ModuleForTests("gen", tt.variant)
- sboxProto := android.RuleBuilderSboxProtoForTests(t, gen.Output("genrule.sbox.textproto"))
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("genrule.sbox.textproto"))
cmd := *sboxProto.Commands[0].Command
android.AssertStringDoesContain(t, "incorrect CC_ARCH", cmd, "CC_ARCH="+tt.arch+" ")
android.AssertStringDoesContain(t, "incorrect CC_NATIVE_BRIDGE", cmd, "CC_NATIVE_BRIDGE="+tt.nativeBridge+" ")
diff --git a/cc/lto.go b/cc/lto.go
index d2a43d27b..8b0880cf0 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -116,7 +116,8 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// better dead code elimination and CFG simplification, but do
// not perform costly optimizations for a balance between compile
// time, binary size and performance.
- if !lto.ThinLTO() {
+ // Apply the same for Eng builds as well.
+ if !lto.ThinLTO() || ctx.Config().Eng() {
ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}
diff --git a/cc/testing.go b/cc/testing.go
index 71d986b4f..b1583f169 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -797,7 +797,7 @@ func AssertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext,
func checkOverrides(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, jsonPath string, expected []string) {
t.Helper()
out := singleton.MaybeOutput(jsonPath)
- content := android.ContentFromFileRuleForTests(t, out)
+ content := android.ContentFromFileRuleForTests(t, ctx, out)
var flags snapshotJsonFlags
if err := json.Unmarshal([]byte(content), &flags); err != nil {
diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go
index c5431b3d3..890a53308 100644
--- a/cc/vendor_snapshot_test.go
+++ b/cc/vendor_snapshot_test.go
@@ -23,13 +23,14 @@ import (
"testing"
)
-func checkJsonContents(t *testing.T, ctx android.TestingSingleton, jsonPath string, key string, value string) {
- jsonOut := ctx.MaybeOutput(jsonPath)
+func checkJsonContents(t *testing.T, ctx *android.TestContext, snapshotSingleton android.TestingSingleton, jsonPath string, key string, value string) {
+ jsonOut := snapshotSingleton.MaybeOutput(jsonPath)
if jsonOut.Rule == nil {
t.Errorf("%q expected but not found", jsonPath)
return
}
- if !strings.Contains(jsonOut.Args["content"], fmt.Sprintf("%q:%q", key, value)) {
+ content := android.ContentFromFileRuleForTests(t, ctx, jsonOut)
+ if !strings.Contains(content, fmt.Sprintf("%q:%q", key, value)) {
t.Errorf("%q must include %q:%q but it only has %v", jsonPath, key, value, jsonOut.Args["content"])
}
}
@@ -167,8 +168,8 @@ func TestVendorSnapshotCapture(t *testing.T) {
filepath.Join(staticDir, "libvendor_available.a.json"),
filepath.Join(staticDir, "libvendor_available.cfi.a.json"))
- checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libb.a.json"), "MinSdkVersion", "apex_inherit")
- checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libvendor_available.a.json"), "MinSdkVersion", "29")
+ checkJsonContents(t, ctx, snapshotSingleton, filepath.Join(staticDir, "libb.a.json"), "MinSdkVersion", "apex_inherit")
+ checkJsonContents(t, ctx, snapshotSingleton, filepath.Join(staticDir, "libvendor_available.a.json"), "MinSdkVersion", "29")
// For binary executables, all vendor:true and vendor_available modules are captured.
if archType == "arm64" {
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 7c14531bd..4cff4b886 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -543,7 +543,7 @@ func TestGenruleHashInputs(t *testing.T) {
for _, test := range testcases {
t.Run(test.name, func(t *testing.T) {
gen := result.ModuleForTests(test.name, "")
- manifest := android.RuleBuilderSboxProtoForTests(t, gen.Output("genrule.sbox.textproto"))
+ manifest := android.RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("genrule.sbox.textproto"))
hash := manifest.Commands[0].GetInputHash()
android.AssertStringEquals(t, "hash", test.expectedHash, hash)
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index f86e1acef..7b89dded4 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -84,7 +84,7 @@ func TestDroidstubs(t *testing.T) {
for _, c := range testcases {
m := ctx.ModuleForTests(c.moduleName, "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, manifest)
cmdline := String(sboxProto.Commands[0].Command)
android.AssertStringContainsEquals(t, "api-versions generation flag", cmdline, "--generate-api-levels", c.generate_xml)
if c.expectedJarFilename != "" {
@@ -133,7 +133,7 @@ func getAndroidJarPatternsForDroidstubs(t *testing.T, sdkType string) []string {
m := ctx.ModuleForTests("foo-stubs", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- cmd := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
+ cmd := String(android.RuleBuilderSboxProtoForTests(t, ctx, manifest).Commands[0].Command)
r := regexp.MustCompile(`--android-jar-pattern [^ ]+/android.jar`)
return r.FindAllString(cmd, -1)
}
@@ -212,7 +212,7 @@ func TestDroidstubsSandbox(t *testing.T) {
t.Errorf("Expected inputs %q, got %q", w, g)
}
- manifest := android.RuleBuilderSboxProtoForTests(t, m.Output("metalava.sbox.textproto"))
+ manifest := android.RuleBuilderSboxProtoForTests(t, ctx, m.Output("metalava.sbox.textproto"))
if g, w := manifest.Commands[0].GetCommand(), "reference __SBOX_SANDBOX_DIR__/out/.intermediates/foo/gen/foo.txt"; !strings.Contains(g, w) {
t.Errorf("Expected command to contain %q, got %q", w, g)
}
@@ -302,7 +302,7 @@ func TestDroidstubsWithSdkExtensions(t *testing.T) {
})
m := ctx.ModuleForTests("baz-stubs", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
+ cmdline := String(android.RuleBuilderSboxProtoForTests(t, ctx, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "sdk-extensions-root present", cmdline, "--sdk-extensions-root sdk/extensions")
android.AssertStringDoesContain(t, "sdk-extensions-info present", cmdline, "--sdk-extensions-info sdk/extensions/info.txt")
}
@@ -434,6 +434,6 @@ func TestDroidstubsHideFlaggedApi(t *testing.T) {
m := result.ModuleForTests("foo", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
+ cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--hide-annotation android.annotation.FlaggedApi")
}
diff --git a/java/java_test.go b/java/java_test.go
index 81119a79e..0c750ebe1 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1921,7 +1921,7 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
for _, c := range testcases {
m := ctx.ModuleForTests(c.moduleName, "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
sourceFilesFlag := "--source-files " + strings.Join(c.sourceTextFileDirs, " ")
android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
@@ -2026,7 +2026,7 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
for _, c := range testcases {
m := ctx.ModuleForTests(c.moduleName, "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
sourceFilesFlag := "--source-files " + strings.Join(c.sourceTextFileDirs, " ")
android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
@@ -2316,7 +2316,7 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
m := ctx.ModuleForTests("bar1", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar")
}
@@ -2480,7 +2480,7 @@ func TestJavaApiContributionImport(t *testing.T) {
`)
m := ctx.ModuleForTests("foo", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
sourceFilesFlag := "--source-files current.txt"
android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
@@ -2501,7 +2501,7 @@ func TestJavaApiLibraryApiFilesSorting(t *testing.T) {
`)
m := ctx.ModuleForTests("foo", "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
// Api files are sorted from the narrowest api scope to the widest api scope.
@@ -2543,7 +2543,7 @@ func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) {
`)
m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common")
manifest := m.Output("metalava.sbox.textproto")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest)
manifestCommand := sboxProto.Commands[0].GetCommand()
classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/.intermediates/bar/android_common/turbine-combined/bar.jar"
android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag)
diff --git a/java/lint_test.go b/java/lint_test.go
index ec901aa70..5e6b8bcea 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -39,7 +39,7 @@ func TestJavaLint(t *testing.T) {
foo := ctx.ModuleForTests("foo", "android_common")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
t.Error("did not pass --baseline flag")
}
@@ -61,7 +61,7 @@ func TestJavaLintWithoutBaseline(t *testing.T) {
foo := ctx.ModuleForTests("foo", "android_common")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
if strings.Contains(*sboxProto.Commands[0].Command, "--baseline") {
t.Error("passed --baseline flag for non existent file")
}
@@ -108,7 +108,7 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) {
foo := ctx.ModuleForTests("foo", "android_common")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline mybaseline.xml") {
t.Error("did not use the correct file for baseline")
}
@@ -276,7 +276,7 @@ func TestJavaLintDatabaseSelectionFull(t *testing.T) {
RunTestWithBp(t, thisBp)
foo := result.ModuleForTests("foo", "android_common")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto"))
if !strings.Contains(*sboxProto.Commands[0].Command, "/"+testCase.expected_file) {
t.Error("did not use full api database for case", testCase)
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index ffe532fcb..1cc1574ac 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -174,6 +174,15 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
cflags = append(cflags, "-D__ANDROID_VNDK__")
if ctx.RustModule().InVendor() {
cflags = append(cflags, "-D__ANDROID_VENDOR__")
+
+ vendorApiLevel := ctx.Config().VendorApiLevel()
+ if vendorApiLevel == "" {
+ // TODO(b/314036847): This is a fallback for UDC targets.
+ // This must be a build failure when UDC is no longer built
+ // from this source tree.
+ vendorApiLevel = ctx.Config().PlatformSdkVersion().String()
+ }
+ cflags = append(cflags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel)
} else if ctx.RustModule().InProduct() {
cflags = append(cflags, "-D__ANDROID_PRODUCT__")
}
diff --git a/ui/build/build.go b/ui/build/build.go
index 9d5c330e1..54a4c27e5 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -283,11 +283,16 @@ func Build(ctx Context, config Config) {
}
rbeCh := make(chan bool)
+ var rbePanic any
if config.StartRBE() {
cleanupRBELogsDir(ctx, config)
+ checkRBERequirements(ctx, config)
go func() {
+ defer func() {
+ rbePanic = recover()
+ close(rbeCh)
+ }()
startRBE(ctx, config)
- close(rbeCh)
}()
defer DumpRBEMetrics(ctx, config, filepath.Join(config.LogsDir(), "rbe_metrics.pb"))
} else {
@@ -345,6 +350,11 @@ func Build(ctx Context, config Config) {
}
<-rbeCh
+ if rbePanic != nil {
+ // If there was a ctx.Fatal in startRBE, rethrow it.
+ panic(rbePanic)
+ }
+
if what&RunNinja != 0 {
if what&RunKati != 0 {
installCleanIfNecessary(ctx, config)
diff --git a/ui/build/rbe.go b/ui/build/rbe.go
index 19a54dfc2..fa04207e0 100644
--- a/ui/build/rbe.go
+++ b/ui/build/rbe.go
@@ -95,14 +95,10 @@ func cleanupRBELogsDir(ctx Context, config Config) {
}
}
-func startRBE(ctx Context, config Config) {
+func checkRBERequirements(ctx Context, config Config) {
if !config.GoogleProdCredsExist() && prodCredsAuthType(config) {
ctx.Fatalf("Unable to start RBE reproxy\nFAILED: Missing LOAS credentials.")
}
- ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap")
- defer ctx.EndTrace()
-
- ctx.Status.Status("Starting rbe...")
if u := ulimitOrFatal(ctx, config, "-u"); u < rbeLeastNProcs {
ctx.Fatalf("max user processes is insufficient: %d; want >= %d.\n", u, rbeLeastNProcs)
@@ -115,6 +111,13 @@ func startRBE(ctx Context, config Config) {
ctx.Fatalf("Unable to create logs dir (%v) for RBE: %v", config.rbeProxyLogsDir, err)
}
}
+}
+
+func startRBE(ctx Context, config Config) {
+ ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap")
+ defer ctx.EndTrace()
+
+ ctx.Status.Status("Starting rbe...")
cmd := Command(ctx, config, "startRBE bootstrap", rbeCommand(ctx, config, bootstrapCmd))