Skip to content

Commit b79acad

Browse files
committed
Init the ch1
1 parent 42d7fde commit b79acad

File tree

20 files changed

+1280
-0
lines changed

20 files changed

+1280
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*/*

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Jobs
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
rust_toolchain: nightly
8+
9+
jobs:
10+
build-doc:
11+
if: github.repository == 'LearningOS/rCore-Tutorial-Code'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build doc
16+
run: |
17+
cd os
18+
make
19+
cargo doc --no-deps --verbose
20+
- name: Push to gh-pages
21+
uses: peaceiris/actions-gh-pages@v3
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
publish_dir: ./os/target/riscv64gc-unknown-none-elf/doc
25+
destination_dir: ${{ github.ref_name }}

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.*/*
2+
!.github/*
3+
!.vscode/settings.json
4+
.idea
5+
Cargo.lock
6+
target
7+
os/src/link_app.S
8+
os/last-*
9+
os/Cargo.lock
10+
os/.gdb_history
11+
user/build
12+
user/target/*
13+
user/.idea/*
14+
user/Cargo.lock
15+
easy-fs/Cargo.lock
16+
easy-fs/target/*
17+
easy-fs-fuse/Cargo.lock
18+
easy-fs-fuse/target/*
19+
tools/
20+
pushall.sh
21+
*.bak

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// Prevent "can't find crate for `test`" error on no_std
3+
// Ref: https://github.com/rust-lang/vscode-rust/issues/729
4+
// For vscode-rust plugin users:
5+
"rust.target": "riscv64gc-unknown-none-elf",
6+
"rust.all_targets": false,
7+
// For Rust Analyzer plugin users:
8+
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
9+
"rust-analyzer.checkOnSave.allTargets": false,
10+
// "rust-analyzer.cargo.features": [
11+
// "board_qemu"
12+
// ]
13+
}

Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# syntax=docker/dockerfile:1
2+
# This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
3+
# with the following major updates:
4+
# - ubuntu 18.04 -> 20.04
5+
# - qemu 5.0.0 -> 7.0.0
6+
# - Extensive comments linking to relevant documentation
7+
FROM ubuntu:20.04
8+
9+
ARG QEMU_VERSION=7.0.0
10+
ARG HOME=/root
11+
12+
# 0. Install general tools
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update && \
15+
apt-get install -y \
16+
curl \
17+
git \
18+
python3 \
19+
wget
20+
21+
# 1. Set up QEMU RISC-V
22+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
23+
# - https://www.qemu.org/download/
24+
# - https://wiki.qemu.org/Documentation/Platforms/RISCV
25+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
26+
27+
# 1.1. Download source
28+
WORKDIR ${HOME}
29+
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
30+
tar xvJf qemu-${QEMU_VERSION}.tar.xz
31+
32+
# 1.2. Install dependencies
33+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
34+
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+
40+
# 1.3. Build and install from source
41+
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
42+
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
43+
make -j$(nproc) && \
44+
make install
45+
46+
# 1.4. Clean up
47+
WORKDIR ${HOME}
48+
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
49+
50+
# 1.5. Sanity checking
51+
RUN qemu-system-riscv64 --version && \
52+
qemu-riscv64 --version
53+
54+
# 2. Set up Rust
55+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
56+
# - https://www.rust-lang.org/tools/install
57+
# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template
58+
59+
# 2.1. Install
60+
ENV RUSTUP_HOME=/usr/local/rustup \
61+
CARGO_HOME=/usr/local/cargo \
62+
PATH=/usr/local/cargo/bin:$PATH \
63+
RUST_VERSION=nightly
64+
RUN set -eux; \
65+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
66+
chmod +x rustup-init; \
67+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
68+
rm rustup-init; \
69+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
70+
71+
# 2.2. Sanity checking
72+
RUN rustup --version && \
73+
cargo --version && \
74+
rustc --version
75+
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+
84+
# Ready to go
85+
WORKDIR ${HOME}

0 commit comments

Comments
 (0)