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

Side by Side Diff: tools/build_shaderc.py

Issue 1903253003: VulkanViewer on Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp 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
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 11 matching lines...) Expand all
22 parser.add_argument('-s', '--src-dir', required=True, help= 22 parser.add_argument('-s', '--src-dir', required=True, help=
23 'path to shaderc source') 23 'path to shaderc source')
24 parser.add_argument('-t', '--build-type', required=True, help= 24 parser.add_argument('-t', '--build-type', required=True, help=
25 'Either Release or Debug') 25 'Either Release or Debug')
26 parser.add_argument('-a', '--arch-type', required=True, help= 26 parser.add_argument('-a', '--arch-type', required=True, help=
27 'Either x86 or x86_64') 27 'Either x86 or x86_64')
28 parser.add_argument('-o', '--output-dir', required=True, help= 28 parser.add_argument('-o', '--output-dir', required=True, help=
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 parser.add_argument('-c', '--android_toolchain', required=False, help=
33 'Location of standalone android toolchain to use for crosscompiling')
32 args = parser.parse_args() 34 args = parser.parse_args()
33 35
34 args.src_dir = os.path.abspath(args.src_dir) 36 args.src_dir = os.path.abspath(args.src_dir)
35 args.output_dir = os.path.abspath(args.output_dir) 37 args.output_dir = os.path.abspath(args.output_dir)
36 38
37 if not os.path.isdir(args.src_dir): 39 if not os.path.isdir(args.src_dir):
38 sys.exit(args.src_dir + ' is not a directory.') 40 sys.exit(args.src_dir + ' is not a directory.')
39 41
40 if 'Release' in args.build_type: 42 if 'Release' in args.build_type:
41 args.build_type = "Release" 43 args.build_type = "Release"
42 elif 'Debug' in args.build_type: 44 elif 'Debug' in args.build_type:
43 args.build_type = "Debug" 45 args.build_type = "Debug"
44 else: 46 else:
45 args.exit('Invalid build type: ' + args.build_type); 47 args.exit('Invalid build type: ' + args.build_type);
46 48
47 if args.arch_type == 'x86': 49 vs_arch = ''
48 vs_arch = '' 50 if args.arch_type == 'x86_64':
49 elif args.arch_type == 'x86_64':
50 vs_arch = ' Win64' 51 vs_arch = ' Win64'
51 else:
52 sys.exit('Invalid arch type: ' + args.arch_type);
53 52
54 if args.project_type == 'ninja': 53 if args.project_type == 'ninja':
55 generator = 'Ninja' 54 generator = 'Ninja'
56 elif args.project_type == 'MSVS2013': 55 elif args.project_type == 'MSVS2013':
57 generator = 'Visual Studio 12 2013' + vs_arch 56 generator = 'Visual Studio 12 2013' + vs_arch
58 elif args.project_type == "MSVS2015": 57 elif args.project_type == "MSVS2015":
59 generator = 'Visual Studio 14 2015' + vs_arch 58 generator = 'Visual Studio 14 2015' + vs_arch
60 else: 59 else:
61 sys.exit('Invalid project type: ' + args.project_type); 60 sys.exit('Invalid project type: ' + args.project_type);
62 61
63 if os.path.isdir(args.output_dir): 62 if os.path.isdir(args.output_dir):
64 shutil.rmtree(args.output_dir) 63 shutil.rmtree(args.output_dir)
65 64
66 try: 65 try:
67 os.makedirs(args.output_dir) 66 os.makedirs(args.output_dir)
68 except os.error: 67 except os.error:
69 sys.exit('Error creating output dir ' + args.output_dir) 68 sys.exit('Error creating output dir ' + args.output_dir)
70 69
71 try: 70 try:
72 build_type_arg='-DCMAKE_BUILD_TYPE=' + args.build_type 71 build_type_arg='-DCMAKE_BUILD_TYPE=' + args.build_type
73 subprocess.check_call(['cmake', '-G', generator, 72 cmake_cmd = ['cmake', '-G', generator,
74 '-DSPIRV_SKIP_EXECUTABLES=ON', '-DSHADERC_ENABLE_SHARED_CRT=ON', 73 '-DSPIRV_SKIP_EXECUTABLES=ON',
75 args.src_dir, build_type_arg], cwd=args.output_dir) 74 '-DSHADERC_ENABLE_SHARED_CRT=ON']
75 if args.android_toolchain and args.android_toolchain.strip() :
76 cmake_cmd.append('-DCMAKE_TOOLCHAIN_FILE=' + args.src_dir +\
77 '/third_party/android-cmake/android.toolchain.cmake')
78 cmake_cmd.append('-DANDROID_TOOLCHAIN_NAME=standalone-clang')
79 cmake_cmd.append('-DANDROID_STANDALONE_TOOLCHAIN=' +\
80 os.path.abspath(args.android_toolchain))
81 cmake_cmd.extend([build_type_arg, args.src_dir])
82 subprocess.check_call(cmake_cmd, cwd=args.output_dir)
76 except subprocess.CalledProcessError as error: 83 except subprocess.CalledProcessError as error:
77 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( 84 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
78 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) 85 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
79 86
80 try: 87 try:
81 subprocess.check_call(['cmake', '--build', args.output_dir, '--config', 88 subprocess.check_call(['cmake', '--build', args.output_dir, '--config',
82 args.build_type], cwd=args.output_dir) 89 args.build_type], cwd=args.output_dir)
83 except subprocess.CalledProcessError as error: 90 except subprocess.CalledProcessError as error:
84 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format( 91 sys.exit('Error (ret code: {code}) calling "{cmd}" in {dir}'.format(
85 code = error.returncode, cmd = error.cmd, dir = args.src_dir)) 92 code = error.returncode, cmd = error.cmd, dir = args.src_dir))
86 93
87 if __name__ == '__main__': 94 if __name__ == '__main__':
88 main() 95 main()
89
OLDNEW
« no previous file with comments | « platform_tools/android/third_party/native_app_glue/android_native_app_glue.c ('k') | tools/vulkan/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698