Skip to content

Commit 1cf0027

Browse files
author
John Kleinschmidt
authored
ci: strip linux binaries for release builds (electron#14991)
1 parent d678d9e commit 1cf0027

4 files changed

Lines changed: 97 additions & 37 deletions

File tree

.circleci/config.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ step-electron-build: &step-electron-build
157157
cd src
158158
ninja -C out/Default electron -j18
159159
160+
step-electron-dist-strip: &step-electron-dist-strip
161+
run:
162+
name: Strip electron binaries
163+
command: |
164+
cd src
165+
electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH"
166+
160167
step-electron-dist-build: &step-electron-dist-build
161168
run:
162169
name: Build dist.zip
@@ -176,7 +183,9 @@ step-electron-chromedriver-build: &step-electron-chromedriver-build
176183
cd src
177184
# NOTE(alexeykuzmin): -j3 because chromedriver is currently built
178185
# on a smaller size machine and ninja mis-detects the number of CPUs available.
179-
ninja -C out/Default electron:electron_chromedriver_zip -j3
186+
ninja -C out/Default chrome/test/chromedriver -j3
187+
electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH" --file $PWD/out/Default/chromedriver
188+
ninja -C out/Default electron:electron_chromedriver_zip
180189
181190
step-electron-chromedriver-store: &step-electron-chromedriver-store
182191
store_artifacts:
@@ -278,6 +287,15 @@ step-mksnapshot-build: &step-mksnapshot-build
278287
name: mksnapshot build
279288
command: |
280289
cd src
290+
if [ "`uname`" != "Darwin" ]; then
291+
if [ "$TARGET_ARCH" == "arm" ]; then
292+
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x86_v8_arm/mksnapshot
293+
elif [ "$TARGET_ARCH" == "arm64" ]; then
294+
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x64_v8_arm64/mksnapshot
295+
else
296+
electron/script/strip-binaries.py --file $PWD/out/Default/mksnapshot
297+
fi
298+
fi
281299
# NOTE(jeremy): -j3 because mksnapshot is currently built on a smaller
282300
# machine size and ninja mis-detects the number of CPUs available.
283301
ninja -C out/Default electron:electron_mksnapshot_zip -j3
@@ -326,6 +344,17 @@ step-maybe-native-mksnapshot-build: &step-maybe-native-mksnapshot-build
326344
echo 'Skipping native mksnapshot build for non arm build'
327345
fi
328346
347+
step-maybe-native-mksnapshot-strip: &step-maybe-native-mksnapshot-strip
348+
run:
349+
name: Native mksnapshot binary strip (arm/arm64)
350+
command: |
351+
if [ "$BUILD_NATIVE_MKSNAPSHOT" == "1" ]; then
352+
cd src
353+
electron/script/strip-binaries.py --file $PWD/out/native_mksnapshot/mksnapshot --target-cpu="$TARGET_ARCH"
354+
else
355+
echo 'Skipping native mksnapshot binary strip'
356+
fi
357+
329358
step-maybe-native-mksnapshot-store: &step-maybe-native-mksnapshot-store
330359
store_artifacts:
331360
path: src/out/native_mksnapshot/mksnapshot.zip
@@ -394,7 +423,7 @@ steps-electron-build: &steps-electron-build
394423

395424
# Node.js headers
396425
- *step-nodejs-headers-build
397-
- *step-nodejs-headers-store
426+
- *step-nodejs-headers-store
398427

399428
- *step-show-sccache-stats
400429

@@ -440,6 +469,7 @@ steps-electron-build-for-publish: &steps-electron-build-for-publish
440469

441470
# Electron app
442471
- *step-electron-build
472+
- *step-electron-dist-strip
443473
- *step-electron-dist-build
444474
- *step-electron-dist-store
445475
- *step-generate-breakpad-symbols
@@ -451,6 +481,7 @@ steps-electron-build-for-publish: &steps-electron-build-for-publish
451481
# native_mksnapshot
452482
- *step-maybe-native-mksnapshot-gn-gen
453483
- *step-maybe-native-mksnapshot-build
484+
- *step-maybe-native-mksnapshot-strip
454485
- *step-maybe-native-mksnapshot-store
455486

456487
# chromedriver

build/zip.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
import sys
55
import zipfile
66

7-
LINUX_BINARIES_TO_STRIP = [
8-
'chromedriver',
9-
'electron',
10-
'libffmpeg.so',
11-
'libnode.so'
12-
]
13-
147
EXTENSIONS_TO_SKIP = [
158
'.pdb'
169
]
@@ -30,22 +23,6 @@ def skip_path(dep):
3023
print("Skipping {}".format(dep))
3124
return should_skip
3225

33-
def strip_binaries(target_cpu, dep):
34-
for binary in LINUX_BINARIES_TO_STRIP:
35-
if dep.endswith(binary):
36-
strip_binary(dep, target_cpu)
37-
38-
def strip_binary(binary_path, target_cpu):
39-
if target_cpu == 'arm':
40-
strip = 'arm-linux-gnueabihf-strip'
41-
elif target_cpu == 'arm64':
42-
strip = 'aarch64-linux-gnu-strip'
43-
elif target_cpu == 'mips64el':
44-
strip = 'mips64el-redhat-linux-strip'
45-
else:
46-
strip = 'strip'
47-
execute([strip, binary_path])
48-
4926
def execute(argv):
5027
try:
5128
output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
@@ -66,8 +43,6 @@ def main(argv):
6643
else:
6744
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED) as z:
6845
for dep in dist_files:
69-
if target_os == 'linux':
70-
strip_binaries(target_cpu, dep)
7146
if skip_path(dep):
7247
continue
7348
if os.path.isdir(dep):

