diff --git a/SLS_C/Makefile b/SLS_C/Makefile index fe8affe..b58051b 100644 --- a/SLS_C/Makefile +++ b/SLS_C/Makefile @@ -5,6 +5,9 @@ CFLAGS ?= -std=c99 -Wall -Wextra -Werror -g -Iinclude -MMD -MP LDFLAGS ?= CTESTFLAGS ?= -std=c99 -Wall -Wextra -Wno-unused-function -Werror -g -O0 -Iinclude -MMD -MP +GIT_COMMIT := $(shell git describe --always --dirty --abbrev=7) +CFLAGS += -DGIT_COMMIT_HASH="\"$(GIT_COMMIT)\"" + SRCDIR := src OBJDIR := obj BINDIR := bin diff --git a/SLS_C/include/sls/main.h b/SLS_C/include/sls/main.h new file mode 100644 index 0000000..819596c --- /dev/null +++ b/SLS_C/include/sls/main.h @@ -0,0 +1,34 @@ +// Kyler Olsen +// YREA SLS +// Main Header +// November 2025 + +#ifndef SLS_MAIN_H +#define SLS_MAIN_H + +#define SLS_NAME "SLS_C" +#define SLS_VER "a.0.0" + +#ifndef GIT_COMMIT_HASH + #define GIT_COMMIT_HASH "UNKNOWN" +#endif + +#if defined(__GNUC__) + #define COMPILER_NAME "GCC" + #define COMPILER_VER __GNUC__ + +#elif defined(__clang__) + #define COMPILER_NAME "Clang" + #define COMPILER_VER __clang_major__ + +#elif defined(_MSC_VER) + #define COMPILER_NAME "MSVC" + #define COMPILER_VER _MSC_VER + +#else + #define COMPILER_NAME "Unknown compiler" + #define COMPILER_VER 0 +#endif + + +#endif // SLS_MAIN_H diff --git a/SLS_C/src/main.c b/SLS_C/src/main.c index 64fbefa..e4bf89f 100644 --- a/SLS_C/src/main.c +++ b/SLS_C/src/main.c @@ -4,8 +4,33 @@ // October 2025 #include +#include +#include + +#include "sls/main.h" +#include "sls/bool.h" +#include "sls/repl.h" int main(int argc, char *argv[]) { - printf("Hello, world!\n"); - return 0; + Boolean version = FALSE; + Boolean file = FALSE; + char *filename = NULL; + + (void)file; + (void)filename; + + for (int i = 0; i < argc; i++) { + if (strcmp(argv[i], "--version") == 0) version = TRUE; + if (strcmp(argv[i], "-v") == 0) version = TRUE; + } + + if (version) { + printf("YREA SLS (" SLS_NAME ") " SLS_VER " (" GIT_COMMIT_HASH ")\n"); + printf("Compiled with " COMPILER_NAME " %d at " __DATE__ " " __TIME__ "\n", COMPILER_VER); + return 0; + } else if (file) { + return 1; + } else { + return repl(0, NULL); + } } diff --git a/SLS_C/src/repl.c b/SLS_C/src/repl.c index b612078..152c5da 100644 --- a/SLS_C/src/repl.c +++ b/SLS_C/src/repl.c @@ -4,3 +4,10 @@ // November 2025 #include "sls/repl.h" + +int repl(int argc, char *argv[]) { + (void)argc; + (void)argv; + + return 1; +}