Skip to main content

Cross compile Cargo project to Windows MSVC target with ease

Project description

cargo-xwin

formerly cargo-xwinbuild

CI Crates.io docs.rs PyPI Docker Image

🚀 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

  1. For pure Rust project, no prerequisites needed.
  2. For C/C++ dependencies, install clang (On macOS run brew install llvm and you're good to go).
  3. For assembly dependencies, install llvm-tools-preview component via rustup 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

  1. Install Rust Windows msvc target via rustup, for example, rustup target add x86_64-pc-windows-msvc
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cargo_xwin-0.17.0-py3-none-win_amd64.whl (3.4 MB view details)

Uploaded Python 3 Windows x86-64

cargo_xwin-0.17.0-py3-none-win32.whl (3.0 MB view details)

Uploaded Python 3 Windows x86

cargo_xwin-0.17.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.5 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_xwin-0.17.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_xwin-0.17.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (5.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_xwin-0.17.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (5.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_xwin-0.17.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (7.7 MB view details)

Uploaded Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file cargo_xwin-0.17.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bbc85153fece2b43bea6dc26b437244336bcc4a41994a53e5d75c2b43a118eb9
MD5 704387f41236e27de79937126e3a5254
BLAKE2b-256 e2c13991111ff6e309d180ed338320180a0a946469cf65f5907fb26cb8b4e340

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-win32.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 675d78f64188dcdc499e478de4024cbd8388fb671ad7d8627e4c3325cf065689
MD5 e1c96ffe1f6e081df5ad4dcabb02a680
BLAKE2b-256 34d28337c8ad64abefd548cea288bb127947536551f3f3c7615cabab0d15692b

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 d1f3377ac0923adfaf88c6f4f1a71df6f0a1875739efda74bf5d7c6632efb5b9
MD5 02dc930e3c3fb5903e39b3283e942a4a
BLAKE2b-256 0c726e67b7bdef6b68372ca9ab3f347895570eea9b80895a4a0bb189ba657d85

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bd6e43f38835d13d0b4dbbf32f4f86f0c7f8cfcca4d788fdf4102d7d4ff4225e
MD5 916552cbb4bbb93e66982a9d76ede245
BLAKE2b-256 c88aa3682469985d7d93dc9b5484575c729565bd3ea779fa0426cef4e26190e0

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 eff0341ee149972ec8a9da3872dde040ba06304373875e53d02f42a4166ccdc3
MD5 6deac97bb314b32721560ef92e0d0d3c
BLAKE2b-256 1af250f00e342a9b41812b455791d4e7993cba492e63827fffb1039883182417

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 0fddc728f46f523a56ddd977ab70c42c5a0d95f9608a42fa0d48230b550b6e2a
MD5 d17356f807e8f99593b716cf98ec9700
BLAKE2b-256 cd90243b8ca7b524c87ecfc424a15a53118e77f498ab747dc9cf05b859a67d48

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.17.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.17.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 4328df6393dddbd4240a3def25a9111aefb2bd51c8db299b96c672976b417538
MD5 31d51b7efcf1ef9a9d4e7379e0c8f0a2
BLAKE2b-256 516308ebe343224bef2e1b970f005fd56cdae44ddcd5fc810a8606a9f0e619fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page