From 2664eca633af9a4d4b84cf2aef50cff38ada3eba Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 7 Sep 2022 17:52:34 +0400 Subject: [PATCH] Add Rust --- .gitignore | 1 + Cargo.lock | 7 +++++++ Cargo.toml | 17 +++++++++++++++++ Makefile | 8 ++++++-- README.md | 2 +- config/3-defvars.mk | 1 + src/lib.rs | 4 ++++ 7 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore index 05471f5..f8e3f5d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ /config/2-conditionals.mk /polytreewm /src/*.o +/target/ /tests/*.o /tests/*.test diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..e1885ee --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "polytreewm" +version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3a3104a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "polytreewm" +version = "0.0.0" +authors = ["Alex Kotov "] +edition = "2021" +description = "PolytreeWM is an extremely fast, small, and dynamic tiling window manager for X" +readme = true +homepage = "https://github.com/PolytreeDE/polytreewm" +repository = "https://github.com/PolytreeDE/polytreewm.git" +license = "MIT" +keywords = [] +categories = [] +publish = false + +[lib] +name = "polytreewm" +crate-type = ["staticlib"] diff --git a/Makefile b/Makefile index b235b72..fa26b47 100644 --- a/Makefile +++ b/Makefile @@ -58,10 +58,10 @@ ALL_EXE = polytreewm $(TEST_EXE) # Executables # ############### -polytreewm: src/main.o $(MODULES_OBJ) +polytreewm: src/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a $(CC) -o $@ $^ $(LDFLAGS) -%.test: %.o tests/main.o $(MODULES_OBJ) +%.test: %.o tests/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a $(CC) -o $@ $^ $(LDFLAGS) ################ @@ -73,6 +73,9 @@ polytreewm: src/main.o $(MODULES_OBJ) dwm.o: $(DWM_SRC) $(DWM_HDR) +target/debug/libpolytreewm.a: + $(CARGO) build + ######### # Tasks # ######### @@ -82,6 +85,7 @@ test: $(TEST_EXE) clean: rm -f $(ALL_OBJ) $(ALL_EXE) + $(CARGO) clean distclean: clean rm -f $(CONFIGMKS_TO_REMOVE) diff --git a/README.md b/README.md index 018691b..3ec1904 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PolytreeWM is an extremely fast, small, and dynamic tiling window manager for X. Requirements ------------ -In order to build PolytreeWM you need the Xlib header files. +In order to build PolytreeWM you need Cargo for Rust and the Xlib header files. Installation ------------ diff --git a/config/3-defvars.mk b/config/3-defvars.mk index 0e24820..21d8b5b 100644 --- a/config/3-defvars.mk +++ b/config/3-defvars.mk @@ -1,3 +1,4 @@ +CARGO = cargo CC = cc PKGCONFIG = pkg-config diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..b18c736 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub extern "C" fn foo() -> u32 { + 123 +}