test: preempt.c and coop.c should be never explicitly included.
[bertos.git] / test / get_source_list.sh
1 #!/bin/bash
2 # This file is part of BeRTOS.
3 #
4 # Bertos is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18 # As a special exception, you may use this file as part of a free software
19 # library without restriction.  Specifically, if other files instantiate
20 # templates or use macros or inline functions from this file, or you compile
21 # this file and link it with other files to produce an executable, this
22 # file does not by itself cause the resulting executable to be covered by
23 # the GNU General Public License.  This exception does not however
24 # invalidate any other reasons why the executable file might be covered by
25 # the GNU General Public License.
26 #
27 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
28 #
29 # Nighlty test for BeRTOS.
30 #
31 # Author Daniele Basile <asterix@develer.com>
32
33 #Directories
34 BERTOS_DIR="./bertos"
35 COPY_DIR="./bertos.saved"
36 CPU_DIR="${BERTOS_DIR}/cpu"
37
38 #Directory to exclude
39 OS_DIR="${BERTOS_DIR}/os"
40 EMUL_DIR="${BERTOS_DIR}/emul"
41 WIZARD_DIR="./wizard"
42 APP_DIR="./examples"
43 FAT_DIR="${BERTOS_DIR}/fs/fatfs"
44 NMEA_DIR="${BERTOS_DIR}/net/nmeap"
45
46 if [ $# \< 2 ] ; then
47         printf "You must specify a cpu target, and source file type!\n"
48         printf "EXAMPLE:\n $0 <cpu target> <source type>\n\n"
49
50         exit 1
51 fi
52 CPU_TARGET=$1
53 EXCLUDE_DIRS="$COPY_DIR $CPU_DIR $APP_DIR $OS_DIR $WIZARD_DIR $EMUL_DIR $FAT_DIR $NMEA_DIR"
54 EXCLUDE_CMD="\.svn -or -name preempt.c -or -name coop.c -prune "
55 for i in $EXCLUDE_DIRS; do 
56         EXCLUDE_CMD="$EXCLUDE_CMD -o -path $i -prune ";
57 done
58
59 #Create a list of source file without a cpu specific source
60 GEN_SRC=`find . \( -name $EXCLUDE_CMD \) -o -name *.${2} -print | xargs`
61
62 #Select c and asm sources for selected cpu target
63 TRG_SRC=`find ${CPU_DIR}/$CPU_TARGET -name \.svn -prune -o -name *.${2} -print | xargs`
64
65 #Generate a list of all source for each cpu
66 SRC_ALL=${GEN_SRC}" "${TRG_SRC}
67
68 # Find the files that contain the string
69 # NOTEST <cpu target> and put it in a list
70
71 NOTEST="notest:"
72 for src in $SRC_ALL ;
73 do
74         grep -P "$NOTEST\s*$CPU_TARGET" $src 2>&1 > /dev/null
75         if [ $? -eq 0 ] ; then
76                 EXCLUDE_LIST="$EXCLUDE_LIST $src"
77         fi      
78 done
79
80 # Remove the exclude list files from the sources to be
81 # compiled
82 for src in $EXCLUDE_LIST ;
83 do
84         SRC_ALL=`echo $SRC_ALL | sed -e "s;$src;;g"`
85 done
86
87 printf "${SRC_ALL}"
88