Merge "Add header_libs to cc_object"
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..c619b5a 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2264,6 +2264,22 @@
}
}
+// 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 TestAidl(t *testing.T) {
+}
+
func assertString(t *testing.T, got, expected string) {
t.Helper()
if got != expected {
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..3b0c5c8
--- /dev/null
+++ b/cc/fuzz.go
@@ -0,0 +1,120 @@
+// 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
+
+ // The fuzzer runtime is not present for darwin host modules, disable cc_fuzz modules when targeting darwin.
+ android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+ disableDarwin := struct {
+ Target struct {
+ Darwin struct {
+ Enabled *bool
+ }
+ }
+ }{}
+ disableDarwin.Target.Darwin.Enabled = BoolPtr(false)
+ ctx.AppendProperties(&disableDarwin)
+ })
+
+ return module
+}
diff --git a/cc/gen.go b/cc/gen.go
index f8007e6..42b0cbe 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -120,6 +120,11 @@
headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h")
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
+ baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel())
+ if baseDir != "" {
+ aidlFlags += " -I" + baseDir
+ }
+
cmd := rule.Command()
cmd.BuiltTool(ctx, "aidl-cpp").
FlagWithDepFile("-d", depFile).
diff --git a/cc/gen_test.go b/cc/gen_test.go
index e4219d9..da3b4e8 100644
--- a/cc/gen_test.go
+++ b/cc/gen_test.go
@@ -16,6 +16,7 @@
import (
"path/filepath"
+ "strings"
"testing"
)
@@ -42,7 +43,8 @@
ctx := testCc(t, `
filegroup {
name: "fg",
- srcs: ["b.aidl"],
+ srcs: ["sub/c.aidl"],
+ path: "sub",
}
cc_library_shared {
@@ -59,6 +61,12 @@
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) {
t.Errorf("missing aidl includes in global flags")
}
+
+ aidlCommand := aidl.RuleParams.Command
+ if !strings.Contains(aidlCommand, "-Isub") {
+ t.Errorf("aidl command for c.aidl should contain \"-Isub\", but was %q", aidlCommand)
+ }
+
})
}
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..f0ad33b 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))
@@ -229,6 +265,7 @@
"bar.c": nil,
"a.proto": nil,
"b.aidl": nil,
+ "sub/c.aidl": nil,
"my_include": nil,
"foo.map.txt": nil,
"liba.so": nil,
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 4d59a39..0eaed76 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -342,15 +342,21 @@
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
+ // it has been removed from the envsetup.sh.
name: "modules-in-dirs-no-deps",
description: "Build action: builds all of the modules in the supplied directories without their dependencies.",
action: build.BUILD_MODULES_IN_DIRECTORIES,
- buildDependencies: false,
+ buildDependencies: true,
}, {
name: "modules-in-a-dir",
description: "Build action: builds all of the modules in the current directory and their dependencies.",
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/droiddoc.go b/java/droiddoc.go
index ae810e1..6de2ddf 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -655,6 +655,7 @@
deps.classpath = append(deps.classpath, dep.SdkImplementationJars(ctx, j.sdkVersion())...)
case Dependency:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
+ deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
case android.SourceFileProducer:
checkProducesJars(ctx, dep)
deps.classpath = append(deps.classpath, dep.Srcs()...)
diff --git a/java/gen.go b/java/gen.go
index b1c028d..69965ec 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -15,6 +15,8 @@
package java
import (
+ "strings"
+
"github.com/google/blueprint"
"android/soong/android"
@@ -63,6 +65,10 @@
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string, deps android.Paths) android.Path {
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
depFile := javaFile.String() + ".d"
+ baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel())
+ if baseDir != "" {
+ aidlFlags += " -I" + baseDir
+ }
ctx.Build(pctx, android.BuildParams{
Rule: aidl,
diff --git a/java/java_test.go b/java/java_test.go
index 677174d..4c85bed 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))
@@ -193,6 +192,7 @@
"bar-doc/a.java": nil,
"bar-doc/b.java": nil,
"bar-doc/IFoo.aidl": nil,
+ "bar-doc/IBar.aidl": nil,
"bar-doc/known_oj_tags.txt": nil,
"external/doclava/templates-sdk": nil,
@@ -222,13 +222,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 +243,7 @@
}
func TestSimple(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -287,7 +287,7 @@
}
func TestSdkVersion(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -313,7 +313,7 @@
}
func TestArchSpecific(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -332,7 +332,7 @@
}
func TestBinary(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library_host {
name: "foo",
srcs: ["a.java"],
@@ -361,7 +361,7 @@
}
func TestPrebuilts(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -412,7 +412,7 @@
}
func TestDefaults(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_defaults {
name: "defaults",
srcs: ["a.java"],
@@ -558,7 +558,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 +587,7 @@
}
func TestIncludeSrcs(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: [
@@ -650,7 +650,7 @@
}
func TestGeneratedSources(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: [
@@ -683,7 +683,7 @@
}
func TestTurbine(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -732,7 +732,7 @@
}
func TestSharding(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "bar",
srcs: ["a.java","b.java","c.java"],
@@ -750,16 +750,22 @@
}
func TestDroiddoc(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
droiddoc_template {
name: "droiddoc-templates-sdk",
path: ".",
}
+ filegroup {
+ name: "bar-doc-aidl-srcs",
+ srcs: ["bar-doc/IBar.aidl"],
+ path: "bar-doc",
+ }
droiddoc {
name: "bar-doc",
srcs: [
"bar-doc/*.java",
"bar-doc/IFoo.aidl",
+ ":bar-doc-aidl-srcs",
],
exclude_srcs: [
"bar-doc/b.java"
@@ -787,13 +793,19 @@
for _, i := range inputs {
javaSrcs = append(javaSrcs, i.Base())
}
- if len(javaSrcs) != 2 || javaSrcs[0] != "a.java" || javaSrcs[1] != "IFoo.java" {
- t.Errorf("inputs of bar-doc must be []string{\"a.java\", \"IFoo.java\", but was %#v.", javaSrcs)
+ if len(javaSrcs) != 3 || javaSrcs[0] != "a.java" || javaSrcs[1] != "IFoo.java" || javaSrcs[2] != "IBar.java" {
+ t.Errorf("inputs of bar-doc must be []string{\"a.java\", \"IFoo.java\", \"IBar.java\", but was %#v.", javaSrcs)
+ }
+
+ aidlRule := ctx.ModuleForTests("bar-doc", "android_common").Output(inputs[2].String())
+ aidlFlags := aidlRule.Args["aidlFlags"]
+ if !strings.Contains(aidlFlags, "-Ibar-doc") {
+ t.Errorf("aidl flags for IBar.aidl should contain \"-Ibar-doc\", but was %q", aidlFlags)
}
}
func TestJarGenrules(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -847,7 +859,7 @@
}
func TestExcludeFileGroupInSrcs(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
java_library {
name: "foo",
srcs: ["a.java", ":foo-srcs"],
@@ -874,7 +886,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 +898,7 @@
}
func TestJavaSdkLibrary(t *testing.T) {
- ctx := testJava(t, `
+ ctx, _ := testJava(t, `
droiddoc_template {
name: "droiddoc-templates-sdk",
path: ".",
@@ -1057,7 +1069,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 +1079,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)
diff --git a/scripts/strip.sh b/scripts/strip.sh
index bd62619..4a1ed3f 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -59,7 +59,7 @@
# ${CROSS_COMPILE}strip --strip-all does not strip .ARM.attributes,
# so we tell llvm-strip to keep it too.
if [ -z "${use_gnu_strip}" ]; then
- "${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp"
+ "${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp"
else
"${CROSS_COMPILE}strip" --strip-all "${infile}" -o "${outfile}.tmp"
fi
@@ -101,7 +101,7 @@
rm -f "${outfile}.dynsyms" "${outfile}.funcsyms" "${outfile}.keep_symbols" "${outfile}.debug" "${outfile}.mini_debuginfo" "${outfile}.mini_debuginfo.xz"
local fail=
if [ -z "${use_gnu_strip}" ]; then
- "${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes -remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
+ "${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes --remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
else
"${CROSS_COMPILE}strip" --strip-all -R .comment "${infile}" -o "${outfile}.tmp" || fail=true
fi