build: make external binaries download action more flexible (#14982)
* build: make external binaries download action more flexible * chore: reformat DEPS Make it look more like Chromium //DEPS: - use name-pattern-condition-action order for hooks - add trailing commas - remove some line breaks Also remove redundant entry from "recursedeps".
This commit is contained in:
parent
6e5dd735f6
commit
5525f34363
2 changed files with 52 additions and 53 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import errno
|
||||
import sys
|
||||
import os
|
||||
|
@ -8,38 +9,48 @@ from lib.config import PLATFORM, get_target_arch
|
|||
from lib.util import add_exec_bit, download, extract_zip, rm_rf, \
|
||||
safe_mkdir, tempdir
|
||||
|
||||
VERSION = 'v1.4.0'
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
FRAMEWORKS_URL = 'http://github.com/electron/electron-frameworks/releases' \
|
||||
'/download/' + VERSION
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Download binaries for Electron build')
|
||||
|
||||
parser.add_argument('-u', '--root-url', required=True,
|
||||
help="Root URL for all downloads.")
|
||||
parser.add_argument('-v', '--version', required=True,
|
||||
help="Version string, e.g. 'v1.0.0'.")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
url_prefix = "{root_url}/{version}".format(**vars(args))
|
||||
|
||||
os.chdir(SOURCE_ROOT)
|
||||
version_file = os.path.join(SOURCE_ROOT, 'external_binaries', '.version')
|
||||
|
||||
if (is_updated(version_file, VERSION)):
|
||||
if (is_updated(version_file, args.version)):
|
||||
return
|
||||
|
||||
rm_rf('external_binaries')
|
||||
safe_mkdir('external_binaries')
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
download_and_unzip('Mantle')
|
||||
download_and_unzip('ReactiveCocoa')
|
||||
download_and_unzip('Squirrel')
|
||||
download_and_unzip(url_prefix, 'Mantle')
|
||||
download_and_unzip(url_prefix, 'ReactiveCocoa')
|
||||
download_and_unzip(url_prefix, 'Squirrel')
|
||||
elif sys.platform in ['cygwin', 'win32']:
|
||||
download_and_unzip('directxsdk-' + get_target_arch())
|
||||
download_and_unzip(url_prefix, 'directxsdk-' + get_target_arch())
|
||||
|
||||
# get sccache & set exec bit. https://bugs.python.org/issue15795
|
||||
download_and_unzip('sccache-{0}-x64'.format(PLATFORM))
|
||||
download_and_unzip(url_prefix, 'sccache-{0}-x64'.format(PLATFORM))
|
||||
appname = 'sccache'
|
||||
if sys.platform == 'win32':
|
||||
appname += '.exe'
|
||||
add_exec_bit(os.path.join('external_binaries', appname))
|
||||
|
||||
with open(version_file, 'w') as f:
|
||||
f.write(VERSION)
|
||||
f.write(args.version)
|
||||
|
||||
|
||||
def is_updated(version_file, version):
|
||||
|
@ -53,15 +64,15 @@ def is_updated(version_file, version):
|
|||
return existing_version == version
|
||||
|
||||
|
||||
def download_and_unzip(framework):
|
||||
zip_path = download_framework(framework)
|
||||
def download_and_unzip(url_prefix, framework):
|
||||
zip_path = download_framework(url_prefix, framework)
|
||||
if zip_path:
|
||||
extract_zip(zip_path, 'external_binaries')
|
||||
|
||||
|
||||
def download_framework(framework):
|
||||
def download_framework(url_prefix, framework):
|
||||
filename = framework + '.zip'
|
||||
url = FRAMEWORKS_URL + '/' + filename
|
||||
url = url_prefix + '/' + filename
|
||||
download_dir = tempdir(prefix='electron-')
|
||||
path = os.path.join(download_dir, filename)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue