#windows-msvc #msvc #cargo #windows #cross-compiling

bin+lib cargo-xwinbuild

Cross compile Cargo project to Windows msvc target with ease

12 unstable releases (3 breaking)

0.4.0 Mar 5, 2022
0.3.3 Mar 4, 2022
0.2.3 Mar 1, 2022
0.1.0 Feb 28, 2022

#313 in Cargo plugins

MIT license

38KB
783 lines

cargo-xwinbuild

CI Crates.io docs.rs PyPI

Cross compile Cargo project to Windows msvc target with ease. (LLVM installation required.)

By using this software you are consented to accept the license at https://go.microsoft.com/fwlink/?LinkId=2086102

Installation

cargo install cargo-xwinbuild

You can also install it using pip:

pip install cargo-xwinbuild

Usage

  1. Install LLVM, on macOS: brew install llvm
  2. Install Rust Windows msvc target via rustup, for example, rustup target add x86_64-pc-windows-msvc
  3. Run cargo xwinbuild, for example, cargo xwinbuild --target x86_64-pc-windows-msvc

Run tests with wine

With wine installed, you can run tests with the cargo xwintest command, for example, cargo xwintest --target x86_64-pc-windows-msvc

Customization

The Microsoft CRT and Windows SDK can be customized using the following environment variables or CLI options.

Environment Variable CLI option Description
XWIN_ARCH --xwin-arch The architectures to include, defaults to x86_64,aarch64, possible values: x86, x86_64, aarch, aarch64
XWIN_VARIANT --xwin-variant The variants to include, defaults to desktop, possible values: desktop, onecore, spectre
XWIN_VERSION --xwin-version The version to retrieve, defaults to 16, can either be a major version of 15 or 16, or a <major>.<minor> version
XWIN_CACHE_DIR --xwin-cache-dir xwin cache directory to put CRT and SDK files

CMake Support

Some Rust crates use the cmake crate to build C/C++ dependencies, cargo-xwinbuild will generate a CMake toolchain file automatically to make cross compilation work out of the box.

ninja is required to enable CMake support.

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Dependencies

~24–40MB
~663K SLoC