Rust Bindgen

rust_bindgen

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

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
bindgen_flagsFlags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details.List of stringsoptional[]
cc_libThe cc_library that contains the .h file. This is used to find the transitive includes.LabeloptionalNone
clang_flagsFlags to pass directly to the clang executable.List of stringsoptional[]
headerThe .h file to generate bindings for.LabeloptionalNone
rustfmtEnable or disable running rustfmt on the generated file.BooleanoptionalTrue

rust_bindgen_toolchain

The tools required for the rust_bindgen rule.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
bindgenThe label of a bindgen executable.LabeloptionalNone
clangThe label of a clang executable.LabeloptionalNone
libclangA cc_library that provides bindgen's runtime dependency on libclang.LabeloptionalNone
libstdcxxA 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.LabeloptionalNone
rustfmtThe label of a rustfmt executable. If this is not provided, falls back to the rust_toolchain rustfmt.LabeloptionalNone

rust_bindgen_library

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

NameDescriptionDefault Value
nameA unique name for this target.none
headerThe label of the .h file to generate bindings for.none
cc_libThe label of the cc_library that contains the .h file. This is used to find the transitive includes.none
bindgen_flagsFlags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details.None
clang_flagsFlags to pass directly to the clang executable.None
rustfmtEnable or disable running rustfmt on the generated file.True
kwargsArguments to forward to the underlying rust_library rule.none

rust_bindgen_repositories

Declare dependencies needed for bindgen.