xdg-app-builder: Add --arch command line option

This is only useful for building for architectures which are
compatible with the build host, e.g. building i686 binaries on
an x86_64 build host.
tingping/wmclass
Tristan Van Berkom 2016-04-30 22:43:39 +01:00 committed by Alexander Larsson
parent 126d805e90
commit aa69c1afef
3 changed files with 21 additions and 2 deletions

View File

@ -836,14 +836,18 @@ builder_manifest_start (BuilderManifest *self,
BuilderContext *context,
GError **error)
{
self->sdk_commit = xdg_app (NULL, "info", "--show-commit", self->sdk,
g_autofree char *arch_option;
arch_option = g_strdup_printf ("--arch=%s", builder_context_get_arch (context));
self->sdk_commit = xdg_app (NULL, "info", arch_option, "--show-commit", self->sdk,
builder_manifest_get_runtime_version (self), NULL);
if (self->sdk_commit == NULL)
return xdg_app_fail (error, "Unable to find sdk %s version %s",
self->sdk,
builder_manifest_get_runtime_version (self));
self->runtime_commit = xdg_app (NULL, "info", "--show-commit", self->runtime,
self->runtime_commit = xdg_app (NULL, "info", arch_option, "--show-commit", self->runtime,
builder_manifest_get_runtime_version (self), NULL);
if (self->runtime_commit == NULL)
return xdg_app_fail (error, "Unable to find runtime %s version %s",
@ -905,6 +909,7 @@ builder_manifest_init_app_dir (BuilderManifest *self,
for (i = 0; self->tags[i] != NULL; i++)
g_ptr_array_add (args, g_strdup_printf ("--tag=%s", self->tags[i]));
}
g_ptr_array_add (args, g_strdup_printf ("--arch=%s", builder_context_get_arch (context)));
g_ptr_array_add (args, g_file_get_path (app_dir));
g_ptr_array_add (args, g_strdup (self->id));
g_ptr_array_add (args, g_strdup (self->sdk));
@ -1751,6 +1756,7 @@ builder_manifest_create_platform (BuilderManifest *self,
g_ptr_array_add (args, g_strdup ("--update"));
g_ptr_array_add (args, g_strdup ("--writable-sdk"));
g_ptr_array_add (args, g_strdup ("--sdk-dir=platform"));
g_ptr_array_add (args, g_strdup_printf ("--arch=%s", builder_context_get_arch (context)));
for (i = 0; self->platform_extensions != NULL && self->platform_extensions[i] != NULL; i++)
{

View File

@ -44,6 +44,7 @@ static gboolean opt_ccache;
static gboolean opt_require_changes;
static gboolean opt_keep_build_dirs;
static gboolean opt_force_clean;
static char *opt_arch;
static char *opt_repo;
static char *opt_subject;
static char *opt_body;
@ -53,6 +54,7 @@ static char **opt_key_ids;
static GOptionEntry entries[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL },
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Architecture to build for (must be host compatible)", "ARCH" },
{ "run", 0, 0, G_OPTION_ARG_NONE, &opt_run, "Run a command in the build directory", NULL },
{ "ccache", 0, 0, G_OPTION_ARG_NONE, &opt_ccache, "Use ccache", NULL },
{ "disable-cache", 0, 0, G_OPTION_ARG_NONE, &opt_disable_cache, "Disable cache", NULL },
@ -230,6 +232,9 @@ main (int argc,
builder_context_set_keep_build_dirs (build_context, opt_keep_build_dirs);
if (opt_arch)
builder_context_set_arch (build_context, opt_arch);
if (opt_ccache &&
!builder_context_enable_ccache (build_context, &error))
{

View File

@ -549,6 +549,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--arch=ARCH</option></term>
<listitem><para>
Specify the machine architecture to build for. If no architecture is specified, the host architecture will be automatically detected. Only host compatible architectures can be specified.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-cache</option></term>