From d2c47bdce06ce6ab5a20ca91f63cf3e5c2c254b7 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 24 Jul 2019 14:45:58 +0100
Subject: [PATCH] Make generation of relocatable tarballs optional

It's easier to do test-builds without this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 ci/Jenkinsfile    |  2 +-
 meson.build       | 22 ++++++++++++----------
 meson_options.txt |  1 +
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile
index d7bc4504f..07196d105 100644
--- a/ci/Jenkinsfile
+++ b/ci/Jenkinsfile
@@ -109,7 +109,7 @@ pipeline {
               sh '''
               set -eu
               cd src
-              meson --prefix="${WORKSPACE}/src/_build/relocatable-install" -Dpython=python3.5 _build
+              meson --prefix="${WORKSPACE}/src/_build/relocatable-install" -Dpython=python3.5 -Drelocatable=true _build
               ninja -C _build
               ninja -C _build install
               meson test --verbose -C _build
diff --git a/meson.build b/meson.build
index a944c143a..0987d1f72 100644
--- a/meson.build
+++ b/meson.build
@@ -260,15 +260,17 @@ executable(
   install_rpath : '${ORIGIN}/../' + get_option('libdir'),
 )
 
-meson.add_install_script(
-  python.path(),
-  join_paths(meson.current_source_dir(), 'build-relocatable-install.py'),
-  '--srcdir', meson.current_source_dir(),
-  '--builddir', meson.current_build_dir(),
-  '--relocatabledir', relocatabledir,
-  '--prefix', get_option('prefix'),
-  '--archive', meson.current_build_dir(),
-  '--set-version', version,
-)
+if get_option('relocatable')
+  meson.add_install_script(
+    python.path(),
+    join_paths(meson.current_source_dir(), 'build-relocatable-install.py'),
+    '--srcdir', meson.current_source_dir(),
+    '--builddir', meson.current_build_dir(),
+    '--relocatabledir', relocatabledir,
+    '--prefix', get_option('prefix'),
+    '--archive', meson.current_build_dir(),
+    '--set-version', version,
+  )
+endif
 
 # vim:set sw=2 sts=2 et:
diff --git a/meson_options.txt b/meson_options.txt
index fef87a65d..78de50b94 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,4 @@
 option('python', type : 'string', value : 'python3')
+option('relocatable', type : 'boolean', value : false)
 option('relocatabledir', type : 'string', value : 'auto')
 option('version', type : 'string', value : 'auto')
-- 
GitLab