Skip to content

Commit 4218f52

Browse files
committed
Merge pull request #134 from cndoit18/add-devcontainer
feat: support devcontainer
1 parent 9aaad91 commit 4218f52

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "rcore-tutorial-v3",
3+
"build": {
4+
"dockerfile": "../Dockerfile",
5+
"args": {
6+
"QEMU_VERSION": "7.0.0",
7+
"DEBIAN_FRONTEND": "noninteractive",
8+
"GDB_VERSION": "14.1"
9+
}
10+
},
11+
"postCreateCommand": "rustup show",
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"rust-lang.rust-analyzer",
16+
"ms-vscode.cpptools",
17+
"tamasfe.even-better-toml"
18+
]
19+
}
20+
}
21+
}

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.*/*
22
!.github/*
33
!.vscode/settings.json
4+
!.devcontainer/devcontainer.json
5+
46
.idea
5-
Cargo.lock
6-
target
7+
**/Cargo.lock
8+
**/target/
9+
710
os/src/link_app.S
811
os/src/linker.ld
912
os/last-*

Dockerfile

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
FROM ubuntu:20.04
88

99
ARG QEMU_VERSION=7.0.0
10+
ARG GDB_VERSION=14.1
1011
ARG HOME=/root
1112

1213
# 0. Install general tools
1314
ARG DEBIAN_FRONTEND=noninteractive
1415
RUN apt-get update && \
1516
apt-get install -y \
16-
curl \
17-
git \
18-
python3 \
19-
wget
17+
curl \
18+
git \
19+
python3 \
20+
wget
2021

2122
# 1. Set up QEMU RISC-V
2223
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
@@ -29,23 +30,33 @@ WORKDIR ${HOME}
2930
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
3031
tar xvJf qemu-${QEMU_VERSION}.tar.xz
3132

33+
RUN wget https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz && \
34+
tar xvJf gdb-${GDB_VERSION}.tar.xz
35+
3236
# 1.2. Install dependencies
3337
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
3438
RUN apt-get install -y \
35-
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
36-
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
37-
zlib1g-dev libexpat-dev git \
38-
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
39+
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
40+
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
41+
zlib1g-dev libexpat-dev git \
42+
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev \
43+
libncurses5-dev python2 python2-dev libreadline-dev tmux
44+
3945

4046
# 1.3. Build and install from source
4147
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
4248
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
4349
make -j$(nproc) && \
4450
make install
4551

52+
WORKDIR ${HOME}/gdb-${GDB_VERSION}
53+
RUN ./configure --prefix=/usr/local --target=riscv64-unknown-elf --enable-tui=yes && \
54+
make -j$(nproc) && \
55+
make install
56+
4657
# 1.4. Clean up
4758
WORKDIR ${HOME}
48-
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
59+
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz ${HOME}/gdb-${GDB_VERSION} gdb-${GDB_VERSION}.tar.xz
4960

5061
# 1.5. Sanity checking
5162
RUN qemu-system-riscv64 --version && \
@@ -73,13 +84,5 @@ RUN rustup --version && \
7384
cargo --version && \
7485
rustc --version
7586

76-
# 3. Build env for labs
77-
# See os1/Makefile `env:` for example.
78-
# This avoids having to wait for these steps each time using a new container.
79-
RUN rustup target add riscv64gc-unknown-none-elf && \
80-
cargo install cargo-binutils --vers ~0.2 && \
81-
rustup component add rust-src && \
82-
rustup component add llvm-tools-preview
83-
8487
# Ready to go
8588
WORKDIR ${HOME}

rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ profile = "minimal"
33
# use the nightly version of the last stable toolchain, see <https://forge.rust-lang.org/>
44
channel = "nightly-2024-01-18"
55
components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]
6+
targets = ["riscv64gc-unknown-none-elf"]

0 commit comments

Comments
 (0)