electron/script/update-external-binaries.py

67 lines
1.6 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2014-05-18 15:03:46 +00:00
import errno
import sys
import os
from lib.config import get_target_arch
from lib.util import safe_mkdir, rm_rf, extract_zip, tempdir, download
2017-07-20 14:04:21 +00:00
VERSION = 'v1.2.1'
2013-07-01 14:27:14 +00:00
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
FRAMEWORKS_URL = 'http://github.com/electron/electron-frameworks/releases' \
'/download/' + VERSION
2014-04-29 02:03:03 +00:00
def main():
os.chdir(SOURCE_ROOT)
version_file = os.path.join(SOURCE_ROOT, 'external_binaries', '.version')
if (is_updated(version_file, VERSION)):
return
rm_rf('external_binaries')
safe_mkdir('external_binaries')
2014-05-18 15:03:46 +00:00
if sys.platform == 'darwin':
download_and_unzip('Mantle')
download_and_unzip('ReactiveCocoa')
download_and_unzip('Squirrel')
elif sys.platform in ['cygwin', 'win32']:
download_and_unzip('directxsdk-' + get_target_arch())
with open(version_file, 'w') as f:
f.write(VERSION)
def is_updated(version_file, version):
existing_version = ''
try:
with open(version_file, 'r') as f:
existing_version = f.readline().strip()
except IOError as e:
if e.errno != errno.ENOENT:
raise
return existing_version == version
def download_and_unzip(framework):
zip_path = download_framework(framework)
if zip_path:
extract_zip(zip_path, 'external_binaries')
def download_framework(framework):
2014-05-18 15:03:46 +00:00
filename = framework + '.zip'
url = FRAMEWORKS_URL + '/' + filename
2015-04-12 14:10:46 +00:00
download_dir = tempdir(prefix='electron-')
path = os.path.join(download_dir, filename)
download('Download ' + framework, url, path)
return path
if __name__ == '__main__':
sys.exit(main())