mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 01:16:26 +04:00
Merge pull request #134 from cndoit18/add-devcontainer
feat: support devcontainer
This commit is contained in:
commit
8cd58cbe3a
21
.devcontainer/devcontainer.json
Normal file
21
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "rcore-tutorial-v3",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "../Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"QEMU_VERSION": "7.0.0",
|
||||||
|
"DEBIAN_FRONTEND": "noninteractive",
|
||||||
|
"GDB_VERSION": "14.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postCreateCommand": "rustup show",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"rust-lang.rust-analyzer",
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"tamasfe.even-better-toml"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
.*/*
|
.*/*
|
||||||
!.github/*
|
!.github/*
|
||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
|
!.devcontainer/devcontainer.json
|
||||||
|
|
||||||
**/target/
|
**/target/
|
||||||
**/Cargo.lock
|
**/Cargo.lock
|
||||||
|
23
Dockerfile
23
Dockerfile
@ -7,6 +7,7 @@
|
|||||||
FROM ubuntu:20.04
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
ARG QEMU_VERSION=7.0.0
|
ARG QEMU_VERSION=7.0.0
|
||||||
|
ARG GDB_VERSION=14.1
|
||||||
ARG HOME=/root
|
ARG HOME=/root
|
||||||
|
|
||||||
# 0. Install general tools
|
# 0. Install general tools
|
||||||
@ -29,13 +30,18 @@ WORKDIR ${HOME}
|
|||||||
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
|
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
|
||||||
tar xvJf qemu-${QEMU_VERSION}.tar.xz
|
tar xvJf qemu-${QEMU_VERSION}.tar.xz
|
||||||
|
|
||||||
|
RUN wget https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz && \
|
||||||
|
tar xvJf gdb-${GDB_VERSION}.tar.xz
|
||||||
|
|
||||||
# 1.2. Install dependencies
|
# 1.2. Install dependencies
|
||||||
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
|
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
|
||||||
RUN apt-get install -y \
|
RUN apt-get install -y \
|
||||||
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
|
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
|
||||||
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
|
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
|
||||||
zlib1g-dev libexpat-dev git \
|
zlib1g-dev libexpat-dev git \
|
||||||
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
|
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev \
|
||||||
|
libncurses5-dev python2 python2-dev libreadline-dev tmux
|
||||||
|
|
||||||
|
|
||||||
# 1.3. Build and install from source
|
# 1.3. Build and install from source
|
||||||
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
|
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
|
||||||
@ -43,9 +49,14 @@ RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
|
|||||||
make -j$(nproc) && \
|
make -j$(nproc) && \
|
||||||
make install
|
make install
|
||||||
|
|
||||||
|
WORKDIR ${HOME}/gdb-${GDB_VERSION}
|
||||||
|
RUN ./configure --prefix=/usr/local --target=riscv64-unknown-elf --enable-tui=yes && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
make install
|
||||||
|
|
||||||
# 1.4. Clean up
|
# 1.4. Clean up
|
||||||
WORKDIR ${HOME}
|
WORKDIR ${HOME}
|
||||||
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
|
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz ${HOME}/gdb-${GDB_VERSION} gdb-${GDB_VERSION}.tar.xz
|
||||||
|
|
||||||
# 1.5. Sanity checking
|
# 1.5. Sanity checking
|
||||||
RUN qemu-system-riscv64 --version && \
|
RUN qemu-system-riscv64 --version && \
|
||||||
@ -73,13 +84,5 @@ RUN rustup --version && \
|
|||||||
cargo --version && \
|
cargo --version && \
|
||||||
rustc --version
|
rustc --version
|
||||||
|
|
||||||
# 3. Build env for labs
|
|
||||||
# See os1/Makefile `env:` for example.
|
|
||||||
# This avoids having to wait for these steps each time using a new container.
|
|
||||||
RUN rustup target add riscv64gc-unknown-none-elf && \
|
|
||||||
cargo install cargo-binutils --vers ~0.2 && \
|
|
||||||
rustup component add rust-src && \
|
|
||||||
rustup component add llvm-tools-preview
|
|
||||||
|
|
||||||
# Ready to go
|
# Ready to go
|
||||||
WORKDIR ${HOME}
|
WORKDIR ${HOME}
|
||||||
|
@ -3,3 +3,4 @@ profile = "minimal"
|
|||||||
# use the nightly version of the last stable toolchain, see <https://forge.rust-lang.org/>
|
# use the nightly version of the last stable toolchain, see <https://forge.rust-lang.org/>
|
||||||
channel = "nightly-2024-01-18"
|
channel = "nightly-2024-01-18"
|
||||||
components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]
|
components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]
|
||||||
|
targets = ["riscv64gc-unknown-none-elf"]
|
||||||
|
Loading…
Reference in New Issue
Block a user