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