aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-09-13 12:06:49 -0400
committernodist <kevin.comas.git@gmail.com>2026-09-13 12:06:49 -0400
commit33d09be340ec13cd02735dbcfe4fc810c4ad5902 (patch)
treee932153595e76d4f21ac201bc2a0a690e318b2c0
parenta82f63b4128f2cac400ae5163011c3df715f6311 (diff)
set up make
-rw-r--r--.gitignore4
-rw-r--r--Makefile39
-rw-r--r--README30
-rw-r--r--TESTING1
-rw-r--r--include/kpl.h2
-rw-r--r--include/kpl_test.h4
-rw-r--r--source/kpl.c8
-rw-r--r--test/README58
-rw-r--r--test/test.c6
9 files changed, 152 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 1750fe8..6612c23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
qemu
+kpl
+kpl_test
+source/*.o
+test/*.o
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e239bc4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,39 @@
+
+.PHONY: clean
+
+MAKEFLAGS := -j$(shell nproc)
+
+INCLUDE_DIR := "./include"
+SOURCE_DIR := "./source"
+TEST_DIR := "./test"
+
+CC := gcc
+OO := -g -Og
+FFLAGS := -fno-omit-frame-pointer -fhardened
+WFLAGS := -Wall -Wextra -Wstack-protector
+CFLAGS = -std=gnu99 $(FLAGS) -I$(INCLUDE_DIR) $(OO) $(FFLAGS) $(WFLAGS)
+CCOBJ = $(CC) -o $@ $^ $(CFLAGS)
+
+OBJECTS := $(patsubst %.c, %.o, $(wildcard ./source/*.c))
+
+kpl: OO := -O2
+kpl: WFLAGS += -Werror
+kpl: FLAGS += -DKPL_MAIN
+kpl: $(OBJECTS)
+ $(CCOBJ)
+
+TEST_OBJECTS := $(patsubst %.c, %.o, $(wildcard ./test/*.c))
+
+kpl_test: $(OBJECTS) $(TEST_OBJECTS)
+ $(CCOBJ)
+
+kpl_test_error: FFLAGS += -fsanitize=address,leak,undefined
+kpl_test_error: kpl_test
+
+kpl_test_thread: FFLAGS += -fsanitize=thread
+kpl_test_thread: kpl_test
+
+clean:
+ @rm -fv kpl
+ @rm -fv kpl_test
+ @find -type f -name "*.o" -exec rm -v {} \;
diff --git a/README b/README
index a5945df..f6037f9 100644
--- a/README
+++ b/README
@@ -1 +1,31 @@
KPL
+
+---
+
+Requirements:
+
+Linux 6+
+GCC 14+
+make
+
+---
+
+Building:
+
+make
+
+---
+
+Running:
+
+./kpl [OPTIONS] ./path/to/file.kpl # Run File
+./kpl [OPTIONS] # Start REPL
+./kpl -h # See OPTIONS
+
+---
+
+Testing:
+
+See TESTING
+
+---
diff --git a/TESTING b/TESTING
index 77b9150..a413c07 100644
--- a/TESTING
+++ b/TESTING
@@ -71,3 +71,4 @@ Cleaning:
./vm.sh -clean # Remove the testing environment
+---
diff --git a/include/kpl.h b/include/kpl.h
new file mode 100644
index 0000000..99ddf32
--- /dev/null
+++ b/include/kpl.h
@@ -0,0 +1,2 @@
+
+#pragma once
diff --git a/include/kpl_test.h b/include/kpl_test.h
new file mode 100644
index 0000000..1a61a30
--- /dev/null
+++ b/include/kpl_test.h
@@ -0,0 +1,4 @@
+
+#pragma once
+
+#include "kpl.h"
diff --git a/source/kpl.c b/source/kpl.c
new file mode 100644
index 0000000..904c14b
--- /dev/null
+++ b/source/kpl.c
@@ -0,0 +1,8 @@
+
+#include "kpl.h"
+
+#ifdef KPL_MAIN
+int main(void) {
+ return 1;
+}
+#endif
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..80d57e6
--- /dev/null
+++ b/test/README
@@ -0,0 +1,58 @@
+Testing
+
+---
+
+File Layout:
+
+The test files mirror the src files, so a function in src/file.c would have a test in test/file.c
+
+---
+
+Includes:
+
+#include "kpl_test.h"
+
+This is the only include a .c file in the test folder needs
+
+---
+
+Writing Tests:
+
+TEST(test_name) {
+ // TEST CODE
+}
+
+Tests pass by default
+
+---
+
+Asserting:
+
+ASSERT(CONDITION, FAIL_MESSAGE);
+
+---
+
+Failing:
+
+FAIL(FAIL_MESSAGE);
+
+---
+
+Building:
+
+make kpl_test # build test exec
+make kpl_test_error # build test exec with address, leak and undefined sanitizer
+make kpl_test_thread # build test exec with thread sanitizer
+
+All objects need to be built with the same sanitizer and do not run valgrind when sanitizers are added
+
+---
+
+Running:
+
+./kpl_test [OPTIONS] # Run all tests
+./kpl_test [OPTIONS] NAME # Run test named NAME
+./kpl_test [OPTIONS] NAME1 NAME2 ... # Run selected tests named NAM1 NAME2 ...
+./kpl_test -h # Show OPTIONS
+
+---
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..f12ee6e
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,6 @@
+
+#include "kpl_test.h"
+
+int main(void) {
+ return 2;
+}