mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-13 12:41:01 -04:00
builder: Add support for ldflags
This commit is contained in:
@@ -40,6 +40,7 @@ struct BuilderOptions
|
||||
gboolean no_debuginfo;
|
||||
char *cflags;
|
||||
char *cxxflags;
|
||||
char *ldflags;
|
||||
char *prefix;
|
||||
char **env;
|
||||
char **build_args;
|
||||
@@ -61,6 +62,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_CFLAGS,
|
||||
PROP_CXXFLAGS,
|
||||
PROP_LDFLAGS,
|
||||
PROP_PREFIX,
|
||||
PROP_ENV,
|
||||
PROP_STRIP,
|
||||
@@ -79,6 +81,7 @@ builder_options_finalize (GObject *object)
|
||||
|
||||
g_free (self->cflags);
|
||||
g_free (self->cxxflags);
|
||||
g_free (self->ldflags);
|
||||
g_free (self->prefix);
|
||||
g_strfreev (self->env);
|
||||
g_strfreev (self->build_args);
|
||||
@@ -106,6 +109,10 @@ builder_options_get_property (GObject *object,
|
||||
g_value_set_string (value, self->cxxflags);
|
||||
break;
|
||||
|
||||
case PROP_LDFLAGS:
|
||||
g_value_set_string (value, self->ldflags);
|
||||
break;
|
||||
|
||||
case PROP_PREFIX:
|
||||
g_value_set_string (value, self->prefix);
|
||||
break;
|
||||
@@ -160,6 +167,11 @@ builder_options_set_property (GObject *object,
|
||||
self->cxxflags = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_LDFLAGS:
|
||||
g_clear_pointer (&self->ldflags, g_free);
|
||||
self->ldflags = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_PREFIX:
|
||||
g_clear_pointer (&self->prefix, g_free);
|
||||
self->prefix = g_value_dup_string (value);
|
||||
@@ -225,6 +237,13 @@ builder_options_class_init (BuilderOptionsClass *klass)
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LDFLAGS,
|
||||
g_param_spec_string ("ldflags",
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PREFIX,
|
||||
g_param_spec_string ("prefix",
|
||||
@@ -519,6 +538,22 @@ builder_options_get_cxxflags (BuilderOptions *self, BuilderContext *context)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
builder_options_get_ldflags (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->ldflags)
|
||||
return o->ldflags;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
builder_options_get_prefix (BuilderOptions *self, BuilderContext *context)
|
||||
{
|
||||
@@ -577,7 +612,7 @@ builder_options_get_env (BuilderOptions *self, BuilderContext *context)
|
||||
GList *l;
|
||||
int i;
|
||||
char **envp = NULL;
|
||||
const char *cflags, *cxxflags;
|
||||
const char *cflags, *cxxflags, *ldflags;
|
||||
|
||||
for (l = options; l != NULL; l = l->next)
|
||||
{
|
||||
@@ -617,6 +652,10 @@ builder_options_get_env (BuilderOptions *self, BuilderContext *context)
|
||||
if (cxxflags)
|
||||
envp = g_environ_setenv (envp, "CXXFLAGS", cxxflags, TRUE);
|
||||
|
||||
ldflags = builder_options_get_ldflags (self, context);
|
||||
if (ldflags)
|
||||
envp = g_environ_setenv (envp, "LDFLAGS", cxxflags, TRUE);
|
||||
|
||||
return envp;
|
||||
}
|
||||
|
||||
@@ -701,6 +740,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->ldflags);
|
||||
builder_cache_checksum_str (cache, self->prefix);
|
||||
builder_cache_checksum_strv (cache, self->env);
|
||||
builder_cache_checksum_strv (cache, self->build_args);
|
||||
|
||||
@@ -41,6 +41,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_ldflags (BuilderOptions *self,
|
||||
BuilderContext *context);
|
||||
const char *builder_options_get_prefix (BuilderOptions *self,
|
||||
BuilderContext *context);
|
||||
char ** builder_options_get_env (BuilderOptions *self,
|
||||
|
||||
@@ -276,6 +276,10 @@
|
||||
<term><option>cxxflags</option> (string)</term>
|
||||
<listitem><para>This is set in the environment variable CXXFLAGS during the build.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>ldflags</option> (string)</term>
|
||||
<listitem><para>This is set in the environment variable LDFLAGS during the build.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>prefix</option> (string)</term>
|
||||
<listitem><para>The build prefix for the modules (defaults to <filename>/app</filename> for
|
||||
|
||||
Reference in New Issue
Block a user