def main(): if AlreadyUpToDate(): return 0 remote_path = '%s/Mac/lld-%s.tgz' % (update.CDS_URL, update.PACKAGE_VERSION) update.DownloadAndUnpack(remote_path, update.LLVM_BUILD_DIR) return 0
def DownloadCoverageToolsIfNeeded(): """Temporary solution to download llvm-profdata and llvm-cov tools.""" # TODO(mmoroz): remove this function once tools get included to Clang bundle: # https://chromium-review.googlesource.com/c/chromium/src/+/688221 clang_script_path = os.path.join(CHROME_SRC_PATH, 'tools', 'clang', 'scripts') sys.path.append(clang_script_path) import update as clang_update import urllib2 def _GetRevisionFromStampFile(file_path): """Read the build stamp file created by tools/clang/scripts/update.py.""" if not os.path.exists(file_path): return 0, 0 with open(file_path) as file_handle: revision_stamp_data = file_handle.readline().strip() revision_stamp_data = revision_stamp_data.split('-') return int(revision_stamp_data[0]), int(revision_stamp_data[1]) clang_revision, clang_sub_revision = _GetRevisionFromStampFile( clang_update.STAMP_FILE) coverage_revision_stamp_file = os.path.join( os.path.dirname(clang_update.STAMP_FILE), 'cr_coverage_revision') coverage_revision, coverage_sub_revision = _GetRevisionFromStampFile( coverage_revision_stamp_file) if (coverage_revision == clang_revision and coverage_sub_revision == clang_sub_revision): # LLVM coverage tools are up to date, bail out. return clang_revision package_version = '%d-%d' % (clang_revision, clang_sub_revision) coverage_tools_file = 'llvm-code-coverage-%s.tgz' % package_version # The code bellow follows the code from tools/clang/scripts/update.py. if sys.platform == 'win32' or sys.platform == 'cygwin': coverage_tools_url = clang_update.CDS_URL + '/Win/' + coverage_tools_file elif sys.platform == 'darwin': coverage_tools_url = clang_update.CDS_URL + '/Mac/' + coverage_tools_file else: assert sys.platform.startswith('linux') coverage_tools_url = (clang_update.CDS_URL + '/Linux_x64/' + coverage_tools_file) try: clang_update.DownloadAndUnpack(coverage_tools_url, clang_update.LLVM_BUILD_DIR) print('Coverage tools %s unpacked.' % package_version) with open(coverage_revision_stamp_file, 'w') as file_handle: file_handle.write(package_version) file_handle.write('\n') except urllib2.URLError: raise Exception('Failed to download coverage tools: %s.' % coverage_tools_url) return clang_revision
def DownloadAndUnpackLlvmObjDumpPackage(platform): cds_file = 'llvmobjdump-%s.tgz' % update.PACKAGE_VERSION cds_full_url = update.GetPlatformUrlPrefix(platform) + cds_file try: update.DownloadAndUnpack(cds_full_url, update.LLVM_BUILD_DIR) except urllib2.URLError: print 'Failed to download prebuilt utils %s' % cds_file print 'Use --force-local-build if you want to build locally.' print 'Exiting.' sys.exit(1)
def main(): if AlreadyUpToDate(): return 0 remote_path = '%s/Mac/lld-%s.tgz' % (update.CDS_URL, update.PACKAGE_VERSION) update.DownloadAndUnpack(remote_path, update.LLVM_BUILD_DIR) # TODO(thakis): Remove this once the lld tgz includes the symlink. if os.path.exists(LLD_LINK_PATH): os.remove(LLD_LINK_PATH) os.remove(LD_LLD_PATH) os.symlink('lld', LLD_LINK_PATH) os.symlink('lld', LD_LLD_PATH) return 0
def DownloadCoverageToolsIfNeeded(): """Temporary solution to download llvm-profdata and llvm-cov tools.""" def _GetRevisionFromStampFile(stamp_file_path): """Returns a pair of revision number by reading the build stamp file. Args: stamp_file_path: A path the build stamp file created by tools/clang/scripts/update.py. Returns: A pair of integers represeting the main and sub revision respectively. """ if not os.path.isfile(stamp_file_path): return 0, 0 with open(stamp_file_path) as stamp_file: stamp_file_line = stamp_file.readline() if ',' in stamp_file_line: package_version = stamp_file_line.rstrip().split(',')[0] else: package_version = stamp_file_line.rstrip() clang_revision_str, clang_sub_revision_str = package_version.split( '-') return int(clang_revision_str), int(clang_sub_revision_str) host_platform = _GetHostPlatform() clang_revision, clang_sub_revision = _GetRevisionFromStampFile( clang_update.STAMP_FILE) coverage_revision_stamp_file = os.path.join( os.path.dirname(clang_update.STAMP_FILE), 'cr_coverage_revision') coverage_revision, coverage_sub_revision = _GetRevisionFromStampFile( coverage_revision_stamp_file) has_coverage_tools = (os.path.isfile(LLVM_COV_PATH) and os.path.isfile(LLVM_PROFDATA_PATH)) if (has_coverage_tools and coverage_revision == clang_revision and coverage_sub_revision == clang_sub_revision): # LLVM coverage tools are up to date, bail out. return package_version = '%d-%d' % (clang_revision, clang_sub_revision) coverage_tools_file = 'llvm-code-coverage-%s.tgz' % package_version # The code bellow follows the code from tools/clang/scripts/update.py. if host_platform == 'mac': coverage_tools_url = clang_update.CDS_URL + '/Mac/' + coverage_tools_file elif host_platform == 'linux': coverage_tools_url = (clang_update.CDS_URL + '/Linux_x64/' + coverage_tools_file) else: assert host_platform == 'win' coverage_tools_url = clang_update.CDS_URL + '/Win/' + coverage_tools_file try: clang_update.DownloadAndUnpack(coverage_tools_url, clang_update.LLVM_BUILD_DIR) with open(coverage_revision_stamp_file, 'w') as file_handle: file_handle.write('%s,%s' % (package_version, host_platform)) file_handle.write('\n') except urllib2.URLError: raise Exception('Failed to download coverage tools: %s.' % coverage_tools_url)
def DownloadCoverageToolsIfNeeded(): """Temporary solution to download llvm-profdata and llvm-cov tools.""" def _GetRevisionFromStampFile(stamp_file_path, platform): """Returns a pair of revision number by reading the build stamp file. Args: stamp_file_path: A path the build stamp file created by tools/clang/scripts/update.py. Returns: A pair of integers represeting the main and sub revision respectively. """ if not os.path.exists(stamp_file_path): return 0, 0 with open(stamp_file_path) as stamp_file: for stamp_file_line in stamp_file.readlines(): if ',' in stamp_file_line: package_version, target_os = stamp_file_line.rstrip( ).split(',') else: package_version = stamp_file_line.rstrip() target_os = '' if target_os and target_os != 'ios' and platform != target_os: continue clang_revision_str, clang_sub_revision_str = package_version.split( '-') return int(clang_revision_str), int(clang_sub_revision_str) assert False, 'Coverage is only supported on target_os - linux, mac and ios' platform = _GetPlatform() clang_revision, clang_sub_revision = _GetRevisionFromStampFile( clang_update.STAMP_FILE, platform) coverage_revision_stamp_file = os.path.join( os.path.dirname(clang_update.STAMP_FILE), 'cr_coverage_revision') coverage_revision, coverage_sub_revision = _GetRevisionFromStampFile( coverage_revision_stamp_file, platform) has_coverage_tools = (os.path.exists(LLVM_COV_PATH) and os.path.exists(LLVM_PROFDATA_PATH)) if (has_coverage_tools and coverage_revision == clang_revision and coverage_sub_revision == clang_sub_revision): # LLVM coverage tools are up to date, bail out. return clang_revision package_version = '%d-%d' % (clang_revision, clang_sub_revision) coverage_tools_file = 'llvm-code-coverage-%s.tgz' % package_version # The code bellow follows the code from tools/clang/scripts/update.py. if platform == 'mac': coverage_tools_url = clang_update.CDS_URL + '/Mac/' + coverage_tools_file else: assert platform == 'linux' coverage_tools_url = (clang_update.CDS_URL + '/Linux_x64/' + coverage_tools_file) try: clang_update.DownloadAndUnpack(coverage_tools_url, clang_update.LLVM_BUILD_DIR) logging.info('Coverage tools %s unpacked', package_version) with open(coverage_revision_stamp_file, 'w') as file_handle: file_handle.write('%s,%s' % (package_version, platform)) file_handle.write('\n') except urllib2.URLError: raise Exception('Failed to download coverage tools: %s.' % coverage_tools_url)
def DownloadCoverageToolsIfNeeded(): """Temporary solution to download llvm-profdata and llvm-cov tools.""" def _GetRevisionFromStampFile(stamp_file_path): """Returns revision by reading the build stamp file. Args: stamp_file_path: A path the build stamp file created by tools/clang/scripts/update.py. Returns: A string represeting the revision of the tool, such as 361212-67510fac-2. """ if not os.path.exists(stamp_file_path): return '' with open(stamp_file_path) as stamp_file: stamp_file_line = stamp_file.readline() if ',' in stamp_file_line: package_version = stamp_file_line.rstrip().split(',')[0] else: package_version = stamp_file_line.rstrip() return package_version cov_path = os.path.join(clang_update.LLVM_BUILD_DIR, 'llvm-cov') profdata_path = os.path.join(clang_update.LLVM_BUILD_DIR, 'llvm-profdata') host_platform = coverage_utils.GetHostPlatform() clang_revision = _GetRevisionFromStampFile(clang_update.STAMP_FILE) coverage_revision_stamp_file = os.path.join( os.path.dirname(clang_update.STAMP_FILE), 'cr_coverage_revision') coverage_revision = _GetRevisionFromStampFile(coverage_revision_stamp_file) has_coverage_tools = (os.path.exists(cov_path) and os.path.exists(profdata_path)) if (has_coverage_tools and clang_revision == coverage_revision): # LLVM coverage tools are up to date, bail out. return package_version = clang_revision coverage_tools_file = 'llvm-code-coverage-%s.tgz' % package_version # The code below follows the code from tools/clang/scripts/update.py. if host_platform == 'mac': coverage_tools_url = clang_update.CDS_URL + '/Mac/' + coverage_tools_file elif host_platform == 'linux': coverage_tools_url = (clang_update.CDS_URL + '/Linux_x64/' + coverage_tools_file) else: assert host_platform == 'win' coverage_tools_url = (clang_update.CDS_URL + '/Win/' + coverage_tools_file) try: clang_update.DownloadAndUnpack(coverage_tools_url, clang_update.LLVM_BUILD_DIR) with open(coverage_revision_stamp_file, 'w') as file_handle: file_handle.write('%s,%s' % (package_version, host_platform)) file_handle.write('\n') except urllib2.URLError: raise Exception('Failed to download coverage tools: %s.' % coverage_tools_url)
def main(): if not AlreadyUpToDate(): cds_file = 'llvmstrip-%s.tgz' % update.PACKAGE_VERSION cds_full_url = update.GetPlatformUrlPrefix(sys.platform) + cds_file update.DownloadAndUnpack(cds_full_url, update.LLVM_BUILD_DIR) return 0