electron/script/build.py

50 lines
1.3 KiB
Python
Raw Normal View History

2013-06-24 07:36:38 +00:00
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
2016-05-10 03:44:56 +00:00
from lib.config import get_target_arch
2016-05-25 16:10:46 +00:00
from lib.util import electron_gyp, import_vs_env
2013-06-24 07:36:38 +00:00
CONFIGURATIONS = ['Release', 'Debug']
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
2013-06-24 07:36:38 +00:00
def main():
os.chdir(SOURCE_ROOT)
2016-05-10 03:44:56 +00:00
# Update the VS build env.
import_vs_env(get_target_arch())
ninja = os.path.join('vendor', 'depot_tools', 'ninja')
if sys.platform == 'win32':
ninja += '.exe'
2013-06-24 07:36:38 +00:00
args = parse_args()
for config in args.configuration:
build_path = os.path.join('out', config[0])
ret = subprocess.call([ninja, '-C', build_path, args.target])
if ret != 0:
sys.exit(ret)
2013-06-24 07:36:38 +00:00
def parse_args():
parser = argparse.ArgumentParser(description='Build project')
2013-06-24 07:36:38 +00:00
parser.add_argument('-c', '--configuration',
help='Build with Release or Debug configuration',
nargs='+',
default=CONFIGURATIONS,
required=False)
parser.add_argument('-t', '--target',
help='Build specified target',
2016-05-25 16:10:46 +00:00
default=electron_gyp()['project_name%'],
required=False)
2013-06-24 07:36:38 +00:00
return parser.parse_args()
if __name__ == '__main__':
sys.exit(main())