2018-10-23 22:08:57 +00:00
|
|
|
# Copyright 2018 The Chromium OS Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2018-09-20 21:39:59 +00:00
|
|
|
FROM debian:stretch
|
|
|
|
LABEL description="Test crosvm using a command like the following: \
|
2019-01-25 03:16:54 +00:00
|
|
|
docker run --privileged -v /dev/log:/dev/log -v <path to crosvm>:/platform/crosvm:ro <crosvm base image>"
|
2018-09-20 21:39:59 +00:00
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
curl \
|
|
|
|
gcc \
|
2018-10-30 16:16:30 +00:00
|
|
|
g++ \
|
2018-09-20 21:39:59 +00:00
|
|
|
git \
|
|
|
|
libcap-dev \
|
2019-04-05 19:33:58 +00:00
|
|
|
libdbus-1-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libdrm-dev \
|
2019-01-16 17:43:56 +00:00
|
|
|
libfdt-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libegl1-mesa-dev \
|
|
|
|
libgl1-mesa-dev \
|
|
|
|
libgles1-mesa-dev \
|
|
|
|
libgles2-mesa-dev \
|
2019-01-17 22:17:01 +00:00
|
|
|
libssl1.0-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libtool \
|
2018-11-30 22:10:11 +00:00
|
|
|
libusb-1.0-0-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libwayland-dev \
|
|
|
|
make \
|
|
|
|
nasm \
|
|
|
|
ninja-build \
|
|
|
|
pkg-config \
|
|
|
|
protobuf-compiler \
|
|
|
|
python3
|
|
|
|
|
|
|
|
ENV RUSTUP_HOME=/usr/local/rustup \
|
|
|
|
CARGO_HOME=/usr/local/cargo \
|
|
|
|
PATH=/usr/local/cargo/bin:$PATH \
|
2019-03-21 21:49:51 +00:00
|
|
|
RUST_VERSION=1.33.0 \
|
2019-01-17 22:17:01 +00:00
|
|
|
RUSTFLAGS='--cfg hermetic'
|
2018-09-20 21:39:59 +00:00
|
|
|
|
|
|
|
# Debian usually has an old rust version in the repository. Instead of using that, we use rustup to
|
|
|
|
# pull in a toolchain versions of our choosing.
|
2018-10-30 16:16:30 +00:00
|
|
|
RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.14.0/x86_64-unknown-linux-gnu/rustup-init" \
|
|
|
|
&& echo "0077ff9c19f722e2be202698c037413099e1188c0c233c12a2297bf18e9ff6e7 *rustup-init" | sha256sum -c - \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& chmod +x rustup-init \
|
|
|
|
&& ./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION \
|
2018-10-23 22:08:57 +00:00
|
|
|
&& rustup component add rustfmt-preview \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& rm rustup-init \
|
|
|
|
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
|
|
|
|
&& rustup --version \
|
|
|
|
&& cargo --version \
|
|
|
|
&& rustc --version
|
|
|
|
|
|
|
|
# Warms up the cargo registry cache for future cargo runs. Cargo will still update the cache using a
|
|
|
|
# git pull, but it only needs to download files that were changed since this image was built.
|
|
|
|
RUN cargo install thisiznotarealpackage -q || true
|
|
|
|
|
|
|
|
# Used /scratch for building dependencies which are too new or don't exist on Debian stretch.
|
|
|
|
WORKDIR /scratch
|
|
|
|
|
|
|
|
# minijail does not exist in upstream linux distros.
|
|
|
|
RUN git clone https://android.googlesource.com/platform/external/minijail \
|
|
|
|
&& cd minijail \
|
|
|
|
&& make -j24 \
|
|
|
|
&& cp libminijail.so /usr/lib/x86_64-linux-gnu/
|
|
|
|
|
|
|
|
# The gbm used by upstream linux distros is not compatible with crosvm, which must use Chrome OS's
|
|
|
|
# minigbm.
|
|
|
|
RUN dpkg --force-depends -r libgbm1
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/platform/minigbm \
|
|
|
|
&& cd minigbm \
|
|
|
|
&& sed 's/-Wall/-Wno-maybe-uninitialized/g' -i Makefile \
|
|
|
|
&& make install -j24
|
|
|
|
|
|
|
|
# New libepoxy requires newer meson than is in Debian stretch.
|
|
|
|
RUN git clone https://github.com/mesonbuild/meson \
|
|
|
|
&& cd meson \
|
|
|
|
&& git checkout 0a5ff338012a00f32c3aa9d8773835accc3e4e5b \
|
|
|
|
&& ln -s $PWD/meson.py /usr/bin/meson
|
|
|
|
|
|
|
|
# New libepoxy has EGL_KHR_DEBUG entry points needed by crosvm.
|
|
|
|
RUN git clone https://github.com/anholt/libepoxy.git \
|
|
|
|
&& cd libepoxy \
|
|
|
|
&& git checkout 707f50e680ab4f1861b1e54ca6e2907aaca56c12 \
|
|
|
|
&& mkdir build \
|
|
|
|
&& cd build \
|
|
|
|
&& meson \
|
|
|
|
&& ninja install
|
|
|
|
|
|
|
|
# virglrenderer is under heavy development on master and we want the very latest.
|
|
|
|
RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git \
|
|
|
|
&& cd virglrenderer \
|
|
|
|
&& ./autogen.sh \
|
|
|
|
&& make install -j24
|
|
|
|
|
2019-01-17 22:17:01 +00:00
|
|
|
# Install libtpm2 so that tpm2-sys/build.rs does not try to build it in place in
|
|
|
|
# the read-only source directory.
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/third_party/tpm2 \
|
|
|
|
&& cd tpm2 \
|
|
|
|
&& git checkout 15260c8cd98eb10b4976d2161cd5cb9bc0c3adac \
|
|
|
|
&& make -j24 \
|
|
|
|
&& cp build/libtpm2.a /lib
|
|
|
|
|
2019-03-05 18:46:37 +00:00
|
|
|
# Install librendernodehost
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/platform2 \
|
|
|
|
&& cd platform2 \
|
|
|
|
&& git checkout 226fc35730a430344a68c34d7fe7d613f758f417 \
|
|
|
|
&& cd rendernodehost \
|
|
|
|
&& gcc -c src.c -o src.o \
|
|
|
|
&& ar rcs librendernodehost.a src.o \
|
|
|
|
&& cp librendernodehost.a /lib
|
|
|
|
|
2019-04-05 19:33:58 +00:00
|
|
|
# Set up sysroot from which system_api proto files are built.
|
|
|
|
ENV SYSROOT=/sysroot
|
|
|
|
RUN mkdir -p $SYSROOT/usr/include/chromeos/dbus/trunks \
|
|
|
|
&& cp platform2/trunks/interface.proto \
|
|
|
|
$SYSROOT/usr/include/chromeos/dbus/trunks
|
|
|
|
|
2019-01-17 22:17:01 +00:00
|
|
|
# Inform pkg-config where libraries we install are placed.
|
|
|
|
COPY pkgconfig/* /usr/lib/pkgconfig
|
|
|
|
|
2018-09-20 21:39:59 +00:00
|
|
|
# Reduces image size and prevents accidentally using /scratch files
|
|
|
|
RUN rm -r /scratch /usr/bin/meson
|
|
|
|
|
|
|
|
# The manual installation of shared objects requires an ld.so.cache refresh.
|
|
|
|
RUN ldconfig
|
|
|
|
|
2019-01-22 02:33:21 +00:00
|
|
|
# Pull down repositories that crosvm depends on to cros checkout-like locations.
|
|
|
|
ENV CROS_ROOT=/
|
|
|
|
ENV THIRD_PARTY_ROOT=$CROS_ROOT/third_party
|
|
|
|
RUN mkdir -p $THIRD_PARTY_ROOT
|
2019-01-24 06:44:17 +00:00
|
|
|
ENV PLATFORM_ROOT=$CROS_ROOT/platform
|
|
|
|
RUN mkdir -p $PLATFORM_ROOT
|
|
|
|
|
2019-01-22 02:33:21 +00:00
|
|
|
# Pull the cras library for audio access.
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/third_party/adhd $THIRD_PARTY_ROOT/adhd
|
|
|
|
|
2019-01-25 03:16:54 +00:00
|
|
|
# The /build directory is used so that the bind mounted /platform/crosvm volume
|
|
|
|
# does not get scribbled on.
|
2018-09-20 21:39:59 +00:00
|
|
|
ENV CARGO_TARGET_DIR=/build
|
|
|
|
RUN mkdir -p $CARGO_TARGET_DIR
|
2019-01-25 03:16:54 +00:00
|
|
|
WORKDIR /platform/crosvm
|
2019-02-13 23:54:36 +00:00
|
|
|
CMD rustup default "$(cat rust-toolchain)" && \
|
|
|
|
rustup component add rustfmt-preview && \
|
|
|
|
cargo --version && rustc --version && rustfmt --version && \
|
2018-11-07 22:02:57 +00:00
|
|
|
echo "Running cargo test" && \
|
2018-12-14 04:42:40 +00:00
|
|
|
cargo test --no-fail-fast --features plugin,default-no-sandbox,wl-dmabuf,gpu,tpm,gpu-forward \
|
|
|
|
--all --exclude aarch64 $TEST_FLAGS -- \
|
2018-10-23 22:08:57 +00:00
|
|
|
--test-threads=1 $TEST_RUNNER_FLAGS && \
|
2018-11-07 22:02:57 +00:00
|
|
|
echo "Running cargo fmt" && \
|
2019-02-20 01:08:53 +00:00
|
|
|
bin/fmt --check
|