-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.native
263 lines (247 loc) · 8.68 KB
/
Dockerfile.native
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
##################################################
## "build" stage
##################################################
FROM docker.io/hectorm/wasm:v62@sha256:4d5b597466a797079637ecdd1042b6c800f02fdaa65b675f13f8d2f48bb698b6 AS build
# Environment
ENV BUILDDIR=/tmp/build
ENV SYSROOT=/tmp/sysroot
ENV PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
ENV PKG_CONFIG_LIBDIR=${SYSROOT}/lib/pkgconfig:${SYSROOT}/share/pkgconfig
ENV PKG_CONFIG_PATH=${PKG_CONFIG_LIBDIR}
ENV CPPFLAGS='-Wdate-time'
ENV CFLAGS='-O3 -fPIC -frandom-seed=42 -Wall -Wextra -Wformat -Werror=format-security'
ENV CXXFLAGS=${CFLAGS}
ENV LDFLAGS='-fuse-ld=mold'
# Build zlib-ng
ARG ZLIB_NG_TREEISH=2.2.1
ARG ZLIB_NG_REMOTE=https://github.com/zlib-ng/zlib-ng.git
WORKDIR ${BUILDDIR}/dep/zlib-ng/
RUN git clone "${ZLIB_NG_REMOTE:?}" ./ \
&& git checkout "${ZLIB_NG_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=OFF \
-D ZLIB_COMPAT=ON \
-D ZLIB_ENABLE_TESTS=OFF \
-D ZLIBNG_ENABLE_TESTS=OFF \
-D WITH_GTEST=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors zlib
# Build brotli
ARG BROTLI_TREEISH=v1.1.0
ARG BROTLI_REMOTE=https://github.com/google/brotli.git
WORKDIR ${BUILDDIR}/dep/brotli/
RUN git clone "${BROTLI_REMOTE:?}" ./ \
&& git checkout "${BROTLI_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_TESTING=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libbrotlidec
# Build libffi
ARG LIBFFI_TREEISH=v3.4.6
ARG LIBFFI_REMOTE=https://github.com/libffi/libffi.git
WORKDIR ${BUILDDIR}/dep/libffi/
RUN git clone "${LIBFFI_REMOTE:?}" ./ \
&& git checkout "${LIBFFI_TREEISH:?}" \
&& git submodule update --init --recursive
RUN NOCONFIGURE=1 ./autogen.sh
RUN ./configure \
--prefix="${SYSROOT:?}" \
--libdir="${SYSROOT:?}"/lib \
--enable-static \
--disable-shared \
--disable-docs
RUN make -j"$(nproc)" install
RUN pkg-config --static --exists --print-errors libffi
# Build glib
ARG GLIB_TREEISH=2.82.0
ARG GLIB_REMOTE=https://github.com/GNOME/glib.git
WORKDIR ${BUILDDIR}/dep/glib/
RUN git clone "${GLIB_REMOTE:?}" ./ \
&& git checkout "${GLIB_TREEISH:?}" \
&& git submodule update --init --recursive
RUN meson setup ./build/ \
--prefix="${SYSROOT:?}" \
--libdir="${SYSROOT:?}"/lib \
--buildtype=release \
--default-library=static \
--force-fallback-for=gvdb,zlib \
-D man-pages=disabled \
-D documentation=false \
-D tests=false \
-D nls=disabled \
-D selinux=disabled \
-D xattr=false \
-D libmount=disabled \
-D glib_assert=false \
-D glib_checks=false
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors glib-2.0
# Build highway
ARG HIGHWAY_TREEISH=1.2.0
ARG HIGHWAY_REMOTE=https://github.com/google/highway.git
WORKDIR ${BUILDDIR}/dep/highway/
RUN git clone "${HIGHWAY_REMOTE:?}" ./ \
&& git checkout "${HIGHWAY_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=OFF \
-D BUILD_TESTING=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libhwy
# Build libspng
ARG LIBSPNG_TREEISH=v0.7.4
ARG LIBSPNG_REMOTE=https://github.com/randy408/libspng.git
WORKDIR ${BUILDDIR}/dep/libspng/
RUN git clone "${LIBSPNG_REMOTE:?}" ./ \
&& git checkout "${LIBSPNG_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D SPNG_STATIC=ON \
-D SPNG_SHARED=OFF \
-D BUILD_EXAMPLES=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libspng_static
# Build libjpeg-turbo
ARG LIBJPEG_TURBO_TREEISH=3.0.3
ARG LIBJPEG_TURBO_REMOTE=https://github.com/libjpeg-turbo/libjpeg-turbo.git
WORKDIR ${BUILDDIR}/dep/libjpeg-turbo/
RUN git clone "${LIBJPEG_TURBO_REMOTE:?}" ./ \
&& git checkout "${LIBJPEG_TURBO_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D ENABLE_STATIC=ON \
-D ENABLE_SHARED=OFF \
-D WITH_JPEG8=ON \
-D WITH_TURBOJPEG=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libjpeg
# Build libjxl
ARG LIBJXL_TREEISH=v0.10.3
ARG LIBJXL_REMOTE=https://github.com/libjxl/libjxl.git
WORKDIR ${BUILDDIR}/dep/libjxl/
RUN git clone "${LIBJXL_REMOTE:?}" ./ \
&& git checkout "${LIBJXL_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D JPEGXL_STATIC=ON \
-D JPEGXL_FORCE_SYSTEM_BROTLI=ON \
-D JPEGXL_FORCE_SYSTEM_HWY=ON \
-D JPEGXL_BUNDLE_LIBPNG=OFF \
-D JPEGXL_ENABLE_JPEGLI=OFF \
-D JPEGXL_ENABLE_MANPAGES=OFF \
-D JPEGXL_ENABLE_DOXYGEN=OFF \
-D JPEGXL_ENABLE_TOOLS=OFF \
-D JPEGXL_ENABLE_VIEWERS=OFF \
-D JPEGXL_ENABLE_DEVTOOLS=OFF \
-D JPEGXL_ENABLE_EXAMPLES=OFF \
-D JPEGXL_ENABLE_COVERAGE=OFF \
-D JPEGXL_ENABLE_FUZZERS=OFF \
-D JPEGXL_ENABLE_BENCHMARK=OFF \
-D BUILD_TESTING=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libjxl
# Build libwebp
ARG LIBWEBP_TREEISH=v1.4.0
ARG LIBWEBP_REMOTE=https://github.com/webmproject/libwebp.git
WORKDIR ${BUILDDIR}/dep/libwebp/
RUN git clone "${LIBWEBP_REMOTE:?}" ./ \
&& git checkout "${LIBWEBP_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=OFF \
-D WEBP_ENABLE_SIMD=ON \
-D WEBP_BUILD_CWEBP=OFF \
-D WEBP_BUILD_DWEBP=OFF \
-D WEBP_BUILD_GIF2WEBP=OFF \
-D WEBP_BUILD_IMG2WEBP=OFF \
-D WEBP_BUILD_VWEBP=OFF \
-D WEBP_BUILD_WEBPINFO=OFF \
-D WEBP_BUILD_LIBWEBPMUX=OFF \
-D WEBP_BUILD_WEBPMUX=OFF \
-D WEBP_BUILD_ANIM_UTILS=OFF \
-D WEBP_BUILD_EXTRAS=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libwebp
# Build FreeType
ARG FREETYPE_TREEISH=VER-2-13-3
ARG FREETYPE_REMOTE=https://gitlab.freedesktop.org/freetype/freetype.git
WORKDIR ${BUILDDIR}/dep/freetype/
RUN git clone "${FREETYPE_REMOTE:?}" ./ \
&& git checkout "${FREETYPE_TREEISH:?}" \
&& git submodule update --init --recursive
RUN cmake -G 'Ninja' -S ./ -B ./build/ \
-D CMAKE_INSTALL_PREFIX="${SYSROOT:?}" \
-D CMAKE_INSTALL_LIBDIR="${SYSROOT:?}"/lib \
-D CMAKE_FIND_ROOT_PATH="${SYSROOT:?}" \
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_TESTING=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D FT_REQUIRE_ZLIB=ON \
-D FT_DISABLE_BZIP2=ON \
-D FT_DISABLE_BROTLI=ON \
-D FT_DISABLE_PNG=ON \
-D FT_DISABLE_HARFBUZZ=ON
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors freetype2
# Build Chafa
ARG CHAFA_TREEISH=1.14.4
ARG CHAFA_REMOTE=https://github.com/hpjansson/chafa.git
WORKDIR ${BUILDDIR}/dep/chafa/
RUN git clone "${CHAFA_REMOTE:?}" ./ \
&& git checkout "${CHAFA_TREEISH:?}" \
&& git submodule update --init --recursive
RUN NOCONFIGURE=1 ./autogen.sh
RUN LDFLAGS="${LDFLAGS:-} $(pkg-config --libs libbrotlicommon)" \
./configure \
--prefix="${SYSROOT:?}" \
--libdir="${SYSROOT:?}"/lib \
--enable-static \
--disable-shared \
--disable-man \
--disable-gtk-doc
RUN make -j"$(nproc)" install
RUN pkg-config --static --exists --print-errors chafa
##################################################
## "dist" stage
##################################################
FROM scratch AS dist
COPY --from=build /tmp/sysroot/bin/chafa /