build(devcontainer): improve Dev Container development

The toolchain and qemu can be built inside the container + running the qemu inside the container

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-02-26 23:10:17 +00:00
parent 88a5f06325
commit 8dab45ecfd
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
3 changed files with 78 additions and 31 deletions

View File

@ -2,41 +2,44 @@ FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/ COPY ./reinstall-cmake.sh /tmp/
RUN <<EOF
if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE};
fi
rm -f /tmp/reinstall-cmake.sh
EOF
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ # Update system and set noninteractive env
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update
fi \
&& rm -f /tmp/reinstall-cmake.sh
# [Optional] Uncomment this section to install additional vcpkg ports.
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# Required packages for building gcc & binutils # Required packages for building gcc & binutils
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \ RUN apt-get -y install --no-install-recommends \
apt-get -y install --no-install-recommends \
build-essential \ build-essential \
bison \ bison \
flex flex \
libgmp-dev \
libmpfr-dev \
texinfo \
file \
sudo
# Required packages for building gcc & binutils # Required packages for building gcc & binutils
RUN wget https://launchpad.net/ubuntu/+archive/primary/+files/autoconf_2.69-11.1_all.deb -O /tmp/autoconf.deb && \ RUN <<EOF
sudo dpkg --force-all -i /tmp/autoconf.deb wget https://launchpad.net/ubuntu/+archive/primary/+files/autoconf_2.69-11.1_all.deb -O /tmp/autoconf.deb
sudo dpkg --force-all -i /tmp/autoconf.deb
EOF
# Required packages for building gcc & binutils # Required packages for building gcc & binutils
RUN wget https://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz -O /tmp/automake.tar.gz && \ RUN <<EOF
tar -xzf /tmp/automake.tar.gz -C /tmp && \ wget https://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz -O /tmp/automake.tar.gz
cd /tmp/automake-1.15.1 && \ tar -xzf /tmp/automake.tar.gz -C /tmp
./configure && make && sudo make install cd /tmp/automake-1.15.1
./configure && make && sudo make install
EOF
# Required packages for building qemu # Required packages for building qemu
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \ RUN apt-get -y install --no-install-recommends \
apt-get -y install --no-install-recommends \
git \ git \
libglib2.0-dev \ libglib2.0-dev \
libfdt-dev \ libfdt-dev \
@ -71,8 +74,39 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
xfslibs-dev \ xfslibs-dev \
libnfs-dev \ libnfs-dev \
libiscsi-dev \ libiscsi-dev \
python3-venv python3-venv \
libslirp-dev \
ovmf
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \ # Required packages for building test apps in userspace
apt-get -y install --no-install-recommends \ RUN apt-get -y install --no-install-recommends \
mingw-w64 mingw-w64
# Required packages for building the OS
RUN apt-get -y install --no-install-recommends \
grub2-common \
xorriso \
mtools \
grub-common \
grub-efi-amd64-bin \
grub-efi-amd64-signed \
grub-gfxpayload-lists \
grub-pc-bin \
grub-pc \
grub2-common
# Configure git
RUN <<EOF
git config --global advice.detachedHead false
git config --global core.autocrlf input
git config --global init.defaultbranch master
EOF
# Set display environment variable for QEMU
ENV DISPLAY=:0
ENV NO_AT_BRIDGE=1
# Set PATH
RUN <<EOF
echo PATH=$PATH:/workspaces/Fennix/cross/bin >> /etc/profile
EOF

View File

@ -1,7 +1,7 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the // For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp // README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{ {
"name": "C++", "name": "Fennix",
"build": { "build": {
"dockerfile": "Dockerfile" "dockerfile": "Dockerfile"
}, },
@ -17,11 +17,23 @@
"vivaxy.vscode-conventional-commits", "vivaxy.vscode-conventional-commits",
"webfreak.debug", "webfreak.debug",
"maziac.asm-code-lens", "maziac.asm-code-lens",
"Seven1bit.vscode-ext-ansi-color-highlight" "Seven1bit.vscode-ext-ansi-color-highlight",
"ms-vsliveshare.vsliveshare",
"maziac.hex-hover-converter",
"ms-vscode.makefile-tools"
] ]
} }
} },
// From this line below are for qemu, so not that important.
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
"source=${localEnv:XAUTHORITY},target=/home/vscode/.Xauthority,type=bind,consistency=cached",
"source=/dev/kvm,target=/dev/kvm,type=bind,consistency=cached",
"source=/run/user/1000/pulse/native,target=/run/user/1000/pulse/native,type=bind,consistency=cached"
],
"runArgs": [
"--privileged"
]
// Features to add to the dev container. More info: https://containers.dev/features. // Features to add to the dev container. More info: https://containers.dev/features.
// "features": {}, // "features": {},

View File

@ -12,7 +12,8 @@
"C_Cpp.autoAddFileAssociations": false, "C_Cpp.autoAddFileAssociations": false,
"conventionalCommits.scopes": [ "conventionalCommits.scopes": [
"initrd", "initrd",
"tools" "tools",
"devcontainer"
] ]
} }
} }