diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-12 22:00:00 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-12 22:34:02 -0400 |
commit | 828adac48d0e08766d192c7ce01021083cfc4d67 (patch) | |
tree | 06e19c3f9117c24e6c6a5e8a95990011a0efe4b3 /stage2/Lib.scala | |
parent | c14e288996d2b56b6b06a0624f4f2fca315369c7 (diff) | |
download | cbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.gz cbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.bz2 cbt-828adac48d0e08766d192c7ce01021083cfc4d67.zip |
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
Diffstat (limited to 'stage2/Lib.scala')
-rw-r--r-- | stage2/Lib.scala | 49 |
1 files changed, 1 insertions, 48 deletions
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 |