This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / class / System.Drawing / Samples / run-samples.sh
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 #########################################################################
33
34 # Prints the script usage
35 print_usage ()
36 {
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
46 }
47
48 # Compiles all the samples
49 compile ()
50 {
51         for src in *.cs
52         do
53                 echo $src
54                 echo -n "$src:: " >> $CLOG
55                 $MCS $COMPILE_OPS $src >> $CLOG 2>&1
56         done
57 }
58
59 # Deletes are the exes
60 clean ()
61 {
62     rm *.exe
63 }
64
65 # Compiles and runs all the samples
66 run ()
67 {
68         compile
69         for exe in *.exe
70         do
71                 echo $exe
72                 echo >> $RLOG
73                 echo "$dir: $exe :: " >> $RLOG
74                 echo >> $RLOG
75                 $MONO $RUN_OPS $exe >> $RLOG 2>&1
76         done
77 }
78
79 # Compliles, runs and deletes all the exes
80 all ()
81 {
82     run
83     clean
84 }
85
86 # Environment setup
87
88 ROOT=$PWD
89 CLOG=$ROOT/compile-log.txt
90 RLOG=$ROOT/runtime-log.txt
91 MCS=mcs
92 MONO=mono
93 LIB=System.Drawing
94 COMPILE_OPS="-g -r:$LIB"
95 RUN_OPS=--debug
96
97 # Uncomment the following line, if you are running this script of MS
98 #MSNet=yes
99
100 # We don't process more than one command line arguments
101 if [ $# -gt 1 ]; then
102     print_usage
103 fi
104
105 # Default option is run, if no command line argument is present
106 if [ -z $1 ]; then
107     arg=--run
108 else
109     arg=$1
110 fi
111
112 # Creates the log files
113 echo '*** LOG FILE for compile-time messages for System.Drawing Samples ***' > $CLOG
114 echo '*** LOG FILE for run-time output messages for System.Drawing Samples ***' > $RLOG
115
116 # All directories are processed under Samples.
117 for dir in System.Drawing System.Drawing.Drawing2D General System.Drawing.Imaging System.Drawing.Printing System.Drawing.Text
118 do
119         echo ===== $dir ====
120
121         echo >> $CLOG
122         echo ===== $dir ==== >> $CLOG
123
124         echo >> $RLOG
125         echo ===== $dir ==== >> $RLOG
126
127         # Change dir if it exists
128         if [ -d $ROOT/$dir ]; then
129             cd $ROOT/$dir
130             case $arg in
131                 "-m") compile ;;
132                 "--make") compile ;;
133                 "-r") run ;;
134                 "--run") run ;;
135                 "-a") all ;;
136                 "--all") all ;;
137                 "-c") clean ;;
138                 "--clean") clean ;;
139                 *) print_usage ;;
140             esac
141             cd ..
142         else
143                 echo "$dir not found." >> $CLOG
144                 echo "$dir not found." >> $RLOG
145         fi
146 done