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

Commit a4ddbea

Browse files
committed
Add AppVeyor & CircleCI scripts for automated Win/Linux/OSX builds
Windows: x86 & x64, Linux and OSX: x86_64 only. 2 packages per platform (enabled/disabled assertions). Tagged builds are uploaded to the corresponding GitHub release, untagged builds to the GitHub 'CI' release. AppVeyor barely manages to complete in time (timeout after 1 hour), that's why the default 7zip compression level is used and compiler-rt & libFuzzer aren't included yet.
1 parent 80990c3 commit a4ddbea

File tree

2 files changed

+302
-0
lines changed

2 files changed

+302
-0
lines changed

.circleci/config.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# The common steps require environment variables CI_OS and LLVM_ENABLE_ASSERTIONS.
2+
commonSteps: &commonSteps
3+
steps:
4+
# Each step starts in working dir `<root>/project` (containing the cloned LLVM repo).
5+
- run:
6+
name: Install dependencies
7+
command: |
8+
cd ..
9+
if [ "$CI_OS" = "linux" ]; then
10+
export DEBIAN_FRONTEND=noninteractive
11+
apt-get -y update
12+
apt-get -yq install software-properties-common
13+
add-apt-repository -y ppa:ubuntu-toolchain-r/test
14+
apt-get -y update
15+
apt-get -yq install curl git-core g++-6 binutils-dev ninja-build
16+
echo "export CC=gcc-6" >> $BASH_ENV
17+
echo "export CXX=g++-6" >> $BASH_ENV
18+
# install CMake
19+
curl -L -o cmake-x64.tar.gz https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.tar.gz
20+
mkdir cmake-x64
21+
tar -xf cmake-x64.tar.gz --strip 1 -C cmake-x64
22+
echo "export PATH=$PWD/cmake-x64/bin:$PATH" >> $BASH_ENV
23+
else
24+
# install CMake
25+
curl -L -o cmake-x64.tar.gz https://cmake.org/files/v3.10/cmake-3.10.0-Darwin-x86_64.tar.gz
26+
mkdir cmake-x64
27+
tar -xf cmake-x64.tar.gz --strip 3 -C cmake-x64
28+
# install Ninja
29+
curl -OL https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip
30+
mkdir ninja
31+
tar -xf ninja-mac.zip -C ninja
32+
echo "export PATH=$PWD/cmake-x64/bin:$PWD/ninja:$PATH" >> $BASH_ENV
33+
fi
34+
- checkout
35+
- run:
36+
name: Checkout git submodules
37+
command: git submodule update --init --recursive
38+
- run:
39+
name: Build LLVM
40+
command: |
41+
cd ..
42+
echo "$PATH"
43+
ninja --version
44+
cmake --version
45+
mkdir ninja-llvm
46+
cd ninja-llvm
47+
if [ "$CI_OS" = "linux" ]; then
48+
extraCMakeFlags="-DLLVM_BINUTILS_INCDIR=/usr/include -DCMAKE_CXX_FLAGS=-static-libstdc++"
49+
else
50+
extraCMakeFlags="-DLLVM_ENABLE_LIBCXX=True -DHAVE_FUTIMENS=0"
51+
fi
52+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/llvm-x64 -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM;PowerPC;NVPTX" -DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS $extraCMakeFlags $CIRCLE_WORKING_DIRECTORY
53+
ninja -j3 install
54+
cd ..
55+
- run:
56+
name: Build compiler-rt & libFuzzer
57+
command: |
58+
cd ..
59+
LLVM_VERSION=$(llvm-x64/bin/llvm-config --version)
60+
LLVM_VERSION=${LLVM_VERSION:0:5}
61+
echo "$LLVM_VERSION"
62+
# Download & extract compiler-rt
63+
curl -OL http://releases.llvm.org/$LLVM_VERSION/compiler-rt-$LLVM_VERSION.src.tar.xz
64+
tar -xf compiler-rt-$LLVM_VERSION.src.tar.xz --no-same-owner
65+
# Build compiler-rt
66+
mkdir ninja-compiler-rt
67+
cd ninja-compiler-rt
68+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/llvm-x64/lib/clang/$LLVM_VERSION -DLLVM_CONFIG_PATH=$(dirname $PWD)/llvm-x64/bin/llvm-config ../compiler-rt-$LLVM_VERSION.src
69+
ninja -j3 install
70+
cd ..
71+
# Build libFuzzer
72+
mkdir libFuzzer
73+
cd libFuzzer
74+
if [ "$CI_OS" = "linux" ]; then
75+
../project/lib/Fuzzer/build.sh
76+
else
77+
# OSX needs additional `-stdlib=libc++`
78+
for f in ../project/lib/Fuzzer/*.cpp; do
79+
${CXX:-clang} -g -O2 -fno-omit-frame-pointer -std=c++11 $f -c -stdlib=libc++ &
80+
done
81+
wait
82+
ar ru libFuzzer.a Fuzzer*.o
83+
fi
84+
cp libFuzzer.a ../llvm-x64/lib
85+
cd ..
86+
- run:
87+
name: Pack installation dir
88+
no_output_timeout: 20m
89+
command: |
90+
cd ..
91+
mkdir artifacts
92+
assertsSuffix=""
93+
if [ "$LLVM_ENABLE_ASSERTIONS" = "ON" ]; then assertsSuffix="-withAsserts"; fi
94+
if [ -z "$CIRCLE_TAG" ]; then
95+
artifactBasename="llvm-${CIRCLE_SHA1:0:8}-$CI_OS-x86_64$assertsSuffix-$(date "+%Y%m%d")"
96+
else
97+
artifactBasename="llvm-${CIRCLE_TAG:5}-$CI_OS-x86_64$assertsSuffix"
98+
fi
99+
mv llvm-x64 $artifactBasename
100+
XZ_OPT=-9 tar -cJf "artifacts/$artifactBasename.tar.xz" $artifactBasename
101+
- run:
102+
name: Pack source dir
103+
command: |
104+
cd ..
105+
if [[ "$CI_OS" = "linux" && "$LLVM_ENABLE_ASSERTIONS" = "OFF" ]]; then
106+
if [ -z "$CIRCLE_TAG" ]; then
107+
artifactBasename="llvm-${CIRCLE_SHA1:0:8}.src"
108+
else
109+
artifactBasename="llvm-${CIRCLE_TAG:5}.src"
110+
fi
111+
XZ_OPT=-9 tar -cJf "artifacts/$artifactBasename.tar.xz" --exclude-vcs --transform=s/project/$artifactBasename/ project
112+
fi
113+
- store_artifacts:
114+
path: ../artifacts
115+
- run:
116+
name: Deploy to GitHub CI release
117+
command: |
118+
cd ..
119+
if [ "$CI_OS" = "linux" ]; then
120+
curl -L -o github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2
121+
else
122+
curl -L -o github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.7.2/darwin-amd64-github-release.tar.bz2
123+
fi
124+
tar -xf github-release.tar.bz2 --strip 3
125+
if [ -z "$CIRCLE_TAG" ]; then CIRCLE_TAG="CI"; fi
126+
# Note: needs GITHUB_TOKEN environment variable
127+
./github-release upload --user ldc-developers --repo llvm --tag $CIRCLE_TAG --name "$(cd artifacts && ls llvm-*x86_64*.tar.xz)" --file artifacts/llvm-*x86_64*.tar.xz
128+
if [[ "$CI_OS" = "linux" && "$LLVM_ENABLE_ASSERTIONS" = "OFF" ]]; then
129+
./github-release upload --user ldc-developers --repo llvm --tag $CIRCLE_TAG --name "$(cd artifacts && ls llvm-*src.tar.xz)" --file artifacts/llvm-*src.tar.xz
130+
fi
131+
132+
version: 2
133+
jobs:
134+
build-linux:
135+
<<: *commonSteps
136+
docker:
137+
- image: ubuntu:14.04
138+
environment:
139+
- CI_OS: "linux"
140+
- LLVM_ENABLE_ASSERTIONS: "OFF"
141+
build-linux-withAsserts:
142+
<<: *commonSteps
143+
docker:
144+
- image: ubuntu:14.04
145+
environment:
146+
- CI_OS: "linux"
147+
- LLVM_ENABLE_ASSERTIONS: "ON"
148+
build-osx:
149+
<<: *commonSteps
150+
macos:
151+
xcode: "9.0"
152+
environment:
153+
- CI_OS: "osx"
154+
- MACOSX_DEPLOYMENT_TARGET: 10.8
155+
- USE_LIBCPP: "true"
156+
- LLVM_ENABLE_ASSERTIONS: "OFF"
157+
build-osx-withAsserts:
158+
<<: *commonSteps
159+
macos:
160+
xcode: "9.0"
161+
environment:
162+
- CI_OS: "osx"
163+
- MACOSX_DEPLOYMENT_TARGET: 10.8
164+
- USE_LIBCPP: "true"
165+
- LLVM_ENABLE_ASSERTIONS: "ON"
166+
167+
workflows:
168+
version: 2
169+
build:
170+
jobs:
171+
- build-linux:
172+
# This is required to also trigger the job after pushing a tag.
173+
filters:
174+
tags:
175+
only: /.*/
176+
- build-osx:
177+
filters:
178+
tags:
179+
only: /.*/
180+
- build-linux-withAsserts:
181+
filters:
182+
tags:
183+
only: /.*/
184+
- build-osx-withAsserts:
185+
filters:
186+
tags:
187+
only: /.*/

