Esempio n. 1
0
def CopyExamples(pepperdir, toolchains):
    buildbot_common.BuildStep('Copy examples')

    if not os.path.exists(os.path.join(pepperdir, 'tools')):
        buildbot_common.ErrorExit('Examples depend on missing tools.')
    if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
        buildbot_common.ErrorExit('Examples depend on missing toolchains.')

    exampledir = os.path.join(pepperdir, 'examples')
    buildbot_common.RemoveDir(exampledir)
    buildbot_common.MakeDir(exampledir)
    AddMakeBat(pepperdir, exampledir)

    # Copy individual files
    files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html', 'Makefile']
    for filename in files:
        oshelpers.Copy(
            ['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])

    # Add examples for supported toolchains
    examples = []
    for tc in toolchains:
        examples.extend(EXAMPLE_MAP[tc])
    for example in examples:
        buildbot_common.CopyDir(os.path.join(SDK_EXAMPLE_DIR, example),
                                exampledir)
        AddMakeBat(pepperdir, os.path.join(exampledir, example))
Esempio n. 2
0
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument('--install-dir',
                        help='Install Directory',
                        dest='install_dir',
                        default='naclmono')
    parser.add_argument('--tar-path',
                        help='Tarfile path',
                        dest='tar_path',
                        default='naclmono_%pepperrev%.bz2')
    parser.add_argument(
        '--upload-path',
        help='Upload path (nativeclient-mirror/nacl/nacl_sdk/XXX)',
        dest='upload_path',
        default=None)
    parser.add_argument('--pepper-revision',
                        help='Pepper revision',
                        dest='pepper_revision',
                        default=None)
    parser.add_argument('--skip-upload',
                        help='Skips upload step',
                        action="store_true",
                        dest='skip_upload')
    options = parser.parse_args(args)

    if not options.upload_path:
        buildbot_common.ErrorExit('--upload-path is required')
    if not options.pepper_revision:
        buildbot_common.ErrorExit('--pepper-revision is required')

    options.tar_path = options.tar_path.replace('%pepperrev%',
                                                options.pepper_revision)

    install_folders = [
        'bin', 'etc', 'include', 'lib', 'lib32', 'libarm', 'share'
    ]

    buildbot_common.BuildStep('Archive Build')
    tar_file = None
    buildbot_common.RemoveFile(options.tar_path)
    try:
        tar_file = tarfile.open(options.tar_path,
                                mode='w:bz2',
                                dereference=True)
        for subfolder in install_folders:
            tar_file.add(os.path.join(options.install_dir, subfolder),
                         arcname=subfolder)
    finally:
        if tar_file:
            tar_file.close()

    if not options.skip_upload:
        buildbot_common.Archive(
            os.path.basename(options.tar_path),
            'nativeclient-mirror/nacl/nacl_sdk/%s' % options.upload_path,
            cwd=os.path.dirname(os.path.abspath(options.tar_path)))
Esempio n. 3
0
def BuildStepCopyExamples(pepperdir, toolchains, build_experimental, clobber):
    buildbot_common.BuildStep('Copy examples')

    if not os.path.exists(os.path.join(pepperdir, 'tools')):
        buildbot_common.ErrorExit('Examples depend on missing tools.')
    if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
        buildbot_common.ErrorExit('Examples depend on missing toolchains.')

    exampledir = MakeDirectoryOrClobber(pepperdir, 'examples', clobber)
    libdir = MakeDirectoryOrClobber(pepperdir, 'lib', clobber)

    plat = getos.GetPlatform()
    for arch in LIB_DICT[plat]:
        buildbot_common.MakeDir(
            os.path.join(libdir, '%s_%s_host' % (plat, arch)))
        if options.gyp and plat != 'win':
            configs = ['debug', 'release']
        else:
            configs = ['Debug', 'Release']
        for config in configs:
            buildbot_common.MakeDir(
                os.path.join(libdir, '%s_%s_host' % (plat, arch), config))

    MakeDirectoryOrClobber(pepperdir, 'src', clobber)

    # Copy individual files
    files = ['favicon.ico', 'httpd.cmd']
    for filename in files:
        oshelpers.Copy(
            ['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])

    args = ['--dstroot=%s' % pepperdir, '--master']
    for toolchain in toolchains:
        if toolchain != 'arm':
            args.append('--' + toolchain)

    for example in EXAMPLE_LIST:
        dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
        args.append(dsc)

    for library in LIBRARY_LIST:
        dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
        args.append(dsc)

    if build_experimental:
        args.append('--experimental')

    print "Generting Makefiles: %s" % str(args)
    if generate_make.main(args):
        buildbot_common.ErrorExit('Failed to build examples.')
Esempio n. 4
0
def UpdateHelpers(pepperdir, clobber=False):
  tools_dir = os.path.join(pepperdir, 'tools')
  if not os.path.exists(tools_dir):
    buildbot_common.ErrorExit('SDK tools dir is missing: %s' % tools_dir)

  exampledir = os.path.join(pepperdir, 'examples')
  if clobber:
    buildbot_common.RemoveDir(exampledir)
  buildbot_common.MakeDir(exampledir)

  # Copy files for individual build and landing page
  files = ['favicon.ico', 'httpd.cmd', 'index.css', 'index.js',
      'button_close.png', 'button_close_hover.png']
  CopyFilesFromTo(files, SDK_RESOURCE_DIR, exampledir)

  # Copy tools scripts and make includes
  buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
      tools_dir)
  buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.mk'),
      tools_dir)

  # Copy tools/lib scripts
  tools_lib_dir = os.path.join(pepperdir, 'tools', 'lib')
  buildbot_common.MakeDir(tools_lib_dir)
  buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', 'lib', '*.py'),
      tools_lib_dir)

  # On Windows add a prebuilt make
  if getos.GetPlatform() == 'win':
    buildbot_common.BuildStep('Add MAKE')
    make_url = posixpath.join(GSTORE, MAKE)
    make_exe = os.path.join(tools_dir, 'make.exe')
    with open(make_exe, 'wb') as f:
      f.write(urllib2.urlopen(make_url).read())
def UpdateHelpers(pepperdir, clobber=False):
  tools_dir = os.path.join(pepperdir, 'tools')
  if not os.path.exists(tools_dir):
    buildbot_common.ErrorExit('SDK tools dir is missing: %s' % tools_dir)

  exampledir = os.path.join(pepperdir, 'examples')
  if clobber:
    buildbot_common.RemoveDir(exampledir)
  buildbot_common.MakeDir(exampledir)

  # Copy files for individual build and landing page
  files = ['favicon.ico', 'httpd.cmd', 'index.css', 'index.js',
      'button_close.png', 'button_close_hover.png']
  CopyFilesFromTo(files, SDK_RESOURCE_DIR, exampledir)

  # Copy tools scripts and make includes
  buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
      tools_dir)
  buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.mk'),
      tools_dir)

  # On Windows add a prebuilt make
  if getos.GetPlatform() == 'win':
    buildbot_common.BuildStep('Add MAKE')
    http_download.HttpDownload(GSTORE + MAKE,
                               os.path.join(tools_dir, 'make.exe'))
