Extract Ninja related stuff to lib/ninja.py

This commit is contained in:
Aleksei Kuzmin 2018-04-09 13:17:14 +02:00
Родитель b0da43567f
Коммит b420d585a0
3 изменённых файлов: 32 добавлений и 12 удалений

Просмотреть файл

@ -9,11 +9,7 @@ import platform
from lib.config import MIPS64EL_GCC, set_mips64el_env, get_output_dir, \
SOURCE_ROOT, VENDOR_DIR, DEPOT_TOOLS_DIR, \
COMPONENTS
NINJA = os.path.join(DEPOT_TOOLS_DIR, 'ninja')
if sys.platform == 'win32':
NINJA = '{0}.exe'.format(NINJA)
from lib.ninja import run as run_ninja
def main():
@ -50,12 +46,13 @@ def main():
target = 'chromiumcontent:chromiumcontent_tests'
if component == 'native_mksnapshot':
target = 'v8:mksnapshot'
subprocess.check_call([NINJA, '-C', os.path.relpath(out_dir), target], env=env)
run_ninja(os.path.relpath(out_dir), target=target, env=env)
if component == 'static_library':
subenv = env.copy()
subenv['CHROMIUMCONTENT_2ND_PASS'] = '1'
target = 'chromiumcontent:libs'
subprocess.check_call([NINJA, '-C', os.path.relpath(out_dir), target], env=subenv)
run_ninja(os.path.relpath(out_dir), target=target, env=subenv)
def parse_args():

Просмотреть файл

@ -17,6 +17,7 @@ import lib.util as util
from lib.config import MIPS64EL_GCC, set_mips64el_env, get_output_dir, \
SOURCE_ROOT, VENDOR_DIR, SRC_DIR, DEPOT_TOOLS_DIR, \
TOOLS_DIR
from lib.ninja import run as run_ninja
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
@ -29,10 +30,6 @@ import ninja_syntax
MAIN_DIR = os.path.join(DIST_DIR, 'main')
DIST_SRC_DIR = os.path.join(MAIN_DIR, 'src')
NINJA = os.path.join(DEPOT_TOOLS_DIR, 'ninja')
if sys.platform == 'win32':
NINJA = '{0}.exe'.format(NINJA)
COPY_PY = os.path.join(TOOLS_DIR, 'copy.py')
LICENSES_PY = os.path.join(TOOLS_DIR, 'licenses.py')
@ -385,7 +382,7 @@ def main():
with Ninja(open(os.path.join(MAIN_DIR, 'build.ninja'), 'wb')) as ninja:
generate_ninja(args, ninja)
subprocess.check_call([NINJA, '-C', MAIN_DIR])
run_ninja(MAIN_DIR)
for component in COMPONENTS:
if ((args.component == 'all' or args.component == component)

26
script/lib/ninja.py Normal file
Просмотреть файл

@ -0,0 +1,26 @@
import os
import subprocess
import sys
from lib.config import DEPOT_TOOLS_DIR
def __get_binary_path():
path = os.path.join(DEPOT_TOOLS_DIR, 'ninja')
if sys.platform == 'win32':
path = '{0}.exe'.format(path)
return path
def run(directory, target=None, env=None):
ninja_binary = __get_binary_path()
args = [ninja_binary,
'-C', directory
]
if target is not None:
args.append(target)
subprocess.check_call(args, env=env)