-
Notifications
You must be signed in to change notification settings - Fork 2
/
lakefile.lean
51 lines (43 loc) · 1.58 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
import Lake
open Lake DSL
-- Cf. https://github.com/lurk-lab/RustFFI.lean
package egg where
srcDir := "Lean"
@[default_target]
lean_lib Egg where
precompileModules := true
target importTarget pkg : System.FilePath := do
let oFile := pkg.buildDir / "c" / "ffi.o"
let srcJob ← inputTextFile <| pkg.dir / "C" / "ffi.c"
buildFileAfterDep oFile srcJob fun srcFile => do
let flags := #["-I", toString (← getLeanIncludeDir), "-fPIC"]
compileO oFile srcFile flags
extern_lib ffi pkg := do
let job ← fetch <| pkg.target ``importTarget
let libFile := pkg.nativeLibDir / nameToStaticLib "ffi"
buildStaticLib libFile #[job]
extern_lib egg_for_lean pkg := do
proc {
cmd := "cargo",
args := #["rustc", "--release", "--", "-C", "relocation-model=pic"],
cwd := pkg.dir / "Rust" / "Egg"
}
let name := nameToStaticLib "egg_for_lean"
let srcPath := pkg.dir / "Rust" / "Egg" / "target" / "release" / name
IO.FS.createDirAll pkg.nativeLibDir
let tgtPath := pkg.nativeLibDir / name
IO.FS.writeBinFile tgtPath (← IO.FS.readBinFile srcPath)
return pure tgtPath
extern_lib slotted_for_lean pkg := do
proc {
cmd := "cargo",
args := #["rustc", "--release", "--", "-C", "relocation-model=pic"],
cwd := pkg.dir / "Rust" / "Slotted"
}
let name := nameToStaticLib "slotted_for_lean"
let srcPath := pkg.dir / "Rust" / "Slotted" / "target" / "release" / name
IO.FS.createDirAll pkg.nativeLibDir
let tgtPath := pkg.nativeLibDir / name
IO.FS.writeBinFile tgtPath (← IO.FS.readBinFile srcPath)
return pure tgtPath
require "nomeata" / "calcify" @ git "master"