Esempio n. 6
0
def GetToolchainNaClInclude(tcname, tcpath, arch, xarch=None):
    if arch == 'x86':
        if tcname == 'pnacl':
            return os.path.join(tcpath, 'newlib', 'sdk', 'include')
        return os.path.join(tcpath, 'x86_64-nacl', 'include')
    else:
        buildbot_common.ErrorExit('Unknown architecture.')
Esempio n. 7
0
def UpdateHelpers(pepperdir, platform, clobber=False):
    if not os.path.exists(os.path.join(pepperdir, 'tools')):
        buildbot_common.ErrorExit('Examples depend on missing tools.')

    exampledir = os.path.join(pepperdir, 'examples')
    if clobber:
        buildbot_common.RemoveDir(exampledir)
    buildbot_common.MakeDir(exampledir)

    # Copy files for individual bild and landing page
    files = ['favicon.ico', 'httpd.cmd']
    CopyFilesFromTo(files, SDK_EXAMPLE_DIR, exampledir)

    resourcesdir = os.path.join(SDK_EXAMPLE_DIR, 'resources')
    files = [
        'index.css', 'index.js', 'button_close.png', 'button_close_hover.png'
    ]
    CopyFilesFromTo(files, resourcesdir, exampledir)

    # Copy tools scripts and make includes
    buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
                            os.path.join(pepperdir, 'tools'))
    buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.mk'),
                            os.path.join(pepperdir, 'tools'))

    # On Windows add a prebuilt make
    if platform == 'win':
        buildbot_common.BuildStep('Add MAKE')
        http_download.HttpDownload(
            GSTORE + MAKE, os.path.join(pepperdir, 'tools', 'make.exe'))
