project: create a way to generate smatch_data for a new project
[smatch.git] / smatch_scripts / build_generic_info.sh
blobedea7f1d8433c6de7d599d7576632e7090e4e94c
1 #!/bin/bash
3 # This is a generic script to parse --info output. For the kernel, don't use
4 # this script, use build_kernel_data.sh instead.
6 SCRIPT_DIR=$(dirname $0)
7 DATA_DIR=smatch_data
8 PROJECT=smatch_generic
10 function usage {
11 echo
12 echo "Usage: $0"
13 echo "Updates the smatch_data/ directory and builds the smatch database"
14 echo
15 exit 1
18 if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
19 usage;
22 if [ -e $SCRIPT_DIR/../smatch ] ; then
23 BIN_DIR=$SCRIPT_DIR/../
24 else
25 echo "This script should be located in the smatch_scripts/ subdirectory of the smatch source."
26 exit 1
29 # If someone is building the database for the first time then make sure all the
30 # required packages are installed
31 if [ ! -e smatch_db.sqlite ] ; then
32 [ -e smatch_warns.txt ] || touch smatch_warns.txt
33 if ! $SCRIPT_DIR/../smatch_data/db/create_db.sh -p=kernel smatch_warns.txt ; then
34 echo "Hm... Not working. Make sure you have all the sqlite3 packages"
35 echo "And the sqlite3 libraries for Perl and Python"
36 exit 1
40 make CHECK="$BIN_DIR/smatch --call-tree --info --param-mapper --spammy --file-output"
42 find -name \*.c.smatch -exec cat \{\} \; -exec rm \{\} \; > smatch_warns.txt
44 for i in $SCRIPT_DIR/gen_* ; do
45 $i smatch_warns.txt -p=${PROJECT}
46 done
48 mkdir -p $DATA_DIR
49 mv $PROJECT.* $DATA_DIR
51 $SCRIPT_DIR/../smatch_data/db/create_db.sh smatch_warns.txt