-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlakefile.lean
81 lines (69 loc) · 2.48 KB
/
lakefile.lean
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
import Lake
open System Lake DSL
package CvxLean where
leanOptions := #[
⟨`pp.unicode.fun, true⟩,
⟨`pp.proofs.withType, false⟩,
⟨`autoImplicit, false⟩,
⟨`relaxedAutoImplicit, false⟩
]
require mathlib from git
"https://github.com/leanprover-community/mathlib4" @
"efad919b6687484ee26ac7c65a29c972d2112b8d"
meta if get_config? env = some "scilean" then
require scilean from git
"https://github.com/verified-optimization/SciLean" @
"master"
meta if get_config? doc = some "on" then
require «doc-gen4» from git
"https://github.com/verified-optimization/doc-gen4.git" @
"main"
@[default_target]
lean_lib CvxLean
@[default_target]
lean_lib CvxLeanTest
def compileCargo (name : String) (manifestFile : FilePath) (cargo : FilePath := "cargo")
(env : Array (String × Option String)) : LogIO Unit := do
logInfo s!"Creating {name}"
proc {
env := env
cmd := cargo.toString
args := #["build", "--release", "--manifest-path", manifestFile.toString]
}
def buildCargo (targetFile : FilePath) (manifestFile : FilePath) (targetDest : FilePath)
(oFileJobs : Array (BuildJob FilePath)) (stopOnSuccess : Bool) :
SpawnM (BuildJob FilePath) :=
let name := targetFile.fileName.getD targetFile.toString
buildFileAfterDepArray targetFile oFileJobs fun _ => do
let env := if stopOnSuccess then #[("RUSTFLAGS", some "--cfg stop_on_success")] else #[]
compileCargo name manifestFile (env := env)
createParentDirs targetDest
proc {
cmd := "cp"
args := #[targetFile.toString, targetDest.toString]
}
target EggPreDCP (pkg) : FilePath := do
let buildDir := pkg.dir / "egg-pre-dcp"
let binFile := buildDir / "target" / "release" / "egg-pre-dcp"
let dest := buildDir / "utils" / "egg-pre-dcp"
let manifestFile := buildDir / "Cargo.toml"
buildCargo binFile manifestFile dest #[] false
target EggPreDCPStopOnSuccess (pkg) : FilePath := do
let buildDir := pkg.dir / "egg-pre-dcp"
let binFile := buildDir / "target" / "release" / "egg-pre-dcp"
let dest := buildDir / "utils" / "egg-pre-dcp"
let manifestFile := buildDir / "Cargo.toml"
buildCargo binFile manifestFile dest #[] true
script EggClean := do
let targetDir : FilePath := "." / "egg-pre-dcp" / "target"
let utilsDir : FilePath := "." / "egg-pre-dcp" / "utils"
let out ←
IO.Process.output {
cmd := "rm"
args := #["-rf", targetDir.toString]
} *>
IO.Process.output {
cmd := "rm"
args := #["-rf", utilsDir.toString]
}
pure out.exitCode