Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 3 # To process a template, run this script with the path to a .tmpl file, e.g., | |
| 4 # | |
| 5 # $ $DART/utils/template/template srcfile [outfile] | |
| 6 # | |
| 7 # where: | |
| 8 # srcfile - the template file file.tmpl (if .tmpl missing .tmpl is assumed). | |
| 9 # outfile - the Dart class file to generate, if outfile not specified then | |
| 10 # outfile is srcfile.dart (srcfile name w/o ext). | |
| 11 # | |
| 12 | |
| 13 # Minimum/Maximum number of arguments | |
| 14 MINARGS=1 | |
| 15 MAXARGS=2 | |
| 16 | |
| 17 # get the number of command-line arguments given | |
| 18 ARGC=$# | |
| 19 | |
| 20 SRCFILE= | |
| 21 OUTFILE= | |
| 22 | |
| 23 # check to make sure enough arguments were given or exit | |
| 24 if [[ $ARGC -eq $MINARGS ]]; | |
| 25 then | |
| 26 SRCFILE=$1 | |
| 27 IDX=`expr index "$SRCFILE" .` | |
| 28 if [[ $IDX -eq 0 ]]; | |
| 29 then | |
| 30 # No extension | |
| 31 FILENAME=$SRCFILE | |
| 32 EXT= | |
| 33 else | |
| 34 FILENAME=${SRCFILE:0:(IDX-1)} | |
| 35 EXT=${SRCFILE:IDX} | |
| 36 fi | |
| 37 | |
| 38 TMPL_EXT='tmpl' | |
| 39 if [ "$EXT" = "$TMPL_EXT" ]; | |
| 40 then | |
| 41 SRCFILE="$PWD/$1" | |
| 42 OUTFILE="$PWD/$FILENAME.dart" | |
| 43 else | |
| 44 SRCFILE="$PWD/$1.$TMPL_EXT" | |
| 45 OUTFILE="$PWD/$FILENAME.dart" | |
| 46 fi | |
| 47 elif [[ $ARGC -eq 2 ]] | |
| 48 then | |
| 49 SRCFILE="$PWD/$1" | |
| 50 OUTFILE="$PWD/$2" | |
| 51 elif [[ $ARGC -lt $MINARGS ]]; | |
| 52 then | |
| 53 echo -e "\033[31mToo few arguments given (Minimum $MINARGS argument)\033[0m" | |
| 54 exit 1 | |
| 55 elif [[ $ARGC -gt $MAXARGS ]]; | |
| 56 then | |
| 57 echo -e "\033[31mToo many arguments\033[0m" | |
| 58 exit 1 | |
| 59 fi | |
| 60 | |
| 61 if [ "$SRCFILE" = "$OUTFILE" ]; | |
| 62 then | |
| 63 echo -e "\033[31msource file must be different from the output file \033[0m" | |
| 64 echo -e "source file: $SRCFILE" | |
| 65 echo -e "output file: $OUTFILE" | |
| 66 exit 1 | |
| 67 fi | |
| 68 | |
| 69 # Path of this bash script. | |
| 70 BASE_DIR="$( cd "$( dirname "$0" )" && pwd )" | |
| 71 DART_VM="$BASE_DIR/../../out/Debug_ia32/dart" | |
|
Siggi Cherem (dart-lang)
2012/03/15 01:21:25
I recommend using Release_ia32 instead, and pass i
terry
2012/03/15 19:02:49
I've removed DART_VM and use just dart ...
DartDo
| |
| 72 | |
| 73 # Pre-process the file | |
| 74 $DART_VM $BASE_DIR/tool.dart $SRCFILE $OUTFILE | |
| 75 | |
| OLD | NEW |