core: runtime 接管用户配置模块句柄

This commit is contained in:
2026-03-24 02:42:23 +08:00
parent 3e09dec613
commit eb376e51b7
5 changed files with 73 additions and 20 deletions

View File

@@ -4,6 +4,9 @@ add_executable(${TEST_APP_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/main.c
${SOURCE_DIR}/base/log.c
${SOURCE_DIR}/backend/output_utils.c
${SOURCE_DIR}/config/defaults.c
${SOURCE_DIR}/config/loader.c
${SOURCE_DIR}/config/runtime_config.c
${SOURCE_DIR}/backend/x11/backend.c
${SOURCE_DIR}/core/layout.c
${SOURCE_DIR}/core/runtime.c
@@ -21,6 +24,7 @@ target_include_directories(${TEST_APP_NAME}
target_link_libraries(${TEST_APP_NAME}
PRIVATE m
PRIVATE ${CMAKE_DL_LIBS}
PRIVATE ${deps_LIBRARIES}
)

View File

@@ -1,9 +1,41 @@
#include "base/log.h"
#include "config/runtime_config.h"
#include "core/backend.h"
#include "core/runtime.h"
static void bootstrap(runtime_t *runtime) {
backend_t *backend = backend_create(nullptr);
backend_detect_t *detect = backend_detect(backend);
if (!backend || !detect || detect->output_count == 0) {
fatal("backend detect failed");
}
runtime_init_desc_t desc = {
.backend = backend,
.outputs = detect->outputs,
.output_count = detect->output_count,
};
if (!runtime_config_load(nullptr, &desc)) {
fatal("failed to build runtime inputs");
}
backend = nullptr;
bool inited = runtime_init(runtime, &desc);
runtime_init_desc_cleanup(&desc);
backend_detect_destroy(detect);
if (!inited) {
fatal("zdwm runtime init failed");
}
};
int main(void) {
runtime_t runtime = {0};
runtime_init(&runtime, nullptr);
bootstrap(&runtime);
runtime_shutdown(&runtime);
return 0;