Skip to content

Commit

Permalink
Merge pull request #8 from messense/rename
Browse files Browse the repository at this point in the history
Rename to cargo-xwin
  • Loading branch information
messense authored Mar 6, 2022
2 parents 4017930 + 9bdf88d commit a36aff5
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 84 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/')"
Expand All @@ -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 }}
Expand Down Expand Up @@ -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/')"
Expand All @@ -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') }}
Expand Down Expand Up @@ -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/')"
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.)

Expand All @@ -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

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["maturin>=0.12,<0.13"]
build-backend = "maturin"

[project]
name = "cargo-xwinbuild"
name = "cargo-xwin"
dependencies = ["ninja"]

[tool.maturin]
Expand Down
30 changes: 30 additions & 0 deletions src/bin/cargo-xwin.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
22 changes: 0 additions & 22 deletions src/bin/cargo-xwinbuild.rs

This file was deleted.

22 changes: 0 additions & 22 deletions src/bin/cargo-xwintest.rs

This file was deleted.

0 comments on commit a36aff5

Please sign in to comment.