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

Side by Side Diff: tools/build_shaderc.py

Issue 1884963002: Make build_shaderc.py blow away output dir and allow build_type arg to contain either Debug or Relea (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: shaderc_build_configuration init Created 4 years, 8 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 | « gyp/shaderc.gyp ('k') | 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
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 8
9 """ 9 """
10 Script to build the shaderc library. 10 Script to build the shaderc library.
(...skipping 18 matching lines...) Expand all
29 'Directory for cmake build') 29 'Directory for cmake build')
30 parser.add_argument('-p', '--project_type', required=True, help= 30 parser.add_argument('-p', '--project_type', required=True, help=
31 'Project type to use. Must be "ninja", "MSVS2013", or "MSVS2015"') 31 'Project type to use. Must be "ninja", "MSVS2013", or "MSVS2015"')
32 args = parser.parse_args() 32 args = parser.parse_args()
33 33
34 args.src_dir = os.path.abspath(args.src_dir) 34 args.src_dir = os.path.abspath(args.src_dir)
35 args.output_dir = os.path.abspath(args.output_dir) 35 args.output_dir = os.path.abspath(args.output_dir)
36 36
37 if not os.path.isdir(args.src_dir): 37 if not os.path.isdir(args.src_dir):
38 sys.exit(args.src_dir + ' is not a directory.') 38 sys.exit(args.src_dir + ' is not a directory.')
39 39
40 if args.build_type != 'Debug' and args.build_type != 'Release': 40 if 'Release' in args.build_type:
41 sys.exit('Invalid build type: ' + args.build_type); 41 args.build_type = "Release"
42 elif 'Debug' in args.build_type:
43 args.build_type = "Debug"
44 else:
45 args.exit('Invalid build type: ' + args.build_type);
42 46
43 if args.arch_type == 'x86': 47 if args.arch_type == 'x86':
44 vs_arch = '' 48 vs_arch = ''
45 elif args.arch_type == 'x86_64': 49 elif args.arch_type == 'x86_64':
46 vs_arch = ' Win64' 50 vs_arch = ' Win64'
47 else: 51 else:
48 sys.exit('Invalid arch type: ' + args.arch_type); 52 sys.exit('Invalid arch type: ' + args.arch_type);
49 53
50 if args.project_type == 'ninja': 54 if args.project_type == 'ninja':
51 generator = 'Ninja' 55 generator = 'Ninja'
52 elif args.project_type == 'MSVS2013': 56 elif args.project_type == 'MSVS2013':
53 generator = 'Visual Studio 12 2013' + vs_arch 57 generator = 'Visual Studio 12 2013' + vs_arch
54 elif args.project_type == "MSVS2015": 58 elif args.project_type == "MSVS2015":
55 generator = 'Visual Studio 14 2015' + vs_arch 59 generator = 'Visual Studio 14 2015' + vs_arch
56 else: 60 else:
57 sys.exit('Invalid project type: ' + args.project_type); 61 sys.exit('Invalid project type: ' + args.project_type);
58 62
59 if not os.path.isdir(args.output_dir): 63 if os.path.isdir(args.output_dir):
60 try: 64 shutil.rmtree(args.output_dir)
61 os.makedirs(args.output_dir) 65
62 except os.error: 66 try:
63 sys.exit('Error creating output dir ' + args.output_dir) 67 os.makedirs(args.output_dir)
68 except os.error:
69 sys.exit('Error creating output dir ' + args.output_dir)
64 70
65 try: 71 try:
66 build_type_arg='-DCMAKE_BUILD_TYPE=' + args.build_type 72 build_type_arg='-DCMAKE_BUILD_TYPE=' + args.build_type
67 subprocess.check_call(['cmake', '-G', generator, 73 subprocess.check_call(['cmake', '-G', generator,
68 '-DSPIRV_SKIP_EXECUTABLES=ON', '-DSHADERC_ENABLE_SHARED_CRT=ON', 74 '-DSPIRV_SKIP_EXECUTABLES=ON', '-DSHADERC_ENABLE_SHARED_CRT=ON',
69 args.src_dir, build_type_arg], cwd=args.output_dir) 75 args.src_dir, build_type_arg], cwd=args.output_dir)
70 except subprocess.CalledProcessError as error: 76 except subprocess.CalledProcessError as error:
71 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( 77 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
72 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) 78 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
73 79
74 try: 80 try:
75 subprocess.check_call(['cmake', '--build', args.output_dir, '--config', 81 subprocess.check_call(['cmake', '--build', args.output_dir, '--config',
76 args.build_type], cwd=args.output_dir) 82 args.build_type], cwd=args.output_dir)
77 except subprocess.CalledProcessError as error: 83 except subprocess.CalledProcessError as error:
78 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( 84 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
79 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) 85 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
80 86
81 if __name__ == '__main__': 87 if __name__ == '__main__':
82 main() 88 main()
83 89
OLDNEW
« no previous file with comments | « gyp/shaderc.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698