Esempio n. 8
0
def GetProjectTree(include):
  # Everything in src is a library, and cannot be run.
  exclude = {'DEST': 'src'}
  try:
    return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include,
                                     exclude=exclude)
  except parse_dsc.ValidationError as e:
    buildbot_common.ErrorExit(str(e))
Esempio n. 9
0
def GetPNaClTranslatorLib(tcpath, arch):
    if arch not in ['arm', 'x86', 'x64']:
        buildbot_common.ErrorExit('Unknown architecture %s.' % arch)
    if arch == 'x86':
        arch = 'x86-32'
    elif arch == 'x64':
        arch = 'x86-64'
    return os.path.join(tcpath, 'translator', arch, 'lib')
Esempio n. 10
0
def BuildStepVerifyFilelist(pepperdir):
  buildbot_common.BuildStep('Verify SDK Files')
  file_list_path = os.path.join(SCRIPT_DIR, 'sdk_files.list')
  try:
    verify_filelist.Verify(file_list_path, pepperdir)
    print 'OK'
  except verify_filelist.ParseException, e:
    buildbot_common.ErrorExit('Parsing sdk_files.list failed:\n\n%s' % e)
Esempio n. 11
0
def CopyExamples(pepperdir, toolchains):
    buildbot_common.BuildStep('Copy examples')

    if not os.path.exists(os.path.join(pepperdir, 'tools')):
        buildbot_common.ErrorExit('Examples depend on missing tools.')
    if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
        buildbot_common.ErrorExit('Examples depend on missing toolchains.')

    exampledir = os.path.join(pepperdir, 'examples')
    buildbot_common.RemoveDir(exampledir)
    buildbot_common.MakeDir(exampledir)

    libdir = os.path.join(pepperdir, 'lib')
    buildbot_common.RemoveDir(libdir)
    buildbot_common.MakeDir(libdir)

    plat = getos.GetPlatform()
    for arch in LIB_DICT[plat]:
        buildbot_common.MakeDir(
            os.path.join(libdir, '%s_%s_host' % (plat, arch)))

    srcdir = os.path.join(pepperdir, 'src')
    buildbot_common.RemoveDir(srcdir)
    buildbot_common.MakeDir(srcdir)

    # Copy individual files
    files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html']
    for filename in files:
        oshelpers.Copy(
            ['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])

    args = ['--dstroot=%s' % pepperdir, '--master']
    for toolchain in toolchains:
        args.append('--' + toolchain)

    for example in EXAMPLE_LIST:
        dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
        args.append(dsc)

    for library in LIBRARY_LIST:
        dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
        args.append(dsc)

    if generate_make.main(args):
        buildbot_common.ErrorExit('Failed to build examples.')
Esempio n. 12
0
def GetToolchainNaClInclude(tcname, tcpath, arch):
  if arch == 'x86':
    if tcname == 'pnacl':
      return os.path.join(tcpath, 'sdk', 'include')
    return os.path.join(tcpath, 'x86_64-nacl', 'include')
  elif arch == 'arm':
    return os.path.join(tcpath, 'arm-nacl', 'include')
  else:
    buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
Esempio n. 13
0
def GetToolchainNaClLib(tcname, tcpath, arch, xarch):
    if arch == 'x86':
        if tcname == 'pnacl':
            return os.path.join(tcpath, 'newlib', 'sdk', 'lib')
        if str(xarch) == '32':
            return os.path.join(tcpath, 'x86_64-nacl', 'lib32')
        if str(xarch) == '64':
            return os.path.join(tcpath, 'x86_64-nacl', 'lib')
    buildbot_common.ErrorExit('Unknown architecture.')
Esempio n. 14
0
def BuildStepBuildToolchains(pepperdir, toolchains):
    buildbot_common.BuildStep('SDK Items')

    GypNinjaBuild_NaCl(GYPBUILD_DIR)
    GypNinjaBuild_Breakpad(GYPBUILD_DIR)

    platform = getos.GetPlatform()
    tcname = platform + '_x86'
    newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
    glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
    pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')

    if set(toolchains) & set(['glibc', 'newlib']):
        GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR)

    if 'arm' in toolchains:
        GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-arm')

    GypNinjaInstall(pepperdir, toolchains)

    if 'newlib' in toolchains:
        InstallNaClHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
                           'newlib')

    if 'glibc' in toolchains:
        InstallNaClHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
                           'glibc')

    if 'arm' in toolchains:
        tcname = platform + '_arm_newlib'
        armdir = os.path.join(pepperdir, 'toolchain', tcname)
        InstallNaClHeaders(GetToolchainNaClInclude('newlib', armdir, 'arm'),
                           'arm')

    if 'pnacl' in toolchains:
        # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default.
        for arch in ('ia32', 'arm'):
            # Fill in the latest native pnacl shim library from the chrome build.
            build_dir = GYPBUILD_DIR + '-pnacl-' + arch
            GypNinjaBuild_Pnacl(build_dir, arch)
            if arch == 'ia32':
                nacl_arches = ['x86-32', 'x86-64']
            elif arch == 'arm':
                nacl_arches = ['arm']
            else:
                buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
            for nacl_arch in nacl_arches:
                release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release',
                                                 'gen', 'tc_pnacl_translate',
                                                 'lib-' + nacl_arch)

                buildbot_common.CopyFile(
                    os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
                    GetPNaClNativeLib(pnacldir, nacl_arch))

        InstallNaClHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
                           'newlib')
