From 828adac48d0e08766d192c7ce01021083cfc4d67 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Sun, 12 Mar 2017 22:00:00 -0400 Subject: fix file watching for real last file watching update didn’t work well enough. This now - rips out barbary watch service as it seems buggy crashing the jvm - make cbt exclusively write files to watch to a file - uses fswatch instead watching all files in that file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stage2/Lib.scala | 49 +------------------------------------------------ 1 file changed, 1 insertion(+), 48 deletions(-) (limited to 'stage2/Lib.scala') diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 5e35ea7..ceea004 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -151,6 +151,7 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ case c: ClassPath => c.string case ExitCode(int) => System.err.println(int); System.exit(int); ??? case s: Seq[_] => s.map(render).mkString("\n") + case s: Set[_] => s.map(render).toSeq.sorted.mkString("\n") case _ => obj.toString } } @@ -478,54 +479,6 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ url } - - // code for continuous compile - def watch[T]( files: () => Set[File] )( - action: Seq[File] => Option[T] = (f: Seq[File]) => Some(f) - ): T = { - import com.barbarysoftware.watchservice._ - import scala.collection.JavaConversions._ - Iterator.continually{ - val watcher = WatchService.newWatchService - val realFiles = files().map(realpath) - realFiles.map{ - // WatchService can only watch folders - case file if file.isFile => dirname(file) - case file => file - }.map{ file => - val watchableFile = new WatchableFile(file) - val key = watchableFile.register( - watcher, - StandardWatchEventKind.ENTRY_CREATE, - StandardWatchEventKind.ENTRY_DELETE, - StandardWatchEventKind.ENTRY_MODIFY - ) - } - Option( watcher.take ) -> realFiles - }.collect{ - case (Some(key),f) => key -> f - }.map{ case (key, realFiles) => - logger.loop("Waiting for file changes...") - 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 ) ) - val res = action(changedFiles) - key.reset - res - }.filterNot(_.isEmpty) - .take(1) - .toList - .head.get - } - def findInnerMostModuleDirectory(directory: File): File = { val buildDir = realpath( directory ++ ("/" ++ lib.buildDirectoryName) ) // do not appent buildFileName here, so that we detect empty build folders -- cgit v1.2.3