Skip to content

Commit 1515d1a

Browse files
committed
Add ability to retain debuginfo before stripping binaries
1 parent c9f1caf commit 1515d1a

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.github/.cspell/project-dictionary.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ gtar
33
lipo
44
mktemp
55
tmpdir
6+
DEBUGINFO
7+
debuginfo
8+
debuginfos
9+
objcopy

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ inputs:
6868
description: The cargo profile to build. This defaults to the release profile.
6969
required: false
7070
default: 'release'
71+
split_debuginfo:
72+
description: Split debuginfos off of the production binary using objcopy before stripping.
73+
required: false
74+
default: 'false'
7175

7276
# TODO: allow kebab-case input option names?
7377
# Note:
@@ -95,3 +99,4 @@ runs:
9599
INPUT_TOKEN: ${{ inputs.token }}
96100
INPUT_REF: ${{ inputs.ref }}
97101
INPUT_PROFILE: ${{ inputs.profile }}
102+
INPUT_SPLIT_DEBUGINFO: ${{ inputs.split_debuginfo }}

main.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ elif [[ ! "${INPUT_ZIP}" =~ ^(all|unix|windows|none)$ ]]; then
4747
bail "invalid input 'zip': ${INPUT_ZIP}"
4848
fi
4949

50+
split_debuginfo="${INPUT_SPLIT_DEBUGINFO:-}"
51+
case "${split_debuginfo}" in
52+
true) split_debuginfo="1" ;;
53+
false) split_debuginfo="" ;;
54+
*) bail "'split_debuginfo' input option must be 'true' or 'false': '${split_debuginfo}'" ;;
55+
esac
56+
5057
leading_dir="${INPUT_LEADING_DIR:-}"
5158
case "${leading_dir}" in
5259
true) leading_dir="1" ;;
@@ -245,6 +252,11 @@ build() {
245252
do_strip() {
246253
target_dir="$1"
247254
if [[ -n "${strip:-}" ]]; then
255+
if [[ -n "${split_debuginfo}" ]]; then
256+
for bin_exe in "${bins[@]}"; do
257+
x objcopy --only-keep-debug "${target_dir}/${bin_exe}" "${target_dir}/${bin_exe}.debug"
258+
done
259+
fi
248260
for bin_exe in "${bins[@]}"; do
249261
x "${strip}" "${target_dir}/${bin_exe}"
250262
done

0 commit comments

Comments
 (0)