1 #!/bin/bash -e 2 3 # RS Invocation script to FileCheck, used to check generated Java 4 # files or C++ files. This assumes that the .rs source file has the 5 # Java package name "foo". 6 7 print_help() { 8 help_str="Usage: %s --output=<output-dir> \ 9 --filecheck=<path-to-filecheck> \ 10 --lang=[Java/C++] \ 11 <.rs file>\n" 12 13 printf "$help_str" $0 14 } 15 16 for arg in "$@" 17 do 18 case $arg in 19 --output=*) 20 outdir="${arg#*=}" 21 ;; 22 --filecheck*) 23 filecheck="${arg#*=}" 24 ;; 25 --lang*) 26 lang="${arg#*=}" 27 ;; 28 --help) 29 print_help 30 exit 0 31 ;; 32 *) 33 rsfile="$arg" 34 ;; 35 esac 36 done 37 38 if [[ (-z $outdir) || (-z $filecheck) || (-z $rsfile) ]] 39 then 40 print_help 41 exit 1 42 fi 43 44 if [[ ! -f $rsfile ]] 45 then 46 echo "Input file $rsfile doesn't exist" 47 exit 1 48 fi 49 50 rsfile_basename=$(basename "$rsfile") 51 52 if [[ $lang == "Java" ]] 53 then 54 filecheck_inputfile=foo/ScriptC_${rsfile_basename%.*}.java 55 elif [[ $lang == "C++" ]] 56 then 57 filecheck_inputfile=ScriptC_${rsfile_basename%.*}.h 58 else 59 echo Unknown language "$lang" 60 print_help 61 exit 1 62 fi 63 64 if [[ ! -f $filecheck ]] 65 then 66 echo "No file at supplied FileCheck path $filecheck" 67 exit 1 68 fi 69 70 if [[ ! -f $outdir/$filecheck_inputfile ]] 71 then 72 echo "Input file $outdir/$filecheck_inputfile doesn't exist" 73 exit 1 74 fi 75 76 "$filecheck" -input-file "$outdir"/$filecheck_inputfile "$rsfile" 77