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