blob: a5933d96a34b9b082d6df7fd5e0157ed1e2186ad [file]
# Copyright 2026 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/rust/rust_bindgen.gni")
import("//build/rust/rust_executable.gni")
import("//build/rust/rust_static_library.gni")
rust_static_library("system") {
crate_root = "lib.rs"
sources = [
"data_pipe.rs",
"lib.rs",
"message.rs",
"message_pipe.rs",
"mojo_types.rs",
"raw_trap.rs",
"scoped_handle_interop.rs",
"trap.rs",
]
cxx_bindings = [ "scoped_handle_interop.rs" ]
allow_unsafe = true
deps = [
":ffi_bindings",
"//base",
"//third_party/rust/bitflags/v2:lib",
"//third_party/rust/cxx/v1:lib",
]
public_deps = [ ":scoped_handle_interop_cc" ]
}
source_set("scoped_handle_interop_cc") {
sources = [
"scoped_handle_interop.cc",
"scoped_handle_interop.h",
]
deps = [
"//base",
"//mojo/public/cpp/system",
]
}
# FOR_RELEASE: This deserves to be its own top-level folder at this point,
# rather than a subfolder of //system. But what should it be called?
# Unlike C++, we've got three layers on top of the C bindings:
# 1. (mostly) Safe, idiomatic, but still low-level FFI bindings (system/ffi)
# 2. Ergonomic, mid-level bindings (system)
# 3. High-level, often Mojom-specific code (bindings)
# C++ just has (2) and (3), building (2) directly on the C code.
rust_static_library("ffi_bindings") {
crate_root = "ffi/lib.rs"
sources = [
"ffi/data_pipe.rs",
"ffi/functions.rs",
"ffi/handles.rs",
"ffi/internal_options.rs",
"ffi/lib.rs",
"ffi/message.rs",
"ffi/message_pipe.rs",
"ffi/result.rs",
"ffi/trap.rs",
]
deps = [
":mojo_c_system_bindings",
"//third_party/rust/bitflags/v2:lib",
"//third_party/rust/static_assertions/v1:lib",
"//third_party/rust/strum/v0_28:lib",
]
allow_unsafe = true
}
rust_bindgen("mojo_c_system_bindings") {
header = "//mojo/public/c/system/thunks.h"
deps = [ "//mojo/public/c/system" ]
visibility = [ ":*" ]
}
rust_static_library("system_bindings_unittests") {
testonly = true
is_gtest_unittests = true
crate_root = "test/lib.rs"
sources = [
"test/core_api_unittests.rs",
"test/lib.rs",
]
allow_unsafe = true
deps = [
":system",
"test_util",
"//testing/rust_gtest_interop",
]
}
rust_static_library("ffi_unittests") {
testonly = true
is_gtest_unittests = true
crate_root = "test/pure_c_api_unittests.rs"
sources = [ "test/pure_c_api_unittests.rs" ]
allow_unsafe = true
deps = [
":ffi_bindings",
"test_util",
"//testing/rust_gtest_interop",
]
}