[pangomm/pangomm-2-42] tools/gen_scripts: Update for non-source-dir builds



commit d6c44208ae2cf5f57614fe099fd51419edf594a1
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Dec 30 18:44:26 2018 +0100

    tools/gen_scripts: Update for non-source-dir builds
    
    Most modules (e.g. pango) can be built in a directory separated from the
    source directory. Update the scripts that generate .defs and doc.xml files
    to handle that.
    The environment variable JHBUILD_SOURCES is not used any more.
    Instead the environment variables GMMPROC_GEN_SOURCE_DIR and
    GMMPROC_GEN_BUILD_DIR are read. See comments in init_generate.sh.

 tools/gen_scripts/generate_all.sh              |  6 ++++
 tools/gen_scripts/init_generate.sh             | 48 ++++++++++++++++++++++++++
 tools/gen_scripts/pango_generate_docs.sh       | 23 +++++-------
 tools/gen_scripts/pango_generate_enums.sh      | 17 +++------
 tools/gen_scripts/pango_generate_extra_defs.sh | 35 +++----------------
 tools/gen_scripts/pango_generate_methods.sh    | 17 +++------
 6 files changed, 76 insertions(+), 70 deletions(-)
---
diff --git a/tools/gen_scripts/generate_all.sh b/tools/gen_scripts/generate_all.sh
index bb18495..4fa3be6 100755
--- a/tools/gen_scripts/generate_all.sh
+++ b/tools/gen_scripts/generate_all.sh
@@ -2,7 +2,13 @@
 
 # Regenerate all pangomm's docs.xml and .defs files
 
+cd "$(dirname "$0")"
+
+echo === pango_generate_docs.sh ===
 ./pango_generate_docs.sh
+echo === pango_generate_enums.sh ===
 ./pango_generate_enums.sh
+echo === pango_generate_extra_defs.sh ===
 ./pango_generate_extra_defs.sh
+echo === pango_generate_methods.sh ===
 ./pango_generate_methods.sh
diff --git a/tools/gen_scripts/init_generate.sh b/tools/gen_scripts/init_generate.sh
new file mode 100755
index 0000000..efa7ce4
--- /dev/null
+++ b/tools/gen_scripts/init_generate.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# This file is part of pangomm-1.4.
+# Initializes some variables for the scripts that generate docs and defs files.
+# Not intented to be called directly from the command line.
+
+# Global environment variables:
+# GMMPROC_GEN_SOURCE_DIR  Top directory where source files are searched for.
+#                         Default value: $(dirname "$0")/../../..
+#                         i.e. 3 levels above this file.
+# GMMPROC_GEN_BUILD_DIR   Top directory where built files are searched for.
+#                         Default value: $GMMPROC_GEN_SOURCE_DIR
+#
+# If you use jhbuild, you can set these environment variables equal to jhbuild's
+# configuration variables checkoutroot and buildroot, respectively.
+# Usually you can leave GMMPROC_GEN_SOURCE_DIR undefined.
+# If you have set buildroot=None, GMMPROC_GEN_BUILD_DIR can also be undefined.
+
+# Root directory of pangomm-1.4 source files.
+root_dir="$(dirname "$0")/../.."
+
+# Where to search for source files.
+if [ -z "$GMMPROC_GEN_SOURCE_DIR" ]; then
+  GMMPROC_GEN_SOURCE_DIR="$root_dir/.."
+fi
+
+# Where to search for built files.
+if [ -z "$GMMPROC_GEN_BUILD_DIR" ]; then
+  GMMPROC_GEN_BUILD_DIR="$GMMPROC_GEN_SOURCE_DIR"
+fi
+
+# Scripts in glibmm-2.4. These are source files.
+gen_docs="$GMMPROC_GEN_SOURCE_DIR/glibmm-2.4/tools/defs_gen/docextract_to_xml.py"
+gen_methods="$GMMPROC_GEN_SOURCE_DIR/glibmm-2.4/tools/defs_gen/h2def.py"
+gen_enums="$GMMPROC_GEN_SOURCE_DIR/glibmm-2.4/tools/enum.pl"
+
+# Where to find executables that generate extra defs (signals and properties).
+# pangomm-1.4 is built with autotools.
+# autotools support, but don't require, non-source-dir builds.
+extra_defs_gen_dir="$GMMPROC_GEN_BUILD_DIR/pangomm-1.4/tools/extra_defs_gen"
+
+source_prefix="$GMMPROC_GEN_SOURCE_DIR/pango"
+build_prefix="$GMMPROC_GEN_BUILD_DIR/pango"
+if [ "$source_prefix" == "$build_prefix" ]; then
+  # pango is built with meson, which requires non-source-dir builds.
+  # This is what jhbuild does, if neccesary, to force non-source-dir builds.
+  build_prefix="$build_prefix/build"
+fi
diff --git a/tools/gen_scripts/pango_generate_docs.sh b/tools/gen_scripts/pango_generate_docs.sh
index 73c95cc..f43ea1e 100755
--- a/tools/gen_scripts/pango_generate_docs.sh
+++ b/tools/gen_scripts/pango_generate_docs.sh
@@ -1,24 +1,17 @@
 #!/bin/bash
 
