| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 The Android Open Source Project | 
 | 2 | // | 
 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 4 | // you may not use this file except in compliance with the License. | 
 | 5 | // You may obtain a copy of the License at | 
 | 6 | // | 
 | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
 | 8 | // | 
 | 9 | // Unless required by applicable law or agreed to in writing, software | 
 | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
 | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 12 | // See the License for the specific language governing permissions and | 
 | 13 | // limitations under the License. | 
 | 14 |  | 
 | 15 | package cc | 
 | 16 |  | 
 | 17 | import ( | 
| Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 18 | 	"path/filepath" | 
 | 19 | 	"testing" | 
 | 20 |  | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 21 | 	"android/soong/android" | 
| Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 22 | 	"android/soong/genrule" | 
| Kiyoung Kim | 487689e | 2022-07-26 09:48:22 +0900 | [diff] [blame] | 23 | 	"android/soong/multitree" | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 24 | ) | 
 | 25 |  | 
| Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 26 | func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { | 
| Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 27 | 	RegisterPrebuiltBuildComponents(ctx) | 
| Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 28 | 	RegisterCCBuildComponents(ctx) | 
| Paul Duffin | 2ee6979 | 2020-01-16 12:14:42 +0000 | [diff] [blame] | 29 | 	RegisterBinaryBuildComponents(ctx) | 
| Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 30 | 	RegisterLibraryBuildComponents(ctx) | 
| Paul Duffin | 1c6c1c7 | 2020-02-21 10:28:43 +0000 | [diff] [blame] | 31 | 	RegisterLibraryHeadersBuildComponents(ctx) | 
| Inseob Kim | 5eb7ee9 | 2022-04-27 10:30:34 +0900 | [diff] [blame] | 32 | 	RegisterLibraryStubBuildComponents(ctx) | 
| Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 33 |  | 
| Kiyoung Kim | 487689e | 2022-07-26 09:48:22 +0900 | [diff] [blame] | 34 | 	multitree.RegisterApiImportsModule(ctx) | 
 | 35 |  | 
| Sam Delmerico | f2b1606 | 2023-09-25 12:13:17 +0000 | [diff] [blame] | 36 | 	ctx.RegisterModuleType("prebuilt_build_tool", android.NewPrebuiltBuildTool) | 
| Jiyong Park | 46a512f | 2020-12-04 18:02:13 +0900 | [diff] [blame] | 37 | 	ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory) | 
| Hao Chen | 1c8ea5b | 2023-10-20 23:03:45 +0000 | [diff] [blame] | 38 | 	ctx.RegisterModuleType("cc_cmake_snapshot", CmakeSnapshotFactory) | 
| Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 39 | 	ctx.RegisterModuleType("cc_object", ObjectFactory) | 
| Wei Li | bcd3994 | 2021-09-16 23:57:28 +0000 | [diff] [blame] | 40 | 	ctx.RegisterModuleType("cc_genrule", GenRuleFactory) | 
| Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 41 | 	ctx.RegisterModuleType("ndk_library", NdkLibraryFactory) | 
| Spandan Das | 319711b | 2023-09-19 19:04:41 +0000 | [diff] [blame] | 42 | 	ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory) | 
| Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 43 | } | 
 | 44 |  | 
| Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 45 | func GatherRequiredDepsForTest(oses ...android.OsType) string { | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 46 | 	ret := commonDefaultModules() | 
 | 47 |  | 
 | 48 | 	supportLinuxBionic := false | 
 | 49 | 	for _, os := range oses { | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 50 | 		if os == android.Windows { | 
 | 51 | 			ret += withWindowsModules() | 
 | 52 | 		} | 
 | 53 | 		if os == android.LinuxBionic { | 
 | 54 | 			supportLinuxBionic = true | 
 | 55 | 			ret += withLinuxBionic() | 
 | 56 | 		} | 
 | 57 | 	} | 
 | 58 |  | 
 | 59 | 	if !supportLinuxBionic { | 
 | 60 | 		ret += withoutLinuxBionic() | 
 | 61 | 	} | 
 | 62 |  | 
 | 63 | 	return ret | 
 | 64 | } | 
 | 65 |  | 
 | 66 | func commonDefaultModules() string { | 
 | 67 | 	return ` | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 68 | 		cc_defaults { | 
 | 69 | 			name: "toolchain_libs_defaults", | 
| Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 70 | 			host_supported: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 71 | 			vendor_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 72 | 			product_available: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 73 | 			recovery_available: true, | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 74 | 			no_libcrt: true, | 
 | 75 | 			sdk_version: "minimum", | 
| Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 76 | 			nocrt: true, | 
| Kalesh Singh | f4ffe0a | 2024-01-29 13:01:51 -0800 | [diff] [blame] | 77 | 			no_crt_pad_segment: true, | 
| Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 78 | 			system_shared_libs: [], | 
 | 79 | 			stl: "none", | 
| Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 80 | 			check_elf_files: false, | 
 | 81 | 			sanitize: { | 
 | 82 | 				never: true, | 
 | 83 | 			}, | 
| Spandan Das | 4de7b49 | 2023-05-05 21:13:01 +0000 | [diff] [blame] | 84 | 			apex_available: [ | 
 | 85 | 				"//apex_available:anyapex", | 
 | 86 | 				"//apex_available:platform", | 
 | 87 | 			], | 
| Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 88 | 		} | 
 | 89 |  | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 90 | 		cc_prebuilt_library_static { | 
 | 91 | 			name: "libcompiler_rt-extras", | 
 | 92 | 			defaults: ["toolchain_libs_defaults"], | 
 | 93 | 			vendor_ramdisk_available: true, | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 94 | 			srcs: [""], | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 95 | 		} | 
 | 96 |  | 
 | 97 | 		cc_prebuilt_library_static { | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 98 | 			name: "libclang_rt.builtins", | 
| Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 99 | 			defaults: ["toolchain_libs_defaults"], | 
 | 100 | 			host_supported: true, | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 101 | 	        vendor_available: true, | 
 | 102 | 			vendor_ramdisk_available: true, | 
 | 103 | 			native_bridge_supported: true, | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 104 | 			srcs: [""], | 
| Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 105 | 		} | 
 | 106 |  | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 107 | 		cc_prebuilt_library_shared { | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 108 | 			name: "libclang_rt.hwasan", | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 109 | 			defaults: ["toolchain_libs_defaults"], | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 110 | 			srcs: [""], | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 111 | 		} | 
 | 112 |  | 
 | 113 | 		cc_prebuilt_library_static { | 
| Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 114 | 			name: "libunwind", | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 115 | 			defaults: [ | 
 | 116 | 				"linux_bionic_supported", | 
 | 117 | 				"toolchain_libs_defaults", | 
 | 118 | 			], | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 119 | 			vendor_ramdisk_available: true, | 
| Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 120 | 			native_bridge_supported: true, | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 121 | 			srcs: [""], | 
| Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 122 | 		} | 
 | 123 |  | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 124 | 		cc_prebuilt_library_static { | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 125 | 			name: "libclang_rt.fuzzer", | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 126 | 			defaults: [ | 
 | 127 | 				"linux_bionic_supported", | 
 | 128 | 				"toolchain_libs_defaults", | 
 | 129 | 			], | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 130 | 			srcs: [""], | 
| Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 131 | 		} | 
 | 132 |  | 
| Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 133 | 		// Needed for sanitizer | 
 | 134 | 		cc_prebuilt_library_shared { | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 135 | 			name: "libclang_rt.ubsan_standalone", | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 136 | 			defaults: ["toolchain_libs_defaults"], | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 137 | 			srcs: [""], | 
| Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 138 | 		} | 
 | 139 |  | 
| Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 140 | 		cc_prebuilt_library_static { | 
| Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 141 | 			name: "libclang_rt.ubsan_standalone.static", | 
 | 142 | 			defaults: ["toolchain_libs_defaults"], | 
 | 143 | 			srcs: [""], | 
 | 144 | 		} | 
 | 145 |  | 
 | 146 | 		cc_prebuilt_library_static { | 
| Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 147 | 			name: "libclang_rt.ubsan_minimal", | 
| Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 148 | 			defaults: ["toolchain_libs_defaults"], | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 149 | 			host_supported: true, | 
 | 150 | 			target: { | 
 | 151 | 				android_arm64: { | 
 | 152 | 					srcs: ["libclang_rt.ubsan_minimal.android_arm64.a"], | 
 | 153 | 				}, | 
 | 154 | 				android_arm: { | 
 | 155 | 					srcs: ["libclang_rt.ubsan_minimal.android_arm.a"], | 
 | 156 | 				}, | 
 | 157 | 				linux_glibc_x86_64: { | 
 | 158 | 					srcs: ["libclang_rt.ubsan_minimal.x86_64.a"], | 
 | 159 | 				}, | 
 | 160 | 				linux_glibc_x86: { | 
 | 161 | 					srcs: ["libclang_rt.ubsan_minimal.x86.a"], | 
 | 162 | 				}, | 
| Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 163 | 				linux_musl_x86_64: { | 
 | 164 | 					srcs: ["libclang_rt.ubsan_minimal.x86_64.a"], | 
 | 165 | 				}, | 
 | 166 | 				linux_musl_x86: { | 
 | 167 | 					srcs: ["libclang_rt.ubsan_minimal.x86.a"], | 
 | 168 | 				}, | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 169 | 			}, | 
| Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 170 | 		} | 
 | 171 |  | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 172 | 		cc_library { | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 173 | 			name: "libc", | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 174 | 			defaults: ["linux_bionic_supported"], | 
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 175 | 			no_libcrt: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 176 | 			nocrt: true, | 
| Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 177 | 			stl: "none", | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 178 | 			system_shared_libs: [], | 
 | 179 | 			recovery_available: true, | 
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 180 | 			stubs: { | 
 | 181 | 				versions: ["27", "28", "29"], | 
 | 182 | 			}, | 
| Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 183 | 			llndk: { | 
 | 184 | 				symbol_file: "libc.map.txt", | 
 | 185 | 			}, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 186 | 		} | 
 | 187 | 		cc_library { | 
 | 188 | 			name: "libm", | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 189 | 			defaults: ["linux_bionic_supported"], | 
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 190 | 			no_libcrt: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 191 | 			nocrt: true, | 
| Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 192 | 			stl: "none", | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 193 | 			system_shared_libs: [], | 
 | 194 | 			recovery_available: true, | 
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 195 | 			stubs: { | 
 | 196 | 				versions: ["27", "28", "29"], | 
 | 197 | 			}, | 
 | 198 | 			apex_available: [ | 
 | 199 | 				"//apex_available:platform", | 
 | 200 | 				"myapex" | 
 | 201 | 			], | 
| Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 202 | 			llndk: { | 
 | 203 | 				symbol_file: "libm.map.txt", | 
 | 204 | 			}, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 205 | 		} | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 206 |  | 
 | 207 | 		// Coverage libraries | 
 | 208 | 		cc_library { | 
 | 209 | 			name: "libprofile-extras", | 
 | 210 | 			vendor_available: true, | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 211 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 212 | 			product_available: true, | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 213 | 			recovery_available: true, | 
 | 214 | 			native_coverage: false, | 
 | 215 | 			system_shared_libs: [], | 
 | 216 | 			stl: "none", | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 217 | 		} | 
 | 218 | 		cc_library { | 
 | 219 | 			name: "libprofile-clang-extras", | 
 | 220 | 			vendor_available: true, | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 221 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 222 | 			product_available: true, | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 223 | 			recovery_available: true, | 
 | 224 | 			native_coverage: false, | 
 | 225 | 			system_shared_libs: [], | 
 | 226 | 			stl: "none", | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 227 | 		} | 
 | 228 | 		cc_library { | 
 | 229 | 			name: "libprofile-extras_ndk", | 
 | 230 | 			vendor_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 231 | 			product_available: true, | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 232 | 			native_coverage: false, | 
 | 233 | 			system_shared_libs: [], | 
 | 234 | 			stl: "none", | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 235 | 			sdk_version: "current", | 
 | 236 | 		} | 
 | 237 | 		cc_library { | 
 | 238 | 			name: "libprofile-clang-extras_ndk", | 
 | 239 | 			vendor_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 240 | 			product_available: true, | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 241 | 			native_coverage: false, | 
 | 242 | 			system_shared_libs: [], | 
 | 243 | 			stl: "none", | 
| Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 244 | 			sdk_version: "current", | 
 | 245 | 		} | 
 | 246 |  | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 247 | 		cc_library { | 
 | 248 | 			name: "libdl", | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 249 | 			defaults: ["linux_bionic_supported"], | 
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 250 | 			no_libcrt: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 251 | 			nocrt: true, | 
| Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 252 | 			stl: "none", | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 253 | 			system_shared_libs: [], | 
 | 254 | 			recovery_available: true, | 
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 255 | 			stubs: { | 
 | 256 | 				versions: ["27", "28", "29"], | 
 | 257 | 			}, | 
 | 258 | 			apex_available: [ | 
 | 259 | 				"//apex_available:platform", | 
 | 260 | 				"myapex" | 
 | 261 | 			], | 
| Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 262 | 			llndk: { | 
 | 263 | 				symbol_file: "libdl.map.txt", | 
 | 264 | 			}, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 265 | 		} | 
 | 266 | 		cc_library { | 
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 267 | 			name: "libft2", | 
 | 268 | 			no_libcrt: true, | 
 | 269 | 			nocrt: true, | 
 | 270 | 			system_shared_libs: [], | 
 | 271 | 			recovery_available: true, | 
| Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 272 | 			llndk: { | 
 | 273 | 				symbol_file: "libft2.map.txt", | 
 | 274 | 				private: true, | 
 | 275 | 			} | 
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 276 | 		} | 
 | 277 | 		cc_library { | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 278 | 			name: "libc++_static", | 
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 279 | 			no_libcrt: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 280 | 			nocrt: true, | 
 | 281 | 			system_shared_libs: [], | 
 | 282 | 			stl: "none", | 
 | 283 | 			vendor_available: true, | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 284 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 285 | 			product_available: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 286 | 			recovery_available: true, | 
| Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 287 | 			host_supported: true, | 
| Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 288 | 			min_sdk_version: "29", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 289 | 			apex_available: [ | 
 | 290 | 				"//apex_available:platform", | 
 | 291 | 				"//apex_available:anyapex", | 
 | 292 | 			], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 293 | 		} | 
 | 294 | 		cc_library { | 
 | 295 | 			name: "libc++", | 
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 296 | 			no_libcrt: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 297 | 			nocrt: true, | 
 | 298 | 			system_shared_libs: [], | 
 | 299 | 			stl: "none", | 
 | 300 | 			vendor_available: true, | 
| Ivan Lozano | 0a468a4 | 2024-05-13 21:03:34 -0400 | [diff] [blame] | 301 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 302 | 			product_available: true, | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 303 | 			recovery_available: true, | 
| Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 304 | 			host_supported: true, | 
| Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 305 | 			min_sdk_version: "29", | 
| Kiyoung Kim | 0d1c1e6 | 2024-03-26 16:33:58 +0900 | [diff] [blame] | 306 | 			double_loadable: true, | 
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 307 | 			apex_available: [ | 
 | 308 | 				"//apex_available:platform", | 
| Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 309 | 				"//apex_available:anyapex", | 
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 310 | 			], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 311 | 		} | 
 | 312 | 		cc_library { | 
| Ryan Prichard | 2a69eb6 | 2024-07-30 01:58:54 +0000 | [diff] [blame] | 313 | 			name: "ndk_libc++_shared", | 
 | 314 | 			export_include_dirs: ["ndk_libc++_shared_include_dirs"], | 
 | 315 | 			no_libcrt: true, | 
 | 316 | 			nocrt: true, | 
 | 317 | 			system_shared_libs: [], | 
 | 318 | 			stl: "none", | 
 | 319 | 			vendor_available: true, | 
 | 320 | 			vendor_ramdisk_available: true, | 
 | 321 | 			product_available: true, | 
 | 322 | 			recovery_available: true, | 
 | 323 | 			host_supported: false, | 
 | 324 | 			sdk_version: "minimum", | 
 | 325 | 			double_loadable: true, | 
 | 326 | 			apex_available: [ | 
 | 327 | 				"//apex_available:platform", | 
 | 328 | 				"//apex_available:anyapex", | 
 | 329 | 			], | 
 | 330 | 		} | 
 | 331 | 		cc_library { | 
| Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 332 | 			name: "libc++demangle", | 
 | 333 | 			no_libcrt: true, | 
 | 334 | 			nocrt: true, | 
 | 335 | 			system_shared_libs: [], | 
 | 336 | 			stl: "none", | 
 | 337 | 			host_supported: false, | 
 | 338 | 			vendor_available: true, | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 339 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 340 | 			product_available: true, | 
| Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 341 | 			recovery_available: true, | 
| Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 342 | 			min_sdk_version: "29", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 343 | 			apex_available: [ | 
 | 344 | 				"//apex_available:platform", | 
 | 345 | 				"//apex_available:anyapex", | 
 | 346 | 			], | 
| Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 347 | 		} | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 348 |  | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 349 | 		cc_defaults { | 
 | 350 | 			name: "crt_defaults", | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 351 | 			defaults: ["linux_bionic_supported"], | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 352 | 			recovery_available: true, | 
 | 353 | 			vendor_available: true, | 
| Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 354 | 			vendor_ramdisk_available: true, | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 355 | 			product_available: true, | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 356 | 			native_bridge_supported: true, | 
 | 357 | 			stl: "none", | 
| Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame] | 358 | 			min_sdk_version: "16", | 
 | 359 | 			crt: true, | 
| Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 360 | 			system_shared_libs: [], | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 361 | 			apex_available: [ | 
 | 362 | 				"//apex_available:platform", | 
 | 363 | 				"//apex_available:anyapex", | 
 | 364 | 			], | 
 | 365 | 		} | 
 | 366 |  | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 367 | 		cc_object { | 
 | 368 | 			name: "crtbegin_so", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 369 | 			defaults: ["crt_defaults"], | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 370 | 			srcs: ["crtbegin_so.c"], | 
 | 371 | 			objs: ["crtbrand"], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 372 | 		} | 
 | 373 |  | 
 | 374 | 		cc_object { | 
| Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 375 | 			name: "crtbegin_dynamic", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 376 | 			defaults: ["crt_defaults"], | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 377 | 			srcs: ["crtbegin.c"], | 
 | 378 | 			objs: ["crtbrand"], | 
| Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 379 | 		} | 
 | 380 |  | 
 | 381 | 		cc_object { | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 382 | 			name: "crtbegin_static", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 383 | 			defaults: ["crt_defaults"], | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 384 | 			srcs: ["crtbegin.c"], | 
 | 385 | 			objs: ["crtbrand"], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 386 | 		} | 
 | 387 |  | 
 | 388 | 		cc_object { | 
 | 389 | 			name: "crtend_so", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 390 | 			defaults: ["crt_defaults"], | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 391 | 			srcs: ["crtend_so.c"], | 
 | 392 | 			objs: ["crtbrand"], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 393 | 		} | 
 | 394 |  | 
 | 395 | 		cc_object { | 
 | 396 | 			name: "crtend_android", | 
| Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 397 | 			defaults: ["crt_defaults"], | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 398 | 			srcs: ["crtend.c"], | 
 | 399 | 			objs: ["crtbrand"], | 
 | 400 | 		} | 
 | 401 |  | 
 | 402 | 		cc_object { | 
| Kalesh Singh | f4ffe0a | 2024-01-29 13:01:51 -0800 | [diff] [blame] | 403 | 			name: "crt_pad_segment", | 
 | 404 | 			defaults: ["crt_defaults"], | 
 | 405 | 		} | 
 | 406 |  | 
 | 407 | 		cc_object { | 
| Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 408 | 			name: "crtbrand", | 
 | 409 | 			defaults: ["crt_defaults"], | 
 | 410 | 			srcs: ["crtbrand.c"], | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 411 | 		} | 
 | 412 |  | 
 | 413 | 		cc_library { | 
 | 414 | 			name: "libprotobuf-cpp-lite", | 
 | 415 | 		} | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 416 |  | 
| Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 417 | 		ndk_library { | 
 | 418 | 			name: "libc", | 
 | 419 | 			first_version: "minimum", | 
 | 420 | 			symbol_file: "libc.map.txt", | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 421 | 		} | 
 | 422 |  | 
| Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 423 | 		ndk_library { | 
 | 424 | 			name: "libm", | 
 | 425 | 			first_version: "minimum", | 
 | 426 | 			symbol_file: "libm.map.txt", | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 427 | 		} | 
 | 428 |  | 
| Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 429 | 		ndk_library { | 
 | 430 | 			name: "libdl", | 
 | 431 | 			first_version: "minimum", | 
 | 432 | 			symbol_file: "libdl.map.txt", | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 433 | 		} | 
 | 434 |  | 
| Jiyong Park | 46a512f | 2020-12-04 18:02:13 +0900 | [diff] [blame] | 435 | 		cc_library_static { | 
 | 436 | 			name: "libgoogle-benchmark", | 
 | 437 | 			sdk_version: "current", | 
 | 438 | 			stl: "none", | 
 | 439 | 			system_shared_libs: [], | 
 | 440 | 		} | 
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 441 |  | 
 | 442 | 		cc_library_static { | 
 | 443 | 			name: "note_memtag_heap_async", | 
 | 444 | 		} | 
 | 445 |  | 
 | 446 | 		cc_library_static { | 
 | 447 | 			name: "note_memtag_heap_sync", | 
 | 448 | 		} | 
| Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 449 |  | 
| Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 450 | 		cc_library { | 
 | 451 | 			name: "libc_musl", | 
 | 452 | 			host_supported: true, | 
 | 453 | 			no_libcrt: true, | 
 | 454 | 			nocrt: true, | 
 | 455 | 			system_shared_libs: [], | 
 | 456 | 			stl: "none", | 
 | 457 | 		} | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 458 | 	` | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 459 | } | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 460 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 461 | func withWindowsModules() string { | 
 | 462 | 	return ` | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 463 | 		cc_prebuilt_library_static { | 
| Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 464 | 			name: "libwinpthread", | 
 | 465 | 			host_supported: true, | 
 | 466 | 			enabled: false, | 
 | 467 | 			target: { | 
 | 468 | 				windows: { | 
 | 469 | 					enabled: true, | 
 | 470 | 				}, | 
 | 471 | 			}, | 
| Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 472 | 			stl: "none", | 
 | 473 | 			srcs:[""], | 
| Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 474 | 		} | 
 | 475 | 		` | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 476 | } | 
 | 477 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 478 | func withLinuxBionic() string { | 
 | 479 | 	return ` | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 480 | 				cc_binary { | 
 | 481 | 					name: "linker", | 
 | 482 | 					defaults: ["linux_bionic_supported"], | 
 | 483 | 					recovery_available: true, | 
 | 484 | 					stl: "none", | 
 | 485 | 					nocrt: true, | 
 | 486 | 					static_executable: true, | 
 | 487 | 					native_coverage: false, | 
 | 488 | 					system_shared_libs: [], | 
 | 489 | 				} | 
 | 490 |  | 
 | 491 | 				cc_genrule { | 
| Colin Cross | 9cfe611 | 2021-06-11 18:02:22 -0700 | [diff] [blame] | 492 | 					name: "host_bionic_linker_script", | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 493 | 					host_supported: true, | 
 | 494 | 					device_supported: false, | 
 | 495 | 					target: { | 
 | 496 | 						host: { | 
 | 497 | 							enabled: false, | 
 | 498 | 						}, | 
 | 499 | 						linux_bionic: { | 
 | 500 | 							enabled: true, | 
 | 501 | 						}, | 
 | 502 | 					}, | 
| Colin Cross | 9cfe611 | 2021-06-11 18:02:22 -0700 | [diff] [blame] | 503 | 					out: ["linker.script"], | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 504 | 				} | 
 | 505 |  | 
 | 506 | 				cc_defaults { | 
 | 507 | 					name: "linux_bionic_supported", | 
 | 508 | 					host_supported: true, | 
 | 509 | 					target: { | 
 | 510 | 						host: { | 
 | 511 | 							enabled: false, | 
 | 512 | 						}, | 
 | 513 | 						linux_bionic: { | 
 | 514 | 							enabled: true, | 
 | 515 | 						}, | 
 | 516 | 					}, | 
 | 517 | 				} | 
 | 518 | 			` | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 519 | } | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 520 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 521 | func withoutLinuxBionic() string { | 
 | 522 | 	return ` | 
| Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 523 | 			cc_defaults { | 
 | 524 | 				name: "linux_bionic_supported", | 
 | 525 | 			} | 
 | 526 | 		` | 
| Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 527 | } | 
| Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 528 |  | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 529 | func GatherRequiredFilesForTest(fs map[string][]byte) { | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 530 | } | 
 | 531 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 532 | // The directory in which cc linux bionic default modules will be defined. | 
 | 533 | // | 
 | 534 | // Placing them here ensures that their location does not conflict with default test modules | 
 | 535 | // defined by other packages. | 
 | 536 | const linuxBionicDefaultsPath = "defaults/cc/linux-bionic/Android.bp" | 
 | 537 |  | 
 | 538 | // The directory in which the default cc common test modules will be defined. | 
 | 539 | // | 
 | 540 | // Placing them here ensures that their location does not conflict with default test modules | 
 | 541 | // defined by other packages. | 
 | 542 | const DefaultCcCommonTestModulesDir = "defaults/cc/common/" | 
 | 543 |  | 
 | 544 | // Test fixture preparer that will register most cc build components. | 
 | 545 | // | 
 | 546 | // Singletons and mutators should only be added here if they are needed for a majority of cc | 
 | 547 | // module types, otherwise they should be added under a separate preparer to allow them to be | 
 | 548 | // selected only when needed to reduce test execution time. | 
 | 549 | // | 
 | 550 | // Module types do not have much of an overhead unless they are used so this should include as many | 
 | 551 | // module types as possible. The exceptions are those module types that require mutators and/or | 
 | 552 | // singletons in order to function in which case they should be kept together in a separate | 
 | 553 | // preparer. | 
 | 554 | var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers( | 
 | 555 | 	android.PrepareForTestWithAndroidBuildComponents, | 
 | 556 | 	android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest), | 
 | 557 | 	android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { | 
| Cory Barker | a1da26f | 2022-06-07 20:12:06 +0000 | [diff] [blame] | 558 | 		ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory) | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 559 | 		ctx.RegisterModuleType("cc_test", TestFactory) | 
 | 560 | 		ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 561 | 		ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) | 
 | 562 |  | 
