1 |
william |
31 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
# Script default parameter |
4 |
|
|
MAX_DEPTH=1 |
5 |
|
|
DIR=$PWD |
6 |
|
|
CMAKE_FILE=CMakeLists.txt |
7 |
|
|
SKIP_H=FALSE |
8 |
|
|
|
9 |
|
|
## Help message |
10 |
|
|
help() |
11 |
|
|
{ |
12 |
|
|
cat <<EOF |
13 |
|
|
This script detects '.cpp/.h' files that are in directory (and sub) but not in the current cmake. |
14 |
|
|
options: |
15 |
|
|
-dir <dirname> : give the directory to check. Default '.' |
16 |
|
|
-help : print this help message and exit |
17 |
|
|
-max_depth <depth> : how many depth to check missing file. Default 1 |
18 |
|
|
-skip : skip the check of '.h' file. Disable by default |
19 |
|
|
EOF |
20 |
|
|
|
21 |
|
|
exit 0 |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
## Handle option |
25 |
|
|
while [ -n "$1" ]; do |
26 |
|
|
case $1 in |
27 |
|
|
-help|-h) help;shift 1;; # appel de la fonction help |
28 |
|
|
-skip|-s) SKIP_H=TRUE;shift 1;; |
29 |
|
|
-dir|-d) DIR=$2;shift 2;; |
30 |
|
|
-max_depth|-m) MAX_DEPTH=$2;shift 2;; |
31 |
|
|
--) shift;break;; |
32 |
|
|
-*) echo "ERROR: $1 option does not exists. Use -h for help";exit 1;; |
33 |
|
|
*) break;; |
34 |
|
|
esac |
35 |
|
|
done |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
## Main sript |
39 |
|
|
for file in `find $DIR -maxdepth $MAX_DEPTH -name "*.cpp"` ; do |
40 |
|
|
PATTERN=`basename $file` |
41 |
|
|
grep $PATTERN $DIR/$CMAKE_FILE > /dev/null || echo $file is missing in $CMAKE_FILE |
42 |
|
|
done |
43 |
|
|
|
44 |
|
|
if [ "${SKIP_H}" = "FALSE" ] ; then |
45 |
|
|
for file in `find $DIR -maxdepth $MAX_DEPTH -name "*.h"` ; do |
46 |
|
|
PATTERN=`basename $file` |
47 |
|
|
grep $PATTERN $DIR/$CMAKE_FILE > /dev/null || echo $file is missing in $CMAKE_FILE |
48 |
|
|
done |
49 |
|
|
fi |
50 |
|
|
exit |