| 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 command buffer shared library and copy it to Skia tree | 10 Script to build the command buffer shared library and copy it to Skia tree |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 | 13 |
| 14 import argparse | 14 import argparse |
| 15 import os | 15 import os |
| 16 import shlex | 16 import shlex |
| 17 import shutil | 17 import shutil |
| 18 import subprocess | 18 import subprocess |
| 19 import sys | 19 import sys |
| 20 | 20 |
| 21 | 21 |
| 22 def main(): | 22 def main(): |
| 23 parser = argparse.ArgumentParser(description=('Builds command_buffer_gles2 ' | 23 parser = argparse.ArgumentParser(description=('Builds command_buffer_gles2 ' |
| 24 'library and copies it')) | 24 'library and copies it')) |
| 25 parser.add_argument('-c', '--chrome-dir', required=True, help= | 25 parser.add_argument('-c', '--chrome-dir', required=True, help= |
| 26 'path to Chromium checkout (directory containing .gclient)') | 26 'path to Chromium checkout (directory containing .gclient)') |
| 27 parser.add_argument('-o', '--output-dir', required=True, | 27 parser.add_argument('-o', '--output-dir', required=True, |
| 28 help='path to copy the command buffer shared library to') | 28 help='path to copy the command buffer shared library to. Typically this ' |
| 29 'is out/Debug or out/Release in a Skia repository') |
| 29 parser.add_argument('--make-output-dir', default=False, action='store_true', | 30 parser.add_argument('--make-output-dir', default=False, action='store_true', |
| 30 help='Makes the output directory if it does not already exist.') | 31 help='Makes the output directory if it does not already exist.') |
| 31 parser.add_argument('-t', '--chrome-build-type', default='Release', | 32 parser.add_argument('--chrome-out-dir', default='CommandBufferForSkia', |
| 32 help='Type of build for the command buffer (e.g. Debug or Release). The ' | 33 help='Type of name of the gn output directory (e.g. Debug or Release). ' |
| 33 'output dir to build will be <chrome-dir>/out/<chrome-build-type> ' | 34 'This is relative to the Chromium src/out directory. Note that this ' |
| 34 'and must already be initialized by gn.') | 35 'script will reset the gn args in this directory on each run.') |
| 36 parser.add_argument('--extra-gn-args', default='', |
| 37 help=('Extra GN arguments to use for the output directory used to build' |
| 38 'the command buffer')) |
| 35 parser.add_argument('--extra-ninja-args', default='', | 39 parser.add_argument('--extra-ninja-args', default='', |
| 36 help=('Extra arguments to pass to ninja when building the command ' | 40 help=('Extra arguments to pass to ninja when building the command ' |
| 37 'buffer shared library')) | 41 'buffer shared library')) |
| 38 parser.add_argument('--chrome-revision', default='origin/lkgr', | 42 parser.add_argument('--chrome-revision', default='origin/lkgr', |
| 39 help='Revision (hash, branch, tag) of Chromium to use.') | 43 help='Revision (hash, branch, tag) of Chromium to use.') |
| 40 parser.add_argument('--no-sync', action='store_true', default=False, | 44 parser.add_argument('--no-sync', action='store_true', default=False, |
| 41 help='Don\'t run git fetch or gclient sync in the Chromium tree') | 45 help='Don\'t run git fetch or gclient sync in the Chromium tree') |
| 42 parser.add_argument('--no-hooks', action='store_true', default=False, | 46 parser.add_argument('--no-hooks', action='store_true', default=False, |
| 43 help='Don\'t run gclient runhooks in the Chromium tree. Implies ' | 47 help='Don\'t run gclient runhooks in the Chromium tree. Implies ' |
| 44 '--no-sync') | 48 '--no-sync') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 | 67 |
| 64 if os.path.isfile(args.output_dir): | 68 if os.path.isfile(args.output_dir): |
| 65 sys.exit(args.output_dir + ' exists but is a file.') | 69 sys.exit(args.output_dir + ' exists but is a file.') |
| 66 elif not os.path.isdir(args.output_dir): | 70 elif not os.path.isdir(args.output_dir): |
| 67 if args.make_output_dir: | 71 if args.make_output_dir: |
| 68 os.makedirs(args.output_dir) | 72 os.makedirs(args.output_dir) |
| 69 else: | 73 else: |
| 70 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir ' | 74 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir ' |
| 71 'to create).') | 75 'to create).') |
| 72 | 76 |
| 73 chrome_target_dir_rel = os.path.join('out', args.chrome_build_type) | 77 chrome_target_dir_rel = os.path.join('out', args.chrome_out_dir) |
| 74 | 78 |
| 75 # The command buffer shared library will have a different name on Linux, | 79 # The command buffer shared library will have a different name on Linux, |
| 76 # Mac, and Windows. Also, on Linux it will be in a 'lib' subdirectory and | 80 # Mac, and Windows. Also, the name of the gclient executable we call out to |
| 77 # needs to be placed in a 'lib' subdirectory of the directory containing the | 81 # has a .bat file extension on Windows. |
| 78 # Skia executable. Also, the name of the gclient executable we call out to has | |
| 79 # a .bat file extension on Windows. | |
| 80 platform = sys.platform | 82 platform = sys.platform |
| 81 if platform == 'cygwin': | 83 if platform == 'cygwin': |
| 82 platform = 'win32' | 84 platform = 'win32' |
| 83 | 85 |
| 84 shared_lib_name = 'libcommand_buffer_gles2.so' | 86 shared_lib_name = 'libcommand_buffer_gles2.so' |
| 85 shared_lib_subdir = 'lib' | |
| 86 gclient = 'gclient' | 87 gclient = 'gclient' |
| 87 if platform == 'darwin': | 88 if platform == 'darwin': |
| 88 shared_lib_name = 'libcommand_buffer_gles2.dylib' | 89 shared_lib_name = 'libcommand_buffer_gles2.dylib' |
| 89 shared_lib_subdir = '' | |
| 90 elif platform == 'win32': | 90 elif platform == 'win32': |
| 91 shared_lib_name = 'command_buffer_gles2.dll' | 91 shared_lib_name = 'command_buffer_gles2.dll' |
| 92 shared_lib_subdir = '' | |
| 93 gclient = 'gclient.bat' | 92 gclient = 'gclient.bat' |
| 94 | 93 |
| 95 if not args.no_sync: | 94 if not args.no_sync: |
| 96 try: | 95 try: |
| 97 subprocess.check_call(['git', 'fetch'], cwd=chrome_src_dir) | 96 subprocess.check_call(['git', 'fetch'], cwd=chrome_src_dir) |
| 98 except subprocess.CalledProcessError as error: | 97 except subprocess.CalledProcessError as error: |
| 99 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, | 98 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, |
| 100 error.cmd, chrome_src_dir)) | 99 error.cmd, chrome_src_dir)) |
| 101 | 100 |
| 102 try: | 101 try: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 124 | 123 |
| 125 gn = 'gn' | 124 gn = 'gn' |
| 126 platform = 'linux64' | 125 platform = 'linux64' |
| 127 if sys.platform == 'darwin': | 126 if sys.platform == 'darwin': |
| 128 platform = 'mac' | 127 platform = 'mac' |
| 129 elif sys.platform == 'win32': | 128 elif sys.platform == 'win32': |
| 130 platform = 'win' | 129 platform = 'win' |
| 131 gn = 'gn.exe' | 130 gn = 'gn.exe' |
| 132 gn = os.path.join(chrome_src_dir, 'buildtools', platform, gn) | 131 gn = os.path.join(chrome_src_dir, 'buildtools', platform, gn) |
| 133 try: | 132 try: |
| 134 subprocess.check_call([gn, 'gen', chrome_target_dir_rel, | 133 gnargs = 'is_component_build=false is_debug=false ' + args.extra_gn_args |
| 135 '--args=is_component_build=false'], | 134 subprocess.check_call([gn, 'gen', chrome_target_dir_rel, '--args='+gnargs], |
| 136 cwd=chrome_src_dir) | 135 cwd=chrome_src_dir) |
| 137 except subprocess.CalledProcessError as error: | 136 except subprocess.CalledProcessError as error: |
| 138 sys.exit('Error (ret code: %s) calling "%s" in %s' % ( | 137 sys.exit('Error (ret code: %s) calling "%s" in %s' % ( |
| 139 error.returncode, error.cmd, chrome_src_dir)) | 138 error.returncode, error.cmd, chrome_src_dir)) |
| 140 | 139 |
| 141 try: | 140 try: |
| 142 subprocess.check_call(['ninja'] + shlex.split(args.extra_ninja_args) + | 141 subprocess.check_call(['ninja'] + shlex.split(args.extra_ninja_args) + |
| 143 ['-C', chrome_target_dir_rel, 'command_buffer_gles2'], | 142 ['-C', chrome_target_dir_rel, 'command_buffer_gles2'], |
| 144 cwd=chrome_src_dir) | 143 cwd=chrome_src_dir) |
| 145 except subprocess.CalledProcessError as error: | 144 except subprocess.CalledProcessError as error: |
| 146 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, | 145 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, |
| 147 error.cmd, chrome_src_dir)) | 146 error.cmd, chrome_src_dir)) |
| 148 | 147 |
| 149 shared_lib_src_dir = os.path.join(chrome_src_dir, chrome_target_dir_rel) | 148 shared_lib_src_dir = os.path.join(chrome_src_dir, chrome_target_dir_rel) |
| 150 shared_lib_dst_dir = os.path.join(args.output_dir, shared_lib_subdir) | |
| 151 # Make the subdir for the dst if does not exist | |
| 152 if shared_lib_subdir and not os.path.isdir(shared_lib_dst_dir): | |
| 153 os.mkdir(shared_lib_dst_dir) | |
| 154 | 149 |
| 155 shared_lib_src = os.path.join(shared_lib_src_dir, shared_lib_name) | 150 shared_lib_src = os.path.join(shared_lib_src_dir, shared_lib_name) |
| 156 shared_lib_dst = os.path.join(shared_lib_dst_dir, shared_lib_name) | 151 shared_lib_dst = os.path.join(args.output_dir, shared_lib_name) |
| 157 | 152 |
| 158 if not os.path.isfile(shared_lib_src): | 153 if not os.path.isfile(shared_lib_src): |
| 159 sys.exit('Command buffer shared library not at expected location: ' + | 154 sys.exit('Command buffer shared library not at expected location: ' + |
| 160 shared_lib_src) | 155 shared_lib_src) |
| 161 | 156 |
| 162 shutil.copy2(shared_lib_src, shared_lib_dst) | 157 shutil.copy2(shared_lib_src, shared_lib_dst) |
| 163 | 158 |
| 164 if not os.path.isfile(shared_lib_dst): | 159 if not os.path.isfile(shared_lib_dst): |
| 165 sys.exit('Command buffer library not copied to ' + shared_lib_dst) | 160 sys.exit('Command buffer library not copied to ' + shared_lib_dst) |
| 166 | 161 |
| 167 print('Command buffer library copied to ' + shared_lib_dst) | 162 print('Command buffer library copied to ' + shared_lib_dst) |
| 168 | 163 |
| 169 | 164 |
| 170 if __name__ == '__main__': | 165 if __name__ == '__main__': |
| 171 main() | 166 main() |
| 172 | 167 |
| OLD | NEW |