-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
153 lines (140 loc) · 4.57 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
val JAR_NAME =
"ralph-lsp.jar"
val MAIN_CLASS =
"org.alephium.ralph.lsp.Main"
val inliningOptions =
Seq(
"-opt-warnings",
"-opt:l:inline",
"-opt-inline-from:org.alephium.ralph.lsp.**"
// Uncomment to debug inlining
/*
"-Yopt-log-inline",
"_"
*/
)
val commonSettings =
Seq(
organization := "org.alephium",
scalaVersion := Version.scala213,
scalacOptions ++=
Seq(
"-deprecation",
"-encoding",
"utf-8",
"-explaintypes",
"-feature",
"-unchecked",
// "-Xsource:3.1",
"-Xfatal-warnings",
"-Xlint:adapted-args",
"-Xlint:constant",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:missing-interpolator",
"-Xlint:nullary-unit",
"-Xlint:option-implicit",
"-Xlint:package-object-classes",
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:nonlocal-return",
"-Ywarn-dead-code",
"-Ywarn-extra-implicit",
"-Ywarn-numeric-widen",
"-Ywarn-unused:implicits",
"-Ywarn-unused:imports",
"-Ywarn-unused:locals",
"-Ywarn-unused:params",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Ywarn-value-discard"
) ++ inliningOptions,
Compile / doc / scalacOptions ++= Seq(
"-no-link-warnings"
)
)
lazy val `compiler-access` =
project
.settings(
commonSettings,
libraryDependencies ++=
Seq(
Dependencies.ralphc,
Dependencies.scalaTest,
Dependencies.scalaCheck,
Dependencies.logback,
Dependencies.scalaLogging
)
)
lazy val `presentation-compiler` =
project
.settings(
commonSettings,
libraryDependencies ++=
Seq(
Dependencies.ralphc,
Dependencies.scalaTest,
Dependencies.scalaCheck,
Dependencies.scalaMock,
Dependencies.logback,
Dependencies.scalaLogging
)
)
.dependsOn(`compiler-access` % "test->test;compile->compile")
/** Copies the JAR generated by assembly to VSCode's out directory */
lazy val copyJARToVSCode =
taskKey[Unit](s"Copy $JAR_NAME to VSCode")
lazy val `lsp-server` =
project
.settings(
commonSettings,
scalacOptions += "-Xmixin-force-forwarders:false", // duplicate RPC method initialized.
assembly / mainClass := Some(MAIN_CLASS),
assembly / assemblyJarName := JAR_NAME,
assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case other => assemblyMergeStrategy.value(other)
},
copyJARToVSCode :=
IO.copyFile(
sourceFile = (Compile / target).value / s"scala-${scalaBinaryVersion.value}" / JAR_NAME,
targetFile = file(s"plugin-vscode/out/$JAR_NAME")
),
Test / scalacOptions += "-Xmixin-force-forwarders:true", // reset to default for tests.
libraryDependencies ++=
Seq(
Dependencies.lsp4j,
Dependencies.scalaTest,
Dependencies.scalaCheck,
Dependencies.scalaMock,
Dependencies.logback,
Dependencies.scalaLogging
)
)
.dependsOn(`presentation-compiler` % "test->test;compile->compile")
lazy val `ralph-lsp` =
(project in file("."))
.settings(
commonSettings,
Compile / mainClass := Some(MAIN_CLASS)
)
.dependsOn(`lsp-server`)
.aggregate(`compiler-access`, `presentation-compiler`, `lsp-server`)
.enablePlugins(JavaAppPackaging)
lazy val downloadWeb3AndInstallStd = taskKey[Unit]("Download alephium-web3 source code and copy std interface to the correct resource folder")
downloadWeb3AndInstallStd := {
val web3Dir = new File(s"target/web3/alephium-web3-${Version.web3}")
val stdDir = new File("compiler-access/src/main/resources/std")
val web3StdDir = new File(s"target/web3/alephium-web3-${Version.web3}/packages/web3/std")
if (java.nio.file.Files.notExists(web3Dir.toPath())) {
IO.unzipURL(new URL(s"https://github.com/alephium/alephium-web3/archive/refs/tags/v${Version.web3}.zip"), new File("target/web3"))
}
IO.copyDirectory(web3StdDir, stdDir)
}
//Download and install of web3 will always be performed before compilation
Compile / compile := ((Compile / compile) dependsOn downloadWeb3AndInstallStd).value