[gnome-builder] build: add build parallelize gsetting
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build: add build parallelize gsetting
- Date: Wed, 23 Dec 2015 08:25:19 +0000 (UTC)
commit 2d314a6c25e4023606c48dbe6a8e76f244fc2231
Author: Christian Hergert <chergert redhat com>
Date: Wed Dec 23 00:20:57 2015 -0800
build: add build parallelize gsetting
I usually run with -j12 on my machines, so something like:
gsettings set org.gnome.builder.build parallel 12
-1 will get you nprocs()+1
0 will get you nprocs()
data/gsettings/Makefile.am | 1 +
data/gsettings/org.gnome.builder.build.gschema.xml | 10 +++++++
plugins/autotools/ide-autotools-build-task.c | 10 +++++--
plugins/autotools/ide-autotools-builder.c | 26 ++++++++++++++++++-
4 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/data/gsettings/Makefile.am b/data/gsettings/Makefile.am
index d8b73b5..853a020 100644
--- a/data/gsettings/Makefile.am
+++ b/data/gsettings/Makefile.am
@@ -1,4 +1,5 @@
gsettings_SCHEMAS = \
+ org.gnome.builder.build.gschema.xml \
org.gnome.builder.code-insight.gschema.xml \
org.gnome.builder.editor.gschema.xml \
org.gnome.builder.editor.language.gschema.xml \
diff --git a/data/gsettings/org.gnome.builder.build.gschema.xml
b/data/gsettings/org.gnome.builder.build.gschema.xml
new file mode 100644
index 0000000..0a7ce7f
--- /dev/null
+++ b/data/gsettings/org.gnome.builder.build.gschema.xml
@@ -0,0 +1,10 @@
+<schemalist>
+ <schema id="org.gnome.builder.build" path="/org/gnome/builder/build/" gettext-domain="gnome-builder">
+ <key name="parallel" type="i">
+ <default>-1</default>
+ <range min="-1" max="512"/>
+ <summary>Build Parallelism</summary>
+ <description>Number of workers to use when performing builds. -1 for sensible default. 0 for number of
CPU.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/plugins/autotools/ide-autotools-build-task.c b/plugins/autotools/ide-autotools-build-task.c
index cd35078..b84fe78 100644
--- a/plugins/autotools/ide-autotools-build-task.c
+++ b/plugins/autotools/ide-autotools-build-task.c
@@ -547,10 +547,14 @@ worker_state_new (IdeAutotoolsBuildTask *self)
state->project_path = g_file_get_path (project_dir);
state->system_type = g_strdup (ide_device_get_system_type (priv->device));
- if ((val32 = g_key_file_get_integer (priv->config, "parallel", "workers", NULL)))
- state->parallel = g_strdup_printf ("-j%u", val32);
+ val32 = g_key_file_get_integer (priv->config, "parallel", "workers", NULL);
+
+ if (val32 == -1)
+ state->parallel = g_strdup_printf ("-j%u", g_get_num_processors () + 1);
+ else if (val32 == 0)
+ state->parallel = g_strdup_printf ("-j%u", g_get_num_processors ());
else
- state->parallel = g_strdup ("-j1");
+ state->parallel = g_strdup_printf ("-j%u", val32);
make_targets = g_ptr_array_new ();
diff --git a/plugins/autotools/ide-autotools-builder.c b/plugins/autotools/ide-autotools-builder.c
index 05bb5bc..41c63b3 100644
--- a/plugins/autotools/ide-autotools-builder.c
+++ b/plugins/autotools/ide-autotools-builder.c
@@ -45,6 +45,23 @@ enum {
static GParamSpec *properties [LAST_PROP];
+static void
+ide_autotools_builder_merge_defaults (IdeAutotoolsBuilder *self,
+ GKeyFile *key_file)
+{
+ g_return_if_fail (IDE_IS_AUTOTOOLS_BUILDER (self));
+ g_return_if_fail (key_file != NULL);
+
+ if (!g_key_file_has_key (key_file, "parallel", "workers", NULL))
+ {
+ g_autoptr(GSettings) settings = g_settings_new ("org.gnome.builder.build");
+
+ g_key_file_set_integer (key_file,
+ "parallel", "workers",
+ g_settings_get_int (settings, "parallel"));
+ }
+}
+
GKeyFile *
ide_autotools_builder_get_config (IdeAutotoolsBuilder *self)
{
@@ -62,8 +79,13 @@ ide_autotools_builder_set_config (IdeAutotoolsBuilder *self,
if (self->config != config)
{
g_clear_pointer (&self->config, g_key_file_unref);
- if (config)
- self->config = g_key_file_ref (config);
+
+ if (config != NULL)
+ {
+ self->config = g_key_file_ref (config);
+ ide_autotools_builder_merge_defaults (self, config);
+ }
+
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONFIG]);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]