Skip to main content

Crate windows_clang

Crate windows_clang 

Source
Expand description

§bnd-clang

bnd-clang is bnd’s maintained fork of windows-clang. It parses C and C++ headers with libclang and emits Rust Definition Language (RDL) source for windows-rdl to compile into WinMD metadata.

The package keeps the upstream-compatible windows_clang Rust library name.

§Requirements

Install libclang through the host package manager. On Ubuntu:

sudo apt-get install libclang-dev

The default feature set links libclang at build time. Enable the runtime feature to use clang-sys runtime loading instead.

§Usage

[build-dependencies]
windows-clang = { package = "bnd-clang", version = "0.0.8" }
windows-rdl = { version = "0.100", default-features = false }
windows_clang::clang()
    .input("example.h")
    .args(["-x", "c", "-std=c11"])
    .filter("example.h")
    .namespace("example")
    .library("example")
    .output("example.rdl")
    .write()
    .expect("generate RDL");

windows_rdl::reader()
    .input("example.rdl")
    .output("example.winmd")
    .write()
    .expect("compile WinMD");

For package generation, write_by_header() emits flat RDL partitions and remap_by_header() converts the compiled WinMD into canonical defining-header namespaces. The remapper round-trips through RDL to restore external TypeRef scopes.

See VENDORED.md for the upstream revision, licensing, and the maintained fork changes.

§License

MIT or Apache-2.0

Structs§

Arch
Target architecture settings that differ between scrape passes.
Clang
Builder that generates RDL from C/C++ headers using libclang.
HeaderRemap
Structurally remaps flat metadata into defining-header namespaces.
ScrapePlan
Multi-arch and output state layered on top of a configured Clang.
Summary
What Clang::scrape produced, for the caller’s summary output.

Constants§

LIBCLANG_VERSION
Pinned libclang version; macro capture changes across major versions.

Functions§

assert_libclang_version
Assert the loaded libclang matches LIBCLANG_VERSION.
clang
Creates a libclang-backed RDL generator.
clang_resource_dir
Resolve the version-matched clang -resource-dir, honoring CLANG_RESOURCE_DIR.
clang_version
Returns the loaded libclang version string.
ensure_libclang
Ensure libclang is loadable, respecting an existing LIBCLANG_PATH.
find_in_dirs
Find name in dirs, returning a forward-slashed path.
libclang_dir
Resolve or fetch the pinned host-arch libclang.dll directory without setting env vars.
nuget_package
Resolve or fetch an exact NuGet package, accepting global-cache or flat restore layouts.
remap_by_header
Creates a remapper for flat per-header RDL and WinMD output.