• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7print_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
16for arg in "$@"
17do
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
36done
37
38if [[ (-z $outdir) || (-z $filecheck) || (-z $rsfile) ]]
39then
40  print_help
41  exit 1
42fi
43
44if [[ ! -f $rsfile ]]
45then
46  echo "Input file $rsfile doesn't exist"
47  exit 1
48fi
49
50rsfile_basename=$(basename "$rsfile")
51
52if [[ $lang == "Java" ]]
53then
54  filecheck_inputfile=foo/ScriptC_${rsfile_basename%.*}.java
55elif [[ $lang == "C++" ]]
56then
57  filecheck_inputfile=ScriptC_${rsfile_basename%.*}.h
58else
59  echo Unknown language "$lang"
60  print_help
61  exit 1
62fi
63
64if [[ ! -f $filecheck ]]
65then
66  echo "No file at supplied FileCheck path $filecheck"
67  exit 1
68fi
69
70if [[ ! -f $outdir/$filecheck_inputfile ]]
71then
72  echo "Input file $outdir/$filecheck_inputfile doesn't exist"
73  exit 1
74fi
75
76"$filecheck" -input-file "$outdir"/$filecheck_inputfile "$rsfile"
77