From 27a9585f53edb6bf1e26a15f3688c4003a1bd11a Mon Sep 17 00:00:00 2001 From: John Whittington Date: Tue, 6 Dec 2022 14:15:16 +0100 Subject: [PATCH] do strip with Cargo profile --- .github/workflows/build.yml | 39 ++++++++++--------------------------- Cargo.toml | 8 +++++++- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 147e9c29..a3e5ddaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,49 +48,30 @@ jobs: run: | cargo build --locked --release --all-features --target=${{ matrix.job.target }} - - name: Strip debug information from executable - id: strip + - name: Prepare and extract crate information + id: prepare shell: bash run: | + echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> "$GITHUB_ENV" + echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> "$GITHUB_ENV" + echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> "$GITHUB_ENV" + # Figure out suffix of binary EXE_suffix="" case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac; - # Figure out what strip tool to use if any - STRIP="strip" - case ${{ matrix.job.target }} in - arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; - aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; - *-pc-windows-msvc) STRIP="" ;; - esac; - # Setup paths - BIN_DIR="${{ env.INTERMEDIATES_DIR }}/stripped-release-bin/" + BIN_DIR="${{ env.INTERMEDIATES_DIR }}/release-bin/" mkdir -p "${BIN_DIR}" BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}" BIN_PATH="${BIN_DIR}/${BIN_NAME}" - # Copy the release build binary to the result location - cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}" - - # Also strip if possible - if [ -n "${STRIP}" ]; then - "${STRIP}" "${BIN_PATH}" - fi - - # Let subsequent steps know where to find the (stripped) bin + # Let subsequent steps know where to find the release bin echo "BIN_PATH=${BIN_PATH}" >> "$GITHUB_OUTPUT" echo "BIN_NAME=${BIN_NAME}" >> "$GITHUB_OUTPUT" - - name: Extract crate information - shell: bash - run: | - echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> "$GITHUB_ENV" - echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> "$GITHUB_ENV" - echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> "$GITHUB_ENV" - - name: Create tarball id: package shell: bash @@ -107,10 +88,10 @@ jobs: mkdir -p "${ARCHIVE_DIR}" # generate cli data - "${{ steps.strip.outputs.BIN_PATH }}" --gen + "${{ steps.prepare.outputs.BIN_PATH }}" --gen # Binary - cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR" + cp "${{ steps.prepare.outputs.BIN_PATH }}" "$ARCHIVE_DIR" # README and LICENSE cp "README.md" "LICENSE" "$ARCHIVE_DIR" # Man page diff --git a/Cargo.toml b/Cargo.toml index 7bacb02c..c9458284 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ description = "List system USB buses and devices; a modern and compatible `lsusb repository = "https://github.com/tuna-f1sh/cyme" readme = "README.md" license = "GPL-3.0-or-later" -version = "1.1.0" +version = "1.1.1" edition = "2021" keywords = ["usb", "lsusb", "system_profiler", "macos", "libusb"] categories = ["command-line-utilities"] @@ -48,3 +48,9 @@ default = ["libusb"] [[bin]] name = "cyme" path = "src/main.rs" + +[profile.release] +lto = true +strip = true +panic = "abort" +codegen-units = 1 # quicker binary, slower build