[glib: 1/2] Generate gtester-report from .in file



commit 8346017b178a010c5cd0ed50b4995fe6942ac955
Author: Simon McVittie <smcv collabora com>
Date:   Mon Sep 24 23:02:02 2018 +0100

    Generate gtester-report from .in file
    
    Previously, it was installed unmodified by the Meson build system.
    
    We don't need to define @bindir@, because gtester-report never
    actually referred to it. We also don't need a definition of
    GTESTER_REPORT for use by GLib itself, because its last use was removed
    in 2013 (https://bugzilla.gnome.org/show_bug.cgi?id=709995).
    
    Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1544
    Signed-off-by: Simon McVittie <smcv collabora com>

 glib.mk                                    |  1 -
 glib/Makefile.am                           | 27 ++++++++++-----------------
 glib/{gtester-report => gtester-report.in} |  8 ++------
 glib/meson.build                           | 11 ++++++++++-
 4 files changed, 22 insertions(+), 25 deletions(-)
---
diff --git a/glib.mk b/glib.mk
index 09aae0e87..f9d09ff6f 100644
--- a/glib.mk
+++ b/glib.mk
@@ -3,7 +3,6 @@
 #GTESTER = gtester                     # for non-GLIB packages
 #GTESTER_REPORT = gtester-report        # for non-GLIB packages
 GTESTER = $(top_builddir)/glib/gtester                 # for the GLIB package
-GTESTER_REPORT = $(top_builddir)/glib/gtester-report   # for the GLIB package
 NULL =
 
 # initialize variables for unconditional += appending
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 8f6536c6d..90d33d082 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -454,24 +454,17 @@ bin_PROGRAMS += gtester
 gtester_SOURCES         = gtester.c
 gtester_LDADD   = libglib-2.0.la 
 
-auto_config_binscripts = gtester-report
-bin_SCRIPTS = ${auto_config_binscripts}
-EXTRA_DIST += ${auto_config_binscripts}
-
-CONFIGVARS = \
-       "bindir"        : "${bindir}",          \
-       "glib-version"  : "${GLIB_VERSION}"
-
-install-exec-hook:
-       for sf in ${auto_config_binscripts} ; do \
-         mv -f "$(DESTDIR)$(bindir)/$$sf" "$(DESTDIR)$(bindir)/$$sf".tmp \
-         && sed < "$(DESTDIR)$(bindir)/$$sf".tmp > "$(DESTDIR)$(bindir)/$$sf" \
-           -e '1,24s|^ *#@PKGINSTALL_CONFIGVARS_IN24LINES@|  ${CONFIGVARS}|' \
-           -e '1,1s|#! /usr/bin/env python.*|#!${PYTHON}|' \
+bin_SCRIPTS = gtester-report
+EXTRA_DIST += gtester-report.in
+
+gtester-report: gtester-report.in Makefile
+       $(AM_V_GEN) set -e ; \
+       sed < $< > $@.tmp \
+           -e '1,1s|#!.*|#!${PYTHON}|' \
+           -e 's|[@]GLIB_VERSION[@]|${GLIB_VERSION}|' \
          || exit $$? ; \
-         chmod a+x $(DESTDIR)$(bindir)/$$sf ; \
-         rm -f "$(DESTDIR)$(bindir)/$$sf".tmp ; \
-       done
+         chmod +x $@.tmp ; \
+         mv $@.tmp $@
 
 endif
 
diff --git a/glib/gtester-report b/glib/gtester-report.in
old mode 100755
new mode 100644
similarity index 98%
rename from glib/gtester-report
rename to glib/gtester-report.in
index c4790adbb..01f6033f7
--- a/glib/gtester-report
+++ b/glib/gtester-report.in
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env @PYTHON@
 # GLib Testing Framework Utility                       -*- Mode: python; -*-
 # Copyright (C) 2007 Imendio AB
 # Authors: Tim Janik
@@ -28,10 +28,6 @@ except ImportError:
     subunit = None
 
 
-pkginstall_configvars = {
-  #@PKGINSTALL_CONFIGVARS_IN24LINES@ # configvars are substituted upon script installation
-}
-
 # xml utilities
 def find_child (node, child_name):
   for child in node.childNodes:
@@ -454,7 +450,7 @@ def parse_opts():
     :return: An options object and the program arguments.
     """
     parser = optparse.OptionParser()
-    parser.version =  pkginstall_configvars.get ('glib-version', '0.0-uninstalled')
+    parser.version = '@GLIB_VERSION@'
     parser.usage = "%prog [OPTIONS] <gtester-log.xml>"
     parser.description = "Generate HTML reports from the XML log files generated by gtester."
     parser.epilog = "gtester-report (GLib utils) version %s."% (parser.version,)
diff --git a/glib/meson.build b/glib/meson.build
index c05c69406..ea568b941 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -303,7 +303,16 @@ else
     dependencies : [libglib_dep])
 endif
 
-install_data('gtester-report', install_dir : get_option('bindir'))
+report_conf = configuration_data()
+report_conf.set('GLIB_VERSION', glib_version)
+report_conf.set('PYTHON', python_name)
+configure_file(
+  input: 'gtester-report.in',
+  output: 'gtester-report',
+  install_dir: get_option('bindir'),
+  configuration: report_conf,
+  install_mode: 'rwxr-xr-x'
+)
 
 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
 


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