Merge "Support robolectric prebuilts in android_robolectric_test"
diff --git a/android/defs.go b/android/defs.go
index 38ecb05..1a76721 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -57,6 +57,15 @@
},
"cpFlags")
+ // A copy rule that only updates the output if it changed.
+ CpIfChanged = pctx.AndroidStaticRule("CpIfChanged",
+ blueprint.RuleParams{
+ Command: "if ! cmp -s $in $out; then cp $in $out; fi",
+ Description: "cp if changed $out",
+ Restat: true,
+ },
+ "cpFlags")
+
CpExecutable = pctx.AndroidStaticRule("CpExecutable",
blueprint.RuleParams{
Command: "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out && chmod +x $out",
diff --git a/android/env.go b/android/env.go
index 58ad0b6..289d803 100644
--- a/android/env.go
+++ b/android/env.go
@@ -15,11 +15,6 @@
package android
import (
- "fmt"
- "os"
- "strings"
- "syscall"
-
"android/soong/shared"
)
@@ -31,9 +26,6 @@
// a manifest regeneration.
var originalEnv map[string]string
-var soongDelveListen string
-var soongDelvePath string
-var isDebugging bool
func InitEnvironment(envFile string) {
var err error
@@ -41,51 +33,6 @@
if err != nil {
panic(err)
}
-
- soongDelveListen = originalEnv["SOONG_DELVE"]
- soongDelvePath = originalEnv["SOONG_DELVE_PATH"]
-}
-
-// Returns whether the current process is running under Delve due to
-// ReexecWithDelveMaybe().
-func IsDebugging() bool {
- return isDebugging
-}
-func ReexecWithDelveMaybe() {
- isDebugging = os.Getenv("SOONG_DELVE_REEXECUTED") == "true"
- if isDebugging || soongDelveListen == "" {
- return
- }
-
- if soongDelvePath == "" {
- fmt.Fprintln(os.Stderr, "SOONG_DELVE is set but failed to find dlv")
- os.Exit(1)
- }
-
- soongDelveEnv := []string{}
- for _, env := range os.Environ() {
- idx := strings.IndexRune(env, '=')
- if idx != -1 {
- soongDelveEnv = append(soongDelveEnv, env)
- }
- }
-
- soongDelveEnv = append(soongDelveEnv, "SOONG_DELVE_REEXECUTED=true")
-
- dlvArgv := []string{
- soongDelvePath,
- "--listen=:" + soongDelveListen,
- "--headless=true",
- "--api-version=2",
- "exec",
- os.Args[0],
- "--",
- }
- dlvArgv = append(dlvArgv, os.Args[1:]...)
- os.Chdir(absSrcDir)
- syscall.Exec(soongDelvePath, dlvArgv, soongDelveEnv)
- fmt.Fprintln(os.Stderr, "exec() failed while trying to reexec with Delve")
- os.Exit(1)
}
func EnvSingleton() Singleton {
diff --git a/android/fixture.go b/android/fixture.go
index ae24b91..2c8997b 100644
--- a/android/fixture.go
+++ b/android/fixture.go
@@ -61,15 +61,15 @@
// register module bar twice:
// var Preparer1 = FixtureRegisterWithContext(RegisterModuleFooAndBar)
// var Preparer2 = FixtureRegisterWithContext(RegisterModuleBarAndBaz)
-// var AllPreparers = FixturePreparers(Preparer1, Preparer2)
+// var AllPreparers = GroupFixturePreparers(Preparer1, Preparer2)
//
// However, when restructured like this it would work fine:
// var PreparerFoo = FixtureRegisterWithContext(RegisterModuleFoo)
// var PreparerBar = FixtureRegisterWithContext(RegisterModuleBar)
// var PreparerBaz = FixtureRegisterWithContext(RegisterModuleBaz)
-// var Preparer1 = FixturePreparers(RegisterModuleFoo, RegisterModuleBar)
-// var Preparer2 = FixturePreparers(RegisterModuleBar, RegisterModuleBaz)
-// var AllPreparers = FixturePreparers(Preparer1, Preparer2)
+// var Preparer1 = GroupFixturePreparers(RegisterModuleFoo, RegisterModuleBar)
+// var Preparer2 = GroupFixturePreparers(RegisterModuleBar, RegisterModuleBaz)
+// var AllPreparers = GroupFixturePreparers(Preparer1, Preparer2)
//
// As after deduping and flattening AllPreparers would result in the following preparers being
// applied:
@@ -109,7 +109,7 @@
// An exported preparer for use by other packages that need to use java modules.
//
// package java
-// var PrepareForIntegrationTestWithJava = FixturePreparers(
+// var PrepareForIntegrationTestWithJava = GroupFixturePreparers(
// android.PrepareForIntegrationTestWithAndroid,
// FixtureRegisterWithContext(RegisterAGroupOfRelatedModulesMutatorsAndSingletons),
// FixtureRegisterWithContext(RegisterAnotherGroupOfRelatedModulesMutatorsAndSingletons),
@@ -144,7 +144,7 @@
// }
//
// package cc
-// var PrepareForTestWithCC = FixturePreparers(
+// var PrepareForTestWithCC = GroupFixturePreparers(
// android.PrepareForArchMutator,
// android.prepareForPrebuilts,
// FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest),
@@ -153,7 +153,7 @@
//
// package apex
//
-// var PrepareForApex = FixturePreparers(
+// var PrepareForApex = GroupFixturePreparers(
// ...
// )
//
@@ -182,7 +182,8 @@
// Create a Fixture.
Fixture(t *testing.T, preparers ...FixturePreparer) Fixture
- // Set the error handler that will be used to check any errors reported by the test.
+ // SetErrorHandler creates a new FixtureFactory that will use the supplied error handler to check
+ // the errors (may be 0) reported by the test.
//
// The default handlers is FixtureExpectsNoErrors which will fail the go test immediately if any
// errors are reported.
@@ -285,9 +286,12 @@
return FixtureAddTextFile("Android.bp", contents)
}
-// Create a composite FixturePreparer that is equivalent to applying each of the supplied
-// FixturePreparer instances in order.
-func FixturePreparers(preparers ...FixturePreparer) FixturePreparer {
+// GroupFixturePreparers creates a composite FixturePreparer that is equivalent to applying each of
+// the supplied FixturePreparer instances in order.
+//
+// Before preparing the fixture the list of preparers is flattened by replacing each
+// instance of GroupFixturePreparers with its contents.
+func GroupFixturePreparers(preparers ...FixturePreparer) FixturePreparer {
return &compositeFixturePreparer{dedupAndFlattenPreparers(nil, preparers)}
}
@@ -378,23 +382,28 @@
// The supplied result can be used to access the state of the code under test just as the main
// body of the test would but if any errors other than ones expected are reported the state may
// be indeterminate.
- CheckErrors(result *TestResult, errs []error)
+ CheckErrors(result *TestResult)
}
type simpleErrorHandler struct {
- function func(result *TestResult, errs []error)
+ function func(result *TestResult)
}
-func (h simpleErrorHandler) CheckErrors(result *TestResult, errs []error) {
- h.function(result, errs)
+func (h simpleErrorHandler) CheckErrors(result *TestResult) {
+ result.Helper()
+ h.function(result)
}
// The default fixture error handler.
//
// Will fail the test immediately if any errors are reported.
+//
+// If the test fails this handler will call `result.FailNow()` which will exit the goroutine within
+// which the test is being run which means that the RunTest() method will not return.
var FixtureExpectsNoErrors = FixtureCustomErrorHandler(
- func(result *TestResult, errs []error) {
- FailIfErrored(result.T, errs)
+ func(result *TestResult) {
+ result.Helper()
+ FailIfErrored(result.T, result.Errs)
},
)
@@ -407,9 +416,15 @@
//
// The test will not fail if:
// * Multiple errors are reported that do not match the pattern as long as one does match.
+//
+// If the test fails this handler will call `result.FailNow()` which will exit the goroutine within
+// which the test is being run which means that the RunTest() method will not return.
func FixtureExpectsAtLeastOneErrorMatchingPattern(pattern string) FixtureErrorHandler {
- return FixtureCustomErrorHandler(func(result *TestResult, errs []error) {
- FailIfNoMatchingErrors(result.T, pattern, errs)
+ return FixtureCustomErrorHandler(func(result *TestResult) {
+ result.Helper()
+ if !FailIfNoMatchingErrors(result.T, pattern, result.Errs) {
+ result.FailNow()
+ }
})
}
@@ -423,14 +438,18 @@
//
// The test will not fail if:
// * One or more of the patterns does not match an error.
+//
+// If the test fails this handler will call `result.FailNow()` which will exit the goroutine within
+// which the test is being run which means that the RunTest() method will not return.
func FixtureExpectsAllErrorsToMatchAPattern(patterns []string) FixtureErrorHandler {
- return FixtureCustomErrorHandler(func(result *TestResult, errs []error) {
- CheckErrorsAgainstExpectations(result.T, errs, patterns)
+ return FixtureCustomErrorHandler(func(result *TestResult) {
+ result.Helper()
+ CheckErrorsAgainstExpectations(result.T, result.Errs, patterns)
})
}
// FixtureCustomErrorHandler creates a custom error handler
-func FixtureCustomErrorHandler(function func(result *TestResult, errs []error)) FixtureErrorHandler {
+func FixtureCustomErrorHandler(function func(result *TestResult)) FixtureErrorHandler {
return simpleErrorHandler{
function: function,
}
@@ -531,6 +550,9 @@
fixture *fixture
Config Config
+
+ // The errors that were reported during the test.
+ Errs []error
}
var _ FixtureFactory = (*fixtureFactory)(nil)
@@ -575,8 +597,10 @@
}
func (f *fixtureFactory) SetErrorHandler(errorHandler FixtureErrorHandler) FixtureFactory {
- f.errorHandler = errorHandler
- return f
+ newFactory := &fixtureFactory{}
+ *newFactory = *f
+ newFactory.errorHandler = errorHandler
+ return newFactory
}
func (f *fixtureFactory) RunTest(t *testing.T, preparers ...FixturePreparer) *TestResult {
@@ -639,9 +663,10 @@
testContext: testContext{ctx},
fixture: f,
Config: f.config,
+ Errs: errs,
}
- f.errorHandler.CheckErrors(result, errs)
+ f.errorHandler.CheckErrors(result)
return result
}
diff --git a/android/fixture_test.go b/android/fixture_test.go
index 7bc033b..5a7bf3b 100644
--- a/android/fixture_test.go
+++ b/android/fixture_test.go
@@ -32,9 +32,9 @@
preparer3 := appendToList("preparer3")
preparer4 := appendToList("preparer4")
- preparer1Then2 := FixturePreparers(preparer1, preparer2)
+ preparer1Then2 := GroupFixturePreparers(preparer1, preparer2)
- preparer2Then1 := FixturePreparers(preparer2, preparer1)
+ preparer2Then1 := GroupFixturePreparers(preparer2, preparer1)
buildDir := "build"
factory := NewFixtureFactory(&buildDir, preparer1, preparer2, preparer1, preparer1Then2)
diff --git a/android/queryview.go b/android/queryview.go
index 9e3e45a..b940202 100644
--- a/android/queryview.go
+++ b/android/queryview.go
@@ -67,10 +67,14 @@
blueprint.RuleParams{
Command: fmt.Sprintf(
"rm -rf ${outDir}/* && "+
- "%s --bazel_queryview_dir ${outDir} %s && "+
+ "BUILDER=\"%s\" && "+
+ "cd $$(dirname \"$$BUILDER\") && "+
+ "ABSBUILDER=\"$$PWD/$$(basename \"$$BUILDER\")\" && "+
+ "cd / && "+
+ "env -i \"$$ABSBUILDER\" --bazel_queryview_dir ${outDir} \"%s\" && "+
"echo WORKSPACE: `cat %s` > ${outDir}/.queryview-depfile.d",
primaryBuilder.String(),
- strings.Join(os.Args[1:], " "),
+ strings.Join(os.Args[1:], "\" \""),
moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
),
CommandDeps: []string{primaryBuilder.String()},
diff --git a/android/testing.go b/android/testing.go
index 5832796..d8c123b 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -48,7 +48,7 @@
return ctx
}
-var PrepareForTestWithArchMutator = FixturePreparers(
+var PrepareForTestWithArchMutator = GroupFixturePreparers(
// Configure architecture targets in the fixture config.
FixtureModifyConfig(modifyTestConfigToSupportArchMutator),
@@ -73,7 +73,7 @@
})
// Prepares an integration test with build components from the android package.
-var PrepareForIntegrationTestWithAndroid = FixturePreparers(
+var PrepareForIntegrationTestWithAndroid = GroupFixturePreparers(
// Mutators. Must match order in mutator.go.
PrepareForTestWithArchMutator,
PrepareForTestWithDefaults,
@@ -456,12 +456,15 @@
}
}
-func FailIfNoMatchingErrors(t *testing.T, pattern string, errs []error) {
+// Fail if no errors that matched the regular expression were found.
+//
+// Returns true if a matching error was found, false otherwise.
+func FailIfNoMatchingErrors(t *testing.T, pattern string, errs []error) bool {
t.Helper()
matcher, err := regexp.Compile(pattern)
if err != nil {
- t.Errorf("failed to compile regular expression %q because %s", pattern, err)
+ t.Fatalf("failed to compile regular expression %q because %s", pattern, err)
}
found := false
@@ -477,6 +480,8 @@
t.Errorf("errs[%d] = %q", i, err)
}
}
+
+ return found
}
func CheckErrorsAgainstExpectations(t *testing.T, errs []error, expectedErrorPatterns []string) {
@@ -497,9 +502,9 @@
for i, err := range errs {
t.Errorf("errs[%d] = %s", i, err)
}
+ t.FailNow()
}
}
-
}
func SetKatiEnabledForTests(config Config) {
diff --git a/android/writedocs.go b/android/writedocs.go
index 6417690..6cb2f10 100644
--- a/android/writedocs.go
+++ b/android/writedocs.go
@@ -66,7 +66,9 @@
soongDocs := ctx.Rule(pctx, "soongDocs",
blueprint.RuleParams{
Command: fmt.Sprintf("rm -f ${outDir}/* && %s --soong_docs %s %s",
- primaryBuilder.String(), docsFile.String(), strings.Join(os.Args[1:], " ")),
+ primaryBuilder.String(),
+ docsFile.String(),
+ "\""+strings.Join(os.Args[1:], "\" \"")+"\""),
CommandDeps: []string{primaryBuilder.String()},
Description: fmt.Sprintf("%s docs $out", primaryBuilder.Base()),
},
diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt
index 476ac4a..047a0f3 100644
--- a/apex/allowed_deps.txt
+++ b/apex/allowed_deps.txt
@@ -192,7 +192,7 @@
GoogleCellBroadcastApp(minSdkVersion:29)
GoogleCellBroadcastServiceModule(minSdkVersion:29)
GoogleExtServices(minSdkVersion:current)
-GooglePermissionController(minSdkVersion:28)
+GooglePermissionController(minSdkVersion:30)
guava(minSdkVersion:current)
gwp_asan_headers(minSdkVersion:(no version))
i18n.module.public.api.stubs(minSdkVersion:(no version))
@@ -527,7 +527,7 @@
no_op(minSdkVersion:current)
note_memtag_heap_async(minSdkVersion:16)
note_memtag_heap_sync(minSdkVersion:16)
-PermissionController(minSdkVersion:28)
+PermissionController(minSdkVersion:30)
permissioncontroller-statsd(minSdkVersion:current)
philox_random(minSdkVersion:(no version))
philox_random_headers(minSdkVersion:(no version))
diff --git a/apex/apex_test.go b/apex/apex_test.go
index fcf2343..991f5c9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -67,14 +67,14 @@
t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
}
-func testApex(t *testing.T, bp string, handlers ...testCustomizer) (*android.TestContext, android.Config) {
+func testApex(t *testing.T, bp string, handlers ...testCustomizer) *android.TestContext {
t.Helper()
ctx, config := testApexContext(t, bp, handlers...)
_, errs := ctx.ParseBlueprintsFiles(".")
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
android.FailIfErrored(t, errs)
- return ctx, config
+ return ctx
}
type testCustomizer func(fs map[string][]byte, config android.Config)
@@ -240,7 +240,6 @@
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(android.RegisterComponentsMutator)
- ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
android.RegisterPrebuiltMutators(ctx)
@@ -249,6 +248,10 @@
ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
+ // These must come after prebuilts and visibility rules to match runtime.
+ ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
+
+ // These must come after override rules to match the runtime.
cc.RegisterRequiredBuildComponentsForTest(ctx)
rust.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterRequiredBuildComponentsForTest(ctx)
@@ -357,7 +360,7 @@
// Minimal test
func TestBasicApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_defaults {
name: "myapex-defaults",
manifest: ":myapex.manifest",
@@ -663,7 +666,7 @@
}
func TestDefaults(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_defaults {
name: "myapex-defaults",
key: "myapex.key",
@@ -738,7 +741,7 @@
}
func TestApexManifest(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -760,7 +763,7 @@
}
func TestBasicZipApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -811,7 +814,7 @@
}
func TestApexWithStubs(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -906,7 +909,7 @@
func TestApexWithStubsWithMinSdkVersion(t *testing.T) {
t.Parallel()
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1013,7 +1016,7 @@
// |
// <platform> |
// libplatform ----------------'
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1078,7 +1081,7 @@
}
func TestApexWithExplicitStubsDependency(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex2",
key: "myapex2.key",
@@ -1174,7 +1177,7 @@
|
`------> libbar
*/
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1236,7 +1239,7 @@
}
func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
- ctx, _ := testApex(t, "", func(fs map[string][]byte, config android.Config) {
+ ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) {
bp := `
apex {
name: "com.android.runtime",
@@ -1300,7 +1303,7 @@
}
func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) {
- ctx, _ := testApex(t, "", func(fs map[string][]byte, config android.Config) {
+ ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) {
bp := `
apex {
name: "com.android.runtime",
@@ -1386,7 +1389,7 @@
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1453,7 +1456,7 @@
}
func TestApexWithSystemLibsStubs(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1549,7 +1552,7 @@
// 1) myapex -> libx -> liba -> libz : this should be #30 link
// 2) otherapex -> liby -> liba -> libz : this should be #30 link
// 3) (platform) -> liba -> libz : this should be non-stub link
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1631,7 +1634,7 @@
}
func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1680,7 +1683,7 @@
}
func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1726,7 +1729,7 @@
}
func TestPlatformUsesLatestStubsFromApexes(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1774,7 +1777,7 @@
}
func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1813,7 +1816,7 @@
}
func TestQTargetApexUsesStaticUnwinder(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2140,7 +2143,7 @@
}
func TestApexMinSdkVersion_OkayEvenWhenDepIsNewer_IfItSatisfiesApexMinSdkVersion(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2227,7 +2230,7 @@
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("S")
config.TestProductVariables.Platform_version_active_codenames = []string{"S", "T"}
}
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2261,7 +2264,7 @@
}
func TestFilesInSubDir(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2324,7 +2327,7 @@
}
func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2383,7 +2386,7 @@
}
func TestUseVendor(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2496,7 +2499,7 @@
}
func TestVendorApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2543,7 +2546,7 @@
}
func TestVendorApex_use_vndk_as_stable(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2607,7 +2610,7 @@
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2635,7 +2638,7 @@
}
func TestAndroidMk_UseVendorRequired(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2670,7 +2673,7 @@
}
func TestAndroidMk_VendorApexRequired(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2702,7 +2705,7 @@
}
func TestAndroidMkWritesCommonProperties(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2732,7 +2735,7 @@
}
func TestStaticLinking(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2777,7 +2780,7 @@
}
func TestKeys(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -2835,7 +2838,7 @@
func TestCertificate(t *testing.T) {
t.Run("if unspecified, it defaults to DefaultAppCertificate", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2853,7 +2856,7 @@
}
})
t.Run("override when unspecified", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -2876,7 +2879,7 @@
}
})
t.Run("if specified as :module, it respects the prop", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2899,7 +2902,7 @@
}
})
t.Run("override when specifiec as <:module>", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -2923,7 +2926,7 @@
}
})
t.Run("if specified as name, finds it from DefaultDevKeyDir", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -2942,7 +2945,7 @@
}
})
t.Run("override when specified as <name>", func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -2968,7 +2971,7 @@
}
func TestMacro(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -3096,7 +3099,7 @@
}
func TestHeaderLibsDependency(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -3240,7 +3243,7 @@
}
func TestVndkApexCurrent(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "com.android.vndk.current.key",
@@ -3297,7 +3300,7 @@
}
func TestVndkApexWithPrebuilt(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "com.android.vndk.current.key",
@@ -3381,7 +3384,7 @@
}
func TestVndkApexVersion(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.v27",
key: "myapex.key",
@@ -3450,7 +3453,7 @@
}
func TestVndkApexNameRule(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "myapex.key",
@@ -3483,7 +3486,7 @@
}
func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "com.android.vndk.current.key",
@@ -3555,7 +3558,7 @@
}
func TestVndkApexWithBinder32(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.v27",
key: "myapex.key",
@@ -3624,7 +3627,7 @@
}
func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "com.android.vndk.current.key",
@@ -3660,7 +3663,7 @@
}
func TestDependenciesInApexManifest(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex_nodep",
key: "myapex.key",
@@ -3768,7 +3771,7 @@
}
func TestApexName(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -3813,7 +3816,7 @@
}
func TestNonTestApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -3866,7 +3869,7 @@
}
func TestTestApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -3915,7 +3918,7 @@
}
func TestApexWithTarget(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4006,7 +4009,7 @@
}
func TestApexWithArch(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4065,7 +4068,7 @@
}
func TestApexWithShBinary(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4106,7 +4109,7 @@
}
for _, tc := range testcases {
t.Run(tc.propName+":"+tc.parition, func(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4139,7 +4142,7 @@
}
func TestFileContexts_FindInDefaultLocationIfNotSet(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4193,7 +4196,7 @@
}
`)
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4216,7 +4219,7 @@
}
func TestFileContexts_SetViaFileGroup(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -4244,7 +4247,7 @@
}
func TestApexKeyFromOtherModule(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_key {
name: "myapex.key",
public_key: ":my.avbpubkey",
@@ -4277,7 +4280,7 @@
}
func TestPrebuilt(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
prebuilt_apex {
name: "myapex",
arch: {
@@ -4300,7 +4303,7 @@
}
func TestPrebuiltFilenameOverride(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
prebuilt_apex {
name: "myapex",
src: "myapex-arm.apex",
@@ -4317,7 +4320,7 @@
}
func TestPrebuiltOverrides(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
prebuilt_apex {
name: "myapex.prebuilt",
src: "myapex-arm.apex",
@@ -4828,7 +4831,7 @@
}
func TestApexWithTests(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -4940,7 +4943,7 @@
}
func TestInstallExtraFlattenedApexes(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5010,7 +5013,7 @@
}
func TestApexWithJavaImport(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5039,7 +5042,7 @@
}
func TestApexWithApps(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5118,7 +5121,7 @@
}
func TestApexWithAppImports(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5167,7 +5170,7 @@
}
func TestApexWithAppImportsPrefer(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5204,12 +5207,13 @@
}))
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
- "app/AppFoo/AppFooPrebuilt.apk",
+ // TODO(b/181974714) - this is wrong it should be "app/AppFoo/AppFooPrebuilt.apk"
+ "app/AppFoo/AppFoo.apk",
})
}
func TestApexWithTestHelperApp(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5420,7 +5424,7 @@
}
func TestApexAvailable_CheckForPlatform(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5483,7 +5487,7 @@
}
func TestApexAvailable_CreatedForApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5518,7 +5522,7 @@
}
func TestOverrideApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5602,7 +5606,7 @@
}
func TestLegacyAndroid10Support(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5662,7 +5666,7 @@
}
func TestJavaSDKLibrary(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5700,7 +5704,7 @@
}
func TestJavaSDKLibrary_WithinApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5753,7 +5757,7 @@
}
func TestJavaSDKLibrary_CrossBoundary(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5804,7 +5808,7 @@
}
func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
prebuilt_apis {
name: "sdk",
api_dirs: ["100"],
@@ -5921,7 +5925,7 @@
}
func TestCompatConfig(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -5982,7 +5986,7 @@
}
func TestCarryRequiredModuleNames(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6126,7 +6130,7 @@
// For unbundled build, symlink shouldn't exist regardless of whether an APEX
// is updatable or not
- ctx, _ := testApex(t, bp, withUnbundledBuild)
+ ctx := testApex(t, bp, withUnbundledBuild)
files := getFiles(t, ctx, "myapex", "android_common_myapex_image")
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
@@ -6138,7 +6142,7 @@
ensureRealfileExists(t, files, "lib64/myotherlib.so")
// For bundled build, symlink to the system for the non-updatable APEXes only
- ctx, _ = testApex(t, bp)
+ ctx = testApex(t, bp)
files = getFiles(t, ctx, "myapex", "android_common_myapex_image")
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
@@ -6151,7 +6155,7 @@
}
func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6203,7 +6207,7 @@
}
func TestApexWithJniLibs(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6245,7 +6249,7 @@
}
func TestApexMutatorsDontRunIfDisabled(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6267,7 +6271,7 @@
}
func TestAppBundle(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6298,7 +6302,7 @@
}
func TestAppSetBundle(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6331,7 +6335,7 @@
}
func TestAppSetBundlePrebuilt(t *testing.T) {
- ctx, _ := testApex(t, "", func(fs map[string][]byte, config android.Config) {
+ ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) {
bp := `
apex_set {
name: "myapex",
@@ -6816,7 +6820,7 @@
}
func TestTestFor(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -6902,7 +6906,7 @@
}
func TestApexSet(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_set {
name: "myapex",
set: "myapex.apks",
@@ -6978,7 +6982,7 @@
}
func TestApexKeysTxt(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7019,7 +7023,7 @@
}
func TestAllowedFiles(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7075,7 +7079,7 @@
}
func TestNonPreferredPrebuiltDependency(t *testing.T) {
- _, _ = testApex(t, `
+ testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7111,7 +7115,7 @@
}
func TestCompressedApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7146,7 +7150,7 @@
}
func TestPreferredPrebuiltSharedLibDep(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7198,7 +7202,7 @@
}
func TestExcludeDependency(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -7342,7 +7346,7 @@
t.Run(test.name, func(t *testing.T) {
for _, otherApexEnabled := range test.otherApexEnabled {
t.Run("otherapex_enabled_"+otherApexEnabled, func(t *testing.T) {
- ctx, _ := testApex(t, fmt.Sprintf(bpBase, otherApexEnabled)+test.stublibBp)
+ ctx := testApex(t, fmt.Sprintf(bpBase, otherApexEnabled)+test.stublibBp)
type modAndMkEntries struct {
mod *cc.Module
diff --git a/apex/boot_image_test.go b/apex/boot_image_test.go
index ff779e1..2e6ed82 100644
--- a/apex/boot_image_test.go
+++ b/apex/boot_image_test.go
@@ -28,7 +28,7 @@
// modules from the ART apex.
func TestBootImages(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
java_sdk_library {
name: "foo",
srcs: ["b.java"],
@@ -181,7 +181,7 @@
}
func TestBootImageInApex(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index 5e9a11f..34b9408 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -9,7 +9,7 @@
)
func TestVndkApexForVndkLite(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx := testApex(t, `
apex_vndk {
name: "com.android.vndk.current",
key: "com.android.vndk.current.key",
@@ -100,7 +100,7 @@
}
t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
- ctx, _ := testApex(t, bp)
+ ctx := testApex(t, bp)
// libfoo doesn't have apex variants
for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
@@ -113,7 +113,7 @@
})
t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
- ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
+ ctx := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
// Now product variant is available
config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
})
@@ -123,7 +123,7 @@
})
t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
- ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
+ ctx := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
config.TestProductVariables.GcovCoverage = proptools.BoolPtr(true)
config.TestProductVariables.Native_coverage = proptools.BoolPtr(true)
})
diff --git a/cc/testing.go b/cc/testing.go
index 45e5312..f62c5f1 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -25,7 +25,6 @@
RegisterBinaryBuildComponents(ctx)
RegisterLibraryBuildComponents(ctx)
RegisterLibraryHeadersBuildComponents(ctx)
- genrule.RegisterGenruleBuildComponents(ctx)
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
@@ -591,6 +590,7 @@
func CreateTestContext(config android.Config) *android.TestContext {
ctx := android.NewTestArchContext(config)
+ genrule.RegisterGenruleBuildComponents(ctx)
ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
ctx.RegisterModuleType("cc_test", TestFactory)
ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index e7f995f..d022f49 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -33,11 +33,15 @@
outDir string
docFile string
bazelQueryViewDir string
+ delveListen string
+ delvePath string
)
func init() {
flag.StringVar(&topDir, "top", "", "Top directory of the Android source tree")
flag.StringVar(&outDir, "out", "", "Soong output directory (usually $TOP/out/soong)")
+ flag.StringVar(&delveListen, "delve_listen", "", "Delve port to listen on for debugging")
+ flag.StringVar(&delvePath, "delve_path", "", "Path to Delve. Only used if --delve_listen is set")
flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output")
flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory")
}
@@ -87,9 +91,9 @@
func main() {
flag.Parse()
+ shared.ReexecWithDelveMaybe(delveListen, delvePath)
android.InitSandbox(topDir)
android.InitEnvironment(shared.JoinPath(topDir, outDir, "soong.environment.available"))
- android.ReexecWithDelveMaybe()
// The top-level Blueprints file is passed as the first argument.
srcDir := filepath.Dir(flag.Arg(0))
@@ -101,9 +105,7 @@
// user sets SOONG_DELVE the first time.
configuration.Getenv("SOONG_DELVE")
configuration.Getenv("SOONG_DELVE_PATH")
- // Read the SOONG_DELVE again through configuration so that there is a dependency on the environment variable
- // and soong_build will rerun when it is set for the first time.
- if listen := configuration.Getenv("SOONG_DELVE"); listen != "" {
+ if shared.IsDebugging() {
// Add a non-existent file to the dependencies so that soong_build will rerun when the debugger is
// enabled even if it completed successfully.
extraNinjaDeps = append(extraNinjaDeps, filepath.Join(configuration.BuildDir(), "always_rerun_for_delve"))
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 74ede68..1c5e78a 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -25,6 +25,7 @@
"strings"
"time"
+ "android/soong/shared"
"android/soong/ui/build"
"android/soong/ui/logger"
"android/soong/ui/metrics"
@@ -118,6 +119,8 @@
// Command is the type of soong_ui execution. Only one type of
// execution is specified. The args are specific to the command.
func main() {
+ shared.ReexecWithDelveMaybe(os.Getenv("SOONG_UI_DELVE"), shared.ResolveDelveBinary())
+
buildStarted := time.Now()
c, args, err := getCommand(os.Args)
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 737773f..fdb00bd 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -288,12 +288,9 @@
} else {
// Other libraries or APKs for which the exact <uses-library> list is unknown.
- // Pass special class loader context to skip the classpath and collision check.
- // This will get removed once LOCAL_USES_LIBRARIES is enforced.
- // Right now LOCAL_USES_LIBRARIES is opt in, for the case where it's not specified we still default
- // to the &.
+ // We assume the class loader context is empty.
rule.Command().
- Text(`class_loader_context_arg=--class-loader-context=\&`).
+ Text(`class_loader_context_arg=--class-loader-context=PCL[]`).
Text(`stored_class_loader_context_arg=""`)
}
diff --git a/java/aar.go b/java/aar.go
index 602d2c4..554ea67 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -805,14 +805,6 @@
return android.Paths{a.classpathFile}
}
-func (a *AARImport) ImplementationJars() android.Paths {
- return android.Paths{a.classpathFile}
-}
-
-func (a *AARImport) ResourceJars() android.Paths {
- return nil
-}
-
func (a *AARImport) ImplementationAndResourcesJars() android.Paths {
return android.Paths{a.classpathFile}
}
@@ -825,22 +817,10 @@
return nil
}
-func (a *AARImport) AidlIncludeDirs() android.Paths {
- return nil
-}
-
func (a *AARImport) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
return nil
}
-func (d *AARImport) ExportedPlugins() (android.Paths, []string, bool) {
- return nil, nil, false
-}
-
-func (a *AARImport) SrcJarArgs() ([]string, android.Paths) {
- return nil, nil
-}
-
var _ android.ApexModule = (*AARImport)(nil)
// Implements android.ApexModule
diff --git a/java/android_manifest.go b/java/android_manifest.go
index c76bb2f..b30f3d2 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -91,7 +91,7 @@
if err != nil {
ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
}
- if UseApiFingerprint(ctx) {
+ if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
}
@@ -100,7 +100,7 @@
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
- if UseApiFingerprint(ctx) {
+ if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
}
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index ee7d018..39fb04a 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -146,14 +146,6 @@
return d.headerJars
}
-func (d *DeviceHostConverter) ImplementationJars() android.Paths {
- return d.implementationJars
-}
-
-func (d *DeviceHostConverter) ResourceJars() android.Paths {
- return d.resourceJars
-}
-
func (d *DeviceHostConverter) ImplementationAndResourcesJars() android.Paths {
return d.implementationAndResourceJars
}
@@ -174,14 +166,6 @@
return nil
}
-func (d *DeviceHostConverter) ExportedPlugins() (android.Paths, []string, bool) {
- return nil, nil, false
-}
-
-func (d *DeviceHostConverter) SrcJarArgs() ([]string, android.Paths) {
- return d.srcJarArgs, d.srcJarDeps
-}
-
func (d *DeviceHostConverter) JacocoReportClassesFile() android.Path {
return nil
}
diff --git a/java/java.go b/java/java.go
index e471f0d..9e35835 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2046,13 +2046,6 @@
return j.installFile
}
-func (j *Module) ResourceJars() android.Paths {
- if j.resourceJar == nil {
- return nil
- }
- return android.Paths{j.resourceJar}
-}
-
func (j *Module) ImplementationAndResourcesJars() android.Paths {
if j.implementationAndResourcesJar == nil {
return nil
@@ -2069,17 +2062,6 @@
return j.classLoaderContexts
}
-// ExportedPlugins returns the list of jars needed to run the exported plugins, the list of
-// classes for the plugins, and a boolean for whether turbine needs to be disabled due to plugins
-// that generate APIs.
-func (j *Module) ExportedPlugins() (android.Paths, []string, bool) {
- return j.exportedPluginJars, j.exportedPluginClasses, j.exportedDisableTurbine
-}
-
-func (j *Module) SrcJarArgs() ([]string, android.Paths) {
- return j.srcJarArgs, j.srcJarDeps
-}
-
var _ logtagsProducer = (*Module)(nil)
func (j *Module) logtags() android.Paths {
@@ -2515,6 +2497,11 @@
}
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if j.testProperties.Test_options.Unit_test == nil && ctx.Host() {
+ // TODO(b/): Clean temporary heuristic to avoid unexpected onboarding.
+ defaultUnitTest := !inList("tradefed", j.properties.Static_libs) && !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites) && !inList("robolectric-host-android_all", j.properties.Static_libs) && !inList("robolectric-host-android_all", j.properties.Libs)
+ j.testProperties.Test_options.Unit_test = proptools.BoolPtr(defaultUnitTest)
+ }
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template,
j.testProperties.Test_suites, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test)
@@ -2675,6 +2662,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
InitJavaModuleMultiTargets(module, android.HostSupported)
+
return module
}
@@ -3046,17 +3034,6 @@
return android.Paths{j.combinedClasspathFile}
}
-func (j *Import) ImplementationJars() android.Paths {
- if j.combinedClasspathFile == nil {
- return nil
- }
- return android.Paths{j.combinedClasspathFile}
-}
-
-func (j *Import) ResourceJars() android.Paths {
- return nil
-}
-
func (j *Import) ImplementationAndResourcesJars() android.Paths {
if j.combinedClasspathFile == nil {
return nil
@@ -3072,22 +3049,10 @@
return nil
}
-func (j *Import) AidlIncludeDirs() android.Paths {
- return j.exportAidlIncludeDirs
-}
-
func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
return j.classLoaderContexts
}
-func (j *Import) ExportedPlugins() (android.Paths, []string, bool) {
- return nil, nil, false
-}
-
-func (j *Import) SrcJarArgs() ([]string, android.Paths) {
- return nil, nil
-}
-
var _ android.ApexModule = (*Import)(nil)
// Implements android.ApexModule
diff --git a/java/java_test.go b/java/java_test.go
index bb51ebc..9112655 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -25,6 +25,7 @@
"strings"
"testing"
+ "android/soong/genrule"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -79,6 +80,8 @@
android.RegisterPrebuiltMutators(ctx)
+ genrule.RegisterGenruleBuildComponents(ctx)
+
// Register module types and mutators from cc needed for JNI testing
cc.RegisterRequiredBuildComponentsForTest(ctx)
diff --git a/java/lint.go b/java/lint.go
index 8272595..50b84dc 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -313,6 +313,7 @@
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String())
+ rule.Command().Text("rm -f").Output(html).Output(text).Output(xml)
var annotationsZipPath, apiVersionsXMLPath android.Path
if ctx.Config().AlwaysUsePrebuiltSdks() {
@@ -329,8 +330,7 @@
FlagWithArg("ANDROID_SDK_HOME=", homeDir.String()).
FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath).
FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath).
- Tool(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/bin/lint")).
- Implicit(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/lib/lint-classpath.jar")).
+ BuiltTool("lint").
Flag("--quiet").
FlagWithInput("--project ", projectXML).
FlagWithInput("--config ", lintXML).
@@ -362,7 +362,7 @@
}
}
- cmd.Text("|| (").Text("cat").Input(text).Text("; exit 7)").Text(")")
+ cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)").Text(")")
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
@@ -438,13 +438,13 @@
}
ctx.Build(pctx, android.BuildParams{
- Rule: android.Cp,
+ Rule: android.CpIfChanged,
Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".annotations.zip"),
Output: copiedAnnotationsZipPath(ctx),
})
ctx.Build(pctx, android.BuildParams{
- Rule: android.Cp,
+ Rule: android.CpIfChanged,
Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".api_versions.xml"),
Output: copiedAPIVersionsXmlPath(ctx),
})
diff --git a/rust/testing.go b/rust/testing.go
index 1afe27e..9534ab5 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/genrule"
)
func GatherRequiredDepsForTest() string {
@@ -211,6 +212,7 @@
ctx := android.NewTestArchContext(config)
android.RegisterPrebuiltMutators(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
+ genrule.RegisterGenruleBuildComponents(ctx)
cc.RegisterRequiredBuildComponentsForTest(ctx)
RegisterRequiredBuildComponentsForTest(ctx)
diff --git a/sdk/testing.go b/sdk/testing.go
index 0bbf7f4..7a2540a 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -26,6 +26,7 @@
"android/soong/android"
"android/soong/apex"
"android/soong/cc"
+ "android/soong/genrule"
"android/soong/java"
)
@@ -109,6 +110,9 @@
// from java package
java.RegisterRequiredBuildComponentsForTest(ctx)
+ // from genrule package
+ genrule.RegisterGenruleBuildComponents(ctx)
+
// from cc package
cc.RegisterRequiredBuildComponentsForTest(ctx)
diff --git a/shared/debug.go b/shared/debug.go
index 0c9ba4f..5392f2b 100644
--- a/shared/debug.go
+++ b/shared/debug.go
@@ -1,8 +1,15 @@
package shared
import (
+ "fmt"
"os"
"os/exec"
+ "strings"
+ "syscall"
+)
+
+var (
+ isDebugging bool
)
// Finds the Delve binary to use. Either uses the SOONG_DELVE_PATH environment
@@ -15,3 +22,48 @@
return result
}
+
+// Returns whether the current process is running under Delve due to
+// ReexecWithDelveMaybe().
+func IsDebugging() bool {
+ return isDebugging
+}
+
+// Re-executes the binary in question under the control of Delve when
+// delveListen is not the empty string. delvePath gives the path to the Delve.
+func ReexecWithDelveMaybe(delveListen, delvePath string) {
+ isDebugging = os.Getenv("SOONG_DELVE_REEXECUTED") == "true"
+ if isDebugging || delveListen == "" {
+ return
+ }
+
+ if delvePath == "" {
+ fmt.Fprintln(os.Stderr, "Delve debugging requested but failed to find dlv")
+ os.Exit(1)
+ }
+
+ soongDelveEnv := []string{}
+ for _, env := range os.Environ() {
+ idx := strings.IndexRune(env, '=')
+ if idx != -1 {
+ soongDelveEnv = append(soongDelveEnv, env)
+ }
+ }
+
+ soongDelveEnv = append(soongDelveEnv, "SOONG_DELVE_REEXECUTED=true")
+
+ dlvArgv := []string{
+ delvePath,
+ "--listen=:" + delveListen,
+ "--headless=true",
+ "--api-version=2",
+ "exec",
+ os.Args[0],
+ "--",
+ }
+
+ dlvArgv = append(dlvArgv, os.Args[1:]...)
+ syscall.Exec(delvePath, dlvArgv, soongDelveEnv)
+ fmt.Fprintln(os.Stderr, "exec() failed while trying to reexec with Delve")
+ os.Exit(1)
+}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index fc43663..c2fa427 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -105,13 +105,11 @@
soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, "."))
soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())
- if os.Getenv("SOONG_DELVE") != "" {
- // SOONG_DELVE is already in cmd.Environment
- soongBuildEnv.Set("SOONG_DELVE_PATH", shared.ResolveDelveBinary())
+ err := writeEnvironmentFile(ctx, envFile, soongBuildEnv.AsMap())
+ if err != nil {
+ ctx.Fatalf("failed to write environment file %s: %s", envFile, err)
}
- writeEnvironmentFile(ctx, envFile, soongBuildEnv.AsMap())
-
func() {
ctx.BeginTrace(metrics.RunSoong, "environment check")
defer ctx.EndTrace()
@@ -173,6 +171,11 @@
"-f", filepath.Join(config.SoongOutDir(), file))
cmd.Environment.Set("SOONG_OUTDIR", config.SoongOutDir())
+ if os.Getenv("SOONG_DELVE") != "" {
+ // SOONG_DELVE is already in cmd.Environment
+ cmd.Environment.Set("SOONG_DELVE_PATH", shared.ResolveDelveBinary())
+ }
+
cmd.Sandbox = soongSandbox
cmd.RunAndStreamOrFatal()
}
diff --git a/vnames.go.json b/vnames.go.json
index 7ce2d4b..f8c6b7f 100644
--- a/vnames.go.json
+++ b/vnames.go.json
@@ -2,7 +2,6 @@
{
"pattern": "(.*)",
"vname": {
- "corpus": "android.googlesource.com/platform/superproject",
"path": "@1@"
}
}
diff --git a/vnames.json b/vnames.json
index f9d3adc..096260f 100644
--- a/vnames.json
+++ b/vnames.json
@@ -2,7 +2,6 @@
{
"pattern": "out/(.*)",
"vname": {
- "corpus": "android.googlesource.com/platform/superproject",
"root": "out",
"path": "@1@"
}
@@ -10,9 +9,7 @@
{
"pattern": "(.*)",
"vname": {
- "corpus": "android.googlesource.com/platform/superproject",
"path": "@1@"
}
}
]
-