aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-11-29 11:29:07 -0500
committerGitHub <noreply@github.com>2016-11-29 11:29:07 -0500
commit2c2902bb347dc832863569ece3bb01150d6b7665 (patch)
tree960f9f36498ca318dd99df7e1f82ed4f62590eb0
parent1535d6eecf402fe0747c271d0bbdd4a02ecc2df1 (diff)
parent7f60cb322370501546df36dc93a50161948d0a22 (diff)
downloadcbt-2c2902bb347dc832863569ece3bb01150d6b7665.tar.gz
cbt-2c2902bb347dc832863569ece3bb01150d6b7665.tar.bz2
cbt-2c2902bb347dc832863569ece3bb01150d6b7665.zip
Merge pull request #326 from cvogt/enhance-bash-script
Enhance bash script
-rwxr-xr-xcbt87
1 files changed, 44 insertions, 43 deletions
diff --git a/cbt b/cbt
index 1521b28..2fc9e07 100755
--- a/cbt
+++ b/cbt
@@ -163,65 +163,66 @@ fi
stage1 () {
log "Checking for changes in cbt/nailgun_launcher" "$@"
- NAILGUN_INDICATOR=$NAILGUN$TARGET/cbt/NailgunLauncher.class
+ NAILGUN_INDICATOR=$NAILGUN$TARGET../classes.last-success
changed=0
for file in `ls $NAILGUN/*.java`; do
if [ $file -nt $NAILGUN_INDICATOR ]; then changed=1; fi
done
compiles=0
if [ $changed -eq 1 ]; then
+ echo "Stopping background process (nailgun) if running" 1>&2
+ $NG ng-stop >> $nailgun_out 2>> $nailgun_err &
#rm $NAILGUN$TARGET/cbt/*.class 2>/dev/null # defensive delete of potentially broken class files
echo "Compiling cbt/nailgun_launcher" 1>&2
+ COMPILE_TIME=$(date -j +%YY%mm%dd%HH%MM.%SS|sed "s/[YmdHMS]//g")
javac -Xlint:deprecation -Xlint:unchecked -d $NAILGUN$TARGET `ls $NAILGUN*.java`
compiles=$?
- if [ $compiles -ne 0 ]; then
- rm $NAILGUN$TARGET/cbt/*.class 2>/dev/null # triggers recompilation next time.
- break
- fi
- if [ $use_nailgun -eq 0 ]; then
- echo "Stopping background process (nailgun)" 1>&2
- $NG ng-stop >> $nailgun_out 2>> $nailgun_err &
- sleep 1
- echo "Restarting background process (nailgun)" 1>&2
- ng-server 127.0.0.1:$NAILGUN_PORT >> $nailgun_out 2>> $nailgun_err &
- sleep 1
+ if [ $compiles -eq 0 ]; then
+ touch -t $COMPILE_TIME $NAILGUN_INDICATOR
+ if [ $use_nailgun -eq 0 ]; then
+ echo "Starting background process (nailgun)" 1>&2
+ ng-server 127.0.0.1:$NAILGUN_PORT >> $nailgun_out 2>> $nailgun_err &
+ sleep 1
+ fi
fi
fi
log "run CBT and loop if desired. This allows recompiling CBT itself as part of compile looping." "$@"
- if [ $use_nailgun -eq 1 ]
- then
- log "Running JVM directly" "$@"
- # -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:5005
- # JVM options to improve startup time. See https://github.com/cvogt/cbt/pull/262
- java $JAVA_OPTS -Xmx6072m -Xss10M -XX:MaxJavaStackTraceDepth=-1 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none -cp $NAILGUN$TARGET cbt.NailgunLauncher $(time_taken) "$CWD" "$@"
- else
- log "Running via background process (nailgun)" "$@"
- for i in 0 1 2 3 4 5 6 7 8 9; do
- log "Adding classpath." "$@"
- $NG ng-cp $NAILGUN$TARGET >> $nailgun_out 2>> $nailgun_err
- log "Checking if nailgun is up yet." "$@"
- $NG cbt.NailgunLauncher check-alive >> $nailgun_out 2>> $nailgun_err
- alive=$?
- if [ $alive -eq 131 ] || [ $alive -eq 33 ]; then
- # the 33 is not working right now
- # echo "Nailgun call failed. Try 'cbt kill' and check the error log cbt/nailgun_launcher/target/nailgun.stderr.log" 1>&2
- #elif [ $alive -eq 33 ]; then
- break
- else
- log "Nope. Sleeping for 0.5 seconds" "$@"
- #if [ "$i" -gt 1 ]; then
- # echo "Waiting for nailgun to start... (In case of problems try -Dlog=nailgun or check logs in cbt/nailgun_launcher/target/*.log)" 1>&2
- #fi
- fi
- sleep 0.3
- done
- log "Running CBT via Nailgun." "$@"
- $NG cbt.NailgunLauncher $(time_taken) "$CWD" "$@"
+ if [ $compiles -eq 0 ]; then
+ if [ $use_nailgun -eq 1 ]
+ then
+ log "Running JVM directly" "$@"
+ # -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:5005
+ # JVM options to improve startup time. See https://github.com/cvogt/cbt/pull/262
+ java $JAVA_OPTS -Xmx6072m -Xss10M -XX:MaxJavaStackTraceDepth=-1 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none -cp $NAILGUN$TARGET cbt.NailgunLauncher $(time_taken) "$CWD" "$@"
+ else
+ log "Running via background process (nailgun)" "$@"
+ for i in 0 1 2 3 4 5 6 7 8 9; do
+ log "Adding classpath." "$@"
+ $NG ng-cp $NAILGUN$TARGET >> $nailgun_out 2>> $nailgun_err
+ log "Checking if nailgun is up yet." "$@"
+ $NG cbt.NailgunLauncher check-alive >> $nailgun_out 2>> $nailgun_err
+ alive=$?
+ if [ $alive -eq 131 ] || [ $alive -eq 33 ]; then
+ # the 33 is not working right now
+ # echo "Nailgun call failed. Try 'cbt kill' and check the error log cbt/nailgun_launcher/target/nailgun.stderr.log" 1>&2
+ #elif [ $alive -eq 33 ]; then
+ break
+ else
+ log "Nope. Sleeping for 0.5 seconds" "$@"
+ #if [ "$i" -gt 1 ]; then
+ # echo "Waiting for nailgun to start... (In case of problems try -Dlog=nailgun or check logs in cbt/nailgun_launcher/target/*.log)" 1>&2
+ #fi
+ fi
+ sleep 0.3
+ done
+ log "Running CBT via Nailgun." "$@"
+ $NG cbt.NailgunLauncher $(time_taken) "$CWD" "$@"
+ fi
+ exitCode=$?
+ log "Done running CBT." "$@"
fi
- exitCode=$?
- log "Done running CBT." "$@"
}
while true; do