Skip to content

Commit 3d529a5

Browse files
committed
Initial revision
0 parents  commit 3d529a5

File tree

9 files changed

+106
-0
lines changed

9 files changed

+106
-0
lines changed

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Erik Bakker
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# sbt-purescript
2+
3+
sbt-purescript is an SBT plugin that compiles [PureScript](http://purescript.org) files to Javascript. It uses and follows the conventions of [sbt-web](https://github.com/sbt/sbt-web).
4+
5+
# Usage
6+
7+
This plugin is not hosted yet. A minimal example can be found in the `example` directory.

build.sbt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sbtPlugin := true
2+
3+
organization := "net.eamelink.sbt"
4+
5+
name := "sbt-purescript"
6+
7+
version := "0.1-SNAPSHOT"
8+
9+
scalaVersion := "2.10.4"
10+
11+
scalacOptions += "-feature"
12+
13+
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.0")
14+
15+
publishMavenStyle := false
16+
17+

example/build.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lazy val root = (project in file(".")).enablePlugins(SbtWeb)

example/project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.5

example/project/plugins.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lazy val root = project.in(file(".")).dependsOn(pureScriptPlugin)
2+
3+
lazy val pureScriptPlugin = file("../..")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main where
2+
3+
import Debug.Trace
4+
5+
main = trace "Hello, World!"

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package net.eamelink.sbt.purescript
2+
3+
import sbt._
4+
import com.typesafe.sbt.web.SbtWeb
5+
import sbt.Keys._
6+
7+
object Import {
8+
object PureScriptKeys {
9+
val purescript = TaskKey[Seq[File]]("purescript", "Invoke the PureScript compiler.")
10+
val binary = SettingKey[String]("purescript-binary", "The purescript binary.")
11+
val outputFile = SettingKey[File]("purescript-output-file", "Purescript output file.")
12+
}
13+
}
14+
15+
object SbtPureScript extends AutoPlugin {
16+
17+
override def requires = SbtWeb
18+
19+
override def trigger = AllRequirements
20+
21+
val autoImport = Import
22+
23+
import SbtWeb.autoImport._
24+
import WebKeys._
25+
import autoImport.PureScriptKeys._
26+
27+
val basePureScriptSettings = Seq(
28+
includeFilter := "*.purs",
29+
outputFile := (public in Assets).value / "js" / "main.js",
30+
binary := "psc")
31+
32+
override def projectSettings =
33+
inConfig(Assets)(basePureScriptSettings) ++
34+
Seq(
35+
purescript := {
36+
val sourceDir = (sourceDirectory in Assets).value
37+
val sources = sourceDir ** (includeFilter in Assets in purescript).value
38+
val sourcePaths = sources.getPaths
39+
streams.value.log.info(s"Purescript compiling ${sourcePaths.length} sources")
40+
41+
val command = List(
42+
(binary in Assets).value,
43+
"--output", (outputFile in Assets).value.absolutePath) ++
44+
sourcePaths
45+
46+
command ! (streams.value.log)
47+
48+
Seq((outputFile in Assets).value)
49+
})
50+
51+
}

0 commit comments

Comments
 (0)