blob: c3a462553d79cb68cd33fe6ce0ffd34d7af57876 [file] [log] [blame]
Ivan Lozanoffee3342019-08-27 12:03:00 -07001// 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
15package rust
16
17import (
18 "android/soong/android"
Ivan Lozanob9040d62019-09-24 13:23:50 -070019 "android/soong/cc"
Ivan Lozanoffee3342019-08-27 12:03:00 -070020)
21
22func GatherRequiredDepsForTest() string {
23 bp := `
24 rust_prebuilt_dylib {
Ivan Lozanoffee3342019-08-27 12:03:00 -070025 name: "libstd_x86_64-unknown-linux-gnu",
26 srcs: [""],
27 host_supported: true,
28 }
29 rust_prebuilt_dylib {
Ivan Lozanoffee3342019-08-27 12:03:00 -070030 name: "libtest_x86_64-unknown-linux-gnu",
31 srcs: [""],
32 host_supported: true,
33 }
Ivan Lozanob9040d62019-09-24 13:23:50 -070034
35 //////////////////////////////
36 // Device module requirements
37
Ivan Lozanob9040d62019-09-24 13:23:50 -070038 cc_library {
39 name: "liblog",
40 no_libcrt: true,
41 nocrt: true,
42 system_shared_libs: [],
43 }
Ivan Lozano2f15bae2020-04-09 09:32:15 -040044 rust_library_dylib {
45 name: "libstd",
46 crate_name: "std",
47 srcs: ["foo.rs"],
48 no_stdlibs: true,
49 }
50 rust_library_rlib {
51 name: "libstd.static",
52 crate_name: "std",
53 srcs: ["foo.rs"],
54 no_stdlibs: true,
55 }
56 rust_library_dylib {
57 name: "libtest",
58 crate_name: "test",
59 srcs: ["foo.rs"],
60 no_stdlibs: true,
61 }
62 rust_library_rlib {
63 name: "libtest.static",
64 crate_name: "test",
65 srcs: ["foo.rs"],
66 no_stdlibs: true,
67 }
68
Paul Duffin77980a82019-12-19 16:01:36 +000069` + cc.GatherRequiredDepsForTest(android.NoOsType)
Ivan Lozanoffee3342019-08-27 12:03:00 -070070 return bp
71}
72
Colin Cross98be1bb2019-12-13 20:41:13 -080073func CreateTestContext() *android.TestContext {
Ivan Lozanoffee3342019-08-27 12:03:00 -070074 ctx := android.NewTestArchContext()
Paul Duffin77980a82019-12-19 16:01:36 +000075 cc.RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -080076 ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
77 ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
78 ctx.RegisterModuleType("rust_test", RustTestFactory)
79 ctx.RegisterModuleType("rust_test_host", RustTestHostFactory)
80 ctx.RegisterModuleType("rust_library", RustLibraryFactory)
81 ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory)
82 ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
83 ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
84 ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory)
85 ctx.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory)
86 ctx.RegisterModuleType("rust_library_shared", RustLibrarySharedFactory)
87 ctx.RegisterModuleType("rust_library_static", RustLibraryStaticFactory)
88 ctx.RegisterModuleType("rust_library_host_shared", RustLibrarySharedHostFactory)
89 ctx.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
90 ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
91 ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
Ivan Lozanoffee3342019-08-27 12:03:00 -070092 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Ivan Lozano52767be2019-10-18 14:49:46 -070093 // rust mutators
94 ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
Chih-Hung Hsieha5f22ed2019-10-24 20:47:54 -070095 ctx.BottomUp("rust_unit_tests", TestPerSrcMutator).Parallel()
Ivan Lozano52767be2019-10-18 14:49:46 -070096 })
Ivan Lozanoffee3342019-08-27 12:03:00 -070097
98 return ctx
99}