| Kiyoung Kim | 973cb6f | 2024-04-29 14:14:53 +0900 | [diff] [blame] | 563 | 		RegisterLlndkLibraryTxtType(ctx) | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 564 | 	}), | 
 | 565 | ) | 
 | 566 |  | 
 | 567 | // Preparer that will define default cc modules, e.g. standard prebuilt modules. | 
 | 568 | var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers( | 
 | 569 | 	PrepareForTestWithCcBuildComponents, | 
| Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 570 |  | 
 | 571 | 	// Additional files needed in tests that disallow non-existent source. | 
 | 572 | 	android.MockFS{ | 
| Ryan Prichard | 2a69eb6 | 2024-07-30 01:58:54 +0000 | [diff] [blame] | 573 | 		"defaults/cc/common/libc.map.txt":                   nil, | 
 | 574 | 		"defaults/cc/common/libdl.map.txt":                  nil, | 
 | 575 | 		"defaults/cc/common/libft2.map.txt":                 nil, | 
 | 576 | 		"defaults/cc/common/libm.map.txt":                   nil, | 
 | 577 | 		"defaults/cc/common/ndk_libc++_shared_include_dirs": nil, | 
 | 578 | 		"defaults/cc/common/crtbegin_so.c":                  nil, | 
 | 579 | 		"defaults/cc/common/crtbegin.c":                     nil, | 
 | 580 | 		"defaults/cc/common/crtend_so.c":                    nil, | 
 | 581 | 		"defaults/cc/common/crtend.c":                       nil, | 
 | 582 | 		"defaults/cc/common/crtbrand.c":                     nil, | 
 | 583 | 		"external/compiler-rt/lib/cfi/cfi_blocklist.txt":    nil, | 
| Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 584 |  | 
 | 585 | 		"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil, | 
 | 586 | 		"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a":   nil, | 
 | 587 | 		"defaults/cc/common/libclang_rt.ubsan_minimal.x86_64.a":        nil, | 
 | 588 | 		"defaults/cc/common/libclang_rt.ubsan_minimal.x86.a":           nil, | 
| Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 589 | 	}.AddToFixture(), | 
 | 590 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 591 | 	// Place the default cc test modules that are common to all platforms in a location that will not | 
 | 592 | 	// conflict with default test modules defined by other packages. | 
 | 593 | 	android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()), | 
 | 594 | 	// Disable linux bionic by default. | 
 | 595 | 	android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()), | 
 | 596 | ) | 
 | 597 |  | 
 | 598 | // Prepare a fixture to use all cc module types, mutators and singletons fully. | 
 | 599 | // | 
 | 600 | // This should only be used by tests that want to run with as much of the build enabled as possible. | 
 | 601 | var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers( | 
 | 602 | 	android.PrepareForIntegrationTestWithAndroid, | 
 | 603 | 	genrule.PrepareForIntegrationTestWithGenrule, | 
 | 604 | 	PrepareForTestWithCcDefaultModules, | 
 | 605 | ) | 
 | 606 |  | 
 | 607 | // The preparer to include if running a cc related test for windows. | 
 | 608 | var PrepareForTestOnWindows = android.GroupFixturePreparers( | 
 | 609 | 	// Place the default cc test modules for windows platforms in a location that will not conflict | 
 | 610 | 	// with default test modules defined by other packages. | 
 | 611 | 	android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()), | 
 | 612 | ) | 
 | 613 |  | 
 | 614 | // The preparer to include if running a cc related test for linux bionic. | 
 | 615 | var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers( | 
| Paul Duffin | 6e9a400 | 2021-03-11 19:01:26 +0000 | [diff] [blame] | 616 | 	// Enable linux bionic | 
 | 617 | 	// | 
 | 618 | 	// Can be used after PrepareForTestWithCcDefaultModules to override its default behavior of | 
 | 619 | 	// disabling linux bionic, hence why this uses FixtureOverrideTextFile. | 
 | 620 | 	android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()), | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 621 | ) | 
 | 622 |  | 
| Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 623 | // PrepareForTestWithHostMusl sets the host configuration to musl libc instead of glibc.  It also disables the test | 
 | 624 | // on mac, which doesn't support musl libc, and adds musl modules. | 
 | 625 | var PrepareForTestWithHostMusl = android.GroupFixturePreparers( | 
 | 626 | 	android.FixtureModifyConfig(android.ModifyTestConfigForMusl), | 
 | 627 | 	android.PrepareForSkipTestOnMac, | 
 | 628 | 	android.FixtureAddTextFile("external/musl/Android.bp", ` | 
 | 629 | 		cc_defaults { | 
 | 630 | 			name: "libc_musl_crt_defaults", | 
 | 631 | 			host_supported: true, | 
 | 632 | 			device_supported: false, | 
 | 633 | 		} | 
 | 634 |  | 
 | 635 | 		cc_object { | 
 | 636 | 			name: "libc_musl_crtbegin_so", | 
 | 637 | 			defaults: ["libc_musl_crt_defaults"], | 
 | 638 | 		} | 
 | 639 |  | 
 | 640 | 		cc_object { | 
 | 641 | 			name: "libc_musl_crtend_so", | 
 | 642 | 			defaults: ["libc_musl_crt_defaults"], | 
 | 643 | 		} | 
 | 644 |  | 
 | 645 | 		cc_object { | 
 | 646 | 			name: "libc_musl_crtbegin_dynamic", | 
 | 647 | 			defaults: ["libc_musl_crt_defaults"], | 
 | 648 | 		} | 
 | 649 |  | 
 | 650 | 		cc_object { | 
 | 651 | 			name: "libc_musl_crtbegin_static", | 
 | 652 | 			defaults: ["libc_musl_crt_defaults"], | 
 | 653 | 		} | 
 | 654 |  | 
 | 655 | 		cc_object { | 
 | 656 | 			name: "libc_musl_crtend", | 
 | 657 | 			defaults: ["libc_musl_crt_defaults"], | 
 | 658 | 		} | 
 | 659 | 	`), | 
 | 660 | ) | 
 | 661 |  | 
