From 19fa46346c440c00b9f4a6509784928232c136e2 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Wed, 9 Mar 2016 00:20:57 -0500 Subject: fix some quite noisy behavior regarding exit codes in the bash runner. The interaction with nailgun probably needs more low level debugging to get flawless --- cbt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cbt b/cbt index 603ec23..09f8d96 100755 --- a/cbt +++ b/cbt @@ -212,17 +212,18 @@ stage1 () { log "Checking if nailgun is up yet." $* $NG cbt.NailgunLauncher cbt.CheckAlive $CP "$CWD" $* >> $nailgun_out 2>> $nailgun_err alive=$? - if [ $alive -eq 131 ]; then - 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 + 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... (For problems try -Dlog=nailgun or check logs in cbt/nailgun_launcher/target/*.log)" 1>&2 fi - sleep 0.5 fi + sleep 0.5 done log "Running $mainClass via Nailgun." $* $NG cbt.NailgunLauncher $mainClass $CP "$CWD" $* -- cgit v1.2.3 From a5a8515c22a7b434a0da34de48caafbef7e5ee8e Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Wed, 9 Mar 2016 00:22:10 -0500 Subject: fix compile looking to only trigger on the provided files, not other files in the same directories --- stage2/Lib.scala | 18 +++++++++++++----- stage2/Stage2.scala | 6 ++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 6bb9c0b..6f83859 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -148,7 +148,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ .filterNot(t => anyRefMembers contains taskName(t)) } - class ReflectBuild(build: Build) extends ReflectObject(build){ + class ReflectBuild(val build: Build) extends ReflectObject(build){ def usage = { val baseTasks = lib.taskNames(ru.typeOf[Build]) val thisTasks = lib.taskNames(subclassType) diff baseTasks @@ -381,10 +381,12 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ import scala.collection.JavaConversions._ val watcher = WatchService.newWatchService - files.map{ - file => - if(file.isFile) dirname(file) - else file + val realFiles = files.map(realpath) + + realFiles.map{ + // WatchService can only watch folders + case file if file.isFile => dirname(file) + case file => file }.distinct.map{ file => val watchableFile = new WatchableFile(file) val key = watchableFile.register( @@ -398,13 +400,19 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ scala.util.control.Breaks.breakable{ while(true){ logger.loop("Waiting for file changes...") + logger.loop("Waiting for file changes...2") Option(watcher.take).map{ key => val changedFiles = key .pollEvents + .toVector .filterNot(_.kind == StandardWatchEventKind.OVERFLOW) .map(_.context.toString) + // make sure we don't react on other files changed + // in the same folder like the files we care about + .filter{ name => realFiles.exists(name startsWith _.toString) } .map(new File(_)) + changedFiles.foreach( f => logger.loop( "Changed: " ++ f.toString ) ) changedFiles.collect(action) key.reset diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index ed63cf1..392e322 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -40,14 +40,16 @@ object Stage2{ logger.loop("Looping change detection over:\n - "++allTriggerFiles.mkString("\n - ")) - lib.watch(allTriggerFiles) { + lib.watch(allTriggerFiles){ case file if triggerCbtFiles.exists(file.toString startsWith _.toString) => logger.loop("Change is in CBT's own source code.") logger.loop("Restarting CBT.") scala.util.control.Breaks.break case file if triggerFiles.exists(file.toString startsWith _.toString) => - new lib.ReflectBuild( lib.loadDynamic(context) ).callNullary(task) + val reflectBuild = new lib.ReflectBuild( lib.loadDynamic(context) ) + logger.loop(s"Re-running $task for " ++ reflectBuild.build.projectDirectory.toString) + reflectBuild.callNullary(task) } } else { new lib.ReflectBuild(build).callNullary(task) -- cgit v1.2.3