script/ci-release-build.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,8 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
6262
}
6363
}
6464

65-
if (options.ghRelease) {
66-
buildRequest.build_parameters.ELECTRON_RELEASE = 1
67-
} else {
68-
buildRequest.build_parameters.RUN_RELEASE_BUILD = 'true'
69-
}
70-
71-
if (options.automaticRelease) {
72-
buildRequest.build_parameters.AUTO_RELEASE = 'true'
65+
if (!options.ghRelease) {
66+
buildRequest.build_parameters.UPLOAD_TO_S3 = 1
7367
}
7468

7569
const circleResponse = await makeRequest({
@@ -237,13 +231,13 @@ module.exports = runRelease
237231

238232
if (require.main === module) {
239233
const args = require('minimist')(process.argv.slice(2), {
240-
boolean: ['ghRelease', 'automaticRelease', 'armTest']
234+
boolean: ['ghRelease', 'armTest']
241235
})
242236
const targetBranch = args._[0]
243237
if (args._.length < 1) {
244238
console.log(`Trigger CI to build release builds of electron.
245239
Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor|VSTS]
246-
[--ghRelease] [--automaticRelease] [--armTest] [--circleBuildNum=xxx] TARGET_BRANCH
240+
[--ghRelease] [--armTest] [--circleBuildNum=xxx] TARGET_BRANCH
247241
`)
248242
process.exit(0)
249243
}

script/strip-binaries.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import os
4+
import sys
5+
6+
from lib.util import execute, get_out_dir
7+
8+
LINUX_BINARIES_TO_STRIP = [
9+
'electron',
10+
'libffmpeg.so',
11+
'libGLESv2.so',
12+
'libEGL.so'
13+
]
14+
15+
def strip_binaries(directory, target_cpu):
16+
for binary in LINUX_BINARIES_TO_STRIP:
17+
binary_path = os.path.join(directory, binary)
18+
if os.path.isfile(binary_path):
19+
strip_binary(binary_path, target_cpu)
20+
21+
def strip_binary(binary_path, target_cpu):
22+
if target_cpu == 'arm':
23+
strip = 'arm-linux-gnueabihf-strip'
24+
elif target_cpu == 'arm64':
25+
strip = 'aarch64-linux-gnu-strip'
26+
elif target_cpu == 'mips64el':
27+
strip = 'mips64el-redhat-linux-strip'
28+
else:
29+
strip = 'strip'
30+
execute([strip, binary_path])
31+
32+
def main():
33+
args = parse_args()
34+
print args
35+
if args.file:
36+
strip_binary(args.file, args.target_cpu)
37+
else:
38+
strip_binaries(args.directory, args.target_cpu)
39+
40+
def parse_args():
41+
parser = argparse.ArgumentParser(description='Strip linux binaries')
42+
parser.add_argument('-d', '--directory',
43+
help='Path to the dir that contains files to strip.',
44+
default=get_out_dir(),
45+
required=False)
46+
parser.add_argument('-f', '--file',
47+
help='Path to a specific file to strip.',
48+
required=False)
49+
parser.add_argument('-v', '--verbose',
50+
action='store_true',
51+
help='Prints the output of the subprocesses')
52+
parser.add_argument('--target-cpu',
53+
default='',
54+
required=False,
55+
help='Target cpu of binaries to strip')
56+
57+
return parser.parse_args()
58+
59+
if __name__ == '__main__':
60+
sys.exit(main())

0 commit comments

Comments
 (0)