-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sc
55 lines (49 loc) · 2.17 KB
/
common.sc
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
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2022 Jiuyang Liu <[email protected]>
import mill._
import mill.scalalib._
import mill.scalajslib._
trait RVDecoderDBJVMModule extends ScalaModule {
override def sources: T[Seq[PathRef]] = T.sources { super.sources() ++ Some(PathRef(millSourcePath / "jvm" / "src")) }
def osLibIvy: Dep
def upickleIvy: Dep
override def ivyDeps = super.ivyDeps() ++ Some(osLibIvy) ++ Some(upickleIvy)
}
trait HasRVDecoderDBResource extends ScalaModule {
def riscvOpcodesPath: T[Option[PathRef]] = T(None)
def riscvOpcodesTar: T[Option[PathRef]] = T {
riscvOpcodesPath().map { riscvOpcodesPath =>
val tmpDir = os.temp.dir()
os.makeDir(tmpDir / "unratified")
os.walk(riscvOpcodesPath.path)
.filter(f =>
f.baseName.startsWith("rv128_") ||
f.baseName.startsWith("rv64_") ||
f.baseName.startsWith("rv32_") ||
f.baseName.startsWith("rv_") ||
f.ext == "csv"
).groupBy(_.segments.contains("unratified")).map {
case (true, fs) => fs.map(os.copy.into(_, tmpDir / "unratified"))
case (false, fs) => fs.map(os.copy.into(_, tmpDir))
}
os.proc("tar", "cf", T.dest / "riscv-opcodes.tar", ".").call(tmpDir)
PathRef(T.dest)
}
}
override def resources: T[Seq[PathRef]] = super.resources() ++ riscvOpcodesTar()
}
trait RVDecoderDBJVMTestModule extends HasRVDecoderDBResource with ScalaModule {
override def sources: T[Seq[PathRef]] = T.sources { super.sources() ++ Some(PathRef(millSourcePath / "jvm" / "src")) }
def dut: RVDecoderDBJVMModule
override def moduleDeps = super.moduleDeps ++ Some(dut)
}
trait RVDecoderDBJSModule extends ScalaJSModule {
override def sources: T[Seq[PathRef]] = T.sources { super.sources() ++ Some(PathRef(millSourcePath / "js" / "src")) }
def upickleIvy: Dep
override def ivyDeps = super.ivyDeps() ++ Some(upickleIvy)
}
trait RVDecoderDBTestJSModule extends ScalaJSModule {
override def sources: T[Seq[PathRef]] = T.sources { super.sources() ++ Some(PathRef(millSourcePath / "js" / "src")) }
def dut: RVDecoderDBJSModule
override def moduleDeps = super.moduleDeps ++ Some(dut)
}