Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to retain debuginfo before stripping binaries #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ gtar
lipo
mktemp
tmpdir
debuginfo
debuginfos
objcopy
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ inputs:
description: The cargo profile to build. This defaults to the release profile.
required: false
default: 'release'
split_debuginfo:
description: Split debuginfos off of the production binary using objcopy before stripping.
required: false
default: 'false'

# TODO: allow kebab-case input option names?
# Note:
Expand Down Expand Up @@ -95,3 +99,4 @@ runs:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_REF: ${{ inputs.ref }}
INPUT_PROFILE: ${{ inputs.profile }}
INPUT_SPLIT_DEBUGINFO: ${{ inputs.split_debuginfo }}
12 changes: 12 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ elif [[ ! "${INPUT_ZIP}" =~ ^(all|unix|windows|none)$ ]]; then
bail "invalid input 'zip': ${INPUT_ZIP}"
fi

split_debuginfo="${INPUT_SPLIT_DEBUGINFO:-}"
case "${split_debuginfo}" in
true) split_debuginfo="1" ;;
false) split_debuginfo="" ;;
*) bail "'split_debuginfo' input option must be 'true' or 'false': '${split_debuginfo}'" ;;
esac

leading_dir="${INPUT_LEADING_DIR:-}"
case "${leading_dir}" in
true) leading_dir="1" ;;
Expand Down Expand Up @@ -245,6 +252,11 @@ build() {
do_strip() {
target_dir="$1"
if [[ -n "${strip:-}" ]]; then
if [[ -n "${split_debuginfo}" ]]; then
for bin_exe in "${bins[@]}"; do
x objcopy --only-keep-debug "${target_dir}/${bin_exe}" "${target_dir}/${bin_exe}.debug"
done
fi
for bin_exe in "${bins[@]}"; do
x "${strip}" "${target_dir}/${bin_exe}"
done
Expand Down