Skip to content

Commit 63f9182

Browse files
author
Daniel Kroening
authored
Merge pull request #461 from tautschnig/build-system
Support vpath builds and use them for coverage measurement
2 parents 73635f0 + 5c29567 commit 63f9182

File tree

4 files changed

+89
-9
lines changed

4 files changed

+89
-9
lines changed

regression/get_coverage.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if [ $? -ne 0 ]; then
99
printf "ERROR: Could not create output directoy"
1010
exit 1
1111
fi
12+
output_dir_abs=`cd $output_dir > /dev/null ; pwd`
1213

1314
# Check that the previous command succeded, if not exit.
1415
command_status()
@@ -49,18 +50,21 @@ lcov -version > $output_dir/cbmc_coverage.out 2>&1
4950
command_status
5051

5152
# Remove any previous build that may not have coverage in it.
52-
printf "INFO: Cleaning CBMC build "
53-
make clean -C ../src >> $output_dir/cbmc_coverage.out 2>&1
53+
printf "INFO: setting up vpath build "
54+
cd ../src
55+
../scripts/vpath-setup.sh coverage-build >> $output_dir_abs/cbmc_coverage.out 2>&1
5456
command_status
57+
cd ../regression
5558

5659
printf "INFO: Building CBMC with Code Coverage enabled "
5760
# Run the usual make target with --coverage to add gcov instrumentation
58-
make CXXFLAGS="--coverage" LINKFLAGS="--coverage" -C ../src >> $output_dir/cbmc_coverage.out 2>&1
61+
make CXXFLAGS="--coverage" LINKFLAGS="--coverage" -C ../src/coverage-build/src \
62+
>> $output_dir/cbmc_coverage.out 2>&1
5963
command_status
6064

6165
printf "INFO: Running Regression tests "
6266
# Run regression tests which will collect the coverage metrics and put them in the src files
63-
make >> $output_dir/cbmc_coverage.out 2>&1
67+
make -C ../src/coverage-build/regression >> $output_dir/cbmc_coverage.out 2>&1
6468
printf "[DONE]\n"
6569

6670
printf "INFO: Gathering coverage metrics "

scripts/vpath-setup.sh

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ $# -ne 1 ]
6+
then
7+
echo "Target directory required" 1>&2
8+
exit 1
9+
fi
10+
11+
if ! make -s generated_files
12+
then
13+
echo "Failed to run 'make generated_files'" 1>&2
14+
exit 1
15+
fi
16+
17+
DEST=$1
18+
19+
gen_makefile()
20+
{
21+
local d=$1
22+
local m=$2
23+
24+
mkdir -p $DEST/src/$d
25+
cat > $DEST/src/$d/$m <<EOF
26+
VPATH =
27+
vpath %.cpp $PWD/$d
28+
vpath %.cc $PWD/$d
29+
vpath %.h $PWD/$d
30+
vpath %.y $PWD/$d
31+
vpath %.l $PWD/$d
32+
vpath %.txt $PWD/$d
33+
EOF
34+
cat $d/$m >> $DEST/src/$d/$m
35+
}
36+
37+
makefiles=$(find . -name Makefile | grep -v $DEST)
38+
39+
for m in $makefiles
40+
do
41+
dir=$(dirname $m)
42+
gen_makefile $dir Makefile
43+
done
44+
45+
gen_makefile big-int makefile
46+
47+
cp common config.inc $DEST/src/
48+
49+
# tweak include paths in config.inc
50+
perl -p -i -e 's/(= \.\.\/\.\.\/)/$1..\/..\//' $DEST/src/config.inc
51+
echo "INCLUDES += -I$PWD" >> $DEST/src/config.inc
52+
53+
# tweak targets that aren't compatible with vpaths
54+
perl -p -i -e "s{(library/\\*.c)}{$PWD/ansi-c/\$1}" $DEST/src/ansi-c/Makefile
55+
perl -p -i -e 's/^(cprover_library.inc:)/%$1/' $DEST/src/ansi-c/Makefile
56+
perl -p -i -e 's/^(cprover_library.cpp:)/#$1/' $DEST/src/ansi-c/Makefile
57+
58+
perl -p -i -e 's/^(irep_ids.cpp:)/#$1/' $DEST/src/util/Makefile
59+
60+
# create sub-directories
61+
mkdir -p $DEST/src/ansi-c/library $DEST/src/ansi-c/literals
62+
mkdir -p $DEST/src/goto-instrument/{accelerate,wmm}
63+
mkdir -p $DEST/src/solvers/{cvc,flattening,floatbv,miniBDD,prop,qbf,refinement,sat,smt1,smt2}
64+
65+
# copy generated files for coverage reports
66+
for f in \
67+
ansi-c/ansi_c_lex.yy.cpp ansi-c/scanner.l ansi-c/ansi_c_y.tab.cpp \
68+
assembler/scanner.l assembler/assembler_lex.yy.cpp \
69+
jsil/jsil_lex.yy.cpp jsil/scanner.l jsil/jsil_y.tab.cpp \
70+
json/parser.y json/json_lex.yy.cpp json/json_y.tab.cpp \
71+
xmllang/scanner.l xmllang/xml_lex.yy.cpp xmllang/xml_y.tab.cpp xmllang/parser.y
72+
do
73+
cp $f $DEST/src/$(dirname $f)/
74+
done
75+
76+
cp -aL ../regression $DEST/

src/solvers/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ SRC = $(CHAFF_SRC) $(BOOLEFORCE_SRC) $(MINISAT_SRC) $(MINISAT2_SRC) \
120120
refinement/refine_arrays.cpp \
121121
miniBDD/miniBDD.cpp
122122

123-
INCLUDES= -I .. \
123+
INCLUDES += -I .. \
124124
$(CHAFF_INCLUDE) $(BOOLEFORCE_INCLUDE) $(MINISAT_INCLUDE) $(MINISAT2_INCLUDE) \
125125
$(SMVSAT_INCLUDE) $(SQUOLEM2_INC) $(CUDD_INCLUDE) $(GLUCOSE_INCLUDE) \
126126
$(PRECOSAT_INCLUDE) $(PICOSAT_INCLUDE) $(LINGELING_INCLUDE)

src/util/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ all: util$(LIBEXT)
3737

3838
###############################################################################
3939

40-
irep_ids.h: irep_ids_convert$(EXEEXT) irep_ids.txt
41-
./irep_ids_convert$(EXEEXT) header < irep_ids.txt > $@
40+
irep_ids.h: irep_ids.txt irep_ids_convert$(EXEEXT)
41+
./irep_ids_convert$(EXEEXT) header < $< > $@
4242

43-
irep_ids.inc: irep_ids_convert$(EXEEXT) irep_ids.txt
44-
./irep_ids_convert$(EXEEXT) table < irep_ids.txt > $@
43+
irep_ids.inc: irep_ids.txt irep_ids_convert$(EXEEXT)
44+
./irep_ids_convert$(EXEEXT) table < $< > $@
4545

4646
irep_ids.cpp: irep_ids.inc irep_ids.h
4747

0 commit comments

Comments
 (0)