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

Side by Side Diff: native_client_sdk/src/build_tools/build_projects.py

Issue 275523003: [NaCl SDK] Make build_projects quiet by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import multiprocessing 6 import multiprocessing
7 import optparse 7 import optparse
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import sys 10 import sys
(...skipping 22 matching lines...) Expand all
33 'bionic', 33 'bionic',
34 'newlib', 34 'newlib',
35 'glibc', 35 'glibc',
36 'pnacl', 36 'pnacl',
37 'win', 37 'win',
38 'linux', 38 'linux',
39 'mac', 39 'mac',
40 ] 40 ]
41 41
42 # Global verbosity setting. 42 # Global verbosity setting.
43 # If set to try (normally via a command line arg) then build_projects will 43 # If set to True (normally via a command line arg) then build_projects will
44 # add V=1 to all calls to 'make' 44 # add V=1 to all calls to 'make'
45 verbose = False 45 verbose = False
46 46
47 47
48 def Trace(msg):
49 if verbose:
50 sys.stderr.write(str(msg) + '\n')
51
52
53 def CopyFile(src, dst):
54 buildbot_common.CopyFile(src, dst, verbose)
55
56
57 def CopyDir(src, dst, **kwargs):
58 buildbot_common.CopyDir(src, dst, verbose=verbose, **kwargs)
59
60
61 def RemoveDir(dst):
62 buildbot_common.RemoveDir(dst, verbose)
63
64
65 def MakeDir(dst):
66 buildbot_common.MakeDir(dst, verbose)
67
68
48 def CopyFilesFromTo(filelist, srcdir, dstdir): 69 def CopyFilesFromTo(filelist, srcdir, dstdir):
49 for filename in filelist: 70 for filename in filelist:
50 srcpath = os.path.join(srcdir, filename) 71 srcpath = os.path.join(srcdir, filename)
51 dstpath = os.path.join(dstdir, filename) 72 dstpath = os.path.join(dstdir, filename)
52 buildbot_common.CopyFile(srcpath, dstpath) 73 CopyFile(srcpath, dstpath)
53 74
54 75
55 def UpdateHelpers(pepperdir, clobber=False): 76 def UpdateHelpers(pepperdir, clobber=False):
56 tools_dir = os.path.join(pepperdir, 'tools') 77 tools_dir = os.path.join(pepperdir, 'tools')
57 if not os.path.exists(tools_dir): 78 if not os.path.exists(tools_dir):
58 buildbot_common.ErrorExit('SDK tools dir is missing: %s' % tools_dir) 79 buildbot_common.ErrorExit('SDK tools dir is missing: %s' % tools_dir)
59 80
60 exampledir = os.path.join(pepperdir, 'examples') 81 exampledir = os.path.join(pepperdir, 'examples')
61 if clobber: 82 if clobber:
62 buildbot_common.RemoveDir(exampledir) 83 RemoveDir(exampledir)
63 buildbot_common.MakeDir(exampledir) 84 MakeDir(exampledir)
64 85
65 # Copy files for individual build and landing page 86 # Copy files for individual build and landing page
66 files = ['favicon.ico', 'httpd.cmd', 'index.css', 'index.js', 87 files = ['favicon.ico', 'httpd.cmd', 'index.css', 'index.js',
67 'button_close.png', 'button_close_hover.png'] 88 'button_close.png', 'button_close_hover.png']
68 CopyFilesFromTo(files, SDK_RESOURCE_DIR, exampledir) 89 CopyFilesFromTo(files, SDK_RESOURCE_DIR, exampledir)
69 90
70 # Copy tools scripts and make includes 91 # Copy tools scripts and make includes
71 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), 92 CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), tools_dir)
72 tools_dir) 93 CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.mk'), tools_dir)
73 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.mk'),
74 tools_dir)
75 94
76 # Copy tools/lib scripts 95 # Copy tools/lib scripts
77 tools_lib_dir = os.path.join(pepperdir, 'tools', 'lib') 96 tools_lib_dir = os.path.join(pepperdir, 'tools', 'lib')
78 buildbot_common.MakeDir(tools_lib_dir) 97 MakeDir(tools_lib_dir)
79 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', 'lib', '*.py'), 98 CopyDir(os.path.join(SDK_SRC_DIR, 'tools', 'lib', '*.py'), tools_lib_dir)
80 tools_lib_dir)
81 99
82 # On Windows add a prebuilt make 100 # On Windows add a prebuilt make
83 if getos.GetPlatform() == 'win': 101 if getos.GetPlatform() == 'win':
84 buildbot_common.BuildStep('Add MAKE') 102 buildbot_common.BuildStep('Add MAKE')
85 make_url = posixpath.join(GSTORE, MAKE) 103 make_url = posixpath.join(GSTORE, MAKE)
86 make_exe = os.path.join(tools_dir, 'make.exe') 104 make_exe = os.path.join(tools_dir, 'make.exe')
87 with open(make_exe, 'wb') as f: 105 with open(make_exe, 'wb') as f:
88 f.write(urllib2.urlopen(make_url).read()) 106 f.write(urllib2.urlopen(make_url).read())
89 107
90 108
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 144
127 ValidateToolchains(toolchains) 145 ValidateToolchains(toolchains)
128 146
129 # Create the library output directories 147 # Create the library output directories
130 libdir = os.path.join(pepperdir, 'lib') 148 libdir = os.path.join(pepperdir, 'lib')
131 platform = getos.GetPlatform() 149 platform = getos.GetPlatform()
132 for config in configs: 150 for config in configs:
133 for arch in LIB_DICT[platform]: 151 for arch in LIB_DICT[platform]:
134 dirpath = os.path.join(libdir, '%s_%s_host' % (platform, arch), config) 152 dirpath = os.path.join(libdir, '%s_%s_host' % (platform, arch), config)
135 if clobber: 153 if clobber:
136 buildbot_common.RemoveDir(dirpath) 154 RemoveDir(dirpath)
137 buildbot_common.MakeDir(dirpath) 155 MakeDir(dirpath)
138 156
139 landing_page = None 157 landing_page = None
140 for branch, projects in project_tree.iteritems(): 158 for branch, projects in project_tree.iteritems():
141 dirpath = os.path.join(pepperdir, branch) 159 dirpath = os.path.join(pepperdir, branch)
142 if clobber: 160 if clobber:
143 buildbot_common.RemoveDir(dirpath) 161 RemoveDir(dirpath)
144 buildbot_common.MakeDir(dirpath) 162 MakeDir(dirpath)
145 targets = [desc['NAME'] for desc in projects] 163 targets = [desc['NAME'] for desc in projects]
146 deps = GetDeps(projects) 164 deps = GetDeps(projects)
147 165
148 # Generate master make for this branch of projects 166 # Generate master make for this branch of projects
149 generate_make.GenerateMasterMakefile(pepperdir, 167 generate_make.GenerateMasterMakefile(pepperdir,
150 os.path.join(pepperdir, branch), 168 os.path.join(pepperdir, branch),
151 targets, deps) 169 targets, deps)
152 170
153 if branch.startswith('examples') and not landing_page: 171 if branch.startswith('examples') and not landing_page:
154 landing_page = LandingPage() 172 landing_page = LandingPage()
155 173
156 # Generate individual projects 174 # Generate individual projects
157 for desc in projects: 175 for desc in projects:
158 srcroot = os.path.dirname(desc['FILEPATH']) 176 srcroot = os.path.dirname(desc['FILEPATH'])
159 generate_make.ProcessProject(pepperdir, srcroot, pepperdir, desc, 177 generate_make.ProcessProject(pepperdir, srcroot, pepperdir, desc,
160 toolchains, configs=configs, 178 toolchains, configs=configs,
161 first_toolchain=first_toolchain) 179 first_toolchain=first_toolchain,
180 verbose=verbose)
162 181
163 if branch.startswith('examples'): 182 if branch.startswith('examples'):
164 landing_page.AddDesc(desc) 183 landing_page.AddDesc(desc)
165 184
166 if landing_page: 185 if landing_page:
167 # Generate the landing page text file. 186 # Generate the landing page text file.
168 index_html = os.path.join(pepperdir, 'examples', 'index.html') 187 index_html = os.path.join(pepperdir, 'examples', 'index.html')
169 index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template') 188 index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template')
170 with open(index_html, 'w') as fh: 189 with open(index_html, 'w') as fh:
171 out = landing_page.GeneratePage(index_template) 190 out = landing_page.GeneratePage(index_template)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 make_cmd.append('IGNORE_DEPS=1') 233 make_cmd.append('IGNORE_DEPS=1')
215 234
216 if verbose: 235 if verbose:
217 make_cmd.append('V=1') 236 make_cmd.append('V=1')
218 237
219 if args: 238 if args:
220 make_cmd += args 239 make_cmd += args
221 else: 240 else:
222 make_cmd.append('TOOLCHAIN=all') 241 make_cmd.append('TOOLCHAIN=all')
223 242
224 buildbot_common.Run(make_cmd, cwd=make_dir, env=env) 243 buildbot_common.Run(make_cmd, cwd=make_dir, env=env, verbose=verbose)
225 if clean: 244 if clean:
226 # Clean to remove temporary files but keep the built 245 # Clean to remove temporary files but keep the built
227 buildbot_common.Run(make_cmd + ['clean'], cwd=make_dir, env=env) 246 buildbot_common.Run(make_cmd + ['clean'], cwd=make_dir, env=env,
247 verbose=verbose)
228 248
229 249
230 def BuildProjects(pepperdir, project_tree, deps=True, 250 def BuildProjects(pepperdir, project_tree, deps=True,
231 clean=False, config='Debug'): 251 clean=False, config='Debug'):
232
233 # Make sure we build libraries (which live in 'src') before 252 # Make sure we build libraries (which live in 'src') before
234 # any of the examples. 253 # any of the examples.
235 build_first = [p for p in project_tree if p != 'src'] 254 build_first = [p for p in project_tree if p != 'src']
236 build_second = [p for p in project_tree if p == 'src'] 255 build_second = [p for p in project_tree if p == 'src']
237 256
238 for branch in build_first + build_second: 257 for branch in build_first + build_second:
239 BuildProjectsBranch(pepperdir, branch, deps, clean, config) 258 BuildProjectsBranch(pepperdir, branch, deps, clean, config)
240 259
241 260
242 def main(argv): 261 def main(argv):
243 parser = optparse.OptionParser() 262 parser = optparse.OptionParser()
244 parser.add_option('-c', '--clobber', 263 parser.add_option('-c', '--clobber',
245 help='Clobber project directories before copying new files', 264 help='Clobber project directories before copying new files',
246 action='store_true', default=False) 265 action='store_true', default=False)
247 parser.add_option('-b', '--build', 266 parser.add_option('-b', '--build',
248 help='Build the projects.', action='store_true') 267 help='Build the projects. Otherwise the projects are only copied.',
268 action='store_true')
249 parser.add_option('--config', 269 parser.add_option('--config',
250 help='Choose configuration to build (Debug or Release). Builds both ' 270 help='Choose configuration to build (Debug or Release). Builds both '
251 'by default') 271 'by default')
252 parser.add_option('--bionic', 272 parser.add_option('--bionic',
253 help='Enable bionic projects', action='store_true') 273 help='Enable bionic projects', action='store_true')
254 parser.add_option('-x', '--experimental', 274 parser.add_option('-x', '--experimental',
255 help='Build experimental projects', action='store_true') 275 help='Build experimental projects', action='store_true')
256 parser.add_option('-t', '--toolchain', 276 parser.add_option('-t', '--toolchain',
257 help='Build using toolchain. Can be passed more than once.', 277 help='Build using toolchain. Can be passed more than once.',
258 action='append', default=[]) 278 action='append', default=[])
259 parser.add_option('-d', '--dest', 279 parser.add_option('-d', '--dest',
260 help='Select which build destinations (project types) are valid.', 280 help='Select which build destinations (project types) are valid.',
261 action='append') 281 action='append')
262 parser.add_option('-v', '--verbose', action='store_true') 282 parser.add_option('-v', '--verbose', action='store_true')
263 283
264 # To setup bash completion for this command first install optcomplete 284 # To setup bash completion for this command first install optcomplete
265 # and then add this line to your .bashrc: 285 # and then add this line to your .bashrc:
266 # complete -F _optcomplete build_projects.py 286 # complete -F _optcomplete build_projects.py
267 try: 287 try:
268 import optcomplete 288 import optcomplete
269 optcomplete.autocomplete(parser) 289 optcomplete.autocomplete(parser)
270 except ImportError: 290 except ImportError:
271 pass 291 pass
272 292
273 options, args = parser.parse_args(argv[1:]) 293 options, args = parser.parse_args(argv[1:])
274 294
295 global verbose
296 if options.verbose:
297 verbose = True
298
275 if 'NACL_SDK_ROOT' in os.environ: 299 if 'NACL_SDK_ROOT' in os.environ:
276 # We don't want the currently configured NACL_SDK_ROOT to have any effect 300 # We don't want the currently configured NACL_SDK_ROOT to have any effect
277 # on the build. 301 # on the build.
278 del os.environ['NACL_SDK_ROOT'] 302 del os.environ['NACL_SDK_ROOT']
279 303
280 pepper_ver = str(int(build_version.ChromeMajorVersion())) 304 pepper_ver = str(int(build_version.ChromeMajorVersion()))
281 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) 305 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
282 306
283 if not options.toolchain: 307 if not options.toolchain:
284 # Order matters here: the default toolchain for an example's Makefile will 308 # Order matters here: the default toolchain for an example's Makefile will
285 # be the first toolchain in this list that is available in the example. 309 # be the first toolchain in this list that is available in the example.
286 # e.g. If an example supports newlib and glibc, then the default will be 310 # e.g. If an example supports newlib and glibc, then the default will be
287 # newlib. 311 # newlib.
288 options.toolchain = ['pnacl', 'newlib', 'glibc', 'host'] 312 options.toolchain = ['pnacl', 'newlib', 'glibc', 'host']
289 if options.experimental or options.bionic: 313 if options.experimental or options.bionic:
290 options.toolchain.append('bionic') 314 options.toolchain.append('bionic')
291 315
292 if 'host' in options.toolchain: 316 if 'host' in options.toolchain:
293 options.toolchain.remove('host') 317 options.toolchain.remove('host')
294 options.toolchain.append(getos.GetPlatform()) 318 options.toolchain.append(getos.GetPlatform())
295 print 'Adding platform: ' + getos.GetPlatform() 319 Trace('Adding platform: ' + getos.GetPlatform())
296 320
297 ValidateToolchains(options.toolchain) 321 ValidateToolchains(options.toolchain)
298 322
299 filters = {} 323 filters = {}
300 if options.toolchain: 324 if options.toolchain:
301 filters['TOOLS'] = options.toolchain 325 filters['TOOLS'] = options.toolchain
302 print 'Filter by toolchain: ' + str(options.toolchain) 326 Trace('Filter by toolchain: ' + str(options.toolchain))
303 if not options.experimental: 327 if not options.experimental:
304 filters['EXPERIMENTAL'] = False 328 filters['EXPERIMENTAL'] = False
305 if options.dest: 329 if options.dest:
306 filters['DEST'] = options.dest 330 filters['DEST'] = options.dest
307 print 'Filter by type: ' + str(options.dest) 331 Trace('Filter by type: ' + str(options.dest))
308 if args: 332 if args:
309 filters['NAME'] = args 333 filters['NAME'] = args
310 print 'Filter by name: ' + str(args) 334 Trace('Filter by name: ' + str(args))
311 335
312 try: 336 try:
313 project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) 337 project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters)
314 except parse_dsc.ValidationError as e: 338 except parse_dsc.ValidationError as e:
315 buildbot_common.ErrorExit(str(e)) 339 buildbot_common.ErrorExit(str(e))
316 parse_dsc.PrintProjectTree(project_tree) 340
341 if verbose:
342 parse_dsc.PrintProjectTree(project_tree)
317 343
318 UpdateHelpers(pepperdir, clobber=options.clobber) 344 UpdateHelpers(pepperdir, clobber=options.clobber)
319 UpdateProjects(pepperdir, project_tree, options.toolchain, 345 UpdateProjects(pepperdir, project_tree, options.toolchain,
320 clobber=options.clobber) 346 clobber=options.clobber)
321 347
322 if options.verbose:
323 global verbose
324 verbose = True
325
326 if options.build: 348 if options.build:
327 if options.config: 349 if options.config:
328 configs = [options.config] 350 configs = [options.config]
329 else: 351 else:
330 configs = ['Debug', 'Release'] 352 configs = ['Debug', 'Release']
331 for config in configs: 353 for config in configs:
332 BuildProjects(pepperdir, project_tree, config=config) 354 BuildProjects(pepperdir, project_tree, config=config)
333 355
334 return 0 356 return 0
335 357
336 358
337 if __name__ == '__main__': 359 if __name__ == '__main__':
338 script_name = os.path.basename(sys.argv[0]) 360 script_name = os.path.basename(sys.argv[0])
339 try: 361 try:
340 sys.exit(main(sys.argv)) 362 sys.exit(main(sys.argv))
341 except parse_dsc.ValidationError as e: 363 except parse_dsc.ValidationError as e:
342 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) 364 buildbot_common.ErrorExit('%s: %s' % (script_name, e))
343 except KeyboardInterrupt: 365 except KeyboardInterrupt:
344 buildbot_common.ErrorExit('%s: interrupted' % script_name) 366 buildbot_common.ErrorExit('%s: interrupted' % script_name)
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/build_tools/build_sdk.py » ('j') | native_client_sdk/src/build_tools/buildbot_common.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698