summaryrefslogtreecommitdiff
path: root/tools/gen_scripts/glib_generate_enums.sh
blob: b366ffd5bc9a3bfab277c5fea260b09d5cc62a37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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 files will be placed in glib/src.

# To update the g[lib|module|object]_enums.defs files:
# 1. ./glib_generate_enums.sh
#    Generates glib/src/glib_enums.defs.orig and glib/src/g[lib|module|object]_enums.defs.
#    If any hunks from the patch file fail to apply, apply them manually to the
#    glib_enums.defs file, if required.
# 2. Optional: Remove glib/src/glib_enums.defs.orig.

# To update the g[lib|module|object]_enums.defs files and the patch file:
# 1. Like step 1 when updating only the g[lib|module|object]_enums.defs files.
# 2. Apply new patches manually to the glib_enums.defs file.
# 3. ./glib_generate_enums.sh --make-patch
# 4. Like step 2 when updating only the g[lib|module|object]_enums.defs files.

if [ -z "$JHBUILD_SOURCES" ]; then
  echo -e "JHBUILD_SOURCES must contain the path to the jhbuild sources."
  exit 1;
fi

PREFIX="$JHBUILD_SOURCES/glib"
ROOT_DIR="$(dirname "$0")/../.."
OUT_DIR="$ROOT_DIR/glib/src"

shopt -s extglob # Enable extended pattern matching
if [ $# -eq 0 ]
then
  ENUM_PL="$JHBUILD_SOURCES/glibmm/tools/enum.pl"
  # Process files whose names end with .h, but not with private.h.
  $ENUM_PL "$PREFIX"/glib/!(*private).h "$PREFIX"/glib/deprecated/!(*private).h > "$OUT_DIR"/glib_enums.defs
  $ENUM_PL "$PREFIX"/gmodule/!(*private).h > "$OUT_DIR"/gmodule_enums.defs
  $ENUM_PL "$PREFIX"/gobject/!(*private).h > "$OUT_DIR"/gobject_enums.defs
  # patch version 2.7.5 does not like directory names.
  cd "$OUT_DIR"
  PATCH_OPTIONS="--backup --version-control=simple --suffix=.orig"
  patch $PATCH_OPTIONS glib_enums.defs glib_enums.defs.patch
elif [ "$1" = "--make-patch" ]
then
  OUT_DIR_FILE="$OUT_DIR"/glib_enums.defs
  diff --unified=5 "$OUT_DIR_FILE".orig "$OUT_DIR_FILE" > "$OUT_DIR_FILE".patch
else
  echo "Usage: $0 [--make-patch]"
  exit 1
fi