Skip to content

Commit 229060e

Browse files
aymanm-googlechromeos-ci-prod
authored andcommitted
Expose a rust_static_library instead of raw rs file from rust_bindgen
Originally, `rust_bindgen` would originally expose an `action` which generates a `.rs` file (and sometimes `.c` file if wrap_static_inline is true). This would move the burden of knowing how to correctly bundle the generated file on the user where they would have to define a custom `BINDGEN_RS_FILE` flag which has to be loaded from the code. In order to eliminate the overhead, the user will treat the `rust_bindgen` as a `rust_static_library` which can be used by importing it using `chromium::import` or `use ..` whether it's first-party or not. The different design also allows the rust toolchain owners to take finer control on what's being done and what's exposed exactly from `rust_bindgen` by tweaking the `bindings.rs` file. This also fixes Cronet in AOSP where Soong (AOSP build system) does not allow a target to access another target's output through its path which what most clients of `rust_bindgen` did through the custom rustflag. In order to stay backward compatible with older consumers of `rust_bindgen`, we created `rust_bindgen_generator` which generates the raw rust which allows flexibility in usage. Bug: 373864033 Change-Id: I3d72aa8ecd11151235d3dd387b313c9d0309d4a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5953710 Auto-Submit: Mohannad Farrag <aymanm@google.com> Commit-Queue: David Benjamin <davidben@chromium.org> Reviewed-by: Dale Curtis <dalecurtis@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Reviewed-by: David Benjamin <davidben@chromium.org> Cr-Commit-Position: refs/heads/main@{#1374672} CrOS-Libchrome-Original-Commit: 63ce6fc17e6c065cc492e6e6b740f8a1e4322181
1 parent 897a631 commit 229060e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

base/logging/rust_logger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use log::Level::{Debug, Error, Info, Trace, Warn};
66
use log::{LevelFilter, Metadata, Record};
77
use std::ffi::CString;
88

9-
mod rust_log_integration {
10-
include!(env!("RUST_LOG_INTEGRATION_BINDGEN_RS_FILE"));
9+
chromium::import! {
10+
"//base:rust_log_bindgen";
1111
}
1212

13-
use rust_log_integration::root::logging::internal::print_rust_log;
14-
use rust_log_integration::root::logging::internal::{
13+
use rust_log_bindgen::logging::internal::print_rust_log;
14+
use rust_log_bindgen::logging::internal::{
1515
RustLogSeverity_DEBUG, RustLogSeverity_ERROR, RustLogSeverity_INFO, RustLogSeverity_TRACE,
1616
RustLogSeverity_WARNING,
1717
};

0 commit comments

Comments
 (0)