blob: f9adec828db4f6da1784a91bee879316e004c9b9 [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 {
25 name: "libarena_x86_64-unknown-linux-gnu",
26 srcs: [""],
27 host_supported: true,
28 }
29 rust_prebuilt_dylib {
30 name: "libfmt_macros_x86_64-unknown-linux-gnu",
31 srcs: [""],
32 host_supported: true,
33 }
34 rust_prebuilt_dylib {
35 name: "libgraphviz_x86_64-unknown-linux-gnu",
36 srcs: [""],
37 host_supported: true,
38 }
39 rust_prebuilt_dylib {
40 name: "libserialize_x86_64-unknown-linux-gnu",
41 srcs: [""],
42 host_supported: true,
43 }
44 rust_prebuilt_dylib {
45 name: "libstd_x86_64-unknown-linux-gnu",
46 srcs: [""],
47 host_supported: true,
48 }
49 rust_prebuilt_dylib {
50 name: "libsyntax_x86_64-unknown-linux-gnu",
51 srcs: [""],
52 host_supported: true,
53 }
54 rust_prebuilt_dylib {
55 name: "libsyntax_ext_x86_64-unknown-linux-gnu",
56 srcs: [""],
57 host_supported: true,
58 }
59 rust_prebuilt_dylib {
60 name: "libsyntax_pos_x86_64-unknown-linux-gnu",
61 srcs: [""],
62 host_supported: true,
63 }
64 rust_prebuilt_dylib {
65 name: "libterm_x86_64-unknown-linux-gnu",
66 srcs: [""],
67 host_supported: true,
68 }
69 rust_prebuilt_dylib {
70 name: "libtest_x86_64-unknown-linux-gnu",
71 srcs: [""],
72 host_supported: true,
73 }
Ivan Lozanob9040d62019-09-24 13:23:50 -070074
75 //////////////////////////////
76 // Device module requirements
77
Ivan Lozanob9040d62019-09-24 13:23:50 -070078 cc_library {
79 name: "liblog",
80 no_libcrt: true,
81 nocrt: true,
82 system_shared_libs: [],
83 }
Paul Duffin77980a82019-12-19 16:01:36 +000084` + cc.GatherRequiredDepsForTest(android.NoOsType)
Ivan Lozanoffee3342019-08-27 12:03:00 -070085 return bp
86}
87
Colin Cross98be1bb2019-12-13 20:41:13 -080088func CreateTestContext() *android.TestContext {
Ivan Lozanoffee3342019-08-27 12:03:00 -070089 ctx := android.NewTestArchContext()
Paul Duffin77980a82019-12-19 16:01:36 +000090 cc.RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -080091 ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
92 ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
93 ctx.RegisterModuleType("rust_test", RustTestFactory)
94 ctx.RegisterModuleType("rust_test_host", RustTestHostFactory)
95 ctx.RegisterModuleType("rust_library", RustLibraryFactory)
96 ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory)
97 ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
98 ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
99 ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory)
100 ctx.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory)
101 ctx.RegisterModuleType("rust_library_shared", RustLibrarySharedFactory)
102 ctx.RegisterModuleType("rust_library_static", RustLibraryStaticFactory)
103 ctx.RegisterModuleType("rust_library_host_shared", RustLibrarySharedHostFactory)
104 ctx.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
105 ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
106 ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700107 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Ivan Lozano52767be2019-10-18 14:49:46 -0700108 // rust mutators
109 ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
Chih-Hung Hsieha5f22ed2019-10-24 20:47:54 -0700110 ctx.BottomUp("rust_unit_tests", TestPerSrcMutator).Parallel()
Ivan Lozano52767be2019-10-18 14:49:46 -0700111 })
Ivan Lozanoffee3342019-08-27 12:03:00 -0700112
113 return ctx
114}