Skip to content

Commit

Permalink
Add ability to retain debuginfo before stripping binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
brancz committed Jul 17, 2023
1 parent c9f1caf commit 09dd859
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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

0 comments on commit 09dd859

Please sign in to comment.