[gtkmm/gtkmm-3-24] tools/gen_scripts: Update for non-source-dir builds
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-3-24] tools/gen_scripts: Update for non-source-dir builds
- Date: Sat, 29 Dec 2018 11:15:19 +0000 (UTC)
commit 41d1b5724a88374f5f38dd075ee695009ad20f08
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sat Dec 29 12:12:32 2018 +0100
tools/gen_scripts: Update for non-source-dir builds
Most modules (e.g. gtk+) can be built in a directory separated from the
source directory. Update the scripts that generate .defs and docs.xml files
to handle that. See !11.
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/gdk_generate_docs.sh | 28 +++++++--------
tools/gen_scripts/gdk_generate_enums.sh | 25 ++++++--------
tools/gen_scripts/gdk_generate_extra_defs.sh | 8 ++---
tools/gen_scripts/gdk_generate_methods.sh | 25 ++++++--------
tools/gen_scripts/generate_docs_and_defs.sh | 2 ++
tools/gen_scripts/gtk_generate_docs.sh | 32 +++++++++--------
tools/gen_scripts/gtk_generate_enums.sh | 21 +++++-------
tools/gen_scripts/gtk_generate_extra_defs.sh | 18 +++++-----
tools/gen_scripts/gtk_generate_methods.sh | 21 +++++-------
tools/gen_scripts/init_generate.sh | 51 ++++++++++++++++++++++++++++
10 files changed, 135 insertions(+), 96 deletions(-)
---
diff --git a/tools/gen_scripts/gdk_generate_docs.sh b/tools/gen_scripts/gdk_generate_docs.sh
index 47483eaa..bcc3e433 100755
--- a/tools/gen_scripts/gdk_generate_docs.sh
+++ b/tools/gen_scripts/gdk_generate_docs.sh
@@ -1,25 +1,21 @@
#!/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 gdk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the XML file will be placed in gdk/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/gdk/src"
+out_dir="$root_dir/gdk/src"
-PARAMS="--with-properties --no-recursion"
-for dir in "$PREFIX"/gtk+-3/{gdk,gdk/deprecated} \
- "$PREFIX"/gdk-pixbuf/gdk-pixbuf "$PREFIX"/gdk-pixbuf/build/gdk-pixbuf; do
+params="--with-properties --no-recursion"
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ gtk_build_dir="$gtk_build_prefix"/gdk
+fi
+for dir in "$gtk_source_prefix"/{gdk,gdk/deprecated} "$gtk_build_dir" \
+ "$pixbuf_source_prefix"/gdk-pixbuf "$pixbuf_build_prefix"/gdk-pixbuf; 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"/gdk_docs.xml
+"$gen_docs" $params > "$out_dir/gdk_docs.xml"
diff --git a/tools/gen_scripts/gdk_generate_enums.sh b/tools/gen_scripts/gdk_generate_enums.sh
index f61bf380..09956b5e 100755
--- a/tools/gen_scripts/gdk_generate_enums.sh
+++ b/tools/gen_scripts/gdk_generate_enums.sh
@@ -1,22 +1,19 @@
#!/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 gdk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the defs file will be placed in gdk/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/gdk/src"
+out_dir="$root_dir/gdk/src"
shopt -s extglob # Enable extended pattern matching
-ENUM_PL="$JHBUILD_SOURCES/glibmm/tools/enum.pl"
+shopt -s nullglob # Skip a filename pattern that matches no file
# Process files whose names end with .h, but not with private.h.
# Exclude gtk+-3/gdk/gdkinternals.h.
-$ENUM_PL "$PREFIX"/gtk+-3/gdk/!(*private|gdkinternals).h "$PREFIX"/gtk+-3/gdk/deprecated/!(*private).h >
"$OUT_DIR"/gdk_enums.defs
-$ENUM_PL "$PREFIX"/gdk-pixbuf/gdk-pixbuf/gdk!(*private).h \
- "$PREFIX"/gdk-pixbuf/build/gdk-pixbuf/*.h > "$OUT_DIR"/gdk_pixbuf_enums.defs
+"$gen_enums" "$gtk_source_prefix"/gdk/!(*private|gdkinternals).h
"$gtk_source_prefix"/gdk/deprecated/!(*private).h > "$out_dir"/gdk_enums.defs
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ "$gen_enums" "$gtk_build_prefix"/gdk/*.h >> "$out_dir"/gdk_enums.defs
+fi
+"$gen_enums" "$pixbuf_source_prefix"/gdk-pixbuf/gdk!(*private).h \
+ "$pixbuf_build_prefix"/gdk-pixbuf/*.h > "$out_dir"/gdk_pixbuf_enums.defs
diff --git a/tools/gen_scripts/gdk_generate_extra_defs.sh b/tools/gen_scripts/gdk_generate_extra_defs.sh
index d726fdf7..83c0a1d8 100755
--- a/tools/gen_scripts/gdk_generate_extra_defs.sh
+++ b/tools/gen_scripts/gdk_generate_extra_defs.sh
@@ -3,10 +3,10 @@
# The script assumes that it resides in the tools/gen_scripts directory
# and the defs file will be placed in gdk/src.
-ROOT_DIR="$(dirname "$0")/../.."
-GEN_DIR="$ROOT_DIR/tools/extra_defs_gen"
-OUT_DIR="$ROOT_DIR/gdk/src"
+source "$(dirname "$0")/init_generate.sh"
+
+out_dir="$root_dir/gdk/src"
# Without LC_ALL=C documentation (docs "xxx") may be translated in the .defs file.
-LC_ALL=C "$GEN_DIR"/generate_defs_gdk > "$OUT_DIR"/gdk_signals.defs
+LC_ALL=C "$extra_defs_gen_dir"/generate_defs_gdk > "$out_dir"/gdk_signals.defs
diff --git a/tools/gen_scripts/gdk_generate_methods.sh b/tools/gen_scripts/gdk_generate_methods.sh
index 4a4af111..0161d413 100755
--- a/tools/gen_scripts/gdk_generate_methods.sh
+++ b/tools/gen_scripts/gdk_generate_methods.sh
@@ -1,22 +1,19 @@
#!/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 gdk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the defs file will be placed in gdk/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/gdk/src"
+out_dir="$root_dir/gdk/src"
shopt -s extglob # Enable extended pattern matching
-H2DEF_PY="$JHBUILD_SOURCES/glibmm/tools/defs_gen/h2def.py"
+shopt -s nullglob # Skip a filename pattern that matches no file
# Process files whose names end with .h, but not with private.h.
# Exclude gtk+-3/gdk/gdkinternals.h.
-$H2DEF_PY "$PREFIX"/gtk+-3/gdk/!(*private|gdkinternals).h "$PREFIX"/gtk+-3/gdk/deprecated/!(*private).h >
"$OUT_DIR"/gdk_methods.defs
-$H2DEF_PY "$PREFIX"/gdk-pixbuf/gdk-pixbuf/gdk!(*private).h \
- "$PREFIX"/gdk-pixbuf/build/gdk-pixbuf/*.h > "$OUT_DIR"/gdk_pixbuf_methods.defs
+"$gen_methods" "$gtk_source_prefix"/gdk/!(*private|gdkinternals).h
"$gtk_source_prefix"/gdk/deprecated/!(*private).h > "$out_dir"/gdk_methods.defs
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ "$gen_methods" "$gtk_build_prefix"/gdk/*.h >> "$out_dir"/gdk_methods.defs
+fi
+"$gen_methods" "$pixbuf_source_prefix"/gdk-pixbuf/gdk!(*private).h \
+ "$pixbuf_build_prefix"/gdk-pixbuf/*.h > "$out_dir"/gdk_pixbuf_methods.defs
diff --git a/tools/gen_scripts/generate_docs_and_defs.sh b/tools/gen_scripts/generate_docs_and_defs.sh
index 3294ce74..e15dcfd6 100755
--- a/tools/gen_scripts/generate_docs_and_defs.sh
+++ b/tools/gen_scripts/generate_docs_and_defs.sh
@@ -3,6 +3,8 @@
# Generate all docs.xml and .defs files, either for gdk or gtk or (default) both.
# This script shall be executed from the tools/gen_scripts directory.
+cd "$(dirname "$0")"
+
if [ $# -eq 0 ]
then
GENERATE_GDK_FILES="yes"
diff --git a/tools/gen_scripts/gtk_generate_docs.sh b/tools/gen_scripts/gtk_generate_docs.sh
index 5b8cf280..3a2bb662 100755
--- a/tools/gen_scripts/gtk_generate_docs.sh
+++ b/tools/gen_scripts/gtk_generate_docs.sh
@@ -1,22 +1,24 @@
#!/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 gtk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the XML file will be placed in gtk/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/gtk/src"
+out_dir="$root_dir/gtk/src"
-PARAMS="--with-properties --no-recursion"
-for dir in "$PREFIX"/gtk+-3/{gtk,gtk/deprecated}; do
- PARAMS="$PARAMS -s $dir"
+params="--with-properties --no-recursion"
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ gtk_build_dir="$gtk_build_prefix"/gtk
+fi
+for dir in "$gtk_source_prefix"/{gtk,gtk/deprecated} "$gtk_build_dir"; do
+ if [ -d "$dir" ]; then
+ 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/gtk_docs.xml"
+# Exclude gtkdnd-quartz.c. Function descriptions in gtkdnd-quartz.c can
+# replace better descriptions in gtkdnd.c, if gtkdnd-quartz.c is processed.
+params="$params -x $gtk_source_prefix/gtk/gtkdnd-quartz.c"
+
+"$gen_docs" $params > "$out_dir/gtk_docs.xml"
diff --git a/tools/gen_scripts/gtk_generate_enums.sh b/tools/gen_scripts/gtk_generate_enums.sh
index f4c9edf6..39f41ac0 100755
--- a/tools/gen_scripts/gtk_generate_enums.sh
+++ b/tools/gen_scripts/gtk_generate_enums.sh
@@ -1,19 +1,16 @@
#!/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 gtk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the defs file will be placed in gtk/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/gtk+-3"
-ROOT_DIR="$(dirname "$0")/../.."
-OUT_DIR="$ROOT_DIR/gtk/src"
+out_dir="$root_dir/gtk/src"
shopt -s extglob # Enable extended pattern matching
-ENUM_PL="$JHBUILD_SOURCES/glibmm/tools/enum.pl"
+shopt -s nullglob # Skip a filename pattern that matches no file
# Process files whose names end with .h, but not with private.h.
-$ENUM_PL "$PREFIX"/gtk/!(*private).h "$PREFIX"/gtk/deprecated/!(*private).h > "$OUT_DIR"/gtk_enums.defs
+"$gen_enums" "$gtk_source_prefix"/gtk/!(*private).h "$gtk_source_prefix"/gtk/deprecated/!(*private).h >
"$out_dir"/gtk_enums.defs
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ "$gen_enums" "$gtk_build_prefix"/gtk/*.h >> "$out_dir"/gtk_enums.defs
+fi
diff --git a/tools/gen_scripts/gtk_generate_extra_defs.sh b/tools/gen_scripts/gtk_generate_extra_defs.sh
index 8be37c02..63daf91a 100755
--- a/tools/gen_scripts/gtk_generate_extra_defs.sh
+++ b/tools/gen_scripts/gtk_generate_extra_defs.sh
@@ -17,22 +17,22 @@
# 3. ./gtk_generate_extra_defs.sh --make-patch
# 4. Like step 2 when updating only the gtk_signals.defs file.
-ROOT_DIR="$(dirname "$0")/../.."
-GEN_DIR="$ROOT_DIR/tools/extra_defs_gen"
-OUT_DIR="$ROOT_DIR/gtk/src"
-OUT_DEFS_FILE="$OUT_DIR"/gtk_signals.defs
+source "$(dirname "$0")/init_generate.sh"
+
+out_dir="$root_dir/gtk/src"
+out_defs_file="$out_dir"/gtk_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_defs_gtk > "$OUT_DEFS_FILE"
+ LC_ALL=C "$extra_defs_gen_dir"/generate_defs_gtk > "$out_defs_file"
# patch version 2.7.5 does not like directory names.
- cd "$(dirname "$OUT_DEFS_FILE")"
- PATCH_OPTIONS="--backup --version-control=simple --suffix=.orig"
- patch $PATCH_OPTIONS "$(basename "$OUT_DEFS_FILE")" "$(basename "$OUT_DEFS_FILE").patch"
+ cd "$(dirname "$out_defs_file")"
+ patch_options="--backup --version-control=simple --suffix=.orig"
+ patch $patch_options "$(basename "$out_defs_file")" "$(basename "$out_defs_file").patch"
elif [ "$1" = "--make-patch" ]
then
- diff --unified=10 "$OUT_DEFS_FILE".orig "$OUT_DEFS_FILE" > "$OUT_DEFS_FILE".patch
+ diff --unified=5 "$out_defs_file".orig "$out_defs_file" > "$out_defs_file".patch
else
echo "Usage: $0 [--make-patch]"
exit 1
diff --git a/tools/gen_scripts/gtk_generate_methods.sh b/tools/gen_scripts/gtk_generate_methods.sh
index fbb34aa1..7c1981a7 100755
--- a/tools/gen_scripts/gtk_generate_methods.sh
+++ b/tools/gen_scripts/gtk_generate_methods.sh
@@ -1,19 +1,16 @@
#!/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 gtk/src.
+# The script assumes that it resides in the tools/gen_scripts/ directory and
+# the defs file will be placed in gtk/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/gtk+-3"
-ROOT_DIR="$(dirname "$0")/../.."
-OUT_DIR="$ROOT_DIR/gtk/src"
+out_dir="$root_dir/gtk/src"
shopt -s extglob # Enable extended pattern matching
-H2DEF_PY="$JHBUILD_SOURCES/glibmm/tools/defs_gen/h2def.py"
+shopt -s nullglob # Skip a filename pattern that matches no file
# Process files whose names end with .h, but not with private.h.
-$H2DEF_PY "$PREFIX"/gtk/!(*private).h "$PREFIX"/gtk/deprecated/!(*private).h > "$OUT_DIR"/gtk_methods.defs
+"$gen_methods" "$gtk_source_prefix"/gtk/!(*private).h "$gtk_source_prefix"/gtk/deprecated/!(*private).h >
"$out_dir"/gtk_methods.defs
+if [ "$gtk_build_prefix" != "$gtk_source_prefix" ]; then
+ "$gen_methods" "$gtk_build_prefix"/gtk/*.h >> "$out_dir"/gtk_methods.defs
+fi
diff --git a/tools/gen_scripts/init_generate.sh b/tools/gen_scripts/init_generate.sh
new file mode 100755
index 00000000..f7a12356
--- /dev/null
+++ b/tools/gen_scripts/init_generate.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# This file is part of gtkmm-3.
+# 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 gtkmm-3 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).
+# gtkmm-3 is built with autotools.
+# autotools support, but don't require, non-source-dir builds.
+extra_defs_gen_dir="$GMMPROC_GEN_BUILD_DIR/gtkmm-3/tools/extra_defs_gen"
+
+gtk_source_prefix="$GMMPROC_GEN_SOURCE_DIR/gtk+-3"
+gtk_build_prefix="$GMMPROC_GEN_BUILD_DIR/gtk+-3"
+pixbuf_source_prefix="$GMMPROC_GEN_SOURCE_DIR/gdk-pixbuf"
+pixbuf_build_prefix="$GMMPROC_GEN_BUILD_DIR/gdk-pixbuf"
+if [ "$GMMPROC_GEN_SOURCE_DIR" == "$GMMPROC_GEN_BUILD_DIR" ]; then
+ # gtk+-3 is built with autotools, which support, but don't require, non-source-dir builds.
+ # gdk-pixbuf is built with meson, which requires non-source-dir builds.
+ # This is what jhbuild does, if neccesary, to force non-source-dir builds.
+ pixbuf_build_prefix="$pixbuf_build_prefix/build"
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]