Automatic date update in version.in
[platform/upstream/binutils.git] / gdb / contrib / gcc-with-excheck
1 #!/bin/sh
2 #   Copyright 2011-2014 Free Software Foundation, Inc.
3 #
4 #   This is free software: you can redistribute it and/or modify it
5 #   under the terms of the GNU General Public License as published by
6 #   the Free Software Foundation, either version 3 of the License, or
7 #   (at your option) any later version.
8 #
9 #   This program is distributed in the hope that it will be useful, but
10 #   WITHOUT ANY WARRANTY; without even the implied warranty of
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #   General Public License for more details.
13 #
14 #   You should have received a copy of the GNU General Public License
15 #   along with this program.  If not, see
16 #   <http://www.gnu.org/licenses/>.
17
18 # You must set PYTHON_PLUGIN in the environment.
19 # It should be the directory holding the "python.so" file.
20 # Usage: gcc-with-excheck [-Xx|-Xc] [--] ARGS
21 # -Xx means to invoke the exception checker.
22 # -Xc means to invoke the cleanup checker.
23 # -- means stop processing -X options.
24 # ARGS are passed to gcc.
25
26 GCC=${GCC:-gcc}
27 exdir=`dirname $0`
28
29 pargs=
30 while true; do
31     case "$1" in
32         -Xc)
33             pargs="$pargs -fplugin-arg-python-script=$exdir/cleanup_check.py"
34             ;;
35         -Xx)
36             pargs="$pargs -fplugin-arg-python-script=$exdir/excheck.py"
37             ;;
38         -X*)
39             echo "unrecognized argument $1" 1>&2
40             exit 1
41             ;;
42         --)
43             shift
44             break
45             ;;
46         *)
47             break
48             ;;
49     esac
50     shift
51 done
52
53 # Recent versions of the Python plugin build two .so files in
54 # different directories, so we have to set this.  This will be fixed
55 # upstream at some point.
56 export LD_LIBRARY_PATH=$PYTHON_PLUGIN:$PYTHON_PLUGIN/gcc-c-api
57
58 gcc -fplugin=$PYTHON_PLUGIN/python.so $pargs "$@"