Skip to content
mikekab edited this page Jan 14, 2013 · 1 revision

Example Bash Script

The following short bash script is useful in testing for successful translation of files in your workspace.

  • Set the MAINDIR variable to your workspace Main directory.
  • Set the COMPILER variable to the version of your compiled Resolve compiler that has the dependencies bundled in.
  • Save the file in some directory above the workspace files you wish to translate.
  • Grant it executable permission with chmod +x .

Usage:

./translate.sh <regex> 
, where regex is a regular expression that matches files you wish to translate.
For example,
./translate.sh *.fa
will attempt to translate all the facility files in the current directory and in any directories below the current directory.
#! /bin/sh -
MAINDIR=~/resolve/workspace/RESOLVE/Main/
COMPILER=~/resolve/myfork/RESOLVE/target/RESOLVE-12.09.01a-jar-with-dependencies.jar

for fname in `find -name $1`
	do 
		basefilename_nosuffix=`basename ${fname%.*}`
		basefilename=`basename $fname`
		#echo java -jar $COMPILER -maindir $MAINDIR -translate $fname
		printf "\ncompiling %s\n" $basefilename
	 	java 2>&1 -jar $COMPILER -maindir $MAINDIR -translate $fname | grep Complete.*$basefilename_nosuffix
		# tests exit code of grep (if phrase not found the compiliation was not successful)
		if test $? -gt 0
		then
			printf "%s did not compile\n" $basefilename
		fi
done

Sample output:


$ ./translate.sh *.rb

compiling Std_Print_Realiz.rb
Std_Print_Realiz.rb did not compile

compiling Std_Location_Linking_Realiz.rb
Std_Location_Linking_Realiz.rb did not compile

compiling Example_Realiz.rb
Complete record: Integer_Template.Example_Realiz

This version suppresses errors. It is intended to report only success or failure.

Clone this wiki locally