-# Note that JHBUILD_SOURCES should be defined to contain the path to the root
-# of the jhbuild sources. The script assumes that it resides in the
-# tools/gen_scripts/ directory and the XML file will be placed in pango/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the XML file will be placed in pango/src.
 
-if [ -z "$JHBUILD_SOURCES" ]; then
-  echo -e "JHBUILD_SOURCES must contain the path to the jhbuild sources."
-  exit 1;
-fi
+source "$(dirname "$0")/init_generate.sh"
 
-PREFIX="$JHBUILD_SOURCES"
-ROOT_DIR="$(dirname "$0")/../.."
-OUT_DIR="$ROOT_DIR/pango/src"
+out_dir="$root_dir/pango/src"
 
-PARAMS="--with-properties --no-recursion"
-for dir in "$PREFIX"/pango/pango "$PREFIX"/pango/build/pango; do
+params="--with-properties --no-recursion"
+for dir in "$source_prefix"/pango "$build_prefix"/pango; do
   if [ -d "$dir" ]; then
-    PARAMS="$PARAMS -s $dir"
+    params="$params -s $dir"
   fi
 done
 
-DOCEXTRACT_TO_XML_PY="$JHBUILD_SOURCES/glibmm/tools/defs_gen/docextract_to_xml.py"
-$DOCEXTRACT_TO_XML_PY $PARAMS > "$OUT_DIR/pango_docs.xml"
+"$gen_docs" $params > "$out_dir/pango_docs.xml"
diff --git a/tools/gen_scripts/pango_generate_enums.sh b/tools/gen_scripts/pango_generate_enums.sh
index 9f2d65c..6f6899a 100755
--- a/tools/gen_scripts/pango_generate_enums.sh
+++ b/tools/gen_scripts/pango_generate_enums.sh
@@ -1,20 +1,13 @@
 #!/bin/bash
 
-# Note that JHBUILD_SOURCES should be defined to contain the path to the root
-# of the jhbuild sources. The script assumes that it resides in the
-# tools/gen_scripts/ directory and the defs file will be placed in pango/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the defs file will be placed in pango/src.
 
-if [ -z "$JHBUILD_SOURCES" ]; then
-  echo -e "JHBUILD_SOURCES must contain the path to the jhbuild sources."
-  exit 1;
-fi
+source "$(dirname "$0")/init_generate.sh"
 
-PREFIX="$JHBUILD_SOURCES/pango"
-ROOT_DIR="$(dirname "$0")/../.."
-OUT_DIR="$ROOT_DIR/pango/src"
+out_dir="$root_dir/pango/src"
 
 shopt -s extglob # Enable extended pattern matching
 shopt -s nullglob # Skip a filename pattern that matches no file
-ENUM_PL="$JHBUILD_SOURCES/glibmm/tools/enum.pl"
 # Process files whose names end with .h, but not with private.h or internal.h.
-$ENUM_PL "$PREFIX"/pango/!(*private|*internal).h "$PREFIX"/build/pango/!(*private).h > 
"$OUT_DIR"/pango_enums.defs
+"$gen_enums" "$source_prefix"/pango/!(*private|*internal).h "$build_prefix"/pango/!(*private).h > 
"$out_dir"/pango_enums.defs
diff --git a/tools/gen_scripts/pango_generate_extra_defs.sh b/tools/gen_scripts/pango_generate_extra_defs.sh
index fd001b8..efd6749 100755
--- a/tools/gen_scripts/pango_generate_extra_defs.sh
+++ b/tools/gen_scripts/pango_generate_extra_defs.sh
@@ -2,37 +2,10 @@
 
 # The script assumes that it resides in the tools/gen_scripts directory
 # and the defs files will be placed in pango/src.
