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 (
|
2022-10-04 07:42:02 +02:00
|
|
|
"encoding/json"
|
2021-05-20 19:01:32 +02:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
"android/soong/android"
|
2020-11-11 03:12:15 +01:00
|
|
|
"android/soong/genrule"
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
"android/soong/multitree"
|
2021-07-07 05:42:39 +02:00
|
|
|
"android/soong/snapshot"
|
2019-02-08 13:00:45 +01:00
|
|
|
)
|
|
|
|
|
2019-12-19 17:01:36 +01:00
|
|
|
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
2019-12-19 15:38:36 +01:00
|
|
|
RegisterPrebuiltBuildComponents(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)
|
2020-02-21 11:28:43 +01:00
|
|
|
RegisterLibraryHeadersBuildComponents(ctx)
|
2022-04-27 03:30:34 +02:00
|
|
|
RegisterLibraryStubBuildComponents(ctx)
|
2019-12-19 16:02:40 +01:00
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
multitree.RegisterApiImportsModule(ctx)
|
|
|
|
|
2023-09-25 14:13:17 +02:00
|
|
|
ctx.RegisterModuleType("prebuilt_build_tool", android.NewPrebuiltBuildTool)
|
2020-12-04 10:02:13 +01:00
|
|
|
ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
|
2019-12-19 16:02:40 +01:00
|
|
|
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
2021-09-17 01:57:28 +02:00
|
|
|
ctx.RegisterModuleType("cc_genrule", GenRuleFactory)
|
2020-02-15 20:00:10 +01:00
|
|
|
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
2021-06-15 01:52:28 +02:00
|
|
|
ctx.RegisterModuleType("ndk_prebuilt_static_stl", NdkPrebuiltStaticStlFactory)
|
2020-06-30 21:32:51 +02:00
|
|
|
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
2023-09-19 21:04:41 +02:00
|
|
|
ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
|
2019-12-19 17:01:36 +01:00
|
|
|
}
|
|
|
|
|
2020-03-02 11:16:35 +01:00
|
|
|
func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
2021-02-24 19:51:54 +01:00
|
|
|
ret := commonDefaultModules()
|
|
|
|
|
|
|
|
supportLinuxBionic := false
|
|
|
|
for _, os := range oses {
|
|
|
|
if os == android.Windows {
|
|
|
|
ret += withWindowsModules()
|
|
|
|
}
|
|
|
|
if os == android.LinuxBionic {
|
|
|
|
supportLinuxBionic = true
|
|
|
|
ret += withLinuxBionic()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !supportLinuxBionic {
|
|
|
|
ret += withoutLinuxBionic()
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func commonDefaultModules() string {
|
|
|
|
return `
|
2022-01-07 16:53:37 +01:00
|
|
|
cc_defaults {
|
|
|
|
name: "toolchain_libs_defaults",
|
2023-02-15 21:20:19 +01:00
|
|
|
host_supported: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
recovery_available: true,
|
2022-01-07 16:53:37 +01:00
|
|
|
no_libcrt: true,
|
|
|
|
sdk_version: "minimum",
|
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
check_elf_files: false,
|
|
|
|
sanitize: {
|
|
|
|
never: true,
|
|
|
|
},
|
2023-05-05 23:13:01 +02:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
"//apex_available:platform",
|
|
|
|
],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 16:53:37 +01:00
|
|
|
cc_prebuilt_library_static {
|
|
|
|
name: "libcompiler_rt-extras",
|
|
|
|
defaults: ["toolchain_libs_defaults"],
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2022-01-07 16:53:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_prebuilt_library_static {
|
2022-02-10 20:41:18 +01:00
|
|
|
name: "libclang_rt.builtins",
|
2022-01-07 16:53:37 +01:00
|
|
|
defaults: ["toolchain_libs_defaults"],
|
2022-02-10 20:41:18 +01:00
|
|
|
host_supported: true,
|
|
|
|
vendor_available: true,
|
2022-01-07 16:53:37 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-02-15 20:29:50 +01:00
|
|
|
native_bridge_supported: true,
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2022-02-10 19:34:19 +01:00
|
|
|
}
|
|
|
|
|
Enforce apex.min_sdk_version for bundled builds
Previously, when Q-targeting apexes are bundled-built, they are built
against the latest stubs.
It was because unwinder is linked dynamically in R and APIs are provided
by libc while Q apexes should run on Q where libc doesn't provide those
APIs. To make Q apexes run on Q device, libc++ should be linked with
static unwinder. But, because libc++ with static unwinder may cause problem
on HWASAN build, Q apexes were built against the latest stubs for bundled
build.
However, Q apexes should be built against Q stubs.
Now, only for HWASAN builds, Q apexes are built against the latest stubs
(and native modules are not linked with static unwinder).
Bug: 151912436
Test: TARGET_SANITIZE=hwaddress m
=> Q apexes(media, resolv, ..) are linked with the latest stubs
m
=> Q apexes are linked with Q stubs,
and Q apexes' libc++ is linked with static unwinder
Merged-In: If32f1b547e6d93e3955c7521eec8aef5851f908c
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
(cherry picked from commit 7406660685a9a085c433ba7081cc6984f66fa732)
Exempt-From-Owner-Approval: cp from internal
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
2020-03-19 20:29:24 +01:00
|
|
|
cc_prebuilt_library_shared {
|
2022-02-10 20:41:18 +01:00
|
|
|
name: "libclang_rt.hwasan",
|
2022-01-07 16:53:37 +01:00
|
|
|
defaults: ["toolchain_libs_defaults"],
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2021-01-14 04:18:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 16:53:37 +01:00
|
|
|
cc_prebuilt_library_static {
|
2021-01-14 04:18:53 +01:00
|
|
|
name: "libunwind",
|
2022-01-07 16:53:37 +01:00
|
|
|
defaults: [
|
|
|
|
"linux_bionic_supported",
|
|
|
|
"toolchain_libs_defaults",
|
|
|
|
],
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2021-01-14 04:18:53 +01:00
|
|
|
native_bridge_supported: true,
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 16:53:37 +01:00
|
|
|
cc_prebuilt_library_static {
|
2022-02-10 20:41:18 +01:00
|
|
|
name: "libclang_rt.fuzzer",
|
2022-01-07 16:53:37 +01:00
|
|
|
defaults: [
|
|
|
|
"linux_bionic_supported",
|
|
|
|
"toolchain_libs_defaults",
|
|
|
|
],
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2019-07-15 18:34:09 +02:00
|
|
|
}
|
|
|
|
|
2019-12-19 15:38:36 +01:00
|
|
|
// Needed for sanitizer
|
|
|
|
cc_prebuilt_library_shared {
|
2022-02-10 20:41:18 +01:00
|
|
|
name: "libclang_rt.ubsan_standalone",
|
2022-02-10 19:34:19 +01:00
|
|
|
defaults: ["toolchain_libs_defaults"],
|
2022-06-18 00:17:05 +02:00
|
|
|
srcs: [""],
|
2022-02-10 19:34:19 +01:00
|
|
|
}
|
|
|
|
|
2023-02-15 21:20:19 +01:00
|
|
|
cc_prebuilt_library_static {
|
|
|
|
name: "libclang_rt.ubsan_standalone.static",
|
|
|
|
defaults: ["toolchain_libs_defaults"],
|
|
|
|
srcs: [""],
|
|
|
|
}
|
|
|
|
|
2022-02-10 19:34:19 +01:00
|
|
|
cc_prebuilt_library_static {
|
2022-02-10 20:41:18 +01:00
|
|
|
name: "libclang_rt.ubsan_minimal",
|
2022-02-10 19:34:19 +01:00
|
|
|
defaults: ["toolchain_libs_defaults"],
|
2022-06-18 00:17:05 +02:00
|
|
|
host_supported: true,
|
|
|
|
target: {
|
|
|
|
android_arm64: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.android_arm64.a"],
|
|
|
|
},
|
|
|
|
android_arm: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.android_arm.a"],
|
|
|
|
},
|
|
|
|
linux_glibc_x86_64: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.x86_64.a"],
|
|
|
|
},
|
|
|
|
linux_glibc_x86: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.x86.a"],
|
|
|
|
},
|
2023-02-15 21:20:19 +01:00
|
|
|
linux_musl_x86_64: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.x86_64.a"],
|
|
|
|
},
|
|
|
|
linux_musl_x86: {
|
|
|
|
srcs: ["libclang_rt.ubsan_minimal.x86.a"],
|
|
|
|
},
|
2022-06-18 00:17:05 +02:00
|
|
|
},
|
2022-02-10 19:34:19 +01:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libc",
|
2020-07-11 05:33:29 +02:00
|
|
|
defaults: ["linux_bionic_supported"],
|
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"],
|
|
|
|
},
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libc.map.txt",
|
|
|
|
},
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libm",
|
2020-07-11 05:33:29 +02:00
|
|
|
defaults: ["linux_bionic_supported"],
|
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"
|
|
|
|
],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libm.map.txt",
|
|
|
|
},
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2020-04-09 15:56:02 +02:00
|
|
|
|
|
|
|
// Coverage libraries
|
|
|
|
cc_library {
|
|
|
|
name: "libprofile-extras",
|
|
|
|
vendor_available: true,
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-04-09 15:56:02 +02:00
|
|
|
recovery_available: true,
|
|
|
|
native_coverage: false,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libprofile-clang-extras",
|
|
|
|
vendor_available: true,
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-04-09 15:56:02 +02:00
|
|
|
recovery_available: true,
|
|
|
|
native_coverage: false,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libprofile-extras_ndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-04-09 15:56:02 +02:00
|
|
|
native_coverage: false,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
sdk_version: "current",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libprofile-clang-extras_ndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-04-09 15:56:02 +02:00
|
|
|
native_coverage: false,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
sdk_version: "current",
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libdl",
|
2020-07-11 05:33:29 +02:00
|
|
|
defaults: ["linux_bionic_supported"],
|
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"
|
|
|
|
],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libdl.map.txt",
|
|
|
|
},
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2019-10-22 12:32:18 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libft2",
|
|
|
|
no_libcrt: true,
|
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
recovery_available: true,
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libft2.map.txt",
|
|
|
|
private: true,
|
|
|
|
}
|
2019-10-22 12:32:18 +02:00
|
|
|
}
|
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,
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
recovery_available: true,
|
2020-02-03 10:06:46 +01:00
|
|
|
host_supported: true,
|
2020-04-15 04:03:39 +02:00
|
|
|
min_sdk_version: "29",
|
2020-03-07 08:35:46 +01:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
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,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-02-08 13:00:45 +01:00
|
|
|
recovery_available: true,
|
2020-02-03 10:06:46 +01:00
|
|
|
host_supported: true,
|
2020-04-15 04:03:39 +02:00
|
|
|
min_sdk_version: "29",
|
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",
|
2020-12-04 21:05:43 +01:00
|
|
|
"//apex_available:anyapex",
|
2020-02-15 20:29:50 +01:00
|
|
|
],
|
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,
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-07-24 21:17:40 +02:00
|
|
|
recovery_available: true,
|
2020-04-15 04:03:39 +02:00
|
|
|
min_sdk_version: "29",
|
2020-03-07 08:35:46 +01:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
2019-07-24 21:17:40 +02:00
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
|
2020-03-07 08:35:46 +01:00
|
|
|
cc_defaults {
|
|
|
|
name: "crt_defaults",
|
2020-07-11 05:33:29 +02:00
|
|
|
defaults: ["linux_bionic_supported"],
|
2020-03-07 08:35:46 +01:00
|
|
|
recovery_available: true,
|
|
|
|
vendor_available: true,
|
2021-02-05 16:57:43 +01:00
|
|
|
vendor_ramdisk_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-03-07 08:35:46 +01:00
|
|
|
native_bridge_supported: true,
|
|
|
|
stl: "none",
|
2020-07-15 22:33:30 +02:00
|
|
|
min_sdk_version: "16",
|
|
|
|
crt: true,
|
2021-07-22 20:39:44 +02:00
|
|
|
system_shared_libs: [],
|
2020-03-07 08:35:46 +01:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_so",
|
2020-03-07 08:35:46 +01:00
|
|
|
defaults: ["crt_defaults"],
|
2021-08-25 09:16:03 +02:00
|
|
|
srcs: ["crtbegin_so.c"],
|
|
|
|
objs: ["crtbrand"],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 01:05:20 +02:00
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_dynamic",
|
2020-03-07 08:35:46 +01:00
|
|
|
defaults: ["crt_defaults"],
|
2021-08-25 09:16:03 +02:00
|
|
|
srcs: ["crtbegin.c"],
|
|
|
|
objs: ["crtbrand"],
|
2019-05-15 01:05:20 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
cc_object {
|
|
|
|
name: "crtbegin_static",
|
2020-03-07 08:35:46 +01:00
|
|
|
defaults: ["crt_defaults"],
|
2021-08-25 09:16:03 +02:00
|
|
|
srcs: ["crtbegin.c"],
|
|
|
|
objs: ["crtbrand"],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtend_so",
|
2020-03-07 08:35:46 +01:00
|
|
|
defaults: ["crt_defaults"],
|
2021-08-25 09:16:03 +02:00
|
|
|
srcs: ["crtend_so.c"],
|
|
|
|
objs: ["crtbrand"],
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtend_android",
|
2020-03-07 08:35:46 +01:00
|
|
|
defaults: ["crt_defaults"],
|
2021-08-25 09:16:03 +02:00
|
|
|
srcs: ["crtend.c"],
|
|
|
|
objs: ["crtbrand"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "crtbrand",
|
|
|
|
defaults: ["crt_defaults"],
|
|
|
|
srcs: ["crtbrand.c"],
|
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",
|
2021-06-15 01:52:28 +02:00
|
|
|
sdk_version: "minimum",
|
2020-02-15 20:00:10 +01:00
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
2020-06-30 21:32:51 +02:00
|
|
|
ndk_library {
|
|
|
|
name: "libc",
|
|
|
|
first_version: "minimum",
|
|
|
|
symbol_file: "libc.map.txt",
|
2020-02-15 20:00:10 +01:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:32:51 +02:00
|
|
|
ndk_library {
|
|
|
|
name: "libm",
|
|
|
|
first_version: "minimum",
|
|
|
|
symbol_file: "libm.map.txt",
|
2020-02-15 20:00:10 +01:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:32:51 +02:00
|
|
|
ndk_library {
|
|
|
|
name: "libdl",
|
|
|
|
first_version: "minimum",
|
|
|
|
symbol_file: "libdl.map.txt",
|
2020-02-15 20:00:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ndk_prebuilt_shared_stl {
|
|
|
|
name: "ndk_libc++_shared",
|
2021-06-15 01:52:28 +02:00
|
|
|
export_include_dirs: ["ndk_libc++_shared"],
|
|
|
|
}
|
|
|
|
|
2020-12-04 10:02:13 +01:00
|
|
|
cc_library_static {
|
|
|
|
name: "libgoogle-benchmark",
|
|
|
|
sdk_version: "current",
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
2020-04-29 00:09:12 +02:00
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "note_memtag_heap_async",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "note_memtag_heap_sync",
|
|
|
|
}
|
2021-07-24 00:23:07 +02:00
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libc_musl",
|
|
|
|
host_supported: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
}
|
2020-02-15 20:00:10 +01:00
|
|
|
`
|
2021-02-24 19:51:54 +01:00
|
|
|
}
|
2020-02-15 20:00:10 +01:00
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
func withWindowsModules() string {
|
|
|
|
return `
|
2022-01-07 16:53:37 +01:00
|
|
|
cc_prebuilt_library_static {
|
2020-03-02 11:16:35 +01:00
|
|
|
name: "libwinpthread",
|
|
|
|
host_supported: true,
|
|
|
|
enabled: false,
|
|
|
|
target: {
|
|
|
|
windows: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
2022-01-07 16:53:37 +01:00
|
|
|
stl: "none",
|
|
|
|
srcs:[""],
|
2020-03-02 11:16:35 +01:00
|
|
|
}
|
|
|
|
`
|
2021-02-24 19:51:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func withLinuxBionic() string {
|
|
|
|
return `
|
2020-07-11 05:33:29 +02:00
|
|
|
cc_binary {
|
|
|
|
name: "linker",
|
|
|
|
defaults: ["linux_bionic_supported"],
|
|
|
|
recovery_available: true,
|
|
|
|
stl: "none",
|
|
|
|
nocrt: true,
|
|
|
|
static_executable: true,
|
|
|
|
native_coverage: false,
|
|
|
|
system_shared_libs: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_genrule {
|
2021-06-12 03:02:22 +02:00
|
|
|
name: "host_bionic_linker_script",
|
2020-07-11 05:33:29 +02:00
|
|
|
host_supported: true,
|
|
|
|
device_supported: false,
|
|
|
|
target: {
|
|
|
|
host: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
linux_bionic: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
2021-06-12 03:02:22 +02:00
|
|
|
out: ["linker.script"],
|
2020-07-11 05:33:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "linux_bionic_supported",
|
|
|
|
host_supported: true,
|
|
|
|
target: {
|
|
|
|
host: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
linux_bionic: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
2021-02-24 19:51:54 +01:00
|
|
|
}
|
2020-07-11 05:33:29 +02:00
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
func withoutLinuxBionic() string {
|
|
|
|
return `
|
2020-07-11 05:33:29 +02:00
|
|
|
cc_defaults {
|
|
|
|
name: "linux_bionic_supported",
|
|
|
|
}
|
|
|
|
`
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2019-05-15 00:44:26 +02:00
|
|
|
|
2020-02-15 20:00:10 +01:00
|
|
|
func GatherRequiredFilesForTest(fs map[string][]byte) {
|
|
|
|
}
|
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
// The directory in which cc linux bionic default modules will be defined.
|
|
|
|
//
|
|
|
|
// Placing them here ensures that their location does not conflict with default test modules
|
|
|
|
// defined by other packages.
|
|
|
|
const linuxBionicDefaultsPath = "defaults/cc/linux-bionic/Android.bp"
|
|
|
|
|
|
|
|
// The directory in which the default cc common test modules will be defined.
|
|
|
|
//
|
|
|
|
// Placing them here ensures that their location does not conflict with default test modules
|
|
|
|
// defined by other packages.
|
|
|
|
const DefaultCcCommonTestModulesDir = "defaults/cc/common/"
|
|
|
|
|
|
|
|
// Test fixture preparer that will register most cc build components.
|
|
|
|
//
|
|
|
|
// Singletons and mutators should only be added here if they are needed for a majority of cc
|
|
|
|
// module types, otherwise they should be added under a separate preparer to allow them to be
|
|
|
|
// selected only when needed to reduce test execution time.
|
|
|
|
//
|
|
|
|
// Module types do not have much of an overhead unless they are used so this should include as many
|
|
|
|
// module types as possible. The exceptions are those module types that require mutators and/or
|
|
|
|
// singletons in order to function in which case they should be kept together in a separate
|
|
|
|
// preparer.
|
|
|
|
var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
|
|
|
|
android.PrepareForTestWithAndroidBuildComponents,
|
|
|
|
android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest),
|
|
|
|
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
2022-06-07 22:12:06 +02:00
|
|
|
ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory)
|
2021-02-24 19:51:54 +01:00
|
|
|
ctx.RegisterModuleType("cc_test", TestFactory)
|
|
|
|
ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
|
|
|
|
|
|
|
RegisterVndkLibraryTxtTypes(ctx)
|
|
|
|
}),
|
2021-03-21 23:01:55 +01:00
|
|
|
|
|
|
|
// Additional files needed in tests that disallow non-existent source files.
|
|
|
|
// This includes files that are needed by all, or at least most, instances of a cc module type.
|
|
|
|
android.MockFS{
|
|
|
|
// Needed for ndk_prebuilt_(shared|static)_stl.
|
2023-09-13 19:58:52 +02:00
|
|
|
"defaults/cc/common/current/sources/cxx-stl/llvm-libc++/libs": nil,
|
2021-03-21 23:01:55 +01:00
|
|
|
}.AddToFixture(),
|
2021-02-24 19:51:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Preparer that will define default cc modules, e.g. standard prebuilt modules.
|
|
|
|
var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
|
|
|
PrepareForTestWithCcBuildComponents,
|
2021-03-21 23:01:55 +01:00
|
|
|
|
|
|
|
// Additional files needed in tests that disallow non-existent source.
|
|
|
|
android.MockFS{
|
2023-07-20 20:16:19 +02:00
|
|
|
"defaults/cc/common/libc.map.txt": nil,
|
|
|
|
"defaults/cc/common/libdl.map.txt": nil,
|
|
|
|
"defaults/cc/common/libm.map.txt": nil,
|
|
|
|
"defaults/cc/common/ndk_libc++_shared": nil,
|
|
|
|
"defaults/cc/common/crtbegin_so.c": nil,
|
|
|
|
"defaults/cc/common/crtbegin.c": nil,
|
|
|
|
"defaults/cc/common/crtend_so.c": nil,
|
|
|
|
"defaults/cc/common/crtend.c": nil,
|
|
|
|
"defaults/cc/common/crtbrand.c": nil,
|
2022-06-18 00:17:05 +02:00
|
|
|
|
|
|
|
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil,
|
|
|
|
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a": nil,
|
|
|
|
"defaults/cc/common/libclang_rt.ubsan_minimal.x86_64.a": nil,
|
|
|
|
"defaults/cc/common/libclang_rt.ubsan_minimal.x86.a": nil,
|
2021-03-21 23:01:55 +01:00
|
|
|
}.AddToFixture(),
|
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
// Place the default cc test modules that are common to all platforms in a location that will not
|
|
|
|
// conflict with default test modules defined by other packages.
|
|
|
|
android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()),
|
|
|
|
// Disable linux bionic by default.
|
|
|
|
android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()),
|
|
|
|
)
|
|
|
|
|
|
|
|
// Prepare a fixture to use all cc module types, mutators and singletons fully.
|
|
|
|
//
|
|
|
|
// This should only be used by tests that want to run with as much of the build enabled as possible.
|
|
|
|
var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers(
|
|
|
|
android.PrepareForIntegrationTestWithAndroid,
|
|
|
|
genrule.PrepareForIntegrationTestWithGenrule,
|
|
|
|
PrepareForTestWithCcDefaultModules,
|
|
|
|
)
|
|
|
|
|
|
|
|
// The preparer to include if running a cc related test for windows.
|
|
|
|
var PrepareForTestOnWindows = android.GroupFixturePreparers(
|
|
|
|
// Place the default cc test modules for windows platforms in a location that will not conflict
|
|
|
|
// with default test modules defined by other packages.
|
|
|
|
android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()),
|
|
|
|
)
|
|
|
|
|
|
|
|
// The preparer to include if running a cc related test for linux bionic.
|
|
|
|
var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers(
|
2021-03-11 20:01:26 +01:00
|
|
|
// Enable linux bionic
|
|
|
|
//
|
|
|
|
// Can be used after PrepareForTestWithCcDefaultModules to override its default behavior of
|
|
|
|
// disabling linux bionic, hence why this uses FixtureOverrideTextFile.
|
|
|
|
android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()),
|
2021-02-24 19:51:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// This adds some additional modules and singletons which might negatively impact the performance
|
|
|
|
// of tests so they are not included in the PrepareForIntegrationTestWithCc.
|
|
|
|
var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers(
|
|
|
|
PrepareForIntegrationTestWithCc,
|
|
|
|
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
2021-07-07 05:42:39 +02:00
|
|
|
snapshot.VendorSnapshotImageSingleton.Init(ctx)
|
|
|
|
snapshot.RecoverySnapshotImageSingleton.Init(ctx)
|
|
|
|
RegisterVendorSnapshotModules(ctx)
|
|
|
|
RegisterRecoverySnapshotModules(ctx)
|
2021-02-24 19:51:54 +01:00
|
|
|
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2023-02-15 21:20:19 +01:00
|
|
|
// PrepareForTestWithHostMusl sets the host configuration to musl libc instead of glibc. It also disables the test
|
|
|
|
// on mac, which doesn't support musl libc, and adds musl modules.
|
|
|
|
var PrepareForTestWithHostMusl = android.GroupFixturePreparers(
|
|
|
|
android.FixtureModifyConfig(android.ModifyTestConfigForMusl),
|
|
|
|
android.PrepareForSkipTestOnMac,
|
|
|
|
android.FixtureAddTextFile("external/musl/Android.bp", `
|
|
|
|
cc_defaults {
|
|
|
|
name: "libc_musl_crt_defaults",
|
|
|
|
host_supported: true,
|
|
|
|
device_supported: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "libc_musl_crtbegin_so",
|
|
|
|
defaults: ["libc_musl_crt_defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "libc_musl_crtend_so",
|
|
|
|
defaults: ["libc_musl_crt_defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "libc_musl_crtbegin_dynamic",
|
|
|
|
defaults: ["libc_musl_crt_defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "libc_musl_crtbegin_static",
|
|
|
|
defaults: ["libc_musl_crt_defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "libc_musl_crtend",
|
|
|
|
defaults: ["libc_musl_crt_defaults"],
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
|
2023-03-10 04:07:19 +01:00
|
|
|
// PrepareForTestWithFdoProfile registers module types to test with fdo_profile
|
|
|
|
var PrepareForTestWithFdoProfile = android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("soong_namespace", android.NamespaceFactory)
|
2023-06-05 18:57:55 +02:00
|
|
|
ctx.RegisterModuleType("fdo_profile", FdoProfileFactory)
|
2023-03-10 04:07:19 +01:00
|
|
|
})
|
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
// TestConfig is the legacy way of creating a test Config for testing cc modules.
|
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
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)
|
|
|
|
|
2020-06-08 02:02:48 +02:00
|
|
|
mockFS := map[string][]byte{}
|
2019-12-14 05:41:13 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-07-20 22:17:15 +02:00
|
|
|
return android.TestArchConfig(buildDir, env, bp, mockFS)
|
2019-12-14 05:41:13 +01:00
|
|
|
}
|
|
|
|
|
2021-02-24 19:51:54 +01:00
|
|
|
// CreateTestContext is the legacy way of creating a TestContext for testing cc modules.
|
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
2020-10-30 01:09:13 +01:00
|
|
|
func CreateTestContext(config android.Config) *android.TestContext {
|
|
|
|
ctx := android.NewTestArchContext(config)
|
2021-03-05 00:02:31 +01:00
|
|
|
genrule.RegisterGenruleBuildComponents(ctx)
|
2022-06-07 22:12:06 +02:00
|
|
|
ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory)
|
2019-11-23 00:25:03 +01:00
|
|
|
ctx.RegisterModuleType("cc_test", TestFactory)
|
2020-06-05 23:26:16 +02:00
|
|
|
ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
|
2019-11-23 00:25:03 +01:00
|
|
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
|
|
|
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
2021-02-24 19:51:54 +01:00
|
|
|
|
2021-07-07 05:42:39 +02:00
|
|
|
snapshot.VendorSnapshotImageSingleton.Init(ctx)
|
|
|
|
snapshot.RecoverySnapshotImageSingleton.Init(ctx)
|
|
|
|
RegisterVendorSnapshotModules(ctx)
|
|
|
|
RegisterRecoverySnapshotModules(ctx)
|
2021-02-24 19:51:54 +01:00
|
|
|
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
2020-12-28 22:50:21 +01:00
|
|
|
RegisterVndkLibraryTxtTypes(ctx)
|
2021-02-24 19:51:54 +01:00
|
|
|
|
2019-09-24 23:55:04 +02:00
|
|
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
2020-07-30 17:04:17 +02:00
|
|
|
android.RegisterPrebuiltMutators(ctx)
|
2020-04-29 19:27:14 +02:00
|
|
|
RegisterRequiredBuildComponentsForTest(ctx)
|
2019-05-15 00:44:26 +02:00
|
|
|
|
|
|
|
return ctx
|
|
|
|
}
|
2021-05-20 19:01:32 +02:00
|
|
|
|
|
|
|
func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) {
|
|
|
|
t.Helper()
|
|
|
|
mod := ctx.ModuleForTests(moduleName, variant)
|
|
|
|
outputFiles := mod.OutputFiles(t, "")
|
|
|
|
if len(outputFiles) != 1 {
|
|
|
|
t.Errorf("%q must have single output\n", moduleName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
snapshotPath := filepath.Join(subDir, snapshotFilename)
|
|
|
|
|
|
|
|
if include {
|
|
|
|
out := singleton.Output(snapshotPath)
|
|
|
|
if fake {
|
|
|
|
if out.Rule == nil {
|
|
|
|
t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0])
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if out.Input.String() != outputFiles[0].String() {
|
|
|
|
t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
out := singleton.MaybeOutput(snapshotPath)
|
|
|
|
if out.Rule != nil {
|
|
|
|
t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CheckSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
|
|
|
t.Helper()
|
|
|
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CheckSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
|
|
|
t.Helper()
|
|
|
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CheckSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
|
|
|
t.Helper()
|
|
|
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func AssertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
|
|
|
|
t.Helper()
|
|
|
|
m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
|
|
|
|
if m.ExcludeFromVendorSnapshot() != expected {
|
|
|
|
t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
|
|
|
|
for _, moduleName := range moduleNames {
|
|
|
|
module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
|
|
|
|
output := module.outputFile.Path().RelativeToTop()
|
|
|
|
paths = append(paths, output)
|
|
|
|
}
|
|
|
|
return paths
|
|
|
|
}
|
2021-11-09 22:23:40 +01:00
|
|
|
|
|
|
|
func AssertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
|
|
|
|
t.Helper()
|
|
|
|
m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
|
|
|
|
if m.ExcludeFromRecoverySnapshot() != expected {
|
|
|
|
t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected)
|
|
|
|
}
|
|
|
|
}
|
2022-10-04 07:42:02 +02:00
|
|
|
|
|
|
|
func checkOverrides(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, jsonPath string, expected []string) {
|
2022-10-06 17:20:37 +02:00
|
|
|
t.Helper()
|
2022-10-04 07:42:02 +02:00
|
|
|
out := singleton.MaybeOutput(jsonPath)
|
|
|
|
content := android.ContentFromFileRuleForTests(t, out)
|
|
|
|
|
|
|
|
var flags snapshotJsonFlags
|
|
|
|
if err := json.Unmarshal([]byte(content), &flags); err != nil {
|
2022-10-06 17:20:37 +02:00
|
|
|
t.Errorf("Error while unmarshalling json %q: %s", jsonPath, err.Error())
|
2022-10-04 07:42:02 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, moduleName := range expected {
|
|
|
|
if !android.InList(moduleName, flags.Overrides) {
|
|
|
|
t.Errorf("expected %q to be in %q: %q", moduleName, flags.Overrides, content)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|