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