def main(args):
    parser = optparse.OptionParser(usage='USAGE: %prog [options] <build_name>')
    parser.add_option('--buildbot',
                      default=False,
                      action='store_true',
                      help='Run as a buildbot.')
    parser.add_option('--trybot',
                      default=False,
                      action='store_true',
                      help='Run as a trybot.')
    parser.add_option('--test_toolchain',
                      dest='test_toolchains',
                      default=[],
                      action='append',
                      help='Append toolchain to test.')
    parser.add_option('--skip-toolchain-build',
                      dest='skip_toolchain_build',
                      default=False,
                      action='store_true',
                      help='Skip Toolchain Build.')

    options, arguments = parser.parse_args(args)
    if len(arguments) != 1:
        print 'Error - expected build_name arguments'
        return 1

    build_name, = arguments

    build_script = os.path.join(NACL_DIR, 'toolchain_build',
                                build_name + '.py')
    if not os.path.isfile(build_script):
        print 'Error - Unknown build script: %s' % build_script
        return 1

    if sys.platform == 'win32':
        print '@@@BUILD_STEP install mingw@@@'
        sys.stdout.flush()
        subprocess.check_call(
            [os.path.join(NACL_DIR, 'buildbot', 'mingw_env.bat')])

    print '@@@BUILD_STEP run_pynacl_tests.py@@@'
    sys.stdout.flush()
    subprocess.check_call([
        sys.executable,
        os.path.join(NACL_DIR, 'pynacl', 'run_pynacl_tests.py')
    ])

    bot_arg = ['--bot']
    if options.buildbot:
        bot_arg.append('--buildbot')
    elif options.trybot:
        bot_arg.append('--trybot')

    # Toolchain build emits its own annotator stages.
    sys.stdout.flush()
    if not options.skip_toolchain_build:
        subprocess.check_call([sys.executable, build_script] + bot_arg +
                              ['--packages-file', TEMP_PACKAGES_FILE])

    if options.buildbot or options.trybot:
        packages.UploadPackages(TEMP_PACKAGES_FILE, options.trybot)

    # Run toolchain tests for built toolchains
    for toolchain_name in options.test_toolchains:
        print '@@@BUILD_STEP test toolchains (%s)@@@' % toolchain_name
        sys.stdout.flush()
        test_options = TOOLCHAIN_TESTS.get(toolchain_name, None)
        if test_options is None:
            print 'Error - unknown toolchain to test with: %s' % toolchain_name
            return 1

        # Extract the toolchain into a temporary directory.
        subprocess.check_call([
            sys.executable, PKG_VER, '--packages', toolchain_name, '--tar-dir',
            TOOLCHAIN_BUILD_PACKAGES, '--dest-dir', TEMP_TOOLCHAIN_DIR,
            'extract', '--skip-missing'
        ])

        toolchain_dir = os.path.join(
            TEMP_TOOLCHAIN_DIR,
            '%s_%s' % (pynacl.platform.GetOS(), pynacl.platform.GetArch()),
            toolchain_name)

        # Use buildbot_standard to run all the scons tests for each test option.
        for mode, arch, clib in test_options:
            if toolchain_name.startswith('nacl_'):
                scons_toolchain_arg = 'nacl_%s_dir' % clib
            elif toolchain_name.startswith('pnacl_'):
                scons_toolchain_arg = 'pnacl_%s_dir' % clib
            else:
                print 'Error - Could not figure out toolchain type: %s' % toolchain_name
                return 1

            subprocess.check_call([
                sys.executable, BUILDBOT_STANDARD,
                '--step-suffix= [%s %s]' % (toolchain_name, mode),
                '--scons-args',
                '%s=%s' % (scons_toolchain_arg, toolchain_dir), mode, arch,
                clib
            ])

    return 0
