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 ( |
| 18 | "android/soong/android" |
| 19 | ) |
| 20 | |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 21 | func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 22 | RegisterPrebuiltBuildComponents(ctx) |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 23 | android.RegisterPrebuiltMutators(ctx) |
Paul Duffin | 075c417 | 2019-12-19 19:06:13 +0000 | [diff] [blame] | 24 | |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 25 | RegisterCCBuildComponents(ctx) |
Paul Duffin | 2ee6979 | 2020-01-16 12:14:42 +0000 | [diff] [blame] | 26 | RegisterBinaryBuildComponents(ctx) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 27 | RegisterLibraryBuildComponents(ctx) |
| 28 | |
| 29 | ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory) |
| 30 | ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory) |
| 31 | ctx.RegisterModuleType("cc_object", ObjectFactory) |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame^] | 32 | ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory) |
| 33 | ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory) |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 36 | func GatherRequiredDepsForTest(os android.OsType) string { |
| 37 | ret := ` |
| 38 | toolchain_library { |
| 39 | name: "libatomic", |
| 40 | vendor_available: true, |
| 41 | recovery_available: true, |
| 42 | src: "", |
| 43 | } |
| 44 | |
| 45 | toolchain_library { |
| 46 | name: "libcompiler_rt-extras", |
| 47 | vendor_available: true, |
| 48 | recovery_available: true, |
| 49 | src: "", |
| 50 | } |
| 51 | |
| 52 | toolchain_library { |
| 53 | name: "libclang_rt.builtins-arm-android", |
| 54 | vendor_available: true, |
| 55 | recovery_available: true, |
| 56 | src: "", |
| 57 | } |
| 58 | |
| 59 | toolchain_library { |
| 60 | name: "libclang_rt.builtins-aarch64-android", |
| 61 | vendor_available: true, |
| 62 | recovery_available: true, |
| 63 | src: "", |
| 64 | } |
| 65 | |
| 66 | toolchain_library { |
| 67 | name: "libclang_rt.builtins-i686-android", |
| 68 | vendor_available: true, |
| 69 | recovery_available: true, |
| 70 | src: "", |
| 71 | } |
| 72 | |
| 73 | toolchain_library { |
| 74 | name: "libclang_rt.builtins-x86_64-android", |
| 75 | vendor_available: true, |
| 76 | recovery_available: true, |
| 77 | src: "", |
| 78 | } |
| 79 | |
| 80 | toolchain_library { |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 81 | name: "libclang_rt.fuzzer-arm-android", |
| 82 | vendor_available: true, |
| 83 | recovery_available: true, |
| 84 | src: "", |
| 85 | } |
| 86 | |
| 87 | toolchain_library { |
| 88 | name: "libclang_rt.fuzzer-aarch64-android", |
| 89 | vendor_available: true, |
| 90 | recovery_available: true, |
| 91 | src: "", |
| 92 | } |
| 93 | |
| 94 | toolchain_library { |
| 95 | name: "libclang_rt.fuzzer-i686-android", |
| 96 | vendor_available: true, |
| 97 | recovery_available: true, |
| 98 | src: "", |
| 99 | } |
| 100 | |
| 101 | toolchain_library { |
| 102 | name: "libclang_rt.fuzzer-x86_64-android", |
| 103 | vendor_available: true, |
| 104 | recovery_available: true, |
| 105 | src: "", |
| 106 | } |
| 107 | |
| 108 | toolchain_library { |
| 109 | name: "libclang_rt.fuzzer-x86_64", |
| 110 | vendor_available: true, |
| 111 | recovery_available: true, |
| 112 | src: "", |
| 113 | } |
| 114 | |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 115 | // Needed for sanitizer |
| 116 | cc_prebuilt_library_shared { |
| 117 | name: "libclang_rt.ubsan_standalone-aarch64-android", |
| 118 | vendor_available: true, |
| 119 | recovery_available: true, |
| 120 | srcs: [""], |
| 121 | } |
| 122 | |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 123 | toolchain_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 124 | name: "libgcc", |
| 125 | vendor_available: true, |
| 126 | recovery_available: true, |
| 127 | src: "", |
| 128 | } |
| 129 | |
Yi Kong | acee27c | 2019-03-29 20:05:14 -0700 | [diff] [blame] | 130 | toolchain_library { |
| 131 | name: "libgcc_stripped", |
| 132 | vendor_available: true, |
| 133 | recovery_available: true, |
| 134 | src: "", |
| 135 | } |
| 136 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 137 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 138 | name: "libc", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 139 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 140 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 141 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 142 | system_shared_libs: [], |
| 143 | recovery_available: true, |
| 144 | } |
| 145 | llndk_library { |
| 146 | name: "libc", |
| 147 | symbol_file: "", |
| 148 | } |
| 149 | cc_library { |
| 150 | name: "libm", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 151 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 152 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 153 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 154 | system_shared_libs: [], |
| 155 | recovery_available: true, |
| 156 | } |
| 157 | llndk_library { |
| 158 | name: "libm", |
| 159 | symbol_file: "", |
| 160 | } |
| 161 | cc_library { |
| 162 | name: "libdl", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 163 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 164 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 165 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 166 | system_shared_libs: [], |
| 167 | recovery_available: true, |
| 168 | } |
| 169 | llndk_library { |
| 170 | name: "libdl", |
| 171 | symbol_file: "", |
| 172 | } |
| 173 | cc_library { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 174 | name: "libft2", |
| 175 | no_libcrt: true, |
| 176 | nocrt: true, |
| 177 | system_shared_libs: [], |
| 178 | recovery_available: true, |
| 179 | } |
| 180 | llndk_library { |
| 181 | name: "libft2", |
| 182 | symbol_file: "", |
| 183 | vendor_available: false, |
| 184 | } |
| 185 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 186 | name: "libc++_static", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 187 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 188 | nocrt: true, |
| 189 | system_shared_libs: [], |
| 190 | stl: "none", |
| 191 | vendor_available: true, |
| 192 | recovery_available: true, |
| 193 | } |
| 194 | cc_library { |
| 195 | name: "libc++", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 196 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 197 | nocrt: true, |
| 198 | system_shared_libs: [], |
| 199 | stl: "none", |
| 200 | vendor_available: true, |
| 201 | recovery_available: true, |
| 202 | vndk: { |
| 203 | enabled: true, |
| 204 | support_system_process: true, |
| 205 | }, |
| 206 | } |
| 207 | cc_library { |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 208 | name: "libc++demangle", |
| 209 | no_libcrt: true, |
| 210 | nocrt: true, |
| 211 | system_shared_libs: [], |
| 212 | stl: "none", |
| 213 | host_supported: false, |
| 214 | vendor_available: true, |
| 215 | recovery_available: true, |
| 216 | } |
| 217 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 218 | name: "libunwind_llvm", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 219 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 220 | nocrt: true, |
| 221 | system_shared_libs: [], |
| 222 | stl: "none", |
| 223 | vendor_available: true, |
| 224 | recovery_available: true, |
| 225 | } |
| 226 | |
| 227 | cc_object { |
| 228 | name: "crtbegin_so", |
| 229 | recovery_available: true, |
| 230 | vendor_available: true, |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 231 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | cc_object { |
Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 235 | name: "crtbegin_dynamic", |
| 236 | recovery_available: true, |
| 237 | vendor_available: true, |
| 238 | } |
| 239 | |
| 240 | cc_object { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 241 | name: "crtbegin_static", |
| 242 | recovery_available: true, |
| 243 | vendor_available: true, |
| 244 | } |
| 245 | |
| 246 | cc_object { |
| 247 | name: "crtend_so", |
| 248 | recovery_available: true, |
| 249 | vendor_available: true, |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 250 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | cc_object { |
| 254 | name: "crtend_android", |
| 255 | recovery_available: true, |
| 256 | vendor_available: true, |
| 257 | } |
| 258 | |
| 259 | cc_library { |
| 260 | name: "libprotobuf-cpp-lite", |
| 261 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame^] | 262 | |
| 263 | cc_library { |
| 264 | name: "ndk_libunwind", |
| 265 | sdk_version: "current", |
| 266 | stl: "none", |
| 267 | system_shared_libs: [], |
| 268 | } |
| 269 | |
| 270 | cc_library { |
| 271 | name: "libc.ndk.current", |
| 272 | sdk_version: "current", |
| 273 | stl: "none", |
| 274 | system_shared_libs: [], |
| 275 | } |
| 276 | |
| 277 | cc_library { |
| 278 | name: "libm.ndk.current", |
| 279 | sdk_version: "current", |
| 280 | stl: "none", |
| 281 | system_shared_libs: [], |
| 282 | } |
| 283 | |
| 284 | cc_library { |
| 285 | name: "libdl.ndk.current", |
| 286 | sdk_version: "current", |
| 287 | stl: "none", |
| 288 | system_shared_libs: [], |
| 289 | } |
| 290 | |
| 291 | ndk_prebuilt_object { |
| 292 | name: "ndk_crtbegin_so.27", |
| 293 | sdk_version: "27", |
| 294 | } |
| 295 | |
| 296 | ndk_prebuilt_object { |
| 297 | name: "ndk_crtend_so.27", |
| 298 | sdk_version: "27", |
| 299 | } |
| 300 | |
| 301 | ndk_prebuilt_shared_stl { |
| 302 | name: "ndk_libc++_shared", |
| 303 | } |
| 304 | ` |
| 305 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 306 | if os == android.Fuchsia { |
| 307 | ret += ` |
| 308 | cc_library { |
| 309 | name: "libbioniccompat", |
| 310 | stl: "none", |
| 311 | } |
| 312 | cc_library { |
| 313 | name: "libcompiler_rt", |
| 314 | stl: "none", |
| 315 | } |
| 316 | ` |
| 317 | } |
| 318 | return ret |
| 319 | } |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 320 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame^] | 321 | func GatherRequiredFilesForTest(fs map[string][]byte) { |
| 322 | fs["prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so"] = nil |
| 323 | fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtbegin_so.o"] = nil |
| 324 | fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtend_so.o"] = nil |
| 325 | fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtbegin_so.o"] = nil |
| 326 | fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtend_so.o"] = nil |
| 327 | fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtbegin_so.o"] = nil |
| 328 | fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtend_so.o"] = nil |
| 329 | fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtbegin_so.o"] = nil |
| 330 | fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtend_so.o"] = nil |
| 331 | } |
| 332 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 333 | func TestConfig(buildDir string, os android.OsType, env map[string]string, |
| 334 | bp string, fs map[string][]byte) android.Config { |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 335 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 336 | // add some modules that are required by the compiler and/or linker |
| 337 | bp = bp + GatherRequiredDepsForTest(os) |
| 338 | |
| 339 | mockFS := map[string][]byte{ |
| 340 | "foo.c": nil, |
| 341 | "foo.lds": nil, |
| 342 | "bar.c": nil, |
| 343 | "baz.c": nil, |
| 344 | "baz.o": nil, |
| 345 | "a.proto": nil, |
| 346 | "b.aidl": nil, |
| 347 | "sub/c.aidl": nil, |
| 348 | "my_include": nil, |
| 349 | "foo.map.txt": nil, |
| 350 | "liba.so": nil, |
| 351 | } |
| 352 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame^] | 353 | GatherRequiredFilesForTest(mockFS) |
| 354 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 355 | for k, v := range fs { |
| 356 | mockFS[k] = v |
| 357 | } |
| 358 | |
| 359 | var config android.Config |
| 360 | if os == android.Fuchsia { |
| 361 | config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS) |
| 362 | } else { |
| 363 | config = android.TestArchConfig(buildDir, env, bp, mockFS) |
| 364 | } |
| 365 | |
| 366 | return config |
| 367 | } |
| 368 | |
| 369 | func CreateTestContext() *android.TestContext { |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 370 | ctx := android.NewTestArchContext() |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 371 | ctx.RegisterModuleType("cc_fuzz", FuzzFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 372 | ctx.RegisterModuleType("cc_test", TestFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 373 | ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory) |
Jooyung Han | b90e491 | 2019-12-09 18:21:48 +0900 | [diff] [blame] | 374 | ctx.RegisterModuleType("ndk_library", NdkLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 375 | ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 376 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
| 377 | ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) |
| 378 | ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory) |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 379 | RegisterRequiredBuildComponentsForTest(ctx) |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 380 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 381 | ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton) |
Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 382 | ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton) |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 383 | |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 384 | return ctx |
| 385 | } |