From ddd7f10079717767c2e36e2b17393b40e6fcfa5d Mon Sep 17 00:00:00 2001 From: Randy Jordan Date: Mon, 2 Feb 2026 19:03:41 -0600 Subject: [PATCH] Initial Commit --- LICENSE | 21 +++++++++++++ Makefile | 76 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 57 ++++++++++++++++++++++++++++++++++ include/.ci2.h.swp | Bin 0 -> 12288 bytes src/linux_ci2.c | 1 + src/win32_ci2.cpp | 9 ++++++ 6 files changed, 164 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 include/.ci2.h.swp create mode 100644 src/linux_ci2.c create mode 100644 src/win32_ci2.cpp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8aa2645 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..95a2a59 --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +# Compiler Flags +CC := gcc +CFLAGS := -g -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -fno-omit-frame-pointer + +# Directory variables +LIBDIR := lib +OBJ := obj +INC := include +SRC := src +TEST := tests + +# Filepath Pattern Matching +LIB := $(LIBDIR)/lib.a +SRCS := $(wildcard $(SRC)/*.c) +OBJS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS)) +TESTS := $(wildcard $(TEST)/*.c) +TESTBINS := $(patsubst $(TEST)/%.c, $(TEST)/bin/%, $(TESTS)) + +# Commands must be labeled PHONY +.PHONY: all release clean test + +# Compiler Release Flags +release: CFLAGS := -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -fno-omit-frame-pointer -O2 -DNDEBUG +release: clean $(LIB) + +# Target for compilation. +all: $(LIB) + +# Target / Dependencies +$(LIB): $(OBJS) | $(LIBDIR) + $(RM) $(LIB) + ar -cvrs $@ $^ + +$(OBJ)/%.o: $(SRC)/%.c $(SRC)/%.h | $(OBJ) + $(CC) $(CFLAGS) -c $< -o $@ + +$(OBJ)/%.o: $(SRC)/%.c | $(OBJ) + $(CC) $(CFLAGS) -c $< -o $@ + +$(TEST)/bin/%: $(TEST)/%.c $(LIB) | $(TEST)/bin + $(CC) $(CFLAGS) $< $(LIB) -o $@ + +# Make directories if none. +$(LIBDIR): + mkdir $@ + +$(INC): + mkdir $@ + +$(OBJ): + mkdir $@ + +$(TEST)/bin: + mkdir $@ + +# Run the tests in the bin folder and track results +test: $(LIB) $(TEST)/bin $(TESTBINS) + @SUCCESS_COUNT=0; FAILURE_COUNT=0; \ + for test in $(TESTBINS); do \ + ./$$test; \ + EXIT_CODE=$$?; \ + TEST_NAME=$(notdir $$test); \ + if [ $$EXIT_CODE -eq 0 ]; then \ + echo "\033[0;32m$$TEST_NAME: EXIT CODE: $$EXIT_CODE (SUCCESS)\033[0m"; \ + SUCCESS_COUNT=$$((SUCCESS_COUNT + 1)); \ + else \ + echo "\033[0;31m$$TEST_NAME: EXIT CODE: $$EXIT_CODE (FAILURE)\033[0m"; \ + FAILURE_COUNT=$$((FAILURE_COUNT + 1)); \ + fi; \ + done; \ + echo "\n\nTests completed"; \ + echo "SUCCESS: $$SUCCESS_COUNT"; \ + echo "FAILURE: $$FAILURE_COUNT"; + +clean: + $(RM) -r $(LIBDIR) $(OBJ) $(TEST)/bin/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce69d1d --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# ci2 + +## Description +Inspired by the [book](https://github.com/drh/cii), and others, this is my +personal C codebase. I wanted to improve my C and DSA knowledge, and make some +useful tools since C doesn't have many language features. This is meant to be +opinionated, and not necessarily modular. It's not meant to be the best way, +but I hope to improve it overtime. + +## Table of Contents + +- [Description](#description) +- [Features](#features) +- [Usage](#usage) +- [Credits / Resources](#credits--resources) +- [License](#license) + +## Features / TODOS +Plan to follow CII book and modify it to my style and use C99. + +- [ ] Exceptions +- [ ] Memory Allocator +- [ ] Arena Allocator +- [ ] String Views +- [ ] Atoms / Quarks +- [ ] Linked List +- [ ] Stacks +- [ ] Queues +- [ ] Vectors / Dynamic Arrays +- [ ] CLI Parsing +- [ ] Opening A Window + +Once these are implemented. The focus will then shift to make our code cross +platform, along with a simple build process. + + +## Usage +`make` to build. + +`make test` to build and run tests. + +## Credits / Resources +[Tom Preston-Werner README Driven Development](https://tom.preston-werner.com/2010/08/23/readme-driven-development)
+[Make a README](https://www.makeareadme.com/)
+[Choose a LICENSE](https://choosealicense.com/)
+[C Interfaces and Implementations](https://github.com/drh/cii)
+[Sean Barrett - Advice for Writing Small Programs in C](https://www.youtube.com/watch?v=eAhWIO1Ra6M)
+[Eskil Steenberg - How I Program C](https://www.youtube.com/watch?v=443UNeGrFoM)
+[Handmade Hero](https://www.youtube.com/playlist?list=PLnuhp3Xd9PYTt6svyQPyRO_AAuMWGxPzU)
+[Mr. 4th Programming](https://www.youtube.com/playlist?list=PLT6InxK-XQvNKTyLXk6H6KKy12UYS_KDL)
+[Chris Wellons](https://nullprogram.com/)
+[Ginger Bill](https://www.gingerbill.org/)
+[Tsoding Daily](https://www.youtube.com/@TsodingDaily)
+[Jacob Sorber](https://www.youtube.com/channel/UCwd5VFu4KoJNjkWJZMFJGHQ)
+ +## License +This project is licensed under MIT - see the [LICENSE](LICENSE) file for details. diff --git a/include/.ci2.h.swp b/include/.ci2.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..5daf94b827cac3b2b2530113c93ed7dafe516361 GIT binary patch literal 12288 zcmeI&y$*sf5Ww-n#L;N<1yFXroZMU;9C1e=0b-C4T=hMD5NBJ3g+v^fNd8UQa_P0X z{x$+<_jEX#JKGc07JB%${ZypN+o*pI>oh6C{v5q}uX3kK%BvG)zLOQvDrt?#+|6l=3KSIc1Nf$T>B0R#|0009ILKmdUe3Dl(_4^{7^soD53kLXI2 ziU0x#AbFcx{vMP91w@Bi)l|0nL`5+Z;A0tg_000IagfB*sr OAb`M_1gz%odsE)5*%_Pw literal 0 HcmV?d00001 diff --git a/src/linux_ci2.c b/src/linux_ci2.c new file mode 100644 index 0000000..d0b9aed --- /dev/null +++ b/src/linux_ci2.c @@ -0,0 +1 @@ +#include "../include/ci2.h" diff --git a/src/win32_ci2.cpp b/src/win32_ci2.cpp new file mode 100644 index 0000000..0e2b89b --- /dev/null +++ b/src/win32_ci2.cpp @@ -0,0 +1,9 @@ +#include + +int CALLBACK WinMain( HINSTANCE hInstance, + HINSTANCE hPrevInstance, // Legacy + PWSTR pCmdLine, // Command Line + int nCmdShow ) // Window Size +{ + return 0; +}