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

Side by Side Diff: tools/build_command_buffer.py

Issue 1699273002: Add a script to build and copy the command buffer shared library. This script will be used by the b… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace Created 4 years, 10 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
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 """
9 Script to build the command buffer shared library and copy it to Skia tree
10 """
11
12 import argparse
13 import os
14 import shutil
15 import sys
16
borenet 2016/02/17 12:26:14 Style nits: 2 lines between top-level blocks, 2-sp
bsalomon 2016/02/17 15:53:23 Done.
17 def main():
18 parser = argparse.ArgumentParser(description=("Builds command_buffer_gles2 "
19 "library and copies it"))
20 parser.add_argument('-c', '--chrome-src', required=True, help=
21 'path to Chromium checkout (directory containing .gclient)')
borenet 2016/02/17 12:26:15 The "-src" is a little misleading since that's als
bsalomon 2016/02/17 15:53:23 Changed to chrome-dir
22 parser.add_argument('-o', '--output-dir', default='.',
23 help='path to copy the command buffer shared library to')
24 parser.add_argument('--make-output-dir', default=False, action='store_true',
25 help='Makes the output directory if it does not already exist.')
26 parser.add_argument('-f', '--fetch', action='store_true',
27 help=('Create Chromium src directory and fetch chromium checkout (if '
28 'directory does not already exist)'))
29 parser.add_argument('--chrome-build-type', default='Release',
30 help='Type of build for the command buffer (e.g. Debug or Release)')
31 parser.add_argument('--extra-ninja-args', default='',
32 help=('Extra arguments to pass to ninja when building the command '
33 'buffer shared library'))
34 parser.add_argument('--chrome-revision', default='lkgr',
35 help='Revision (hash, branch tag) of Chromium to use.')
36 parser.add_argument('--no-sync', action='store_true', default=False,
37 help="Don't run git fetch or gclient sync in the Chromium tree")
38 args = parser.parse_args()
39
40 args.chrome_src = os.path.abspath(args.chrome_src)
41 args.output_dir = os.path.abspath(args.output_dir)
42
43 if not os.path.isdir(args.chrome_src):
44 if args.fetch:
45 os.mkdir(args.chrome_src)
borenet 2016/02/17 12:26:14 Probably want os.makedirs here, which is equivalen
bsalomon 2016/02/17 15:53:23 Done.
46 if not os.path.isdir(args.chrome_src):
47 sys.exit('Could not create ' + args.chrome_src)
48 os.chdir(args.chrome_src)
49 if os.system('fetch chromium'):
borenet 2016/02/17 12:26:14 This would be safer and avoid the chdir: subproce
bsalomon 2016/02/17 15:53:23 Done.
50 sys.exit('Error fetching chromium at ' + args.chrome_src)
51 else:
52 sys.exit('Invalid Chromium src directory: ' + args.chrome_src)
53
54 if not os.path.isdir(args.chrome_src + '/src'):
55 sys.exit(args.chrome_src + '/src' + ' does not exist')
borenet 2016/02/17 12:26:14 Use os.path.join(args.chrome_src, 'src'), here and
bsalomon 2016/02/17 15:53:23 Done.
56
57 if not os.path.isdir(args.output_dir):
58 if args.make_output_dir:
59 os.makedirs(args.output_dir)
60
61 if not os.path.isdir(args.output_dir):
62 sys.exit('Invalid output directory: ' + args.output_dir)
63
64 os.chdir(args.chrome_src + '/src')
65
66 chrome_target_dir = (os.path.abspath(args.chrome_src) + '/src/out/' +
67 args.chrome_build_type)
68
69 if not args.no_sync:
70 if os.system('git fetch'):
71 sys.exit('Error in git fetch.')
72
73 if os.system('git checkout origin/lkgr'):
74 sys.exit('Error checking out origin/lkgr.')
75
76 if not args.no_sync:
77 if os.system('gclient sync'):
78 sys.exit('Error in gclient sync.')
79
80 if os.system('ninja ' + args.extra_ninja_args + ' -C out/' +
81 args.chrome_build_type + ' command_buffer_gles2'):
82 sys.exit('Error building command_buffer_gles2.')
83
84 shared_lib_src = chrome_target_dir + '/lib/libcommand_buffer_gles2.so'
85 shared_lib_dst = args.output_dir + '/libcommand_buffer_gles2.so'
86
87 if not os.path.isfile(shared_lib_src):
88 sys.exit('Command buffer shared library not at expected location: ' +
89 shared_lib_src)
90
91 shutil.copy2(shared_lib_src, shared_lib_dst)
92
93 if not os.path.isfile(shared_lib_dst):
94 sys.exit('Command buffer library not copied to ' + shared_lib_dst)
95
96 print('Command buffer library copied to ' + shared_lib_dst)
97
98 if __name__ == '__main__':
99 main()
100
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