| Vinh Tran | cde1016 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 662 | // PrepareForTestWithFdoProfile registers module types to test with fdo_profile | 
 | 663 | var PrepareForTestWithFdoProfile = android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { | 
 | 664 | 	ctx.RegisterModuleType("soong_namespace", android.NamespaceFactory) | 
| Vinh Tran | ce40b92 | 2023-06-05 12:57:55 -0400 | [diff] [blame] | 665 | 	ctx.RegisterModuleType("fdo_profile", FdoProfileFactory) | 
| Vinh Tran | cde1016 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 666 | }) | 
 | 667 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 668 | // TestConfig is the legacy way of creating a test Config for testing cc modules. | 
 | 669 | // | 
 | 670 | // See testCc for an explanation as to how to stop using this deprecated method. | 
 | 671 | // | 
 | 672 | // deprecated | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 673 | func TestConfig(buildDir string, os android.OsType, env map[string]string, | 
 | 674 | 	bp string, fs map[string][]byte) android.Config { | 
| Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 675 |  | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 676 | 	// add some modules that are required by the compiler and/or linker | 
 | 677 | 	bp = bp + GatherRequiredDepsForTest(os) | 
 | 678 |  | 
| Colin Cross | 2fce23a | 2020-06-07 17:02:48 -0700 | [diff] [blame] | 679 | 	mockFS := map[string][]byte{} | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 680 |  | 
| Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 681 | 	GatherRequiredFilesForTest(mockFS) | 
 | 682 |  | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 683 | 	for k, v := range fs { | 
 | 684 | 		mockFS[k] = v | 
 | 685 | 	} | 
 | 686 |  | 
| Colin Cross | cb0ac95 | 2021-07-20 13:17:15 -0700 | [diff] [blame] | 687 | 	return android.TestArchConfig(buildDir, env, bp, mockFS) | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 688 | } | 
 | 689 |  | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 690 | // CreateTestContext is the legacy way of creating a TestContext for testing cc modules. | 
 | 691 | // | 
 | 692 | // See testCc for an explanation as to how to stop using this deprecated method. | 
 | 693 | // | 
 | 694 | // deprecated | 
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 695 | func CreateTestContext(config android.Config) *android.TestContext { | 
 | 696 | 	ctx := android.NewTestArchContext(config) | 
| Paul Duffin | d6ceb86 | 2021-03-04 23:02:31 +0000 | [diff] [blame] | 697 | 	genrule.RegisterGenruleBuildComponents(ctx) | 
| Cory Barker | a1da26f | 2022-06-07 20:12:06 +0000 | [diff] [blame] | 698 | 	ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory) | 
| Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 699 | 	ctx.RegisterModuleType("cc_test", TestFactory) | 
| Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 700 | 	ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) | 
| Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 701 | 	ctx.RegisterModuleType("filegroup", android.FileGroupFactory) | 
 | 702 | 	ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 703 |  | 
