forked from Mirrors/flatpak-builder
builder: Separate run-dir and base-dir
We always put the state in the .flatpak-builder subdirectory of where you ran flatpak-builder, independent on the location of the json manifest. This makes sense in general, but is also extra important when we want to check out the json from git inside the .flatpak-buidler directory.tingping/wmclass
parent
1cdd9e796d
commit
e71e4221a9
|
@ -40,7 +40,8 @@ struct BuilderContext
|
|||
GObject parent;
|
||||
|
||||
GFile *app_dir;
|
||||
GFile *base_dir;
|
||||
GFile *run_dir; /* directory flatpak-builder was started from */
|
||||
GFile *base_dir; /* directory with json manifest, origin for source files */
|
||||
SoupSession *soup_session;
|
||||
char *arch;
|
||||
char *stop_at;
|
||||
|
@ -77,7 +78,7 @@ G_DEFINE_TYPE (BuilderContext, builder_context, G_TYPE_OBJECT);
|
|||
enum {
|
||||
PROP_0,
|
||||
PROP_APP_DIR,
|
||||
PROP_BASE_DIR,
|
||||
PROP_RUN_DIR,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
@ -94,6 +95,7 @@ builder_context_finalize (GObject *object)
|
|||
g_clear_object (&self->rofiles_dir);
|
||||
g_clear_object (&self->ccache_dir);
|
||||
g_clear_object (&self->app_dir);
|
||||
g_clear_object (&self->run_dir);
|
||||
g_clear_object (&self->base_dir);
|
||||
g_clear_object (&self->soup_session);
|
||||
g_clear_object (&self->options);
|
||||
|
@ -116,8 +118,8 @@ builder_context_get_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BASE_DIR:
|
||||
g_value_set_object (value, self->base_dir);
|
||||
case PROP_RUN_DIR:
|
||||
g_value_set_object (value, self->run_dir);
|
||||
break;
|
||||
|
||||
case PROP_APP_DIR:
|
||||
|
@ -139,8 +141,8 @@ builder_context_set_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BASE_DIR:
|
||||
g_set_object (&self->base_dir, g_value_get_object (value));
|
||||
case PROP_RUN_DIR:
|
||||
g_set_object (&self->run_dir, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_APP_DIR:
|
||||
|
@ -157,7 +159,7 @@ builder_context_constructed (GObject *object)
|
|||
{
|
||||
BuilderContext *self = BUILDER_CONTEXT (object);
|
||||
|
||||
self->state_dir = g_file_get_child (self->base_dir, ".flatpak-builder");
|
||||
self->state_dir = g_file_get_child (self->run_dir, ".flatpak-builder");
|
||||
self->download_dir = g_file_get_child (self->state_dir, "downloads");
|
||||
self->build_dir = g_file_get_child (self->state_dir, "build");
|
||||
self->cache_dir = g_file_get_child (self->state_dir, "cache");
|
||||
|
@ -182,8 +184,8 @@ builder_context_class_init (BuilderContextClass *klass)
|
|||
G_TYPE_FILE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_BASE_DIR,
|
||||
g_param_spec_object ("base-dir",
|
||||
PROP_RUN_DIR,
|
||||
g_param_spec_object ("run-dir",
|
||||
"",
|
||||
"",
|
||||
G_TYPE_FILE,
|
||||
|
@ -197,12 +199,25 @@ builder_context_init (BuilderContext *self)
|
|||
self->rofiles_file_lock = init;
|
||||
}
|
||||
|
||||
GFile *
|
||||
builder_context_get_run_dir (BuilderContext *self)
|
||||
{
|
||||
return self->run_dir;
|
||||
}
|
||||
|
||||
GFile *
|
||||
builder_context_get_base_dir (BuilderContext *self)
|
||||
{
|
||||
return self->base_dir;
|
||||
}
|
||||
|
||||
void
|
||||
builder_context_set_base_dir (BuilderContext *self,
|
||||
GFile *base_dir)
|
||||
{
|
||||
g_set_object (&self->base_dir, base_dir);
|
||||
}
|
||||
|
||||
GFile *
|
||||
builder_context_get_state_dir (BuilderContext *self)
|
||||
{
|
||||
|
@ -649,11 +664,11 @@ builder_context_extend_env (BuilderContext *self,
|
|||
}
|
||||
|
||||
BuilderContext *
|
||||
builder_context_new (GFile *base_dir,
|
||||
builder_context_new (GFile *run_dir,
|
||||
GFile *app_dir)
|
||||
{
|
||||
return g_object_new (BUILDER_TYPE_CONTEXT,
|
||||
"base-dir", base_dir,
|
||||
"run-dir", run_dir,
|
||||
"app-dir", app_dir,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ GType builder_context_get_type (void);
|
|||
|
||||
GFile * builder_context_get_app_dir (BuilderContext *self);
|
||||
GFile * builder_context_get_app_dir_raw (BuilderContext *self);
|
||||
GFile * builder_context_get_run_dir (BuilderContext *self);
|
||||
GFile * builder_context_get_base_dir (BuilderContext *self);
|
||||
void builder_context_set_base_dir (BuilderContext *self,
|
||||
GFile *base_dir);
|
||||
GFile * builder_context_get_state_dir (BuilderContext *self);
|
||||
GFile * builder_context_get_cache_dir (BuilderContext *self);
|
||||
GFile * builder_context_get_build_dir (BuilderContext *self);
|
||||
|
@ -84,7 +87,7 @@ 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);
|
||||
|
||||
BuilderContext *builder_context_new (GFile *base_dir,
|
||||
BuilderContext *builder_context_new (GFile *run_dir,
|
||||
GFile *app_dir);
|
||||
gboolean builder_context_enable_ccache (BuilderContext *self,
|
||||
GError **error);
|
||||
|
|
|
@ -204,6 +204,8 @@ main (int argc,
|
|||
g_autofree char *cache_branch = NULL;
|
||||
g_autoptr(GFileEnumerator) dir_enum = NULL;
|
||||
g_autoptr(GFileEnumerator) dir_enum2 = NULL;
|
||||
g_autofree char *cwd = NULL;
|
||||
g_autoptr(GFile) cwd_dir = NULL;
|
||||
GFileInfo *next = NULL;
|
||||
const char *platform_id = NULL;
|
||||
g_autofree char **orig_argv = NULL;
|
||||
|
@ -293,6 +295,40 @@ main (int argc,
|
|||
return usage (context, "MANIFEST must be specified");
|
||||
manifest_path = argv[argnr++];
|
||||
|
||||
if (app_dir_path)
|
||||
app_dir = g_file_new_for_path (app_dir_path);
|
||||
cwd = g_get_current_dir ();
|
||||
cwd_dir = g_file_new_for_path (cwd);
|
||||
|
||||
build_context = builder_context_new (cwd_dir, app_dir);
|
||||
|
||||
builder_context_set_use_rofiles (build_context, !opt_disable_rofiles);
|
||||
builder_context_set_keep_build_dirs (build_context, opt_keep_build_dirs);
|
||||
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);
|
||||
|
||||
if (opt_arch)
|
||||
builder_context_set_arch (build_context, opt_arch);
|
||||
|
||||
if (opt_stop_at)
|
||||
{
|
||||
opt_build_only = TRUE;
|
||||
builder_context_set_stop_at (build_context, opt_stop_at);
|
||||
}
|
||||
|
||||
if (opt_ccache &&
|
||||
!builder_context_enable_ccache (build_context, &error))
|
||||
{
|
||||
g_printerr ("Can't initialize ccache use: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
manifest_file = g_file_new_for_path (manifest_path);
|
||||
base_dir = g_file_get_parent (manifest_file);
|
||||
|
||||
builder_context_set_base_dir (build_context, base_dir);
|
||||
|
||||
if (!g_file_get_contents (manifest_path, &json, NULL, &error))
|
||||
{
|
||||
g_printerr ("Can't load '%s': %s\n", manifest_path, error->message);
|
||||
|
@ -321,34 +357,6 @@ main (int argc,
|
|||
return 0;
|
||||
}
|
||||
|
||||
manifest_file = g_file_new_for_path (manifest_path);
|
||||
base_dir = g_file_get_parent (manifest_file);
|
||||
app_dir = g_file_new_for_path (app_dir_path);
|
||||
|
||||
build_context = builder_context_new (base_dir, app_dir);
|
||||
|
||||
builder_context_set_use_rofiles (build_context, !opt_disable_rofiles);
|
||||
builder_context_set_keep_build_dirs (build_context, opt_keep_build_dirs);
|
||||
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);
|
||||
|
||||
if (opt_arch)
|
||||
builder_context_set_arch (build_context, opt_arch);
|
||||
|
||||
if (opt_stop_at)
|
||||
{
|
||||
opt_build_only = TRUE;
|
||||
builder_context_set_stop_at (build_context, opt_stop_at);
|
||||
}
|
||||
|
||||
if (opt_ccache &&
|
||||
!builder_context_enable_ccache (build_context, &error))
|
||||
{
|
||||
g_printerr ("Can't initialize ccache use: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
app_dir_is_empty = !g_file_query_exists (app_dir, NULL) ||
|
||||
directory_is_empty (app_dir_path);
|
||||
|
||||
|
|
Loading…
Reference in New Issue