Skip to content

Commit 83bcd9c

Browse files
author
田凯夫
committed
Chapter 1
0 parents  commit 83bcd9c

22 files changed

Lines changed: 1378 additions & 0 deletions

.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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Jobs
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
rust_toolchain: nightly-2022-08-05
8+
9+
jobs:
10+
build-doc:
11+
if: github.repository == 'LearningOS/rCore-Tutorial-Code-2023S'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
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 }}
26+
basic-test:
27+
runs-on: ubuntu-latest
28+
container:
29+
image: duskmoon/dev-env:rcore-ci
30+
steps:
31+
- uses: actions/checkout@v3
32+
- name: Run tests
33+
run: |
34+
qemu-system-riscv64 --version
35+
rustup target add riscv64gc-unknown-none-elf
36+
cd os && make run
37+
gitlab-mirror:
38+
if: github.repository == 'LearningOS/rCore-Tutorial-Code-2023S'
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v1
42+
- name: Mirror + trigger CI
43+
uses: Gallium70/gitlab-mirror-and-ci-action@master
44+
with:
45+
args: "https://git.tsinghua.edu.cn/os-lab/2023s/public/rcore-tutorial-code-2023s"
46+
env:
47+
GITLAB_HOSTNAME: "git.tsinghua.edu.cn"
48+
GITLAB_PROJECT_ID: "20881"
49+
GITLAB_PROJECT_NAME: "rcore-tutorial-code-2023s"
50+
GITLAB_PROJECT_TOKEN: ${{secrets.GITLAB_PROJECT_TOKEN}}
51+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.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)