-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
83 lines (68 loc) · 2.73 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
ARG BASE_IMAGE=ubuntu:18.04
FROM $BASE_IMAGE
ARG TARGET_LLVM_VERSION=8
ARG IMAGE_REPO=bionic
ARG GCC_VERSION=7
# Depenedencies to fetch, build llvm and clang
RUN apt-get update && apt-get install -y \
wget \
gnupg2 \
lsb-release \
software-properties-common
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
# The repository name used here MUST be kept in sync with the base image version
add-apt-repository "deb http://apt.llvm.org/$IMAGE_REPO/ llvm-toolchain-$IMAGE_REPO-$TARGET_LLVM_VERSION main"
RUN apt-get update
RUN apt-get install -y \
# Build toolchains that we are targeting for compatibility with
gcc-"$GCC_VERSION" \
g++-"$GCC_VERSION" \
cmake \
# clangmetatool uses gtest
libgtest-dev \
# Depenedencies for our perl scripts
libfile-spec-native-perl
# Set up LLVM packages with depenedencies
RUN apt-get install -y \
# LLVM
llvm-"$TARGET_LLVM_VERSION" \
libllvm"$TARGET_LLVM_VERSION" \
llvm-"$TARGET_LLVM_VERSION"-dev \
# Clang & friends
clang-"$TARGET_LLVM_VERSION" \
libclang-common-"$TARGET_LLVM_VERSION"-dev \
libclang-"$TARGET_LLVM_VERSION"-dev
# LLVM 18 produces an ABI conflict
RUN if [ $TARGET_LLVM_VERSION -lt 18 ] ; then apt-get install -y libc++-"$TARGET_LLVM_VERSION"-dev; fi
# Set up build environment
ENV CC=/usr/bin/gcc-"$GCC_VERSION" \
CXX=/usr/bin/g++-"$GCC_VERSION" \
MAKEFLAGS="-j4" \
CMAKE_BUILD_PARALLEL_LEVEL=4
# Install gtest as they recommend to, for 1.8.x
RUN cd /usr/src/gtest && \
cmake . && \
make && \
find . -name "libg*" -exec mv {} /usr/lib \;
COPY . clangmetatool/
WORKDIR clangmetatool
# Build tool, run tests, and do a test install
RUN cmake \
-DClang_DIR="$(llvm-config-$TARGET_LLVM_VERSION --cmakedir)"/../clang \
-DLLVM_DIR="$(llvm-config-$TARGET_LLVM_VERSION --cmakedir)" \
-Bbuild \
-H.
RUN cmake --build build/ --target all
RUN cmake --build build/ --target test -- ARGS="--output-on-failure"
RUN cmake --build build/ --target install
# Fix includes for clangmetatool (due to ubuntu debian's clang)
RUN ln -s /usr/lib/llvm-8/include/clangmetatool /usr/include/clangmetatool
# Build skeleton
RUN mkdir skeleton/build && cd skeleton/build && \
cmake -DClang_DIR="$(llvm-config-$TARGET_LLVM_VERSION --cmakedir)"/../clang \
-Dclangmetatool_DIR="$(llvm-config-$TARGET_LLVM_VERSION --cmakedir)"/../clang .. && \
cmake --build . --target all && \
cmake --build . --target install && \
cd - && rm -rf skeleton/build
# Run the tool on itself
RUN yourtoolname $(find src skeleton -name '*.cpp') -- -std=gnu++17 -I$(llvm-config-$TARGET_LLVM_VERSION --includedir)