| 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 make_rules | 7 import make_rules |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 'DEST': (str, '', True), | 276 'DEST': (str, '', True), |
| 277 }, False), | 277 }, False), |
| 278 'SEARCH': (list, '', False), | 278 'SEARCH': (list, '', False), |
| 279 'POST': (str, '', False), | 279 'POST': (str, '', False), |
| 280 'PRE': (str, '', False), | 280 'PRE': (str, '', False), |
| 281 'DEST': (str, ['examples', 'src'], True), | 281 'DEST': (str, ['examples', 'src'], True), |
| 282 'NAME': (str, '', False), | 282 'NAME': (str, '', False), |
| 283 'DATA': (list, '', False), | 283 'DATA': (list, '', False), |
| 284 'TITLE': (str, '', False), | 284 'TITLE': (str, '', False), |
| 285 'DESC': (str, '', False), | 285 'DESC': (str, '', False), |
| 286 'INFO': (str, '', False) | 286 'INFO': (str, '', False), |
| 287 'EXPERIMENTAL': (bool, [True, False], False) |
| 287 } | 288 } |
| 288 | 289 |
| 289 | 290 |
| 290 def ErrorMsgFunc(text): | 291 def ErrorMsgFunc(text): |
| 291 sys.stderr.write(text + '\n') | 292 sys.stderr.write(text + '\n') |
| 292 | 293 |
| 293 | 294 |
| 294 def ValidateFormat(src, format, ErrorMsg=ErrorMsgFunc): | 295 def ValidateFormat(src, format, ErrorMsg=ErrorMsgFunc): |
| 295 failed = False | 296 failed = False |
| 296 | 297 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 parser.add_option('--master', help='Create master Makefile.', | 521 parser.add_option('--master', help='Create master Makefile.', |
| 521 action='store_true', dest='master', default=False) | 522 action='store_true', dest='master', default=False) |
| 522 parser.add_option('--newlib', help='Create newlib examples.', | 523 parser.add_option('--newlib', help='Create newlib examples.', |
| 523 action='store_true', dest='newlib', default=False) | 524 action='store_true', dest='newlib', default=False) |
| 524 parser.add_option('--glibc', help='Create glibc examples.', | 525 parser.add_option('--glibc', help='Create glibc examples.', |
| 525 action='store_true', dest='glibc', default=False) | 526 action='store_true', dest='glibc', default=False) |
| 526 parser.add_option('--pnacl', help='Create pnacl examples.', | 527 parser.add_option('--pnacl', help='Create pnacl examples.', |
| 527 action='store_true', dest='pnacl', default=False) | 528 action='store_true', dest='pnacl', default=False) |
| 528 parser.add_option('--host', help='Create host examples.', | 529 parser.add_option('--host', help='Create host examples.', |
| 529 action='store_true', dest='host', default=False) | 530 action='store_true', dest='host', default=False) |
| 531 parser.add_option('--experimental', help='Create experimental examples.', |
| 532 action='store_true', dest='experimental', default=False) |
| 530 | 533 |
| 531 toolchains = [] | 534 toolchains = [] |
| 532 platform = getos.GetPlatform() | 535 platform = getos.GetPlatform() |
| 533 | 536 |
| 534 options, args = parser.parse_args(argv) | 537 options, args = parser.parse_args(argv) |
| 535 if options.newlib: | 538 if options.newlib: |
| 536 toolchains.append('newlib') | 539 toolchains.append('newlib') |
| 537 if options.glibc: | 540 if options.glibc: |
| 538 toolchains.append('glibc') | 541 toolchains.append('glibc') |
| 539 if options.pnacl: | 542 if options.pnacl: |
| 540 toolchains.append('pnacl') | 543 toolchains.append('pnacl') |
| 541 if options.host: | 544 if options.host: |
| 542 toolchains.append(platform) | 545 toolchains.append(platform) |
| 543 | 546 |
| 544 # By default support newlib and glibc | 547 # By default support newlib and glibc |
| 545 if not toolchains: | 548 if not toolchains: |
| 546 toolchains = ['newlib', 'glibc'] | 549 toolchains = ['newlib', 'glibc'] |
| 547 print 'Using default toolchains: ' + ' '.join(toolchains) | 550 print 'Using default toolchains: ' + ' '.join(toolchains) |
| 548 | 551 |
| 549 examples = [] | 552 examples = [] |
| 550 libs = [] | 553 libs = [] |
| 551 for filename in args: | 554 for filename in args: |
| 552 desc = LoadProject(filename, toolchains) | 555 desc = LoadProject(filename, toolchains) |
| 553 if not desc: | 556 if not desc: |
| 554 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) | 557 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) |
| 555 continue | 558 continue |
| 556 | 559 |
| 560 if desc.get('EXPERIMENTAL', False) and not options.experimental: |
| 561 print 'Skipping %s, experimental only.' % (filename,) |
| 562 continue |
| 563 |
| 557 srcroot = os.path.dirname(os.path.abspath(filename)) | 564 srcroot = os.path.dirname(os.path.abspath(filename)) |
| 558 if not ProcessProject(srcroot, options.dstroot, desc, toolchains): | 565 if not ProcessProject(srcroot, options.dstroot, desc, toolchains): |
| 559 ErrorExit('\n*** Failed to process project: %s ***' % filename) | 566 ErrorExit('\n*** Failed to process project: %s ***' % filename) |
| 560 | 567 |
| 561 # if this is an example add it to the master make and update the html | 568 # if this is an example add it to the master make and update the html |
| 562 if desc['DEST'] == 'examples': | 569 if desc['DEST'] == 'examples': |
| 563 examples.append(desc['NAME']) | 570 examples.append(desc['NAME']) |
| 564 ProcessHTML(srcroot, options.dstroot, desc, toolchains) | 571 ProcessHTML(srcroot, options.dstroot, desc, toolchains) |
| 565 | 572 |
| 566 # if this is a library add it to the master make | 573 # if this is a library add it to the master make |
| 567 if desc['DEST'] == 'src': | 574 if desc['DEST'] == 'src': |
| 568 libs.append(desc['NAME']) | 575 libs.append(desc['NAME']) |
| 569 | 576 |
| 570 if options.master: | 577 if options.master: |
| 571 master_in = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') | 578 master_in = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') |
| 572 master_out = os.path.join(options.dstroot, 'examples', 'Makefile') | 579 master_out = os.path.join(options.dstroot, 'examples', 'Makefile') |
| 573 GenerateMasterMakefile(master_in, master_out, examples) | 580 GenerateMasterMakefile(master_in, master_out, examples) |
| 574 master_out = os.path.join(options.dstroot, 'src', 'Makefile') | 581 master_out = os.path.join(options.dstroot, 'src', 'Makefile') |
| 575 GenerateMasterMakefile(master_in, master_out, libs) | 582 GenerateMasterMakefile(master_in, master_out, libs) |
| 576 return 0 | 583 return 0 |
| 577 | 584 |
| 578 | 585 |
| 579 if __name__ == '__main__': | 586 if __name__ == '__main__': |
| 580 sys.exit(main(sys.argv[1:])) | 587 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |