OLD | NEW |
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 import buildbot_common | 6 import buildbot_common |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 from generate_index import LandingPage | 10 from generate_index import LandingPage |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 continue | 269 continue |
270 | 270 |
271 # If it's a bool, the expected values are always True or False. | 271 # If it's a bool, the expected values are always True or False. |
272 if exp_type is bool: | 272 if exp_type is bool: |
273 continue | 273 continue |
274 | 274 |
275 # If it's a string and there are expected values, make sure it matches | 275 # If it's a string and there are expected values, make sure it matches |
276 if exp_type is str: | 276 if exp_type is str: |
277 if type(exp_value) is list and exp_value: | 277 if type(exp_value) is list and exp_value: |
278 if value not in exp_value: | 278 if value not in exp_value: |
279 ErrorMsg('Value %s not expected for %s.' % (value, key)) | 279 ErrorMsg("Value '%s' not expected for %s." % (value, key)) |
280 failed = True | 280 failed = True |
281 continue | 281 continue |
282 | 282 |
283 # if it's a list, then we need to validate the values | 283 # if it's a list, then we need to validate the values |
284 if exp_type is list: | 284 if exp_type is list: |
285 # If we expect a dictionary, then call this recursively | 285 # If we expect a dictionary, then call this recursively |
286 if type(exp_value) is dict: | 286 if type(exp_value) is dict: |
287 for val in value: | 287 for val in value: |
288 if not ValidateFormat(val, exp_value, ErrorMsg): | 288 if not ValidateFormat(val, exp_value, ErrorMsg): |
289 failed = True | 289 failed = True |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 WriteReplaced(srcfile, dstfile, replace) | 387 WriteReplaced(srcfile, dstfile, replace) |
388 | 388 |
389 | 389 |
390 def LoadProject(filename, toolchains): | 390 def LoadProject(filename, toolchains): |
391 """Generate a Master Makefile that builds all examples. | 391 """Generate a Master Makefile that builds all examples. |
392 | 392 |
393 Load a project desciption file, verifying it conforms and checking | 393 Load a project desciption file, verifying it conforms and checking |
394 if it matches the set of requested toolchains. Return None if the | 394 if it matches the set of requested toolchains. Return None if the |
395 project is filtered out.""" | 395 project is filtered out.""" |
396 | 396 |
397 print '\n\nProcessing %s...' % filename | 397 print 'Processing %s...' % filename |
398 # Default src directory is the directory the description was found in | 398 # Default src directory is the directory the description was found in |
399 desc = open(filename, 'r').read() | 399 desc = open(filename, 'r').read() |
400 desc = eval(desc, {}, {}) | 400 desc = eval(desc, {}, {}) |
401 | 401 |
402 # Verify the format of this file | 402 # Verify the format of this file |
403 if not ValidateFormat(desc, DSC_FORMAT): | 403 if not ValidateFormat(desc, DSC_FORMAT): |
404 ErrorExit('Failed to validate: ' + filename) | 404 ErrorExit('Failed to validate: ' + filename) |
405 | 405 |
406 # Check if we are actually interested in this example | 406 # Check if we are actually interested in this example |
407 match = False | 407 match = False |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 } | 520 } |
521 | 521 |
522 WriteReplaced(in_path, out_path, replace) | 522 WriteReplaced(in_path, out_path, replace) |
523 | 523 |
524 outdir = os.path.dirname(os.path.abspath(out_path)) | 524 outdir = os.path.dirname(os.path.abspath(out_path)) |
525 pepperdir = os.path.dirname(outdir) | 525 pepperdir = os.path.dirname(outdir) |
526 AddMakeBat(pepperdir, outdir) | 526 AddMakeBat(pepperdir, outdir) |
527 | 527 |
528 | 528 |
529 def main(argv): | 529 def main(argv): |
530 parser = optparse.OptionParser() | 530 usage = "usage: generate_make [options] <dsc_file ..>" |
| 531 parser = optparse.OptionParser(usage=usage) |
531 parser.add_option('--dstroot', help='Set root for destination.', | 532 parser.add_option('--dstroot', help='Set root for destination.', |
532 dest='dstroot', default=os.path.join(OUT_DIR, 'pepper_canary')) | 533 default=os.path.join(OUT_DIR, 'pepper_canary')) |
533 parser.add_option('--master', help='Create master Makefile.', | 534 parser.add_option('--master', help='Create master Makefile.', |
534 action='store_true', dest='master', default=False) | 535 action='store_true', default=False) |
535 parser.add_option('--newlib', help='Create newlib examples.', | 536 parser.add_option('--newlib', help='Create newlib examples.', |
536 action='store_true', dest='newlib', default=False) | 537 action='store_true', default=False) |
537 parser.add_option('--glibc', help='Create glibc examples.', | 538 parser.add_option('--glibc', help='Create glibc examples.', |
538 action='store_true', dest='glibc', default=False) | 539 action='store_true', default=False) |
539 parser.add_option('--pnacl', help='Create pnacl examples.', | 540 parser.add_option('--pnacl', help='Create pnacl examples.', |
540 action='store_true', dest='pnacl', default=False) | 541 action='store_true', default=False) |
541 parser.add_option('--host', help='Create host examples.', | 542 parser.add_option('--host', help='Create host examples.', |
542 action='store_true', dest='host', default=False) | 543 action='store_true', default=False) |
543 parser.add_option('--experimental', help='Create experimental examples.', | 544 parser.add_option('--experimental', help='Create experimental examples.', |
544 action='store_true', dest='experimental', default=False) | 545 action='store_true', default=False) |
545 | 546 |
546 toolchains = [] | 547 toolchains = [] |
547 platform = getos.GetPlatform() | 548 platform = getos.GetPlatform() |
548 | 549 |
549 options, args = parser.parse_args(argv) | 550 options, args = parser.parse_args(argv) |
550 if options.newlib: | 551 if options.newlib: |
551 toolchains.append('newlib') | 552 toolchains.append('newlib') |
552 if options.glibc: | 553 if options.glibc: |
553 toolchains.append('glibc') | 554 toolchains.append('glibc') |
554 if options.pnacl: | 555 if options.pnacl: |
555 toolchains.append('pnacl') | 556 toolchains.append('pnacl') |
556 if options.host: | 557 if options.host: |
557 toolchains.append(platform) | 558 toolchains.append(platform) |
558 | 559 |
559 if not args: | 560 if not args: |
560 ErrorExit('Please specify one or more projects to generate Makefiles for.') | 561 ErrorExit('Please specify one or more projects to generate Makefiles for.') |
561 | 562 |
562 # By default support newlib and glibc | 563 # By default support newlib and glibc |
563 if not toolchains: | 564 if not toolchains: |
564 toolchains = ['newlib', 'glibc'] | 565 toolchains = ['newlib', 'glibc', 'pnacl'] |
565 print 'Using default toolchains: ' + ' '.join(toolchains) | |
566 | 566 |
567 master_projects = {} | 567 master_projects = {} |
568 | 568 |
569 landing_page = LandingPage() | 569 landing_page = LandingPage() |
570 for filename in args: | 570 for i, filename in enumerate(args): |
| 571 if i: |
| 572 # Print two newlines between each dsc file we process |
| 573 print '\n' |
571 desc = LoadProject(filename, toolchains) | 574 desc = LoadProject(filename, toolchains) |
572 if not desc: | 575 if not desc: |
573 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) | 576 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) |
574 continue | 577 continue |
575 | 578 |
576 if desc.get('EXPERIMENTAL', False) and not options.experimental: | 579 if desc.get('EXPERIMENTAL', False) and not options.experimental: |
577 print 'Skipping %s, experimental only.' % (filename,) | 580 print 'Skipping %s, experimental only.' % (filename,) |
578 continue | 581 continue |
579 | 582 |
580 srcroot = os.path.dirname(os.path.abspath(filename)) | 583 srcroot = os.path.dirname(os.path.abspath(filename)) |
(...skipping 25 matching lines...) Expand all Loading... |
606 for dest, projects in master_projects.iteritems(): | 609 for dest, projects in master_projects.iteritems(): |
607 master_out = os.path.join(options.dstroot, dest, 'Makefile') | 610 master_out = os.path.join(options.dstroot, dest, 'Makefile') |
608 GenerateMasterMakefile(master_in, master_out, projects) | 611 GenerateMasterMakefile(master_in, master_out, projects) |
609 | 612 |
610 return 0 | 613 return 0 |
611 | 614 |
612 | 615 |
613 if __name__ == '__main__': | 616 if __name__ == '__main__': |
614 sys.exit(main(sys.argv[1:])) | 617 sys.exit(main(sys.argv[1:])) |
615 | 618 |
OLD | NEW |