Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Commit 78501de

Browse files
committed
LDC: Set up CI with Azure Pipelines and Shippable
Azure: Windows x86 & x64, macOS x64, Linux x64, Android ARMv7-A Shippable: Linux AArch64 2 packages per platform (enabled/disabled assertions), except for cross-compiled Android. Tagged builds are uploaded to the corresponding GitHub release, untagged builds to the GitHub 'CI' release.
1 parent c0a76db commit 78501de

File tree

4 files changed

+450
-0
lines changed

4 files changed

+450
-0
lines changed

.azure-pipelines/posix.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Each step starts in the checked-out source directory,
2+
# environment variables aren't persisted across steps.
3+
4+
steps:
5+
- script: |
6+
set -ex
7+
cd ..
8+
if [ "$CI_OS" = "osx" ]; then export PATH="$PWD/ninja:$PATH"; fi
9+
cmake --version
10+
ninja --version
11+
mkdir build
12+
cd build
13+
cmake -G Ninja $BUILD_SOURCESDIRECTORY \
14+
-DCMAKE_BUILD_TYPE=Release \
15+
-DCMAKE_INSTALL_PREFIX=$PWD/../install \
16+
-DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" \
17+
-DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \
18+
$BASE_CMAKE_FLAGS $EXTRA_CMAKE_FLAGS
19+
ninja install
20+
displayName: Build & install LLVM incl. LLD, compiler-rt and the Khronos SPIRV-LLVM-Translator
21+
- script: |
22+
set -ex
23+
cd ..
24+
if [ "${BUILD_SOURCEBRANCH:0:10}" = "refs/tags/" ]; then
25+
ARTIFACT_ID=${BUILD_SOURCEBRANCH:15}
26+
else
27+
ARTIFACT_ID=${BUILD_SOURCEVERSION:0:8}
28+
fi
29+
ASSERTS_SUFFIX=""
30+
if [ "$LLVM_ENABLE_ASSERTIONS" = "ON" ]; then
31+
ASSERTS_SUFFIX="-withAsserts"
32+
fi
33+
artifactName=llvm-$ARTIFACT_ID-$CI_OS-$ARCH$ASSERTS_SUFFIX
34+
mv install $artifactName
35+
mkdir artifacts
36+
chmod -R go=rX $artifactName
37+
if [ "$CI_OS" = "osx" ]; then
38+
sudo chown -R root:wheel $artifactName
39+
tar -cJf artifacts/$artifactName.tar.xz --options='compression-level=9' $artifactName
40+
else
41+
XZ_OPT=-9 tar -cJf artifacts/$artifactName.tar.xz --owner=0 --group=0 $artifactName
42+
fi
43+
# Persist the ARTIFACT_ID and ASSERTS_SUFFIX variables for future steps
44+
set +x
45+
echo "##vso[task.setvariable variable=ARTIFACT_ID]$ARTIFACT_ID"
46+
echo "##vso[task.setvariable variable=ASSERTS_SUFFIX]$ASSERTS_SUFFIX"
47+
displayName: Pack installation dir
48+
- script: |
49+
set -ex
50+
cd ..
51+
artifactName=llvm-$ARTIFACT_ID.src
52+
chmod -R go=rX $BUILD_SOURCESDIRECTORY
53+
XZ_OPT=-9 tar -cJf artifacts/$artifactName.tar.xz --exclude-vcs --owner=0 --group=0 --transform=s,${BUILD_SOURCESDIRECTORY:1},$artifactName, $BUILD_SOURCESDIRECTORY
54+
displayName: Pack source dir
55+
condition: and(succeeded(), and(eq(variables['CI_OS'], 'linux'), eq(variables['LLVM_ENABLE_ASSERTIONS'], 'OFF')))
56+
- task: PublishPipelineArtifact@0
57+
inputs:
58+
artifactName: $(CI_OS)-$(ARCH)$(ASSERTS_SUFFIX)
59+
targetPath: ../artifacts
60+
displayName: Publish artifact(s)

