Merge "soong-ui: Redirect mmm to mmma."
diff --git a/Android.bp b/Android.bp
index 4893de6..62b0fd4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -178,6 +178,7 @@
"cc/linker.go",
"cc/binary.go",
+ "cc/fuzz.go",
"cc/library.go",
"cc/object.go",
"cc/test.go",
diff --git a/apex/apex.go b/apex/apex.go
index 9701e2a..284af5c 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1430,6 +1430,13 @@
// Optional name for the installed apex. If unspecified, name of the
// module is used as the file name
Filename *string
+
+ // Names of modules to be overridden. Listed modules can only be other binaries
+ // (in Make or Soong).
+ // This does not completely prevent installation of the overridden binaries, but if both
+ // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
+ // from PRODUCT_PACKAGES.
+ Overrides []string
}
func (p *Prebuilt) installable() bool {
@@ -1525,17 +1532,16 @@
return p.prebuilt.Name(p.ModuleBase.Name())
}
-func (p *Prebuilt) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(p.inputApex),
Include: "$(BUILD_PREBUILT)",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", p.installFilename)
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !p.installable())
- },
+ AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ entries.SetString("LOCAL_MODULE_PATH", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
+ entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
+ entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...)
},
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 94cf19d..5fc0738 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -17,6 +17,7 @@
import (
"io/ioutil"
"os"
+ "reflect"
"strings"
"testing"
@@ -45,13 +46,13 @@
t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
}
-func testApex(t *testing.T, bp string) *android.TestContext {
+func testApex(t *testing.T, bp string) (*android.TestContext, android.Config) {
ctx, config := testApexContext(t, bp)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
android.FailIfErrored(t, errs)
- return ctx
+ return ctx, config
}
func testApexContext(t *testing.T, bp string) (*android.TestContext, android.Config) {
@@ -264,7 +265,7 @@
// Minimal test
func TestBasicApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_defaults {
name: "myapex-defaults",
manifest: ":myapex.manifest",
@@ -388,7 +389,7 @@
}
func TestBasicZipApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -436,7 +437,7 @@
}
func TestApexWithStubs(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -520,7 +521,7 @@
}
func TestApexWithExplicitStubsDependency(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -587,7 +588,7 @@
}
func TestApexWithSystemLibsStubs(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -708,7 +709,7 @@
}
func TestFilesInSubDir(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -768,7 +769,7 @@
}
func TestUseVendor(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -842,7 +843,7 @@
}
func TestStaticLinking(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -882,7 +883,7 @@
}
func TestKeys(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -936,7 +937,7 @@
}
func TestMacro(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -980,7 +981,7 @@
}
func TestHeaderLibsDependency(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1028,7 +1029,7 @@
}
func TestNonTestApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1079,7 +1080,7 @@
if android.InAnyApex("mylib_common_test") {
t.Fatal("mylib_common_test must not be used in any other tests since this checks that global state is not updated in an illegal way!")
}
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -1127,7 +1128,7 @@
}
func TestApexWithTarget(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1207,7 +1208,7 @@
}
func TestApexWithShBinary(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1235,7 +1236,7 @@
}
func TestApexInProductPartition(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1267,7 +1268,7 @@
}
func TestApexKeyFromOtherModule(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_key {
name: "myapex.key",
public_key: ":my.avbpubkey",
@@ -1300,7 +1301,7 @@
}
func TestPrebuilt(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
prebuilt_apex {
name: "myapex",
arch: {
@@ -1323,7 +1324,7 @@
}
func TestPrebuiltFilenameOverride(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
prebuilt_apex {
name: "myapex",
src: "myapex-arm.apex",
@@ -1339,8 +1340,28 @@
}
}
+func TestPrebuiltOverrides(t *testing.T) {
+ ctx, config := testApex(t, `
+ prebuilt_apex {
+ name: "myapex.prebuilt",
+ src: "myapex-arm.apex",
+ overrides: [
+ "myapex",
+ ],
+ }
+ `)
+
+ p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt)
+
+ expected := []string{"myapex"}
+ actual := android.AndroidMkEntriesForTest(t, config, "", p).EntryMap["LOCAL_OVERRIDES_PACKAGES"]
+ if !reflect.DeepEqual(actual, expected) {
+ t.Errorf("Incorrect LOCAL_OVERRIDES_PACKAGES value '%s', expected '%s'", actual, expected)
+ }
+}
+
func TestApexWithTests(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -1374,7 +1395,7 @@
}
func TestApexUsesOtherApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
diff --git a/cc/cc_test.go b/cc/cc_test.go
index ca34185..a1b753c 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2264,6 +2264,19 @@
}
}
+// Simple smoke test for the cc_fuzz target that ensures the rule compiles
+// correctly.
+func TestFuzzTarget(t *testing.T) {
+ ctx := testCc(t, `
+ cc_fuzz {
+ name: "fuzz_smoke_test",
+ srcs: ["foo.c"],
+ }`)
+
+ variant := "android_arm64_armv8-a_core"
+ ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
+}
+
func assertString(t *testing.T, got, expected string) {
t.Helper()
if got != expected {
diff --git a/cc/compiler.go b/cc/compiler.go
index fd6184b..0f9599e 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -485,7 +485,7 @@
"-I"+android.PathForModuleGen(ctx, "aidl").String())
}
- if compiler.hasSrcExt(".rs") || compiler.hasSrcExt(".fs") {
+ if compiler.hasSrcExt(".rscript") || compiler.hasSrcExt(".fs") {
flags = rsFlags(ctx, flags, &compiler.Properties)
}
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index d5e9d01..db9092d 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -181,6 +181,9 @@
if arch == "" {
return ""
}
+ if !t.Bionic() {
+ return "libclang_rt." + library + "-" + arch
+ }
return "libclang_rt." + library + "-" + arch + "-android"
}
@@ -224,6 +227,10 @@
return LibclangRuntimeLibrary(t, "scudo_minimal")
}
+func LibFuzzerRuntimeLibrary(t Toolchain) string {
+ return LibclangRuntimeLibrary(t, "fuzzer")
+}
+
func ToolPath(t Toolchain) string {
if p := t.ToolPath(); p != "" {
return p
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index f072f34..f08a379 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -233,6 +233,14 @@
return "${config.LinuxX8664YasmFlags}"
}
+func (toolchainLinuxX86) LibclangRuntimeLibraryArch() string {
+ return "i686"
+}
+
+func (toolchainLinuxX8664) LibclangRuntimeLibraryArch() string {
+ return "x86_64"
+}
+
func (t *toolchainLinux) AvailableLibraries() []string {
return linuxAvailableLibraries
}
diff --git a/cc/fuzz.go b/cc/fuzz.go
new file mode 100644
index 0000000..d13e04a
--- /dev/null
+++ b/cc/fuzz.go
@@ -0,0 +1,106 @@
+// Copyright 2016 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 cc
+
+import (
+ "android/soong/android"
+ "android/soong/cc/config"
+)
+
+func init() {
+ android.RegisterModuleType("cc_fuzz", FuzzFactory)
+}
+
+// cc_fuzz creates a host/device fuzzer binary. Host binaries can be found at
+// $ANDROID_HOST_OUT/fuzz/, and device binaries can be found at /data/fuzz on
+// your device, or $ANDROID_PRODUCT_OUT/data/fuzz in your build tree.
+func FuzzFactory() android.Module {
+ module := NewFuzz(android.HostAndDeviceSupported)
+ return module.Init()
+}
+
+func NewFuzzInstaller() *baseInstaller {
+ return NewBaseInstaller("fuzz", "fuzz", InstallInData)
+}
+
+type fuzzBinary struct {
+ *binaryDecorator
+ *baseCompiler
+}
+
+func (fuzz *fuzzBinary) linkerProps() []interface{} {
+ props := fuzz.binaryDecorator.linkerProps()
+ return props
+}
+
+func (fuzz *fuzzBinary) linkerInit(ctx BaseModuleContext) {
+ // Add ../lib[64] to rpath so that out/host/linux-x86/fuzz/<fuzzer> can
+ // find out/host/linux-x86/lib[64]/library.so
+ runpaths := []string{"../lib"}
+ for _, runpath := range runpaths {
+ if ctx.toolchain().Is64Bit() {
+ runpath += "64"
+ }
+ fuzz.binaryDecorator.baseLinker.dynamicProperties.RunPaths = append(
+ fuzz.binaryDecorator.baseLinker.dynamicProperties.RunPaths, runpath)
+ }
+
+ // add "" to rpath so that fuzzer binaries can find libraries in their own fuzz directory
+ fuzz.binaryDecorator.baseLinker.dynamicProperties.RunPaths = append(
+ fuzz.binaryDecorator.baseLinker.dynamicProperties.RunPaths, "")
+
+ fuzz.binaryDecorator.linkerInit(ctx)
+}
+
+func (fuzz *fuzzBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
+ deps.StaticLibs = append(deps.StaticLibs,
+ config.LibFuzzerRuntimeLibrary(ctx.toolchain()))
+ deps = fuzz.binaryDecorator.linkerDeps(ctx, deps)
+ return deps
+}
+
+func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = fuzz.binaryDecorator.linkerFlags(ctx, flags)
+ return flags
+}
+
+func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
+ fuzz.binaryDecorator.baseInstaller.dir = "fuzz"
+ fuzz.binaryDecorator.baseInstaller.dir64 = "fuzz"
+ fuzz.binaryDecorator.baseInstaller.install(ctx, file)
+}
+
+func NewFuzz(hod android.HostOrDeviceSupported) *Module {
+ module, binary := NewBinary(hod)
+
+ // TODO(mitchp): The toolchain does not currently export the x86 (32-bit)
+ // variant of libFuzzer for host. There is no way to only disable the host
+ // 32-bit variant, so we specify cc_fuzz targets as 64-bit only. This doesn't
+ // hurt anyone, as cc_fuzz is mostly for experimental targets as of this
+ // moment.
+ module.multilib = "64"
+
+ binary.baseInstaller = NewFuzzInstaller()
+ module.sanitize.SetSanitizer(fuzzer, true)
+
+ fuzz := &fuzzBinary{
+ binaryDecorator: binary,
+ baseCompiler: NewBaseCompiler(),
+ }
+ module.compiler = fuzz
+ module.linker = fuzz
+ module.installer = fuzz
+ return module
+}
diff --git a/cc/gen.go b/cc/gen.go
index e5c4194..f8007e6 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -238,7 +238,7 @@
depFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp.d")
srcFiles[i] = cppFile
deps = append(deps, genAidl(ctx, aidlRule, srcFile, cppFile, depFile, buildFlags.aidlFlags)...)
- case ".rs", ".fs":
+ case ".rscript", ".fs":
cppFile := rsGeneratedCppFile(ctx, srcFile)
rsFiles = append(rsFiles, srcFiles[i])
srcFiles[i] = cppFile
diff --git a/cc/rs.go b/cc/rs.go
index fbc6bfb..5951edb 100644
--- a/cc/rs.go
+++ b/cc/rs.go
@@ -51,7 +51,7 @@
"depFiles", "outDir", "rsFlags", "stampFile")
)
-// Takes a path to a .rs or .fs file, and returns a path to a generated ScriptC_*.cpp file
+// Takes a path to a .rscript or .fs file, and returns a path to a generated ScriptC_*.cpp file
// This has to match the logic in llvm-rs-cc in DetermineOutputFile.
func rsGeneratedCppFile(ctx android.ModuleContext, rsFile android.Path) android.WritablePath {
fileName := strings.TrimSuffix(rsFile.Base(), rsFile.Ext())
diff --git a/cc/test.go b/cc/test.go
index c735fd9..0a00aa1 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -210,6 +210,11 @@
deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_c++", "libgtest_ndk_c++")
} else if BoolDefault(test.Properties.Isolated, false) {
deps.StaticLibs = append(deps.StaticLibs, "libgtest_isolated_main")
+ // The isolated library requires liblog, but adding it
+ // as a static library means unit tests cannot override
+ // liblog functions. Instead make it a shared library
+ // dependency.
+ deps.SharedLibs = append(deps.SharedLibs, "liblog")
} else {
deps.StaticLibs = append(deps.StaticLibs, "libgtest_main", "libgtest")
}
diff --git a/cc/testing.go b/cc/testing.go
index df7cb78..bf806bc 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -63,6 +63,41 @@
}
toolchain_library {
+ name: "libclang_rt.fuzzer-arm-android",
+ vendor_available: true,
+ recovery_available: true,
+ src: "",
+ }
+
+ toolchain_library {
+ name: "libclang_rt.fuzzer-aarch64-android",
+ vendor_available: true,
+ recovery_available: true,
+ src: "",
+ }
+
+ toolchain_library {
+ name: "libclang_rt.fuzzer-i686-android",
+ vendor_available: true,
+ recovery_available: true,
+ src: "",
+ }
+
+ toolchain_library {
+ name: "libclang_rt.fuzzer-x86_64-android",
+ vendor_available: true,
+ recovery_available: true,
+ src: "",
+ }
+
+ toolchain_library {
+ name: "libclang_rt.fuzzer-x86_64",
+ vendor_available: true,
+ recovery_available: true,
+ src: "",
+ }
+
+ toolchain_library {
name: "libgcc",
vendor_available: true,
recovery_available: true,
@@ -196,6 +231,7 @@
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory))
+ ctx.RegisterModuleType("cc_fuzz", android.ModuleFactoryAdaptor(FuzzFactory))
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory))
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 9ae86b1..0eaed76 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -342,10 +342,13 @@
action: build.BUILD_MODULES,
buildDependencies: true,
}, {
+ // buildDependencies is set to true as mm is being deprecated. This is redirecting to mma build
+ // command behaviour. Once it has soaked for a while, the build command is deleted from here once
+ // it has been removed from the envsetup.sh.
name: "modules-in-a-dir-no-deps",
description: "Build action: builds all of the modules in the current directory without their dependencies.",
action: build.BUILD_MODULES_IN_A_DIRECTORY,
- buildDependencies: false,
+ buildDependencies: true,
}, {
// buildDependencies is set to true as mmm is being deprecated. This is redirecting to mmma build
// command behaviour. Once it has soaked for a while, the build command is deleted from here once
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index 107837d..fbf2baa 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -15,18 +15,20 @@
package java
import (
- "android/soong/android"
"bytes"
"io"
"io/ioutil"
"strings"
"testing"
+
+ "android/soong/android"
)
type testAndroidMk struct {
*testing.T
body []byte
}
+
type testAndroidMkModule struct {
*testing.T
props map[string]string
@@ -115,30 +117,26 @@
}
func TestRequired(t *testing.T) {
- config := testConfig(nil)
- ctx := testContext(config, `
+ ctx, config := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
required: ["libfoo"],
}
- `, nil)
- run(t, ctx, config)
+ `)
mk := getAndroidMk(t, ctx, config, "foo")
mk.moduleFor("foo").hasRequired("libfoo")
}
func TestHostdex(t *testing.T) {
- config := testConfig(nil)
- ctx := testContext(config, `
+ ctx, config := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
hostdex: true,
}
- `, nil)
- run(t, ctx, config)
+ `)
mk := getAndroidMk(t, ctx, config, "foo")
mk.moduleFor("foo")
@@ -146,16 +144,14 @@
}
func TestHostdexRequired(t *testing.T) {
- config := testConfig(nil)
- ctx := testContext(config, `
+ ctx, config := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
hostdex: true,
required: ["libfoo"],
}
- `, nil)
- run(t, ctx, config)
+ `)
mk := getAndroidMk(t, ctx, config, "foo")
mk.moduleFor("foo").hasRequired("libfoo")
@@ -163,8 +159,7 @@
}
func TestHostdexSpecificRequired(t *testing.T) {
- config := testConfig(nil)
- ctx := testContext(config, `
+ ctx, config := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -175,8 +170,7 @@
},
},
}
- `, nil)
- run(t, ctx, config)
+ `)
mk := getAndroidMk(t, ctx, config, "foo")
mk.moduleFor("foo").hasNoRequired("libfoo")
diff --git a/java/app_test.go b/java/app_test.go
index f08969d..32de019 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -43,7 +43,7 @@
}
)
-func testAppContext(config android.Config, bp string, fs map[string][]byte) *android.TestContext {
+func testAppContext(bp string, fs map[string][]byte) *android.TestContext {
appFS := map[string][]byte{}
for k, v := range fs {
appFS[k] = v
@@ -53,13 +53,13 @@
appFS[file] = nil
}
- return testContext(config, bp, appFS)
+ return testContext(bp, appFS)
}
func testApp(t *testing.T, bp string) *android.TestContext {
config := testConfig(nil)
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
@@ -176,7 +176,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
config := testConfig(nil)
- ctx := testContext(config, fmt.Sprintf(bp, testCase.prop), fs)
+ ctx := testContext(fmt.Sprintf(bp, testCase.prop), fs)
run(t, ctx, config)
module := ctx.ModuleForTests("foo", "android_common")
@@ -388,7 +388,7 @@
config.TestProductVariables.EnforceRROExcludedOverlays = testCase.enforceRROExcludedOverlays
}
- ctx := testAppContext(config, bp, fs)
+ ctx := testAppContext(bp, fs)
run(t, ctx, config)
resourceListToFiles := func(module android.TestingModule, list []string) (files []string) {
@@ -515,7 +515,7 @@
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
@@ -547,7 +547,7 @@
}
func TestJNIABI(t *testing.T) {
- ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
system_shared_libs: [],
@@ -620,7 +620,7 @@
}
func TestJNIPackaging(t *testing.T) {
- ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
system_shared_libs: [],
@@ -774,7 +774,7 @@
if test.certificateOverride != "" {
config.TestProductVariables.CertificateOverrides = []string{test.certificateOverride}
}
- ctx := testAppContext(config, test.bp, nil)
+ ctx := testAppContext(test.bp, nil)
run(t, ctx, config)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -832,7 +832,7 @@
if test.packageNameOverride != "" {
config.TestProductVariables.PackageNameOverrides = []string{test.packageNameOverride}
}
- ctx := testAppContext(config, test.bp, nil)
+ ctx := testAppContext(test.bp, nil)
run(t, ctx, config)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -865,7 +865,7 @@
`
config := testConfig(nil)
config.TestProductVariables.ManifestPackageNameOverrides = []string{"foo:org.dandroid.bp"}
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
@@ -879,7 +879,7 @@
}
func TestOverrideAndroidApp(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
@@ -980,7 +980,7 @@
}
func TestOverrideAndroidAppDependency(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
@@ -1021,7 +1021,7 @@
}
func TestAndroidAppImport(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
android_app_import {
name: "foo",
apk: "prebuilts/apk/app.apk",
@@ -1050,7 +1050,7 @@
}
func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
android_app_import {
name: "foo",
apk: "prebuilts/apk/app.apk",
@@ -1071,7 +1071,7 @@
}
func TestAndroidAppImport_Presigned(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
android_app_import {
name: "foo",
apk: "prebuilts/apk/app.apk",
@@ -1166,7 +1166,7 @@
config := testConfig(nil)
config.TestProductVariables.AAPTPreferredConfig = test.aaptPreferredConfig
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
@@ -1183,7 +1183,7 @@
}
func TestStl(t *testing.T) {
- ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
}
@@ -1286,7 +1286,7 @@
config := testConfig(nil)
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
@@ -1398,7 +1398,7 @@
}
func TestEmbedNotice(t *testing.T) {
- ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
android_app {
name: "foo",
srcs: ["a.java"],
@@ -1549,7 +1549,7 @@
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
}
- ctx := testAppContext(config, bp, nil)
+ ctx := testAppContext(bp, nil)
run(t, ctx, config)
diff --git a/java/device_host_converter_test.go b/java/device_host_converter_test.go
index 9b9d0d8..44aae9b 100644
--- a/java/device_host_converter_test.go
+++ b/java/device_host_converter_test.go
@@ -50,9 +50,7 @@
}
`
- config := testConfig(nil)
- ctx := testContext(config, bp, nil)
- run(t, ctx, config)
+ ctx, config := testJava(t, bp)
deviceModule := ctx.ModuleForTests("device_module", "android_common")
deviceTurbineCombined := deviceModule.Output("turbine-combined/device_module.jar")
@@ -133,9 +131,7 @@
}
`
- config := testConfig(nil)
- ctx := testContext(config, bp, nil)
- run(t, ctx, config)
+ ctx, config := testJava(t, bp)
hostModule := ctx.ModuleForTests("host_module", config.BuildOsCommonVariant)
hostJavac := hostModule.Output("javac/host_module.jar")
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index f91ff69..4c38399 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -51,7 +51,7 @@
dexpreoptConfig.RuntimeApexJars = []string{"foo", "bar", "baz"}
setDexpreoptTestGlobalConfig(config, dexpreoptConfig)
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
ctx.RegisterSingletonType("dex_bootjars", android.SingletonFactoryAdaptor(dexpreoptBootJarsFactory))
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go
index 7d0109f..22b7bb9 100644
--- a/java/dexpreopt_test.go
+++ b/java/dexpreopt_test.go
@@ -142,7 +142,7 @@
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
- ctx := testJava(t, test.bp)
+ ctx, _ := testJava(t, test.bp)
dexpreopt := ctx.ModuleForTests("foo", "android_common").MaybeDescription("dexpreopt")
enabled := dexpreopt.Rule != nil
diff --git a/java/java_test.go b/java/java_test.go
index 677174d..5942afe 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -57,8 +57,7 @@
return TestConfig(buildDir, env)
}
-func testContext(config android.Config, bp string,
- fs map[string][]byte) *android.TestContext {
+func testContext(bp string, fs map[string][]byte) *android.TestContext {
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
@@ -222,13 +221,13 @@
android.FailIfErrored(t, errs)
}
-func testJava(t *testing.T, bp string) *android.TestContext {
+func testJava(t *testing.T, bp string) (*android.TestContext, android.Config) {
t.Helper()
config := testConfig(nil)
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
run(t, ctx, config)
- return ctx
+ return ctx, config
}
func moduleToPath(name string) string {
@@ -243,7 +242,7 @@
}
func TestSimple(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -287,7 +286,7 @@
}
func TestSdkVersion(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -313,7 +312,7 @@
}
func TestArchSpecific(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -332,7 +331,7 @@
}
func TestBinary(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library_host {
name: "foo",
srcs: ["a.java"],
@@ -361,7 +360,7 @@
}
func TestPrebuilts(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -412,7 +411,7 @@
}
func TestDefaults(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_defaults {
name: "defaults",
srcs: ["a.java"],
@@ -558,7 +557,7 @@
for _, test := range table {
t.Run(test.name, func(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: [
@@ -587,7 +586,7 @@
}
func TestIncludeSrcs(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: [
@@ -650,7 +649,7 @@
}
func TestGeneratedSources(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: [
@@ -683,7 +682,7 @@
}
func TestTurbine(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -732,7 +731,7 @@
}
func TestSharding(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "bar",
srcs: ["a.java","b.java","c.java"],
@@ -750,7 +749,7 @@
}
func TestDroiddoc(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
droiddoc_template {
name: "droiddoc-templates-sdk",
path: ".",
@@ -793,7 +792,7 @@
}
func TestJarGenrules(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -847,7 +846,7 @@
}
func TestExcludeFileGroupInSrcs(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java", ":foo-srcs"],
@@ -874,7 +873,7 @@
func TestJavaLibrary(t *testing.T) {
config := testConfig(nil)
- ctx := testContext(config, "", map[string][]byte{
+ ctx := testContext("", map[string][]byte{
"libcore/Android.bp": []byte(`
java_library {
name: "core",
@@ -886,7 +885,7 @@
}
func TestJavaSdkLibrary(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
droiddoc_template {
name: "droiddoc-templates-sdk",
path: ".",
@@ -1057,7 +1056,7 @@
t.Run("Java language level 8", func(t *testing.T) {
// Test default javac -source 1.8 -target 1.8
- ctx := testJava(t, bp)
+ ctx, _ := testJava(t, bp)
checkPatchModuleFlag(t, ctx, "foo", "")
checkPatchModuleFlag(t, ctx, "bar", "")
@@ -1067,7 +1066,7 @@
t.Run("Java language level 9", func(t *testing.T) {
// Test again with javac -source 9 -target 9
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "true"})
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
run(t, ctx, config)
checkPatchModuleFlag(t, ctx, "foo", "")
diff --git a/java/kotlin_test.go b/java/kotlin_test.go
index e0eb0c0..5c6d45f 100644
--- a/java/kotlin_test.go
+++ b/java/kotlin_test.go
@@ -22,7 +22,7 @@
)
func TestKotlin(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java", "b.kt"],
@@ -84,7 +84,7 @@
}
func TestKapt(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java", "b.kt"],
diff --git a/java/plugin_test.go b/java/plugin_test.go
index d1aef2c..c7913d3 100644
--- a/java/plugin_test.go
+++ b/java/plugin_test.go
@@ -20,7 +20,7 @@
)
func TestNoPlugin(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -44,7 +44,7 @@
}
func TestPlugin(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -83,7 +83,7 @@
}
func TestPluginGeneratesApi(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
diff --git a/java/sdk_test.go b/java/sdk_test.go
index f82a4fb..6be17eb 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -282,7 +282,7 @@
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
run(t, ctx, config)
checkClasspath(t, ctx)
@@ -309,7 +309,7 @@
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
run(t, ctx, config)
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
@@ -335,7 +335,7 @@
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
- ctx := testContext(config, bp, nil)
+ ctx := testContext(bp, nil)
run(t, ctx, config)
checkClasspath(t, ctx)