xref: /illumos-gate/usr/src/tools/smatch/src/smatch_scripts/build_kernel_data.sh (revision 6523a3aa7f325d64841382707603be7a86e68147)
1#!/bin/bash
2
3PROJECT=kernel
4
5function usage {
6    echo
7    echo "Usage:  $0"
8    echo "Updates the smatch_data/ directory and builds the smatch database"
9    echo
10    exit 1
11}
12
13if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
14	usage;
15fi
16
17SCRIPT_DIR=$(dirname $0)
18if [ -e $SCRIPT_DIR/../smatch -a -d kernel -a -d fs ] ; then
19    CMD=$SCRIPT_DIR/../smatch
20    DATA_DIR=$SCRIPT_DIR/../smatch_data
21else
22    echo "This script should be located in the smatch_scripts/ subdirectory of the smatch source."
23    echo "It should be run from the root of a kernel source tree."
24    exit 1
25fi
26
27# If someone is building the database for the first time then make sure all the
28# required packages are installed
29if [ ! -e smatch_db.sqlite ] ; then
30    [ -e smatch_warns.txt ] || touch smatch_warns.txt
31    if ! $DATA_DIR/db/create_db.sh -p=kernel smatch_warns.txt ; then
32        echo "Hm... Not working.  Make sure you have all the sqlite3 packages"
33        echo "And the sqlite3 libraries for Perl and Python"
34        exit 1
35    fi
36fi
37
38BUILD_STATUS=0
39$SCRIPT_DIR/test_kernel.sh --call-tree --info --spammy --data=$DATA_DIR || BUILD_STATUS=$?
40echo "smatch_warns.txt built."
41
42for i in $SCRIPT_DIR/gen_* ; do
43	$i smatch_warns.txt -p=kernel
44done
45
46mv ${PROJECT}.* $DATA_DIR
47
48$DATA_DIR/db/create_db.sh -p=kernel smatch_warns.txt
49
50exit $BUILD_STATUS
51