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.16.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc057604ac6a55fc419e59e597fc205251acf02104dda6fa50667a037a4bf3c9 |
|
MD5 | 561eb768c43d1e905ece624d401c136b |
|
BLAKE2b-256 | 04f788b4ef6a8f44f0ddfbc5845dd8f2e17c8f6b26e4f30ce1025e674b157671 |
Hashes for cargo_xwin-0.16.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfbf09dce96477dc8f3faf4fdc690ab761e07070ef36931106a21a2167a92766 |
|
MD5 | 4d342452d10a3150e9e0b19d21f605e5 |
|
BLAKE2b-256 | 949ebe21ea64aacb441ca91ef29c77efa9f801f934c206ae706404ff5e7205c5 |
Hashes for cargo_xwin-0.16.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 319a3e355e633f78c50037e61a621680d2642ce036250bcc0f259e0c6cd3116f |
|
MD5 | e8a3a478a516df2659c5f42893b52fb4 |
|
BLAKE2b-256 | 5add34649f5650de861c97ddc61b1ec955a4debd817984f34e5ca86925da6959 |
Hashes for cargo_xwin-0.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba840d9beea3882c815f06bb1d3095d472fd98bf129be2e336bddbf97601a435 |
|
MD5 | 73493b83b68ee0795ac29f49242d34e9 |
|
BLAKE2b-256 | 0ef5188992b55c3885337e8c708183b20c83fcbf4b6af8321fda21bb852a56d6 |
Hashes for cargo_xwin-0.16.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79bfeda0ce61f4e970af604a95958051a84ac168f7b967e74e50a93d5c9e0780 |
|
MD5 | d1e0a08f76e73e7817d938fa88b6335d |
|
BLAKE2b-256 | 94209119886d80fec983b7e54f7e128daf7137c3e5cb662b4cfa7f219e6c67cc |
Hashes for cargo_xwin-0.16.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1472c923b01b30a9de5df1633226d7acf6278e62ab8ff755b9ee043da102c372 |
|
MD5 | 37f12ed3be482792a562aec276d08dca |
|
BLAKE2b-256 | 6c4091e509b64bb104e0bd5214d4eebb52f011b79d93bfce3b7d6064e8688943 |
Hashes for cargo_xwin-0.16.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf04290d50dd1131bd6eb8ad3138ba5080199bc447fea6acc384871c416790f2 |
|
MD5 | a40224057da0227b810d4f23e4c2a7dd |
|
BLAKE2b-256 | cb6a624ac32bcba0a834ffcb0f1e24ab660a199231d105c21c809a28d63dec97 |