rules_rust

Rust Bindgen

rust_bindgen

rust_bindgen(name, bindgen_flags, cc_lib, clang_flags, header)

Generates a rust source file from a cc_library and a header.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required  
bindgen_flags Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. List of strings optional []
cc_lib The cc_library that contains the .h file. This is used to find the transitive includes. Label optional None
clang_flags Flags to pass directly to the clang executable. List of strings optional []
header The .h file to generate bindings for. Label optional None

rust_bindgen_toolchain

rust_bindgen_toolchain(name, bindgen, clang, libclang, libstdcxx, rustfmt)

The tools required for the rust_bindgen rule.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required  
bindgen The label of a bindgen executable. Label optional None
clang The label of a clang executable. Label optional None
libclang A cc_library that provides bindgen’s runtime dependency on libclang. Label optional None
libstdcxx A cc_library that satisfies libclang’s libstdc++ dependency. This is used to make the execution of clang hermetic. If None, system libraries will be used instead. Label optional None
rustfmt The label of a rustfmt executable. If this is provided, generated sources will be formatted. Label optional None

rust_bindgen_library

rust_bindgen_library(name, header, cc_lib, bindgen_flags, clang_flags, kwargs)

Generates a rust source file for header, and builds a rust_library.

Arguments are the same as rust_bindgen, and kwargs are passed directly to rust_library.

PARAMETERS

Name Description Default Value
name A unique name for this target. none
header The label of the .h file to generate bindings for. none
cc_lib The label of the cc_library that contains the .h file. This is used to find the transitive includes. none
bindgen_flags Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. None
clang_flags Flags to pass directly to the clang executable. None
kwargs Arguments to forward to the underlying rust_library rule. none

rust_bindgen_repositories

rust_bindgen_repositories()

Declare dependencies needed for bindgen.