1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
mojo / public / rust / BUILD.gn [blame]
# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/rust.gni")
import("//build/rust/rust_bindgen.gni")
import("//build/rust/rust_static_library.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")
# Meta target to build everything
group("mojo_rust") {
deps = [ ":mojo" ]
}
# These tests require real mojo and can't be mixed with test-only mojo. Mojo can
# only be initialized once per process, and can't change modes.
test("mojo_rust_integration_unittests") {
deps = [
"//base/test:run_all_unittests",
"//mojo/public/rust/tests:mojo_rust_system_tests",
"//testing/gtest",
]
}
# These tests use stubbed out test-only mojo and can't be mixed with real mojo.
# Mojo can only be initialized once per process, and can't change modes.
test("mojo_rust_unittests") {
deps = [
"//base/test:run_all_unittests",
"//testing/gtest",
]
if (enable_rust_mojom_bindings) {
deps += [ "//mojo/public/rust/tests:mojo_rust_bindings_tests" ]
}
}
source_set("mojo_c_system_wrapper") {
sources = [ "system/wrapper.h" ]
deps = [ "//mojo/public/c/system:headers" ]
visibility = [ ":*" ]
}
rust_bindgen("mojo_c_system_binding") {
header = "system/wrapper.h"
deps = [ ":mojo_c_system_wrapper" ]
visibility = [ ":*" ]
}
rust_static_library("mojo_system") {
crate_root = "system/lib.rs"
allow_unsafe = true
# This should be removed; we should not rely on unstable features. But it's in
# experimental code and won't block compiler rolls. If it becomes a problem
# just disable the whole build target.
configs -= [ "//build/config/compiler:disallow_unstable_features" ]
rustflags = [ "-Zallow-features=maybe_uninit_slice" ]
sources = [
"system/core.rs",
"system/data_pipe.rs",
"system/ffi.rs",
"system/handle.rs",
"system/lib.rs",
"system/message_pipe.rs",
"system/mojo_types.rs",
"system/shared_buffer.rs",
"system/trap.rs",
"system/wait.rs",
"system/wait_set.rs",
]
deps = [
":mojo_c_system_binding",
":mojo_c_system_wrapper",
"//mojo/public/c/system",
"//third_party/rust/bitflags/v2:lib",
]
# TODO(crbug.com/369430130): reenable this warning.
rustflags += [ "-Aimproper-ctypes" ]
}
rust_static_library("mojo_system_test_support") {
testonly = true
crate_root = "system/test_support/lib.rs"
# Calls Mojo FFI functions.
allow_unsafe = true
sources = [ "system/test_support/lib.rs" ]
deps = [
":mojo_system",
"//mojo/public/c/system",
]
}
rust_static_library("mojo_bindings") {
crate_root = "bindings/lib.rs"
allow_unsafe = true
sources = [
"bindings/data.rs",
"bindings/lib.rs",
"bindings/mojom.rs",
]
deps = [
":mojo_system",
"//third_party/rust/bitflags/v2:lib",
"//third_party/rust/bytemuck/v1:lib",
"//third_party/rust/static_assertions/v1:lib",
]
}
# Convenience target to link both Mojo Rust components and reexport them under a
# single `mojo` name.
rust_static_library("mojo") {
crate_root = "lib.rs"
sources = [ "lib.rs" ]
deps = [
":mojo_bindings",
":mojo_system",
]
}