run-samples.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 <[email protected]> #
  28. # Ravindra <[email protected]> #
  29. # #
  30. # Copyright (C) 2004, Novell, Inc. http://www.novell.com #
  31. # #
  32. #########################################################################
  33. # Prints the script usage
  34. print_usage ()
  35. {
  36. echo "Usage: run-samples [option]"
  37. echo "Only one option is processed at a time."
  38. echo "Possible options are: (m)ake, (c)lean, (r)un, (a)ll"
  39. echo " -m, --make: Just compiles all the samples."
  40. echo " -c, --clean: Just removes all the exes."
  41. echo " -r, --run: makes and runs all the samples. [Default]"
  42. echo " -a, --all: same as run and clean combined."
  43. echo " --run option is assumed, if no option is specified."
  44. exit 1
  45. }
  46. # Compiles all the samples
  47. compile ()
  48. {
  49. echo === Compiling samples in $dir ===
  50. for src in *.cs
  51. do
  52. echo " $src"
  53. echo -n " $src:: " >> $CLOG
  54. $MCS $COMPILE_OPS $src >> $CLOG 2>&1
  55. done
  56. }
  57. # Deletes all the exes
  58. clean ()
  59. {
  60. echo === Cleaning $dir ===
  61. rm *.exe
  62. }
  63. # Compiles and runs all the samples
  64. run ()
  65. {
  66. compile
  67. echo === Running samples in $dir ===
  68. for exe in *.exe
  69. do
  70. echo " $exe"
  71. echo >> $RLOG
  72. echo "$dir: $exe :: " >> $RLOG
  73. echo >> $RLOG
  74. $MONO $RUN_OPS $exe >> $RLOG 2>&1
  75. done
  76. }
  77. # Compliles, runs and deletes all the exes
  78. all ()
  79. {
  80. run
  81. clean
  82. }
  83. # Environment setup
  84. ROOT=$PWD
  85. CLOG=$ROOT/compile-log.txt
  86. RLOG=$ROOT/runtime-log.txt
  87. MCS=mcs
  88. MONO=mono
  89. LIB=System.Drawing
  90. COMPILE_OPS="-g -r:$LIB"
  91. RUN_OPS=--debug
  92. # Uncomment the following line, if you are running this script on MS
  93. #MSNet=yes
  94. # We don't process more than one command line arguments
  95. if [ $# -gt 1 ]; then
  96. print_usage
  97. fi
  98. # Default option is run, if no command line argument is present
  99. if [ -z $1 ]; then
  100. arg=--run
  101. else
  102. arg=$1
  103. fi
  104. # Creates the log files
  105. echo '*** LOG FILE for compile-time messages for System.Drawing Samples ***' > $CLOG
  106. echo '*** LOG FILE for run-time output messages for System.Drawing Samples ***' > $RLOG
  107. # All directories are processed under Samples.
  108. for dir in `ls -d System.Drawing*`
  109. do
  110. echo >> $CLOG
  111. echo ===== $dir ===== >> $CLOG
  112. echo >> $RLOG
  113. echo ===== $dir ===== >> $RLOG
  114. # Change dir if it exists
  115. if [ -d $ROOT/$dir ]; then
  116. cd $ROOT/$dir
  117. case $arg in
  118. "-m") compile ;;
  119. "--make") compile ;;
  120. "-r") run ;;
  121. "--run") run ;;
  122. "-a") all ;;
  123. "--all") all ;;
  124. "-c") clean ;;
  125. "--clean") clean ;;
  126. *) print_usage ;;
  127. esac
  128. cd ..
  129. else
  130. echo "$dir not found." >> $CLOG
  131. echo "$dir not found." >> $RLOG
  132. fi
  133. done