Compare commits

...

3 Commits

Author SHA1 Message Date
1d7b9260c3 Add config.h for version information 2022-12-03 17:25:25 +01:00
bdc9747f9e Set a project version 2022-12-03 17:18:25 +01:00
3740309427 Check for STRINGIZE_VALUE_OF before defining it 2022-12-03 17:18:16 +01:00
5 changed files with 15 additions and 2 deletions

View File

@ -5,7 +5,7 @@ set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CROSSCOMPILING true)
project(Luna LANGUAGES C CXX ASM_NASM)
project(Luna LANGUAGES C CXX ASM_NASM VERSION 0.1.0)
set(LUNA_ROOT ${CMAKE_CURRENT_LIST_DIR})

View File

@ -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)

6
kernel/src/config.h.in Normal file
View File

@ -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@"

View File

@ -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<void> init()
{
kinfoln("Hello, world!");
kinfoln("Starting Moon %s", MOON_VERSION);
kinfoln("Current platform: %s", CPU::platform_string());

View File

@ -3,7 +3,9 @@
extern _noreturn bool __check_failed(const char* file, const char* line, const char* func, const char* expr);
#ifndef STRINGIZE_VALUE_OF
#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
#endif
#define check(expr) (expr) || __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr)