Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [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 rust |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 19 | "android/soong/cc" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 20 | ) |
| 21 | |
| 22 | func GatherRequiredDepsForTest() string { |
| 23 | bp := ` |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 24 | rust_prebuilt_library { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 25 | name: "libstd_x86_64-unknown-linux-gnu", |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 26 | crate_name: "std", |
| 27 | rlib: { |
| 28 | srcs: ["libstd.rlib"], |
| 29 | }, |
| 30 | dylib: { |
| 31 | srcs: ["libstd.so"], |
| 32 | }, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 33 | host_supported: true, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 34 | sysroot: true, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 35 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 36 | rust_prebuilt_library { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 37 | name: "libtest_x86_64-unknown-linux-gnu", |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 38 | crate_name: "test", |
| 39 | rlib: { |
| 40 | srcs: ["libtest.rlib"], |
| 41 | }, |
| 42 | dylib: { |
| 43 | srcs: ["libtest.so"], |
| 44 | }, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 45 | host_supported: true, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 46 | sysroot: true, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 47 | } |
Thiébaud Weksteen | 83ee52f | 2020-08-05 09:29:23 +0200 | [diff] [blame] | 48 | rust_prebuilt_library { |
Ivan Lozano | c5d34ec | 2021-02-09 14:22:00 -0500 | [diff] [blame^] | 49 | name: "libstd_i686-unknown-linux-gnu", |
| 50 | crate_name: "std", |
| 51 | rlib: { |
| 52 | srcs: ["libstd.rlib"], |
| 53 | }, |
| 54 | dylib: { |
| 55 | srcs: ["libstd.so"], |
| 56 | }, |
| 57 | host_supported: true, |
| 58 | sysroot: true, |
| 59 | } |
| 60 | rust_prebuilt_library { |
| 61 | name: "libtest_i686-unknown-linux-gnu", |
| 62 | crate_name: "test", |
| 63 | rlib: { |
| 64 | srcs: ["libtest.rlib"], |
| 65 | }, |
| 66 | dylib: { |
| 67 | srcs: ["libtest.so"], |
| 68 | }, |
| 69 | host_supported: true, |
| 70 | sysroot: true, |
| 71 | } |
| 72 | rust_prebuilt_library { |
Thiébaud Weksteen | 83ee52f | 2020-08-05 09:29:23 +0200 | [diff] [blame] | 73 | name: "libstd_x86_64-apple-darwin", |
| 74 | crate_name: "std", |
| 75 | rlib: { |
| 76 | srcs: ["libstd.rlib"], |
| 77 | }, |
| 78 | dylib: { |
| 79 | srcs: ["libstd.so"], |
| 80 | }, |
| 81 | host_supported: true, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 82 | sysroot: true, |
Thiébaud Weksteen | 83ee52f | 2020-08-05 09:29:23 +0200 | [diff] [blame] | 83 | } |
| 84 | rust_prebuilt_library { |
| 85 | name: "libtest_x86_64-apple-darwin", |
| 86 | crate_name: "test", |
| 87 | rlib: { |
| 88 | srcs: ["libtest.rlib"], |
| 89 | }, |
| 90 | dylib: { |
| 91 | srcs: ["libtest.so"], |
| 92 | }, |
| 93 | host_supported: true, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 94 | sysroot: true, |
Thiébaud Weksteen | 83ee52f | 2020-08-05 09:29:23 +0200 | [diff] [blame] | 95 | } |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 96 | ////////////////////////////// |
| 97 | // Device module requirements |
| 98 | |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 99 | cc_library { |
| 100 | name: "liblog", |
| 101 | no_libcrt: true, |
| 102 | nocrt: true, |
| 103 | system_shared_libs: [], |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 104 | apex_available: ["//apex_available:platform", "//apex_available:anyapex"], |
Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 105 | min_sdk_version: "29", |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 106 | } |
Zach Johnson | 3df4e63 | 2020-11-06 11:56:27 -0800 | [diff] [blame] | 107 | cc_library { |
| 108 | name: "libprotobuf-cpp-full", |
| 109 | no_libcrt: true, |
| 110 | nocrt: true, |
| 111 | system_shared_libs: [], |
| 112 | export_include_dirs: ["libprotobuf-cpp-full-includes"], |
| 113 | } |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 114 | cc_library { |
| 115 | name: "libclang_rt.asan-aarch64-android", |
| 116 | no_libcrt: true, |
| 117 | nocrt: true, |
| 118 | system_shared_libs: [], |
| 119 | export_include_dirs: ["libprotobuf-cpp-full-includes"], |
| 120 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 121 | rust_library { |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 122 | name: "libstd", |
| 123 | crate_name: "std", |
| 124 | srcs: ["foo.rs"], |
| 125 | no_stdlibs: true, |
Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 126 | host_supported: true, |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 127 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 128 | vendor_ramdisk_available: true, |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 129 | native_coverage: false, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 130 | sysroot: true, |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 131 | apex_available: ["//apex_available:platform", "//apex_available:anyapex"], |
Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 132 | min_sdk_version: "29", |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 133 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 134 | rust_library { |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 135 | name: "libtest", |
| 136 | crate_name: "test", |
| 137 | srcs: ["foo.rs"], |
| 138 | no_stdlibs: true, |
Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 139 | host_supported: true, |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 140 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 141 | vendor_ramdisk_available: true, |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 142 | native_coverage: false, |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 143 | sysroot: true, |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 144 | apex_available: ["//apex_available:platform", "//apex_available:anyapex"], |
Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 145 | min_sdk_version: "29", |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 146 | } |
Treehugger Robot | 588aae7 | 2020-08-21 10:01:58 +0000 | [diff] [blame] | 147 | rust_library { |
| 148 | name: "libprotobuf", |
| 149 | crate_name: "protobuf", |
| 150 | srcs: ["foo.rs"], |
| 151 | host_supported: true, |
| 152 | } |
Zach Johnson | 3df4e63 | 2020-11-06 11:56:27 -0800 | [diff] [blame] | 153 | rust_library { |
| 154 | name: "libgrpcio", |
| 155 | crate_name: "grpcio", |
| 156 | srcs: ["foo.rs"], |
| 157 | host_supported: true, |
| 158 | } |
| 159 | rust_library { |
| 160 | name: "libfutures", |
| 161 | crate_name: "futures", |
| 162 | srcs: ["foo.rs"], |
| 163 | host_supported: true, |
| 164 | } |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 165 | rust_library { |
| 166 | name: "liblibfuzzer_sys", |
| 167 | crate_name: "libfuzzer_sys", |
| 168 | srcs:["foo.rs"], |
| 169 | host_supported: true, |
| 170 | } |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 171 | ` |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 172 | return bp |
| 173 | } |
| 174 | |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 175 | func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 176 | ctx.RegisterModuleType("rust_binary", RustBinaryFactory) |
| 177 | ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory) |
Ivan Lozano | 4fef93c | 2020-07-08 08:39:44 -0400 | [diff] [blame] | 178 | ctx.RegisterModuleType("rust_bindgen", RustBindgenFactory) |
Thiébaud Weksteen | a6351ca | 2020-09-29 09:53:21 +0200 | [diff] [blame] | 179 | ctx.RegisterModuleType("rust_bindgen_host", RustBindgenHostFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 180 | ctx.RegisterModuleType("rust_test", RustTestFactory) |
| 181 | ctx.RegisterModuleType("rust_test_host", RustTestHostFactory) |
| 182 | ctx.RegisterModuleType("rust_library", RustLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 183 | ctx.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory) |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 184 | ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory) |
| 185 | ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory) |
| 186 | ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory) |
| 187 | ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory) |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 188 | ctx.RegisterModuleType("rust_fuzz", RustFuzzFactory) |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 189 | ctx.RegisterModuleType("rust_ffi", RustFFIFactory) |
| 190 | ctx.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory) |
| 191 | ctx.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory) |
| 192 | ctx.RegisterModuleType("rust_ffi_host", RustFFIHostFactory) |
| 193 | ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory) |
| 194 | ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 195 | ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory) |
Treehugger Robot | 588aae7 | 2020-08-21 10:01:58 +0000 | [diff] [blame] | 196 | ctx.RegisterModuleType("rust_protobuf", RustProtobufFactory) |
| 197 | ctx.RegisterModuleType("rust_protobuf_host", RustProtobufHostFactory) |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 198 | ctx.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 199 | ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory) |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 200 | ctx.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 201 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 202 | // rust mutators |
| 203 | ctx.BottomUp("rust_libraries", LibraryMutator).Parallel() |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 204 | ctx.BottomUp("rust_stdlinkage", LibstdMutator).Parallel() |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 205 | ctx.BottomUp("rust_begin", BeginMutator).Parallel() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 206 | }) |
Thiébaud Weksteen | e4d12a0 | 2020-06-05 11:09:27 +0200 | [diff] [blame] | 207 | ctx.RegisterSingletonType("rust_project_generator", rustProjectGeneratorSingleton) |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | func CreateTestContext(config android.Config) *android.TestContext { |
| 211 | ctx := android.NewTestArchContext(config) |
| 212 | android.RegisterPrebuiltMutators(ctx) |
| 213 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
| 214 | cc.RegisterRequiredBuildComponentsForTest(ctx) |
| 215 | RegisterRequiredBuildComponentsForTest(ctx) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 216 | |
| 217 | return ctx |
| 218 | } |