electron/script/update.py

66 lines
2 KiB
Python
Raw Normal View History

2013-06-24 07:24:30 +00:00
#!/usr/bin/env python
import os
2015-06-10 06:11:34 +00:00
import platform
2013-06-24 07:24:30 +00:00
import subprocess
import sys
2015-07-02 07:10:05 +00:00
from lib.config import get_target_arch, PLATFORM
2015-07-01 09:17:44 +00:00
from lib.util import get_host_arch
2014-08-03 15:13:04 +00:00
2013-06-24 07:24:30 +00:00
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
2013-06-24 07:24:30 +00:00
def main():
os.chdir(SOURCE_ROOT)
2015-07-01 08:51:06 +00:00
if platform.architecture()[0] != '64bit':
print 'Electron is required to be built on a 64bit machine'
return 1
update_external_binaries()
return update_gyp()
2013-06-24 07:24:30 +00:00
def update_external_binaries():
uf = os.path.join('script', 'update-external-binaries.py')
2014-05-18 15:03:46 +00:00
subprocess.check_call([sys.executable, uf])
2013-06-28 08:12:40 +00:00
2013-06-24 07:24:30 +00:00
def update_gyp():
# 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.
# In order to work around this, we decided to generate the configuration
# 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))
def run_gyp(target_arch, component):
2015-07-02 07:10:05 +00:00
env = os.environ.copy()
if PLATFORM == 'linux' and target_arch != get_host_arch():
env['GYP_CROSSCOMPILE'] = '1'
2015-07-03 02:01:44 +00:00
elif PLATFORM == 'win32':
env['GYP_MSVS_VERSION'] = '2013'
python = sys.executable
if sys.platform == 'cygwin':
# Force using win32 python on cygwin.
python = os.path.join('vendor', 'python_26', 'python.exe')
gyp = os.path.join('vendor', 'brightray', 'vendor', 'gyp', 'gyp_main.py')
2015-04-08 11:19:40 +00:00
defines = [
'-Dlibchromiumcontent_component={0}'.format(component),
'-Dtarget_arch={0}'.format(target_arch),
2015-07-01 09:17:44 +00:00
'-Dhost_arch={0}'.format(get_host_arch()),
2015-04-08 11:19:40 +00:00
'-Dlibrary=static_library',
]
return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.',
2015-07-02 07:10:05 +00:00
'atom.gyp', '-Icommon.gypi'] + defines, env=env)
2013-06-24 07:24:30 +00:00
2015-06-10 06:11:34 +00:00
2013-06-24 07:24:30 +00:00
if __name__ == '__main__':
sys.exit(main())