diff options
author | crupest <crupest@outlook.com> | 2019-03-30 21:04:42 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-30 21:04:42 +0800 |
commit | ee130224147f034e02d1d4d83e3f2d5a59e625c2 (patch) | |
tree | 79d73bb5c5b3e29657d31a90d45ff7d20c3c5041 /tools | |
parent | 88ecaa7f4f82b390cbda838b68121e93f878c299 (diff) | |
download | cru-ee130224147f034e02d1d4d83e3f2d5a59e625c2.tar.gz cru-ee130224147f034e02d1d4d83e3f2d5a59e625c2.tar.bz2 cru-ee130224147f034e02d1d4d83e3f2d5a59e625c2.zip |
Link skia.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/build.py b/tools/build.py index c2829560..0fc23f18 100644 --- a/tools/build.py +++ b/tools/build.py @@ -13,27 +13,34 @@ parser.add_argument('--clang-build-skia', action='store_true', help='whether use clang to build skia') args = parser.parse_args() + class ConflictArgumentError(Exception): def __init__(self, message): self.message = message + if args.arch == 'x86' and args.clang_build_skia: raise ConflictArgumentError('clang does not support to build skia in x86') project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) os.chdir(project_root) + def detect_ninja(): try: subprocess.check_call('ninja --version') except: print('No ninja, install ninja.') - subprocess.check_call('choco install ninja', stdout=sys.stdout, stderr=sys.stderr) + subprocess.check_call('choco install ninja', + stdout=sys.stdout, stderr=sys.stderr) + detect_ninja() + def build_skia(): - subprocess.check_call('py -2 .\\skia\\tools\\git-sync-deps', stdout=sys.stdout, stderr=sys.stderr) + subprocess.check_call('py -2 .\\skia\\tools\\git-sync-deps', + stdout=sys.stdout, stderr=sys.stderr) gn_args = ''' is_debug = {debug} @@ -49,7 +56,7 @@ def build_skia(): skia_use_lua = false skia_use_sfntly = false skia_use_xps = false - '''.format(debug = 'true' if args.config == 'Debug' else 'false' ) + '''.format(debug='true' if args.config == 'Debug' else 'false') if args.arch == 'x86': gn_args += 'target_cpu="x86"\n' @@ -62,31 +69,38 @@ def build_skia(): out_dir += '_clang' os.makedirs("skia/out/{}".format(out_dir), exist_ok=True) - gn_arg_file_path = os.path.join(project_root, 'skia/out', out_dir, 'args.gn') + gn_arg_file_path = os.path.join( + project_root, 'skia/out', out_dir, 'args.gn') with open(gn_arg_file_path, 'w+') as f: f.write(gn_args) - + os.chdir('./skia') - subprocess.check_call('.\\bin\\gn.exe gen .\\out\\{}\\'.format(out_dir), stdout=sys.stdout, stderr=sys.stderr) + subprocess.check_call('.\\bin\\gn.exe gen .\\out\\{}\\'.format( + out_dir), stdout=sys.stdout, stderr=sys.stderr) subprocess.check_call('ninja -C .\\out\\{} skia'.format(out_dir)) + build_skia() os.chdir(project_root) + def build_cru_ui(): - os.environ['PreferredToolArchitecture'] = 'x64' # use vs x64 toolchain + os.environ['PreferredToolArchitecture'] = 'x64' # use vs x64 toolchain generater_vs_arch_map = { 'x86': 'Win32', 'x64': 'x64' } - subprocess.run('cmake -S . -B build -G "Visual Studio 15 2017" -A {arch}'.format(arch=generater_vs_arch_map[args.arch]), + subprocess.run('cmake -S . -B build -G "Visual Studio 15 2017" -A {arch} {clang}' + .format(arch=generater_vs_arch_map[args.arch], + clang="-DCRU_SKIA_USE_CLANG=TRUE" if args.clang_build_skia else ""), stdout=sys.stdout, stderr=sys.stderr) subprocess.run('cmake --build build --target ALL_BUILD --config {config}'.format(config=args.config), stdout=sys.stdout, stderr=sys.stderr) + build_cru_ui() |