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 using xwin or windows-msvc-sysroot.

By using this software you are consented to accept the license at https://go.microsoft.com/fwlink/?LinkId=2086102

Prerequisite

  1. Install clang (On macOS run brew install llvm and you're good to go).
  2. For assembly dependencies, install llvm-tools component via rustup component add llvm-tools or install llvm.

A full LLVM installation is recommended to avoid possible issues.

Installation

cargo install --locked 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_CROSS_COMPILER --cross-compiler The cross compiler to use, defaults to clang-cl, possible values: clang-cl, clang
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_SDK_VERSION --xwin-sdk-version The SDK version to retrieve, defaults to the latest version
XWIN_CRT_VERSION --xwin-crt-version The CRT version to retrieve, defaults to the latest version
XWIN_INCLUDE_ATL --xwin-include-atl Whether to include the Active Template Library (ATL) in the installation
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).
XWIN_INCLUDE_DEBUG_SYMBOLS --xwin-include-debug-symbols Whether or not to include debug symbols (PDBs) 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.19.0-py3-none-win_amd64.whl (3.9 MB view details)

Uploaded Python 3Windows x86-64

cargo_xwin-0.19.0-py3-none-win32.whl (3.4 MB view details)

Uploaded Python 3Windows x86

cargo_xwin-0.19.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (4.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

cargo_xwin-0.19.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cargo_xwin-0.19.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

cargo_xwin-0.19.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (4.6 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ i686

cargo_xwin-0.19.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (8.7 MB view details)

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

File details

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

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 615a89aa7539b3d524abb28c0e5d1a83a05fcfcee8a245b4b36efd4cd6ba3436
MD5 d59c0eecbc515e8419cedfbb34c854c9
BLAKE2b-256 ee41ccc11e04bfcb77a3e9799b001a30d37142ebd0b2b0c2c995b242736665fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cargo_xwin-0.19.0-py3-none-win32.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 1bdfd6692550f1e703d2fb1a489df22f03bdc7fd6c4bc0d88e4a5a31a93bc2b6
MD5 c8ade89177d64691aaea93aa617b6166
BLAKE2b-256 6242f32d59743195b7578733269ec46c4afa117ccfd3207fd4b02c145cc9b6bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 50eda4fa91f6a84fa749c48894b7d00b1e07e43cb65d091ed5dd995e934c89d1
MD5 0d3f91ff145608eed6ca8fe80c69176a
BLAKE2b-256 24b5c22301c35fe04bf99664445eec6c655bdee0afdc2e20cb0343a02a479940

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8c063f91aef0d8fa0f614c3582cac58ce80b26874a467211afb6213ec2b508b
MD5 f866172a882bddb0f2952fda70d0773d
BLAKE2b-256 67812058ddb0d035682d20989074610e448c1c3ee1079d6594ef6193de4bc965

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ac1bbe2495da315e065f83cc58cbaa8fd0c3a0d4b9294f7aba59ec52b3078854
MD5 c7808fc622125c174da1b17a12e5c191
BLAKE2b-256 e20f7af795ba0546b013d3a9c0c0300715d09fde4d089153a2f1036584b7cc77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 fb65627eb154d8a7ce19bd76e946b704a4ac3405aa2de9c9049633ae3d630616
MD5 9920bfe8bc9051fee664f47ad25cb0a6
BLAKE2b-256 25aefff7361f64086d7b8093dd3139725fc0e6e9355a91b2cf05d6093649c7e2

See more details on using hashes here.

File details

Details for the file cargo_xwin-0.19.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cargo_xwin-0.19.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b75bef7e43295b699df7e7e07f284876f984190781a6a57145a6cdd1dc73ceb7
MD5 ea382a46d5c9e606ac8d4c002297e054
BLAKE2b-256 5a8163e9f73c97a03c1919e066a2049df48e08685b77fcd8eb933720bf980a00

See more details on using hashes here.

Supported by

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