Bundle sources: add flag --bundle-sources to control the bundling

By default the bundling feature is turned off.
tingping/wmclass
Simon Schampijer 2017-04-05 06:54:39 +02:00
parent 057f420b47
commit e473ca3b46
5 changed files with 25 additions and 7 deletions

View File

@ -66,6 +66,7 @@ struct BuilderContext
gboolean build_runtime;
gboolean build_extension;
gboolean separate_locales;
gboolean bundle_sources;
gboolean sandboxed;
gboolean rebuild_on_sdk_change;
gboolean use_rofiles;
@ -509,6 +510,19 @@ builder_context_set_separate_locales (BuilderContext *self,
self->separate_locales = !!separate_locales;
}
gboolean
builder_context_get_bundle_sources (BuilderContext *self)
{
return self->bundle_sources;
}
void
builder_context_set_bundle_sources (BuilderContext *self,
gboolean bundle_sources)
{
self->bundle_sources = !!bundle_sources;
}
static char *rofiles_unmount_path = NULL;
void

View File

@ -86,6 +86,9 @@ void builder_context_set_build_extension (BuilderContext *self,
gboolean builder_context_get_separate_locales (BuilderContext *self);
void builder_context_set_separate_locales (BuilderContext *self,
gboolean separate_locales);
void builder_context_set_bundle_sources (BuilderContext *self,
gboolean bundle_sources);
gboolean builder_context_get_bundle_sources (BuilderContext *self);
gboolean builder_context_get_rebuild_on_sdk_change (BuilderContext *self);
void builder_context_set_rebuild_on_sdk_change (BuilderContext *self,
gboolean rebuild_on_sdk_change);
@ -95,7 +98,6 @@ void builder_context_set_checksum_for (BuilderContext *self,
const char *name,
const char *checksum);
BuilderContext *builder_context_new (GFile *run_dir,
GFile *app_dir);
gboolean builder_context_enable_ccache (BuilderContext *self,

View File

@ -38,6 +38,7 @@ static gboolean opt_run;
static gboolean opt_disable_cache;
static gboolean opt_disable_rofiles;
static gboolean opt_download_only;
static gboolean opt_bundle_sources;
static gboolean opt_build_only;
static gboolean opt_finish_only;
static gboolean opt_show_deps;
@ -77,6 +78,7 @@ static GOptionEntry entries[] = {
{ "disable-download", 0, 0, G_OPTION_ARG_NONE, &opt_disable_download, "Don't download any new sources", NULL },
{ "disable-updates", 0, 0, G_OPTION_ARG_NONE, &opt_disable_updates, "Only download missing sources, never update to latest vcs version", NULL },
{ "download-only", 0, 0, G_OPTION_ARG_NONE, &opt_download_only, "Only download sources, don't build", NULL },
{ "bundle-sources", 0, 0, G_OPTION_ARG_NONE, &opt_bundle_sources, "Bundle module sources as runtime", NULL },
{ "use-sources", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_sources_dirs, "Build the sources specified by SOURCE-DIR, multiple uses of this option possible", "SOURCE-DIR"},
{ "build-only", 0, 0, G_OPTION_ARG_NONE, &opt_build_only, "Stop after build, don't run clean and finish phases", NULL },
{ "finish-only", 0, 0, G_OPTION_ARG_NONE, &opt_finish_only, "Only run clean and finish and export phases", NULL },
@ -323,6 +325,7 @@ main (int argc,
builder_context_set_sandboxed (build_context, opt_sandboxed);
builder_context_set_jobs (build_context, opt_jobs);
builder_context_set_rebuild_on_sdk_change (build_context, opt_rebuild_on_sdk_change);
builder_context_set_bundle_sources (build_context, opt_bundle_sources);
if (opt_sources_dirs)
{
@ -665,14 +668,14 @@ main (int argc,
}
/* Export sources extensions */
sourcesinfo_metadata = g_file_get_child (app_dir, "metadata.sourcesinfo");
if (g_file_query_exists (sourcesinfo_metadata, NULL))
sourcesinfo_metadata = g_file_get_child (app_dir, "metadata.sources");
if (builder_context_get_bundle_sources (build_context) && g_file_query_exists (sourcesinfo_metadata, NULL))
{
g_autofree char *sources_id = builder_manifest_get_sources_id (manifest);
g_print ("Exporting %s to repo\n", sources_id);
if (!do_export (build_context, &error, TRUE,
"--metadata=metadata.sourcesinfo",
"--metadata=metadata.sources",
builder_context_get_build_runtime (build_context) ? "--files=usr/sources" : "--files=sources",
opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL))
{

View File

@ -2274,12 +2274,11 @@ builder_manifest_finish (BuilderManifest *self,
return FALSE;
}
if (g_file_query_exists (sources_dir, NULL))
if (builder_context_get_bundle_sources (context) && g_file_query_exists (sources_dir, NULL))
{
g_autoptr(GFile) metadata_sources_file = NULL;
g_autofree char *metadata_contents = NULL;
g_autofree char *sources_id = builder_manifest_get_sources_id (self);
metadata_sources_file = g_file_get_child (app_dir, "metadata.sources");
metadata_contents = g_strdup_printf ("[Runtime]\n"

View File

@ -1187,7 +1187,7 @@ builder_module_build (BuilderModule *self,
if (!builder_module_extract_sources (self, source_dir, context, error))
return FALSE;
if (!builder_module_bundle_sources (self, context, error))
if (builder_context_get_bundle_sources (context) && !builder_module_bundle_sources (self, context, error))
return FALSE;
if (self->subdir != NULL && self->subdir[0] != 0)