-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbuild.sbt
More file actions
74 lines (57 loc) · 3.29 KB
/
build.sbt
File metadata and controls
74 lines (57 loc) · 3.29 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
73
74
name := "nam-controller"
organization := "com.sc4nam"
version := "50-SNAPSHOT"
scalaVersion := "3.6.4"
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-feature",
// "-opt-warnings:at-inline-failed-summary",
// "-opt:l:inline", "-opt-inline-from:<sources>",
"-encoding", "UTF-8",
"-release:8")
console / initialCommands := """
import io.github.memo33.metarules.meta._, com.sc4nam.module, module.syntax._
import Implicits._, Network._, Flags._, RotFlip._, Rule.{CopyTile => %}, group.SymGroup._, module.NetworkProperties._
lazy val resolve = module.Main.resolveSafely
lazy val preimage = module.ReverseResolver.create()
implicit lazy val context: RuleTransducer.Context = RuleTransducer.Context(module.Main.resolve, module.RegenerateTileOrientationCache.loadCache(), module.MirrorVariants.preprocessor)
def transduce(rule: Rule[SymTile]): Unit = RuleTransducer(rule)(context).map(_.toRul2String).foreach(println)
"""
def wrapWithJLogger(logger: sbt.util.Logger): sbt.util.Logger = {
// the following is a workaround to highlight the logged warnings with sbt
val jLogger = java.util.logging.Logger.getLogger("networkaddonmod")
jLogger.setUseParentHandlers(false) // avoids printing to console twice
class MyHandler extends java.util.logging.Handler {
def close() = {}
def flush() = {}
def publish(record: java.util.logging.LogRecord): Unit = record.getLevel match {
case java.util.logging.Level.SEVERE => logger.error(record.getMessage)
case java.util.logging.Level.WARNING => logger.warn(record.getMessage)
case java.util.logging.Level.INFO => logger.info(record.getMessage)
}
}
jLogger.addHandler(new MyHandler())
logger
}
def runMainWithJLogger(main: String) = Def.inputTask {
val args: Seq[String] = sbt.complete.Parsers.spaceDelimited("<arg>").parsed
(Compile / runner).value.run(
mainClass = if (main == null) args(0) else main,
classpath = (Compile / fullClasspath).value.files,
log = wrapWithJLogger(streams.value.log),
options = if (main == null) args.drop(1) else args)
}
// Compile / mainClass := Some("metarules.module.CompileAllMetarules") // execute with `sbt run`
run := runMainWithJLogger("com.sc4nam.module.CompileAllMetarules").evaluated
runMain := runMainWithJLogger(null).evaluated
lazy val generateLocales = inputKey[scala.util.Try[Unit]]("Generates the locale .dat files from .po files")
generateLocales := runMainWithJLogger("com.sc4nam.localization.GenerateLocales").evaluated
lazy val regenerateTileOrientationCache = inputKey[scala.util.Try[Unit]]("Regenerates the cache used for translating metarules to RUL2")
regenerateTileOrientationCache := runMainWithJLogger("com.sc4nam.module.RegenerateTileOrientationCache").evaluated
lazy val conflictingOverridesCheck = inputKey[scala.util.Try[Unit]]("Checks all RUL2 code for conflicting overrides, optionally updates the inline `conflicting-override` tags")
conflictingOverridesCheck := runMainWithJLogger("com.sc4nam.scripts.ConflictingOverridesChecker").evaluated
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.17" % Test
libraryDependencies += "tv.cntt" %% "scaposer" % "1.11.1" cross CrossVersion.for3Use2_13
libraryDependencies += "io.github.memo33" %% "scdbpf" % "0.2.0" cross CrossVersion.for3Use2_13
libraryDependencies += "io.github.memo33" %% "metarules" % "0.7.1"