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 |
XWIN_INCLUDE_DEBUG_LIBS |
--xwin-include-debug-libs |
Whether or not to include debug libs in installation (default false). |
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.17.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 129d1d085f581d7a5ed0eae3f43e7c70272bb539cb46434c98aaefd5954538c8 |
|
MD5 | 3d4fb868e18c056ae1c86bd802082b20 |
|
BLAKE2b-256 | 80ac9567f7959c6c95a1a1aaf811476b97c5de1f5e31356beb651d3a7b7be78c |
Hashes for cargo_xwin-0.17.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc96e3f0b51c971e7ec4c21902a3afb02cc7e27e4dc6a4200fa544bdbeafe425 |
|
MD5 | fcd863668b0db126e19a74e235251820 |
|
BLAKE2b-256 | e0d5603fb0ca607e6f60ea2755ffec2f5872839642cfe6383357a34b70f6de14 |
Hashes for cargo_xwin-0.17.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d3644da64f89c762f0ec441bdf220937e626671110c62bc19ca2b7eb67b564 |
|
MD5 | 2b7d99e559d85a235a5858f387cc67cc |
|
BLAKE2b-256 | cdaee784de00642938edba64677ad7977a359a2ee8275cee71559cd9ed8d3e7e |
Hashes for cargo_xwin-0.17.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70f251d1cbcfe3caa12e7fb7c8e0f519e9111ef06420f0b84a6d0be167e5652f |
|
MD5 | 5a6626f497340cfd3350489efba32519 |
|
BLAKE2b-256 | 3565ee37b0c7d573b13781e7e576196f324a4af9d292da2513293074ceda48a0 |
Hashes for cargo_xwin-0.17.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc73abbd5e5ce5621a0c620998eb0b1185a2a47cb1a1a5f544d366eea53e6f36 |
|
MD5 | e5e0dd63e1d45625bb3e7128e9ee2a07 |
|
BLAKE2b-256 | 4e48a5b11d7421af9869373ddeaf585203628c839efb978f44c20e2002a214fd |
Hashes for cargo_xwin-0.17.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11e484244dbf1ebbb6bb40d95d3a5e33dcdd17ba199b4f9ec912aa89a9abf60b |
|
MD5 | eca70284aaea52df591c50661f6d00fa |
|
BLAKE2b-256 | e6c3ca194cc6e57cee357feddc3118169ba9eb7ea4f293b743580afdfc4919ef |
Hashes for cargo_xwin-0.17.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4f42e31627b8e84d70342b377f7e8defd323efa0aa945cc837318e591dabaab |
|
MD5 | 3eb658b95d97e1f5d505360dc521c6c6 |
|
BLAKE2b-256 | 8b07c24ee0eccbc627e750c194bb584de5796c6b0449ed628317ef7dea73e3e3 |