Merge "Support java_sdk_library as java_libs of apex"
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 0ee1201..2c99f1f 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -25,6 +25,11 @@
// This file implements common functionality for handling modules that may exist as prebuilts,
// source, or both.
+func RegisterPrebuiltMutators(ctx RegistrationContext) {
+ ctx.PreArchMutators(RegisterPrebuiltsPreArchMutators)
+ ctx.PostDepsMutators(RegisterPrebuiltsPostDepsMutators)
+}
+
type prebuiltDependencyTag struct {
blueprint.BaseDependencyTag
}
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index 600f078..8648b93 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -141,8 +141,7 @@
config := TestConfig(buildDir, nil, bp, fs)
ctx := NewTestContext()
- ctx.PreArchMutators(RegisterPrebuiltsPreArchMutators)
- ctx.PostDepsMutators(RegisterPrebuiltsPostDepsMutators)
+ RegisterPrebuiltMutators(ctx)
ctx.RegisterModuleType("filegroup", FileGroupFactory)
ctx.RegisterModuleType("prebuilt", newPrebuiltModule)
ctx.RegisterModuleType("source", newSourceModule)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index bb64f80..e8dc9aa 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -286,20 +286,13 @@
ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
ctx.RegisterModuleType("override_apex", overrideApexFactory)
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
- cc.RegisterPrebuiltBuildComponents(ctx)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
- ctx.RegisterModuleType("cc_defaults", func() android.Module {
- return cc.DefaultsFactory()
- })
ctx.RegisterModuleType("cc_test", cc.TestFactory)
- ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
@@ -309,23 +302,9 @@
ctx.RegisterModuleType("java_sdk_library", java.SdkLibraryFactory)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
- ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
- })
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
- ctx.BottomUp("version", cc.VersionMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
- })
ctx.PreDepsMutators(RegisterPreDepsMutators)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.PostDepsMutators(RegisterPostDepsMutators)
- ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel()
- ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel()
- })
ctx.Register(config)
diff --git a/cc/cc.go b/cc/cc.go
index 4c9d42b..14e7122 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -33,9 +33,15 @@
)
func init() {
- android.RegisterModuleType("cc_defaults", defaultsFactory)
+ RegisterCCBuildComponents(android.InitRegistrationContext)
- android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ pctx.Import("android/soong/cc/config")
+}
+
+func RegisterCCBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("cc_defaults", defaultsFactory)
+
+ ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
@@ -45,7 +51,7 @@
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
})
- android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
@@ -79,7 +85,6 @@
})
android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
- pctx.Import("android/soong/cc/config")
}
type Deps struct {
diff --git a/cc/cc_test.go b/cc/cc_test.go
index d73dac5..27ff38f 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2478,7 +2478,7 @@
srcs: ["foo.c"],
}`)
- variant := "android_arm64_armv8-a"
+ variant := "android_arm64_armv8-a_fuzzer"
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
}
diff --git a/cc/compdb.go b/cc/compdb.go
index 519380f..dff14db 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -27,7 +27,7 @@
// This singleton generates a compile_commands.json file. It does so for each
// blueprint Android.bp resulting in a cc.Module when either make, mm, mma, mmm
// or mmma is called. It will only create a single compile_commands.json file
-// at out/development/ide/compdb/compile_commands.json. It will also symlink it
+// at ${OUT_DIR}/soong/development/ide/compdb/compile_commands.json. It will also symlink it
// to ${SOONG_LINK_COMPDB_TO} if set. In general this should be created by running
// make SOONG_GEN_COMPDB=1 nothing to get all targets.
@@ -43,7 +43,7 @@
const (
compdbFilename = "compile_commands.json"
- compdbOutputProjectsDirectory = "out/development/ide/compdb"
+ compdbOutputProjectsDirectory = "development/ide/compdb"
// Environment variables used to modify behavior of this singleton.
envVariableGenerateCompdb = "SOONG_GEN_COMPDB"
@@ -78,12 +78,12 @@
})
// Create the output file.
- dir := filepath.Join(getCompdbAndroidSrcRootDirectory(ctx), compdbOutputProjectsDirectory)
- os.MkdirAll(dir, 0777)
- compDBFile := filepath.Join(dir, compdbFilename)
- f, err := os.Create(compdbFilename)
+ dir := android.PathForOutput(ctx, compdbOutputProjectsDirectory)
+ os.MkdirAll(dir.String(), 0777)
+ compDBFile := dir.Join(ctx, compdbFilename)
+ f, err := os.Create(compDBFile.String())
if err != nil {
- log.Fatalf("Could not create file %s: %s", filepath.Join(dir, compdbFilename), err)
+ log.Fatalf("Could not create file %s: %s", compDBFile, err)
}
defer f.Close()
@@ -106,7 +106,7 @@
finalLinkPath := filepath.Join(ctx.Config().Getenv(envVariableCompdbLink), compdbFilename)
if finalLinkPath != "" {
os.Remove(finalLinkPath)
- if err := os.Symlink(compDBFile, finalLinkPath); err != nil {
+ if err := os.Symlink(compDBFile.String(), finalLinkPath); err != nil {
log.Fatalf("Unable to symlink %s to %s: %s", compDBFile, finalLinkPath, err)
}
}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 658cef0..3d809fc 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -72,11 +72,6 @@
ctx := CreateTestContext()
- RegisterPrebuiltBuildComponents(ctx)
-
- ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
- ctx.PostDepsMutators(android.RegisterPrebuiltsPostDepsMutators)
-
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
diff --git a/cc/testing.go b/cc/testing.go
index 93f27cd..de4f1ec 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -18,6 +18,18 @@
"android/soong/android"
)
+func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
+ RegisterPrebuiltBuildComponents(ctx)
+ ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
+ ctx.RegisterModuleType("cc_library", LibraryFactory)
+ ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
+ ctx.RegisterModuleType("cc_object", ObjectFactory)
+
+ android.RegisterPrebuiltMutators(ctx)
+
+ RegisterCCBuildComponents(ctx)
+}
+
func GatherRequiredDepsForTest(os android.OsType) string {
ret := `
toolchain_library {
@@ -97,6 +109,14 @@
src: "",
}
+ // Needed for sanitizer
+ cc_prebuilt_library_shared {
+ name: "libclang_rt.ubsan_standalone-aarch64-android",
+ vendor_available: true,
+ recovery_available: true,
+ srcs: [""],
+ }
+
toolchain_library {
name: "libgcc",
vendor_available: true,
@@ -285,33 +305,20 @@
func CreateTestContext() *android.TestContext {
ctx := android.NewTestArchContext()
- ctx.RegisterModuleType("cc_defaults", defaultsFactory)
ctx.RegisterModuleType("cc_binary", BinaryFactory)
ctx.RegisterModuleType("cc_binary_host", binaryHostFactory)
ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
- ctx.RegisterModuleType("cc_library", LibraryFactory)
ctx.RegisterModuleType("cc_library_shared", LibrarySharedFactory)
ctx.RegisterModuleType("cc_library_static", LibraryStaticFactory)
ctx.RegisterModuleType("cc_library_headers", LibraryHeaderFactory)
ctx.RegisterModuleType("cc_test", TestFactory)
- ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
- ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
- ctx.RegisterModuleType("cc_object", ObjectFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("link", LinkageMutator).Parallel()
- ctx.BottomUp("vndk", VndkMutator).Parallel()
- ctx.BottomUp("version", VersionMutator).Parallel()
- ctx.BottomUp("begin", BeginMutator).Parallel()
- })
- ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
- })
+ RegisterRequiredBuildComponentsForTest(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index ee04dfd..fc1bae1 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -222,6 +222,14 @@
invocationPath := odexPath.ReplaceExtension(ctx, "invocation")
+ // TODO(skvadrik): fix this to use boot image location in the module config (currently it is broken
+ // in JIT-zygote builds, because "default" boot image is hard-coded in parts of the module config).
+ bootImage := module.DexPreoptImages[archIdx]
+ var bootImageLocation string
+ if bootImage != nil {
+ bootImageLocation = PathToLocation(bootImage, arch)
+ }
+
// The class loader context using paths in the build
var classLoaderContextHost android.Paths
@@ -349,7 +357,7 @@
Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", module.PreoptBootClassPathDexLocations, ":").
Flag("${class_loader_context_arg}").
Flag("${stored_class_loader_context_arg}").
- FlagWithArg("--boot-image=", strings.Join(module.DexPreoptImageLocations, ":")).Implicits(module.DexPreoptImagesDeps[archIdx].Paths()).
+ FlagWithArg("--boot-image=", bootImageLocation).Implicits(module.DexPreoptImagesDeps[archIdx].Paths()).
FlagWithInput("--dex-file=", module.DexPath).
FlagWithArg("--dex-location=", dexLocationArg).
FlagWithOutput("--oat-file=", odexPath).ImplicitOutput(vdexPath).
diff --git a/java/java_test.go b/java/java_test.go
index 1f25962..096cdb9 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -74,8 +74,6 @@
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
RegisterSdkLibraryBuildComponents(ctx)
- ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
- ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
RegisterPrebuiltApisBuildComponents(ctx)
@@ -85,15 +83,8 @@
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
// Register module types and mutators from cc needed for JNI testing
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
- ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory)
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
- })
return ctx
}
diff --git a/rust/testing.go b/rust/testing.go
index 1dd16cf..f9adec8 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -75,97 +75,19 @@
//////////////////////////////
// Device module requirements
- toolchain_library {
- name: "libgcc",
- no_libcrt: true,
- nocrt: true,
- src: "",
- system_shared_libs: [],
- }
- cc_library {
- name: "libc",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- }
- cc_library {
- name: "libm",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- }
- cc_library {
- name: "libdl",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- }
- cc_object {
- name: "crtbegin_dynamic",
- }
-
- cc_object {
- name: "crtend_android",
- }
cc_library {
name: "liblog",
no_libcrt: true,
nocrt: true,
system_shared_libs: [],
}
-
- //////////////////////////////
- // cc module requirements
-
- toolchain_library {
- name: "libatomic",
- src: "",
- }
- toolchain_library {
- name: "libclang_rt.builtins-aarch64-android",
- src: "",
- }
- toolchain_library {
- name: "libgcc_stripped",
- src: "",
- }
- cc_library {
- name: "libc++_static",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- }
- cc_library {
- name: "libc++demangle",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- host_supported: false,
- }
- cc_library {
- name: "libc++",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- }
- cc_library {
- name: "libunwind_llvm",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- }
- `
+` + cc.GatherRequiredDepsForTest(android.NoOsType)
return bp
}
func CreateTestContext() *android.TestContext {
ctx := android.NewTestArchContext()
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
ctx.RegisterModuleType("rust_test", RustTestFactory)
@@ -182,13 +104,7 @@
ctx.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- // cc mutators
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("version", cc.VersionMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
-
// rust mutators
ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
ctx.BottomUp("rust_unit_tests", TestPerSrcMutator).Parallel()
diff --git a/sdk/testing.go b/sdk/testing.go
index 61043f3..eec7f01 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -68,13 +68,6 @@
ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
- ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
- })
- ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel()
- ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel()
- })
ctx.RegisterModuleType("package", android.PackageFactory)
// from java package
@@ -83,20 +76,9 @@
java.RegisterStubsBuildComponents(ctx)
// from cc package
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
- cc.RegisterPrebuiltBuildComponents(ctx)
- ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
- ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
- ctx.BottomUp("version", cc.VersionMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
- })
// from apex package
ctx.RegisterModuleType("apex", apex.BundleFactory)
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index d24262d..0c0f222 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -60,25 +60,15 @@
java.RegisterAppBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
- ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
- ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("sysprop_deps", syspropDepsMutator).Parallel()
})
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
ctx.RegisterModuleType("cc_library_static", cc.LibraryFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
- ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
- ctx.BottomUp("version", cc.VersionMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
- ctx.BottomUp("sysprop_cc", cc.SyspropMutator).Parallel()
ctx.BottomUp("sysprop_java", java.SyspropMutator).Parallel()
})
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index 90ff706..711a9c7 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -94,7 +94,6 @@
"patch": Allowed,
"pstree": Allowed,
"python3": Allowed,
- "realpath": Allowed,
"rsync": Allowed,
"sh": Allowed,
"tr": Allowed,