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

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

Issue 9383038: Build cleanups (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | native_client_sdk/src/examples/Makefile » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Entry point for both build and try bots 6 """Entry point for both build and try bots
7 7
8 This script is invoked from XXX, usually without arguments 8 This script is invoked from XXX, usually without arguments
9 to package an SDK. It automatically determines whether 9 to package an SDK. It automatically determines whether
10 this SDK is for mac, win, linux. 10 this SDK is for mac, win, linux.
(...skipping 10 matching lines...) Expand all
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 23
24 # local includes 24 # local includes
25 import build_utils 25 import build_utils
26 import lastchange 26 import lastchange
27 27
28 # Create the various paths of interest 28 # Create the various paths of interest
29 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 29 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
30 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) 30 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR)
31 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples')
31 SDK_DIR = os.path.dirname(SDK_SRC_DIR) 32 SDK_DIR = os.path.dirname(SDK_SRC_DIR)
32 SRC_DIR = os.path.dirname(SDK_DIR) 33 SRC_DIR = os.path.dirname(SDK_DIR)
33 NACL_DIR = os.path.join(SRC_DIR, 'native_client') 34 NACL_DIR = os.path.join(SRC_DIR, 'native_client')
34 OUT_DIR = os.path.join(SRC_DIR, 'out') 35 OUT_DIR = os.path.join(SRC_DIR, 'out')
35 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') 36 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi')
36 37
37 38
38 # Add SDK make tools scripts to the python path. 39 # Add SDK make tools scripts to the python path.
39 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) 40 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
40 sys.path.append(os.path.join(NACL_DIR, 'build')) 41 sys.path.append(os.path.join(NACL_DIR, 'build'))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 def AddMakeBat(makepath): 102 def AddMakeBat(makepath):
102 """Create a simple batch file to execute Make. 103 """Create a simple batch file to execute Make.
103 104
104 Creates a simple batch file named make.bat for the Windows platform at the 105 Creates a simple batch file named make.bat for the Windows platform at the
105 given path, pointing to the Make executable in the SDK.""" 106 given path, pointing to the Make executable in the SDK."""
106 fp = open(os.path.join(makepath, 'make.bat'), 'wb') 107 fp = open(os.path.join(makepath, 'make.bat'), 'wb')
107 fp.write('@..\\..\\tools\\make.exe %*\n') 108 fp.write('@..\\..\\tools\\make.exe %*\n')
108 fp.close() 109 fp.close()
109 110
110 111
111 def CopyDir(src, dst, excludes=['.svn']): 112 def CopyDir(src, dst, excludes=['.svn','*/.svn']):
112 """Recursively copy a directory using.""" 113 """Recursively copy a directory using."""
113 args = ['-r', src, dst] 114 args = ['-r', src, dst]
114 for exc in excludes: 115 for exc in excludes:
115 args.append('--exclude=' + exc) 116 args.append('--exclude=' + exc)
116 print "cp -r %s %s" % (src, dst) 117 print "cp -r %s %s" % (src, dst)
117 oshelpers.Copy(args) 118 oshelpers.Copy(args)
118 119
119 120
120 def RemoveDir(dst): 121 def RemoveDir(dst):
121 """Remove the provided path.""" 122 """Remove the provided path."""
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 MakeDir(os.path.join(tc_dst_inc, 'GLES2')) 277 MakeDir(os.path.join(tc_dst_inc, 'GLES2'))
277 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'), 278 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'),
278 os.path.join(tc_dst_inc, 'GLES2')) 279 os.path.join(tc_dst_inc, 'GLES2'))
279 280
280 # Copy the KHR headers 281 # Copy the KHR headers
281 MakeDir(os.path.join(tc_dst_inc, 'KHR')) 282 MakeDir(os.path.join(tc_dst_inc, 'KHR'))
282 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), 283 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'),
283 os.path.join(tc_dst_inc, 'KHR')) 284 os.path.join(tc_dst_inc, 'KHR'))
284 285
285 286
287 def UntarToolchains(pepperdir, platform, arch):
288 BuildStep('Untar Toolchains')
289 tcname = platform + '_' + arch
290 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp')
291 RemoveDir(tmpdir)
292 MakeDir(tmpdir)
293
294 # Untar the newlib toolchains
295 tarfile = GetNewlibToolchain(platform, arch)
296 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR)
297
298 # Then rename/move it to the pepper toolchain directory
299 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk')
300 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
301 print "Buildbot mv %s to %s" % (srcdir, newlibdir)
302 MoveDir(srcdir, newlibdir)
303 print "Done with buildbot move"
304 # Untar the glibc toolchains
305 tarfile = GetGlibcToolchain(platform, arch)
306 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR)
307
308 # Then rename/move it to the pepper toolchain directory
309 srcdir = os.path.join(tmpdir, 'toolchain', tcname)
310 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
311 MoveDir(srcdir, glibcdir)
312
313
314 def BuildToolchains(pepperdir, platform, arch, pepper_ver):
315 BuildStep('SDK Items')
316
317 tcname = platform + '_' + arch
318 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
319 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
320
321 # Run scons TC build steps
322 if arch == 'x86':
323 Run(GetBuildArgs('newlib', newlibdir, 'x86', '32'), cwd=NACL_DIR)
324 Run(GetBuildArgs('newlib', newlibdir, 'x86', '64'), cwd=NACL_DIR)
325
326 Run(GetBuildArgs('glibc', glibcdir, 'x86', '32'), cwd=NACL_DIR)
327 Run(GetBuildArgs('glibc', glibcdir, 'x86', '64'), cwd=NACL_DIR)
328 else:
329 ErrorExit('Missing arch %s' % arch)
330
331 # Copy headers
332 if arch == 'x86':
333 InstallHeaders(GetToolchainNaClInclude(newlibdir, 'x86'),
334 pepper_ver,
335 'newlib')
336 InstallHeaders(GetToolchainNaClInclude(glibcdir, 'x86'),
337 pepper_ver,
338 'glibc')
339 else:
340 ErrorExit('Missing arch %s' % arch)
341
342
343 def CopyExamples(pepperdir, extras = []):
344 BuildStep('Copy examples')
345 examples = [
346 'dlopen', 'fullscreen_tumbler', 'gamepad', 'geturl',
347 'hello_world_glibc', 'hello_world_interactive', 'hello_world_newlib',
348 'input_events', 'load_progress', 'mouselock',
349 'multithreaded_input_events', 'pi_generator', 'pong', 'sine_synth',
350 'tumbler'] + extras
351 files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html', 'Makefile']
352 if not os.path.exists(os.path.join(pepperdir, 'tools')):
353 ErrorExit('Examples depend on missing tools.')
354 if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
355 ErrorExit('Examples depend on missing toolchains.')
356 exampledir = os.path.join(pepperdir, 'examples')
357 RemoveDir(exampledir)
358 MakeDir(exampledir)
359 AddMakeBat(exampledir)
360 for filename in files:
361 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])
362 for example in examples:
363 CopyDir(os.path.join(SDK_EXAMPLE_DIR, example), exampledir)
364
365
366 def BuildUpdater():
367 BuildStep('Create Installer/Updater')
368 tooldir = os.path.join(SRC_DIR, 'out', 'sdk_tools')
369 sdkupdate = os.path.join(SDK_SRC_DIR, 'build_tools', 'sdk_tools', 'sdk_update. py')
370 license = os.path.join(SDK_SRC_DIR, 'LICENSE')
371 RemoveDir(tooldir)
372 MakeDir(tooldir)
373 args = ['-v', sdkupdate, license, CYGTAR, tooldir]
374 oshelpers.Copy(args)
375 tarname = 'sdk_tools.tgz'
376 tarfile = os.path.join(OUT_DIR, tarname)
377 Run([sys.executable, CYGTAR, '-C', tooldir, '-czf', tarfile,
378 'sdk_update.py', 'LICENSE', 'cygtar.py'], cwd=NACL_DIR)
379 sys.stdout.write('\n')
380
381
286 def main(args): 382 def main(args):
287 parser = optparse.OptionParser() 383 parser = optparse.OptionParser()
288 # Modes 384
289 parser.add_option('--examples-only', help='Rebuild the examples.', 385 parser.add_option('--examples', help='Rebuild the examples.',
290 action='store_true', dest='examples_only', default=False) 386 action='store_true', dest='examples', default=False)
387 parser.add_option('--update', help='Rebuild the updater.',
388 action='store_true', dest='update', default=False)
291 parser.add_option('--skip-tar', help='Skip generating a tarball.', 389 parser.add_option('--skip-tar', help='Skip generating a tarball.',
292 action='store_true', dest='skip_tar', default=False) 390 action='store_true', dest='skip_tar', default=False)
293 parser.add_option('--archive', help='Force the archive step.', 391 parser.add_option('--archive', help='Force the archive step.',
294 action='store_true', dest='archive') 392 action='store_true', dest='archive', default=True)
295 393 parser.add_option('--release', help='PPAPI release version.',
394 dest='release', default=None)
395
296 options, args = parser.parse_args(args[1:]) 396 options, args = parser.parse_args(args[1:])
297 397
298 platform = getos.GetPlatform() 398 platform = getos.GetPlatform()
299 arch = 'x86' 399 arch = 'x86'
300 400
301 skip_examples = False 401 skip = options.examples or options.update
302 skip_untar = False
303 skip_build = False
304 skip_headers = False
305 skip_tar = False
306 force_archive = options.archive
307 402
308 if options.examples_only: 403 skip_examples = skip
309 skip_untar = True 404 skip_update = skip
310 skip_build = True 405 skip_untar = skip
311 skip_headers = True 406 skip_build = skip
312 skip_tar = True 407 skip_tar = skip or options.skip_tar
313 408
314 if options.skip_tar: 409 if options.examples: skip_examples = False
315 skip_tar = True 410 if options.update: skip_update = False
316 411
317 if options.archive and (options.examples_only or options.skip_tar): 412 if options.archive and (options.examples_only or options.skip_tar):
318 parser.error('Incompatible arguments with archive.') 413 parser.error('Incompatible arguments with archive.')
319 414
320 pepper_ver = build_utils.ChromeMajorVersion() 415 pepper_ver = build_utils.ChromeMajorVersion()
321 clnumber = lastchange.FetchVersionInfo(None).revision 416 clnumber = lastchange.FetchVersionInfo(None).revision
417 if options.release:
418 pepper_ver = options.release
322 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) 419 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)
323 420
421
324 BuildStep('Clean Pepper Dir') 422 BuildStep('Clean Pepper Dir')
325 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) 423 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
326 if not skip_untar: 424 if not skip_untar:
327 RemoveDir(pepperdir) 425 RemoveDir(pepperdir)
328 MakeDir(os.path.join(pepperdir, 'toolchain')) 426 MakeDir(os.path.join(pepperdir, 'toolchain'))
329 MakeDir(os.path.join(pepperdir, 'tools')) 427 MakeDir(os.path.join(pepperdir, 'tools'))
330 428
331 BuildStep('Untar Toolchains') 429 BuildStep('Add Text Files')
332 tcname = platform + '_' + arch 430 files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE', 'README']
333 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') 431 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files]
432 oshelpers.Copy(['-v'] + files + [pepperdir])
433
334 434
335 # Clean out the temporary toolchain untar directory 435 # Clean out the temporary toolchain untar directory
336 if not skip_untar: 436 if not skip_untar:
337 RemoveDir(tmpdir) 437 UntarToolchains(pepperdir, platform, arch)
338 MakeDir(tmpdir)
339 tcname = platform + '_' + arch
340 438
341 # Untar the newlib toolchains 439 if not skip_build:
342 tarfile = GetNewlibToolchain(platform, arch) 440 BuildToolchains(pepperdir, platform, arch, pepper_ver)
343 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR)
344 441
345 # Then rename/move it to the pepper toolchain directory 442 BuildStep('Copy make OS helpers')
346 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk')
347 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
348 print "Buildbot mv %s to %s" % (srcdir, newlibdir)
349 MoveDir(srcdir, newlibdir)
350 print "Done with buildbot move"
351 # Untar the glibc toolchains
352 tarfile = GetGlibcToolchain(platform, arch)
353 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR)
354
355 # Then rename/move it to the pepper toolchain directory
356 srcdir = os.path.join(tmpdir, 'toolchain', tcname)
357 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
358 MoveDir(srcdir, glibcdir)
359 else:
360 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
361 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
362
363 BuildStep('SDK Items')
364 if not skip_build:
365 if arch == 'x86':
366 Run(GetBuildArgs('newlib', newlibdir, 'x86', '32'), cwd=NACL_DIR)
367 Run(GetBuildArgs('newlib', newlibdir, 'x86', '64'), cwd=NACL_DIR)
368
369 Run(GetBuildArgs('glibc', glibcdir, 'x86', '32'), cwd=NACL_DIR)
370 Run(GetBuildArgs('glibc', glibcdir, 'x86', '64'), cwd=NACL_DIR)
371 else:
372 ErrorExit('Missing arch %s' % arch)
373
374 if not skip_headers:
375 BuildStep('Copy Toolchain headers')
376 if arch == 'x86':
377 InstallHeaders(GetToolchainNaClInclude(newlibdir, 'x86'),
378 pepper_ver,
379 'newlib')
380 InstallHeaders(GetToolchainNaClInclude(glibcdir, 'x86'),
381 pepper_ver,
382 'glibc')
383 else:
384 ErrorExit('Missing arch %s' % arch)
385
386 BuildStep('Copy make helpers')
387 CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), 443 CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
388 os.path.join(pepperdir, 'tools')) 444 os.path.join(pepperdir, 'tools'))
389 if platform == 'win': 445 if platform == 'win':
390 BuildStep('Add MAKE') 446 BuildStep('Add MAKE')
391 http_download.HttpDownload(GSTORE + MAKE, 447 http_download.HttpDownload(GSTORE + MAKE,
392 os.path.join(pepperdir, 'tools' ,'make.exe')) 448 os.path.join(pepperdir, 'tools' ,'make.exe'))
393 449
394 if not skip_examples: 450 if not skip_examples:
395 BuildStep('Copy examples') 451 CopyExamples(pepperdir)
396 RemoveDir(os.path.join(pepperdir, 'examples'))
397 CopyDir(os.path.join(SDK_SRC_DIR, 'examples'), pepperdir)
398 452
399 tarname = 'naclsdk_' + platform + '.bz2'
400 BuildStep('Tar Pepper Bundle')
401 if not skip_tar: 453 if not skip_tar:
402 tarfile = os.path.join(OUT_DIR, 'naclsdk_' + platform + '.bz2') 454 BuildStep('Tar Pepper Bundle')
455 tarname = 'naclsdk_' + platform + '.bz2'
456 tarfile = os.path.join(OUT_DIR, tarname)
403 Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 457 Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
404 'pepper_' + pepper_ver], cwd=NACL_DIR) 458 'pepper_' + pepper_ver], cwd=NACL_DIR)
405 459
406 # Archive on non-trybots. 460 # Archive on non-trybots.
407 if force_archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): 461 if options.archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''):
408 BuildStep('Archive build') 462 BuildStep('Archive build')
409 Archive(tarname) 463 Archive(tarname)
410 464
411 if not skip_examples: 465 if not skip_examples:
412 BuildStep('Test Build Examples') 466 BuildStep('Test Build Examples')
413 filelist = os.listdir(os.path.join(pepperdir, 'examples')) 467 filelist = os.listdir(os.path.join(pepperdir, 'examples'))
414 for filenode in filelist: 468 for filenode in filelist:
415 dirnode = os.path.join(pepperdir, 'examples', filenode) 469 dirnode = os.path.join(pepperdir, 'examples', filenode)
416 makefile = os.path.join(dirnode, 'Makefile') 470 makefile = os.path.join(dirnode, 'Makefile')
417 if os.path.isfile(makefile): 471 if os.path.isfile(makefile):
418 if platform == 'win':
419 AddMakeBat(dirnode)
420 print "\n\nMake: " + dirnode 472 print "\n\nMake: " + dirnode
421 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) 473 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True)
422 474
475 # Build SDK Tools
476 if not skip_update:
477 BuildUpdater()
478
423 return 0 479 return 0
424 480
425 481
426 if __name__ == '__main__': 482 if __name__ == '__main__':
427 sys.exit(main(sys.argv)) 483 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/examples/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698