| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |