From 9bdf88d4865f734a30b777da9b623f91b693046c Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 6 Mar 2022 22:02:56 +0800 Subject: [PATCH] Rename to cargo-xwin --- .github/workflows/CI.yml | 24 ++++++++++++------------ .github/workflows/Release.yml | 24 ++++++++++++------------ Cargo.lock | 2 +- Cargo.toml | 5 ++--- README.md | 24 +++++++++++++----------- pyproject.toml | 2 +- src/bin/cargo-xwin.rs | 30 ++++++++++++++++++++++++++++++ src/bin/cargo-xwinbuild.rs | 22 ---------------------- src/bin/cargo-xwintest.rs | 22 ---------------------- 9 files changed, 71 insertions(+), 84 deletions(-) create mode 100644 src/bin/cargo-xwin.rs delete mode 100644 src/bin/cargo-xwinbuild.rs delete mode 100644 src/bin/cargo-xwintest.rs diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e2a0a96..deb94a0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -72,29 +72,29 @@ jobs: with: command: build args: --release - - name: xwinbuild - x86_64 + - name: xwin build - x86_64 run: | rustup target add x86_64-pc-windows-msvc - cargo run --release xwinbuild --target x86_64-pc-windows-msvc --manifest-path tests/libhello/Cargo.toml - cargo run --release xwinbuild --target x86_64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml - cargo run --release xwinbuild --target x86_64-pc-windows-msvc --manifest-path tests/hello-tls/Cargo.toml - cargo run --release xwinbuild --target x86_64-pc-windows-msvc --manifest-path tests/hello-rustls/Cargo.toml + cargo run --release xwin build --target x86_64-pc-windows-msvc --manifest-path tests/libhello/Cargo.toml + cargo run --release xwin build --target x86_64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml + cargo run --release xwin build --target x86_64-pc-windows-msvc --manifest-path tests/hello-tls/Cargo.toml + cargo run --release xwin build --target x86_64-pc-windows-msvc --manifest-path tests/hello-rustls/Cargo.toml # Test CMake support - cargo run --release xwinbuild --target x86_64-pc-windows-msvc --manifest-path tests/crfsuite-rs/Cargo.toml + cargo run --release xwin build --target x86_64-pc-windows-msvc --manifest-path tests/crfsuite-rs/Cargo.toml - name: xwintest - x86_64 if: matrix.os == 'ubuntu-latest' run: | - cargo run --release --bin cargo-xwintest xwintest --target x86_64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml - - name: xwinbuild - aarch64 + cargo run --release xwin test --target x86_64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml + - name: xwin build - aarch64 run: | rustup target add aarch64-pc-windows-msvc - cargo run --release xwinbuild --target aarch64-pc-windows-msvc --manifest-path tests/libhello/Cargo.toml - cargo run --release xwinbuild --target aarch64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml - cargo run --release xwinbuild --target aarch64-pc-windows-msvc --manifest-path tests/hello-tls/Cargo.toml + cargo run --release xwin build --target aarch64-pc-windows-msvc --manifest-path tests/libhello/Cargo.toml + cargo run --release xwin build --target aarch64-pc-windows-msvc --manifest-path tests/hello-windows/Cargo.toml + cargo run --release xwin build --target aarch64-pc-windows-msvc --manifest-path tests/hello-tls/Cargo.toml # Test CMake support - cargo run --release xwinbuild --target aarch64-pc-windows-msvc --manifest-path tests/crfsuite-rs/Cargo.toml + cargo run --release xwin build --target aarch64-pc-windows-msvc --manifest-path tests/crfsuite-rs/Cargo.toml fmt: name: Rustfmt diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 20bf22e..0bfb589 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -33,7 +33,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: apple-darwin-bin - path: target/release/cargo-xwinbuild + path: target/release/cargo-xwin if-no-files-found: error - name: Get tag if: "startsWith(github.ref, 'refs/tags/')" @@ -43,15 +43,15 @@ jobs: if: "startsWith(github.ref, 'refs/tags/')" run: | cd target/release - tar czvf cargo-xwinbuild-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz cargo-xwinbuild - shasum -a 256 cargo-xwinbuild-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz > cargo-xwinbuild-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz.sha256 + tar czvf cargo-xwin-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz cargo-xwin + shasum -a 256 cargo-xwin-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz > cargo-xwin-${{ steps.tag.outputs.tag }}.apple-darwin.tar.gz.sha256 cd - - name: Upload binary to GitHub Release uses: svenstaro/upload-release-action@v2 if: "startsWith(github.ref, 'refs/tags/')" with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/release/cargo-xwinbuild*.tar.gz + file: target/release/cargo-xwin*.tar.gz file_glob: true overwrite: true tag: ${{ github.ref }} @@ -91,7 +91,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: windows-${{ matrix.platform.arch }}-bin - path: target/${{ matrix.platform.target }}/release/cargo-xwinbuild.exe + path: target/${{ matrix.platform.target }}/release/cargo-xwin.exe if-no-files-found: error - name: Get tag if: "startsWith(github.ref, 'refs/tags/')" @@ -101,15 +101,15 @@ jobs: if: "startsWith(github.ref, 'refs/tags/')" run: | cd target/${{ matrix.platform.target }}/release - 7z a cargo-xwinbuild.zip cargo-xwinbuild.exe + 7z a cargo-xwin.zip cargo-xwin.exe cd - - name: Upload binary to GitHub Release uses: svenstaro/upload-release-action@v2 if: "startsWith(github.ref, 'refs/tags/')" with: repo_token: ${{ secrets.GITHUB_TOKEN }} - asset_name: cargo-xwinbuild-${{ steps.tag.outputs.tag }}.windows-${{ matrix.platform.arch }}.zip - file: target/${{ matrix.platform.target }}/release/cargo-xwinbuild.zip + asset_name: cargo-xwin-${{ steps.tag.outputs.tag }}.windows-${{ matrix.platform.arch }}.zip + file: target/${{ matrix.platform.target }}/release/cargo-xwin.zip overwrite: true tag: ${{ github.ref }} prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} @@ -151,7 +151,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: ${{ matrix.platform.target }}-bin - path: target/${{ matrix.platform.target }}/release/cargo-xwinbuild + path: target/${{ matrix.platform.target }}/release/cargo-xwin if-no-files-found: error - name: Get tag if: "startsWith(github.ref, 'refs/tags/')" @@ -161,15 +161,15 @@ jobs: if: "startsWith(github.ref, 'refs/tags/')" run: | cd target/${{ matrix.platform.target }}/release - tar czvf cargo-xwinbuild-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz cargo-xwinbuild - shasum -a 256 cargo-xwinbuild-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz > cargo-xwinbuild-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz.sha256 + tar czvf cargo-xwin-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz cargo-xwin + shasum -a 256 cargo-xwin-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz > cargo-xwin-${{ steps.tag.outputs.tag }}.${{ matrix.platform.target }}.tar.gz.sha256 cd - - name: Upload binary to GitHub Release uses: svenstaro/upload-release-action@v2 if: "startsWith(github.ref, 'refs/tags/')" with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/${{ matrix.platform.target }}/release/cargo-xwinbuild*.tar.gz* + file: target/${{ matrix.platform.target }}/release/cargo-xwin*.tar.gz* file_glob: true overwrite: true tag: ${{ github.ref }} diff --git a/Cargo.lock b/Cargo.lock index 6ad3c92..59b4317 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f3132262930b0522068049f5870a856ab8affc80c70d08b6ecb785771a6fc23" [[package]] -name = "cargo-xwinbuild" +name = "cargo-xwin" version = "0.4.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 3a1ad20..d7197ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,12 @@ [package] -name = "cargo-xwinbuild" +name = "cargo-xwin" version = "0.4.0" edition = "2018" -default-run = "cargo-xwinbuild" description = "Cross compile Cargo project to Windows msvc target with ease" license = "MIT" keywords = ["windows", "cargo", "msvc"] readme = "README.md" -repository = "https://github.com/messense/cargo-xwinbuild" +repository = "https://github.com/messense/cargo-xwin" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 6536fdd..583286b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -# cargo-xwinbuild +# cargo-xwin -[![CI](https://github.com/messense/cargo-xwinbuild/workflows/CI/badge.svg)](https://github.com/messense/cargo-xwinbuild/actions?query=workflow%3ACI) -[![Crates.io](https://img.shields.io/crates/v/cargo-xwinbuild.svg)](https://crates.io/crates/cargo-xwinbuild) -[![docs.rs](https://docs.rs/cargo-xwinbuild/badge.svg)](https://docs.rs/cargo-xwinbuild/) -[![PyPI](https://img.shields.io/pypi/v/cargo-xwinbuild.svg)](https://pypi.org/project/cargo-xwinbuild) +_formerly cargo-xwinbuild_ + +[![CI](https://github.com/messense/cargo-xwin/workflows/CI/badge.svg)](https://github.com/messense/cargo-xwin/actions?query=workflow%3ACI) +[![Crates.io](https://img.shields.io/crates/v/cargo-xwin.svg)](https://crates.io/crates/cargo-xwin) +[![docs.rs](https://docs.rs/cargo-xwin/badge.svg)](https://docs.rs/cargo-xwin/) +[![PyPI](https://img.shields.io/pypi/v/cargo-xwin.svg)](https://pypi.org/project/cargo-xwin) Cross compile Cargo project to Windows msvc target with ease. (LLVM installation required.) @@ -12,25 +14,25 @@ Cross compile Cargo project to Windows msvc target with ease. (LLVM installation ## Installation ```bash -cargo install cargo-xwinbuild +cargo install cargo-xwin ``` You can also install it using pip: ```bash -pip install cargo-xwinbuild +pip install cargo-xwin ``` ## Usage 1. Install [LLVM](https://llvm.org), on macOS: `brew install llvm` 2. Install Rust Windows msvc target via rustup, for example, `rustup target add x86_64-pc-windows-msvc` -3. Run `cargo xwinbuild`, for example, `cargo xwinbuild --target x86_64-pc-windows-msvc` +3. Run `cargo xwin`, 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 xwintest` command, -for example, `cargo xwintest --target x86_64-pc-windows-msvc` +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 @@ -46,7 +48,7 @@ The Microsoft CRT and Windows SDK can be customized using the following environm ### CMake Support Some Rust crates use the [cmake](https://github.com/alexcrichton/cmake-rs) crate to build C/C++ dependencies, -cargo-xwinbuild will generate a [CMake toolchain](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html) file +cargo-xwin will generate a [CMake toolchain](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html) file automatically to make cross compilation work out of the box. **[ninja](https://ninja-build.org/) is required** to enable CMake support. diff --git a/pyproject.toml b/pyproject.toml index 756a845..4e6dd25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["maturin>=0.12,<0.13"] build-backend = "maturin" [project] -name = "cargo-xwinbuild" +name = "cargo-xwin" dependencies = ["ninja"] [tool.maturin] diff --git a/src/bin/cargo-xwin.rs b/src/bin/cargo-xwin.rs new file mode 100644 index 0000000..f4ce522 --- /dev/null +++ b/src/bin/cargo-xwin.rs @@ -0,0 +1,30 @@ +use cargo_xwin::{Build, Test}; +use clap::{Parser, Subcommand}; + +#[derive(Debug, Parser)] +#[clap(version, name = "cargo")] +pub enum Cli { + #[clap(subcommand, name = "xwin")] + Opt(Opt), +} + +#[allow(clippy::large_enum_variant)] +#[derive(Debug, Subcommand)] +#[clap(global_setting(clap::AppSettings::DeriveDisplayOrder))] +pub enum Opt { + #[clap(name = "build")] + Build(Build), + #[clap(name = "test")] + Test(Test), +} + +fn main() -> anyhow::Result<()> { + let cli = Cli::parse(); + match cli { + Cli::Opt(opt) => match opt { + Opt::Build(build) => build.execute()?, + Opt::Test(test) => test.execute()?, + }, + } + Ok(()) +} diff --git a/src/bin/cargo-xwinbuild.rs b/src/bin/cargo-xwinbuild.rs deleted file mode 100644 index 5b3b059..0000000 --- a/src/bin/cargo-xwinbuild.rs +++ /dev/null @@ -1,22 +0,0 @@ -use cargo_xwinbuild::Build; -use clap::Parser; - -#[allow(clippy::large_enum_variant)] -#[derive(Debug, Parser)] -#[clap( - version, - name = "cargo", - global_setting(clap::AppSettings::DeriveDisplayOrder) -)] -pub enum Opt { - #[clap(name = "xwinbuild")] - Build(Build), -} - -fn main() -> anyhow::Result<()> { - let opt = Opt::parse(); - match opt { - Opt::Build(build) => build.execute()?, - } - Ok(()) -} diff --git a/src/bin/cargo-xwintest.rs b/src/bin/cargo-xwintest.rs deleted file mode 100644 index bf577a4..0000000 --- a/src/bin/cargo-xwintest.rs +++ /dev/null @@ -1,22 +0,0 @@ -use cargo_xwinbuild::Test; -use clap::Parser; - -#[allow(clippy::large_enum_variant)] -#[derive(Debug, Parser)] -#[clap( - version, - name = "cargo", - global_setting(clap::AppSettings::DeriveDisplayOrder) -)] -pub enum Opt { - #[clap(name = "xwintest")] - Test(Test), -} - -fn main() -> anyhow::Result<()> { - let opt = Opt::parse(); - match opt { - Opt::Test(test) => test.execute()?, - } - Ok(()) -}