forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
193 lines (183 loc) · 5.38 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
FROM ubuntu:24.04
LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
VOLUME "/var/source"
ARG TARGETPLATFORM
# Ensure TARGETPLATFORM is set
RUN case ${TARGETPLATFORM} in \
"linux/amd64") \
echo "Building for linux/amd64" \
;; \
"linux/arm64") \
echo "Building for linux/arm64" \
;; \
*) \
if [ -z "$TARGETPLATFORM" ] ;\
then \
echo "TARGETPLATFORM not defined! Please run from buildkit (buildx)." \
&& return 1 ;\
else \
echo "Unsupported platform ${TARGETPLATFORM}." \
&& return 1 ;\
fi \
;; \
esac
# base build and check tools and libraries layer
RUN set -x \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing --no-install-recommends \
autoconf \
automake \
bison \
bridge-utils \
ccache \
clang \
clang-format \
clang-tidy \
cmake \
curl \
flex \
g++ \
generate-ninja \
git \
git-lfs \
gperf \
iproute2 \
jq \
lcov \
libavahi-client-dev \
libavahi-common-dev \
libcairo2-dev \
libcairo-dev \
libdbus-1-dev \
libdbus-glib-1-dev \
libdmalloc-dev \
libgif-dev \
libgirepository-1.0-1 \
libglib2.0-dev \
libical-dev \
libjpeg-dev \
libmbedtls-dev \
libncurses5-dev \
libncursesw5-dev \
libnl-3-dev \
libnl-route-3-dev \
libnspr4-dev \
libpango1.0-dev \
libpixman-1-dev \
libreadline-dev \
libsdl2-dev \
libsdl-pango-dev \
libssl-dev \
libtool \
libudev-dev \
libusb-1.0-0 \
libusb-dev \
libxml2-dev \
make \
meson \
net-tools \
ninja-build \
nodejs \
patch \
pkg-config \
python3 \
python3-click \
python3-coloredlogs \
python3-dev \
python3-future \
python3-pandas \
python3-pip \
python3-tabulate \
python3-venv \
python-is-python3 \
rsync \
shellcheck \
strace \
systemd \
udev \
unzip \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/ \
&& git lfs install \
&& : # last line
# NOTE: this install is NOT ideal as we are installing over system
# we should migrate to venvs for packages we do not directly have
# provided by the system
RUN set -x \
&& pip3 install --break-system-packages --no-cache-dir --break-system-packages \
attrs \
cxxfilt \
ghapi \
mobly \
portpicker \
pygit \
PyGithub \
ruff \
&& : # last line
# Install bloat comparison tools
RUN set -x \
&& git clone https://github.com/google/bloaty.git \
&& mkdir -p bloaty/build \
&& cd bloaty/build \
&& cmake -DCMAKE_BUILD_TYPE=MinSizeRel ../ \
&& make -j$(nproc) \
&& strip bloaty \
&& make install \
&& cd ../.. \
&& rm -rf bloaty \
&& : # last line
# Need newer version of include-what-you-use
RUN set -x \
&& apt-get update \
# Install build and runtime requirements for IWYU
&& DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-18 libclang-18-dev llvm-18-dev \
# Build and install IWYU
&& git clone --depth=1 --branch=clang_18 https://github.com/include-what-you-use/include-what-you-use.git \
&& mkdir -p include-what-you-use/build \
&& cd include-what-you-use/build \
&& cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 -DIWYU_LINK_CLANG_DYLIB=OFF .. \
&& make -j$(nproc) \
&& strip bin/include-what-you-use \
&& make install \
# Save clang-18 files, so we can restore them after build dependencies cleanup
# AWK logic converts 'libLLVM.so.18.1 => /usr/lib/llvm-18/lib/libLLVM.so.18.1 (0x00007f781ede6000)' to '/usr/lib/llvm-18/lib/libLLVM.so.18.1'
&& tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) $(ldd bin/include-what-you-use | grep /usr/lib/llvm | awk '{print $3}') /usr/lib/llvm-18/lib/libLLVM.so.1 \
# Cleanup build dependencies
&& apt autopurge -fy clang-18 libclang-18-dev llvm-18-dev \
&& rm -rf /var/lib/apt/lists/ \
# Restore clang-18 files
&& tar -xf clang-18-files.tar -C / \
# Cleanup
&& cd ../.. \
&& rm -rf include-what-you-use \
&& : # last line
# Build glib-2.0 from source with enabled thread sanitizer. This is needed for
# running CHIP tests with TSAN enabled. When running applications with TSAN
# all shared libraries should be built with TSAN enabled, otherwise TSAN might
# report false positives. This case is most prominent with glib-2.0, which has
# a lot of threads-related APIs.
ENV LD_LIBRARY_PATH_TSAN=/usr/lib/x86_64-linux-gnu-tsan
RUN case ${TARGETPLATFORM} in \
"linux/amd64") \
set -x \
&& mkdir -p $LD_LIBRARY_PATH_TSAN \
&& export CCACHE_DISABLE=1 PYTHONDONTWRITEBYTECODE=1 \
&& GLIB_VERSION=$(pkg-config --modversion glib-2.0) \
&& git clone --depth=1 --branch=$GLIB_VERSION https://github.com/GNOME/glib.git \
&& CFLAGS="-O2 -g -fsanitize=thread" meson glib/build glib -Dtests=false \
&& DESTDIR=../build-image ninja -C glib/build install \
&& mv glib/build-image/usr/local/lib64/lib* $LD_LIBRARY_PATH_TSAN \
&& rm -rf glib \
;; \
"linux/arm64") \
echo "ARM64 unsupported with TSAN" \
;; \
*) \
echo "Unsupported platform ${TARGETPLATFORM}" \
&& return 1 ;\
;; \
esac
# Some things that save space
# Protoc goes from 108M to 4.6M
RUN strip /usr/local/bin/protoc*