Exemple #1
0
def AddGnuWinToPath():
    """Download some GNU win tools and add them to PATH."""
    if sys.platform != 'win32':
        return

    gnuwin_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gnuwin')
    GNUWIN_VERSION = '12'
    GNUWIN_STAMP = os.path.join(gnuwin_dir, 'stamp')
    if ReadStampFile(GNUWIN_STAMP) == GNUWIN_VERSION:
        print('GNU Win tools already up to date.')
    else:
        zip_name = 'gnuwin-%s.zip' % GNUWIN_VERSION
        DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
        WriteStampFile(GNUWIN_VERSION, GNUWIN_STAMP)

    os.environ['PATH'] = gnuwin_dir + os.pathsep + os.environ.get('PATH', '')

    # find.exe, mv.exe and rm.exe are from MSYS (see crrev.com/389632). MSYS uses
    # Cygwin under the hood, and initializing Cygwin has a race-condition when
    # getting group and user data from the Active Directory is slow. To work
    # around this, use a horrible hack telling it not to do that.
    # See https://crbug.com/905289
    etc = os.path.join(gnuwin_dir, '..', '..', 'etc')
    EnsureDirExists(etc)
    with open(os.path.join(etc, 'nsswitch.conf'), 'w') as f:
        f.write('passwd: files\n')
        f.write('group: files\n')
Exemple #2
0
def AddZlibToPath():
  """Download and build zlib, and add to PATH."""
  zlib_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'zlib-1.2.11')
  if os.path.exists(zlib_dir):
    RmTree(zlib_dir)
  zip_name = 'zlib-1.2.11.tar.gz'
  DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
  os.chdir(zlib_dir)
  zlib_files = [
      'adler32', 'compress', 'crc32', 'deflate', 'gzclose', 'gzlib', 'gzread',
      'gzwrite', 'inflate', 'infback', 'inftrees', 'inffast', 'trees',
      'uncompr', 'zutil'
  ]
  cl_flags = [
      '/nologo', '/O2', '/DZLIB_DLL', '/c', '/D_CRT_SECURE_NO_DEPRECATE',
      '/D_CRT_NONSTDC_NO_DEPRECATE'
  ]
  RunCommand(
      ['cl.exe'] + [f + '.c' for f in zlib_files] + cl_flags, msvc_arch='x64')
  RunCommand(
      ['lib.exe'] + [f + '.obj'
                     for f in zlib_files] + ['/nologo', '/out:zlib.lib'],
      msvc_arch='x64')
  # Remove the test directory so it isn't found when trying to find
  # test.exe.
  shutil.rmtree('test')

  os.environ['PATH'] = zlib_dir + os.pathsep + os.environ.get('PATH', '')
  return zlib_dir
Exemple #3
0
def AddCMakeToPath(args):
  """Download CMake and add it to PATH."""
  if args.use_system_cmake:
    return

  if sys.platform == 'win32':
    zip_name = 'cmake-3.17.1-win64-x64.zip'
    dir_name = ['cmake-3.17.1-win64-x64', 'bin']
  elif sys.platform == 'darwin':
    if platform.machine() == 'arm64':
      # TODO(thakis): Move to 3.20 everywhere.
      zip_name = 'cmake-3.20.0-macos-universal.tar.gz'
      dir_name = [
          'cmake-3.20.0-macos-universal', 'CMake.app', 'Contents', 'bin'
      ]
    else:
      zip_name = 'cmake-3.17.1-Darwin-x86_64.tar.gz'
      dir_name = ['cmake-3.17.1-Darwin-x86_64', 'CMake.app', 'Contents', 'bin']
  else:
    zip_name = 'cmake-3.17.1-Linux-x86_64.tar.gz'
    dir_name = ['cmake-3.17.1-Linux-x86_64', 'bin']

  cmake_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, *dir_name)
  if not os.path.exists(cmake_dir):
    DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
  os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
Exemple #4
0
def MaybeDownloadHostGcc(args):
    """Download a modern GCC host compiler on Linux."""
    if not sys.platform.startswith('linux') or args.gcc_toolchain:
        return
    gcc_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gcc530trusty')
    if not os.path.exists(gcc_dir):
        DownloadAndUnpack(CDS_URL + '/tools/gcc530trusty.tgz', gcc_dir)
    args.gcc_toolchain = gcc_dir
Exemple #5
0
def AddSvnToPathOnWin():
    """Download svn.exe and add it to PATH."""
    if sys.platform != 'win32':
        return
    svn_ver = 'svn-1.6.6-win'
    svn_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, svn_ver)
    if not os.path.exists(svn_dir):
        DownloadAndUnpack(CDS_URL + '/tools/%s.zip' % svn_ver,
                          LLVM_BUILD_TOOLS_DIR)
    os.environ['PATH'] = svn_dir + os.pathsep + os.environ.get('PATH', '')
Exemple #6
0
def AddCMakeToPath(args):
  """Download CMake and add it to PATH."""
  if args.use_system_cmake:
    return

  if sys.platform == 'win32':
    zip_name = 'cmake-3.12.1-win32-x86.zip'
    dir_name = ['cmake-3.12.1-win32-x86', 'bin']
  elif sys.platform == 'darwin':
    zip_name = 'cmake-3.12.1-Darwin-x86_64.tar.gz'
    dir_name = ['cmake-3.12.1-Darwin-x86_64', 'CMake.app', 'Contents', 'bin']
  else:
    zip_name = 'cmake-3.12.1-Linux-x86_64.tar.gz'
    dir_name = ['cmake-3.12.1-Linux-x86_64', 'bin']

  cmake_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, *dir_name)
  if not os.path.exists(cmake_dir):
    DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
  os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
Exemple #7
0
def DownloadRPMalloc():
  """Download rpmalloc."""
  rpmalloc_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'rpmalloc')
  if os.path.exists(rpmalloc_dir):
    RmTree(rpmalloc_dir)

  # Using rpmalloc bc1923f rather than the latest release (1.4.1) because
  # it contains the fix for https://github.com/mjansson/rpmalloc/pull/186
  # which would cause lld to deadlock.
  # The zip file was created and uploaded as follows:
  # $ mkdir rpmalloc
  # $ curl -L https://github.com/mjansson/rpmalloc/archive/bc1923f436539327707b08ef9751a7a87bdd9d2f.tar.gz \
  #     | tar -C rpmalloc --strip-components=1 -xzf -
  # $ GZIP=-9 tar vzcf rpmalloc-bc1923f.tgz rpmalloc
  # $ gsutil.py cp -n -a public-read rpmalloc-bc1923f.tgz \
  #     gs://chromium-browser-clang/tools/
  zip_name = 'rpmalloc-bc1923f.tgz'
  DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
  rpmalloc_dir = rpmalloc_dir.replace('\\', '/')
  return rpmalloc_dir