.azure-pipelines/windows.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Each step starts in the checked-out source directory,
2+
# environment variables aren't persisted across steps.
3+
4+
steps:
5+
- script: |
6+
set
7+
displayName: Print environment variables
8+
- checkout: self
9+
submodules: true
10+
fetchDepth: 50
11+
- script: |
12+
echo on
13+
cd ..
14+
:: Download & extract Ninja
15+
curl -L -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip 2>&1
16+
mkdir ninja
17+
cd ninja
18+
7z x ../ninja.zip > nul
19+
cd ..
20+
:: Download & install clang
21+
curl -L -o clang.exe http://releases.llvm.org/%CLANG_VERSION%/LLVM-%CLANG_VERSION%-win64.exe 2>&1
22+
clang.exe /S
23+
displayName: Install prerequisites
24+
- script: |
25+
echo on
26+
cd ..
27+
set PATH=C:\Program Files\LLVM\bin;%CD%\ninja;%PATH%
28+
call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%ARCH%
29+
echo on
30+
cmake --version
31+
ninja --version
32+
clang-cl --version
33+
mkdir build
34+
cd build
35+
cmake -G Ninja %BUILD_SOURCESDIRECTORY% -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CD%/../install -DLLVM_TARGETS_TO_BUILD=%LLVM_TARGETS_TO_BUILD% -DLLVM_ENABLE_ASSERTIONS=%LLVM_ENABLE_ASSERTIONS% -DLLVM_DEFAULT_TARGET_TRIPLE=%LLVM_DEFAULT_TARGET_TRIPLE% %BASE_CMAKE_FLAGS% %EXTRA_CMAKE_FLAGS%
36+
ninja install
37+
displayName: Build & install LLVM incl. LLD, compiler-rt and the Khronos SPIRV-LLVM-Translator
38+
- script: |
39+
echo on
40+
cd ..
41+
:: On Windows, the lld symlinks are copies
42+
rm install/bin/ld.lld.exe
43+
rm install/bin/ld64.lld.exe
44+
rm install/bin/lld.exe
45+
rm install/bin/wasm-ld.exe
46+
if "%BUILD_SOURCEBRANCH:~0,10%" == "refs/tags/" (
47+
set ARTIFACT_ID=%BUILD_SOURCEBRANCH:~15%
48+
) else (
49+
set ARTIFACT_ID=%BUILD_SOURCEVERSION:~0,8%
50+
)
51+
set ASSERTS_SUFFIX=
52+
if "%LLVM_ENABLE_ASSERTIONS%" == "ON" (
53+
set ASSERTS_SUFFIX=-withAsserts
54+
)
55+
set ARTIFACT_NAME=llvm-%ARTIFACT_ID%-windows-%ARCH%%ASSERTS_SUFFIX%
56+
mv install %ARTIFACT_NAME%
57+
mkdir artifacts
58+
cd %ARTIFACT_NAME%
59+
7z a -mx=9 ../artifacts/%ARTIFACT_NAME%.7z * > nul
60+
:: Persist the ASSERTS_SUFFIX env variable for future steps
61+
echo off
62+
echo ##vso[task.setvariable variable=ASSERTS_SUFFIX]%ASSERTS_SUFFIX%
63+
displayName: Pack installation dir
64+
- task: PublishPipelineArtifact@0
65+
inputs:
66+
artifactName: windows-$(ARCH)$(ASSERTS_SUFFIX)
67+
targetPath: ../artifacts
68+
displayName: Publish artifact

