/xmake-skills:xmake-rustfrom xmake-skills
Builds Rust projects with xmake: binary/library targets, Cargo dependency integration, C↔Rust interop via cxxbridge, and cross-compile support.
Ships in xmake-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Xmake builds Rust projects via rustc (and optionally cargo for dependency resolution). It gives you the same declarative target() / add_files() model you use for C/C++, plus special support for Cargo package integration and C↔Rust FFI.
xmake create -l rust -t console hello
cd hello
xmake run
Generated xmake.lua:
add_rules("mode.debug", "mode.release")
target("hello")
set_kind("binary")
add_files("src/main.rs")
That's it — same shape as C++, just .rs files.
target("app") set_kind("binary") -- executable
target("mylib") set_kind("static") -- .rlib / .a
target("mydyn") set_kind("shared") -- cdylib
target("app")
set_kind("binary")
add_files("src/main.rs")
set_values("rust.edition", "2021") -- or "2018", "2015", "2024"
add_rcflags("-C", "opt-level=3", {force = true})
add_rcflags is the Rust equivalent of add_cxflags. {force = true} bypasses the flag auto-filter.
For a handful of crates, use cargo::name version in add_requires:
add_requires("cargo::base64 0.13.0")
add_requires("cargo::serde 1.0", {configs = {features = {"derive"}}})
target("app")
set_kind("binary")
add_files("src/main.rs")
add_packages("cargo::base64", "cargo::serde")
Downside: if two of your direct deps share a transitive dep at different versions, you hit "multiple versions of crate" errors. For non-trivial dep trees, use the full-Cargo.toml path below.
Cargo.toml wayWrite a normal Cargo.toml next to your xmake.lua, then let xmake read it:
add_requires("cargo::deps", {configs = {cargo_toml = path.join(os.projectdir(), "Cargo.toml")}})
target("app")
set_kind("binary")
add_files("src/main.rs")
add_packages("cargo::deps")
Cargo resolves the full graph (including transitives) once, xmake consumes the result. Use this for any project with more than a couple of crates.
cxxbridge)add_requires("cargo::cxx 1.0")
target("bridge")
set_kind("static")
add_files("src/lib.rs")
add_packages("cargo::cxx")
target("app")
set_kind("binary")
add_files("src/main.cpp")
add_deps("bridge")
Use #[cxx::bridge] in src/lib.rs as with a normal cxx project. Xmake wires up the header generation.
target("cxxlib")
set_kind("static")
add_files("src/cxx/*.cpp")
target("app")
set_kind("binary")
add_files("src/main.rs")
add_deps("cxxlib")
Rust links cxxlib as a native static library via -l. Use extern "C" on the C++ side, extern "C" { ... } block on the Rust side.
Full examples: tests/projects/rust/cxx_call_rust_library and rust_call_cxx_library.
xmake f --toolchain=rust # force rustc as the toolchain
xmake show -l toolchains # see what else is available
Xmake auto-detects rustc on PATH. Pin a specific install via --sdk:
xmake f --toolchain=rust --sdk=$HOME/.rustup/toolchains/stable-x86_64-apple-darwin
xmake f -p windows -a x86_64 --toolchain=rust
xmake
Under the hood xmake passes --target=x86_64-pc-windows-msvc (or equivalent) to rustc. The corresponding Rust target component must be installed:
rustup target add x86_64-pc-windows-msvc
xmake run app --some-arg
Or add test cases:
target("app_test")
set_kind("binary")
add_files("tests/*.rs")
add_tests("default")
See xmake-tests.
cargo::foo + transitive cargo::foo at a different version → link errors. Switch to the full Cargo.toml route.rustup target add. Cross-compile fails with "can't find crate for std". Install the Rust target component first.set_languages("..."). Doesn't apply to Rust — use set_values("rust.edition", "2021").cargo:: and manual -l flags. Let add_packages("cargo::...") own the link line; mixing hand-rolled add_links gets messy..rs and .cpp in the same target. Not supported — split into two targets with add_deps.xmake-targets, xmake-build-optimizationxmake-cross-compilationxmake-packagesxmake-testsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub xmake-io/xmake-skills --plugin xmake-skills58 skills in this plugin
/xmake-addon-developmentUse when writing an Xmake addon — the `addon.lua` manifest, the payload layout (plugins/rules/toolchains/modules/includes/templates), `@self` references, shipping package definitions with an addon, `add_globalmodules`, testing it locally, and publishing it to xmake-repo as an `addon` kind package./xmake-addonsUse when installing or using an Xmake addon — `xmake addon --install/--list/--remove/--upgrade/--search`, declaring `add_addons(...)` in a project, and referencing addon payloads with `@addon/<name>/<rule>`, `@addon.<name>.<module>` or `@self`. For writing and publishing one, see xmake-addon-development./xmake-async-jobsUse when running parallel / async work inside xmake scripts — `async.runjobs` for parallel job execution, `async.jobgraph` (DAG) for dependency-ordered jobs, `async.jobpool` (tree structure), `core.base.scheduler` coroutine scheduling, semaphores, and `on_build_files(..., {jobgraph = true})` in rules. For running external compile jobs faster, see `xmake-build-optimization`.Other plugins' skills for the same job