Skip to content

Commit 7acbbf2

Browse files
author
John Kleinschmidt
committed
Add logic to bundle native mksnapshot for arm/arm64
1 parent 23bb3bd commit 7acbbf2

4 files changed

Lines changed: 53 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
/vendor/llvm/
4141
/vendor/npm/
4242
/vendor/python_26/
43+
/vendor/native_mksnapshot
44+
/vendor/LICENSES.chromium.html
4345
node_modules/
4446
SHASUMS256.txt
4547
**/package-lock.json

script/bootstrap.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def main():
4040
if args.target_arch == 'mips64el':
4141
download_mips64el_toolchain()
4242

43+
if args.target_arch.startswith('arm'):
44+
download_native_mksnapshot(args.target_arch)
45+
4346
# Redirect to use local libchromiumcontent build.
4447
if args.build_release_libcc or args.build_debug_libcc:
4548
build_libchromiumcontent(args.verbose, args.target_arch,
@@ -216,6 +219,15 @@ def download_mips64el_toolchain():
216219
subprocess.check_call(['tar', '-xf', tar_name, '-C', VENDOR_DIR])
217220
os.remove(tar_name)
218221

222+
def download_native_mksnapshot(arch):
223+
if not os.path.exists(os.path.join(VENDOR_DIR,
224+
'native_mksnapshot')):
225+
tar_name = 'native-mksnapshot.tar.bz2'
226+
url = '{0}/linux/{1}/{2}/{3}'.format(BASE_URL, arch,
227+
get_libchromiumcontent_commit(), tar_name)
228+
download(tar_name, url, os.path.join(SOURCE_ROOT, tar_name))
229+
subprocess.call(['tar', '-jxf', tar_name, '-C', VENDOR_DIR])
230+
os.remove(tar_name)
219231

220232
def create_chrome_version_h():
221233
version_file = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'VERSION')

script/create-dist.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
2525
CHROMIUM_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'download',
2626
'libchromiumcontent', 'static_library')
27+
NATIVE_MKSNAPSHOT_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'native_mksnapshot')
2728

2829
PROJECT_NAME = electron_gyp()['project_name%']
2930
PRODUCT_NAME = electron_gyp()['product_name%']
@@ -141,7 +142,6 @@ def copy_chrome_binary(binary):
141142
shutil.copyfile(src, dest)
142143
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
143144

144-
145145
def copy_vcruntime_binaries():
146146
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
147147
r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC", 0,
@@ -260,17 +260,39 @@ def create_dist_zip():
260260

261261

262262
def create_chrome_binary_zip(binary, version):
263-
dist_name = get_zip_name(binary, version)
263+
file_suffix = ''
264+
create_native_mksnapshot = False
265+
if binary == 'mksnapshot':
266+
arch = get_target_arch()
267+
if arch.startswith('arm'):
268+
# if the arch is arm/arm64 the mksnapshot executable is an x64 binary,
269+
# so name it as such.
270+
file_suffix = 'x64'
271+
create_native_mksnapshot = True
272+
dist_name = get_zip_name(binary, version, file_suffix)
264273
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
265274

275+
files = ['LICENSE', 'LICENSES.chromium.html']
276+
if PLATFORM == 'win32':
277+
files += [binary + '.exe']
278+
else:
279+
files += [binary]
280+
266281
with scoped_cwd(DIST_DIR):
267-
files = ['LICENSE', 'LICENSES.chromium.html']
268-
if PLATFORM == 'win32':
269-
files += [binary + '.exe']
270-
else:
271-
files += [binary]
272282
make_zip(zip_file, files, [])
273283

284+
if create_native_mksnapshot == True:
285+
# Create a zip with the native version of the mksnapshot binary.
286+
src = os.path.join(NATIVE_MKSNAPSHOT_DIR, binary)
287+
dest = os.path.join(DIST_DIR, binary)
288+
# Copy file and keep the executable bit.
289+
shutil.copyfile(src, dest)
290+
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
291+
292+
dist_name = get_zip_name(binary, version)
293+
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
294+
with scoped_cwd(DIST_DIR):
295+
make_zip(zip_file, files, [])
274296

275297
def create_ffmpeg_zip():
276298
dist_name = get_zip_name('ffmpeg', ELECTRON_VERSION)

script/upload.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ def main():
8585
upload_electron(github, release, os.path.join(DIST_DIR, ffmpeg),
8686
args.upload_to_s3)
8787

88-
# Upload chromedriver and mksnapshot for minor version update.
89-
if parse_version(args.version)[2] == '0':
90-
chromedriver = get_zip_name('chromedriver', ELECTRON_VERSION)
91-
upload_electron(github, release, os.path.join(DIST_DIR, chromedriver),
92-
args.upload_to_s3)
93-
mksnapshot = get_zip_name('mksnapshot', ELECTRON_VERSION)
88+
chromedriver = get_zip_name('chromedriver', ELECTRON_VERSION)
89+
upload_electron(github, release, os.path.join(DIST_DIR, chromedriver),
90+
args.upload_to_s3)
91+
mksnapshot = get_zip_name('mksnapshot', ELECTRON_VERSION)
92+
upload_electron(github, release, os.path.join(DIST_DIR, mksnapshot),
93+
args.upload_to_s3)
94+
95+
if get_target_arch().startswith('arm'):
96+
# Upload the x64 binary for arm/arm64 mksnapshot
97+
mksnapshot = get_zip_name('mksnapshot', ELECTRON_VERSION, 'x64')
9498
upload_electron(github, release, os.path.join(DIST_DIR, mksnapshot),
9599
args.upload_to_s3)
96100

0 commit comments

Comments
 (0)