File: animate.in

package info (click to toggle)
gmt 5.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 150,460 kB
  • ctags: 18,539
  • sloc: ansic: 194,217; sh: 7,349; xml: 149; makefile: 72; fortran: 49; lisp: 41; csh: 5
file content (87 lines) | stat: -rwxr-xr-x 2,214 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# $Id: animate.in 13990 2015-01-26 18:00:58Z pwessel $
#
# Bash script for creating videos of the animation examples.
# The videos will optionally be included in the RST gallery.

test -z "$1" && exit 1

# Where the current script resides (need absolute path)
script_name="$1"
script_dir=$(dirname "${script_name}")
script="@GMT_SOURCE_DIR@/doc/examples/${script_name}"
if ! [ -x "${script}" ]; then
  echo "error: cannot execute script ${script}." >&2
  exit 1
fi

# choose awk
if type gawk >/dev/null 2>&1 ; then
  export AWK=gawk
elif type nawk >/dev/null 2>&1 ; then
  export AWK=nawk
else
  export AWK=awk
fi

# Temporary change LANG to C
LANG=C

# Define variables that are needed *within* test scripts
GMT_SOURCE_DIR="@GMT_SOURCE_DIR@"
GRAPHICSMAGICK="@GRAPHICSMAGICK@"
src="@GMT_SOURCE_DIR@/doc/examples/${script_dir}"

# Font lookup path for Ghostscript (invoked from gm compare and ps2raster)
export GS_FONTPATH="@CMAKE_CURRENT_SOURCE_DIR@/ex31/fonts"

# Use executables from GMT_BINARY_DIR, fallback to CMAKE_INSTALL_PREFIX/GMT_BINDIR
unset GMT5_SHAREDIR
export GMT_SHAREDIR="@GMT_SOURCE_DIR@/share"
export GMT_USERDIR="@GMT_BINARY_DIR@/share"
export PATH="@GMT_SOURCE_DIR@/src:$PATH" # for gmt_shell_functions.sh

# Reset error count
ERROR=0

# gmt wrapper
function gmt()
{
  "@GMT_BINARY_DIR@/src/gmt" "$@"
}

# export function definitions to subshells
export -f gmt

set -E # Shell functions and subshells need to inherit ERR trap

function on_err()
{
  trap - ERR SIGSEGV SIGTRAP SIGBUS # Restore trap
  ((++ERROR))
  echo "ERROR: ${1}:${2}" >&2 # Report error line
  exit $ERROR
}
trap 'on_err "${BASH_SOURCE}" "${LINENO}"' ERR SIGSEGV SIGTRAP SIGBUS

# Create a temporary directory exec_dir in the build dir
# Then copy all of its contents (except files excluded by GLOBIGNORE)
# Run remainder of this GMT script there
exec_dir="@CMAKE_CURRENT_BINARY_DIR@/${script_dir}"
rm -rf "$exec_dir"
mkdir -p "$exec_dir"
cd "$exec_dir"
GLOBIGNORE="*.bat:*.ps:*.sh"
for file in "$src"/* ; do
  test -f "$file" && ln -s "$file" .
done
unset GLOBIGNORE

# Start with proper GMT defaults
gmt set -Du FORMAT_TIME_STAMP "Version 5"

# Now run the original script
. "${script}" animate

# vim: ft=sh