Esempio n. 15
0
def BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains):
    buildbot_common.BuildStep('SDK Items')

    tcname = platform + '_' + arch
    newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
    glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
    pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')

    # Run scons TC build steps
    if arch == 'x86':
        if 'newlib' in toolchains:
            buildbot_common.Run(GetBuildArgs('newlib', newlibdir, pepperdir,
                                             'x86', '32'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            buildbot_common.Run(GetBuildArgs('newlib', newlibdir, pepperdir,
                                             'x86', '64'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
                           pepper_ver, 'newlib')

        if 'glibc' in toolchains:
            buildbot_common.Run(GetBuildArgs('glibc', glibcdir, pepperdir,
                                             'x86', '32'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            buildbot_common.Run(GetBuildArgs('glibc', glibcdir, pepperdir,
                                             'x86', '64'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
                           pepper_ver, 'glibc')

        if 'pnacl' in toolchains:
            buildbot_common.Run(GetBuildArgs('pnacl', pnacldir, pepperdir,
                                             'x86', '32'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            buildbot_common.Run(GetBuildArgs('pnacl', pnacldir, pepperdir,
                                             'x86', '64'),
                                cwd=NACL_DIR,
                                shell=(platform == 'win'))
            # Pnacl libraries are typically bitcode, but some are native and
            # will be looked up in the native library directory.
            buildbot_common.Move(
                os.path.join(
                    GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'),
                    'libpnacl_irt_shim.a'),
                GetPNaClNativeLib(pnacldir, 'x86-64'))
            InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
                           pepper_ver, 'newlib')
    else:
        buildbot_common.ErrorExit('Missing arch %s' % arch)
Esempio n. 16
0
def GetToolchainNaClInclude(pepperdir, tcname, arch=None):
    tcpath = GetToolchainDir(pepperdir, tcname)
    if arch is None:
        arch = TOOLCHAIN_PACKAGE_MAP[tcname][2]
    if arch == 'x86':
        return os.path.join(tcpath, 'x86_64-nacl', 'include')
    elif arch == 'pnacl':
        return os.path.join(tcpath, 'le32-nacl', 'include')
    elif arch == 'arm':
        return os.path.join(tcpath, 'arm-nacl', 'include')
    else:
        buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
Esempio n. 17
0
def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver,
                             toolchains):
  buildbot_common.BuildStep('SDK Items')

  tcname = platform + '_' + arch
  newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
  glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
  pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')

  # Run scons TC build steps
  if arch == 'x86':
    if set(toolchains) & set(['newlib', 'glibc']):
      GypNinjaBuild_X86(pepperdir, platform, toolchains)

    if 'newlib' in toolchains:
      InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
                     pepper_ver,
                     'newlib')

    if 'glibc' in toolchains:
      InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
                     pepper_ver,
                     'glibc')

    if 'pnacl' in toolchains:
      shell = platform == 'win'
      buildbot_common.Run(
          GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'),
          cwd=NACL_DIR, shell=shell)
      buildbot_common.Run(
          GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'),
          cwd=NACL_DIR, shell=shell)

      for arch in ('ia32', 'arm'):
        # Fill in the latest native pnacl shim library from the chrome build.
        GypNinjaBuild_Pnacl('gypbuild-' + arch, arch)
        release_build_dir = os.path.join(OUT_DIR, 'gypbuild-' + arch,
                                         'Release')

        pnacl_libdir_map = { 'ia32': 'x86-64', 'arm': 'arm' }
        buildbot_common.CopyFile(
            os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
            GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch]))

      InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
                     pepper_ver,
                     'newlib')
  else:
    buildbot_common.ErrorExit('Missing arch %s' % arch)
Esempio n. 18
0
def GenerateMake(outdir, toolchains):
    args = [
        '--dstroot=%s' % outdir, '--master', '--config=Release',
        '--first-valid-toolchain'
    ]
    for toolchain in toolchains:
        args.append('--' + toolchain)

    for example in EXAMPLE_LIST:
        dsc = os.path.join(build_sdk.SDK_EXAMPLE_DIR, example, 'example.dsc')
        args.append(dsc)

    print "Generating Makefiles: %s" % str(args)
    if generate_make.main(args):
        buildbot_common.ErrorExit('Failed to build examples.')
def GetBrowserTesterCommand(desc, toolchain, config):
    if browser_path is None:
        buildbot_common.ErrorExit(
            'Failed to find chrome browser using FindChrome.')

    args = [
        sys.executable,
        browser_tester_py,
        '--browser_path',
        browser_path,
        '--timeout',
        '30.0',  # seconds
        # Prevent the infobar that shows up when requesting filesystem quota.
        '--browser_flag',
        '--unlimited-storage',
        '--enable_sockets',
        # Prevent installing a new copy of PNaCl.
        '--browser_flag',
        '--disable-component-update',
    ]

    args.extend(['--serving_dir', GetServingDirForProject(desc)])
    # Fall back on the example directory in the Chromium repo, to find test.js.
    args.extend(['--serving_dir', GetRepoServingDirForProject(desc)])
    # If it is not found there, fall back on the dummy one (in this directory.)
    args.extend(['--serving_dir', SCRIPT_DIR])

    if toolchain == platform:
        exe_dir = GetExecutableDirForProject(desc, toolchain, config)
        ppapi_plugin = os.path.join(exe_dir, desc['NAME'])
        if platform == 'win':
            ppapi_plugin += '.dll'
        else:
            ppapi_plugin += '.so'
        args.extend(['--ppapi_plugin', ppapi_plugin])

        ppapi_plugin_mimetype = 'application/x-ppapi-%s' % config.lower()
        args.extend(['--ppapi_plugin_mimetype', ppapi_plugin_mimetype])

    if toolchain == 'pnacl':
        args.extend(['--browser_flag', '--enable-pnacl'])

    url = 'index.html'
    url += '?tc=%s&config=%s&test=true' % (toolchain, config)
    args.extend(['--url', url])
    return args
def StepRunBrowserTests(toolchains, experimental):
    buildbot_common.BuildStep('Run Tests')

    args = [
        sys.executable,
        os.path.join(SCRIPT_DIR, 'test_projects.py'),
    ]

    if experimental:
        args.append('-x')
    for toolchain in toolchains:
        args.extend(['-t', toolchain])

    try:
        subprocess.check_call(args)
    except subprocess.CalledProcessError:
        buildbot_common.ErrorExit('Error running tests.')
def InstallFiles(src_root, dest_root, file_list):
    """Copy a set of files from src_root to dest_root according
  to the given mapping.  This allows files to be copied from
  to a location in the destination tree that is different to the
  location in the source tree.

  If the destination mapping ends with a '/' then the destination
  basename is inherited from the the source file.

  Wildcards can be used in the source list but it is not recommended
  as this can end up adding things to the SDK unintentionally.
  """
    for file_spec in file_list:
        # The list of files to install can be a simple list of
        # strings or a list of pairs, where each pair corresponds
        # to a mapping from source to destination names.
        if type(file_spec) == str:
            src_file = dest_file = file_spec
        else:
            src_file, dest_file = file_spec

        src_file = os.path.join(src_root, src_file)

        # Expand sources files using glob.
        sources = glob.glob(src_file)
        if not sources:
            sources = [src_file]

        if len(sources) > 1 and not dest_file.endswith('/'):
            buildbot_common.ErrorExit(
                "Target file must end in '/' when "
                "using globbing to install multiple files")

        for source in sources:
            if dest_file.endswith('/'):
                dest = os.path.join(dest_file, os.path.basename(source))
            else:
                dest = dest_file
            dest = os.path.join(dest_root, dest)
            if not os.path.isdir(os.path.dirname(dest)):
                buildbot_common.MakeDir(os.path.dirname(dest))
            buildbot_common.CopyFile(source, dest)
Esempio n. 22
0
def BuildStepBuildToolchains(pepperdir, toolchains, build, clean):
    buildbot_common.BuildStep('SDK Items')

    if clean:
        for dirname in glob.glob(os.path.join(OUT_DIR, GNBUILD_DIR + '*')):
            buildbot_common.RemoveDir(dirname)
        build = True

    if build:
        GnNinjaBuildAll(GNBUILD_DIR)

    GnNinjaInstall(pepperdir, toolchains)

    for toolchain in toolchains:
        if toolchain not in ('host', 'clang-newlib'):
            InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, toolchain),
                               toolchain)

    if 'pnacl' in toolchains:
        # NOTE: gn build all untrusted code in the x86 build
        build_dir = GetNinjaOutDir('x64')
        nacl_arches = ['x86', 'x64', 'arm']
        for nacl_arch in nacl_arches:
            shim_file = os.path.join(build_dir, 'clang_newlib_' + nacl_arch,
                                     'obj', 'ppapi', 'native_client', 'src',
                                     'untrusted', 'pnacl_irt_shim',
                                     'libpnacl_irt_shim.a')

            pnacldir = GetToolchainDir(pepperdir, 'pnacl')
            pnacl_translator_lib_dir = GetPNaClTranslatorLib(
                pnacldir, nacl_arch)
            if not os.path.isdir(pnacl_translator_lib_dir):
                buildbot_common.ErrorExit('Expected %s directory to exist.' %
                                          pnacl_translator_lib_dir)

            buildbot_common.CopyFile(shim_file, pnacl_translator_lib_dir)

        InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'x86'),
                           'pnacl')
        InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'arm'),
                           'pnacl')
