Cross compile Cargo project to Windows MSVC target with ease
Project description
cargo-xwin
formerly cargo-xwinbuild
🚀 Help me to become a full-time open-source developer by sponsoring me on GitHub
Cross compile Cargo project to Windows msvc target with ease.
By using this software you are consented to accept the license at https://go.microsoft.com/fwlink/?LinkId=2086102
Prerequisite
- For pure Rust project, no prerequisites needed.
- For C/C++ dependencies, install clang (On macOS run
brew install llvm
and you're good to go). - For assembly dependencies, install
llvm-tools-preview
component viarustup component add llvm-tools-preview
or install llvm.
Installation
cargo install cargo-xwin
You can also install it using pip:
pip install cargo-xwin
We also provide a Docker image which has wine pre-installed in addition to cargo-xwin and Rust, for example to build for x86_64 Windows:
docker run --rm -it -v $(pwd):/io -w /io messense/cargo-xwin \
cargo xwin build --release --target x86_64-pc-windows-msvc
Usage
- Install Rust Windows msvc target via rustup, for example,
rustup target add x86_64-pc-windows-msvc
- Run
cargo xwin build
, for example,cargo xwin build --target x86_64-pc-windows-msvc
Run tests with wine
With wine installed, you can run tests with the cargo xwin test
command,
for example, cargo xwin test --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-xwin 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for cargo_xwin-0.14.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a5e1b1ed3bfd0ec74053df307c842d2c48aa49c6d5dfc538be94301a9d33859 |
|
MD5 | 149d3c42405639d6123925a78e74ad55 |
|
BLAKE2b-256 | 4dc705ed79412f5628252f9b5145b8349ac2d5c10250e9965d1931588737e6b3 |
Hashes for cargo_xwin-0.14.0-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecde02b1f8416a8451ccd6ab69cf0334ffcbd913262c46d9555a202c3b0e3f22 |
|
MD5 | 5ced8f2194a581dd498ff7a422c1edab |
|
BLAKE2b-256 | 148358c31577a640f4f807520f3a35fd7ad400c4c20250132a03241f03ca9438 |
Hashes for cargo_xwin-0.14.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa78f391bf859b1a010f415706a69c30b80e5ded13b3e5ed84def82c6ea3b951 |
|
MD5 | 16175a1801882346d57a8a5f7023a6a1 |
|
BLAKE2b-256 | 48ba31fa2c8b001a74593ea7605f940111e9759ace5e650f2ff637aed91275ba |
Hashes for cargo_xwin-0.14.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf73f3b547e95dcf5947883cd9efb4d7f6236bb29c33c203490eba50229139e |
|
MD5 | ff3b79838e5ebeb17c7d2f046ad7b06e |
|
BLAKE2b-256 | 30cda0352a5c21e8cb2b2f22c243d4d14708fe14db00e78ae196e6f2e92c7fda |
Hashes for cargo_xwin-0.14.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 971c4a6539391ecc8d2a294b3c3e3006e2e77fac25c824def97b235853ca89ef |
|
MD5 | ed0c194b7a477307789355be6950f454 |
|
BLAKE2b-256 | ef6ff6e68fe88f5476946d1d9b2d5fc92718b4a31a53a77d18abf3e380b112cb |
Hashes for cargo_xwin-0.14.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30630ded6a6f5d10e8b2582c07446f7c9d7e2ba388fa2c9ca68a5aa5ef1b5687 |
|
MD5 | 0af2902907566abcbb9f65c50bd43634 |
|
BLAKE2b-256 | e5fdd1100d578f6561a1e7186df3bd68adfb0419cc048acf97d74e8549554115 |
Hashes for cargo_xwin-0.14.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9e60fb7e0de69cb2ebfddba214d7876647266c4386c740009666d969b4de513 |
|
MD5 | d1b6b738fd094a6d49566f9dd7b6b2d8 |
|
BLAKE2b-256 | 80c0b29ff5afe77b5efc06804590f07f4c440d9bc261d34e2eb8b25475702ab6 |