diff --git a/builder/builder-main.c b/builder/builder-main.c index b602a980..69d833ed 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -403,12 +403,12 @@ main (int argc, } /* Can't push this as user data to the demarshalling :/ */ - builder_manifest_set_demarshal_buid_context (build_context); + builder_manifest_set_demarshal_base_dir (builder_context_get_base_dir (build_context)); manifest = (BuilderManifest *) json_gobject_from_data (BUILDER_TYPE_MANIFEST, json, -1, &error); - builder_manifest_set_demarshal_buid_context (NULL); + builder_manifest_set_demarshal_base_dir (NULL); if (manifest == NULL) { diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index 45d6637d..08c75880 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -36,12 +36,18 @@ #define LOCALES_SEPARATE_DIR "share/runtime/locale" -static BuilderContext *demarshal_build_context = NULL; +static GFile *demarshal_base_dir = NULL; void -builder_manifest_set_demarshal_buid_context (BuilderContext *build_context) +builder_manifest_set_demarshal_base_dir (GFile *dir) { - g_set_object (&demarshal_build_context, build_context); + g_set_object (&demarshal_base_dir, dir); +} + +GFile * +builder_manifest_get_demarshal_base_dir (void) +{ + return g_object_ref (demarshal_base_dir); } struct BuilderManifest @@ -954,15 +960,19 @@ builder_manifest_deserialize_property (JsonSerializable *serializable, { const char *module_relpath = json_node_get_string (element_node); g_autoptr(GFile) module_file = - g_file_resolve_relative_path (builder_context_get_base_dir (demarshal_build_context), module_relpath); + g_file_resolve_relative_path (demarshal_base_dir, module_relpath); const char *module_path = flatpak_file_get_path_cached (module_file); g_autofree char *json = NULL; g_autoptr(GError) error = NULL; if (g_file_get_contents (module_path, &json, NULL, &error)) { + g_autoptr(GFile) module_file_dir = g_file_get_parent (module_file); + g_autoptr(GFile) saved_demarshal_base_dir = builder_manifest_get_demarshal_base_dir (); + builder_manifest_set_demarshal_base_dir (module_file_dir); module = json_gobject_from_data (BUILDER_TYPE_MODULE, json, -1, &error); + builder_manifest_set_demarshal_base_dir (saved_demarshal_base_dir); if (module) builder_module_set_json_path (BUILDER_MODULE (module), module_path); } diff --git a/builder/builder-manifest.h b/builder/builder-manifest.h index c61e5530..8fd25f91 100644 --- a/builder/builder-manifest.h +++ b/builder/builder-manifest.h @@ -44,7 +44,8 @@ typedef struct BuilderManifest BuilderManifest; GType builder_manifest_get_type (void); -void builder_manifest_set_demarshal_buid_context (BuilderContext *build_context); +void builder_manifest_set_demarshal_base_dir (GFile *dir); +GFile *builder_manifest_get_demarshal_base_dir (void); const char * builder_manifest_get_id (BuilderManifest *self); char * builder_manifest_get_locale_id (BuilderManifest *self); diff --git a/builder/builder-module.c b/builder/builder-module.c index a7969632..6006a1dc 100644 --- a/builder/builder-module.c +++ b/builder/builder-module.c @@ -34,6 +34,7 @@ #include "builder-utils.h" #include "builder-module.h" #include "builder-post-process.h" +#include "builder-manifest.h" struct BuilderModule { @@ -679,12 +680,23 @@ builder_module_deserialize_property (JsonSerializable *serializable, if (JSON_NODE_HOLDS_VALUE (element_node) && json_node_get_value_type (element_node) == G_TYPE_STRING) { - const char *module_path = json_node_get_string (element_node); + g_autoptr(GFile) saved_demarshal_base_dir = builder_manifest_get_demarshal_base_dir (); + const char *module_relpath = json_node_get_string (element_node); + g_autoptr(GFile) module_file = + g_file_resolve_relative_path (saved_demarshal_base_dir, module_relpath); + const char *module_path = flatpak_file_get_path_cached (module_file); g_autofree char *json = NULL; if (g_file_get_contents (module_path, &json, NULL, NULL)) - module = json_gobject_from_data (BUILDER_TYPE_MODULE, - json, -1, NULL); + { + g_autoptr(GFile) module_file_dir = g_file_get_parent (module_file); + builder_manifest_set_demarshal_base_dir (module_file_dir); + module = json_gobject_from_data (BUILDER_TYPE_MODULE, + json, -1, NULL); + builder_manifest_set_demarshal_base_dir (saved_demarshal_base_dir); + if (module) + builder_module_set_json_path (BUILDER_MODULE (module), module_path); + } } else if (JSON_NODE_HOLDS_OBJECT (element_node)) module = json_gobject_deserialize (BUILDER_TYPE_MODULE, element_node);