From 67780ad2890e589b5b044a9f97d6b82815ba83e6 Mon Sep 17 00:00:00 2001 From: Bruno Dutra Date: Sat, 2 Dec 2023 14:41:24 +0100 Subject: [PATCH] basic make script to build distributable binaries --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ Makefile.toml | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Makefile.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa480aac..8e869c73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,3 +94,28 @@ jobs: with: token: ${{secrets.CODECOV_TOKEN}} fail_ci_if_error: true + + dist: + needs: [fmt, clippy, audit, check, doc] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: macOS-latest + target: x86_64-apple-darwin + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rust-src + targets: ${{ matrix.target }} + - run: sudo apt install -y musl-tools + if: runner.os == 'Linux' + - run: cargo install --force cargo-make + - run: cargo make dist diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 00000000..112ecb94 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,24 @@ +[tasks.env] +env = { TARGET = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", FLAGS = '[]' } + +[tasks.env.linux] +env = { TARGET = "x86_64-unknown-linux-musl", FLAGS = '["-Ctarget-feature=+crt-static", "-Crelocation-model=static"]' } + +[tasks.env.mac] +env = { TARGET = "x86_64-apple-darwin", FLAGS = '["-Ctarget-feature=+crt-static", "-Crelocation-model=static"]' } + +[tasks.env.windows] +env = { TARGET = "x86_64-pc-windows-msvc", FLAGS = '["-Ctarget-feature=+crt-static"]' } + +[tasks.dist] +dependencies = ["env"] +command = "cargo" +args = [ + "build", + "-Zbuild-std=core,alloc,std,panic_abort", + "-Zbuild-std-features=panic_immediate_abort", + "-Zunstable-options", + "--config=build.rustflags = ${FLAGS}", + "--target=${TARGET}", + "--release", +]