mirror of https://gitlab.com/qemu-project/qemu
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
4.3 KiB
Docker
146 lines
4.3 KiB
Docker
# syntax = docker/dockerfile:1.5
|
|
|
|
ARG EMSDK_VERSION_QEMU=3.1.50
|
|
ARG ZLIB_VERSION=1.3.1
|
|
ARG GLIB_MINOR_VERSION=2.84
|
|
ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
|
|
ARG PIXMAN_VERSION=0.44.2
|
|
ARG FFI_VERSION=v3.4.7
|
|
ARG MESON_VERSION=1.5.0
|
|
|
|
FROM emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base
|
|
ARG MESON_VERSION
|
|
ENV TARGET=/builddeps/target
|
|
ENV CPATH="$TARGET/include"
|
|
ENV PKG_CONFIG_PATH="$TARGET/lib/pkgconfig"
|
|
ENV EM_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
|
|
ENV CFLAGS="-O3 -pthread -DWASM_BIGINT"
|
|
ENV CXXFLAGS="$CFLAGS"
|
|
ENV LDFLAGS="-sWASM_BIGINT -sASYNCIFY=1 -L$TARGET/lib"
|
|
RUN apt-get update && apt-get install -y \
|
|
autoconf \
|
|
build-essential \
|
|
libglib2.0-dev \
|
|
libtool \
|
|
pkgconf \
|
|
ninja-build \
|
|
python3-pip
|
|
RUN pip3 install meson==${MESON_VERSION} tomli
|
|
RUN mkdir /build
|
|
WORKDIR /build
|
|
RUN mkdir -p $TARGET
|
|
RUN <<EOF
|
|
cat <<EOT > /cross.meson
|
|
[host_machine]
|
|
system = 'emscripten'
|
|
cpu_family = 'wasm32'
|
|
cpu = 'wasm32'
|
|
endian = 'little'
|
|
|
|
[binaries]
|
|
c = 'emcc'
|
|
cpp = 'em++'
|
|
ar = 'emar'
|
|
ranlib = 'emranlib'
|
|
pkgconfig = ['pkg-config', '--static']
|
|
EOT
|
|
EOF
|
|
|
|
FROM build-base AS zlib-dev
|
|
ARG ZLIB_VERSION
|
|
RUN mkdir -p /zlib
|
|
RUN curl -Ls https://zlib.net/zlib-$ZLIB_VERSION.tar.xz | \
|
|
tar xJC /zlib --strip-components=1
|
|
WORKDIR /zlib
|
|
RUN emconfigure ./configure --prefix=$TARGET --static
|
|
RUN emmake make install -j$(nproc)
|
|
|
|
FROM build-base AS libffi-dev
|
|
ARG FFI_VERSION
|
|
RUN mkdir -p /libffi
|
|
RUN git clone https://github.com/libffi/libffi /libffi
|
|
WORKDIR /libffi
|
|
RUN git checkout $FFI_VERSION
|
|
RUN autoreconf -fiv
|
|
RUN emconfigure ./configure --host=wasm32-unknown-linux \
|
|
--prefix=$TARGET --enable-static \
|
|
--disable-shared --disable-dependency-tracking \
|
|
--disable-builddir --disable-multi-os-directory \
|
|
--disable-raw-api --disable-docs
|
|
RUN emmake make install SUBDIRS='include' -j$(nproc)
|
|
|
|
FROM build-base AS pixman-dev
|
|
ARG PIXMAN_VERSION
|
|
RUN mkdir /pixman/
|
|
RUN git clone https://gitlab.freedesktop.org/pixman/pixman /pixman/
|
|
WORKDIR /pixman
|
|
RUN git checkout pixman-$PIXMAN_VERSION
|
|
RUN <<EOF
|
|
cat <<EOT >> /cross.meson
|
|
[built-in options]
|
|
c_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
cpp_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
objc_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
c_link_args = [$(printf "'%s', " $LDFLAGS | sed 's/, $//')]
|
|
cpp_link_args = [$(printf "'%s', " $LDFLAGS | sed 's/, $//')]
|
|
EOT
|
|
EOF
|
|
RUN meson setup _build --prefix=$TARGET --cross-file=/cross.meson \
|
|
--default-library=static \
|
|
--buildtype=release -Dtests=disabled -Ddemos=disabled
|
|
RUN meson install -C _build
|
|
|
|
FROM build-base AS glib-dev
|
|
ARG GLIB_VERSION
|
|
ARG GLIB_MINOR_VERSION
|
|
RUN mkdir -p /stub
|
|
WORKDIR /stub
|
|
RUN <<EOF
|
|
cat <<'EOT' > res_query.c
|
|
#include <netdb.h>
|
|
int res_query(const char *name, int class,
|
|
int type, unsigned char *dest, int len)
|
|
{
|
|
h_errno = HOST_NOT_FOUND;
|
|
return -1;
|
|
}
|
|
EOT
|
|
EOF
|
|
RUN emcc ${CFLAGS} -c res_query.c -fPIC -o libresolv.o
|
|
RUN ar rcs libresolv.a libresolv.o
|
|
RUN mkdir -p $TARGET/lib/
|
|
RUN cp libresolv.a $TARGET/lib/
|
|
|
|
RUN mkdir -p /glib
|
|
RUN curl -Lks https://download.gnome.org/sources/glib/${GLIB_MINOR_VERSION}/glib-$GLIB_VERSION.tar.xz | \
|
|
tar xJC /glib --strip-components=1
|
|
|
|
COPY --link --from=zlib-dev /builddeps/ /builddeps/
|
|
COPY --link --from=libffi-dev /builddeps/ /builddeps/
|
|
|
|
WORKDIR /glib
|
|
RUN <<EOF
|
|
CFLAGS="$CFLAGS -Wno-incompatible-function-pointer-types" ;
|
|
cat <<EOT >> /cross.meson
|
|
[built-in options]
|
|
c_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
cpp_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
objc_args = [$(printf "'%s', " $CFLAGS | sed 's/, $//')]
|
|
c_link_args = [$(printf "'%s', " $LDFLAGS | sed 's/, $//')]
|
|
cpp_link_args = [$(printf "'%s', " $LDFLAGS | sed 's/, $//')]
|
|
EOT
|
|
EOF
|
|
RUN meson setup _build --prefix=$TARGET --cross-file=/cross.meson \
|
|
--default-library=static --buildtype=release --force-fallback-for=pcre2 \
|
|
-Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dnls=disabled \
|
|
-Dtests=false -Dglib_debug=disabled -Dglib_assert=false -Dglib_checks=false
|
|
# FIXME: emscripten doesn't provide some pthread functions in the final link,
|
|
# which isn't detected during meson setup.
|
|
RUN sed -i -E "/#define HAVE_POSIX_SPAWN 1/d" ./_build/config.h
|
|
RUN sed -i -E "/#define HAVE_PTHREAD_GETNAME_NP 1/d" ./_build/config.h
|
|
RUN meson install -C _build
|
|
|
|
FROM build-base
|
|
COPY --link --from=glib-dev /builddeps/ /builddeps/
|
|
COPY --link --from=pixman-dev /builddeps/ /builddeps/
|