|
| 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 incl. LLD and compiler-rt |
| 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 \ |
| 53 | + -DCMAKE_BUILD_TYPE=Release \ |
| 54 | + -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/llvm-x64 \ |
| 55 | + -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;Mips;MSP430;NVPTX;PowerPC;X86" \ |
| 56 | + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV;WebAssembly" \ |
| 57 | + -DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \ |
| 58 | + -DCOMPILER_RT_INCLUDE_TESTS=OFF \ |
| 59 | + $extraCMakeFlags \ |
| 60 | + $CIRCLE_WORKING_DIRECTORY |
| 61 | + ninja -j3 install |
| 62 | + cd .. |
| 63 | + - run: |
| 64 | + name: Pack installation dir |
| 65 | + no_output_timeout: 20m |
| 66 | + command: | |
| 67 | + cd .. |
| 68 | + mkdir artifacts |
| 69 | + assertsSuffix="" |
| 70 | + if [ "$LLVM_ENABLE_ASSERTIONS" = "ON" ]; then assertsSuffix="-withAsserts"; fi |
| 71 | + if [ -z "$CIRCLE_TAG" ]; then |
| 72 | + artifactBasename="llvm-${CIRCLE_SHA1:0:8}-$CI_OS-x86_64$assertsSuffix-$(date "+%Y%m%d")" |
| 73 | + else |
| 74 | + artifactBasename="llvm-${CIRCLE_TAG:5}-$CI_OS-x86_64$assertsSuffix" |
| 75 | + fi |
| 76 | + mv llvm-x64 $artifactBasename |
| 77 | + XZ_OPT=-9 tar -cJf "artifacts/$artifactBasename.tar.xz" $artifactBasename |
| 78 | + - run: |
| 79 | + name: Pack source dir |
| 80 | + command: | |
| 81 | + cd .. |
| 82 | + if [[ "$CI_OS" = "linux" && "$LLVM_ENABLE_ASSERTIONS" = "OFF" ]]; then |
| 83 | + if [ -z "$CIRCLE_TAG" ]; then |
| 84 | + artifactBasename="llvm-${CIRCLE_SHA1:0:8}.src" |
| 85 | + else |
| 86 | + artifactBasename="llvm-${CIRCLE_TAG:5}.src" |
| 87 | + fi |
| 88 | + XZ_OPT=-9 tar -cJf "artifacts/$artifactBasename.tar.xz" --exclude-vcs --transform=s/project/$artifactBasename/ project |
| 89 | + fi |
| 90 | + - store_artifacts: |
| 91 | + path: ../artifacts |
| 92 | + - run: |
| 93 | + name: Deploy to GitHub CI release |
| 94 | + command: | |
| 95 | + cd .. |
| 96 | + if [ "$CI_OS" = "linux" ]; then |
| 97 | + curl -L -o github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2 |
| 98 | + else |
| 99 | + curl -L -o github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.7.2/darwin-amd64-github-release.tar.bz2 |
| 100 | + fi |
| 101 | + tar -xf github-release.tar.bz2 --strip 3 |
| 102 | + if [ -z "$CIRCLE_TAG" ]; then CIRCLE_TAG="CI"; fi |
| 103 | + # Note: needs GITHUB_TOKEN environment variable |
| 104 | + ./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 |
| 105 | + if [[ "$CI_OS" = "linux" && "$LLVM_ENABLE_ASSERTIONS" = "OFF" ]]; then |
| 106 | + ./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 |
| 107 | + fi |
| 108 | +
|
| 109 | +version: 2 |
| 110 | +jobs: |
| 111 | + build-linux: |
| 112 | + <<: *commonSteps |
| 113 | + docker: |
| 114 | + - image: ubuntu:14.04 |
| 115 | + environment: |
| 116 | + - CI_OS: "linux" |
| 117 | + - LLVM_ENABLE_ASSERTIONS: "OFF" |
| 118 | + build-linux-withAsserts: |
| 119 | + <<: *commonSteps |
| 120 | + docker: |
| 121 | + - image: ubuntu:14.04 |
| 122 | + environment: |
| 123 | + - CI_OS: "linux" |
| 124 | + - LLVM_ENABLE_ASSERTIONS: "ON" |
| 125 | + build-osx: |
| 126 | + <<: *commonSteps |
| 127 | + macos: |
| 128 | + xcode: "9.2.0" |
| 129 | + environment: |
| 130 | + - CI_OS: "osx" |
| 131 | + - MACOSX_DEPLOYMENT_TARGET: 10.8 |
| 132 | + - USE_LIBCPP: "true" |
| 133 | + - LLVM_ENABLE_ASSERTIONS: "OFF" |
| 134 | + build-osx-withAsserts: |
| 135 | + <<: *commonSteps |
| 136 | + macos: |
| 137 | + xcode: "9.2.0" |
| 138 | + environment: |
| 139 | + - CI_OS: "osx" |
| 140 | + - MACOSX_DEPLOYMENT_TARGET: 10.8 |
| 141 | + - USE_LIBCPP: "true" |
| 142 | + - LLVM_ENABLE_ASSERTIONS: "ON" |
| 143 | + |
| 144 | +workflows: |
| 145 | + version: 2 |
| 146 | + build: |
| 147 | + jobs: |
| 148 | + - build-linux: |
| 149 | + # This is required to also trigger the job after pushing a tag. |
| 150 | + filters: |
| 151 | + tags: |
| 152 | + only: /.*/ |
| 153 | + - build-osx: |
| 154 | + filters: |
| 155 | + tags: |
| 156 | + only: /.*/ |
| 157 | + - build-linux-withAsserts: |
| 158 | + filters: |
| 159 | + tags: |
| 160 | + only: /.*/ |
| 161 | + - build-osx-withAsserts: |
| 162 | + filters: |
| 163 | + tags: |
| 164 | + only: /.*/ |
0 commit comments