manifest: expand module list

Linearize the tree of modules and submodules when the modules
are set on the manifest, while filtering out disabled modules
at the same time.

Skip source-less modules when building; this makes it possible
to have modules that only contain submodules.

With this approach, we use the tree structure of modules for
serializing and deserializing to and from json, while using
a linear list of modules for building.
tingping/wmclass
Matthias Clasen 2016-06-08 23:39:20 -04:00
parent 2757c63fea
commit e25e379a2a
1 changed files with 31 additions and 20 deletions

View File

@ -70,6 +70,7 @@ struct BuilderManifest
char *command;
BuilderOptions *build_options;
GList *modules;
GList *expanded_modules;
};
typedef struct
@ -134,6 +135,7 @@ builder_manifest_finalize (GObject *object)
g_free (self->command);
g_clear_object (&self->build_options);
g_list_free_full (self->modules, g_object_unref);
g_list_free (self->expanded_modules);
g_strfreev (self->cleanup);
g_strfreev (self->cleanup_commands);
g_strfreev (self->cleanup_platform);
@ -148,6 +150,28 @@ builder_manifest_finalize (GObject *object)
G_OBJECT_CLASS (builder_manifest_parent_class)->finalize (object);
}
static GList *
expand_modules (GList *modules)
{
GList *l;
GList *expanded = NULL;
for (l = modules; l; l = l->next)
{
BuilderModule *m = l->data;
GList *submodules;
if (builder_module_get_disabled (m))
continue;
submodules = expand_modules (builder_module_get_modules (m));
expanded = g_list_concat (expanded, submodules);
expanded = g_list_append (expanded, m);
}
return expanded;
}
static void
builder_manifest_get_property (GObject *object,
guint prop_id,
@ -357,6 +381,8 @@ builder_manifest_set_property (GObject *object,
g_list_free_full (self->modules, g_object_unref);
/* NOTE: This takes ownership of the list! */
self->modules = g_value_get_pointer (value);
g_list_free (self->expanded_modules);
self->expanded_modules = expand_modules (self->modules);
break;
case PROP_CLEANUP:
@ -995,7 +1021,7 @@ builder_manifest_checksum_for_cleanup (BuilderManifest *self,
builder_cache_checksum_str (cache, self->desktop_file_name_suffix);
builder_cache_checksum_boolean (cache, self->appstream_compose);
for (l = self->modules; l != NULL; l = l->next)
for (l = self->expanded_modules; l != NULL; l = l->next)
{
BuilderModule *m = l->data;
builder_module_checksum_for_cleanup (m, cache, context);
@ -1063,13 +1089,10 @@ builder_manifest_download (BuilderManifest *self,
GList *l;
g_print ("Downloading sources\n");
for (l = self->modules; l != NULL; l = l->next)
for (l = self->expanded_modules; l != NULL; l = l->next)
{
BuilderModule *m = l->data;
if (builder_module_get_disabled (m))
continue;
if (!builder_module_download_sources (m, update_vcs, context, error))
return FALSE;
}
@ -1092,17 +1115,11 @@ builder_manifest_build (BuilderManifest *self,
builder_context_set_separate_locales (context, self->separate_locales);
g_print ("Starting build of %s\n", self->id ? self->id : "app");
for (l = self->modules; l != NULL; l = l->next)
for (l = self->expanded_modules; l != NULL; l = l->next)
{
BuilderModule *m = l->data;
g_autoptr(GPtrArray) changes = NULL;
if (builder_module_get_disabled (m))
{
g_print ("Skipping disabled module %s\n", builder_module_get_name (m));
continue;
}
g_autofree char *stage = g_strdup_printf ("build-%s", builder_module_get_name (m));
if (!builder_module_get_sources (m))
@ -1392,13 +1409,10 @@ builder_manifest_cleanup (BuilderManifest *self,
}
}
for (l = self->modules; l != NULL; l = l->next)
for (l = self->expanded_modules; l != NULL; l = l->next)
{
BuilderModule *m = l->data;
if (builder_module_get_disabled (m))
continue;
builder_module_cleanup_collect (m, FALSE, context, to_remove_ht);
}
@ -1870,13 +1884,10 @@ builder_manifest_create_platform (BuilderManifest *self,
return FALSE;
}
for (l = self->modules; l != NULL; l = l->next)
for (l = self->expanded_modules; l != NULL; l = l->next)
{
BuilderModule *m = l->data;
if (builder_module_get_disabled (m))
continue;
builder_module_cleanup_collect (m, TRUE, context, to_remove_ht);
}