fix typo
[mcs.git] / class / System.Drawing / Samples / run-samples.sh
blob3f8af55f0cee4ca126f946a6c627c81a510483ae
1 #!/bin/sh
2 ################## System.Drawing: run-samples.sh #######################
3 # #
4 # This script compiles and runs samples from each directory in #
5 # System.Drawing.Samples directory. Compiled exes and output #
6 # images, if any, are saved to respective directories. #
7 # Compile time logs are saved to compile-log.txt and runtime logs are #
8 # saved to runtime-log.txt. Both log files are saved at the same #
9 # location where this script is run. #
10 # #
11 # Following are the two ways to run this script, #
12 # $ run-samples.sh #
13 # OR #
14 # $ run-samples.sh [option] #
15 # #
16 # NOTE: Possible options are (m)ake, (c)lean, (r)un, (a)ll #
17 # --run is default option, when no option is specified. #
18 # Only one option can be specified at a time. #
19 # -m, --make - compiles all the samples #
20 # -c, --clean - deletes all the exes generated #
21 # -r, --run - compiles and runs all the samples. [Default] #
22 # -a, --all - runs all the samples and also cleans #
23 # #
24 # **** This script would hang, if any sample hangs!!! #
25 # #
26 # Authors: #
27 # Sachin <skumar1@novell.com> #
28 # Ravindra <rkumar@novell.com> #
29 # #
30 # Copyright (C) 2004, Novell, Inc. http://www.novell.com #
31 # #
32 #########################################################################
34 # Prints the script usage
35 print_usage ()
37 echo "Usage: run-samples [option]"
38 echo "Only one option is processed at a time."
39 echo "Possible options are: (m)ake, (c)lean, (r)un, (a)ll"
40 echo " -m, --make: Just compiles all the samples."
41 echo " -c, --clean: Just removes all the exes."
42 echo " -r, --run: makes and runs all the samples. [Default]"
43 echo " -a, --all: same as run and clean combined."
44 echo " --run option is assumed, if no option is specified."
45 exit 1
48 # Compiles all the samples
49 compile ()
51 echo === Compiling samples in $dir ===
53 for src in *.cs
55 echo " $src"
56 echo -n " $src:: " >> $CLOG
57 $MCS $COMPILE_OPS $src >> $CLOG 2>&1
58 done
61 # Deletes all the exes
62 clean ()
64 echo === Cleaning $dir ===
65 rm *.exe
68 # Compiles and runs all the samples
69 run ()
71 compile
72 echo === Running samples in $dir ===
73 for exe in *.exe
75 echo " $exe"
76 echo >> $RLOG
77 echo "$dir: $exe :: " >> $RLOG
78 echo >> $RLOG
79 $MONO $RUN_OPS $exe >> $RLOG 2>&1
80 done
83 # Compliles, runs and deletes all the exes
84 all ()
86 run
87 clean
90 # Environment setup
92 ROOT=$PWD
93 CLOG=$ROOT/compile-log.txt
94 RLOG=$ROOT/runtime-log.txt
95 MCS=mcs
96 MONO=mono
97 LIB=System.Drawing
98 COMPILE_OPS="-g -r:$LIB"
99 RUN_OPS=--debug
101 # Uncomment the following line, if you are running this script on MS
102 #MSNet=yes
104 # We don't process more than one command line arguments
105 if [ $# -gt 1 ]; then
106 print_usage
109 # Default option is run, if no command line argument is present
110 if [ -z $1 ]; then
111 arg=--run
112 else
113 arg=$1
116 # Creates the log files
117 echo '*** LOG FILE for compile-time messages for System.Drawing Samples ***' > $CLOG
118 echo '*** LOG FILE for run-time output messages for System.Drawing Samples ***' > $RLOG
120 # All directories are processed under Samples.
121 for dir in `ls -d System.Drawing*`
123 echo >> $CLOG
124 echo ===== $dir ===== >> $CLOG
126 echo >> $RLOG
127 echo ===== $dir ===== >> $RLOG
129 # Change dir if it exists
130 if [ -d $ROOT/$dir ]; then
131 cd $ROOT/$dir
132 case $arg in
133 "-m") compile ;;
134 "--make") compile ;;
135 "-r") run ;;
136 "--run") run ;;
137 "-a") all ;;
138 "--all") all ;;
139 "-c") clean ;;
140 "--clean") clean ;;
141 *) print_usage ;;
142 esac
143 cd ..
144 else
145 echo "$dir not found." >> $CLOG
146 echo "$dir not found." >> $RLOG
148 done