1
1
#! /bin/bash
2
- echo " Compiling the helper file to extract the raw list of parameters from cbmc"
3
- g++ -c -MMD -MP -std=c++11 -Wall -I ../../src/ -ftrack-macro-expansion=0 -fno-diagnostics-show-caret switch_extractor_helper.c -o tmp.o 2> pragma.txt
4
2
5
- retval= $?
3
+ set -e
6
4
7
- # clean up compiled files, we don't need them.
8
- rm tmp.o 2> /dev/null
9
- rm tmp.d 2> /dev/null
5
+ # make sure we execute the remainder in the directory containing this script
6
+ cd ` dirname $0 `
10
7
11
- # check if compilation went fine
12
- if [ $retval -ne 0 ]; then
13
- echo " Problem compiling the helper file, parameter list not extracted."
14
- exit 1;
15
- fi
8
+ echo " Compiling the helper file to extract the raw list of parameters from cbmc"
9
+ g++ -E -dM -std=c++11 -I../../src ../../src/cbmc/cbmc_parse_options.cpp -o macros.c
10
+ echo CBMC_OPTIONS >> macros.c
16
11
17
12
echo " Converting the raw parameter list to the format required by autocomplete scripts"
18
- rawstring=` sed " s/^.*pragma message: \(.*\)/\1/" pragma.txt`
19
- # delete pragma file, we won't need it
20
- rm pragma.txt 2> /dev/null
13
+ rawstring=" ` gcc -E -P -w macros.c` \" ?h(help)\" "
14
+ rm macros.c
21
15
22
16
# now the main bit, convert from raw format to a proper list of switches
23
17
cleanstring=` (
@@ -26,7 +20,7 @@ cleanstring=`(
26
20
(echo $rawstring | grep -o " ([^)]*)" | sed " s/^.\(.*\).$/--\1/" ) ;
27
21
# extract 1-hyphen switches, such as -F
28
22
# use sed to remove all (foo) expressions, then you're left with switches and ':', so grep the colons out and then use sed to include the '-'
29
- (echo $rawstring | sed " s/([^)]*)//g" | grep -o " [a-zA-Z0-9]" | sed " s/\(.*\)/-\1/" )
23
+ (echo $rawstring | sed " s/([^)]*)//g" | grep -o " [a-zA-Z0-9? ]" | sed " s/\(.*\)/-\1/" )
30
24
) | tr ' \n' ' ' `
31
25
32
26
# sanity check that there is only one line of output
@@ -36,13 +30,10 @@ if [ `echo $cleanstring | wc -l | awk '{print $1}'` -ne 1 ]; then
36
30
fi
37
31
38
32
# sanity check that there are no dangerous characters
39
- echo $cleanstring | grep -q " [^a-zA-Z0-9 -]"
40
- if [ $? -eq 0 ]; then
33
+ if echo $cleanstring | grep -q " [^a-zA-Z0-9? -]" ; then
41
34
echo " Problem converting the parameter list to the correct format, illegal characters detected. This is likely to be an error in this conversion script."
42
35
exit 1;
43
36
fi
44
37
45
38
echo " Injecting the parameter list to the autocomplete file."
46
39
sed " 5 s/.*/ local switches=\" $cleanstring \" /" cbmc.sh.template > cbmc.sh
47
-
48
- rm pragma.txt 2> /dev/null
0 commit comments