[polari/wip/fmuellner/ci-snapshots: 5/9] build: Add support for 'snapshot' builds



commit 90b6c575a561e8ca75f005f5bfca23c00e33eac9
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jul 25 18:05:38 2018 +0200

    build: Add support for 'snapshot' builds
    
    Our CI now generates flatpak bundles on successful builds, which
    are intended for conveniently testing proposed changes with just
    a couple of clicks. However for now we still miss that goal, due
    to two important restrictions:
    
     - the bundle uses the same ID/branch as the nightly
       build, so it can conflict or interfere with the
       installation
    
     - if Polari is already running in the session, the bundle
       has to be launched manually with --test-instance to work
    
    We will be able to address the former by adjusting the CI script to
    use a dedicated branch, but to address the latter, we need explicit
    support in the app. Add that in form of a compile time option for
    producing development snapshots, which injects --test-instance into
    the command line.
    
    https://gitlab.gnome.org/GNOME/polari/issues/61

 meson.build       |  1 +
 meson_options.txt |  5 +++++
 src/polari.c      | 10 +++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index d969d95..9892011 100644
--- a/meson.build
+++ b/meson.build
@@ -49,6 +49,7 @@ conf.set_quoted('PKGLIBDIR', pkglibdir)
 
 cc = meson.get_compiler('c')
 conf.set10('HAVE_STRCASESTR', cc.has_function('strcasestr'))
+conf.set10('SNAPSHOT', get_option('snapshot'))
 
 config_h = declare_dependency(
   sources: configure_file(
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..7457300
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('snapshot',
+  type: 'boolean',
+  value: false,
+  description: 'Build development snapshot'
+)
diff --git a/src/polari.c b/src/polari.c
index 299f984..d3dc429 100644
--- a/src/polari.c
+++ b/src/polari.c
@@ -14,13 +14,21 @@ const char *src =
 static char **
 get_js_argv (int argc, const char * const *argv)
 {
+  char * injected_args[] = {
+#ifdef SNAPSHOT
+    "--test-instance",
+#endif
+    NULL
+  };
   char **strv;
   int js_argc = argc - 1; // gjs doesn't do argv[0]
   int i;
 
-  strv = g_new0 (char *, js_argc + 1);
+  strv = g_new0 (char *, js_argc + G_N_ELEMENTS (injected_args) + 1);
   for (i = 0; i < js_argc; i++)
     strv[i] = g_strdup (argv[i + 1]);
+  for (i = 0; i < G_N_ELEMENTS (injected_args); i++)
+    strv[js_argc + i] = g_strdup (injected_args[i]);
   return strv;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]