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.
This commit is contained in:
Quinn
2025-04-12 20:52:35 +02:00
committed by Quinn
parent 87117931f7
commit 401854002f
5 changed files with 8 additions and 100 deletions

View File

@@ -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"

View File

@@ -13,18 +13,11 @@ CSTD := c17
CFLAGS := $(shell pkg-config --cflags glfw3) -Wall -Wextra -Wpedantic -Wno-pointer-arith -static CFLAGS := $(shell pkg-config --cflags glfw3) -Wall -Wextra -Wpedantic -Wno-pointer-arith -static
LDFLAGS := $(shell pkg-config --libs glfw3) LDFLAGS := $(shell pkg-config --libs glfw3)
# Rust compiler options
RUSTC := cargo rustc
RSFLAGS :=
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CFLAGS += -g -Og CFLAGS += -g -Og
RSOUT := debug
PROF := dbg PROF := dbg
else else
CFLAGS += -DNDEBUG -O2 -Werror CFLAGS += -DNDEBUG -O2 -Werror
RSOUT := release
RSFLAGS := --release
PROF := rel PROF := rel
endif endif
@@ -32,13 +25,9 @@ ifneq ($(MAKECMDGOALS),clean)
ifeq ($(ARCH),linux-x86_64) ifeq ($(ARCH),linux-x86_64)
CFLAGS += -target x86_64-pc-linux-gnu CFLAGS += -target x86_64-pc-linux-gnu
LDFLAGS += -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) else ifeq ($(ARCH),win-x86_64)
CFLAGS += -target x86_64-pc-windows-gnu CFLAGS += -target x86_64-pc-windows-gnu
LDFLAGS += -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 EXT := .exe
else else
$(error you must set the ARCH environment variable to one of these: 'linux-x86_64' 'win-x86_64') $(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_SRC := $(shell find src/ -name '*.c')
C_OBJ := $(patsubst src/%,$(DIR_OBJ)/%,$(C_SRC:.c=.o)) C_OBJ := $(patsubst src/%,$(DIR_OBJ)/%,$(C_SRC:.c=.o))
C_DEP := $(C_OBJ:.o=.d) 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 endif
define log_col define log_col
@@ -73,20 +58,18 @@ run: compile
compile: compile_commands.json $(BIN) compile: compile_commands.json $(BIN)
clean: clean:
@$(call warn,"cleaning!") @$(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 # TODO: write a structure for the unit tests in this
# create the binary (linking step) # create the binary (linking step)
$(BIN): $(C_OBJ) $(RS_LIB) $(BIN): $(C_OBJ)
@$(call mesg,"RUSTC: '$(RUSTC)'")
@$(call mesg,"CC: '$(CC)'") @$(call mesg,"CC: '$(CC)'")
@$(call mesg,"CFLAGS: '$(CFLAGS)'") @$(call mesg,"CFLAGS: '$(CFLAGS)'")
@$(call mesg,"RSFLAGS: '$(RSFLAGS)'")
@$(call mesg,"LDFLAGS: '$(LDFLAGS)'") @$(call mesg,"LDFLAGS: '$(LDFLAGS)'")
@$(call comp,"linking to: '$@'") @$(call comp,"linking to: '$@'")
@mkdir -p $(@D) @mkdir -p $(@D)
@$(CC) $(LDFLAGS) -o $@ $(C_OBJ) $(RS_LIB) @$(CC) $(LDFLAGS) -o $@ $(C_OBJ)
@$(call warn,"current profile: '$(PROF)'") @$(call warn,"current profile: '$(PROF)'")
# create .o and .d files for C sources # create .o and .d files for C sources
@@ -95,10 +78,6 @@ $(DIR_OBJ)/%.o: src/%.c
@mkdir -p $(@D) @mkdir -p $(@D)
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x c -o $@ $< @$(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) # update compile commands if the makefile has been updated (for linting)
ifneq ($(shell which bear),) ifneq ($(shell which bear),)
compile_commands.json: makefile compile_commands.json: makefile
@@ -114,4 +93,3 @@ endif
# include the dependencies # include the dependencies
-include $(C_DEP) -include $(C_DEP)
-include $(RS_DEP)

View File

@@ -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),*)); }};
}

View File

@@ -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");
}
}

View File

@@ -1,9 +1,10 @@
#include "error.h" #include "error.h"
extern void test(void);
int main(int argc, char** argv) { int main(int argc, char** argv) {
(void)argc, (void)argv; (void)argc, (void)argv;
test(); debug("%s", "owo");
debug("owo"); info("%s", "owo");
warn("%s", "owo");
error("%s", "owo");
fatal("%s", "owo");
} }