-
Notifications
You must be signed in to change notification settings - Fork 2
/
lakefile.lean
45 lines (35 loc) · 1.33 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
import Lake
open System Lake DSL
unsafe def extismIncludePathImpl (_: Unit) :=
match unsafeBaseIO (IO.getEnv "EXTISM_INCLUDE_PATH") with
| .none => "/usr/local/include"
| .some x => x
unsafe def extismLibPathImpl (_: Unit) :=
match unsafeBaseIO (IO.getEnv "EXTISM_LIB_PATH") with
| .none => "/usr/local/lib"
| .some x => x
@[implemented_by extismIncludePathImpl]
opaque extismIncludePath: Unit -> String
@[implemented_by extismLibPathImpl]
opaque extismLibPath: Unit -> String
package extism {
-- precompileModules := true
moreLinkArgs := #["-L" ++ extismLibPath (), "-lextism"]
}
lean_lib Extism
-- add library configuration options here
@[default_target]
lean_exe test {
root := `Test
}
target bindings.o pkg : FilePath := do
let oFile := pkg.buildDir / "c" / "bindings.o"
let srcJob ← inputTextFile <| pkg.dir / "c" / "bindings.c"
let weakArgs := #["-I", (← getLeanIncludeDir).toString, "-I", extismIncludePath ()]
buildO oFile srcJob weakArgs #["-fPIC", "--std=c11"] "cc" getLeanTrace
extern_lib libleanextism pkg := do
let name := nameToStaticLib "leanextism"
let ffiO ← bindings.o.fetch
buildStaticLib (pkg.nativeLibDir / name) #[ffiO]
-- meta if get_config? env = some "dev" then -- dev is so not everyone has to build it
-- require «doc-gen4» from git "https://github.com/leanprover/doc-gen4" @ "main"