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 """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 copy |
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 out_makefile, examples) | 444 out_makefile, examples) |
444 | 445 |
445 def main(args): | 446 def main(args): |
446 parser = optparse.OptionParser() | 447 parser = optparse.OptionParser() |
447 parser.add_option('--pnacl', help='Enable pnacl build.', | 448 parser.add_option('--pnacl', help='Enable pnacl build.', |
448 action='store_true', dest='pnacl', default=False) | 449 action='store_true', dest='pnacl', default=False) |
449 parser.add_option('--examples', help='Only build the examples.', | 450 parser.add_option('--examples', help='Only build the examples.', |
450 action='store_true', dest='only_examples', default=False) | 451 action='store_true', dest='only_examples', default=False) |
451 parser.add_option('--update', help='Only build the updater.', | 452 parser.add_option('--update', help='Only build the updater.', |
452 action='store_true', dest='only_updater', default=False) | 453 action='store_true', dest='only_updater', default=False) |
| 454 parser.add_option('--test-examples', |
| 455 help='Run the pyauto tests for examples.', action='store_true', |
| 456 dest='test_examples', default=False) |
453 parser.add_option('--skip-tar', help='Skip generating a tarball.', | 457 parser.add_option('--skip-tar', help='Skip generating a tarball.', |
454 action='store_true', dest='skip_tar', default=False) | 458 action='store_true', dest='skip_tar', default=False) |
455 parser.add_option('--archive', help='Force the archive step.', | 459 parser.add_option('--archive', help='Force the archive step.', |
456 action='store_true', dest='archive', default=False) | 460 action='store_true', dest='archive', default=False) |
457 parser.add_option('--release', help='PPAPI release version.', | 461 parser.add_option('--release', help='PPAPI release version.', |
458 dest='release', default=None) | 462 dest='release', default=None) |
459 | 463 |
460 options, args = parser.parse_args(args[1:]) | 464 options, args = parser.parse_args(args[1:]) |
461 platform = getos.GetPlatform() | 465 platform = getos.GetPlatform() |
462 arch = 'x86' | 466 arch = 'x86' |
463 | 467 |
464 builder_name = os.getenv('BUILDBOT_BUILDERNAME','') | 468 builder_name = os.getenv('BUILDBOT_BUILDERNAME','') |
465 if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0: | 469 if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0: |
466 options.pnacl = True | 470 options.pnacl = True |
467 | 471 |
| 472 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build |
| 473 # pyauto Chrome. |
| 474 if buildbot_common.IsSDKBuilder(): |
| 475 options.test_examples = True |
| 476 |
468 if options.pnacl: | 477 if options.pnacl: |
469 toolchains = ['pnacl'] | 478 toolchains = ['pnacl'] |
470 else: | 479 else: |
471 toolchains = ['newlib', 'glibc'] | 480 toolchains = ['newlib', 'glibc'] |
472 print 'Building: ' + ' '.join(toolchains) | 481 print 'Building: ' + ' '.join(toolchains) |
473 skip = options.only_examples or options.only_updater | 482 skip = options.only_examples or options.only_updater |
474 | 483 |
475 skip_examples = skip and not options.only_examples | 484 skip_examples = skip and not options.only_examples |
476 skip_update = skip and not options.only_updater | 485 skip_update = skip and not options.only_updater |
477 skip_untar = skip | 486 skip_untar = skip |
478 skip_build = skip | 487 skip_build = skip |
479 skip_test_updater = skip | 488 skip_test_updater = skip |
| 489 skip_test_examples = skip or not options.test_examples |
| 490 skip_test_build_tools = skip |
480 skip_tar = skip or options.skip_tar | 491 skip_tar = skip or options.skip_tar |
481 | 492 |
482 if options.archive and (options.only_examples or options.skip_tar): | 493 if options.archive and (options.only_examples or options.skip_tar): |
483 parser.error('Incompatible arguments with archive.') | 494 parser.error('Incompatible arguments with archive.') |
484 | 495 |
485 pepper_ver = str(int(build_utils.ChromeMajorVersion())) | 496 pepper_ver = str(int(build_utils.ChromeMajorVersion())) |
486 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) | 497 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) |
487 clnumber = build_utils.ChromeRevision() | 498 clnumber = build_utils.ChromeRevision() |
488 if options.release: | 499 if options.release: |
489 pepper_ver = options.release | 500 pepper_ver = options.release |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 if 'pnacl' in toolchains: | 555 if 'pnacl' in toolchains: |
545 tarname = 'p' + tarname | 556 tarname = 'p' + tarname |
546 tarfile = os.path.join(OUT_DIR, tarname) | 557 tarfile = os.path.join(OUT_DIR, tarname) |
547 | 558 |
548 if not skip_tar: | 559 if not skip_tar: |
549 buildbot_common.BuildStep('Tar Pepper Bundle') | 560 buildbot_common.BuildStep('Tar Pepper Bundle') |
550 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, | 561 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, |
551 'pepper_' + pepper_ver], cwd=NACL_DIR) | 562 'pepper_' + pepper_ver], cwd=NACL_DIR) |
552 | 563 |
553 # Run build tests | 564 # Run build tests |
554 buildbot_common.BuildStep('Run build_tools tests') | 565 if not skip_test_build_tools: |
555 buildbot_common.Run([sys.executable, | 566 buildbot_common.BuildStep('Run build_tools tests') |
556 os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')]) | 567 buildbot_common.Run([sys.executable, |
| 568 os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')]) |
557 | 569 |
558 # build sdk update | 570 # build sdk update |
559 if not skip_update: | 571 if not skip_update: |
560 build_updater.BuildUpdater(OUT_DIR) | 572 build_updater.BuildUpdater(OUT_DIR) |
561 | 573 |
562 # start local server sharing a manifest + the new bundle | 574 # start local server sharing a manifest + the new bundle |
563 if not skip_test_updater and not skip_tar: | 575 if not skip_test_updater and not skip_tar: |
564 buildbot_common.BuildStep('Move bundle to localserver dir') | 576 buildbot_common.BuildStep('Move bundle to localserver dir') |
565 buildbot_common.MakeDir(SERVER_DIR) | 577 buildbot_common.MakeDir(SERVER_DIR) |
566 buildbot_common.Move(tarfile, SERVER_DIR) | 578 buildbot_common.Move(tarfile, SERVER_DIR) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 # If we are testing examples, do it in the newly pulled directory. | 619 # If we are testing examples, do it in the newly pulled directory. |
608 pepperdir = os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) | 620 pepperdir = os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) |
609 | 621 |
610 # kill server | 622 # kill server |
611 finally: | 623 finally: |
612 if server: | 624 if server: |
613 server.Shutdown() | 625 server.Shutdown() |
614 | 626 |
615 # build examples. | 627 # build examples. |
616 if not skip_examples: | 628 if not skip_examples: |
617 buildbot_common.BuildStep('Test Build Examples') | 629 buildbot_common.BuildStep('Build Examples') |
618 example_dir = os.path.join(pepperdir, 'examples') | 630 example_dir = os.path.join(pepperdir, 'examples') |
619 makefile = os.path.join(example_dir, 'Makefile') | 631 makefile = os.path.join(example_dir, 'Makefile') |
620 if os.path.isfile(makefile): | 632 if os.path.isfile(makefile): |
621 print "\n\nMake: " + example_dir | 633 print "\n\nMake: " + example_dir |
622 buildbot_common.Run(['make', '-j8'], | 634 buildbot_common.Run(['make', '-j8'], |
623 cwd=os.path.abspath(example_dir), shell=True) | 635 cwd=os.path.abspath(example_dir), shell=True) |
624 | 636 |
625 # test examples. | 637 # test examples. |
626 skip_test_examples = True | 638 if not skip_examples and not skip_test_examples: |
627 if not skip_examples: | 639 buildbot_common.BuildStep('Test Examples') |
628 if not skip_test_examples: | 640 env = copy.copy(os.environ) |
629 run_script_path = os.path.join(SRC_DIR, 'chrome', 'test', 'functional') | 641 env['pepper_ver'] = pepper_ver |
630 buildbot_common.Run([sys.executable, 'nacl_sdk_example_test.py', | 642 env['OUT_DIR'] = OUT_DIR |
631 'nacl_sdk_example_test.NaClSDKTest.testNaClSDK'], cwd=run_script_path, | 643 run_script_path = os.path.join(SRC_DIR, 'chrome', 'test', 'functional') |
632 env=dict(os.environ.items()+{'pepper_ver':pepper_ver, | 644 buildbot_common.Run([sys.executable, 'nacl_sdk.py', |
633 'OUT_DIR':OUT_DIR}.items())) | 645 'nacl_sdk.NaClSDKTest.NaClSDKExamples'], cwd=run_script_path, |
| 646 env=env) |
634 | 647 |
635 # Archive on non-trybots. | 648 # Archive on non-trybots. |
636 buildername = os.environ.get('BUILDBOT_BUILDERNAME', '') | 649 if options.archive or buildbot_common.IsSDKBuilder(): |
637 if options.archive or '-sdk' in buildername: | |
638 buildbot_common.BuildStep('Archive build') | 650 buildbot_common.BuildStep('Archive build') |
639 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \ | 651 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \ |
640 build_utils.ChromeVersion() | 652 build_utils.ChromeVersion() |
641 buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile)) | 653 buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile)) |
642 | 654 |
643 if not skip_update: | 655 if not skip_update: |
644 # Only push up sdk_tools.tgz on the linux buildbot. | 656 # Only push up sdk_tools.tgz on the linux buildbot. |
645 if buildername == 'linux-sdk-multi': | 657 if builder_name == 'linux-sdk-multi': |
646 sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz') | 658 sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz') |
647 buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, | 659 buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, |
648 step_link=False) | 660 step_link=False) |
649 | 661 |
650 # generate "manifest snippet" for this archive. | 662 # generate "manifest snippet" for this archive. |
651 if not skip_test_updater: | 663 if not skip_test_updater: |
652 archive = bundle.GetArchive(manifest_util.GetHostOS()) | 664 archive = bundle.GetArchive(manifest_util.GetHostOS()) |
653 archive.url = 'https://commondatastorage.googleapis.com/' \ | 665 archive.url = 'https://commondatastorage.googleapis.com/' \ |
654 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( | 666 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( |
655 build_utils.ChromeVersion(), tarname) | 667 build_utils.ChromeVersion(), tarname) |
656 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') | 668 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') |
657 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: | 669 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: |
658 manifest_snippet_stream.write(bundle.GetDataAsString()) | 670 manifest_snippet_stream.write(bundle.GetDataAsString()) |
659 | 671 |
660 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, | 672 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, |
661 step_link=False) | 673 step_link=False) |
662 | 674 |
663 return 0 | 675 return 0 |
664 | 676 |
665 | 677 |
666 if __name__ == '__main__': | 678 if __name__ == '__main__': |
667 sys.exit(main(sys.argv)) | 679 sys.exit(main(sys.argv)) |
OLD | NEW |