Skip to content

Commit

Permalink
do strip with Cargo profile
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Dec 6, 2022
1 parent 23d9515 commit 27a9585
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
39 changes: 10 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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

0 comments on commit 27a9585

Please sign in to comment.