From 20eb8b73f7914c86812eda4b3b14ee2d0cd5a826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 23 Nov 2020 14:52:17 +0100 Subject: userprog makefile --- halt/Cargo.toml | 23 ----------------------- halt/main.c | 5 ----- halt/rust-toolchain | 1 - halt/rust.h | 1 - halt/src/lib.rs | 19 ------------------- rust/Cargo.toml | 20 ++++++++++++++++++++ rust/Makefile | 2 ++ rust/rust-toolchain | 1 + rust/src/lib.rs | 19 +++++++++++++++++++ src/Makefile.userprog | 8 ++++++-- 10 files changed, 48 insertions(+), 51 deletions(-) delete mode 100644 halt/Cargo.toml delete mode 100644 halt/main.c delete mode 100644 halt/rust-toolchain delete mode 100644 halt/rust.h delete mode 100644 halt/src/lib.rs create mode 100644 rust/Cargo.toml create mode 100644 rust/Makefile create mode 100644 rust/rust-toolchain create mode 100644 rust/src/lib.rs diff --git a/halt/Cargo.toml b/halt/Cargo.toml deleted file mode 100644 index 14c75e0..0000000 --- a/halt/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "halt" -version = "0.1.0" -authors = ["Gustav Sörnäs "] -edition = "2018" - -[lib] -name = "halt" -crate-type = ["staticlib"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[profile.dev] -panic = "abort" - -[profile.release] -panic = "abort" -lto = true - -[dependencies.libc] -version = "0.2" -default-features = false -features = ["extra_traits"] diff --git a/halt/main.c b/halt/main.c deleted file mode 100644 index c89be21..0000000 --- a/halt/main.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "rust.h" - -void _start (int argc, char **argv) { - main(); -} diff --git a/halt/rust-toolchain b/halt/rust-toolchain deleted file mode 100644 index adfa491..0000000 --- a/halt/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-i686-unknown-linux-gnu diff --git a/halt/rust.h b/halt/rust.h deleted file mode 100644 index eba2976..0000000 --- a/halt/rust.h +++ /dev/null @@ -1 +0,0 @@ -int main(void); diff --git a/halt/src/lib.rs b/halt/src/lib.rs deleted file mode 100644 index 43470b2..0000000 --- a/halt/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_std] -//#![feature(asm)] -//#![feature(link_args)] -//#![link_args = "-L -lpintos"] - -#[panic_handler] -fn panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -#[no_mangle] -pub unsafe extern "C" fn entry() { - exit(0x69); -} - -#[link(name="pintos", kind="static")] -extern { - fn exit(status: i32); -} diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..a74fdd6 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "pintos-rs" +version = "0.1.0" +authors = ["Gustav Sörnäs "] +edition = "2018" + +[lib] +name = "rust" +crate-type = ["staticlib"] + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" + +[dependencies.libc] +version = "0.2" +default-features = false +features = ["extra_traits"] diff --git a/rust/Makefile b/rust/Makefile new file mode 100644 index 0000000..23187c9 --- /dev/null +++ b/rust/Makefile @@ -0,0 +1,2 @@ +all: + cargo rustc -- -C link-arg= -L. diff --git a/rust/rust-toolchain b/rust/rust-toolchain new file mode 100644 index 0000000..adfa491 --- /dev/null +++ b/rust/rust-toolchain @@ -0,0 +1 @@ +nightly-i686-unknown-linux-gnu diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..43470b2 --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,19 @@ +#![no_std] +//#![feature(asm)] +//#![feature(link_args)] +//#![link_args = "-L -lpintos"] + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +pub unsafe extern "C" fn entry() { + exit(0x69); +} + +#[link(name="pintos", kind="static")] +extern { + fn exit(status: i32); +} diff --git a/src/Makefile.userprog b/src/Makefile.userprog index f7271fe..3c4d404 100644 --- a/src/Makefile.userprog +++ b/src/Makefile.userprog @@ -23,7 +23,7 @@ lib/user_SRC += lib/user/console.c # Console code. LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC))) LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ)) -LIB = lib/user/entry.o libc.a +LIB = lib/user/entry.o libc.a librust.a PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC)) PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC))) @@ -48,9 +48,13 @@ libc.a: $(LIB_OBJ) ar r $@ $^ ranlib $@ +librust.a: + make -C $(SRCDIR)/../halt all + cp $(SRCDIR)/../rust/target/debug/librust.a $@ + clean:: rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP) - rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a + rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a librust.a .PHONY: all clean -- cgit v1.2.1