Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move check for writable cache file to after usage options

  • Loading branch information...
commit 9ee4389d2f582d3e8f98d99b8f2588a3ef550569 1 parent 5d73e7d
@pvlugter pvlugter authored
View
23 src/main/scala/com/typesafe/zinc/Inputs.scala
@@ -120,12 +120,9 @@ object Inputs {
/**
* By default the cache location is relative to the classes directory (for example, target/classes/../cache/classes).
- * If not writable then the fallback is within the zinc cache directory.
*/
def defaultCacheLocation(classesDir: File) = {
- val alongside = classesDir.getParentFile / "cache" / classesDir.getName
- if (Util.checkWritable(alongside)) alongside
- else Setup.zincCacheDir / "analysis-cache" / classesDir.getCanonicalPath
+ classesDir.getParentFile / "cache" / classesDir.getName
}
/**
@@ -147,6 +144,24 @@ object Inputs {
}
/**
+ * Verify inputs and update if necessary.
+ * Currently checks that the cache file is writable.
+ */
+ def verify(inputs: Inputs): Inputs = {
+ inputs.copy(cacheFile = verifyCacheFile(inputs.cacheFile, inputs.classesDirectory))
+ }
+
+ /**
+ * Check that the cache file is writable.
+ * If not writable then the fallback is within the zinc cache directory.
+ *
+ */
+ def verifyCacheFile(cacheFile: File, classesDir: File): File = {
+ if (Util.checkWritable(cacheFile)) cacheFile
+ else Setup.zincCacheDir / "analysis-cache" / classesDir.getCanonicalPath
+ }
+
+ /**
* Debug output for inputs.
*/
def debug(inputs: Inputs, log: xsbti.Logger): Unit = {
View
11 src/main/scala/com/typesafe/zinc/Main.scala
@@ -76,15 +76,18 @@ object Main {
sys.exit(1)
}
+ // verify inputs and update if needed
+ val vinputs = Inputs.verify(inputs)
+
// warn about cache file location when under zinc cache dir
- if (inputs.cacheFile.getCanonicalPath startsWith Setup.zincCacheDir.getPath) {
- log.warn("Default cache file location not accessible. Using " + inputs.cacheFile.getPath)
+ if (vinputs.cacheFile.getCanonicalPath startsWith Setup.zincCacheDir.getPath) {
+ log.warn("Default cache file location not accessible. Using " + vinputs.cacheFile.getPath)
}
if (isDebug) {
val debug: String => Unit = log.debug(_)
Setup.show(setup, debug)
- Inputs.show(inputs, debug)
+ Inputs.show(vinputs, debug)
debug("Setup and Inputs parsed " + Util.timing(startTime))
}
@@ -92,7 +95,7 @@ object Main {
try {
val compiler = Compiler(setup, log)
log.debug("Zinc compiler = %s [%s]" format (compiler, compiler.hashCode.toHexString))
- compiler.compile(inputs, cwd)(log)
+ compiler.compile(vinputs, cwd)(log)
log.info("Compile success " + Util.timing(startTime))
} catch {
case e: CompileFailed =>
Please sign in to comment.
Something went wrong with that request. Please try again.