builder: Pass down global cleanups via BuildContext

tingping/wmclass
Alexander Larsson 2016-01-11 10:36:58 +01:00
parent 5896b5ae08
commit 1b2ed4fe09
5 changed files with 64 additions and 44 deletions

View File

@ -44,6 +44,7 @@ struct BuilderContext {
BuilderOptions *options; BuilderOptions *options;
gboolean keep_build_dirs; gboolean keep_build_dirs;
char **cleanup;
}; };
typedef struct { typedef struct {
@ -70,6 +71,7 @@ builder_context_finalize (GObject *object)
g_clear_object (&self->soup_session); g_clear_object (&self->soup_session);
g_clear_object (&self->options); g_clear_object (&self->options);
g_free (self->arch); g_free (self->arch);
g_strfreev (self->cleanup);
G_OBJECT_CLASS (builder_context_parent_class)->finalize (object); G_OBJECT_CLASS (builder_context_parent_class)->finalize (object);
} }
@ -261,6 +263,20 @@ builder_context_set_keep_build_dirs (BuilderContext *self,
self->keep_build_dirs = keep_build_dirs; self->keep_build_dirs = keep_build_dirs;
} }
void
builder_context_set_global_cleanup (BuilderContext *self,
const char **cleanup)
{
g_strfreev (self->cleanup);
self->cleanup = g_strdupv ((char **)cleanup);
}
const char **
builder_context_get_global_cleanup (BuilderContext *self)
{
return (const char **)self->cleanup;
}
gboolean gboolean
builder_context_get_keep_build_dirs (BuilderContext *self) builder_context_get_keep_build_dirs (BuilderContext *self)
{ {

View File

@ -48,10 +48,14 @@ int builder_context_get_n_cpu (BuilderContext *self);
void builder_context_set_keep_build_dirs (BuilderContext *self, void builder_context_set_keep_build_dirs (BuilderContext *self,
gboolean keep_build_dirs); gboolean keep_build_dirs);
gboolean builder_context_get_keep_build_dirs (BuilderContext *self); gboolean builder_context_get_keep_build_dirs (BuilderContext *self);
void builder_context_set_global_cleanup (BuilderContext *self,
const char **cleanup);
const char ** builder_context_get_global_cleanup (BuilderContext *self);
BuilderOptions *builder_context_get_options (BuilderContext *self); BuilderOptions *builder_context_get_options (BuilderContext *self);
void builder_context_set_options (BuilderContext *self, void builder_context_set_options (BuilderContext *self,
BuilderOptions *option); BuilderOptions *option);
BuilderContext *builder_context_new (GFile *base_dir, BuilderContext *builder_context_new (GFile *base_dir,
GFile *app_dir); GFile *app_dir);

View File

@ -682,6 +682,7 @@ builder_manifest_build (BuilderManifest *self,
GList *l; GList *l;
builder_context_set_options (context, self->build_options); builder_context_set_options (context, self->build_options);
builder_context_set_global_cleanup (context, (const char **)self->cleanup);
g_print ("Starting build of %s\n", self->app_id ? self->app_id : "app"); g_print ("Starting build of %s\n", self->app_id ? self->app_id : "app");
for (l = self->modules; l != NULL; l = l->next) for (l = self->modules; l != NULL; l = l->next)
@ -926,7 +927,7 @@ builder_manifest_cleanup (BuilderManifest *self,
{ {
BuilderModule *m = l->data; BuilderModule *m = l->data;
builder_module_cleanup_collect (m, self->cleanup, to_remove_ht); builder_module_cleanup_collect (m, context, to_remove_ht);
} }
keys = (char **)g_hash_table_get_keys_as_array (to_remove_ht, &n_keys); keys = (char **)g_hash_table_get_keys_as_array (to_remove_ht, &n_keys);

View File

@ -1034,11 +1034,12 @@ builder_module_set_changes (BuilderModule *self,
void void
builder_module_cleanup_collect (BuilderModule *self, builder_module_cleanup_collect (BuilderModule *self,
char **global_patterns, BuilderContext *context,
GHashTable *to_remove_ht) GHashTable *to_remove_ht)
{ {
GPtrArray *changed_files; GPtrArray *changed_files;
int i, j; int i, j;
const char **global_patterns = builder_context_get_global_cleanup (context);
changed_files = self->changes; changed_files = self->changes;
for (i = 0; i < changed_files->len; i++) for (i = 0; i < changed_files->len; i++)

View File

@ -60,7 +60,6 @@ gboolean builder_module_build (BuilderModule *self,
gboolean builder_module_update (BuilderModule *self, gboolean builder_module_update (BuilderModule *self,
BuilderContext *context, BuilderContext *context,
GError **error); GError **error);
void builder_module_checksum (BuilderModule *self, void builder_module_checksum (BuilderModule *self,
BuilderCache *cache, BuilderCache *cache,
BuilderContext *context); BuilderContext *context);
@ -68,10 +67,9 @@ void builder_module_checksum_for_cleanup (BuilderModule *self,
BuilderCache *cache, BuilderCache *cache,
BuilderContext *context); BuilderContext *context);
void builder_module_cleanup_collect (BuilderModule *self, void builder_module_cleanup_collect (BuilderModule *self,
char **global_patterns, BuilderContext *context,
GHashTable *to_remove_ht); GHashTable *to_remove_ht);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(BuilderModule, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(BuilderModule, g_object_unref)
G_END_DECLS G_END_DECLS