build: add real version numbering

This commit is contained in:
2026-04-30 20:53:24 +01:00
parent 5e9a165578
commit 6f178f1a60
5 changed files with 20 additions and 7 deletions
+16 -1
View File
@@ -16,6 +16,21 @@ set(generic_src_dirs ds init kernel libc sched util vm syscall)
set(kernel_sources "")
set(kernel_headers "")
set(version_args --arch ${CMAKE_SYSTEM_PROCESSOR})
if (CMAKE_BUILD_TYPE AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(version_args ${version_args} "--release")
endif()
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/magenta.buildid
${version_args}
OUTPUT_VARIABLE kernel_version
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Magenta kernel version: ${kernel_version}")
foreach (dir ${generic_src_dirs})
file(GLOB_RECURSE dir_sources ${dir}/*.c)
file(GLOB_RECURSE dir_headers ${dir}/*.h)
@@ -52,7 +67,7 @@ add_custom_command(
COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:${kernel_exe_name}>)
target_link_libraries(${kernel_exe_name} -nostdlib -ffreestanding -lgcc)
target_compile_definitions(${kernel_exe_name} PRIVATE BUILD_ID="0")
target_compile_definitions(${kernel_exe_name} PRIVATE KERNEL_VERSION="${kernel_version}")
include(arch/${kernel_arch}/config.cmake)
include(arch/${kernel_arch}/targets.cmake)
-2
View File
@@ -92,8 +92,6 @@ static void find_bsp(multiboot_info_t *mb, struct boot_module *out)
{
memset(out, 0x0, sizeof *out);
printk("modules=%u: %llx", mb->mods_count, mb->mods_addr);
multiboot_module_t *mods = PTR32(mb->mods_addr);
size_t nr_mods = mb->mods_count;
+1 -1
View File
@@ -23,7 +23,7 @@ extern char __pstart[], __pend[];
void print_kernel_banner(void)
{
printk("Magenta kernel version " BUILD_ID);
printk("Magenta version " KERNEL_VERSION);
}
static void hang(void)
+1 -1
View File
@@ -17,7 +17,7 @@ void panic_irq(struct ml_cpu_context *ctx, const char *fmt, ...)
va_end(args);
printk("---[ kernel panic: %s", buf);
printk("kernel: " BUILD_ID ", compiler version: " __VERSION__);
printk("kernel: " KERNEL_VERSION ", compiler version: " __VERSION__);
struct task *task = get_current_task();
struct thread *thr = get_current_thread();
+2 -2
View File
@@ -33,7 +33,7 @@ if is_arg_set('release'):
build_type = 'release'
current_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).decode('utf-8').strip()
current_tag = current_tag[1:]
revision = subprocess.check_output(['git', 'rev-list', '{}..HEAD'.format(current_tag), '--count']).decode('utf-8').strip()
build_id = '{}/{}_{}'.format(current_tag, build_type, arch)
build_id = '{}~{}/{}_{}'.format(current_tag[1:], revision, build_type, arch)
print('{}'.format(build_id.upper()))