def main(args):
    parser = optparse.OptionParser()
    parser.add_option('--copy',
                      help='Only copy the files, don\'t build.',
                      action='store_true')
    parser.add_option(
        '--clobber-examples',
        help='Don\'t examples directory before copying new files',
        action='store_true')
    parser.add_option('--test-examples',
                      help='Run the pyauto tests for examples.',
                      action='store_true')
    parser.add_option('--experimental',
                      help='build experimental examples and libraries',
                      action='store_true')
    parser.add_option(
        '-t',
        '--toolchain',
        help='Build using toolchain. Can be passed more than once.',
        action='append')
    parser.add_option('--gyp',
                      help='Use gyp to build examples/libraries/Makefiles.',
                      action='store_true')

    options, args = parser.parse_args(args[1:])

    valid_toolchains = ['newlib', 'glibc', 'pnacl', 'host']
    if not options.toolchain:
        toolchains = valid_toolchains
    else:
        invalid_toolchains = set(options.toolchain) - set(valid_toolchains)
        if invalid_toolchains:
            print 'Ignoring invalid toolchains: %s' % (
                ', '.join(invalid_toolchains), )
        toolchains = list(set(options.toolchain) - invalid_toolchains)

    pepper_ver = str(int(build_utils.ChromeMajorVersion()))
    pepperdir = os.path.join(build_sdk.OUT_DIR, 'pepper_' + pepper_ver)
    platform = getos.GetPlatform()

    build_sdk.options = options

    build_sdk.BuildStepCopyBuildHelpers(pepperdir, platform)
    build_sdk.BuildStepCopyExamples(pepperdir, toolchains,
                                    options.experimental,
                                    options.clobber_examples)
    test_sdk.BuildStepCopyTests(pepperdir, toolchains, options.experimental,
                                options.clobber_examples)
    if options.copy:
        return 0

    # False = don't clean after building the libraries directory.
    build_sdk.BuildStepBuildLibraries(pepperdir, platform, 'src', False)
    test_sdk.BuildStepBuildExamples(pepperdir, platform)
    test_sdk.BuildStepBuildTests(pepperdir, platform)
    if options.test_examples:
        test_sdk.BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)

    return 0
Beispiel #2
0
def main(args):
  parser = optparse.OptionParser()
  parser.add_option('--experimental', help='build experimental tests',
                    action='store_true')
  parser.add_option('--pyauto', help='Run pyauto tests', action='store_true')

  options, args = parser.parse_args(args[1:])

  platform = getos.GetPlatform()
  pepper_ver = str(int(build_utils.ChromeMajorVersion()))
  pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
  toolchains = ['newlib', 'glibc', 'pnacl', 'host']

  BuildStepBuildToolsTests()
  BuildStepBuildExamples(pepperdir, platform)
  BuildStepCopyTests(pepperdir, toolchains, options.experimental, True)
  BuildStepBuildTests(pepperdir, platform)
  if options.pyauto:
    BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)

  return 0
Beispiel #3
0
def main(args):
  args = args[1:]

  buildbot_revision = os.environ.get('BUILDBOT_REVISION', '')
  buildername = os.environ.get('BUILDBOT_BUILDERNAME', '')

  os.chdir(SCRIPT_DIR)

  if buildername == 'linux-sdk-mono32':
    assert buildbot_revision
    sdk_revision = buildbot_revision.split(':')[0]
    pepper_revision = build_utils.ChromeMajorVersion()
    build_and_upload_mono(sdk_revision, pepper_revision, None,
                          'trunk.' + sdk_revision, args)
  elif buildername == 'linux-sdk-mono64':
    infos = get_sdk_build_info()
    for info in infos:
      # This will put the file in naclmono_19/1/naclmono_19.bz2 for example.
      upload_path = info['naclmono_name'] + '/' + info['naclmono_rev']
      build_and_upload_mono(None, info['pepper_revision'], info['sdk_url'],
          upload_path, args)
    update_mono_sdk_json(infos)
