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

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

Issue 10539082: Add DSC files for the various examples. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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) 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.
11 11
12 The script inspects the following environment variables: 12 The script inspects the following environment variables:
13 13
14 BUILDBOT_BUILDERNAME to determine whether the script is run locally 14 BUILDBOT_BUILDERNAME to determine whether the script is run locally
15 and whether it should upload an SDK to file storage (GSTORE) 15 and whether it should upload an SDK to file storage (GSTORE)
16 """ 16 """
17 17
18 18
19 # std python includes 19 # std python includes
20 import generate_make
20 import optparse 21 import optparse
21 import os 22 import os
22 import platform 23 import platform
23 import subprocess 24 import subprocess
24 import sys 25 import sys
25 26
26 # local includes 27 # local includes
27 import buildbot_common 28 import buildbot_common
28 import build_updater 29 import build_updater
29 import build_utils 30 import build_utils
(...skipping 18 matching lines...) Expand all
48 49
49 import getos 50 import getos
50 import http_download 51 import http_download
51 import oshelpers 52 import oshelpers
52 53
53 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' 54 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/'
54 MAKE = 'nacl_sdk/make_3_81/make.exe' 55 MAKE = 'nacl_sdk/make_3_81/make.exe'
55 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') 56 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py')
56 57
57 58
58 def AddMakeBat(pepperdir, makepath):
59 """Create a simple batch file to execute Make.
60
61 Creates a simple batch file named make.bat for the Windows platform at the
62 given path, pointing to the Make executable in the SDK."""
63
64 makepath = os.path.abspath(makepath)
65 if not makepath.startswith(pepperdir):
66 buildbot_common.ErrorExit('Make.bat not relative to Pepper directory: ' +
67 makepath)
68
69 makeexe = os.path.abspath(os.path.join(pepperdir, 'tools'))
70 relpath = os.path.relpath(makeexe, makepath)
71
72 fp = open(os.path.join(makepath, 'make.bat'), 'wb')
73 outpath = os.path.join(relpath, 'make.exe')
74
75 # Since make.bat is only used by Windows, for Windows path style
76 outpath = outpath.replace(os.path.sep, '\\')
77 fp.write('@%s %%*\n' % outpath)
78 fp.close()
79
80
81 def BuildOutputDir(*paths): 59 def BuildOutputDir(*paths):
82 return os.path.join(OUT_DIR, *paths) 60 return os.path.join(OUT_DIR, *paths)
83 61
84 62
85 def GetGlibcToolchain(platform, arch): 63 def GetGlibcToolchain(platform, arch):
86 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') 64 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars')
87 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch) 65 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch)
88 return os.path.join(tcdir, tcname) 66 return os.path.join(tcdir, tcname)
89 67
90 68
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 'mouselock', 340 'mouselock',
363 'multithreaded_input_events', 341 'multithreaded_input_events',
364 'pi_generator', 342 'pi_generator',
365 'pong', 343 'pong',
366 'sine_synth', 344 'sine_synth',
367 'tumbler', 345 'tumbler',
368 'websocket' 346 'websocket'
369 ], 347 ],
370 'glibc': [ 348 'glibc': [
371 'dlopen', 349 'dlopen',
372 'hello_world_glibc',
373 ], 350 ],
374 'pnacl': [ 351 'pnacl': [
375 'hello_world_pnacl', 352 'hello_world_pnacl',
376 ], 353 ],
377 } 354 }
378 355
379 def GenerateExamplesMakefile(in_path, out_path, examples):
380 """Generate a Makefile that includes only the examples supported by this
381 SDK."""
382 # Line wrap the PROJECTS variable
383 wrap_width = 80
384 projects_text = ''
385 projects_line = 'PROJECTS:='
386 for example in examples:
387 if len(projects_line + example + ' ') > wrap_width:
388 projects_text += projects_line + '\n'
389 projects_line = 'PROJECTS+='
390 projects_line += example + ' '
391
392 # Add the last unwrapped line
393 projects_text += projects_line + '\n'
394
395 out_makefile_text = ''
396 wrote_projects_text = False
397 snipping = False
398 for line in open(in_path, 'r'):
399 if line.startswith('# =SNIP='):
400 snipping = not snipping
401 continue
402
403 if snipping:
404 if not wrote_projects_text:
405 out_makefile_text += projects_text
406 wrote_projects_text = True
407 else:
408 out_makefile_text += line
409
410 open(out_path, 'w').write(out_makefile_text)
411
412 356
413 def CopyExamples(pepperdir, toolchains): 357 def CopyExamples(pepperdir, toolchains):
414 buildbot_common.BuildStep('Copy examples') 358 buildbot_common.BuildStep('Copy examples')
415 359
416 if not os.path.exists(os.path.join(pepperdir, 'tools')): 360 if not os.path.exists(os.path.join(pepperdir, 'tools')):
417 buildbot_common.ErrorExit('Examples depend on missing tools.') 361 buildbot_common.ErrorExit('Examples depend on missing tools.')
418 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): 362 if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
419 buildbot_common.ErrorExit('Examples depend on missing toolchains.') 363 buildbot_common.ErrorExit('Examples depend on missing toolchains.')
420 364
421 exampledir = os.path.join(pepperdir, 'examples') 365 exampledir = os.path.join(pepperdir, 'examples')
422 buildbot_common.RemoveDir(exampledir) 366 buildbot_common.RemoveDir(exampledir)
423 buildbot_common.MakeDir(exampledir) 367 buildbot_common.MakeDir(exampledir)
424 AddMakeBat(pepperdir, exampledir)
425 368
426 # Copy individual files 369 # Copy individual files
427 files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html'] 370 files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html']
428 for filename in files: 371 for filename in files:
429 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir]) 372 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])
430 373
431 # Add examples for supported toolchains 374 # Add examples for supported toolchains
432 examples = [] 375 examples = []
433 for tc in toolchains: 376 for tc in toolchains:
434 examples.extend(EXAMPLE_MAP[tc]) 377 examples.extend(EXAMPLE_MAP[tc])
378
379 print 'Process: ' + ' '.join(examples)
380 args = ['--dstroot=%s' % pepperdir, '--master']
435 for example in examples: 381 for example in examples:
436 buildbot_common.CopyDir(os.path.join(SDK_EXAMPLE_DIR, example), exampledir) 382 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
437 AddMakeBat(pepperdir, os.path.join(exampledir, example)) 383 args.append(dsc)
384 generate_make.main(args)
438 385
439 # Generate a root Makefile that only includes supported examples
440 out_makefile = os.path.join(exampledir, 'Makefile')
441 print 'Generating %s' % (out_makefile,)
442 GenerateExamplesMakefile(os.path.join(SDK_EXAMPLE_DIR, 'Makefile'),
443 out_makefile, examples)
444 386
445 def main(args): 387 def main(args):
446 parser = optparse.OptionParser() 388 parser = optparse.OptionParser()
447 parser.add_option('--pnacl', help='Enable pnacl build.', 389 parser.add_option('--pnacl', help='Enable pnacl build.',
448 action='store_true', dest='pnacl', default=False) 390 action='store_true', dest='pnacl', default=False)
449 parser.add_option('--examples', help='Only build the examples.', 391 parser.add_option('--examples', help='Only build the examples.',
450 action='store_true', dest='only_examples', default=False) 392 action='store_true', dest='only_examples', default=False)
451 parser.add_option('--update', help='Only build the updater.', 393 parser.add_option('--update', help='Only build the updater.',
452 action='store_true', dest='only_updater', default=False) 394 action='store_true', dest='only_updater', default=False)
453 parser.add_option('--skip-tar', help='Skip generating a tarball.', 395 parser.add_option('--skip-tar', help='Skip generating a tarball.',
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 manifest_snippet_stream.write(bundle.GetDataAsString()) 600 manifest_snippet_stream.write(bundle.GetDataAsString())
659 601
660 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, 602 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR,
661 step_link=False) 603 step_link=False)
662 604
663 return 0 605 return 0
664 606
665 607
666 if __name__ == '__main__': 608 if __name__ == '__main__':
667 sys.exit(main(sys.argv)) 609 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698