Skip to content

Commit bf76104

Browse files
committed
add options for workflows with strip and debug symbols
Signed-off-by: Avi Deitcher <[email protected]>
1 parent 4e7952b commit bf76104

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

.github/workflows/build-reusable.yaml

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ on:
3030
description: "Languages list"
3131
type: string
3232
default: '[""]'
33+
strip:
34+
description: "Options to build unstripped, stripped or both, must be one of 'unstripped', 'stripped', 'both'"
35+
type: string
36+
default: 'unstripped'
3337
report:
3438
description: "Generate build report"
3539
type: boolean
@@ -69,10 +73,23 @@ jobs:
6973
echo "C model list: ${{ inputs.cmodel }}"
7074
echo "Report: ${{ inputs.report }}"
7175
echo "Languages list: ${{ inputs.languages }}"
76+
echo "Strip: ${{ inputs.strip }}"
7277
echo "Simulator: ${{ inputs.sim }}"
7378
79+
validate_inputs:
80+
name: Validate inputs
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Check strip input
84+
run: |
85+
if [[ "${{ inputs.strip }}" != "unstripped" && "${{ inputs.strip }}" != "stripped" && "${{ inputs.strip }}" != "both" ]]; then
86+
echo "Invalid strip option: ${{ inputs.strip }}. Must be one of 'unstripped', 'stripped', 'both'."
87+
exit 1
88+
fi
89+
7490
submodule_cache:
7591
name: Initialize submodule cache
92+
needs: [validate_inputs]
7693
runs-on: ubuntu-latest
7794
outputs:
7895
key: ${{ steps.keygen.outputs.smcache_key }}
@@ -104,7 +121,7 @@ jobs:
104121
105122
build:
106123
runs-on: ${{ matrix.os }}
107-
needs: [submodule_cache]
124+
needs: [submodule_cache,validate_inputs]
108125
env:
109126
smcache_key: ${{ needs.submodule_cache.outputs.key }}
110127
strategy:
@@ -158,17 +175,13 @@ jobs:
158175
if [ -n "${{ matrix.languages }}" ]; then
159176
ARGS="$ARGS --enable-languages=${{ matrix.languages }}"
160177
fi
178+
if [ "${{ matrix.strip }}" = "true" ]; then
179+
ARGS="$ARGS --enable-strip"
180+
fi
161181
$BUILD_TOOLCHAIN $ARGS
162182
sudo mkdir /mnt/riscv
163183
sudo chown runner:runner /mnt/riscv
164184
make -j $(nproc) ${{ matrix.mode }}
165-
166-
- name: tarball build
167-
run: |
168-
du -s -h /mnt/riscv
169-
./.github/dedup-dir.sh /mnt/riscv/
170-
XZ_OPT="-e -T0" tar cJvf riscv.tar.xz -C /mnt/ riscv/
171-
172185
- name: make report
173186
if: |
174187
matrix.os == 'ubuntu-24.04'
@@ -196,12 +209,32 @@ jobs:
196209
if [ -n "$ARTIFACT_NAME" ]; then
197210
ARTIFACT_NAME="-${ARTIFACT_NAME}"
198211
fi
199-
echo "TOOLCHAIN_NAME=riscv$BITS-$MODE-${{ matrix.os }}-${{ matrix.compiler }}${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
200-
201-
- name: Move output to representative name
212+
BASE_NAME="riscv$BITS-$MODE-${{ matrix.os }}-${{ matrix.compiler }}"
213+
echo "TOOLCHAIN_NAME=${BASE_NAME}${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
214+
echo "TOOLCHAIN_NAME_STRIPPED=${BASE_NAME}-stripped${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
215+
- name: tarball build unstripped
216+
if: ${{ inputs.strip == 'unstripped' || inputs.strip == 'both' }}
202217
run: |
218+
du -s -h /mnt/riscv
219+
./.github/dedup-dir.sh /mnt/riscv/
220+
XZ_OPT="-e -T0" tar cJvf riscv.tar.xz -C /mnt/ riscv/
203221
mv riscv.tar.xz ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}.tar.xz
222+
- name: strip binaries
223+
run: |
224+
find /mnt/riscv -type f -exec strip {} \;
225+
- name: tarball build stripped
226+
if: ${{ inputs.strip == 'stripped' || inputs.strip == 'both' }}
227+
run: |
228+
du -s -h /mnt/riscv
229+
XZ_OPT="-e -T0" tar cJvf riscv-stripped.tar.xz -C /mnt/ riscv/
230+
mv riscv-stripped.tar.xz ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME_STRIPPED }}.tar.xz
204231
- uses: actions/upload-artifact@v4
232+
if: ${{ inputs.strip == 'unstripped' || inputs.strip == 'both' }}
205233
with:
206234
name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}
207235
path: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}.tar.xz
236+
- uses: actions/upload-artifact@v4
237+
if: ${{ inputs.strip == 'stripped' || inputs.strip == 'both' }}
238+
with:
239+
name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME_STRIPPED }}
240+
path: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME_STRIPPED }}.tar.xz

0 commit comments

Comments
 (0)