-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.native
182 lines (169 loc) · 5.82 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
##################################################
## "build" stage
##################################################
FROM docker.io/hectorm/wasm:v61@sha256:61c2cdaac1d5cc789bc247a9c675dc88b627a7d8ab85ae7fa4c3de04d5c94d82 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=''
# Build zlib
ARG ZLIB_TREEISH=v1.3.1
ARG ZLIB_REMOTE=https://github.com/madler/zlib.git
WORKDIR ${BUILDDIR}/dep/zlib/
RUN git clone "${ZLIB_REMOTE:?}" ./ \
&& git checkout "${ZLIB_TREEISH:?}" \
&& git submodule update --init --recursive
RUN ./configure \
--prefix="${SYSROOT:?}" \
--libdir="${SYSROOT:?}"/lib \
--static
RUN make -j"$(nproc)" install
RUN pkg-config --static --exists --print-errors zlib
# 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.80.3
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 libpng
ARG LIBPNG_TREEISH=v1.6.43
ARG LIBPNG_REMOTE=https://github.com/glennrp/libpng.git
WORKDIR ${BUILDDIR}/dep/libpng/
RUN git clone "${LIBPNG_REMOTE:?}" ./ \
&& git checkout "${LIBPNG_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 PNG_STATIC=ON \
-D PNG_SHARED=OFF
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libpng
# 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
RUN ninja -C ./build/ install
RUN pkg-config --static --exists --print-errors libjpeg
# Build libwebp
ARG LIBWEBP_TREEISH=v1.4.0
ARG LIBWEBP_REMOTE=https://chromium.googlesource.com/webm/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_USE_THREAD=OFF \
-D WEBP_BUILD_CWEBP=OFF \
-D WEBP_BUILD_DWEBP=OFF \
-D WEBP_BUILD_VWEBP=OFF \
-D WEBP_BUILD_WEBPINFO=OFF \
-D WEBP_BUILD_WEBPMUX=OFF \
-D WEBP_BUILD_IMG2WEBP=OFF \
-D WEBP_BUILD_GIF2WEBP=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-2
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 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.0
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 ./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 /