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.6-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6c3569cdcc1d87830734909a5238195277af5e0ef9d17d2b9021fac216ad292 |
|
MD5 | 9ffd6f6e31223452b5c3944af9321693 |
|
BLAKE2b-256 | 2c56904bf9147df62cf08e2bbdf14fe0fa91c69618dc806efafc0113a001c077 |
Hashes for cargo_xwin-0.14.6-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72ba79f33cbefb0a52f82a3d484c8dc3bb0c2846a447957778fe69c85699393c |
|
MD5 | 034e687f5ee1b59fae3513913b8b4972 |
|
BLAKE2b-256 | 6367c82b8efe9e355e53289a22d7751920c1a03c7ce1ad468604b48d7d925ff6 |
Hashes for cargo_xwin-0.14.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eb326caa240bcb140be3424cceef391a6c32a1a0f995dab0bba9e5602bd2434 |
|
MD5 | 483a11b1d03908b552873ff14a8c2730 |
|
BLAKE2b-256 | 97fb5dd597063fff34521dd5134c0f4d4a5ea8037af2d98cdd9fe70a9327e281 |
Hashes for cargo_xwin-0.14.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6260446050d5157de08e7e84d8bfd75d13fc37a89057119b46e4854022136b0 |
|
MD5 | e161f4cc24388e255fd18eda5c9c4121 |
|
BLAKE2b-256 | e229f3cd3e4274c3dafa196c1920716a960e7000da1b9cebf4f1877d6cc8d4d7 |
Hashes for cargo_xwin-0.14.6-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99025d1635e4a1ca84881d04c7376151f912f3ce90ab3d3f333ce126754c36c3 |
|
MD5 | 4764ae80006bc59359ef2dc0d78e8cc4 |
|
BLAKE2b-256 | 6f6ca198bc22e211814fb99b09bb6adf869337b10bd52738acc0d3f913e9621c |
Hashes for cargo_xwin-0.14.6-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78579e282aba24d0e736b82690a7f4c6a0f40975109e5d12d298cefb0cd60fc0 |
|
MD5 | 55f7b9acfe889750dae01bdd5bf201e1 |
|
BLAKE2b-256 | eefd35e2ea4519bbd7870b8e586977f18e1eded6a29faf23d11e7c56ff87a278 |
Hashes for cargo_xwin-0.14.6-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c10fa46528d469aeade12504e1e6a8ba3690fdfb6695aba17ad2b14f69e0ecc1 |
|
MD5 | b99539b386bb19ff094467241c5494a5 |
|
BLAKE2b-256 | 084183aab013f425d203cd469f2fdaa5233985fa89356758152f23aed934dd19 |