File: updateextern.sh

package info (click to toggle)
scip 10.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,156 kB
  • sloc: ansic: 716,600; cpp: 41,095; awk: 9,195; sh: 4,918; makefile: 4,044; python: 2,076; perl: 731; xml: 660; java: 314; php: 24; lisp: 15
file content (78 lines) | stat: -rwxr-xr-x 1,954 bytes parent folder | download
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
#!/usr/bin/env bash
#
# This bash script updates all "extern" of public methods with "EXTERN".
# The latter is a macro define in def.h and is needed to easily create
# libraries for Windows. In case of any other system this macro "EXTERN" is
# replaces by "extern".
#
# This scripts should be run before every release. You just have to run
# this script as it is from the main directory of SCIP.
#
# > scripts/updateextern.sh
#
# There is nothing to adjust. Afterward please check the changes via "git
# diff" to make sure that the replacement worked

DIRECTORY="src/scip"
EXTRAFILES=(scip)
PLUGINTYPES=(branch cons dialog disp event heur message nodesel prop presol pricer reader relax sepa)

echo ""
echo "This script changes all "extern" to "EXTERN" in the header of public callable methods"
echo ""

FILES="src/scip/scip*.h src/scip/pub_*.h src/nlpi/exprinterpret.h src/blockmemshell/memory.h"

# collect all header files related to plugins
for PLUGINTYPE in ${PLUGINTYPES[@]}
do
    for FILE in $DIRECTORY/$PLUGINTYPE"_"*.h
    do
	# ignore xyz plugin templates
	if test "$FILE" = "$DIRECTORY/$PLUGINTYPE"_"xyz.h"
	then
	    continue
	fi

	if test -f $FILE
	then
	    FILES="$FILES $FILE"
	fi
    done
done

# collect all public header files
for FILE in $DIRECTORY/pub_*.h
do
    if test -t $FILE
    then
	FILES="$FILES $FILE"
    fi
done

# collect the header of the extra files
for EXTRAFILE in ${EXTRAFILES[@]}
do
    if test -f $DIRECTORY/$EXTRAFILE
    then
	FILES="$FILES $DIRECTORY/$EXTRAFILE"
    fi
done

# replace in all collected header files the lines which start and end with
# "extern" by "EXTERN"; note that we also consider trailing white spaces
for FILE in ${FILES[@]}
do
    if test -f $FILE
    then
	COUNT=`grep -c "^extern\([ ]*\)$" $FILE`

	if test $COUNT -gt 0
	then
	    echo "--> replaced $COUNT extern in $FILE"

	    mv $FILE $FILE.oldextern
	    sed 's/^extern\([ ]*\)$/EXTERN/g' $FILE.oldextern > $FILE
	fi
    fi
done