Esempio n. 23
0
def AddMakeBat(pepperdir, makepath):
    """Create a simple batch file to execute Make.
  
  Creates a simple batch file named make.bat for the Windows platform at the
  given path, pointing to the Make executable in the SDK."""

    makepath = os.path.abspath(makepath)
    if not makepath.startswith(pepperdir):
        buildbot_common.ErrorExit(
            'Make.bat not relative to Pepper directory: ' + makepath)

    makeexe = os.path.abspath(os.path.join(pepperdir, 'tools'))
    relpath = os.path.relpath(makeexe, makepath)

    fp = open(os.path.join(makepath, 'make.bat'), 'wb')
    outpath = os.path.join(relpath, 'make.exe')

    # Since make.bat is only used by Windows, for Windows path style
    outpath = outpath.replace(os.path.sep, '\\')
    fp.write('@%s %%*\n' % outpath)
    fp.close()
Esempio n. 24
0
def StepRunBrowserTests(toolchains, experimental):
  buildbot_common.BuildStep('Run Tests')

  args = [
    sys.executable,
    os.path.join(SCRIPT_DIR, 'test_projects.py'),
    '--retry-times=3',
  ]

  if experimental:
    args.append('-x')
  for toolchain in toolchains:
    # TODO(sbc): Re-enable brower tests for native PPAPI platforms:
    # http://crbug.com/646666
    if toolchain in ['mac', 'linux', 'win']:
      continue
    args.extend(['-t', toolchain])

  try:
    subprocess.check_call(args)
  except subprocess.CalledProcessError:
    buildbot_common.ErrorExit('Error running tests.')