Пример #2
0
        gsd_arg = ['--buildbot']
    elif args.trybot:
        gsd_arg = ['--trybot']

    cmd = ToolchainBuildCmd(
        cygwin_python if host_os == 'win' else None,
        host_os != 'win',  # On Windows, we synced already
        gsd_arg + ['--packages-file', TEMP_PACKAGES_FILE])
    logging.info('Running: ' + ' '.join(cmd))
    subprocess.check_call(cmd)

    if args.buildbot or args.trybot:
        # Don't upload packages from the 32-bit linux bot to avoid racing on
        # uploading the same packages as the 64-bit linux bot
        if host_os != 'linux' or pynacl.platform.IsArch64Bit():
            packages.UploadPackages(TEMP_PACKAGES_FILE, args.trybot)

except subprocess.CalledProcessError:
    # Ignore any failures and keep going (but make the bot stage red).
    print '@@@STEP_FAILURE@@@'
sys.stdout.flush()

# Since mac and windows bots don't build target libraries or run tests yet,
# Run a basic sanity check that tests the host components (LLVM, binutils,
# gold plugin)
if host_os == 'win' or host_os == 'mac':
    with buildbot_lib.Step('Test host binaries and gold plugin',
                           status,
                           halt_on_fail=False):
        buildbot_lib.Command(context, [
            sys.executable,
# package_version tool.
# First build only the packages that will be uploaded, and upload them.
RunWithLog(ToolchainBuildCmd(sync=True, extra_flags=['--canonical-only']))

if use_goma:
  buildbot_lib.Command(context, cmd=[
      sys.executable, '/b/build/goma/goma_ctl.py', 'stop'])

if args.skip_tests:
  sys.exit(0)

if args.buildbot or args.trybot:
  # Don't upload packages from the 32-bit linux bot to avoid racing on
  # uploading the same packages as the 64-bit linux bot
  if host_os != 'linux' or pynacl.platform.IsArch64Bit():
    packages.UploadPackages(TEMP_PACKAGES_FILE, args.trybot, args.sanitize)

# Since windows bots don't build target libraries or run tests yet, Run a basic
# sanity check that tests the host components (LLVM, binutils, gold plugin).
# Then exit, since the rest of this file is just test running.
# For now full test coverage is only achieved on the main waterfall bots.
if host_os == 'win':
  packages.ExtractPackages(TEMP_PACKAGES_FILE, overlay_packages=False)
  with buildbot_lib.Step('Test host binaries and gold plugin', status,
                         halt_on_fail=False):
    buildbot_lib.Command(
        context,
        [sys.executable,
        os.path.join('tests', 'gold_plugin', 'gold_plugin_test.py'),
        '--toolchaindir', toolchain_install_dir])
else:
Пример #4
0
TEMP_PACKAGES_FILE = os.path.join(TOOLCHAIN_BUILD_OUT_DIR, 'packages.txt')

build_name = sys.argv[1]
bot_type = sys.argv[2]

build_script = os.path.join(NACL_DIR, 'toolchain_build', build_name + '.py')
if not os.path.isfile(build_script):
    print 'Error - Unknown build script: %s' % build_script
    sys.exit(1)

if sys.platform == 'win32':
    print '@@@BUILD_STEP install mingw@@@'
    sys.stdout.flush()
    subprocess.check_call(
        [os.path.join(NACL_DIR, 'buildbot', 'mingw_env.bat')])

print '@@@BUILD_STEP run_pynacl_tests.py@@@'
sys.stdout.flush()
subprocess.check_call(
    [sys.executable,
     os.path.join(NACL_DIR, 'pynacl', 'run_pynacl_tests.py')])

# Toolchain build emits its own annotator stages.
sys.stdout.flush()
subprocess.check_call(
    [sys.executable, build_script, '--packages-file', TEMP_PACKAGES_FILE] +
    sys.argv[2:])

if bot_type == '--buildbot' or bot_type == '--trybot':
    packages.UploadPackages(TEMP_PACKAGES_FILE, bot_type == '--trybot')