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

Side by Side Diff: tools/build_command_buffer.py

Issue 1704193002: Make build_command_buffer.py work on Mac and Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if os.path.isfile(args.output_dir): 79 if os.path.isfile(args.output_dir):
80 sys.exit(args.output_dir + ' exists but is a file.') 80 sys.exit(args.output_dir + ' exists but is a file.')
81 elif not os.path.isdir(args.output_dir): 81 elif not os.path.isdir(args.output_dir):
82 if args.make_output_dir: 82 if args.make_output_dir:
83 os.makedirs(args.output_dir) 83 os.makedirs(args.output_dir)
84 else: 84 else:
85 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir ' 85 sys.exit(args.output_dir + ' does not exist (specify --make-output-dir '
86 'to create).') 86 'to create).')
87 87
88 chrome_target_dir_rel = os.path.join('out', args.chrome_build_type) 88 chrome_target_dir_rel = os.path.join('out', args.chrome_build_type)
89 chrome_target_dir = os.path.join(chrome_src_dir, chrome_target_dir_rel)
90 89
91 if not args.no_sync: 90 if not args.no_sync:
92 try: 91 try:
93 subprocess.check_call(['git', 'fetch'], cwd=chrome_src_dir) 92 subprocess.check_call(['git', 'fetch'], cwd=chrome_src_dir)
94 except subprocess.CalledProcessError as error: 93 except subprocess.CalledProcessError as error:
95 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode, 94 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode,
96 error.cmd, chrome_src_dir) 95 error.cmd, chrome_src_dir)
97 96
98 try: 97 try:
99 subprocess.check_call(['git', 'checkout', args.chrome_revision], 98 subprocess.check_call(['git', 'checkout', args.chrome_revision],
100 cwd=chrome_src_dir) 99 cwd=chrome_src_dir)
101 except subprocess.CalledProcessError as error: 100 except subprocess.CalledProcessError as error:
102 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode, 101 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode,
103 error.cmd, chrome_src_dir) 102 error.cmd, chrome_src_dir)
104 103
105 if not args.no_sync: 104 if not args.no_sync:
106 try: 105 try:
107 subprocess.check_call(['gclient', 'sync'], cwd=chrome_src_dir) 106 os.environ['GYP_GENERATORS'] = 'ninja'
107 subprocess.check_call(['gclient', 'sync', '--reset', '--force'],
108 cwd=chrome_src_dir)
108 except subprocess.CalledProcessError as error: 109 except subprocess.CalledProcessError as error:
109 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode, 110 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode,
110 error.cmd, chrome_src_dir) 111 error.cmd, chrome_src_dir)
111 112
112 try: 113 try:
113 subprocess.check_call(['ninja'] + shlex.split(args.extra_ninja_args) + 114 subprocess.check_call(['ninja'] + shlex.split(args.extra_ninja_args) +
114 ['-C', chrome_target_dir_rel, 'command_buffer_gles2'], 115 ['-C', chrome_target_dir_rel, 'command_buffer_gles2'],
115 cwd=chrome_src_dir) 116 cwd=chrome_src_dir)
116 except subprocess.CalledProcessError as error: 117 except subprocess.CalledProcessError as error:
117 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode, 118 sys.exit('Error (ret code: %s) calling "%s" in %s' % error.returncode,
118 error.cmd, chrome_src_dir) 119 error.cmd, chrome_src_dir)
119 120
120 shared_lib_src = os.path.join(chrome_target_dir, 'lib', 121 # The command buffer shared library will have a different extension on Linux,
121 'libcommand_buffer_gles2.so') 122 # Mac, and Windows. Also, on Linux it will be in a 'lib' subdirectory and
122 shared_lib_dst = os.path.join(args.output_dir, 'libcommand_buffer_gles2.so') 123 # needs to be placed in a 'lib' subdirectory of the directory containing the
124 # Skia executable.
125 platform = sys.platform
126 if platform == 'cygwin':
127 platform = 'win32'
128
129 shared_lib_ext = '.so'
130 shared_lib_subdir = 'lib'
131 if platform == 'darwin':
132 shared_lib_ext = '.dylib'
133 shared_lib_subdir = ''
134 elif platform == 'win32':
135 shared_lib_ext = '.dll'
136 shared_lib_subdir = ''
137
138 shared_lib_src_dir = os.path.join(chrome_src_dir, chrome_target_dir_rel,
139 shared_lib_subdir)
140 shared_lib_dst_dir = os.path.join(args.output_dir, shared_lib_subdir)
141 # Make the subdir for the dst if does not exist
142 if shared_lib_subdir and not os.path.isdir(shared_lib_dst_dir):
143 os.mkdir(shared_lib_dst_dir)
144
145 shared_lib_name = 'libcommand_buffer_gles2' + shared_lib_ext
146 shared_lib_src = os.path.join(shared_lib_src_dir, shared_lib_name)
147 shared_lib_dst = os.path.join(shared_lib_dst_dir, shared_lib_name)
123 148
124 if not os.path.isfile(shared_lib_src): 149 if not os.path.isfile(shared_lib_src):
125 sys.exit('Command buffer shared library not at expected location: ' + 150 sys.exit('Command buffer shared library not at expected location: ' +
126 shared_lib_src) 151 shared_lib_src)
127 152
128 shutil.copy2(shared_lib_src, shared_lib_dst) 153 shutil.copy2(shared_lib_src, shared_lib_dst)
129 154
130 if not os.path.isfile(shared_lib_dst): 155 if not os.path.isfile(shared_lib_dst):
131 sys.exit('Command buffer library not copied to ' + shared_lib_dst) 156 sys.exit('Command buffer library not copied to ' + shared_lib_dst)
132 157
133 print('Command buffer library copied to ' + shared_lib_dst) 158 print('Command buffer library copied to ' + shared_lib_dst)
134 159
135 160
136 if __name__ == '__main__': 161 if __name__ == '__main__':
137 main() 162 main()
138 163
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