Compare commits

...

2 Commits

Author SHA1 Message Date
5f93db596e further cleanup and organization 2026-06-10 09:06:08 -05:00
7350a8cdfc create better file structure 2026-06-10 08:51:45 -05:00
7 changed files with 90 additions and 46 deletions

34
Makefile Normal file
View File

@@ -0,0 +1,34 @@
CC = gcc
SHELL := /bin/bash
INCLUDE := include
CFLAGS = -Wall -Wextra -I$(INCLUDE) -ggdb
BUILD_DIR := build
TEST_BUILD_DIR := $(BUILD_DIR)/test
TEST_BUILD_FILES := $(TEST_BUILD_DIR)/test.o \
$(TEST_BUILD_DIR)/array.o \
INCLUDE_INSTALL_PATH := /usr/local/include/LTypes
all: test
test: $(TEST_BUILD_FILES)
$(CC) $(CFLAGS) -I./test/include -o $(TEST_BUILD_DIR)/test $(TEST_BUILD_FILES)
@echo ""
$(TEST_BUILD_DIR)/test
$(TEST_BUILD_DIR)/%.o: test/%.c | $(TEST_BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(TEST_BUILD_DIR):
mkdir -p $(TEST_BUILD_DIR)
$(INCLUDE_INSTALL_PATH):
mkdir -p $(INCLUDE_INSTALL_PATH)
install: $(INCLUDE_INSTALL_PATH)
cp $(INCLUDE)/* $(INCLUDE_INSTALL_PATH)
clean:
rm -rf $(BUILD_DIR)

1
include/README.md Normal file
View File

@@ -0,0 +1 @@
To use any single header file, either include `version.h` or remove the include from the top.

View File

@@ -1,11 +1,7 @@
#ifndef LTYPES_ARRAY_H
#define LTYPES_ARRAY_H
#define L_TYPES_AUTHOR "Lucielle <luci@git.lunarware.tech"
#define L_TYPES_REPO "https://git.lunarware.tech/lucielle/ltypes.git"
#define L_TYPES_VERSION "0.1.0"
#define L_TYPES_LICENSE "GNU GPL v3"
#include "version.h"
#include <stddef.h>
typedef struct {

9
include/version.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef LTYPES_VERSION_H
#define LTYPES_VERSION_H
#define L_TYPES_AUTHOR "Lucielle <luci@git.lunarware.tech"
#define L_TYPES_REPO "https://git.lunarware.tech/lucielle/ltypes.git"
#define L_TYPES_VERSION "0.1.0"
#define L_TYPES_LICENSE "GNU GPL v3"
#endif

41
test.c
View File

@@ -1,41 +0,0 @@
#include <stdio.h>
#define L_ARRAY_IMPLEMENTATION
#include "array.h"
#include "assert.h"
#define TEST_FUNCTION
static int test_l_array() {
int RETURN_CODE = 0;
LArray* array = l_array_create();
int number_1 = 5;
int number_2 = 15;
l_array_append(array, &number_2);
l_array_append(array, &number_1);
assert(*(int*)array->items[0] == 15);
assert(*(int*)array->items[1] == 5);
assert(array->count == 2);
assert(array->capacity == 8);
l_array_clear(array);
assert(array->items == NULL);
return RETURN_CODE;
}
int main(void) {
printf("AUTHOR: %s\n", L_TYPES_AUTHOR);
printf("REPO: %s\n", L_TYPES_REPO);
printf("VERSION: %s\n", L_TYPES_VERSION);
printf("LICENSE: %s\n\n", L_TYPES_LICENSE);
if (
test_l_array()
) return 1;
return 0;
}

27
test/array.c Normal file
View File

@@ -0,0 +1,27 @@
#define L_ARRAY_IMPLEMENTATION
#include "../include/array.h"
#include <stdio.h>
int test_l_array() {
int RETURN_CODE = 0;
printf("test_l_array() : ");
LArray* array = l_array_create();
int number_1 = 5;
int number_2 = 15;
l_array_append(array, &number_2);
l_array_append(array, &number_1);
if (*(int*)array->items[0] != 15) RETURN_CODE++;
if (*(int*)array->items[1] != 5) RETURN_CODE++;
if (array->count != 2) RETURN_CODE++;
if (array->capacity != 8) RETURN_CODE++;
l_array_clear(array);
if (array->items != NULL) RETURN_CODE++;
printf("%d\n", RETURN_CODE);
return RETURN_CODE;
}

18
test/test.c Normal file
View File

@@ -0,0 +1,18 @@
#include <stdio.h>
#include "../include/version.h"
int test_l_array();
int main(void) {
printf("AUTHOR: %s\n", L_TYPES_AUTHOR);
printf("REPO: %s\n", L_TYPES_REPO);
printf("VERSION: %s\n", L_TYPES_VERSION);
printf("LICENSE: %s\n\n", L_TYPES_LICENSE);
int RETURN_CODE = 0;
RETURN_CODE += test_l_array();
printf("\nError Total: %d\n", RETURN_CODE);
return RETURN_CODE;
}