From 5647fb12734377f51247a4f156480b794bf3972a Mon Sep 17 00:00:00 2001 From: WangRunji Date: Mon, 16 Jul 2018 13:37:26 +0800 Subject: [PATCH] Fix build guide --- Makefile | 34 ++++++++++++++++++++++++++++++++++ README.md | 6 +++--- kernel/Makefile | 40 +--------------------------------------- 3 files changed, 38 insertions(+), 42 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3c11240 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +# used by docker_* targets +docker_image ?= blog_os +tag ?= 0.1 +pwd ?= $(realpath ./) +ifeq ($(OS),Windows_NT) +uid ?= 0 +gid ?= 0 +innerpwd ?= /root/blog_os +else +uid ?= $(shell id -u) +gid ?= $(shell id -g) +innerpwd ?= $(pwd) +endif +docker_cargo_volume ?= blogos-$(uid)-$(gid)-cargo +docker_rustup_volume ?= blogos-$(uid)-$(gid)-rustup +docker_args ?= -e LOCAL_UID=$(uid) -e LOCAL_GID=$(gid) -v $(docker_cargo_volume):/usr/local/cargo -v $(docker_rustup_volume):/usr/local/rustup -v $(pwd):$(innerpwd) -w $(innerpwd) +docker_clean_args ?= $(docker_cargo_volume) $(docker_rustup_volume) + +# docker_* targets + +docker_build: + @docker build docker/ -t $(docker_image):$(tag) + +docker_iso: + @docker run --rm $(docker_args) $(docker_image):$(tag) make iso + +docker_interactive: + @docker run -it --rm $(docker_args) $(docker_image):$(tag) + +docker_clean: + @docker volume rm $(docker_clean_args) + +docker_riscv: + @docker run -it --rm $(docker_args) wangrunji0408/riscv-rust \ No newline at end of file diff --git a/README.md b/README.md index 462132c..3178d53 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ Available on DockerHub: `wangrunji0408/riscv-rust` ```bash git clone https://github.com/wangrunji0408/RustOS.git -b riscv --recursive -cd RustOS/kernel +cd RustOS # Pull docker image and enter docker interactive shell make docker_riscv # Inside docker ... +cd kernel # Patch the atomic mod of core lib make patch-core -make build -make justrun +make run ``` ## Summary diff --git a/kernel/Makefile b/kernel/Makefile index 04f8612..63c4538 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -162,42 +162,4 @@ $(riscv_user_img_obj): ../user/user-riscv.img # patch Rust core for RISCV32I atomic patch-core: - @patch -p0 /rust/rust-riscv-rust-1.26.0-1-dev/src/libcore/sync/atomic.rs src/arch/riscv32/atomic.patch - -# used by docker_* targets -docker_image ?= blog_os -tag ?= 0.1 -pwd ?= $(realpath ./) -ifeq ($(OS),Windows_NT) -uid ?= 0 -gid ?= 0 -innerpwd ?= /root/blog_os -else -uid ?= $(shell id -u) -gid ?= $(shell id -g) -innerpwd ?= $(pwd) -endif -docker_cargo_volume ?= blogos-$(uid)-$(gid)-cargo -docker_rustup_volume ?= blogos-$(uid)-$(gid)-rustup -docker_args ?= -e LOCAL_UID=$(uid) -e LOCAL_GID=$(gid) -v $(docker_cargo_volume):/usr/local/cargo -v $(docker_rustup_volume):/usr/local/rustup -v $(pwd):$(innerpwd) -w $(innerpwd) -docker_clean_args ?= $(docker_cargo_volume) $(docker_rustup_volume) - -# docker_* targets - -docker_build: - @docker build docker/ -t $(docker_image):$(tag) - -docker_iso: - @docker run --rm $(docker_args) $(docker_image):$(tag) make iso - -docker_run: docker_iso - @qemu-system-$(arch) -cdrom $(iso) -s - -docker_interactive: - @docker run -it --rm $(docker_args) $(docker_image):$(tag) - -docker_clean: - @docker volume rm $(docker_clean_args) - -docker_riscv: - @docker run -it --rm $(docker_args) wangrunji0408/riscv-rust \ No newline at end of file + @patch -p0 /rust/rust-riscv-rust-1.26.0-1-dev/src/libcore/sync/atomic.rs src/arch/riscv32/atomic.patch \ No newline at end of file