| Kiyoung Kim | 973cb6f | 2024-04-29 14:14:53 +0900 | [diff] [blame] | 704 | 	RegisterLlndkLibraryTxtType(ctx) | 
| Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 705 |  | 
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 706 | 	ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) | 
| Paul Duffin | 021f4e5 | 2020-07-30 16:04:17 +0100 | [diff] [blame] | 707 | 	android.RegisterPrebuiltMutators(ctx) | 
| Paul Duffin | c988c8e | 2020-04-29 18:27:14 +0100 | [diff] [blame] | 708 | 	RegisterRequiredBuildComponentsForTest(ctx) | 
| Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 709 |  | 
| Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 710 | 	return ctx | 
 | 711 | } | 
| Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 712 |  | 
 | 713 | func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) { | 
 | 714 | 	t.Helper() | 
 | 715 | 	mod := ctx.ModuleForTests(moduleName, variant) | 
| Yu Liu | 51c2231 | 2024-08-20 23:56:15 +0000 | [diff] [blame] | 716 | 	outputFiles := mod.OutputFiles(ctx, t, "") | 
| Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 717 | 	if len(outputFiles) != 1 { | 
 | 718 | 		t.Errorf("%q must have single output\n", moduleName) | 
 | 719 | 		return | 
 | 720 | 	} | 
 | 721 | 	snapshotPath := filepath.Join(subDir, snapshotFilename) | 
 | 722 |  | 
 | 723 | 	if include { | 
 | 724 | 		out := singleton.Output(snapshotPath) | 
 | 725 | 		if fake { | 
 | 726 | 			if out.Rule == nil { | 
 | 727 | 				t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0]) | 
 | 728 | 			} | 
 | 729 | 		} else { | 
 | 730 | 			if out.Input.String() != outputFiles[0].String() { | 
 | 731 | 				t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0]) | 
 | 732 | 			} | 
 | 733 | 		} | 
 | 734 | 	} else { | 
 | 735 | 		out := singleton.MaybeOutput(snapshotPath) | 
 | 736 | 		if out.Rule != nil { | 
 | 737 | 			t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0]) | 
 | 738 | 		} | 
 | 739 | 	} | 
 | 740 | } | 
 | 741 |  | 
 | 742 | func CheckSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { | 
 | 743 | 	t.Helper() | 
 | 744 | 	checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false) | 
 | 745 | } | 
 | 746 |  | 
 | 747 | func CheckSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { | 
 | 748 | 	t.Helper() | 
 | 749 | 	checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false) | 
 | 750 | } | 
 | 751 |  | 
 | 752 | func CheckSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { | 
 | 753 | 	t.Helper() | 
 | 754 | 	checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true) | 
 | 755 | } | 
 | 756 |  | 
| Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 757 | func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) { | 
 | 758 | 	for _, moduleName := range moduleNames { | 
 | 759 | 		module := ctx.ModuleForTests(moduleName, variant).Module().(*Module) | 
 | 760 | 		output := module.outputFile.Path().RelativeToTop() | 
 | 761 | 		paths = append(paths, output) | 
 | 762 | 	} | 
 | 763 | 	return paths | 
 | 764 | } |