From: Cheng Zhao Date: Sat, 11 Apr 2015 09:58:19 +0000 (+0800) Subject: win: Build with the arch chosen by user X-Git-Tag: v0.23.0~4^2~18 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=de016e72a57fb50622ace268f80310459406ae28;p=electron.git win: Build with the arch chosen by user --- diff --git a/script/create-dist.py b/script/create-dist.py index 4d1ae544..a7ceb99f 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -8,7 +8,7 @@ import sys import stat from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, PLATFORM, \ - DIST_ARCH + get_target_arch from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \ execute, get_chromedriver_version @@ -155,7 +155,7 @@ def create_symbols(): def create_dist_zip(): dist_name = 'atom-shell-{0}-{1}-{2}.zip'.format(ATOM_SHELL_VERSION, - PLATFORM, DIST_ARCH) + PLATFORM, get_target_arch()) zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name) with scoped_cwd(DIST_DIR): @@ -168,7 +168,7 @@ def create_dist_zip(): def create_chromedriver_zip(): dist_name = 'chromedriver-{0}-{1}-{2}.zip'.format(get_chromedriver_version(), - PLATFORM, DIST_ARCH) + PLATFORM, get_target_arch()) zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name) with scoped_cwd(DIST_DIR): @@ -183,7 +183,7 @@ def create_chromedriver_zip(): def create_symbols_zip(): dist_name = 'atom-shell-{0}-{1}-{2}-symbols.zip'.format(ATOM_SHELL_VERSION, PLATFORM, - DIST_ARCH) + get_target_arch()) zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name) with scoped_cwd(DIST_DIR): diff --git a/script/lib/config.py b/script/lib/config.py index 2c2a7eda..250c3622 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -1,22 +1,13 @@ #!/usr/bin/env python +import os import platform import sys + BASE_URL = 'http://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = 'f1ad1412461ba3345a27cfe935ffc872dba0ac5b' -ARCH = { - 'cygwin': '32bit', - 'darwin': '64bit', - 'linux2': platform.architecture()[0], - 'win32': '32bit', -}[sys.platform] -DIST_ARCH = { - '32bit': 'ia32', - '64bit': 'x64', -}[ARCH] - PLATFORM = { 'cygwin': 'win32', 'darwin': 'darwin', @@ -26,10 +17,35 @@ PLATFORM = { verbose_mode = False + +def get_target_arch(): + # Always build 64bit on OS X. + if PLATFORM == 'darwin': + return 'x64' + # Only build for host's arch on Linux. + elif PLATFORM == 'linux': + if platform.architecture()[0] == '32bit': + return 'ia32' + else: + return 'x64' + # On Windows it depends on user. + elif PLATFORM == 'win32': + target_arch_path = os.path.join(__file__, '..', '..', '..', 'vendor', + 'brightray', 'vendor', 'download', + 'libchromiumcontent', '.target_arch') + with open(os.path.normpath(target_arch_path)) as f: + target_arch = f.read().strip() + return target_arch + # Maybe we will support other platforms in future. + else: + return 'x64' + + def enable_verbose_mode(): print 'Running in verbose mode' global verbose_mode verbose_mode = True + def is_verbose_mode(): return verbose_mode diff --git a/script/update.py b/script/update.py index ba3380d6..aaa07526 100755 --- a/script/update.py +++ b/script/update.py @@ -4,7 +4,7 @@ import os import subprocess import sys -from lib.config import DIST_ARCH +from lib.config import get_target_arch SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) @@ -23,14 +23,6 @@ def update_external_binaries(): def update_gyp(): - target_arch = DIST_ARCH - if sys.platform == 'darwin': - # Only have 64bit build on OS X. - target_arch = 'x64' - elif sys.platform in ['cygwin', 'win32']: - # Only have 32bit build on Windows. - target_arch = 'ia32' - # Since gyp doesn't support specify link_settings for each configuration, # we are not able to link to different libraries in "Debug" and "Release" # configurations. @@ -38,6 +30,7 @@ def update_gyp(): # for twice, one is to generate "Debug" config, the other one to generate # the "Release" config. And the settings are controlled by the variable # "libchromiumcontent_component" which is defined before running gyp. + target_arch = get_target_arch() return (run_gyp(target_arch, 0) or run_gyp(target_arch, 1)) diff --git a/script/upload.py b/script/upload.py index 0c2b2ba6..81fd28f5 100755 --- a/script/upload.py +++ b/script/upload.py @@ -7,7 +7,7 @@ import subprocess import sys import tempfile -from lib.config import DIST_ARCH, PLATFORM +from lib.config import PLATFORM, get_target_arch from lib.util import execute, get_atom_shell_version, parse_version, \ get_chromedriver_version, scoped_cwd from lib.github import GitHub @@ -22,13 +22,13 @@ OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R') DIST_DIR = os.path.join(SOURCE_ROOT, 'dist') DIST_NAME = 'atom-shell-{0}-{1}-{2}.zip'.format(ATOM_SHELL_VERSION, PLATFORM, - DIST_ARCH) + get_target_arch()) SYMBOLS_NAME = 'atom-shell-{0}-{1}-{2}-symbols.zip'.format(ATOM_SHELL_VERSION, PLATFORM, - DIST_ARCH) + get_target_arch()) CHROMEDRIVER_NAME = 'chromedriver-{0}-{1}-{2}.zip'.format(CHROMEDRIVER_VERSION, PLATFORM, - DIST_ARCH) + get_target_arch()) def main(): diff --git a/vendor/brightray b/vendor/brightray index f44a3834..33367e86 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit f44a3834690c010a1841cde92ca5e4798b1c9d2f +Subproject commit 33367e86d33f2ba8bf3d9dc796b469e6d5855e20