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.
- 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.12.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 160273c4c0fa89369c9a8571bd75c407a13781d67c32a868126f8d49009de8c3 |
|
MD5 | a9ab7c6021307fd4292a0aaa8bc4261f |
|
BLAKE2b-256 | d35eb3e889d5b373e9b81bb723e6715520cd32bbe7bfc85e5c81cccefd0e6969 |
Hashes for cargo_xwin-0.12.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ad1e7b20dc093a15359781680091b66f04f2f205c04fe5e2297f3f2b74afae |
|
MD5 | 053df169c8d1a67e39bbdc7b14556680 |
|
BLAKE2b-256 | cbc43bdafb5a6b5d6413294c9ad04e791d450dc3fea3459c2d9e7545c249f13f |
Hashes for cargo_xwin-0.12.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1cb782fbcd1d51bc2ced88a122a5f200c9b48b4c2eab7885d7fa0a95542509e |
|
MD5 | 0f76f2e4409fca2475386c3e7c7968c7 |
|
BLAKE2b-256 | 5fd140f549dd3b14c4ef4c0f366506be5f1eedc6b35e9a45ab45b3d3ce7cc0fe |
Hashes for cargo_xwin-0.12.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68ed2892fc11c5d0789769e153c2f7596873f56a9d15a5329e248ca765c5c0be |
|
MD5 | 4bc3fe6662e48fe0d8869fbe8c61eb22 |
|
BLAKE2b-256 | abd6c1be70274c29b34c3cf26463bf4aca6b0667ad1e767aaa69770c0efde7fd |
Hashes for cargo_xwin-0.12.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed3fee6b93503b929ef72a2503d760e1b6a9803462b42d422594513f9294bf61 |
|
MD5 | 4783f2e7c07c3daa78b20e0672e4b93d |
|
BLAKE2b-256 | a482b1595c049be0dc4f2c9b85d0fbfcb0c08a6fc0503f632ba4843b29a54f83 |
Hashes for cargo_xwin-0.12.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ede1983243d1e4e8c75efec402408659128421b73f295136b0800ef4ed03c9e0 |
|
MD5 | d30c73fe73641d495a1f7d804eaca340 |
|
BLAKE2b-256 | fadb82dff72ccf5fef62a48ce1209f7e657a0a76186812e2d92fe8f10ad506b4 |
Hashes for cargo_xwin-0.12.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c0f9eacd0fbf20f9cc365a9434859674b5d522aa1fa1618170b28a6e37f65cd |
|
MD5 | b8a2c79bb44c1306a6ff28e87764a694 |
|
BLAKE2b-256 | e2e37fb58841f5e117328e32605092e84257e1f77bced4d25103a669a11d5c33 |