-
Notifications
You must be signed in to change notification settings - Fork 3
/
wstiny
executable file
·115 lines (93 loc) · 3.39 KB
/
wstiny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
export REGFLAG=wstiny
export WSVARIANT=wstiny
# TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \
# -n 'example.bash' -- "$@"`
# if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# # Note the quotes around `$TEMP': they are essential!
# eval set -- "$TEMP"
# while true ; do
# case "$1" in
# -a|--a-long) echo "Option a" ; shift ;;
# -b|--b-long) echo "Option b, argument \`$2'" ; shift 2 ;;
# -c|--c-long)
# # c has an optional argument. As we are in quoted mode,
# # an empty parameter will be generated if its optional
# # argument is not found.
# case "$2" in
# "") echo "Option c, no argument"; shift 2 ;;
# *) echo "Option c, argument \`$2'" ; shift 2 ;;
# esac ;;
# --) shift ; break ;;
# *) echo "Internal error!" ; exit 1 ;;
# esac
# done
## HACK HACK HACK: I hate having to do this.
function killjavahack () {
ps aux | grep "java PrintfClient" | grep -v grep | awk '{ print $2 }' | xargs kill &> /dev/null
}
rm -f query.c query.py WSQuery.nc WSQueryApp.nc Makefile.tos2
if [ -d build/telosb ];
then rm -f build/telosb/*;
fi
killjavahack;
if wsc $* -exit-error -no-gcc
then echo
else CODE=$?; echo ERROR, wstiny failed with code $CODE.; exit $CODE;
fi
echo "Copying WSMsp files to local directory."
cp -f $REGIMENTD/src/linked_lib/WSMspAdc*.nc .
# # No nesC separate compilation:
# # MATCH=`echo $FIRST | grep "^//WSLIBDEPS:"`
# # if [ "$MATCH" != "" ];
# # then
# # export EXTRALIBS=`echo $FIRST | sed "s/\/\/WSLIBDEPS://"`
# # export WS_LINK="$WS_LINK $EXTRALIBS"
# # echo Linking extra libraries requested by query file: $EXTRALIBS
# # fi
function tossim() {
chmod +x query.py;
echo
echo "BUILDING TINYOS COMPONENTS:"
echo "============================================================"
## HACK:
TELOSSPECIFIC=`grep Msp WSQueryApp.nc`
if [ "$TELOSSPECIFIC" == "" ];
then make -f Makefile.tos2 micaz sim;
else echo " Generated code is Telos-specific, not generating code for TOSSIM.";
fi
}
function pc() {
echo;echo "BUILDING PC-SIDE COMPONENTS:"
echo "============================================================"
if ! wsc2-gcc;
then exit 1;
fi
}
# Option (1) This builds both... for now this is only for telos:
if [ -f "WSQuery.nc" ] &&
[ -f "query.c" ];
then
echo;echo "BUILDING SPLIT APPLICATION (TELOS/PC)"
pc;
echo;echo "BUILDING TINYOS COMPONENTS:"
echo "============================================================"
killjavahack
# A default:
#if [ "$THEMOTE" == "" ]; then THEMOTE=/dev/ttyUSB0; fi
if [ "$THEMOTE" = "" ]; then
echo "Environment var THEMOTE is unset."
echo "You may use 'progtelos' to program the mote(s) yourself."
else
echo "Programming a single mote with nodeID = 1: $THEMOTE"; echo;
if ! make -f Makefile.tos2 telosb bsl,$THEMOTE install,1 2> .TOS_build_log.txt
then echo "Error $? while building telosb, see .TOS_build_log.txt"; exit 1; fi
fi
# Option (2) Build only tossim
elif [ -f "WSQuery.nc" ];
then tossim;
# Option (3) Build only the pc side -- hmm, why would that be?
elif [ -f "query.c" ];
then pc;
else echo No .c or .nc output files found...
fi