azure-pipelines.yml

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
variables:
2+
LLVM_TARGETS_TO_BUILD: AArch64;ARM;Mips;MSP430;NVPTX;PowerPC;RISCV;WebAssembly;X86
3+
# Prevent dependencies on some purely optional libraries, and a dependency on clang
4+
# for compiler-rt and SPIRV-LLVM-Translator tests.
5+
BASE_CMAKE_FLAGS: -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DCOMPILER_RT_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF
6+
7+
# Although tags are supposed to trigger builds by default, they don't.
8+
trigger:
9+
- '*'
10+
- refs/tags/ldc-v*
11+
12+
jobs:
13+
- job: Windows
14+
timeoutInMinutes: 180
15+
pool:
16+
vmImage: 'windows-2019'
17+
variables:
18+
CLANG_VERSION: 9.0.0
19+
VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
20+
EXTRA_CMAKE_FLAGS: -DLLVM_USE_CRT_RELEASE=MT
21+
strategy:
22+
matrix:
23+
x64:
24+
ARCH: x64
25+
LLVM_DEFAULT_TARGET_TRIPLE: x86_64-pc-windows-msvc
26+
LLVM_ENABLE_ASSERTIONS: OFF
27+
x64_withAsserts:
28+
ARCH: x64
29+
LLVM_DEFAULT_TARGET_TRIPLE: x86_64-pc-windows-msvc
30+
LLVM_ENABLE_ASSERTIONS: ON
31+
x86:
32+
ARCH: x86
33+
LLVM_DEFAULT_TARGET_TRIPLE: i686-pc-windows-msvc
34+
LLVM_ENABLE_ASSERTIONS: OFF
35+
# Let CMake configure 64-bit clang-cl for 32-bit code emission.
36+
CFLAGS: -m32
37+
CXXFLAGS: -m32
38+
ASMFLAGS: -m32
39+
x86_withAsserts:
40+
ARCH: x86
41+
LLVM_DEFAULT_TARGET_TRIPLE: i686-pc-windows-msvc
42+
LLVM_ENABLE_ASSERTIONS: ON
43+
CFLAGS: -m32
44+
CXXFLAGS: -m32
45+
ASMFLAGS: -m32
46+
steps:
47+
- template: .azure-pipelines/windows.yml
48+
49+
- job: Linux
50+
timeoutInMinutes: 180
51+
pool:
52+
vmImage: 'ubuntu-16.04'
53+
variables:
54+
CI_OS: linux
55+
ARCH: x86_64
56+
EXTRA_CMAKE_FLAGS: -DLLVM_BINUTILS_INCDIR=/usr/include -DCMAKE_CXX_FLAGS=-static-libstdc++
57+
strategy:
58+
matrix:
59+
x64:
60+
LLVM_ENABLE_ASSERTIONS: OFF
61+
x64_withAsserts:
62+
LLVM_ENABLE_ASSERTIONS: ON
63+
steps:
64+
- checkout: self
65+
submodules: true
66+
fetchDepth: 50
67+
- script: |
68+
set -ex
69+
cd ..
70+
export DEBIAN_FRONTEND=noninteractive
71+
sudo apt-get -q update
72+
sudo apt-get -yq install \
73+
git-core cmake ninja-build g++ binutils-dev python
74+
displayName: Install prerequisites
75+
- template: .azure-pipelines/posix.yml
76+
77+
- job: macOS
78+
timeoutInMinutes: 180
79+
pool:
80+
vmImage: 'macOS-10.13'
81+
variables:
82+
CI_OS: osx
83+
ARCH: x86_64
84+
EXTRA_CMAKE_FLAGS: -DHAVE_FUTIMENS=0
85+
MACOSX_DEPLOYMENT_TARGET: 10.9
86+
strategy:
87+
matrix:
88+
x64:
89+
LLVM_ENABLE_ASSERTIONS: OFF
90+
x64_withAsserts:
91+
LLVM_ENABLE_ASSERTIONS: ON
92+
steps:
93+
- checkout: self
94+
submodules: true
95+
fetchDepth: 50
96+
- script: |
97+
set -ex
98+
cd ..
99+
# Download & extract Ninja
100+
curl -L -o ninja-mac.zip https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-mac.zip
101+
mkdir ninja
102+
tar -xf ninja-mac.zip -C ninja
103+
displayName: Install prerequisites
104+
- template: .azure-pipelines/posix.yml
105+
106+
- job: Android_armv7a
107+
timeoutInMinutes: 180
108+
pool:
109+
vmImage: 'ubuntu-16.04'
110+
variables:
111+
CI_OS: android
112+
ARCH: armv7a
113+
LLVM_TARGETS_TO_BUILD: AArch64;ARM;WebAssembly;X86
114+
LLVM_ENABLE_ASSERTIONS: OFF
115+
EXTRA_CMAKE_FLAGS: -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_STL=c++_static -DCMAKE_CROSSCOMPILING=True -DLLVM_TARGET_ARCH=ARM -DLLVM_DEFAULT_TARGET_TRIPLE=armv7a--linux-androideabi -DLLVM_ENABLE_PLUGINS=OFF
116+
steps:
117+
- checkout: self
118+
submodules: true
119+
fetchDepth: 50
120+
- script: |
121+
set -ex
122+
cd ..
123+
export DEBIAN_FRONTEND=noninteractive
124+
sudo apt-get -q update
125+
sudo apt-get -yq install \
126+
git-core cmake ninja-build g++ curl python unzip
127+
displayName: Install prerequisites
128+
- script: |
129+
set -ex
130+
cd ..
131+
cmake --version
132+
ninja --version
133+
mkdir build-native
134+
cd build-native
135+
cmake -G Ninja $BUILD_SOURCESDIRECTORY \
136+
-DCMAKE_BUILD_TYPE=Release \
137+
-DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" \
138+
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="$LLVM_EXPERIMENTAL_TARGETS_TO_BUILD" \
139+
-DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \
140+
$BASE_CMAKE_FLAGS
141+
ninja llvm-tblgen
142+
displayName: Build native llvm-tblgen
143+
- script: |
144+
set -ex
145+
cd ..
146+
# Download & extract Android NDK
147+
curl -OL https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip
148+
unzip android-ndk-r20-linux-x86_64.zip > /dev/null
149+
rm android-ndk-r20-linux-x86_64.zip
150+
# The NDK toolchain file enforces `-g` as base C[XX] flag - remove it to
151+
# *significantly* reduce executable sizes
152+
TOOLCHAIN_FILE=$PWD/android-ndk-r20/build/cmake/android.toolchain.cmake
153+
sed -i 's|^ -g$||' $TOOLCHAIN_FILE
154+
# Extend EXTRA_CMAKE_FLAGS for future steps
155+
set +x
156+
echo "##vso[task.setvariable variable=EXTRA_CMAKE_FLAGS]$EXTRA_CMAKE_FLAGS -DLLVM_TABLEGEN=$PWD/build-native/bin/llvm-tblgen -DLLVM_CONFIG_PATH=$PWD/build-native/bin/llvm-config -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE"
157+
displayName: Set up cross-compilation
158+
- template: .azure-pipelines/posix.yml
159+
160+
# Uploads the packages to a GitHub release.
161+
- job: Upload_to_GitHub
162+
timeoutInMinutes: 30
163+
pool:
164+
vmImage: 'ubuntu-16.04'
165+
dependsOn:
166+
- Windows
167+
- Linux
168+
- macOS
169+
- Android_armv7a
170+
# Only run for branches and tags, no PRs.
171+
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/'), startsWith(variables['Build.SourceBranch'], 'refs/tags/')))
172+
steps:
173+
- checkout: none
174+
- task: DownloadPipelineArtifact@0
175+
inputs:
176+
artifactName: windows-x64
177+
targetPath: artifacts
178+
- task: DownloadPipelineArtifact@0
179+
inputs:
180+
artifactName: windows-x64-withAsserts
181+
targetPath: artifacts
182+
- task: DownloadPipelineArtifact@0
183+
inputs:
184+
artifactName: windows-x86
185+
targetPath: artifacts
186+
- task: DownloadPipelineArtifact@0
187+
inputs:
188+
artifactName: windows-x86-withAsserts
189+
targetPath: artifacts
190+
- task: DownloadPipelineArtifact@0
191+
inputs:
192+
artifactName: linux-x86_64
193+
targetPath: artifacts
194+
- task: DownloadPipelineArtifact@0
195+
inputs:
196+
artifactName: linux-x86_64-withAsserts
197+
targetPath: artifacts
198+
- task: DownloadPipelineArtifact@0
199+
inputs:
200+
artifactName: osx-x86_64
201+
targetPath: artifacts
202+
- task: DownloadPipelineArtifact@0
203+
inputs:
204+
artifactName: osx-x86_64-withAsserts
205+
targetPath: artifacts
206+
- task: DownloadPipelineArtifact@0
207+
inputs:
208+
artifactName: android-armv7a
209+
targetPath: artifacts
210+
- bash: |
211+
set -e
212+
if [ "${BUILD_SOURCEBRANCH:0:10}" != "refs/tags/" ]; then
213+
releaseTag=CI
214+
isPreRelease=true
215+
else
216+
releaseTag=${BUILD_SOURCEBRANCH:10}
217+
isPreRelease=false
218+
fi
219+
echo "##vso[task.setvariable variable=GITHUB_RELEASE_TAG]$releaseTag"
220+
echo "##vso[task.setvariable variable=GITHUB_RELEASE_ISPRERELEASE]$isPreRelease"
221+
displayName: Set GITHUB_RELEASE_{TAG,ISPRERELEASE} env variables
222+
- task: GitHubRelease@0
223+
inputs:
224+
gitHubConnection: kinke
225+
repositoryName: ldc-developers/llvm
226+
action: edit
227+
tag: $(GITHUB_RELEASE_TAG)
228+
assets: artifacts/*
229+
assetUploadMode: replace
230+
isPreRelease: $(GITHUB_RELEASE_ISPRERELEASE)
231+
addChangeLog: false
232+
displayName: Upload artifacts to GitHub release

0 commit comments

Comments
 (0)