Beispiel #4
0
def main(args):
    args = args[1:]

    buildbot_revision = os.environ.get('BUILDBOT_REVISION', '')
    assert buildbot_revision
    sdk_revision = buildbot_revision.split(':')[0]
    pepper_revision = build_utils.ChromeMajorVersion()

    install_dir = 'naclmono'
    buildbot_common.RemoveDir(install_dir)

    buildbot_common.Run([
        sys.executable, 'nacl-mono-builder.py', '--arch', 'x86-32',
        '--install-dir', install_dir
    ] + args)
    buildbot_common.Run([
        sys.executable, 'nacl-mono-builder.py', '--arch', 'x86-64',
        '--install-dir', install_dir
    ] + args)
    buildbot_common.Run([
        sys.executable, 'nacl-mono-archive.py', '--sdk-revision', sdk_revision,
        '--pepper-revision', pepper_revision, '--install-dir', install_dir
    ] + args)
Beispiel #5
0
def main(args):
    parser = optparse.OptionParser()
    _, args = parser.parse_args(args[1:])

    toolchains = ['newlib', 'glibc']

    pepper_ver = str(int(build_utils.ChromeMajorVersion()))
    pepperdir = os.path.join(build_sdk.OUT_DIR, 'pepper_' + pepper_ver)
    app_dir = os.path.join(build_sdk.OUT_DIR, 'naclsdk_app')
    app_examples_dir = os.path.join(app_dir, 'examples')
    sdk_resources_dir = os.path.join(build_sdk.SDK_EXAMPLE_DIR, 'resources')
    platform = getos.GetPlatform()

    buildbot_common.RemoveDir(app_dir)
    buildbot_common.MakeDir(app_dir)
    GenerateMake(app_dir, toolchains)

    easy_template.RunTemplateFile(
        os.path.join(sdk_resources_dir, 'manifest.json.template'),
        os.path.join(app_examples_dir, 'manifest.json'),
        {'version': build_utils.ChromeVersionNoTrunk()})
    for filename in ['background.js', 'icon128.png']:
        buildbot_common.CopyFile(os.path.join(sdk_resources_dir, filename),
                                 os.path.join(app_examples_dir, filename))

    os.environ['NACL_SDK_ROOT'] = pepperdir
    build_sdk.BuildStepMakeAll(app_dir, platform, 'examples', 'Build Examples',
                               False, False, 'Release')

    RemoveBuildCruft(app_dir)
    StripNexes(app_dir, platform, pepperdir)

    app_zip = os.path.join(app_dir, 'examples.zip')
    os.chdir(app_examples_dir)
    oshelpers.Zip([app_zip, '-r', '*'])

    return 0
