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, |
| 34 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 35 | rust_prebuilt_library { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 36 | name: "libtest_x86_64-unknown-linux-gnu", |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 37 | crate_name: "test", |
| 38 | rlib: { |
| 39 | srcs: ["libtest.rlib"], |
| 40 | }, |
| 41 | dylib: { |
| 42 | srcs: ["libtest.so"], |
| 43 | }, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 44 | host_supported: true, |
| 45 | } |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 46 | |
| 47 | ////////////////////////////// |
| 48 | // Device module requirements |
| 49 | |
Ivan Lozano | b9040d6 | 2019-09-24 13:23:50 -0700 | [diff] [blame] | 50 | cc_library { |
| 51 | name: "liblog", |
| 52 | no_libcrt: true, |
| 53 | nocrt: true, |
| 54 | system_shared_libs: [], |
| 55 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 56 | rust_library { |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 57 | name: "libstd", |
| 58 | crate_name: "std", |
| 59 | srcs: ["foo.rs"], |
| 60 | no_stdlibs: true, |
Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 61 | host_supported: true, |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 62 | native_coverage: false, |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 63 | } |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 64 | rust_library { |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 65 | name: "libtest", |
| 66 | crate_name: "test", |
| 67 | srcs: ["foo.rs"], |
| 68 | no_stdlibs: true, |
Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 69 | host_supported: true, |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 70 | native_coverage: false, |
Ivan Lozano | 2f15bae | 2020-04-09 09:32:15 -0400 | [diff] [blame] | 71 | } |
| 72 | |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 73 | ` + cc.GatherRequiredDepsForTest(android.NoOsType) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 74 | return bp |
| 75 | } |
| 76 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 77 | func CreateTestContext() *android.TestContext { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 78 | ctx := android.NewTestArchContext() |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 79 | cc.RegisterRequiredBuildComponentsForTest(ctx) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 80 | ctx.RegisterModuleType("rust_binary", RustBinaryFactory) |
| 81 | ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory) |
| 82 | ctx.RegisterModuleType("rust_test", RustTestFactory) |
| 83 | ctx.RegisterModuleType("rust_test_host", RustTestHostFactory) |
| 84 | ctx.RegisterModuleType("rust_library", RustLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 85 | ctx.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory) |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 86 | ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory) |
| 87 | ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory) |
| 88 | ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory) |
| 89 | ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory) |
| 90 | ctx.RegisterModuleType("rust_ffi", RustFFIFactory) |
| 91 | ctx.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory) |
| 92 | ctx.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory) |
| 93 | ctx.RegisterModuleType("rust_ffi_host", RustFFIHostFactory) |
| 94 | ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory) |
| 95 | ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 96 | ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory) |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 97 | ctx.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 98 | ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory) |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame^] | 99 | ctx.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 100 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 101 | // rust mutators |
| 102 | ctx.BottomUp("rust_libraries", LibraryMutator).Parallel() |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 103 | ctx.BottomUp("rust_begin", BeginMutator).Parallel() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 104 | }) |
ThiƩbaud Weksteen | e4d12a0 | 2020-06-05 11:09:27 +0200 | [diff] [blame] | 105 | ctx.RegisterSingletonType("rust_project_generator", rustProjectGeneratorSingleton) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 106 | |
| 107 | return ctx |
| 108 | } |