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.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13a382769afa50895821c8adc2a13969c3e293612a5a69ecdd8a1cd779a17f54 |
|
MD5 | ef814a0ba40df295de7dd70c579b581f |
|
BLAKE2b-256 | ba6e8e3249c3be7f004174adfaf77254f2bbb024247789f990f80c2a8536c0d6 |
Hashes for cargo_xwin-0.14.2-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc7f645fd6c403bb0a364c141efad29171cc997a45792c21caba328e0b195997 |
|
MD5 | c58c31c0f6978a7764d45f8595507f0d |
|
BLAKE2b-256 | 55afbf1224df1085b6969bb17f4c37c4ade0ceb37e9e6a157904d823c71ebe66 |
Hashes for cargo_xwin-0.14.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb4f343edc71636556da9d63295401c027d35c148d156066f9101610861a5b29 |
|
MD5 | 9097d3a77f8f5d287e7aa73c04158e92 |
|
BLAKE2b-256 | a924ff7ff249e5cd3470eb1e98e776fc62e075e71a4d527eace04532e39955ef |
Hashes for cargo_xwin-0.14.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f8f2343ba79f0d041c2f1de996ebe16f3c6b08ba538d54ae5fed23b634f2ff |
|
MD5 | 52f6a6754cd6cb19cf13ad1af0e851f6 |
|
BLAKE2b-256 | c45c1fca209f58db3266be0dced1c34813613b7ccefb711856b8eb60d17d9022 |
Hashes for cargo_xwin-0.14.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c2ea6b954b97935388b19e62b83e785b1e620217665445ab448f5ce985dce5a |
|
MD5 | 85796c0304e30271ba5656275fe9a9a1 |
|
BLAKE2b-256 | e5d5ac5d5bc7dfd9dd87a3a048da349d7be6b9253ccda0dfba0cf3179ee5f6c2 |
Hashes for cargo_xwin-0.14.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61bd0a6d7b795e215c31626e503957fad72f3d33754311b2a712e0fa3f416451 |
|
MD5 | 882a832595387a3418e1dc73d5a4ee06 |
|
BLAKE2b-256 | 35fbb208e96da735c702218927e4d0b1a0097a414afb8e2372a959ff78b2758a |
Hashes for cargo_xwin-0.14.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca9a75438c3f526f76f0004586b716caedacf1a46ac1fb10d55e3771adfa6c00 |
|
MD5 | d447aaa06d923aefab0aab93ce5e7e58 |
|
BLAKE2b-256 | 8db28c7640f9b8489c9d803a7719f5da9a2c76f7d5043223c9eb5330a8e895e7 |