Skip to content

Commit

Permalink
Use strip to reduce artifacts size
Browse files Browse the repository at this point in the history
  • Loading branch information
er2off committed May 21, 2023
1 parent 383d2e5 commit c7895b2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on: [push, pull_request]
env:
WAF_FLAGS: -T release --disable-warns --prefix=build_hl2
WAF_FLAGS: -T debug --disable-warns --prefix=build_hl2

jobs:
build-linux:
Expand Down Expand Up @@ -52,14 +52,20 @@ jobs:
- name: Configure
run: ./waf configure ${{ matrix.bits }} ${{ matrix.android }} ${{ matrix.flags }} $WAF_FLAGS
- name: Build ${{ matrix.os }}
run: ./waf install
- name: Tar binaries
run: tar cvf build.tar build_hl2
- name: Upload artifact
run: ./waf install --strip-to-file
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}
path: |
build_hl2
!build_hl2/**/*.debug
- name: Upload debug symbols
uses: actions/upload-artifact@v3
with:
name: Linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}.tar
path: build.tar
name: debug-Linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}
path: |
build_hl2/**/*.debug
build-macos:
strategy:
Expand All @@ -78,14 +84,20 @@ jobs:
- name: Configure
run: ./waf configure --64bits ${{ matrix.flags }} $WAF_FLAGS
- name: Build macos-amd64
run: ./waf install
- name: Tar binaries
run: tar cvf build.tar build_hl2
- name: Upload artifact
run: ./waf install --strip-to-file
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: macOS--64bits${{matrix.flags}}${{matrix.android}}
path: |
build_hl2
!build_hl2/**/*.dSYM
- name: Upload debug symbols
uses: actions/upload-artifact@v3
with:
name: macOS--64bits${{matrix.flags}}.tar
path: build.tar
name: debug-macOS--64bits${{matrix.flags}}${{matrix.android}}
path: |
build_hl2/**/*.dSYM
build-windows:
strategy:
Expand Down
21 changes: 15 additions & 6 deletions scripts/waifulib/strip_on_install_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def configure(conf):

if conf.env.DEST_BINFMT == 'mac-o':
conf.env.STRIPFLAGS += ['-x']
conf.find_program('dsymutil', var='DSYMUTIL')
conf.env.STRIPFLAGS += ['-S'] # we will use .dSYM instead
return # macOS don't have objcopy

# a1ba: I am lazy to add `export OBJCOPY=` everywhere in my scripts
Expand Down Expand Up @@ -56,12 +58,19 @@ def copy_fun(self, src, tgt):
c3 = Logs.colors.YELLOW
c4 = Logs.colors.BLUE
try:
if self.generator.bld.options.strip_to_file and self.env.DEST_BINFMT == 'elf':
ocopy_cmd = self.env.OBJCOPY + ['--only-keep-debug', tgt, tgt_debug]
self.generator.bld.cmd_and_log(ocopy_cmd, output=Context.BOTH, quiet=Context.BOTH)
if not self.generator.bld.progress_bar:
Logs.info('%s+ objcopy --only-keep-debug %s%s%s %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)

if self.generator.bld.options.strip_to_file:
if self.env.DEST_BINFMT == 'elf':
ocopy_cmd = self.env.OBJCOPY + ['--only-keep-debug', tgt, tgt_debug]
self.generator.bld.cmd_and_log(ocopy_cmd, output=Context.BOTH, quiet=Context.BOTH)
if not self.generator.bld.progress_bar:
Logs.info('%s+ objcopy --only-keep-debug %s%s%s %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)
elif self.env.DEST_BINFMT == 'mac-o':
tgt_debug = os.path.splitext(tgt)[0] + '.dSYM'
dsymutil_cmd = self.env.DSYMUTIL + [tgt, '-o', tgt_debug]
self.generator.bld.cmd_and_log(dsymutil_cmd, output=Context.BOTH, quiet=Context.BOTH)
if not self.generator.bld.progress_bar:
Logs.info('%s+ dsymutil %s%s%s -o %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)

strip_cmd = self.env.STRIP + self.env.STRIPFLAGS + [tgt]
self.generator.bld.cmd_and_log(strip_cmd, output=Context.BOTH, quiet=Context.BOTH)
if not self.generator.bld.progress_bar:
Expand Down

0 comments on commit c7895b2

Please sign in to comment.