Beispiel #6
0
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('--pnacl',
                      help='Enable pnacl build.',
                      action='store_true',
                      dest='pnacl',
                      default=False)
    parser.add_option('--examples',
                      help='Rebuild the examples.',
                      action='store_true',
                      dest='examples',
                      default=False)
    parser.add_option('--update',
                      help='Rebuild the updater.',
                      action='store_true',
                      dest='update',
                      default=False)
    parser.add_option('--skip-tar',
                      help='Skip generating a tarball.',
                      action='store_true',
                      dest='skip_tar',
                      default=False)
    parser.add_option('--archive',
                      help='Force the archive step.',
                      action='store_true',
                      dest='archive',
                      default=False)
    parser.add_option('--release',
                      help='PPAPI release version.',
                      dest='release',
                      default=None)

    options, args = parser.parse_args(args[1:])
    platform = getos.GetPlatform()
    arch = 'x86'

    builder_name = os.getenv('BUILDBOT_BUILDERNAME', '')
    if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0:
        options.pnacl = True

    if options.pnacl:
        toolchains = ['pnacl']
    else:
        toolchains = ['newlib', 'glibc']
    print 'Building: ' + ' '.join(toolchains)
    skip = options.examples or options.update

    skip_examples = skip
    skip_update = skip
    skip_untar = skip
    skip_build = skip
    skip_tar = skip or options.skip_tar

    if options.examples: skip_examples = False
    skip_update = not options.update

    if options.archive and (options.examples or options.skip_tar):
        parser.error('Incompatible arguments with archive.')

    pepper_ver = str(int(build_utils.ChromeMajorVersion()))
    clnumber = lastchange.FetchVersionInfo(None).revision
    if options.release:
        pepper_ver = options.release
    print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)

    if not skip_build:
        buildbot_common.BuildStep('Rerun hooks to get toolchains')
        buildbot_common.Run(['gclient', 'runhooks'],
                            cwd=SRC_DIR,
                            shell=(platform == 'win'))

    buildbot_common.BuildStep('Clean Pepper Dir')
    pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
    if not skip_untar:
        buildbot_common.RemoveDir(pepperdir)
        buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain'))
        buildbot_common.MakeDir(os.path.join(pepperdir, 'tools'))

    buildbot_common.BuildStep('Add Text Files')
    files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE', 'README']
    files = [os.path.join(SDK_SRC_DIR, filename) for filename in files]
    oshelpers.Copy(['-v'] + files + [pepperdir])

    # Clean out the temporary toolchain untar directory
    if not skip_untar:
        UntarToolchains(pepperdir, platform, arch, toolchains)

    if not skip_build:
        BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)

    buildbot_common.BuildStep('Copy make OS helpers')
    buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
                            os.path.join(pepperdir, 'tools'))
    if platform == 'win':
        buildbot_common.BuildStep('Add MAKE')
        http_download.HttpDownload(
            GSTORE + MAKE, os.path.join(pepperdir, 'tools', 'make.exe'))

    if not skip_examples:
        CopyExamples(pepperdir, toolchains)

    if not skip_tar:
        buildbot_common.BuildStep('Tar Pepper Bundle')
        tarname = 'naclsdk_' + platform + '.bz2'
        if 'pnacl' in toolchains:
            tarname = 'p' + tarname
        tarfile = os.path.join(OUT_DIR, tarname)
        buildbot_common.Run([
            sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
            'pepper_' + pepper_ver
        ],
                            cwd=NACL_DIR)

    # Archive on non-trybots.
    if options.archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''):
        buildbot_common.BuildStep('Archive build')
        buildbot_common.Archive(
            tarname, 'nativeclient-mirror/nacl/nacl_sdk/%s' %
            build_utils.ChromeVersion(), OUT_DIR)

    if not skip_examples:
        buildbot_common.BuildStep('Test Build Examples')
        filelist = os.listdir(os.path.join(pepperdir, 'examples'))
        for filenode in filelist:
            dirnode = os.path.join(pepperdir, 'examples', filenode)
            makefile = os.path.join(dirnode, 'Makefile')
            if os.path.isfile(makefile):
                print "\n\nMake: " + dirnode
                buildbot_common.Run(['make', 'all', '-j8'],
                                    cwd=os.path.abspath(dirnode),
                                    shell=True)


# Build SDK Tools
    if not skip_update:
        BuildUpdater()

    return 0
def main(args):
  parser = optparse.OptionParser()
  parser.add_option('--examples', help='Only build the examples.',
      action='store_true', dest='only_examples', default=False)
  parser.add_option('--clobber-examples',
      help='Don\'t examples directory before copying new files',
      action='store_true', dest='clobber_examples', default=False)
  parser.add_option('--update', help='Only build the updater.',
      action='store_true', dest='only_updater', default=False)
  parser.add_option('--test-examples',
      help='Run the pyauto tests for examples.', action='store_true',
      dest='test_examples', default=False)
  parser.add_option('--skip-tar', help='Skip generating a tarball.',
      action='store_true', dest='skip_tar', default=False)
  parser.add_option('--archive', help='Force the archive step.',
      action='store_true', dest='archive', default=False)
  parser.add_option('--gyp',
      help='Use gyp to build examples/libraries/Makefiles.',
      action='store_true')
  parser.add_option('--release', help='PPAPI release version.',
      dest='release', default=None)
  parser.add_option('--experimental',
      help='build experimental examples and libraries', action='store_true',
      dest='build_experimental', default=False)
  parser.add_option('--skip-toolchain', help='Skip toolchain download/untar',
      action='store_true', dest='skip_toolchain', default=False)

  global options
  options, args = parser.parse_args(args[1:])
  platform = getos.GetPlatform()
  arch = 'x86'

  generate_make.use_gyp = options.gyp

  # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
  # pyauto Chrome.
  if buildbot_common.IsSDKBuilder():
    options.test_examples = True

  toolchains = ['newlib', 'glibc', 'pnacl', 'host']
  print 'Building: ' + ' '.join(toolchains)

  if options.archive and (options.only_examples or options.skip_tar):
    parser.error('Incompatible arguments with archive.')

  pepper_ver = str(int(build_utils.ChromeMajorVersion()))
  pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
  pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
  pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
  clnumber = build_utils.ChromeRevision()
  tarname = 'naclsdk_' + platform + '.tar.bz2'
  tarfile = os.path.join(SERVER_DIR, tarname)

  if options.release:
    pepper_ver = options.release
  print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)

  if options.only_examples:
    BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental,
                          options.clobber_examples)
    BuildStepBuildLibraries(pepperdir, platform, 'src', False)  # Don't clean.
    BuildStepBuildExamples(pepperdir, platform)
    BuildStepCopyTests(pepperdir, toolchains, options.build_experimental,
                       options.clobber_examples)
    BuildStepBuildTests(pepperdir, platform)
    if options.test_examples:
      BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)
  elif options.only_updater:
    build_updater.BuildUpdater(OUT_DIR)
  else:  # Build everything.
    BuildStepBuildToolsTests()

    if not options.skip_toolchain:
      BuildStepDownloadToolchains(platform)
    BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
    BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
    BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
    if not options.skip_toolchain:
      BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
    BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
    InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
    BuildStepCopyBuildHelpers(pepperdir, platform)
    BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental,
                          True)

    # Ship with libraries prebuilt, so run that first.
    BuildStepBuildLibraries(pepperdir, platform, 'src')
    BuildStepGenerateNotice(pepperdir)

    if not options.skip_tar:
      BuildStepTarBundle(pepper_ver, tarfile)
      build_updater.BuildUpdater(OUT_DIR)

      # BuildStepTestUpdater downloads the bundle to its own directory. Build
      # the examples and test from this directory instead of the original.
      pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile)
      BuildStepBuildExamples(pepperdir, platform)
      BuildStepCopyTests(pepperdir, toolchains, options.build_experimental,
                         True)
      BuildStepBuildTests(pepperdir, platform)
      if options.test_examples:
        BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)

      # Archive on non-trybots.
      if options.archive or buildbot_common.IsSDKBuilder():
        BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
        BuildStepArchiveSDKTools()

  return 0
