2019-02-08 13:00:45 +01:00
|
|
|
// Copyright (C) 2019 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
)
|
|
|
|
|
2019-12-19 17:01:36 +01:00
|
|
|
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
2019-12-19 15:38:36 +01:00
|
|
|
RegisterPrebuiltBuildComponents(ctx)
|
|
|
|
android.RegisterPrebuiltMutators(ctx)
|
2019-12-19 20:16:28 +01:00
|
|
|
|
|
|
|
RegisterCCBuildComponents(ctx)
|
2020-01-16 13:14:42 +01:00
|
|
|
RegisterBinaryBuildComponents(ctx)
|
2019-12-19 16:02:40 +01:00
|
|
|
RegisterLibraryBuildComponents(ctx)
|
|
|
|
|
|
|
|
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
2020-02-15 20:00:10 +01:00
|
|
|
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
|
|
|
ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
|
2019-12-19 17:01:36 +01:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
func GatherRequiredDepsForTest(os android.OsType) string {
|
|
|
|
ret := `
|
|
|
|
toolchain_library {
|
|
|
|
name: "libatomic",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libcompiler_rt-extras",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libclang_rt.builtins-arm-android",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libclang_rt.builtins-aarch64-android",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libclang_rt.builtins-i686-android",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libclang_rt.builtins-x86_64-android",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
2019-07-15 18:34:09 +02:00
|
|
|
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: "",
|
|
|
|
}
|
|
|
|
|
2019-12-19 15:38:36 +01:00
|
|
|
// Needed for sanitizer
|
|
|
|
cc_prebuilt_library_shared {
|
|
|
|
name: "libclang_rt.ubsan_standalone-aarch64-android",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
system_shared_libs: [],
|
2019-12-19 15:38:36 +01:00
|
|
|
srcs: [""],
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
toolchain_library {
|
|
|
|
name: "libgcc",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
2019-03-30 04:05:14 +01:00
|
|
|
toolchain_library {
|
|
|
|
name: "libgcc_stripped",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
|
|
|
src: "",
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libc",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
2019-12-11 03:37:45 +01:00
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
system_shared_libs: [],
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
stubs: {
|
|
|
|
versions: ["27", "28", "29"],
|
|
|
|
},
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libc",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libm",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
2019-12-11 03:37:45 +01:00
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
system_shared_libs: [],
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
stubs: {
|
|
|
|
versions: ["27", "28", "29"],
|
|
|
|
},
|
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"myapex"
|
|
|
|
],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libm",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libdl",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
2019-12-11 03:37:45 +01:00
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
system_shared_libs: [],
|
|
|
|
recovery_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
stubs: {
|
|
|
|
versions: ["27", "28", "29"],
|
|
|
|
},
|
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"myapex"
|
|
|
|
],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libdl",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
2019-10-22 12:32:18 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libft2",
|
|
|
|
no_libcrt: true,
|
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
recovery_available: true,
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libft2",
|
|
|
|
symbol_file: "",
|
|
|
|
vendor_available: false,
|
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libc++_static",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-03 10:06:46 +01:00
|
|
|
host_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libc++",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
2020-02-03 10:06:46 +01:00
|
|
|
host_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
2020-02-15 20:29:50 +01:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"myapex"
|
|
|
|
],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2019-07-24 21:17:40 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libc++demangle",
|
|
|
|
no_libcrt: true,
|
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
host_supported: false,
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libunwind_llvm",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
vendor_available: true,
|
|
|
|
recovery_available: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_so",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-10-15 08:20:07 +02:00
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 01:05:20 +02:00
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_dynamic",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
|
|
|
stl: "none",
|
2019-05-15 01:05:20 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_static",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtend_so",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2019-10-15 08:20:07 +02:00
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtend_android",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
|
|
|
stl: "none",
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libprotobuf-cpp-lite",
|
|
|
|
}
|
2020-02-15 20:00:10 +01:00
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "ndk_libunwind",
|
|
|
|
sdk_version: "current",
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libc.ndk.current",
|
|
|
|
sdk_version: "current",
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libm.ndk.current",
|
|
|
|
sdk_version: "current",
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libdl.ndk.current",
|
|
|
|
sdk_version: "current",
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
ndk_prebuilt_object {
|
|
|
|
name: "ndk_crtbegin_so.27",
|
|
|
|
sdk_version: "27",
|
|
|
|
}
|
|
|
|
|
|
|
|
ndk_prebuilt_object {
|
|
|
|
name: "ndk_crtend_so.27",
|
|
|
|
sdk_version: "27",
|
|
|
|
}
|
|
|
|
|
|
|
|
ndk_prebuilt_shared_stl {
|
|
|
|
name: "ndk_libc++_shared",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
if os == android.Fuchsia {
|
|
|
|
ret += `
|
|
|
|
cc_library {
|
|
|
|
name: "libbioniccompat",
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libcompiler_rt",
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
2019-05-15 00:44:26 +02:00
|
|
|
|
2020-02-15 20:00:10 +01:00
|
|
|
func GatherRequiredFilesForTest(fs map[string][]byte) {
|
|
|
|
fs["prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtbegin_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtend_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtbegin_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtend_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtbegin_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtend_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtbegin_so.o"] = nil
|
|
|
|
fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtend_so.o"] = nil
|
|
|
|
}
|
|
|
|
|
2019-12-14 05:41:13 +01:00
|
|
|
func TestConfig(buildDir string, os android.OsType, env map[string]string,
|
|
|
|
bp string, fs map[string][]byte) android.Config {
|
2019-05-15 00:44:26 +02:00
|
|
|
|
2019-12-14 05:41:13 +01:00
|
|
|
// add some modules that are required by the compiler and/or linker
|
|
|
|
bp = bp + GatherRequiredDepsForTest(os)
|
|
|
|
|
|
|
|
mockFS := map[string][]byte{
|
|
|
|
"foo.c": nil,
|
|
|
|
"foo.lds": nil,
|
|
|
|
"bar.c": nil,
|
|
|
|
"baz.c": nil,
|
|
|
|
"baz.o": nil,
|
|
|
|
"a.proto": nil,
|
|
|
|
"b.aidl": nil,
|
|
|
|
"sub/c.aidl": nil,
|
|
|
|
"my_include": nil,
|
|
|
|
"foo.map.txt": nil,
|
|
|
|
"liba.so": nil,
|
|
|
|
}
|
|
|
|
|
2020-02-15 20:00:10 +01:00
|
|
|
GatherRequiredFilesForTest(mockFS)
|
|
|
|
|
2019-12-14 05:41:13 +01:00
|
|
|
for k, v := range fs {
|
|
|
|
mockFS[k] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
var config android.Config
|
|
|
|
if os == android.Fuchsia {
|
|
|
|
config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
|
|
|
|
} else {
|
|
|
|
config = android.TestArchConfig(buildDir, env, bp, mockFS)
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateTestContext() *android.TestContext {
|
2019-05-15 00:44:26 +02:00
|
|
|
ctx := android.NewTestArchContext()
|
2019-11-23 00:25:03 +01:00
|
|
|
ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
|
|
|
|
ctx.RegisterModuleType("cc_test", TestFactory)
|
|
|
|
ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
|
2019-12-09 10:21:48 +01:00
|
|
|
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
2019-11-23 00:25:03 +01:00
|
|
|
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
|
|
|
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
|
|
|
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
|
2019-12-19 17:01:36 +01:00
|
|
|
RegisterRequiredBuildComponentsForTest(ctx)
|
2019-09-24 23:55:04 +02:00
|
|
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
2019-11-23 00:25:03 +01:00
|
|
|
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
2019-11-15 01:59:12 +01:00
|
|
|
ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
|
2019-05-15 00:44:26 +02:00
|
|
|
|
|
|
|
return ctx
|
|
|
|
}
|