Esempio n. 25
0
    def Copy(self, src_root, file_list):
        if type(file_list) is not list:
            file_list = [file_list]

        for file_spec in file_list:
            # The list of files to install can be a simple list of
            # strings or a list of pairs, where each pair corresponds
            # to a mapping from source to destination names.
            if type(file_spec) is str:
                src_file = dest_file = file_spec
            else:
                src_file, dest_file = file_spec

            src_file = os.path.join(src_root, src_file)

            # Expand sources files using glob.
            sources = glob.glob(src_file)
            if not sources:
                sources = [src_file]

            if len(sources) > 1:
                if not (dest_file.endswith('/') or dest_file == ''):
                    buildbot_common.ErrorExit(
                        "Target file %r must end in '/' or be empty when "
                        "using globbing to install files %r" %
                        (dest_file, sources))

            for source in sources:
                if dest_file.endswith('/'):
                    dest = os.path.join(dest_file, os.path.basename(source))
                else:
                    dest = dest_file
                dest = os.path.join(self.dirname, dest)
                if not os.path.isdir(os.path.dirname(dest)):
                    buildbot_common.MakeDir(os.path.dirname(dest))
                if os.path.isdir(source):
                    buildbot_common.CopyDir(source, dest)
                else:
                    buildbot_common.CopyFile(source, dest)
