builder: Allow specifying custom prefix

tingping/wmclass
Alexander Larsson 2015-12-15 19:28:14 +01:00
parent 8b5208a995
commit a0885d4576
4 changed files with 47 additions and 3 deletions

View File

@ -727,7 +727,7 @@ builder_module_build (BuilderModule *self,
{
const char *configure_cmd;
const char *configure_final_arg = skip_arg;
const char *configure_prefix_arg = skip_arg;
g_autofree char *configure_prefix_arg = NULL;
g_autofree char *configure_content = NULL;
if (!g_file_load_contents (configure_file, NULL, &configure_content, NULL, NULL, error))
@ -766,9 +766,11 @@ builder_module_build (BuilderModule *self,
}
if (self->cmake)
configure_prefix_arg = "-DCMAKE_INSTALL_PREFIX:PATH='/app'";
configure_prefix_arg = g_strdup_printf ("-DCMAKE_INSTALL_PREFIX:PATH='%s'",
builder_options_get_prefix (self->build_options, context));
else
configure_prefix_arg = "--prefix=/app";
configure_prefix_arg = g_strdup_printf ("--prefix=%s",
builder_options_get_prefix (self->build_options, context));
if (!build (app_dir, source_dir, build_dir, build_args, env, error,
configure_cmd, configure_prefix_arg, strv_arg, self->config_opts, configure_final_arg, NULL))

View File

@ -37,6 +37,7 @@ struct BuilderOptions {
char *cflags;
char *cxxflags;
char *prefix;
char **env;
char **build_args;
GHashTable *arch;
@ -55,6 +56,7 @@ enum {
PROP_0,
PROP_CFLAGS,
PROP_CXXFLAGS,
PROP_PREFIX,
PROP_ENV,
PROP_ARCH,
PROP_BUILD_ARGS,
@ -69,6 +71,7 @@ builder_options_finalize (GObject *object)
g_free (self->cflags);
g_free (self->cxxflags);
g_free (self->prefix);
g_strfreev (self->env);
g_strfreev (self->build_args);
@ -93,6 +96,10 @@ builder_options_get_property (GObject *object,
g_value_set_string (value, self->cxxflags);
break;
case PROP_PREFIX:
g_value_set_string (value, self->prefix);
break;
case PROP_ENV:
g_value_set_boxed (value, self->env);
break;
@ -131,6 +138,11 @@ builder_options_set_property (GObject *object,
self->cxxflags = g_value_dup_string (value);
break;
case PROP_PREFIX:
g_clear_pointer (&self->prefix, g_free);
self->prefix = g_value_dup_string (value);
break;
case PROP_ENV:
tmp = self->env;
self->env = g_strdupv (g_value_get_boxed (value));
@ -177,6 +189,13 @@ builder_options_class_init (BuilderOptionsClass *klass)
"",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_PREFIX,
g_param_spec_string ("prefix",
"",
"",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ENV,
g_param_spec_boxed ("env",
@ -439,6 +458,22 @@ builder_options_get_cxxflags (BuilderOptions *self, BuilderContext *context)
return NULL;
}
const char *
builder_options_get_prefix (BuilderOptions *self, BuilderContext *context)
{
g_autoptr(GList) options = get_all_options (self, context);
GList *l;
for (l = options; l != NULL; l = l->next)
{
BuilderOptions *o = l->data;
if (o->prefix)
return o->prefix;
}
return "/app";
}
char **
builder_options_get_env (BuilderOptions *self, BuilderContext *context)
{
@ -514,6 +549,7 @@ builder_options_checksum (BuilderOptions *self,
builder_cache_checksum_str (cache, BUILDER_OPTION_CHECKSUM_VERSION);
builder_cache_checksum_str (cache, self->cflags);
builder_cache_checksum_str (cache, self->cxxflags);
builder_cache_checksum_str (cache, self->prefix);
builder_cache_checksum_strv (cache, self->env);
builder_cache_checksum_strv (cache, self->build_args);

View File

@ -42,6 +42,8 @@ const char *builder_options_get_cflags (BuilderOptions *self,
BuilderContext *context);
const char *builder_options_get_cxxflags (BuilderOptions *self,
BuilderContext *context);
const char *builder_options_get_prefix (BuilderOptions *self,
BuilderContext *context);
char ** builder_options_get_env (BuilderOptions *self,
BuilderContext *context);
char ** builder_options_get_build_args (BuilderOptions *self,

View File

@ -186,6 +186,10 @@
<term><option>cxxflags</option></term>
<listitem><para>This is set in the environment variable CXXFLAGS during the build.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>prefix</option></term>
<listitem><para>The build prefix for the modules (defaults to <filename>/app</filename>).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>env</option></term>
<listitem><para>This is a dictionary defining environment variables to be set during the build.</para></listitem>