summaryrefslogtreecommitdiff
path: root/clang/bin/clang-rename-wrapper
blob: da7cbaca57e4a4f288637cd2d88adc3100d92828 (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
#!/bin/bash

mydir=$(dirname $0)
myname=clang-rename
if [ -h $0 ]; then
    mydir=$(dirname $(readlink -f $0))
fi

c=
o=
file=
for i in "$@"
do
    if [ "$i" = "-c" ]; then
        c=1
    elif [ "$i" = "-o" ]; then
        o=1
    elif [ -n "$o" ]; then
        o=
    elif [ -n "$c" ]; then
        file=$i
        break
    fi
done

ret=0
if [ -n "$file" ]; then
    if [ "$myname" == "clang-rename" ]; then
        mkdir -p /tmp/rename
        RENAME_ARGS="$RENAME_ARGS -export-fixes=$(mktemp -p /tmp/rename XXXXXXXXXX.yaml)"
    fi
    $myname $RENAME_ARGS $file -- "$@"
    ret=$?
fi

# gbuild detected or error: no need to call the real compiler
if [ $ret -gt 0 -o -n "$COMPILER_EXTERNAL_TOOL" ]; then
    exit $ret
fi

exec "$@"

# vi:set shiftwidth=4 expandtab: