mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 07:35:45 +01:00
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:
17
Cargo.toml
17
Cargo.toml
@@ -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"
|
||||
28
makefile
28
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)
|
||||
|
||||
33
src/error.rs
33
src/error.rs
@@ -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),*)); }};
|
||||
}
|
||||
21
src/lib.rs
21
src/lib.rs
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user