-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathlakefile.lean
More file actions
76 lines (58 loc) · 2.61 KB
/
lakefile.lean
File metadata and controls
76 lines (58 loc) · 2.61 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
75
76
import Lake
open Lake DSL System
require mathlib from git
"https://github.com/leanprover-community/mathlib4.git"@"v4.22.0"
package «evmyul» {
moreLeanArgs := #["-DautoImplicit=false"]
moreServerOptions := #[⟨`autoImplicit, false⟩]
}
def cloneWithCache (pkg : NPackage _package.name) (dirname url : String) : FetchM (Job GitRepo) := do
let repoDir : GitRepo := ⟨pkg.dir / dirname⟩
if !(← repoDir.dir.pathExists) then dbg_trace s!"Cloning: {url}"; GitRepo.clone url repoDir
return pure repoDir
target cloneSha2 pkg : GitRepo := cloneWithCache pkg "sha2" "https://github.com/amosnier/sha-2.git"
target cloneKeccak256 pkg : GitRepo := cloneWithCache pkg "keccak256" "https://github.com/brainhub/SHA3IUF.git"
def hash256CDir (hash256repo : GitRepo) : FilePath :=
hash256repo.dir
abbrev compiler := "cc"
target ffi.o pkg : FilePath := do
let sha2 ← (←cloneSha2.fetch).await
let keccak256 ← (←cloneKeccak256.fetch).await
let oFile := pkg.buildDir / "ffi.o"
let srcJob ← inputTextFile <| pkg.dir / "EvmYul" / "FFI" / "ffi.c"
let weakArgs := #[
"-I", (← getLeanIncludeDir).toString,
"-I", sha2.dir.toString,
"-I", keccak256.dir.toString
]
buildO oFile srcJob weakArgs #["-fPIC"] compiler getLeanTrace
def buildFFILib (pkg : Package) (repo : GitRepo) (fileName : String) : FetchM (Job FilePath) := do
let srcJob ← inputTextFile $ repo.dir / fileName |>.addExtension "c"
let oFile := pkg.buildDir / fileName |>.addExtension "o"
let includeArgs := #["-I", repo.dir.toString]
let weakArgs := includeArgs
buildO oFile srcJob weakArgs #["-fPIC"] compiler getLeanTrace
def buildSha256Obj (pkg : Package) (fileName : String) := do
buildFFILib pkg (← (←cloneSha2.fetch).await).1 fileName
def buildKeccak256Obj (pkg : Package) (fileName : String) := do
buildFFILib pkg (← (←cloneKeccak256.fetch).await).1 fileName
extern_lib libleanffi pkg := do
-- In the static lib we include:
-- the `sha-256` library itself
let sha256O ← buildSha256Obj pkg "sha-256"
let keccak256 ← buildKeccak256Obj pkg "sha3"
-- our own `ffi.c`
let ffiO ← ffi.o.fetch
if !(←System.FilePath.pathExists "EthereumTests") then
dbg_trace s!"Cloning EthereumTests into a submodule."
discard <| IO.Process.run {cmd := "git", args := #["submodule", "update", "--init"]}
let name := nameToStaticLib "leanffi"
buildStaticLib (pkg.nativeLibDir / name) #[sha256O, keccak256, ffiO]
lean_lib «Conform»
@[default_target]
lean_lib «EvmYul»
@[test_driver]
lean_exe «conform» where
root := `Conform.Main
lean_exe «yulSemanticsTests» where
root := `EvmYul.Yul.YulSemanticsTests.Main