From 401854002f013a45fa6029025f1ef137255ee9e6 Mon Sep 17 00:00:00 2001 From: Quinn Date: Sat, 12 Apr 2025 20:52:35 +0200 Subject: [PATCH] remove rust/cargo from compilation it has become clear that incorperating rust in this project was a mistake, since I don't understand it well enough for it to be useful, and at this rate it'd be faster to use GLFW in C than in rust. --- Cargo.toml | 17 ----------------- makefile | 28 +++------------------------- src/error.rs | 33 --------------------------------- src/lib.rs | 21 --------------------- src/main.c | 9 +++++---- 5 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 Cargo.toml delete mode 100644 src/error.rs delete mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 13c88e2..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "mcaselector-lite" -version = "0.0.1" -edition = "2024" - -[lib] -crate-type = ["staticlib"] - -[profile.dev] -panic = "abort" - -[profile.release] -panic = "abort" - -[dependencies] -glfw-sys = "5.0.0" -libc = "0.2.171" diff --git a/makefile b/makefile index cc800c9..707f48d 100644 --- a/makefile +++ b/makefile @@ -13,18 +13,11 @@ CSTD := c17 CFLAGS := $(shell pkg-config --cflags glfw3) -Wall -Wextra -Wpedantic -Wno-pointer-arith -static LDFLAGS := $(shell pkg-config --libs glfw3) -# Rust compiler options -RUSTC := cargo rustc -RSFLAGS := - ifeq ($(DEBUG),1) CFLAGS += -g -Og -RSOUT := debug PROF := dbg else CFLAGS += -DNDEBUG -O2 -Werror -RSOUT := release -RSFLAGS := --release PROF := rel endif @@ -32,13 +25,9 @@ ifneq ($(MAKECMDGOALS),clean) ifeq ($(ARCH),linux-x86_64) CFLAGS += -target x86_64-pc-linux-gnu LDFLAGS += -target x86_64-pc-linux-gnu -RSFLAGS += --target=x86_64-unknown-linux-gnu -RSOUT := target/x86_64-unknown-linux-gnu/$(RSOUT) else ifeq ($(ARCH),win-x86_64) CFLAGS += -target x86_64-pc-windows-gnu LDFLAGS += -target x86_64-pc-windows-gnu -RSFLAGS += --target=x86_64-pc-windows-gnu -RSOUT := target/x86_64-pc-windows-gnu/$(RSOUT) EXT := .exe else $(error you must set the ARCH environment variable to one of these: 'linux-x86_64' 'win-x86_64') @@ -53,10 +42,6 @@ BIN := $(DIR_BIN)/$(NAME)$(EXT) C_SRC := $(shell find src/ -name '*.c') C_OBJ := $(patsubst src/%,$(DIR_OBJ)/%,$(C_SRC:.c=.o)) C_DEP := $(C_OBJ:.o=.d) -RS_SRC := $(shell find src/ -name '*.rs') -RS_LIB := $(RSOUT)/libmcaselector_lite.a -RS_DEP := $(RSOUT)/libmcaselector_lite.d -RSOUT := endif define log_col @@ -73,20 +58,18 @@ run: compile compile: compile_commands.json $(BIN) clean: @$(call warn,"cleaning!") - rm -rf bin/ obj/ target/ compile_commands.json + rm -rf bin/ obj/ compile_commands.json # TODO: write a structure for the unit tests in this # create the binary (linking step) -$(BIN): $(C_OBJ) $(RS_LIB) - @$(call mesg,"RUSTC: '$(RUSTC)'") +$(BIN): $(C_OBJ) @$(call mesg,"CC: '$(CC)'") @$(call mesg,"CFLAGS: '$(CFLAGS)'") - @$(call mesg,"RSFLAGS: '$(RSFLAGS)'") @$(call mesg,"LDFLAGS: '$(LDFLAGS)'") @$(call comp,"linking to: '$@'") @mkdir -p $(@D) - @$(CC) $(LDFLAGS) -o $@ $(C_OBJ) $(RS_LIB) + @$(CC) $(LDFLAGS) -o $@ $(C_OBJ) @$(call warn,"current profile: '$(PROF)'") # create .o and .d files for C sources @@ -95,10 +78,6 @@ $(DIR_OBJ)/%.o: src/%.c @mkdir -p $(@D) @$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x c -o $@ $< -# create .o and .d files for the entire rust codebase -$(RS_LIB): $(RS_SRC) - $(RUSTC) $(RSFLAGS) - # update compile commands if the makefile has been updated (for linting) ifneq ($(shell which bear),) compile_commands.json: makefile @@ -114,4 +93,3 @@ endif # include the dependencies -include $(C_DEP) --include $(RS_DEP) diff --git a/src/error.rs b/src/error.rs deleted file mode 100644 index 8961f65..0000000 --- a/src/error.rs +++ /dev/null @@ -1,33 +0,0 @@ -unsafe extern "C" { - pub fn debug(fmt: *const u8, ...); - pub fn info(fmt: *const u8, ...); - pub fn warn(fmt: *const u8, ...); - pub fn error(fmt: *const u8, ...); - pub fn fatal(fmt: *const u8, ...); -} - -#[macro_export] -macro_rules! debug { - ($fmt:expr) => {{ $crate::error::debug($fmt.as_ptr()); }}; - ($fmt:expr, $($arg:expr),*) => {{ $crate::error::debug($fmt.as_ptr(), ($($arg),*)); }}; -} -#[macro_export] -macro_rules! info { - ($fmt:expr) => {{ $crate::error::info($fmt.as_ptr()); }}; - ($fmt:expr, $($arg:expr),*) => {{ $crate::error::info($fmt.as_ptr(), ($($arg),*)); }}; -} -#[macro_export] -macro_rules! warn { - ($fmt:expr) => {{ $crate::error::warn($fmt.as_ptr()); }}; - ($fmt:expr, $($arg:expr),*) => {{ $crate::error::warn($fmt.as_ptr(), ($($arg),*)); }}; -} -#[macro_export] -macro_rules! error { - ($fmt:expr) => {{ $crate::error::error($fmt.as_ptr()); }}; - ($fmt:expr, $($arg:expr),*) => {{ $crate::error::error($fmt.as_ptr(), ($($arg),*)); }}; -} -#[macro_export] -macro_rules! fatal { - ($fmt:expr) => {{ $crate::error::fatal($fmt.as_ptr()); }}; - ($fmt:expr, $($arg:expr),*) => {{ $crate::error::fatal($fmt.as_ptr(), ($($arg),*)); }}; -} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index eeb91ca..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![cfg_attr(not(test), no_std)] - -#[cfg(not(test))] -#[panic_handler] -fn panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -// contains all publicly facing functions - -mod error; - -pub extern "C" fn test() { - unsafe { - debug!("%s", "hi"); - info!("%s", "hi"); - warn!("%s", "hi"); - error!("%s", "hi"); - fatal!("%s", "hi"); - } -} diff --git a/src/main.c b/src/main.c index b56cbd7..19aa04e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,10 @@ #include "error.h" -extern void test(void); - int main(int argc, char** argv) { (void)argc, (void)argv; - test(); - debug("owo"); + debug("%s", "owo"); + info("%s", "owo"); + warn("%s", "owo"); + error("%s", "owo"); + fatal("%s", "owo"); }