Esempio n. 26
0
def BuildStepCopyTests(pepperdir, toolchains, build_experimental, clobber):
  buildbot_common.BuildStep('Copy Tests')

  build_sdk.MakeDirectoryOrClobber(pepperdir, 'testlibs', clobber)
  build_sdk.MakeDirectoryOrClobber(pepperdir, 'tests', clobber)

  args = ['--dstroot=%s' % pepperdir, '--master']
  for toolchain in toolchains:
    args.append('--' + toolchain)

  for library in TEST_LIBRARY_LIST:
    dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
    args.append(dsc)

  for example in TEST_EXAMPLE_LIST:
    dsc = os.path.join(SDK_LIBRARY_DIR, example, 'example.dsc')
    args.append(dsc)

  if build_experimental:
    args.append('--experimental')

  if generate_make.main(args):
    buildbot_common.ErrorExit('Failed to build tests.')
Esempio n. 27
0
def main(args):
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--experimental',
                        help='build experimental tests',
                        action='store_true')
    parser.add_argument('--sanitizer',
                        help='Run sanitizer (asan/tsan/valgrind) tests',
                        action='store_true')
    parser.add_argument('--verbose',
                        '-v',
                        help='Verbose output',
                        action='store_true')
    parser.add_argument('phases', nargs="*")

    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']

    # To setup bash completion for this command first install optcomplete
    # and then add this line to your .bashrc:
    #  complete -F _optcomplete test_sdk.py
    try:
        import optcomplete
        optcomplete.autocomplete(parser)
    except ImportError:
        pass

    options = parser.parse_args(args)

    pepper_ver = str(int(build_version.ChromeMajorVersion()))
    pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
    toolchains = ['clang-newlib', 'newlib', 'glibc', 'pnacl']
    toolchains.append(getos.GetPlatform())

    if options.verbose:
        build_projects.verbose = True

    phases = [
        ('build_examples', StepBuildExamples, pepperdir),
        ('copy_tests', StepCopyTests, pepperdir, toolchains,
         options.experimental),
        ('build_tests', StepBuildTests, pepperdir),
        ('sel_ldr_tests', StepRunSelLdrTests, pepperdir, None),
        ('browser_tests', StepRunBrowserTests, toolchains,
         options.experimental),
    ]

    if options.sanitizer:
        if getos.GetPlatform() != 'linux':
            buildbot_common.ErrorExit('sanitizer tests only run on linux.')
        phases += [
            ('sel_ldr_tests_asan', StepRunSelLdrTests, pepperdir, 'address'),
            ('sel_ldr_tests_tsan', StepRunSelLdrTests, pepperdir, 'thread'),
            ('sel_ldr_tests_valgrind', StepRunSelLdrTests, pepperdir,
             'valgrind')
        ]

    if options.phases:
        phase_names = [p[0] for p in phases]
        for arg in options.phases:
            if arg not in phase_names:
                msg = 'Invalid argument: %s\n' % arg
                msg += 'Possible arguments:\n'
                for name in phase_names:
                    msg += '   %s\n' % name
                parser.error(msg.strip())

    for phase in phases:
        phase_name = phase[0]
        if options.phases and phase_name not in options.phases:
            continue
        phase_func = phase[1]
        phase_args = phase[2:]
        phase_func(*phase_args)

    return 0
