├── .gitignore ├── README.md ├── build.sbt ├── macro ├── build.sbt └── src │ └── main │ └── scala │ └── Macros.scala ├── project └── build.scala └── src └── main └── scala └── Main.scala /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.log 3 | 4 | # sbt specific 5 | dist/* 6 | target/ 7 | lib_managed/ 8 | src_managed/ 9 | project/boot/ 10 | project/plugins/project/ 11 | 12 | # Scala-IDE specific 13 | .scala_dependencies 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scala-macro-template 2 | ==================== 3 | 4 | Template for getting up and running with macros in no time. 5 | 6 | Scala macros must be compiled separately from the code that uses it. This 7 | template contains a subproject for writing macros that the main project then 8 | depends upon. 9 | 10 | The build file is based on the one found in the SBT docs here: 11 | http://www.scala-sbt.org/0.13.0/docs/Detailed-Topics/Macro-Projects.html 12 | 13 | To compile and run everything, simply use `sbt run`. 14 | 15 | Uses scala 2.11.2 without Macro Paradise. Tested with sbt 0.13.0. 16 | 17 | There is an example on the branch `complete-example`: 18 | https://github.com/echojc/scala-macro-template/tree/complete-example 19 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "2.11.2" 2 | -------------------------------------------------------------------------------- /macro/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "2.11.2" 2 | -------------------------------------------------------------------------------- /macro/src/main/scala/Macros.scala: -------------------------------------------------------------------------------- 1 | import scala.language.experimental.macros 2 | //import scala.reflect.macros.blackbox.Context 3 | //import scala.reflect.macros.whitebox.Context 4 | 5 | object Macros { 6 | // write macros here 7 | } 8 | -------------------------------------------------------------------------------- /project/build.scala: -------------------------------------------------------------------------------- 1 | import sbt._ 2 | import Keys._ 3 | 4 | object MacroBuild extends Build { 5 | lazy val main = Project("main", file(".")) dependsOn(macroSub) 6 | lazy val macroSub = Project("macro", file("macro")) settings( 7 | libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _) 8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /src/main/scala/Main.scala: -------------------------------------------------------------------------------- 1 | object Main extends App { 2 | import Macros._ 3 | } 4 | --------------------------------------------------------------------------------