appveyor.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#---------------------------------#
2+
# general configuration #
3+
#---------------------------------#
4+
5+
#version: 1.0.{build}-{branch}
6+
7+
#---------------------------------#
8+
# environment configuration #
9+
#---------------------------------#
10+
11+
environment:
12+
matrix:
13+
- APPVEYOR_JOB_ARCH: x64
14+
LLVM_ENABLE_ASSERTIONS: OFF
15+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
16+
- APPVEYOR_JOB_ARCH: x86
17+
LLVM_ENABLE_ASSERTIONS: OFF
18+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
19+
- APPVEYOR_JOB_ARCH: x64
20+
LLVM_ENABLE_ASSERTIONS: ON
21+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
22+
- APPVEYOR_JOB_ARCH: x86
23+
LLVM_ENABLE_ASSERTIONS: ON
24+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
25+
26+
# scripts that are called at very beginning, before repo cloning
27+
init:
28+
- git config --global core.autocrlf input
29+
30+
clone_depth: 1
31+
32+
# scripts that run after cloning repository
33+
install:
34+
- cd c:\projects
35+
# Fetch submodules
36+
- cd llvm
37+
- git submodule update --init --recursive
38+
- cd ..
39+
# Download & extract Ninja
40+
- appveyor DownloadFile "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip" -FileName ninja.zip
41+
- md ninja
42+
- cd ninja
43+
- 7z x ..\ninja.zip > nul
44+
- cd ..
45+
# Set environment variables
46+
- set PATH=%CD%\ninja;%PATH%
47+
- if "%APPVEYOR_BUILD_WORKER_IMAGE:~-4%" == "2017" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=%APPVEYOR_JOB_ARCH%
48+
- if "%APPVEYOR_BUILD_WORKER_IMAGE:~-4%" == "2015" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %APPVEYOR_JOB_ARCH%
49+
# Print environment info
50+
- set
51+
- msbuild /version
52+
- cl
53+
- cmake --version
54+
- ninja --version
55+
56+
#---------------------------------#
57+
# build configuration #
58+
#---------------------------------#
59+
60+
build_script:
61+
- cd c:\projects
62+
- md ninja-llvm
63+
- cd ninja-llvm
64+
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=c:\projects\LLVM-%APPVEYOR_JOB_ARCH% -DLLVM_USE_CRT_RELEASE=MT -DLLVM_TARGETS_TO_BUILD=X86;AArch64;ARM;PowerPC;NVPTX -DLLVM_ENABLE_ASSERTIONS=%LLVM_ENABLE_ASSERTIONS% ..\llvm
65+
- ninja -j3 install
66+
# TODO: Include compiler-rt and libFuzzer as soon as AppVeyor
67+
# doesn't scratch the timeout limit anymore.
68+
69+
after_build:
70+
# pack installation dir & publish as artifact
71+
- ps: |
72+
echo 'Preparing artifact...'
73+
cd "c:\projects\LLVM-$Env:APPVEYOR_JOB_ARCH"
74+
del bin\ld.lld.exe
75+
del bin\lld.exe
76+
$assertsSuffix = ''
77+
If ($Env:LLVM_ENABLE_ASSERTIONS -eq 'ON') {
78+
$assertsSuffix = '-withAsserts'
79+
}
80+
If (Test-Path Env:APPVEYOR_REPO_TAG_NAME) {
81+
$artifactFilename = "llvm-$($Env:APPVEYOR_REPO_TAG_NAME.Substring(5))-windows-$Env:APPVEYOR_JOB_ARCH$assertsSuffix.7z"
82+
} Else {
83+
$artifactFilename = "llvm-$($Env:APPVEYOR_REPO_COMMIT.Substring(0, 8))-windows-$Env:APPVEYOR_JOB_ARCH$assertsSuffix-$(get-date -f yyyyMMdd).7z"
84+
}
85+
# TODO: Use higher compression level (-mx=9) as soon as
86+
# AppVeyor doesn't scratch the timeout limit anymore.
87+
7z a "..\$artifactFilename" * > $null
88+
cd ..
89+
Push-AppveyorArtifact $artifactFilename
90+
91+
test: off
92+
93+
#---------------------------------#
94+
# deployment configuration #
95+
#---------------------------------#
96+
97+
deploy:
98+
- release: CI
99+
prerelease: true
100+
provider: GitHub
101+
auth_token:
102+
secure: qnbD8agL9mr0SFvy/sMkR2E29oQQ427T5zYwVVZkjRS3IZ361tG+9jlSiyEkyULy
103+
artifact: /llvm-.*\.7z/
104+
on:
105+
appveyor_repo_tag: false
106+
- release: $(APPVEYOR_REPO_TAG_NAME)
107+
description: $(APPVEYOR_REPO_TAG_NAME)
108+
prerelease: true
109+
draft: true
110+
provider: GitHub
111+
auth_token:
112+
secure: qnbD8agL9mr0SFvy/sMkR2E29oQQ427T5zYwVVZkjRS3IZ361tG+9jlSiyEkyULy
113+
artifact: /llvm-.*\.7z/
114+
on:
115+
appveyor_repo_tag: true

0 commit comments

Comments
 (0)