Beispiel #8
0
def main(args):
  parser = optparse.OptionParser()
  parser.add_option('--run-tests',
      help='Run tests. This includes building examples.', action='store_true')
  parser.add_option('--run-pyauto-tests',
      help='Run the pyauto tests for examples.', action='store_true')
  parser.add_option('--skip-tar', help='Skip generating a tarball.',
      action='store_true')
  parser.add_option('--archive', help='Force the archive step.',
      action='store_true')
  parser.add_option('--gyp',
      help='Use gyp to build examples/libraries/Makefiles.',
      action='store_true')
  parser.add_option('--release', help='PPAPI release version.',
      dest='release', default=None)
  parser.add_option('--experimental',
      help='build experimental examples and libraries', action='store_true',
      dest='build_experimental')
  parser.add_option('--skip-toolchain', help='Skip toolchain untar',
      action='store_true')
  parser.add_option('--mac_sdk',
      help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.',
      dest='mac_sdk')

  global options
  options, args = parser.parse_args(args[1:])
  platform = getos.GetPlatform()
  arch = 'x86'

  generate_make.use_gyp = options.gyp

  # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
  # pyauto Chrome.
  if buildbot_common.IsSDKBuilder():
    options.run_tests = True
    options.run_pyauto_tests = True
    options.archive = True

  if buildbot_common.IsSDKTrybot():
    options.run_tests = True

  toolchains = ['newlib', 'glibc', 'arm', 'pnacl', 'host']
  print 'Building: ' + ' '.join(toolchains)

  if options.archive and options.skip_tar:
    parser.error('Incompatible arguments with archive.')

  pepper_ver = str(int(build_utils.ChromeMajorVersion()))
  pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
  pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
  pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
  clnumber = build_utils.ChromeRevision()
  tarname = 'naclsdk_' + platform + '.tar.bz2'
  tarfile = os.path.join(OUT_DIR, tarname)

  if options.release:
    pepper_ver = options.release
  print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)

  if 'NACL_SDK_ROOT' in os.environ:
    # We don't want the currently configured NACL_SDK_ROOT to have any effect
    # of the build.
    del os.environ['NACL_SDK_ROOT']

  BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
  BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])

  if not options.skip_toolchain:
    BuildStepDownloadToolchains(platform)
    BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)

  BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
  BuildStepBuildToolchains(pepperdir, platform, pepper_ver, toolchains)
  InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
  BuildStepCopyBuildHelpers(pepperdir, platform)
  BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True)

  # Ship with libraries prebuilt, so run that first.
  BuildStepBuildLibraries(pepperdir, platform, 'src')
  BuildStepGenerateNotice(pepperdir)

  if not options.skip_tar:
    BuildStepTarBundle(pepper_ver, tarfile)

  if options.run_tests:
    BuildStepRunTests()

  # Archive on non-trybots.
  if options.archive:
    BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
    BuildStepArchiveSDKTools()

  return 0
