Static FFI library that provides an entry point to the Rust log decoder.
The cbindgen program reads a locally generated Cargo.toml manifest to create the header for the cpp-log-decoder static Rust library, and its dependencies, to expose a public C API.
There are four steps to create/update the bindings header:
Cargo.toml manifest.The stable Rust toolchain cannot process Fuchsia-generated Cargo.toml manifests. You therefore must link the Fuchsia toolchain in your environment:
rustup toolchain link fuchsia "~/fuchsia/prebuilt/third_party/rust/linux-x64"
If you cannot link this toolchain in your environment, you may alternately use the nightly Rust toolchain instead.
We currently pin cbindgen at version 0.26.0 to avoid unexpected behavior with cbindgen updates. You can install it with the following:
cargo install --version 0.26.0 --force cbindgen
Cargo.toml manifest for cpp-log-decoderGenerate a Cargo.toml by following the instructions on fuchsia.dev for the build target //src/lib/diagnostics/log/message/rust/cpp-log-decoder:staticlib.
As of this writing, this is done in the following way.
Using fx args, add //build/rust:cargo_toml_gen to host_labels.
Using fx args, add //src/lib/diagnostics/log/message/rust/cpp-log-decoder:staticlib to build_only_labels.
Build the cargo_toml_gen target and generate the Cargo.toml manifest:
fx args # then append "//build/rust:cargo_toml_gen" to `host_labels`
fx args # then append "//src/diagnostics/lib/cpp-log-decoder:staticlib"
# to `build_only_labels`
fx build //build/rust:cargo_toml_gen
fx gen-cargo //src/lib/diagnostics/log/message/rust/cpp-log-decoder:_log_decoder_c_bindings_rustc_static.actual
fx gen-cargo //src/lib/diagnostics/log/message/rust:lib.actual
The following command uses the Fuchsia toolchain and cbindgen to create/update the bindings header. If you could not link the Fuchsia toolchain, you may substitute RUSTUP_TOOLCHAIN=nightly.
RUSTUP_TOOLCHAIN=fuchsia cbindgen ~/fuchsia/src/lib/diagnostics/log/message/rust/cpp-log-decoder -o ~/fuchsia/src/lib/diagnostics/log/message/rust/cpp-log-decoder/log_decoder.h