mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
Add new dev container and install-deps scripts
The new container just provides a standard debian box with a rust toolchain. Installation of dependencies has been extracted into scripts which can also be used to set up a machine for development. This will replace the current ./ci/ containers. BUG=b:199950887,b:199950423 TEST=./tools/dev_container ./tools/run_tests Change-Id: I832bc5b129246923df937a34614b4d74955304dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221781 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
This commit is contained in:
parent
af0144e51b
commit
c4ec996103
8 changed files with 212 additions and 0 deletions
5
.devcontainer/devcontainer.json
Normal file
5
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"image": "gcr.io/crosvm-packages/crosvm_dev:latest",
|
||||
"extensions": [
|
||||
]
|
||||
}
|
27
tools/dev_container
Executable file
27
tools/dev_container
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2021 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.
|
||||
|
||||
set -e
|
||||
cd "$(dirname $0)/.."
|
||||
|
||||
docker_args=(
|
||||
--rm
|
||||
--volume $(pwd):/workspace:rw
|
||||
--device /dev/net/tun
|
||||
--device /dev/kvm
|
||||
--volume /dev/log:/dev/log
|
||||
--privileged
|
||||
)
|
||||
|
||||
# Enable interactive mode when running in an interactive terminal.
|
||||
if [ -t 1 ]; then
|
||||
docker_args+=(-it)
|
||||
fi
|
||||
|
||||
docker run \
|
||||
${docker_args[@]} \
|
||||
gcr.io/crosvm-packages/crosvm_dev:$(cat tools/impl/dev_container/version) \
|
||||
"$@"
|
||||
|
43
tools/impl/dev_container/Dockerfile
Normal file
43
tools/impl/dev_container/Dockerfile
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2021 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.
|
||||
ARG RUST_VERSION
|
||||
FROM docker.io/rust:${RUST_VERSION}-slim-bullseye
|
||||
|
||||
# Use a dedicated target directory so we do not write into the source directory.
|
||||
RUN mkdir -p /scratch/cargo_target
|
||||
ENV CARGO_TARGET_DIR=/scratch/cargo_target
|
||||
|
||||
# Prevent the container from writing root-owned __pycache__ files into the src.
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Add foreign architectures for cross-compilation.
|
||||
RUN dpkg --add-architecture arm64 \
|
||||
&& dpkg --add-architecture armhf
|
||||
|
||||
# Install dependencies for native builds.
|
||||
COPY tools/install-deps /tools/
|
||||
RUN apt-get update \
|
||||
&& apt-get install --yes sudo \
|
||||
&& /tools/install-deps \
|
||||
# Clear apt cache to save space in layer.
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
# Delete build artifacts from 'cargo install' to save space in layer.
|
||||
&& rm -rf /scratch/cargo_target/*
|
||||
|
||||
# Install cross-compilation dependencies.
|
||||
COPY tools/install-aarch64-deps tools/install-armhf-deps /tools/
|
||||
RUN apt-get update \
|
||||
&& /tools/install-aarch64-deps \
|
||||
&& /tools/install-armhf-deps \
|
||||
# Clear apt cache to save space in layer.
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Prebuild aarch64 VM image for faster startup.
|
||||
COPY tools/aarch64vm /tools/
|
||||
COPY /tools/impl/testvm.py /tools/impl/
|
||||
COPY /tools/impl/testvm/version /tools/impl/testvm/
|
||||
RUN /tools/aarch64vm build
|
||||
|
||||
VOLUME /workspace
|
||||
WORKDIR /workspace
|
36
tools/impl/dev_container/Makefile
Normal file
36
tools/impl/dev_container/Makefile
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2021 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.
|
||||
#
|
||||
# To locally build the docker container for usage with dev_container:
|
||||
#
|
||||
# make -C tools/impl/dev_container crosvm_dev
|
||||
#
|
||||
# To upload a new version of the container, uprev the `version` file and run;
|
||||
#
|
||||
# make -C tools/impl/dev_container upload
|
||||
#
|
||||
# You need write permission to the crosvm-packages cloud registry to do so.
|
||||
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
TAG_BASE=gcr.io/crosvm-packages
|
||||
VERSION=$(shell cat version)
|
||||
RUST_VERSION=$(shell cat ../../../rust-toolchain)
|
||||
BUILD_CONTEXT=$(shell realpath ../../../)
|
||||
|
||||
DOCKER ?= docker
|
||||
|
||||
all: crosvm_dev
|
||||
|
||||
upload: all
|
||||
$(DOCKER) push $(TAG_BASE)/crosvm_dev:$(VERSION)
|
||||
|
||||
crosvm_dev:
|
||||
$(DOCKER) build \
|
||||
--build-arg RUST_VERSION=$(RUST_VERSION) \
|
||||
-t $(TAG_BASE)/$@:$(VERSION) \
|
||||
-f Dockerfile \
|
||||
$(BUILD_CONTEXT)
|
||||
|
||||
.PHONY: all crosvm_dev upload
|
1
tools/impl/dev_container/version
Normal file
1
tools/impl/dev_container/version
Normal file
|
@ -0,0 +1 @@
|
|||
r0001
|
28
tools/install-aarch64-deps
Executable file
28
tools/install-aarch64-deps
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2021 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.
|
||||
set -ex
|
||||
|
||||
sudo apt-get install --yes --no-install-recommends \
|
||||
g++-aarch64-linux-gnu \
|
||||
gcc-aarch64-linux-gnu \
|
||||
ipxe-qemu \
|
||||
libc-dev:arm64 \
|
||||
libcap-dev:arm64 \
|
||||
libdbus-1-dev:arm64 \
|
||||
libdrm-dev:arm64 \
|
||||
libepoxy-dev:arm64 \
|
||||
libssl-dev:arm64 \
|
||||
libwayland-dev:arm64 \
|
||||
libxext-dev:arm64 \
|
||||
qemu-efi-aarch64 \
|
||||
qemu-system-aarch64 \
|
||||
qemu-user-static
|
||||
|
||||
rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
# Generate a cross file for meson to compile for aarch64
|
||||
sudo mkdir -p -m 0755 /usr/local/share/meson/cross
|
||||
sudo /usr/share/meson/debcrossgen --arch arm64 \
|
||||
-o /usr/local/share/meson/cross/aarch64
|
24
tools/install-armhf-deps
Executable file
24
tools/install-armhf-deps
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2021 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.
|
||||
set -ex
|
||||
|
||||
sudo apt-get install --yes --no-install-recommends \
|
||||
g++-arm-linux-gnueabihf \
|
||||
gcc-arm-linux-gnueabihf \
|
||||
libc-dev:armhf \
|
||||
libcap-dev:armhf \
|
||||
libdbus-1-dev:armhf \
|
||||
libdrm-dev:armhf \
|
||||
libepoxy-dev:armhf \
|
||||
libssl-dev:armhf \
|
||||
libwayland-dev:armhf \
|
||||
libxext-dev:armhf
|
||||
|
||||
rustup target add armv7-unknown-linux-gnueabihf
|
||||
|
||||
# Generate a cross file for meson to compile for armhf
|
||||
sudo mkdir -p -m 0755 /usr/local/share/meson/cross
|
||||
sudo /usr/share/meson/debcrossgen --arch armhf \
|
||||
-o /usr/local/share/meson/cross/armhf
|
48
tools/install-deps
Executable file
48
tools/install-deps
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2021 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.
|
||||
set -ex
|
||||
|
||||
sudo apt-get install --yes --no-install-recommends \
|
||||
ca-certificates \
|
||||
clang \
|
||||
cloud-image-utils \
|
||||
curl \
|
||||
dpkg-dev \
|
||||
expect \
|
||||
g++ \
|
||||
gcc \
|
||||
git \
|
||||
jq \
|
||||
libasound2-dev \
|
||||
libcap-dev \
|
||||
libclang-dev \
|
||||
libdbus-1-dev \
|
||||
libdrm-dev \
|
||||
libepoxy-dev \
|
||||
libssl-dev \
|
||||
libwayland-dev \
|
||||
libxext-dev \
|
||||
make \
|
||||
meson \
|
||||
nasm \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
pkg-config \
|
||||
protobuf-compiler \
|
||||
python3 \
|
||||
python3-setuptools \
|
||||
qemu-system-x86 \
|
||||
rsync \
|
||||
screen \
|
||||
wayland-protocols
|
||||
|
||||
|
||||
# The bindgen tool is required to build a crosvm dependency.
|
||||
cargo install bindgen
|
||||
|
||||
# The mdbook and mdbook-mermaid tools are used to build the crosvm book.
|
||||
cargo install mdbook --no-default-features --version "^0.4.10"
|
||||
cargo install mdbook-mermaid --version "^0.8.3"
|
||||
|
Loading…
Reference in a new issue