From 616c824f3d49853323a7d776f914281b7544ad41 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Thu, 9 Mar 2017 22:41:09 -0500 Subject: avoid non-existent directory warning --- stage2/BasicBuild.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index f3e5f99..5f74c99 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -88,7 +88,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge */ def compileStatusFile: File = compileTarget ++ ".last-success" - def generatedSources: Seq[File] = Seq( projectDirectory / "src_generated" ) + def generatedSources: Seq[File] = Seq( projectDirectory / "src_generated" ).filter( _.exists ) /** Source directories and files. Defaults to .scala and .java files in src/ and top-level. */ def sources: Seq[File] = ( Seq(defaultSourceDirectory) -- cgit v1.2.3 From a06fdb7e62c5e1c9bd2737ffa7df50e9c31f6b97 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Thu, 9 Mar 2017 22:50:33 -0500 Subject: more concise runMain in more places --- plugins/scalajs/ScalaJsLib.scala | 5 ++--- stage1/Stage1Lib.scala | 5 ++--- stage1/resolver.scala | 4 ++-- stage2/BasicBuild.scala | 5 ++--- stage2/Lib.scala | 6 ++---- stage2/ToolsTasks.scala | 12 ++++++------ stage2/plugins/Dotty.scala | 14 +++++--------- stage2/plugins/Frege.scala | 5 ++--- 8 files changed, 23 insertions(+), 33 deletions(-) diff --git a/plugins/scalajs/ScalaJsLib.scala b/plugins/scalajs/ScalaJsLib.scala index 7886478..5b231a1 100644 --- a/plugins/scalajs/ScalaJsLib.scala +++ b/plugins/scalajs/ScalaJsLib.scala @@ -15,14 +15,13 @@ case class ScalaJsLib( outputPath.getParentFile.mkdirs val scalaJsCliDep = dep( "scalajs-cli_"++lib.libMajorVersion(scalaVersion) ) outputPath.getParentFile.mkdirs - lib.runMain( + scalaJsCliDep.runMain( "org.scalajs.cli.Scalajsld", Seq( "--sourceMap", "--stdlib", s"${scalaJsLibraryDependency.jar.getAbsolutePath}", "--output", outputPath.string - ) ++ scalaJsOptions ++ entriesToLink.map(_.getAbsolutePath), - scalaJsCliDep.classLoader + ) ++ scalaJsOptions ++ entriesToLink.map(_.getAbsolutePath) ) } diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index c46e00c..01115d4 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -272,12 +272,11 @@ class Stage1Lib( logger: Logger ) extends BaseLib{ redirectOutToErr{ System.err.println("Compiling to " ++ compileTarget.toString) try{ - lib.runMain( + zinc.runMain( _class, dualArgs ++ singleArgs ++ ( if(cp.isEmpty) Nil else Seq("-cp", cp) - ) ++ sourceFiles.map(_.string), - zinc.classLoader + ) ++ sourceFiles.map(_.string) ) } catch { case scala.util.control.NonFatal(e) => diff --git a/stage1/resolver.scala b/stage1/resolver.scala index 86cf5ab..1304f76 100644 --- a/stage1/resolver.scala +++ b/stage1/resolver.scala @@ -79,7 +79,7 @@ trait DependencyImplementation extends Dependency{ } */ - def runMain( className: String, args: String* ) = lib.runMain( className, args, classLoader ) + def runMain( className: String, args: Seq[String] ) = lib.runMain( className, args, classLoader ) def flatClassLoader: Boolean = false @@ -88,7 +88,7 @@ trait DependencyImplementation extends Dependency{ def runClass: Option[String] = lib.runClass( mainClasses ).map( _.getName ) def run( args: String* ): ExitCode = { - runClass.map( runMain( _, args: _* ) ).getOrElse{ + runClass.map( runMain( _, args ) ).getOrElse{ // FIXME: this just doing nothing when class is not found has been repeatedly // surprising. Let's try to make this more visible than just logging an error. // Currently blocked on task `recursive` trying every subbuild and would error diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 5f74c99..0d8017f 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -196,15 +196,14 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge } val scalac = new ScalaCompilerDependency(context.cbtLastModified, context.paths.mavenCache, scalaVersion) - lib.runMain( + scalac.runMain( "scala.tools.nsc.MainGenericRunner", Seq( "-bootclasspath", scalac.classpath.string, "-classpath", classpath.string - ) ++ context.args , - scalac.classLoader + ) ++ context.args ) } diff --git a/stage2/Lib.scala b/stage2/Lib.scala index db1ee6d..46668b7 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -76,10 +76,8 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ ) ++ compileArgs ++ sourceFiles.map(_.toString) logger.lib("creating docs for source files "+args.mkString(", ")) redirectOutToErr{ - runMain( - "scala.tools.nsc.ScalaDoc", - args, - new ScalaDependencies(cbtLastModified,mavenCache,scalaVersion).classLoader + new ScalaDependencies(cbtLastModified,mavenCache,scalaVersion).runMain( + "scala.tools.nsc.ScalaDoc", args ) } Some(scaladocTarget) diff --git a/stage2/ToolsTasks.scala b/stage2/ToolsTasks.scala index eb41dd0..15052ae 100644 --- a/stage2/ToolsTasks.scala +++ b/stage2/ToolsTasks.scala @@ -49,22 +49,22 @@ class ToolsTasks( def amm = ammonite def ammonite = { val version = args.lift(1).getOrElse(constants.scalaVersion) - val classLoader = Resolver(mavenCentral).bindOne( + val ammonite = Resolver(mavenCentral).bindOne( MavenDependency( "com.lihaoyi","ammonite-repl_2.11.8",args.lift(1).getOrElse("0.5.8") ) - ).classLoader + ) // FIXME: this does not work quite yet, throws NoSuchFileException: /ammonite/repl/frontend/ReplBridge$.class - lib.runMain( - "ammonite.repl.Main", args.drop(2), classLoader + ammonite.runMain( + "ammonite.repl.Main", args.drop(2) ) } def scala = { val version = args.lift(1).getOrElse(constants.scalaVersion) val scalac = new ScalaCompilerDependency( cbtLastModified, mavenCache, version ) val _args = Seq("-cp", scalac.classpath.string) ++ args.drop(2) - lib.runMain( - "scala.tools.nsc.MainGenericRunner", _args, scalac.classLoader + scalac.runMain( + "scala.tools.nsc.MainGenericRunner", _args ) } def cbtEarlyDependencies = { diff --git a/stage2/plugins/Dotty.scala b/stage2/plugins/Dotty.scala index 8ffcdb6..01ffa27 100644 --- a/stage2/plugins/Dotty.scala +++ b/stage2/plugins/Dotty.scala @@ -78,15 +78,14 @@ class DottyLib( def repl(args: Seq[String], classpath: ClassPath) = { consoleOrFail("Use `cbt direct repl` instead") - lib.runMain( + dottyCompiler.runMain( "dotty.tools.dotc.repl.Main", Seq( "-bootclasspath", dottyCompiler.classpath.string, "-classpath", classpath.string - ) ++ args, - dottyCompiler.classLoader + ) ++ args ) } @@ -144,27 +143,24 @@ class DottyLib( "-d", compileTarget.toString ) val singleArgs = dottyOptions.map( "-S" ++ _ ) - val urls = dottyCompiler.classpath.strings.map("file://"+_).map(new java.net.URL(_)) - val cl = new java.net.URLClassLoader( urls.to ) val code = try{ System.err.println("Compiling with Dotty to " ++ compileTarget.toString) compileTarget.mkdirs redirectOutToErr{ - lib.runMain( + dottyCompiler.runMain( _class, dualArgs ++ singleArgs ++ Seq( "-bootclasspath", dottyCompiler.classpath.string ) ++ ( if(cp.isEmpty) Nil else Seq("-classpath", cp) // let's put cp last. It so long - ) ++ sourceFiles.map(_.toString), - cl + ) ++ sourceFiles.map(_.toString) ) } } catch { case e: Exception => System.err.println(red("Dotty crashed. See https://github.com/lampepfl/dotty/issues. To reproduce run:")) - System.err.println(cl) + System.err.println(dottyCompiler.classLoader) System.out.println(s""" java -cp \\ ${dottyCompiler.classpath.strings.mkString(":\\\n")} \\ diff --git a/stage2/plugins/Frege.scala b/stage2/plugins/Frege.scala index 3598d08..3fcd56b 100644 --- a/stage2/plugins/Frege.scala +++ b/stage2/plugins/Frege.scala @@ -88,10 +88,9 @@ class FregeLib( System.err.println("Compiling with Frege to " ++ compileTarget.toString) compileTarget.mkdirs redirectOutToErr{ - lib.runMain( + fregeDependency.runMain( _class, - dualArgs ++ singleArgs ++ sourceFiles.map(_.toString), - fregeDependency.classLoader + dualArgs ++ singleArgs ++ sourceFiles.map(_.toString) ) } } catch { -- cgit v1.2.3