From 5c6904cd135a3cb22ae0ac177586e84c435f2cee Mon Sep 17 00:00:00 2001 From: icex2 Date: Mon, 19 Feb 2024 23:21:28 +0100 Subject: [PATCH] refactor(launcher): Tweak usage of property-util accordingly --- src/main/launcher/bootstrap-config.c | 13 +++- src/main/launcher/bootstrap.c | 94 ++++++++++++++++++---------- src/main/launcher/bootstrap.h | 4 +- src/main/launcher/launcher-config.c | 5 +- src/main/launcher/launcher.c | 13 ++-- 5 files changed, 83 insertions(+), 46 deletions(-) diff --git a/src/main/launcher/bootstrap-config.c b/src/main/launcher/bootstrap-config.c index 1f17ca7..35915c6 100644 --- a/src/main/launcher/bootstrap-config.c +++ b/src/main/launcher/bootstrap-config.c @@ -277,6 +277,7 @@ static void _bootstrap_config_inheritance_resolve( char inherit_name[64]; avs_error error; + struct property_node *result; startup_profile_node = property_search(NULL, startup_node, profile_name); @@ -319,7 +320,15 @@ static void _bootstrap_config_inheritance_resolve( inherit_name, inherited_nodes[i]); - property_node_clone(NULL, startup_profile_node, tmp_node, TRUE); + result = property_node_clone( + NULL, startup_profile_node, tmp_node, true); + + if (!result) { + log_fatal( + "Merging '%s' into '%s' failed", + inherited_nodes[i], + inherit_name); + } } } } @@ -335,7 +344,7 @@ static void _bootstrap_config_load_bootstrap_module_app_config( app_node = property_search(NULL, profile_node, "component/param"); - config->app_config = property_util_clone(app_node); + config->app_config = property_util_node_extract(app_node); } static void _bootstrap_config_load_bootstrap_default_files_config( diff --git a/src/main/launcher/bootstrap.c b/src/main/launcher/bootstrap.c index f48c053..a9e52bb 100644 --- a/src/main/launcher/bootstrap.c +++ b/src/main/launcher/bootstrap.c @@ -160,40 +160,54 @@ void bootstrap_default_files_create( void bootstrap_avs_init( const struct bootstrap_boot_config *config, const struct bootstrap_log_config *log_config, - struct property_node *override_node) + struct property *override_property) { - struct property *property; - struct property_node *node; + struct property *file_property; + struct property *merged_property; + struct property_node *root_node; log_assert(config); log_assert(log_config); - log_assert(override_node); + log_assert(override_property); log_info("avs init"); - property = avs_config_load(config->config_file); - node = avs_config_root_get(property); - - property_util_node_merge(property, node, override_node); + file_property = avs_config_load(config->config_file); if (_bootstrap_log_property_configs) { - log_misc("avs-config"); - property_util_node_log(node); + log_misc("avs-config from file: %s", config->config_file); + property_util_log(file_property); } - _bootstrap_avs_config_force_overrides_apply(node); - _bootstrap_avs_config_log_overrides_apply(node, log_config); + merged_property = + avs_config_property_merge(file_property, override_property); - avs_fs_assert_root_device_exists(node); + property_util_free(file_property); - log_misc("Creating AVS file system directories for nvram and raw..."); + if (_bootstrap_log_property_configs) { + log_misc("avs-config merged with overrides"); + property_util_log(merged_property); + } - avs_fs_mountpoint_dir_create(node, "nvram"); - avs_fs_mountpoint_dir_create(node, "raw"); + root_node = avs_config_root_get(merged_property); - avs_init(node, config->avs_heap_size, config->std_heap_size); + _bootstrap_avs_config_force_overrides_apply(root_node); + _bootstrap_avs_config_log_overrides_apply(root_node, log_config); - property_util_free(property); + if (_bootstrap_log_property_configs) { + log_misc("avs-config final"); + property_util_log(merged_property); + } + + avs_fs_assert_root_device_exists(root_node); + + log_misc("Creating AVS file system directories..."); + + avs_fs_mountpoints_fs_dirs_create(root_node); + + avs_init(root_node, config->avs_heap_size, config->std_heap_size); + + property_util_free(merged_property); log_misc("avs init done"); } @@ -201,35 +215,47 @@ void bootstrap_avs_init( void bootstrap_eamuse_init( const struct bootstrap_eamuse_config *config, const struct ea3_ident_config *ea3_ident_config, - struct property_node *override_node) + struct property *override_property) { - struct property *property; - struct property_node *node; + struct property *file_property; + struct property *merged_property; + struct property_node *root_node; log_assert(config); log_assert(ea3_ident_config); - log_assert(override_node); + log_assert(override_property); log_info("eamuse init"); if (config->enable) { - property = eamuse_config_avs_load(config->config_file); - node = eamuse_config_root_get(property); - - property_util_node_merge(property, node, override_node); - - _bootstrap_eamuse_ea3_ident_config_inject(node, ea3_ident_config); - - property_util_node_log(node); + file_property = eamuse_config_avs_load(config->config_file); if (_bootstrap_log_property_configs) { - log_misc("eamuse-config"); - property_util_node_log(node); + log_misc("eamuse-config from file: %s", config->config_file); + property_util_log(file_property); } - eamuse_init(node); + merged_property = property_util_merge(file_property, override_property); - property_util_free(property); + property_util_free(file_property); + + if (_bootstrap_log_property_configs) { + log_misc("eamuse-config merged with overrides"); + property_util_log(merged_property); + } + + root_node = eamuse_config_root_get(merged_property); + + _bootstrap_eamuse_ea3_ident_config_inject(root_node, ea3_ident_config); + + if (_bootstrap_log_property_configs) { + log_misc("eamuse-config final"); + property_util_log(merged_property); + } + + eamuse_init(root_node); + + property_util_free(merged_property); } else { log_warning("Eamuse disabled"); } diff --git a/src/main/launcher/bootstrap.h b/src/main/launcher/bootstrap.h index 9006bf7..4deab8f 100644 --- a/src/main/launcher/bootstrap.h +++ b/src/main/launcher/bootstrap.h @@ -13,11 +13,11 @@ void bootstrap_default_files_create( void bootstrap_avs_init( const struct bootstrap_boot_config *config, const struct bootstrap_log_config *log_config, - struct property_node *override_node); + struct property *override_property); void bootstrap_eamuse_init( const struct bootstrap_eamuse_config *config, const struct ea3_ident_config *ea3_ident_config, - struct property_node *override_node); + struct property *override_property); void bootstrap_module_init( const struct bootstrap_module_config *module_config, const struct array *iat_hook_dlls); diff --git a/src/main/launcher/launcher-config.c b/src/main/launcher/launcher-config.c index a42d3d0..6f278e0 100644 --- a/src/main/launcher/launcher-config.c +++ b/src/main/launcher/launcher-config.c @@ -75,7 +75,7 @@ _launcher_config_layered_config_nodes_load(struct property_node *node) // node cur = property_node_traversal(cur, TRAVERSE_FIRST_CHILD); - config_property[cnt] = property_util_clone(cur); + config_property[cnt] = property_util_node_extract(cur); } else { log_fatal( "Unsupported 'kind' attribute value '%s' of config node", kind); @@ -89,8 +89,7 @@ _launcher_config_layered_config_nodes_load(struct property_node *node) return NULL; } - merged_property = - property_util_merge((struct property **) &config_property[0], cnt); + merged_property = property_util_many_merge(config_property, cnt); for (int i = 0; i < cnt; i++) { property_util_free(config_property[i]); diff --git a/src/main/launcher/launcher.c b/src/main/launcher/launcher.c index 64b2e23..ea33469 100644 --- a/src/main/launcher/launcher.c +++ b/src/main/launcher/launcher.c @@ -265,8 +265,7 @@ _launcher_remote_debugger_trap(const struct launcher_debug_config *config) } static void _launcher_procmon_init( - const struct launcher_debug_config *config, - struct procmon *procmon) + const struct launcher_debug_config *config, struct procmon *procmon) { procmon_init(procmon); @@ -537,7 +536,7 @@ void _launcher_init( bootstrap_avs_init( &bootstrap_config->startup.boot, &bootstrap_config->startup.log, - avs_config_root_get(launcher_config->avs.property)); + launcher_config->avs.property); bootstrap_default_files_create(&bootstrap_config->startup.default_file); _launcher_ea3_ident_config_load( @@ -576,7 +575,7 @@ void _launcher_run( bootstrap_eamuse_init( &bootstrap_config->startup.eamuse, ea3_ident_config, - eamuse_config_root_get(launcher_config->eamuse.property)); + launcher_config->eamuse.property); bootstrap_module_game_run(); } @@ -619,7 +618,11 @@ void launcher_main(const struct options *options) log_assert(options); _launcher_init( - options, &launcher_config, &bootstrap_config, &ea3_ident_config, &procmon); + options, + &launcher_config, + &bootstrap_config, + &ea3_ident_config, + &procmon); _launcher_run(&launcher_config, &bootstrap_config, &ea3_ident_config);