Beispiel #9
0
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('--pnacl',
                      help='Enable pnacl build.',
                      action='store_true',
                      dest='pnacl',
                      default=False)
    parser.add_option('--examples',
                      help='Only build the examples.',
                      action='store_true',
                      dest='only_examples',
                      default=False)
    parser.add_option('--update',
                      help='Only build the updater.',
                      action='store_true',
                      dest='only_updater',
                      default=False)
    parser.add_option('--skip-tar',
                      help='Skip generating a tarball.',
                      action='store_true',
                      dest='skip_tar',
                      default=False)
    parser.add_option('--archive',
                      help='Force the archive step.',
                      action='store_true',
                      dest='archive',
                      default=False)
    parser.add_option('--release',
                      help='PPAPI release version.',
                      dest='release',
                      default=None)

    options, args = parser.parse_args(args[1:])
    platform = getos.GetPlatform()
    arch = 'x86'

    builder_name = os.getenv('BUILDBOT_BUILDERNAME', '')
    if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0:
        options.pnacl = True

    if options.pnacl:
        toolchains = ['pnacl']
    else:
        toolchains = ['newlib', 'glibc']
    print 'Building: ' + ' '.join(toolchains)
    skip = options.only_examples or options.only_updater

    skip_examples = skip and not options.only_examples
    skip_update = skip and not options.only_updater
    skip_untar = skip
    skip_build = skip
    skip_test_updater = skip
    skip_tar = skip or options.skip_tar

    if options.archive and (options.only_examples or options.skip_tar):
        parser.error('Incompatible arguments with archive.')

    pepper_ver = str(int(build_utils.ChromeMajorVersion()))
    pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
    clnumber = build_utils.ChromeRevision()
    if options.release:
        pepper_ver = options.release
    print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)

    if not skip_build:
        buildbot_common.BuildStep('Rerun hooks to get toolchains')
        buildbot_common.Run(['gclient', 'runhooks'],
                            cwd=SRC_DIR,
                            shell=(platform == 'win'))

    buildbot_common.BuildStep('Clean Pepper Dirs')
    pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
    pepperold = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
    buildbot_common.RemoveDir(pepperold)
    if not skip_untar:
        buildbot_common.RemoveDir(pepperdir)
        buildbot_common.MakeDir(os.path.join(pepperdir, 'libraries'))
        buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain'))
        buildbot_common.MakeDir(os.path.join(pepperdir, 'tools'))
    else:
        buildbot_common.MakeDir(pepperdir)

    if not skip_build:
        buildbot_common.BuildStep('Add Text Files')
        files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE', 'README']
        files = [os.path.join(SDK_SRC_DIR, filename) for filename in files]
        oshelpers.Copy(['-v'] + files + [pepperdir])

    # Clean out the temporary toolchain untar directory
    if not skip_untar:
        UntarToolchains(pepperdir, platform, arch, toolchains)

    if not skip_build:
        BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
        InstallHeaders(os.path.join(pepperdir, 'libraries'), pepper_ver,
                       'libs')

    if not skip_build:
        buildbot_common.BuildStep('Copy make OS helpers')
        buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
                                os.path.join(pepperdir, 'tools'))
        if platform == 'win':
            buildbot_common.BuildStep('Add MAKE')
            http_download.HttpDownload(
                GSTORE + MAKE, os.path.join(pepperdir, 'tools', 'make.exe'))
            rename_list = [
                'ncval_x86_32', 'ncval_x86_64', 'sel_ldr_x86_32',
                'sel_ldr_x86_64'
            ]
            tools = os.path.join(pepperdir, 'tools')
            for name in rename_list:
                src = os.path.join(pepperdir, 'tools', name)
                dst = os.path.join(pepperdir, 'tools', name + '.exe')
                buildbot_common.Move(src, dst)

    if not skip_examples:
        CopyExamples(pepperdir, toolchains)

    tarname = 'naclsdk_' + platform + '.bz2'
    if 'pnacl' in toolchains:
        tarname = 'p' + tarname
    tarfile = os.path.join(OUT_DIR, tarname)

    if not skip_tar:
        buildbot_common.BuildStep('Tar Pepper Bundle')
        buildbot_common.Run([
            sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
            'pepper_' + pepper_ver
        ],
                            cwd=NACL_DIR)

    # Run build tests
    buildbot_common.BuildStep('Run build_tools tests')
    buildbot_common.Run([
        sys.executable,
        os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')
    ])

    # build sdk update
    if not skip_update:
        build_updater.BuildUpdater(OUT_DIR)

    # start local server sharing a manifest + the new bundle
    if not skip_test_updater and not skip_tar:
        buildbot_common.BuildStep('Move bundle to localserver dir')
        buildbot_common.MakeDir(SERVER_DIR)
        buildbot_common.Move(tarfile, SERVER_DIR)
        tarfile = os.path.join(SERVER_DIR, tarname)

        server = None
        try:
            buildbot_common.BuildStep('Run local server')
            server = test_server.LocalHTTPServer(SERVER_DIR)

            buildbot_common.BuildStep('Generate manifest')
            with open(tarfile, 'rb') as tarfile_stream:
                archive_sha1, archive_size = manifest_util.DownloadAndComputeHash(
                    tarfile_stream)
            archive = manifest_util.Archive(manifest_util.GetHostOS())
            archive.CopyFrom({
                'url': server.GetURL(tarname),
                'size': archive_size,
                'checksum': {
                    'sha1': archive_sha1
                }
            })
            bundle = manifest_util.Bundle('pepper_' + pepper_ver)
            bundle.CopyFrom({
                'revision':
                int(clnumber),
                'repath':
                'pepper_' + pepper_ver,
                'version':
                int(pepper_ver),
                'description':
                'Chrome %s bundle, revision %s' % (pepper_ver, clnumber),
                'stability':
                'dev',
                'recommended':
                'no',
                'archives': [archive]
            })
            manifest = manifest_util.SDKManifest()
            manifest.SetBundle(bundle)
            manifest_name = 'naclsdk_manifest2.json'
            with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \
                manifest_stream:
                manifest_stream.write(manifest.GetDataAsString())

            # use newly built sdk updater to pull this bundle
            buildbot_common.BuildStep('Update from local server')
            naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk')
            if platform == 'win':
                naclsdk_sh += '.bat'
            buildbot_common.Run([
                naclsdk_sh, '-U',
                server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver
            ])

            # If we are testing examples, do it in the newly pulled directory.
            pepperdir = os.path.join(OUT_DIR, 'nacl_sdk',
                                     'pepper_' + pepper_ver)

        # kill server
        finally:
            if server:
                server.Shutdown()

    # build examples.
    if not skip_examples:
        buildbot_common.BuildStep('Test Build Examples')
        example_dir = os.path.join(pepperdir, 'examples')
        makefile = os.path.join(example_dir, 'Makefile')
        if os.path.isfile(makefile):
            print "\n\nMake: " + example_dir
            buildbot_common.Run(['make', '-j8'],
                                cwd=os.path.abspath(example_dir),
                                shell=True)

    # Archive on non-trybots.
    buildername = os.environ.get('BUILDBOT_BUILDERNAME', '')
    if options.archive or '-sdk' in buildername:
        buildbot_common.BuildStep('Archive build')
        bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \
            build_utils.ChromeVersion()
        buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile))

        if not skip_update:
            # Only push up sdk_tools.tgz on the linux buildbot.
            if buildername == 'linux-sdk-multi':
                sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz')
                buildbot_common.Archive('sdk_tools.tgz',
                                        bucket_path,
                                        OUT_DIR,
                                        step_link=False)

        # generate "manifest snippet" for this archive.
        if not skip_test_updater:
            archive = bundle.GetArchive(manifest_util.GetHostOS())
            archive.url = 'https://commondatastorage.googleapis.com/' \
                'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % (
                    build_utils.ChromeVersion(), tarname)
            manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json')
            with open(manifest_snippet_file, 'wb') as manifest_snippet_stream:
                manifest_snippet_stream.write(bundle.GetDataAsString())

            buildbot_common.Archive(tarname + '.json',
                                    bucket_path,
                                    OUT_DIR,
                                    step_link=False)

    return 0