OLD | NEW |
| (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 args = parser.parse_args() | |
33 | |
34 args.src_dir = os.path.abspath(args.src_dir) | |
35 args.output_dir = os.path.abspath(args.output_dir) | |
36 | |
37 if not os.path.isdir(args.src_dir): | |
38 sys.exit(args.src_dir + ' is not a directory.') | |
39 | |
40 if args.build_type != 'Debug' and args.build_type != 'Release': | |
41 sys.exit('Invalid build type: ' + args.build_type); | |
42 | |
43 if args.arch_type == 'x86': | |
44 vs_arch = '' | |
45 elif args.arch_type == 'x86_64': | |
46 vs_arch = ' Win64' | |
47 else: | |
48 sys.exit('Invalid arch type: ' + args.arch_type); | |
49 | |
50 if args.project_type == 'ninja': | |
51 generator = 'Ninja' | |
52 elif args.project_type == 'MSVS2013': | |
53 generator = 'Visual Studio 12 2013' + vs_arch | |
54 elif args.project_type == "MSVS2015": | |
55 generator = 'Visual Studio 14 2015' + vs_arch | |
56 else: | |
57 sys.exit('Invalid project type: ' + args.project_type); | |
58 | |
59 if not os.path.isdir(args.output_dir): | |
60 try: | |
61 os.makedirs(args.output_dir) | |
62 except os.error: | |
63 sys.exit('Error creating output dir ' + args.output_dir) | |
64 | |
65 try: | |
66 subprocess.check_call(['cmake', '-G', generator, | |
67 '-DSPIRV_SKIP_EXECUTABLES=ON', args.src_dir], cwd=args.output_dir) | |
68 except subprocess.CalledProcessError as error: | |
69 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( | |
70 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) | |
71 | |
72 try: | |
73 subprocess.check_call(['cmake', '--build', args.output_dir, '--config', | |
74 args.build_type], cwd=args.output_dir) | |
75 except subprocess.CalledProcessError as error: | |
76 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( | |
77 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) | |
78 | |
79 if __name__ == '__main__': | |
80 main() | |
81 | |
OLD | NEW |