diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-12 01:47:57 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-12 11:56:25 -0400 |
commit | 244f86a9cdf19904169456c234a2752f125dd427 (patch) | |
tree | 51e1f79100cc3651dfce66d4a284584d6bef3997 /cbt | |
parent | 4eb753e4d4ef5be7443b99832892bac697b10b50 (diff) | |
download | cbt-244f86a9cdf19904169456c234a2752f125dd427.tar.gz cbt-244f86a9cdf19904169456c234a2752f125dd427.tar.bz2 cbt-244f86a9cdf19904169456c234a2752f125dd427.zip |
revamp loop feature
now CBT and builds pass their file names to the current build
via the context. The build then simply blocks until any file changes.
Then it returns with a special exit code, which the bash script picks
up and restarts CBT. Thats works well for looping over project files.
It works less well for looping over builds and CBT itself. For this
a build has to success once, so that the .cbt-loop.tmp file exists.
Then looping works for cbt and builds, but the file list is not
updated in case of compile errors, etc.
Fixes
- https://github.com/cvogt/cbt/issues/406
- https://github.com/cvogt/cbt/issues/405
- https://github.com/cvogt/cbt/issues/202
- https://github.com/cvogt/cbt/issues/50
- https://github.com/cvogt/cbt/issues/22
We should improve for 1.0 in https://github.com/cvogt/cbt/issues/419
to handle looping over build files and cbt itself smarter.
Diffstat (limited to 'cbt')
-rwxr-xr-x | cbt | 40 |
1 files changed, 38 insertions, 2 deletions
@@ -199,6 +199,7 @@ stage1 () { log "Running JVM directly" "$@" # JVM options to improve startup time. See https://github.com/cvogt/cbt/pull/262 java $JAVA_OPTS $DEBUG -Xmx6072m -Xss10M -XX:MaxJavaStackTraceDepth=-1 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none -cp $NAILGUN$TARGET cbt.NailgunLauncher $(time_taken) "$CWD" "$@" + exitCode=$? else log "Running via background process (nailgun)" "$@" for i in 0 1 2 3 4 5 6 7 8 9; do @@ -222,17 +223,52 @@ stage1 () { done log "Running CBT via Nailgun." "$@" $NG cbt.NailgunLauncher $(time_taken) "$CWD" "$@" + exitCode=$? fi - exitCode=$? log "Done running CBT." "$@" fi } + +loop=1 +case "$1" in + "loop") loop=0 +esac +case "$2" in + "loop") loop=0 +esac + +CBT_SIGNALS_LOOPING=253 +USER_PRESSED_CTRL_C=130 + +CBT_LOOP_FILE="$CWD/target/.cbt-loop.tmp" while true; do stage1 "$@" - if [ ! "$1" = "loop" ]; then + if [ ! $loop -eq 0 ] || [ $exitCode -eq $USER_PRESSED_CTRL_C ]; then + log "not looping, exiting" "$@" break + else + if [ ! $exitCode -eq $CBT_SIGNALS_LOOPING ]; then + log "exitCode $exitCode" "$@" + which fswatch >/dev/null 2>/dev/null + export fswatch_installed=$? + if [ -f "$CBT_LOOP_FILE" ]; then + if [ $fswatch_installed -eq 0 ]; then + # fswatch allows looping over CBT's sources itself + log "fswatch found. looping." "$@" + files=($(cat "$CBT_LOOP_FILE")) + fswatch --one-event "${files[@]}" + else + log "fswatch not installed, stopping cbt" "$@" + break + fi + else + log "no $CBT_LOOP_FILE file, stopping cbt" "$@" + break + fi + fi fi + echo "======= Restarting CBT =======" 1>&2 done |