From 1d7b9260c315f25a1cc960447b70515e8d18df41 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 3 Dec 2022 17:25:25 +0100 Subject: [PATCH] Add config.h for version information --- kernel/CMakeLists.txt | 4 ++++ kernel/src/config.h.in | 6 ++++++ kernel/src/main.cpp | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 kernel/src/config.h.in diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index e23e42fd..a1c5155d 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -58,6 +58,10 @@ set_target_properties(moon PROPERTIES CXX_STANDARD 20) target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) +configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/config.h @ONLY) + +target_include_directories(moon PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen) + target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot) \ No newline at end of file diff --git a/kernel/src/config.h.in b/kernel/src/config.h.in new file mode 100644 index 00000000..6cbc30ec --- /dev/null +++ b/kernel/src/config.h.in @@ -0,0 +1,6 @@ +#pragma once + +#define MOON_VERSION "@CMAKE_PROJECT_VERSION@" +#define MOON_VERSION_MAJOR "@CMAKE_PROJECT_VERSION_MAJOR@" +#define MOON_VERSION_MINOR "@CMAKE_PROJECT_VERSION_MINOR@" +#define MOON_VERSION_PATCH "@CMAKE_PROJECT_VERSION_PATCH@" \ No newline at end of file diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index bf0cf636..3e5cba2c 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -4,6 +4,7 @@ #include "arch/Serial.h" #include "arch/Timer.h" #include "boot/Init.h" +#include "config.h" #include "memory/Heap.h" #include "memory/MemoryManager.h" #include "video/TextConsole.h" @@ -11,7 +12,7 @@ Result init() { - kinfoln("Hello, world!"); + kinfoln("Starting Moon %s", MOON_VERSION); kinfoln("Current platform: %s", CPU::platform_string());