Skip to content

Commit

Permalink
Add eng/download-checkout-llvm.yml eng/download-llvm-release.py eng/d…
Browse files Browse the repository at this point in the history
…ownload-llvm-release.yml
  • Loading branch information
echesakov committed Sep 17, 2020
1 parent 111abc3 commit 8a6bb77
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
12 changes: 12 additions & 0 deletions eng/download-checkout-llvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
steps:
- download: current
artifact: $(LLVMSourceBundle)
displayName: Download LLVM bundle

- script: git clone $(Pipeline.Workspace)\$(LLVMSourceBundle)\$(LLVMSourceBundle) $(Build.SourcesDirectory)\src\llvm-project
displayName: Checkout LLVM from bundle (Windows)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

- script: git clone $(Pipeline.Workspace)/$(LLVMSourceBundle)/$(LLVMSourceBundle) $(Build.SourcesDirectory)/src/llvm-project
displayName: Checkout LLVM from bundle (Linux or macOS)
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
45 changes: 45 additions & 0 deletions eng/download-llvm-release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
#
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
#
import argparse
import io
import os
import sys
import tarfile
from urllib import request
from urllib.error import URLError, HTTPError

Release_urls = {
'llvmorg-9.0.1': {
'linux': 'https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/clang+llvm-9.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz',
'macos': 'https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/clang+llvm-9.0.1-x86_64-apple-darwin.tar.xz'
},
'llvmorg-10.0.1': {
'linux': 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz',
'macos': 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-apple-darwin.tar.xz'
}
}

def download_llvm_release(release_url, output_dir):
try:
with request.urlopen(release_url) as response:
downloaded_bytes = response.read()
except (URLError, HTTPError) as err:
print(err)
sys.exit(1)

with io.BytesIO(downloaded_bytes) as downloaded_fileobj:
with tarfile.open(fileobj=downloaded_fileobj, mode='r:xz') as archive:
archive.extractall(path=output_dir)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-release', required=True, choices=Release_urls.keys())
parser.add_argument('-os', required=True, choices=['linux', 'macos'])
parser.add_argument('-output-dir', dest='output_dir', default=os.getcwd())
args = parser.parse_args()

release_url = Release_urls[args.release][args.os]
download_llvm_release(release_url, args.output_dir)
12 changes: 12 additions & 0 deletions eng/download-llvm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
- name: os
type: string
- name: release
type: string

steps:
- script: python3 $(Build.SourcesDirectory)/eng/download-llvm-release.py -os ${{ parameters.os }} -release ${{ parameters.release }} -output-dir $(Pipeline.Workspace)
displayName: Download LLVM release from GitHub

- script: echo '##vso[task.prependpath]'$(find $(Pipeline.Workspace) -name "clang+llvm-*" -type d)/bin
displayName: Add Clang and LLVM to the PATH

0 comments on commit 8a6bb77

Please sign in to comment.