-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.sbt
More file actions
72 lines (48 loc) · 2.74 KB
/
build.sbt
File metadata and controls
72 lines (48 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name := "Java2CppTranslator"
version := "1.0"
scalaVersion := "2.11.7"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
parallelExecution in Test := false
fork in run := true
mainClass in assembly := Some("edu.nyu.oop.Boot")
unmanagedResourceDirectories in Compile += { baseDirectory.value / "src/main/java" }
resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.9"
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
crossPaths := false
scalariformSettings
// Custom tasks
compile <<= (compile in Compile) dependsOn(clean, compile in Test)
// Formats any C++ code located in the /output directory
val formatc = TaskKey[Unit]("formatc", "Code formatter for generated C++. Run it after translation.")
formatc := """astyle --suffix=none --style=allman output/* """.!
// Formats Java code located in the test directory
val formatjtests = TaskKey[Unit]("formatjtests", "Code formatter for Java Unit Tests. Run it regularly.")
formatjtests := """astyle --recursive --suffix=none --style=java src/test/java/* """.!
// Formats Java code located in the main directory
val formatj = TaskKey[Unit]("formatj", "Code formatter for Java. Run it regularly.")
formatj <<= formatjtests map { (e) => """astyle --recursive --suffix=none --style=java src/main/java/* """.! }
// Compiles C++ code located in the output directory
val compilec = TaskKey[Unit]("compilec", "Compile the generated C++.")
//compilec := """find output -name *.cpp -exec g++ -o output/a.out {} \+ """.!
compilec := """g++ -std=c++11 output/main.cpp output/java_lang.cpp output/output.cpp -o output/a.out """.!
// Executes C++ code located in the output directory
val execc = TaskKey[Unit]("execc", "Execute the generated C++.")
execc := """output/a.out""".!
// Cleans generated C++ executable file located in the output directory
val cleanc = TaskKey[Unit]("cleanc", "Clean the generated C++ executable.")
cleanc := """rm output/a.out""".!
// Shortcut for executing our root xtc Tool
val runxtc = inputKey[Unit]("Run a command on your Boot class.")
runxtc := Def.inputTaskDyn {
val args = sbt.complete.DefaultParsers.spaceDelimited("<arg>").parsed
val cmd = s" edu.nyu.oop.Boot ${args.mkString(" ")}"
(runMain in Compile).toTask(cmd)
}.evaluated
// Dumps configuration located in the properties file to console
val conf = inputKey[Unit]("Output application configuration")
conf := Def.inputTaskDyn {
(runMain in Compile).toTask(s" edu.nyu.oop.Boot -printConfig src/test/java/inputs/test000/Test000.java")
}.evaluated