Esempio n. 28
0
            ('sel_ldr_tests_valgrind', StepRunSelLdrTests, pepperdir,
             'valgrind')
        ]

    if options.phases:
        phase_names = [p[0] for p in phases]
        for arg in options.phases:
            if arg not in phase_names:
                msg = 'Invalid argument: %s\n' % arg
                msg += 'Possible arguments:\n'
                for name in phase_names:
                    msg += '   %s\n' % name
                parser.error(msg.strip())

    for phase in phases:
        phase_name = phase[0]
        if options.phases and phase_name not in options.phases:
            continue
        phase_func = phase[1]
        phase_args = phase[2:]
        phase_func(*phase_args)

    return 0


if __name__ == '__main__':
    try:
        sys.exit(main(sys.argv[1:]))
    except KeyboardInterrupt:
        buildbot_common.ErrorExit('test_sdk: interrupted')
def ValidateToolchains(toolchains):
    invalid_toolchains = set(toolchains) - set(ALL_TOOLCHAINS)
    if invalid_toolchains:
        buildbot_common.ErrorExit('Invalid toolchain(s): %s' %
                                  (', '.join(invalid_toolchains)))
    ValidateToolchains(options.toolchain)

    include = {}
    if options.toolchain:
        include['TOOLS'] = options.toolchain
        print 'Filter by toolchain: ' + str(options.toolchain)
    if not options.experimental:
        include['EXPERIMENTAL'] = False
    if options.dest:
        include['DEST'] = options.dest
        print 'Filter by type: ' + str(options.dest)
    if args:
        include['NAME'] = args
        print 'Filter by name: ' + str(args)
    if not options.config:
        options.config = ALL_CONFIGS

    project_tree = GetProjectTree(include)
    return RunAllTestsInTree(project_tree, options.toolchain, options.config,
                             options.retry_times)


if __name__ == '__main__':
    script_name = os.path.basename(sys.argv[0])
    try:
        sys.exit(main(sys.argv))
    except parse_dsc.ValidationError as e:
        buildbot_common.ErrorExit('%s: %s' % (script_name, e))
    except KeyboardInterrupt:
        buildbot_common.ErrorExit('%s: interrupted' % script_name)