-# It shall be executed from the tools/gen_scripts directory.
 
-# To update the gtk_signals.defs file:
-# 1. ./pango_generate_extra_defs.sh
-#    Generates pango/src/pango_signals.defs.orig and pango/src/pango_signals.defs.
-#    If any hunks from the patch file fail to apply, apply them manually to the
-#    pango_signals.defs file, if required.
-# 2. Optional: Remove pango/src/pango_signals.defs.orig.
+source "$(dirname "$0")/init_generate.sh"
 
-# To update the pango_signals.defs file and the patch file:
-# 1. Like step 1 when updating only the pango_signals.defs file.
-# 2. Apply new patches manually to the pango_signals.defs file.
-# 3. ./pango_generate_extra_defs.sh --make-patch
-# 4. Like step 2 when updating only the pango_signals.defs file.
-
-ROOT_DIR="$(dirname "$0")/../.."
-GEN_DIR="$ROOT_DIR/tools/extra_defs_gen"
-OUT_DIR="$ROOT_DIR/pango/src"
-OUT_DEFS_FILE="$OUT_DIR"/pango_signals.defs
-
-if [ $# -eq 0 ]
-then
-  # Without LC_ALL=C documentation (docs "xxx") may be translated in the .defs file.
-  LC_ALL=C "$GEN_DIR"/generate_extra_defs > "$OUT_DEFS_FILE"
-  # PATCH_OPTIONS="--backup --version-control=simple --suffix=.orig"
-  # patch $PATCH_OPTIONS "$OUT_DEFS_FILE" "$OUT_DEFS_FILE".patch
-elif [ "$1" = "--make-patch" ]
-then
-  diff --unified=5 "$OUT_DEFS_FILE".orig "$OUT_DEFS_FILE" > "$OUT_DEFS_FILE".patch
-else
-  echo "Usage: $0 [--make-patch]"
-  exit 1
-fi
+out_dir="$root_dir/pango/src"
 
+# Without LC_ALL=C documentation (docs "xxx") may be translated in the .defs file.
+LC_ALL=C "$extra_defs_gen_dir"/generate_extra_defs > "$out_dir"/pango_signals.defs
diff --git a/tools/gen_scripts/pango_generate_methods.sh b/tools/gen_scripts/pango_generate_methods.sh
index 37e70a8..ca1b8d6 100755
--- a/tools/gen_scripts/pango_generate_methods.sh
+++ b/tools/gen_scripts/pango_generate_methods.sh
@@ -1,20 +1,13 @@
 #!/bin/bash
 
-# Note that JHBUILD_SOURCES should be defined to contain the path to the root
-# of the jhbuild sources. The script assumes that it resides in the
-# tools/gen_scripts/ directory and the defs file will be placed in pango/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory
+# and the defs file will be placed in pango/src.
 
-if [ -z "$JHBUILD_SOURCES" ]; then
-  echo -e "JHBUILD_SOURCES must contain the path to the jhbuild sources."
-  exit 1;
-fi
+source "$(dirname "$0")/init_generate.sh"
 
-PREFIX="$JHBUILD_SOURCES/pango"
-ROOT_DIR="$(dirname "$0")/../.."
-OUT_DIR="$ROOT_DIR/pango/src"
+out_dir="$root_dir/pango/src"
 
 shopt -s extglob # Enable extended pattern matching
 shopt -s nullglob # Skip a filename pattern that matches no file
-H2DEF_PY="$JHBUILD_SOURCES/glibmm/tools/defs_gen/h2def.py"
 # Process files whose names end with .h, but not with private.h or internal.h.
-$H2DEF_PY "$PREFIX"/pango/!(*private|*internal).h "$PREFIX"/build/pango/!(*private).h > 
"$OUT_DIR"/pango_methods.defs
+"$gen_methods" "$source_prefix"/pango/!(*private|*internal).h "$build_prefix"/pango/!(*private).h > 
"$out_dir"/pango_methods.defs


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