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

Side by Side Diff: tools/build_command_buffer.py

Issue 2236953002: Improvements to build_command_buffer.py (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | 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 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
(...skipping 10 matching lines...) Expand all
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')
29 parser.add_argument('--make-output-dir', default=False, action='store_true', 29 parser.add_argument('--make-output-dir', default=False, action='store_true',
30 help='Makes the output directory if it does not already exist.') 30 help='Makes the output directory if it does not already exist.')
31 parser.add_argument('-f', '--fetch', action='store_true', default=False, 31 parser.add_argument('-t', '--chrome-build-type', default='Release',
32 help=('Create Chromium src directory and fetch chromium checkout (if ' 32 help='Type of build for the command buffer (e.g. Debug or Release). The '
33 'directory does not already exist)')) 33 'output dir to build will be <chrome-dir>/out/<chrome-build-type> '
34 parser.add_argument('--chrome-build-type', default='Release', 34 'and must already be initialized by gn.')
35 help='Type of build for the command buffer (e.g. Debug or Release)')
36 parser.add_argument('--extra-ninja-args', default='', 35 parser.add_argument('--extra-ninja-args', default='',
37 help=('Extra arguments to pass to ninja when building the command ' 36 help=('Extra arguments to pass to ninja when building the command '
38 'buffer shared library')) 37 'buffer shared library'))
39 parser.add_argument('--chrome-revision', default='origin/lkgr', 38 parser.add_argument('--chrome-revision', default='origin/lkgr',
40 help='Revision (hash, branch, tag) of Chromium to use.') 39 help='Revision (hash, branch, tag) of Chromium to use.')
41 parser.add_argument('--no-sync', action='store_true', default=False, 40 parser.add_argument('--no-sync', action='store_true', default=False,
42 help='Don\'t run git fetch or gclient sync in the Chromium tree') 41 help='Don\'t run git fetch or gclient sync in the Chromium tree')
42 parser.add_argument('--no-hooks', action='store_true', default=False,
43 help='Don\'t run gclient runhooks in the Chromium tree. Implies '
44 '--no-sync')
43 args = parser.parse_args() 45 args = parser.parse_args()
44 46
45 args.chrome_dir = os.path.abspath(args.chrome_dir) 47 args.chrome_dir = os.path.abspath(args.chrome_dir)
46 args.output_dir = os.path.abspath(args.output_dir) 48 args.output_dir = os.path.abspath(args.output_dir)
47 49
50 if args.no_hooks:
51 args.no_sync = True
52
48 if os.path.isfile(args.chrome_dir): 53 if os.path.isfile(args.chrome_dir):
49 sys.exit(args.chrome_dir + ' exists but is a file.') 54 sys.exit(args.chrome_dir + ' exists but is a file.')
50 55
51 if os.path.isfile(args.output_dir): 56 if os.path.isfile(args.output_dir):
52 sys.exit(args.output_dir + ' exists but is a file.') 57 sys.exit(args.output_dir + ' exists but is a file.')
53 58
54 chrome_src_dir = os.path.join(args.chrome_dir, 'src') 59 chrome_src_dir = os.path.join(args.chrome_dir, 'src')
55 60
56 if os.path.isfile(chrome_src_dir):
57 sys.exit(chrome_src_dir + ' exists but is a file.')
58 elif not os.path.isdir(chrome_src_dir):
59 if args.fetch:
60 if os.path.isdir(args.chrome_dir):
61 # If chrome_dir is a dir but chrome_src_dir does not exist we will only
62 # fetch into chrome_dir if it is empty.
63 if os.listdir(args.chrome_dir):
64 sys.exit(args.chrome_dir + ' is not a chromium checkout and is not '
65 'empty.')
66 else:
67 os.makedirs(args.chrome_dir)
68 if not os.path.isdir(args.chrome_dir):
69 sys.exit('Could not create ' + args.chrome_dir)
70 try:
71 subprocess.check_call(['fetch', 'chromium'], cwd=args.chrome_dir)
72 except subprocess.CalledProcessError as error:
73 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode,
74 error.cmd, args.chrome_dir)
75
76 if not os.path.isdir(chrome_src_dir): 61 if not os.path.isdir(chrome_src_dir):
77 sys.exit(chrome_src_dir + ' is not a directory.') 62 sys.exit(chrome_src_dir + ' is not a directory.')
78 63
79 if os.path.isfile(args.output_dir): 64 if os.path.isfile(args.output_dir):
80 sys.exit(args.output_dir + ' exists but is a file.') 65 sys.exit(args.output_dir + ' exists but is a file.')
81 elif not os.path.isdir(args.output_dir): 66 elif not os.path.isdir(args.output_dir):
82 if args.make_output_dir: 67 if args.make_output_dir:
83 os.makedirs(args.output_dir) 68 os.makedirs(args.output_dir)
84 else: 69 else:
85 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir ' 70 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir '
(...skipping 30 matching lines...) Expand all
116 101
117 try: 102 try:
118 subprocess.check_call(['git', 'checkout', args.chrome_revision], 103 subprocess.check_call(['git', 'checkout', args.chrome_revision],
119 cwd=chrome_src_dir) 104 cwd=chrome_src_dir)
120 except subprocess.CalledProcessError as error: 105 except subprocess.CalledProcessError as error:
121 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, 106 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode,
122 error.cmd, chrome_src_dir)) 107 error.cmd, chrome_src_dir))
123 108
124 try: 109 try:
125 os.environ['GYP_GENERATORS'] = 'ninja' 110 os.environ['GYP_GENERATORS'] = 'ninja'
126 subprocess.check_call([gclient, 'sync', '--reset', '--force'], 111 subprocess.check_call([gclient, 'sync', '--reset', '--force',
112 '--nohooks'],
127 cwd=chrome_src_dir) 113 cwd=chrome_src_dir)
128 except subprocess.CalledProcessError as error: 114 except subprocess.CalledProcessError as error:
129 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode, 115 sys.exit('Error (ret code: %s) calling "%s" in %s' % (error.returncode,
130 error.cmd, chrome_src_dir)) 116 error.cmd, chrome_src_dir))
131 117
132 try: 118 if not args.no_hooks:
133 subprocess.check_call([gclient, 'runhooks'], cwd=chrome_src_dir) 119 try:
134 except subprocess.CalledProcessError as error: 120 subprocess.check_call([gclient, 'runhooks'], cwd=chrome_src_dir)
135 sys.exit('Error (ret code: %s) calling "%s" in %s' % ( 121 except subprocess.CalledProcessError as error:
136 error.returncode, error.cmd, chrome_src_dir)) 122 sys.exit('Error (ret code: %s) calling "%s" in %s' % (
123 error.returncode, error.cmd, chrome_src_dir))
137 124
138 gn = 'gn' 125 gn = 'gn'
139 platform = 'linux64' 126 platform = 'linux64'
140 if sys.platform == 'darwin': 127 if sys.platform == 'darwin':
141 platform = 'mac' 128 platform = 'mac'
142 elif sys.platform == 'win32': 129 elif sys.platform == 'win32':
143 platform = 'win' 130 platform = 'win'
144 gn = 'gn.exe' 131 gn = 'gn.exe'
145 gn = os.path.join(chrome_src_dir, 'buildtools', platform, gn) 132 gn = os.path.join(chrome_src_dir, 'buildtools', platform, gn)
146 try: 133 try:
(...skipping 28 matching lines...) Expand all
175 162
176 if not os.path.isfile(shared_lib_dst): 163 if not os.path.isfile(shared_lib_dst):
177 sys.exit('Command buffer library not copied to ' + shared_lib_dst) 164 sys.exit('Command buffer library not copied to ' + shared_lib_dst)
178 165
179 print('Command buffer library copied to ' + shared_lib_dst) 166 print('Command buffer library copied to ' + shared_lib_dst)
180 167
181 168
182 if __name__ == '__main__': 169 if __name__ == '__main__':
183 main() 170 main()
184 171
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698