summaryrefslogtreecommitdiff
path: root/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder')
-rw-r--r--examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/JarLibClasspathBuilder.scala13
-rw-r--r--examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PartialClasspathBuilder.scala38
-rw-r--r--examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala41
3 files changed, 92 insertions, 0 deletions
diff --git a/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/JarLibClasspathBuilder.scala b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/JarLibClasspathBuilder.scala
new file mode 100644
index 0000000..5bc488c
--- /dev/null
+++ b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/JarLibClasspathBuilder.scala
@@ -0,0 +1,13 @@
+/* __ *\
+** ________ ___ / / ___ __ ____ Scala.js tools **
+** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2014, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
+** /____/\___/_/ |_/____/_/ | |__/ /____/ **
+** |/____/ **
+\* */
+
+
+package scala.scalajs.tools.classpath.builder
+
+class JarLibClasspathBuilder extends AbstractJarLibClasspathBuilder
+ with PhysicalFileSystem
diff --git a/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PartialClasspathBuilder.scala b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PartialClasspathBuilder.scala
new file mode 100644
index 0000000..626c74c
--- /dev/null
+++ b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PartialClasspathBuilder.scala
@@ -0,0 +1,38 @@
+/* __ *\
+** ________ ___ / / ___ __ ____ Scala.js tools **
+** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2014, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
+** /____/\___/_/ |_/____/_/ | |__/ /____/ **
+** |/____/ **
+\* */
+
+
+package scala.scalajs.tools.classpath.builder
+
+import scala.scalajs.tools.classpath._
+import scala.collection.immutable.Seq
+
+/**
+ * Allows to create a PartialClasspathBuilder from a (filesystem) classpath
+ *
+ * Rules for classpath reading:
+ * - IR goes to scalaJSIR
+ * - Descends into JARs
+ * - Entries stay in order of ‘cp‘, IR remains unordered
+ * - Earlier IR entries shadow later IR entries with the same relative path
+ * - JS goes to availableLibs (earlier libs take precedence)
+ * - JS_DEPENDENCIES are added to dependencies
+ */
+class PartialClasspathBuilder extends AbstractPartialClasspathBuilder
+ with PhysicalFileSystem
+
+object PartialClasspathBuilder {
+ /** Convenience method. The same as
+ *
+ * {{{
+ * (new PartialClasspathBuilder).build(cp)
+ * }}}
+ */
+ def build(cp: Seq[java.io.File]): PartialClasspath =
+ (new PartialClasspathBuilder).build(cp)
+}
diff --git a/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala
new file mode 100644
index 0000000..a0dd7a5
--- /dev/null
+++ b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala
@@ -0,0 +1,41 @@
+package scala.scalajs.tools.classpath.builder
+
+import scala.scalajs.tools.io._
+
+import scala.collection.immutable.Traversable
+
+import java.io._
+
+/** FileSystem implementation using java.io._ */
+trait PhysicalFileSystem extends FileSystem {
+
+ type File = java.io.File
+
+ val DummyVersion: String = "DUMMY_FILE"
+
+ def isDirectory(f: File): Boolean = f.isDirectory
+ def isFile(f: File): Boolean = f.isFile
+ def isJSFile(f: File): Boolean = f.isFile && f.getName.endsWith(".js")
+ def isIRFile(f: File): Boolean = f.isFile && f.getName.endsWith(".sjsir")
+ def isJARFile(f: File): Boolean = f.isFile && f.getName.endsWith(".jar")
+ def exists(f: File): Boolean = f.exists
+
+ def getName(f: File): String = f.getName
+ def getAbsolutePath(f: File): String = f.getAbsolutePath
+ def getVersion(f: File): String = f.lastModified.toString
+
+ def listFiles(d: File): Traversable[File] = {
+ require(d.isDirectory)
+ Option(d.listFiles).map(_.toList).getOrElse {
+ throw new IOException(s"Couldn't list files in $d")
+ }
+ }
+
+ def toJSFile(f: File): VirtualJSFile = FileVirtualJSFile(f)
+ def toIRFile(f: File): VirtualScalaJSIRFile = FileVirtualScalaJSIRFile(f)
+ def toReader(f: File): Reader =
+ new BufferedReader(new FileReader(f))
+ def toInputStream(f: File): InputStream =
+ new BufferedInputStream(new FileInputStream(f))
+
+}