forked from uuverifiers/eldarica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
159 lines (138 loc) · 5.31 KB
/
build.sbt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
lazy val commonSettings = Seq(
name := "Eldarica",
organization := "uuverifiers",
version := "2.0.9-ext",
homepage := Some(url("https://github.com/uuverifiers/eldarica")),
licenses := Seq("BSD License 2.0" -> url("https://github.com/uuverifiers/eldarica/blob/master/LICENSE")),
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.18"),
run / fork := true,
cancelable in Global := true,
publishTo := Some(Resolver.file("file", new File( "/home/wv/public_html/maven/" )) )
)
// Jar files for the parsers
lazy val parserSettings = Seq(
packageDoc / publishArtifact := false,
packageSrc / publishArtifact := false,
exportJars := true,
crossPaths := true
)
// Parser generation
lazy val parserGen = Seq(
Compile / sourceGenerators += Def.task {
val outputDir = (Compile / sourceManaged).value / "parser"
val base = baseDirectory.value
val cacheDir = outputDir / ".cache"
val parserDir = base / "src" / "main" / "scala" / "lazabs" / "parser"
val parserOutputDir = outputDir / "normal"
val hornParserDir = base / "src" / "main" / "scala" / "lazabs" / "horn" / "parser"
val hornParserOutputDir = outputDir / "horn"
// generated Java files
val lexerFile = parserOutputDir / "Lexer.java"
val hornLexerFile = hornParserOutputDir / "HornLexer.java"
val parserFile = parserOutputDir / "Parser.java"
val hornParserFile = hornParserOutputDir / "Parser.java"
val symFile = parserOutputDir / "Symbols.java"
val hornSymFile = hornParserOutputDir / "Symbols.java"
// grammar file
val flex = parserDir / "Lexer.jflex"
val hornFlex = hornParserDir / "HornLexer.jflex"
val cup = parserDir / "Parser.cup"
val hornCup = hornParserDir / "HornParser.cup"
val jflexLib = "./tools/JFlex.jar"
val cupLib = "./tools/java-cup-11a.jar"
val cache = FileFunction.cached(cacheDir,
inStyle = FilesInfo.lastModified,
outStyle = FilesInfo.exists){ _ =>
scala.sys.process.Process(
"java -jar " + jflexLib + " -d " +
hornParserOutputDir + " --nobak " + hornFlex).!
scala.sys.process.Process(
"java -cp ./tools/ -jar " + cupLib + " -destdir " +
hornParserOutputDir + " -parser Parser -symbols Symbols " +
hornCup).!
scala.sys.process.Process(
"java -jar " + jflexLib + " -d " + parserOutputDir +
" --nobak " + flex).!
scala.sys.process.Process(
"java -cp ./tools/ -jar " + cupLib + " -destdir " +
parserOutputDir + " -parser Parser -symbols Symbols " + cup).!
Set(lexerFile,
parserFile,
symFile,
hornLexerFile,
hornParserFile,
hornSymFile)
}
cache(Set(hornFlex, hornCup, flex, cup)).toSeq
}.taskValue
)
lazy val ccParser = (project in file("cc-parser")).
settings(commonSettings: _*).
settings(parserSettings: _*).
settings(
name := "Eldarica-CC-parser",
Compile / packageBin := baseDirectory.value / "cc-parser.jar",
Compile / unmanagedJars += baseDirectory.value / "cc-parser.jar"
).
disablePlugins(AssemblyPlugin)
lazy val tplspecParser = (project in file("template-parser")).
settings(commonSettings: _*).
settings(parserSettings: _*).
settings(
name := "Eldarica-tplspec-parser",
Compile / packageBin := baseDirectory.value / "tplspec-parser.jar",
Compile / unmanagedJars += baseDirectory.value / "tplspec-parser.jar"
).
disablePlugins(AssemblyPlugin)
// Actual project
lazy val root = (project in file(".")).
aggregate(ccParser, tplspecParser).
dependsOn(ccParser, tplspecParser).
settings(parserGen: _*).
settings(commonSettings: _*).
//
settings(
Compile / mainClass := Some("lazabs.Main"),
//
Compile / unmanagedJars ++= (baseDirectory map { base =>
val baseDirectories = (base / "flata")
val customJars = (baseDirectories ** "*.jar")
customJars.classpath
}).value,
//
Compile / scalacOptions ++=
List("-feature",
"-language:implicitConversions,postfixOps,reflectiveCalls",
"-encoding", "UTF-8"),
scalacOptions += (scalaVersion map { sv => sv match {
case "2.11.12" => "-optimise"
case "2.12.18" => "-opt:_"
}}).value,
//
assembly / test := None,
//
libraryDependencies +=
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4",
//
libraryDependencies +=
"net.sf.squirrel-sql.thirdparty-non-maven" % "java-cup" % "0.11a",
//
libraryDependencies +=
"org.antlr" % "antlr" % "3.3",
//
libraryDependencies +=
"org.scala-lang.modules" %% "scala-xml" % "1.3.0",
//
libraryDependencies +=
"org.scalactic" %% "scalactic" % "3.2.14",
//
libraryDependencies +=
"org.scalatest" %% "scalatest" % "3.2.14" % "test",
//
// libraryDependencies += "io.github.uuverifiers" %% "princess" % "2023-04-07"
//
resolvers += "uuverifiers" at "https://eldarica.org/maven/",
libraryDependencies += "uuverifiers" %% "princess" % "nightly-SNAPSHOT"
)
//