Skip to content

Commit c7895b2

Browse files
committed
Use strip to reduce artifacts size
1 parent 383d2e5 commit c7895b2

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

.github/workflows/build.yml

+25-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on: [push, pull_request]
44
env:
5-
WAF_FLAGS: -T release --disable-warns --prefix=build_hl2
5+
WAF_FLAGS: -T debug --disable-warns --prefix=build_hl2
66

77
jobs:
88
build-linux:
@@ -52,14 +52,20 @@ jobs:
5252
- name: Configure
5353
run: ./waf configure ${{ matrix.bits }} ${{ matrix.android }} ${{ matrix.flags }} $WAF_FLAGS
5454
- name: Build ${{ matrix.os }}
55-
run: ./waf install
56-
- name: Tar binaries
57-
run: tar cvf build.tar build_hl2
58-
- name: Upload artifact
55+
run: ./waf install --strip-to-file
56+
- name: Upload build
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}
60+
path: |
61+
build_hl2
62+
!build_hl2/**/*.debug
63+
- name: Upload debug symbols
5964
uses: actions/upload-artifact@v3
6065
with:
61-
name: Linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}.tar
62-
path: build.tar
66+
name: debug-Linux${{matrix.bits}}${{matrix.flags}}${{matrix.android}}
67+
path: |
68+
build_hl2/**/*.debug
6369
6470
build-macos:
6571
strategy:
@@ -78,14 +84,20 @@ jobs:
7884
- name: Configure
7985
run: ./waf configure --64bits ${{ matrix.flags }} $WAF_FLAGS
8086
- name: Build macos-amd64
81-
run: ./waf install
82-
- name: Tar binaries
83-
run: tar cvf build.tar build_hl2
84-
- name: Upload artifact
87+
run: ./waf install --strip-to-file
88+
- name: Upload build
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: macOS--64bits${{matrix.flags}}${{matrix.android}}
92+
path: |
93+
build_hl2
94+
!build_hl2/**/*.dSYM
95+
- name: Upload debug symbols
8596
uses: actions/upload-artifact@v3
8697
with:
87-
name: macOS--64bits${{matrix.flags}}.tar
88-
path: build.tar
98+
name: debug-macOS--64bits${{matrix.flags}}${{matrix.android}}
99+
path: |
100+
build_hl2/**/*.dSYM
89101
90102
build-windows:
91103
strategy:

scripts/waifulib/strip_on_install_v2.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def configure(conf):
2525

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

3032
# a1ba: I am lazy to add `export OBJCOPY=` everywhere in my scripts
@@ -56,12 +58,19 @@ def copy_fun(self, src, tgt):
5658
c3 = Logs.colors.YELLOW
5759
c4 = Logs.colors.BLUE
5860
try:
59-
if self.generator.bld.options.strip_to_file and self.env.DEST_BINFMT == 'elf':
60-
ocopy_cmd = self.env.OBJCOPY + ['--only-keep-debug', tgt, tgt_debug]
61-
self.generator.bld.cmd_and_log(ocopy_cmd, output=Context.BOTH, quiet=Context.BOTH)
62-
if not self.generator.bld.progress_bar:
63-
Logs.info('%s+ objcopy --only-keep-debug %s%s%s %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)
64-
61+
if self.generator.bld.options.strip_to_file:
62+
if self.env.DEST_BINFMT == 'elf':
63+
ocopy_cmd = self.env.OBJCOPY + ['--only-keep-debug', tgt, tgt_debug]
64+
self.generator.bld.cmd_and_log(ocopy_cmd, output=Context.BOTH, quiet=Context.BOTH)
65+
if not self.generator.bld.progress_bar:
66+
Logs.info('%s+ objcopy --only-keep-debug %s%s%s %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)
67+
elif self.env.DEST_BINFMT == 'mac-o':
68+
tgt_debug = os.path.splitext(tgt)[0] + '.dSYM'
69+
dsymutil_cmd = self.env.DSYMUTIL + [tgt, '-o', tgt_debug]
70+
self.generator.bld.cmd_and_log(dsymutil_cmd, output=Context.BOTH, quiet=Context.BOTH)
71+
if not self.generator.bld.progress_bar:
72+
Logs.info('%s+ dsymutil %s%s%s -o %s%s%s', c1, c4, tgt, c1, c3, tgt_debug, c1)
73+
6574
strip_cmd = self.env.STRIP + self.env.STRIPFLAGS + [tgt]
6675
self.generator.bld.cmd_and_log(strip_cmd, output=Context.BOTH, quiet=Context.BOTH)
6776
if not self.generator.bld.progress_bar:

0 commit comments

Comments
 (0)