diff --git a/.gitignore b/.gitignore index f76886b..62c06e8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ !README.md !LICENSE !xmake.lua -!compile_commands.json !/Kanel/ !/Xmake/ !/.github/ diff --git a/Kanel/Runtime/Includes/Core/Application.h b/Kanel/Runtime/Includes/Core/Application.h new file mode 100644 index 0000000..b89e4b1 --- /dev/null +++ b/Kanel/Runtime/Includes/Core/Application.h @@ -0,0 +1,19 @@ +// Copyright (C) 2024 kanel +// This file is part of "kanel-CLI" +// For conditions of distribution and use, see copyright notice in LICENSE + +#ifndef KANEL_CLI_CORE_APPLICATION +#define KANEL_CLI_CORE_APPLICATION + +#include + +typedef struct KbhCoreApplication +{ + +} KbhCoreApplication; + +KbhCoreApplication* kbhCreateCoreApplication(int argc, char** argv); +KANEL_CLI_NONNULL(1) void kbhLaunchCoreApplication(const KbhCoreApplication* application); +KANEL_CLI_NONNULL(1) void kbhDestroyCoreApplication(const KbhCoreApplication* application); + +#endif diff --git a/Kanel/Runtime/Includes/Modules/GPU/Vulkan/VulkanCore.h b/Kanel/Runtime/Includes/Modules/GPU/Vulkan/VulkanCore.h index 30d66a3..07ef6ea 100644 --- a/Kanel/Runtime/Includes/Modules/GPU/Vulkan/VulkanCore.h +++ b/Kanel/Runtime/Includes/Modules/GPU/Vulkan/VulkanCore.h @@ -34,7 +34,6 @@ typedef struct KbhVulkanContextHandler size_t devices_count; } KbhVulkanContextHandler; - KANEL_CLI_NONNULL(1) KbhRHIResult kbhVulkanInit(KbhVulkanContext* context); KbhRHIResult kbhVulkanLoadNewDevice(KbhVulkanContext context); void kbhVulkanUninit(KbhVulkanContext context); diff --git a/Kanel/Runtime/Sources/Core/Application.c b/Kanel/Runtime/Sources/Core/Application.c new file mode 100644 index 0000000..15b64be --- /dev/null +++ b/Kanel/Runtime/Sources/Core/Application.c @@ -0,0 +1,42 @@ +// Copyright (C) 2024 kanel +// This file is part of "kanel-CLI" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include +#include +#include + +#include + +KbhCoreApplication* kbhCreateCoreApplication(int argc, char** argv) +{ + KbhCoreApplication* application = (KbhCoreApplication*)malloc(sizeof(KbhCoreApplication)); + if(!application) + return KANEL_CLI_NULLPTR; + if(!kbhRuntimeOptionsParseCmd(argc, argv)) + { + kbhRuntimeOptionsClear(); + return 0; + } + kbhCoreLoadAllModulesFromCmdLine(); + return application; +} + +void kbhLaunchCoreApplication(const KbhCoreApplication* application) +{ + // tests + char dummy[1024]; + if(kbhRuntimeOptionsGetString("gpu", dummy, 1024)) + { + kbhInitGPUSupport(); + kbhUninitGPUSupport(); + } +} + +void kbhDestroyCoreApplication(const KbhCoreApplication* application) +{ + kbhCoreUnloadAllModules(); + kbhRuntimeOptionsClear(); + free((void*)application); +} diff --git a/Kanel/Runtime/Sources/Core/ModuleLoader.c b/Kanel/Runtime/Sources/Core/ModuleLoader.c index 571f29b..83eba89 100644 --- a/Kanel/Runtime/Sources/Core/ModuleLoader.c +++ b/Kanel/Runtime/Sources/Core/ModuleLoader.c @@ -19,27 +19,27 @@ typedef struct KbhCoreModuleDescriptor KbhCoreModule type; } KbhCoreModuleDescriptor; -static KbhCoreModuleDescriptor* head = KANEL_CLI_NULLPTR; +static KbhCoreModuleDescriptor* module_descriptors_head = KANEL_CLI_NULLPTR; static void kbhAddLibModule(KbhLibModule module, KbhCoreModule type) { KbhCoreModuleDescriptor* descriptor = (KbhCoreModuleDescriptor*)malloc(sizeof(KbhCoreModuleDescriptor)); if(!descriptor) kbhFatalError("allocation failed"); - descriptor->next = head; + descriptor->next = module_descriptors_head; descriptor->module = module; descriptor->type = type; - head = descriptor; + module_descriptors_head = descriptor; } static void kbhRemoveLibModule(KbhCoreModule type) { - KbhCoreModuleDescriptor* ptr = head; + KbhCoreModuleDescriptor* ptr = module_descriptors_head; if(ptr == KANEL_CLI_NULLPTR) return; if(ptr->type == type) { - head = ptr->next; + module_descriptors_head = ptr->next; free((void*)ptr); return; } @@ -93,8 +93,8 @@ KbhLibModule kbhCoreLoadModule(KbhCoreModule type) void kbhCoreUnloadAllModules() { - while(head != KANEL_CLI_NULLPTR) - kbhCoreUnloadModule(head->type); + while(module_descriptors_head != KANEL_CLI_NULLPTR) + kbhCoreUnloadModule(module_descriptors_head->type); } void kbhCoreUnloadModule(KbhCoreModule type) diff --git a/Kanel/Runtime/Sources/Core/RuntimeOptions.c b/Kanel/Runtime/Sources/Core/RuntimeOptions.c index 2456bf9..2740444 100644 --- a/Kanel/Runtime/Sources/Core/RuntimeOptions.c +++ b/Kanel/Runtime/Sources/Core/RuntimeOptions.c @@ -35,14 +35,14 @@ typedef struct KbhRuntimeOption KbhRuntimeOptionType type; } KbhRuntimeOption; -static KbhRuntimeOption* head = KANEL_CLI_NULLPTR; +static KbhRuntimeOption* runtime_options_head = KANEL_CLI_NULLPTR; static void kbhAddRuntimeOptionStringToList(const char* name, const char* string) { KbhRuntimeOption* option = (KbhRuntimeOption*)malloc(sizeof(KbhRuntimeOption)); if(!option) kbhFatalError("allocation failed"); - option->next = head; + option->next = runtime_options_head; option->name = strdup(name); if(!option->name) kbhFatalError("allocation failed"); @@ -50,7 +50,7 @@ static void kbhAddRuntimeOptionStringToList(const char* name, const char* string if(!option->string) kbhFatalError("allocation failed"); option->type = KBH_RUNTIME_OPTION_STRING; - head = option; + runtime_options_head = option; } static void kbhAddRuntimeOptionFloat32ToList(const char* name, float f32) @@ -58,13 +58,13 @@ static void kbhAddRuntimeOptionFloat32ToList(const char* name, float f32) KbhRuntimeOption* option = (KbhRuntimeOption*)malloc(sizeof(KbhRuntimeOption)); if(!option) kbhFatalError("allocation failed"); - option->next = head; + option->next = runtime_options_head; option->name = strdup(name); if(!option->name) kbhFatalError("allocation failed"); option->f32 = f32; option->type = KBH_RUNTIME_OPTION_FLOAT32; - head = option; + runtime_options_head = option; } static void kbhAddRuntimeOptionFloat64ToList(const char* name, double f64) @@ -72,13 +72,13 @@ static void kbhAddRuntimeOptionFloat64ToList(const char* name, double f64) KbhRuntimeOption* option = (KbhRuntimeOption*)malloc(sizeof(KbhRuntimeOption)); if(!option) kbhFatalError("allocation failed"); - option->next = head; + option->next = runtime_options_head; option->name = strdup(name); if(!option->name) kbhFatalError("allocation failed"); option->f64 = f64; option->type = KBH_RUNTIME_OPTION_INT; - head = option; + runtime_options_head = option; } static void kbhAddRuntimeOptionIntegerToList(const char* name, int32_t integer) @@ -86,13 +86,13 @@ static void kbhAddRuntimeOptionIntegerToList(const char* name, int32_t integer) KbhRuntimeOption* option = (KbhRuntimeOption*)malloc(sizeof(KbhRuntimeOption)); if(!option) kbhFatalError("allocation failed"); - option->next = head; + option->next = runtime_options_head; option->name = strdup(name); if(!option->name) kbhFatalError("allocation failed"); option->integer = integer; option->type = KBH_RUNTIME_OPTION_INT; - head = option; + runtime_options_head = option; } static void kbhAddRuntimeOptionBooleanToList(const char* name, bool boolean) @@ -100,13 +100,13 @@ static void kbhAddRuntimeOptionBooleanToList(const char* name, bool boolean) KbhRuntimeOption* option = (KbhRuntimeOption*)malloc(sizeof(KbhRuntimeOption)); if(!option) kbhFatalError("allocation failed"); - option->next = head; + option->next = runtime_options_head; option->name = strdup(name); if(!option->name) kbhFatalError("allocation failed"); option->boolean = boolean; option->type = KBH_RUNTIME_OPTION_BOOL; - head = option; + runtime_options_head = option; } bool kbhRuntimeOptionsParseCmd(int argc, char** argv) @@ -140,7 +140,7 @@ bool kbhRuntimeOptionsParseCmd(int argc, char** argv) bool kbhRuntimeOptionsGetString(const char* opt_name, char* dst, size_t dst_len) { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { if(strcmp(ptr->name, opt_name) == 0) @@ -163,7 +163,7 @@ bool kbhRuntimeOptionsGetString(const char* opt_name, char* dst, size_t dst_len) bool kbhRuntimeOptionsGetFloat64(const char* opt_name, double* dst) { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { if(strcmp(ptr->name, opt_name) == 0) @@ -181,7 +181,7 @@ bool kbhRuntimeOptionsGetFloat64(const char* opt_name, double* dst) bool kbhRuntimeOptionsGetFloat32(const char* opt_name, float* dst) { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { if(strcmp(ptr->name, opt_name) == 0) @@ -199,7 +199,7 @@ bool kbhRuntimeOptionsGetFloat32(const char* opt_name, float* dst) bool kbhRuntimeOptionsGetInt(const char* opt_name, int32_t* dst) { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { if(strcmp(ptr->name, opt_name) == 0) @@ -217,7 +217,7 @@ bool kbhRuntimeOptionsGetInt(const char* opt_name, int32_t* dst) bool kbhRuntimeOptionsGetBool(const char* opt_name, bool* dst) { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { if(strcmp(ptr->name, opt_name) == 0) @@ -235,7 +235,7 @@ bool kbhRuntimeOptionsGetBool(const char* opt_name, bool* dst) void kbhRuntimeOptionsClear() { - KbhRuntimeOption* ptr = head; + KbhRuntimeOption* ptr = runtime_options_head; while(ptr != KANEL_CLI_NULLPTR) { KbhRuntimeOption* tmp = ptr->next; diff --git a/Kanel/Runtime/Sources/Core/main.c b/Kanel/Runtime/Sources/Core/main.c index e985cfb..1ad1c80 100644 --- a/Kanel/Runtime/Sources/Core/main.c +++ b/Kanel/Runtime/Sources/Core/main.c @@ -2,29 +2,14 @@ // This file is part of "kanel-CLI" // For conditions of distribution and use, see copyright notice in LICENSE -#include -#include - -#include +#include int main(int argc, char *argv[]) { - if(!kbhRuntimeOptionsParseCmd(argc, argv)) - { - kbhRuntimeOptionsClear(); - return 0; - } - kbhCoreLoadAllModulesFromCmdLine(); - - // tests - char dummy[1024]; - if(kbhRuntimeOptionsGetString("gpu", dummy, 1024)) - { - kbhInitGPUSupport(); - kbhUninitGPUSupport(); - } - - kbhCoreUnloadAllModules(); - kbhRuntimeOptionsClear(); + KbhCoreApplication* application = kbhCreateCoreApplication(argc, argv); + if(!application) + return 1; + kbhLaunchCoreApplication(application); + kbhDestroyCoreApplication(application); return 0; } diff --git a/compile_commands.json b/compile_commands.json deleted file mode 100644 index 389f6d2..0000000 --- a/compile_commands.json +++ /dev/null @@ -1,96 +0,0 @@ -[ -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_GPU_BUILD", "-DKANEL_CLI_GPU_DEBUG", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_gpu/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/RHI/RHICore.c.o", "Kanel/Runtime/Sources/Modules/GPU/RHI/RHICore.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/RHI/RHICore.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/EventBus.c.o", "Kanel/Runtime/Sources/Core/EventBus.c"], - "file": "Kanel/Runtime/Sources/Core/EventBus.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/main.c.o", "Kanel/Runtime/Sources/Core/main.c"], - "file": "Kanel/Runtime/Sources/Core/main.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/Logs.c.o", "Kanel/Runtime/Sources/Core/Logs.c"], - "file": "Kanel/Runtime/Sources/Core/Logs.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/LibLoader.c.o", "Kanel/Runtime/Sources/Core/LibLoader.c"], - "file": "Kanel/Runtime/Sources/Core/LibLoader.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/ModuleLoader.c.o", "Kanel/Runtime/Sources/Core/ModuleLoader.c"], - "file": "Kanel/Runtime/Sources/Core/ModuleLoader.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/Core/RuntimeOptions.c.o", "Kanel/Runtime/Sources/Core/RuntimeOptions.c"], - "file": "Kanel/Runtime/Sources/Core/RuntimeOptions.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/GPU/GPUSupport.c.o", "Kanel/Runtime/Sources/GPU/GPUSupport.c"], - "file": "Kanel/Runtime/Sources/GPU/GPUSupport.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-I", "/home/kbz8/.xmake/packages/v/vrg/@default/725e51fe81b74141ade9efbd3ccaf900/include", "-o", "build/Objs/linux_x86_64/kanel_cli/linux/x86_64/debug/Kanel/Runtime/Sources/GPU/RHIBindPoint.c.o", "Kanel/Runtime/Sources/GPU/RHIBindPoint.c"], - "file": "Kanel/Runtime/Sources/GPU/RHIBindPoint.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanDevice.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanDevice.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanDevice.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanInstance.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanInstance.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanInstance.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanQueue.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanQueue.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanQueue.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandPool.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandPool.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandPool.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanShaderLoader.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanShaderLoader.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanShaderLoader.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanPipeline.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanPipeline.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanPipeline.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanLoader.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanLoader.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanLoader.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanBuffer.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanBuffer.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanBuffer.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandBuffer.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandBuffer.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCommandBuffer.c" -}, -{ - "directory": "/home/kbz8/Documents/Code/GRMHD/kanel-CLI", - "arguments": ["/usr/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-O3", "-std=c23", "-IKanel/Runtime/Includes", "-IKanel/Build", "-IKanel/Runtime/Sources", "-DKANEL_CLI_DEBUG", "-DKANEL_CLI_VULKAN_BUILD", "-DKANEL_CLI_VULKAN_DEBUG", "-DVK_NO_PROTOTYPES", "-DNZSL_STATIC", "-I", "/home/kbz8/.xmake/packages/n/nzsl/2024.09.14/f8c5efc4c4b245579e8bacfb7125a63c/include", "-I", "/home/kbz8/.xmake/packages/n/nazarautils/2024.08.27/c5665ee714854eb0b8ca0680632e4dc1/include", "-I", "/home/kbz8/.xmake/packages/f/fmt/11.0.2/d396b4e809304cf1ad4202e5aa292d4c/include", "-I", "/home/kbz8/.xmake/packages/e/efsw/1.4.0/6f9ce721488c4ab5b84d813f9ec32998/include", "-I", "/home/kbz8/.xmake/packages/v/vulkan-memory-allocator/v3.1.0/0071e6d310bd4794889fe99914304a77/include", "-fPIC", "-o", "build/Objs/linux_x86_64/kanel_vulkan/linux/x86_64/debug/Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCore.c.o", "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCore.c"], - "file": "Kanel/Runtime/Sources/Modules/GPU/Vulkan/VulkanCore.c" -}] diff --git a/xmake.lua b/xmake.lua index c233095..1c15fbb 100644 --- a/xmake.lua +++ b/xmake.lua @@ -115,6 +115,7 @@ add_rules("build.gpu_plugins") option("compile_shaders", { description = "Compile nzsl shaders into an includable binary version", default = true }) option("static", { description = "Build the engine statically (implies embed_gpu_backends)", default = is_plat("wasm") or false }) option("embed_gpu_backends", { description = "Embed GPU backend code into libkanelcli_gpu instead of loading them dynamically", default = is_plat("wasm") or false }) +option("unitybuild", { description = "Build the engine using unity build", default = false }) add_requires("vrg") @@ -241,9 +242,15 @@ for name, module in pairs(modules) do add_cflags("-fPIC") end + add_ldflags("-Wl,--export-dynamic") + add_includedirs("Kanel/Runtime/Sources") add_rpathdirs("$ORIGIN") + if has_config("unitybuild") then + add_rules("c.unity_build", { batchsize = 12 }) + end + on_clean(function(target) if target:objectfiles() then for _, file in ipairs(target:objectfiles()) do @@ -280,9 +287,13 @@ target("kanel_cli") add_packages("vrg") + if has_config("unitybuild") then + add_rules("c.unity_build", { batchsize = 0 }) + end + for _, dir in ipairs(os.dirs("Kanel/Runtime/Sources/*")) do if dir ~= "Kanel/Runtime/Sources/Modules" then - add_files(dir .. "/**.c") + add_files(dir .. "/**.c", { unity_group = dir }) add_files(dir .. "/**.cpp") end end