Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: tools/build_shaderc.py

Issue 2060503002: Remove shaderc cmake compiling (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 """
10 Script to build the shaderc library.
11 """
12
13 import argparse
14 import os
15 import shlex
16 import shutil
17 import subprocess
18 import sys
19
20 def main():
21 parser = argparse.ArgumentParser(description='Builds shaderc')
22 parser.add_argument('-s', '--src-dir', required=True, help=
23 'path to shaderc source')
24 parser.add_argument('-t', '--build-type', required=True, help=
25 'Either Release or Debug')
26 parser.add_argument('-a', '--arch-type', required=True, help=
27 'Either x86 or x86_64')
28 parser.add_argument('-o', '--output-dir', required=True, help=
29 'Directory for cmake build')
30 parser.add_argument('-p', '--project_type', required=True, help=
31 'Project type to use. Must be "ninja", "MSVS2013", or "MSVS2015"')
32 parser.add_argument('-c', '--android_toolchain', required=False, help=
33 'Location of standalone android toolchain to use for crosscompiling')
34 args = parser.parse_args()
35
36 args.src_dir = os.path.abspath(args.src_dir)
37 args.output_dir = os.path.abspath(args.output_dir)
38
39 if not os.path.isdir(args.src_dir):
40 sys.exit(args.src_dir + ' is not a directory.')
41
42 if 'Release' in args.build_type:
43 args.build_type = "Release"
44 elif 'Debug' in args.build_type:
45 args.build_type = "Debug"
46 else:
47 args.exit('Invalid build type: ' + args.build_type);
48
49 vs_arch = ''
50 if args.arch_type == 'x86_64':
51 vs_arch = ' Win64'
52
53 if args.project_type == 'ninja':
54 generator = 'Ninja'
55 elif args.project_type == 'MSVS2013':
56 generator = 'Visual Studio 12 2013' + vs_arch
57 elif args.project_type == "MSVS2015":
58 generator = 'Visual Studio 14 2015' + vs_arch
59 else:
60 sys.exit('Invalid project type: ' + args.project_type);
61
62 if os.path.isdir(args.output_dir):
63 shutil.rmtree(args.output_dir)
64
65 try:
66 os.makedirs(args.output_dir)
67 except os.error:
68 sys.exit('Error creating output dir ' + args.output_dir)
69
70 try:
71 build_type_arg='-DCMAKE_BUILD_TYPE=' + args.build_type
72 cmake_cmd = ['cmake', '-G', generator,
73 '-DSPIRV_SKIP_EXECUTABLES=ON',
74 '-DSHADERC_ENABLE_SHARED_CRT=ON']
75 if args.android_toolchain and args.android_toolchain.strip() :
76 cmake_cmd.append('-DCMAKE_TOOLCHAIN_FILE=' +\
77 os.environ['ANDROID_SDK_ROOT'] +\
78 '/cmake/android.toolchain.cmake')
79 cmake_cmd.append('-DANDROID_TOOLCHAIN_NAME=standalone-clang')
80 cmake_cmd.append('-DANDROID_STANDALONE_TOOLCHAIN=' +\
81 os.path.abspath(args.android_toolchain))
82 cmake_cmd.extend([build_type_arg, args.src_dir])
83 subprocess.check_call(cmake_cmd, cwd=args.output_dir)
84 except subprocess.CalledProcessError as error:
85 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
86 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
87
88 try:
89 subprocess.check_call(['cmake', '--build', args.output_dir, '--config',
90 args.build_type], cwd=args.output_dir)
91 except subprocess.CalledProcessError as error:
92 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
93 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
94
95 if __name__ == '__main__':
96 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698