Home | History | Annotate | Download | only in scripts
      1 #!/usr/bin/env python
      2 # Copyright 2017 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 """Script to download lld/mac from google storage."""
      7 
      8 import os
      9 import re
     10 import subprocess
     11 import sys
     12 
     13 import update
     14 
     15 LLVM_BUILD_DIR = update.LLVM_BUILD_DIR
     16 LLD_LINK_PATH = os.path.join(LLVM_BUILD_DIR, 'bin', 'lld-link')
     17 
     18 
     19 def AlreadyUpToDate():
     20   if not os.path.exists(LLD_LINK_PATH):
     21     return False
     22   lld_rev = subprocess.check_output([LLD_LINK_PATH, '--version'])
     23   return (re.match(r'LLD.*\(trunk (\d+)\)', lld_rev).group(1) ==
     24              update.CLANG_REVISION)
     25 
     26 
     27 def main():
     28   if AlreadyUpToDate():
     29     return 0
     30   remote_path = '%s/Mac/lld-%s.tgz' % (update.CDS_URL, update.PACKAGE_VERSION)
     31   update.DownloadAndUnpack(remote_path, update.LLVM_BUILD_DIR)
     32   return 0
     33 
     34 
     35 if __name__ == '__main__':
     36   sys.exit(main())
     37