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.14.9-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f72c5dce53ee3b91d18a6adc36ab760e5e18ec8f4243faaa4dce9434f6f6f01e |
|
MD5 | adbb15813bd07e882c54ab8a3c2772b3 |
|
BLAKE2b-256 | 54c114129c52ebb3efac84c65de6d4e048aef24d6e877b508326afb081033b3b |
Hashes for cargo_xwin-0.14.9-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37d6e2dcfba376a4827486710356f34cdd19b72604f0c9cd46bb807dd75fe1a0 |
|
MD5 | eb6c19da1e336e7b0d58f06a27f83ca2 |
|
BLAKE2b-256 | 005dce5a44e2596e87e5f4623c9048d60dca2035dfebee67076884af5c3f4cf4 |
Hashes for cargo_xwin-0.14.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40db72cfc55902bceb6b1f018558c5659fcc1f5c29281e285ade2e01c39acb4a |
|
MD5 | 46228f2cabc4f2f9d219964507261cd9 |
|
BLAKE2b-256 | 6f2a3634676a1548da3e155b55caeed5cddbd5cc85e72cc28d73f77711ef0288 |
Hashes for cargo_xwin-0.14.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 879ae60e89cb795fa345d996a15780438ba3d51a4785a96ac202f41c13b62583 |
|
MD5 | 9a2a5014680ae85e6fb95975ef8054e4 |
|
BLAKE2b-256 | 262c7f5a9750f4f75842cdee42fd0bba5b4481bd9679b8c6d8af98c9724aa24d |
Hashes for cargo_xwin-0.14.9-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44f6bd5d5a5b3b80958b106eff9803544ad63a35693b1a6110da966a776c5dd3 |
|
MD5 | a4da6040350103e275a66e5f9e2a1e29 |
|
BLAKE2b-256 | c112df27d1d70202c7908dfe45cb55b2a832ac5841d61adb159b08caf801c601 |
Hashes for cargo_xwin-0.14.9-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25636ec0ccfacb987138960865eaad46f0c198ab896219c9ba6ec9c46ec97163 |
|
MD5 | 40ff227d06a283308591d006f7d385ed |
|
BLAKE2b-256 | 89390f5be6fa892a9fe736b2aff5365cd3f093a365bccf1c8e4dad8cea751284 |
Hashes for cargo_xwin-0.14.9-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cb995682aa86c858b44442ce66a8c66b4c5fd16588299d0777274ab00eb9a8c |
|
MD5 | 1c9a355e455eb8e14f7e204f13b1dd6d |
|
BLAKE2b-256 | 561efefe7139902e15f9c700a3a5df9f69793bcb746269a7396692b36a7f7140 |