def GetChromePath():
    chrome_path = os.environ.get('CHROME_PATH')
    if chrome_path:
        if not os.path.exists(chrome_path):
            raise Error('Invalid CHROME_PATH: %s' % chrome_path)
    else:
        chrome_path = oshelpers.FindExeInPath(CHROME_EXE_BASENAME)
        if not chrome_path:
            raise Error('CHROME_PATH is undefined, and %s not found in PATH.' %
                        CHROME_EXE_BASENAME)

    return os.path.realpath(chrome_path)
示例#2
0
def GetChromePath(platform):
  # If CHROME_PATH is defined and exists, use that.
  chrome_path = os.environ.get('CHROME_PATH')
  if chrome_path:
    if not os.path.exists(chrome_path):
      raise Error('Invalid CHROME_PATH: %s' % chrome_path)
    return os.path.realpath(chrome_path)

  # Otherwise look in the PATH environment variable.
  basename = os.path.basename(CHROME_DEFAULT_PATH[platform])
  chrome_path = oshelpers.FindExeInPath(basename)
  if chrome_path:
    return os.path.realpath(chrome_path)

  # Finally, try the default paths to Chrome.
  chrome_path = CHROME_DEFAULT_PATH[platform]
  if os.path.exists(chrome_path):
    return os.path.realpath(chrome_path)

  raise Error('CHROME_PATH is undefined, and %s not found in PATH, nor %s.' % (
              basename, chrome_path))
示例#3
0
def GetWindowsEnvironment():
    if oshelpers.FindExeInPath('cl.exe') is not None:
        # cl.exe is already in the path, let's just use that.
        return os.environ

    sys.path.append(os.path.join(NACL_DIR, 'buildbot'))
    import buildbot_standard

    # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll
    # fake enough of that here to work.
    class FakeContext(object):
        def __init__(self):
            self.env = os.environ

        def GetEnv(self, key):
            return self.env[key]

        def __getitem__(self, key):
            # The nacl side script now needs gyp_vars to return a list.
            if key == 'gyp_vars':
                return []
            return self.env[key]

        def SetEnv(self, key, value):
            self.env[key] = value

        def __setitem__(self, key, value):
            self.env[key] = value

    context = FakeContext()
    buildbot_standard.SetupWindowsEnvironment(context)

    env_script = 'vcvarsall.bat'

    if not oshelpers.FindExeInPath(env_script):
        # This might happen if Visual Studio is not installed. Check to see if
        # vs2013 is in depot_tools.

        # Find depot_tools by looking for gclient.bat.
        gclient_bat = oshelpers.FindExeInPath('gclient.bat')
        if gclient_bat is None:
            ErrorExit('gclient.bat is not in the path. Where is depot_tools?')

        depot_tools_dir = os.path.dirname(gclient_bat)
        vs2013_dir = os.path.join(depot_tools_dir, 'win_toolchain',
                                  'vs2013_files')
        if not os.path.exists(vs2013_dir):
            ErrorExit(
                'Visual Studio not installed normally or in depot_tools.')

        # The depot_tools vs2013 toolchain has its own batch file (not
        # vcvarsall.bat) for setting the environment variables needed by vs2013.
        env_script = os.path.join(vs2013_dir, 'win8sdk', 'bin', 'SetEnv.cmd')

    # Running the env_script adds the correct directories to the path for
    # executables (e.g. cl.exe, link.exe), include paths, lib directories, etc,
    # which we extract below.
    process = subprocess.Popen(env_script + ' x86 > NUL && set',
                               stdout=subprocess.PIPE,
                               env=context.env,
                               shell=True)
    stdout, _ = process.communicate()

    # Parse environment from "set" command above.
    # It looks like this:
    # KEY1=VALUE1\r\n
    # KEY2=VALUE2\r\n
    # ...
    return dict(line.split('=', 1) for line in stdout.split('\r\n')[:-1])
示例#4
0
sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))

import getos
import oshelpers

BUILD_DIR = os.path.join(NACL_DIR, 'build')
NACL_TOOLCHAIN_DIR = os.path.join(NACL_DIR, 'toolchain')
NACL_TOOLCHAINTARS_DIR = os.path.join(NACL_TOOLCHAIN_DIR, '.tars')

CYGTAR = os.path.join(BUILD_DIR, 'cygtar.py')
PKGVER = os.path.join(BUILD_DIR, 'package_version', 'package_version.py')
VERSION_JSON = os.path.join(BUILD_ARCHIVE_DIR, 'version.json')

PLATFORM = getos.GetPlatform()
TAR = oshelpers.FindExeInPath('tar')
options = None
all_archives = []

# Mapping from toolchain name to the equivalent package_version.py directory
# name.
TOOLCHAIN_PACKAGE_MAP = {
    'glibc_x86': 'nacl_x86_glibc',
    'glibc_arm': 'nacl_arm_glibc',
    'pnacl': 'pnacl_newlib'
}


def Tar(archive_path, root, files):
    if os.path.exists(TAR):
        cmd = [TAR]