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