forked from leanprover-community/mathlib3port
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lakefile.lean
58 lines (48 loc) · 2.28 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
import Lake
open Lake DSL System
-- Usually the `tag` will be of the form `nightly-2021-11-22`.
-- If you would like to use an artifact from a PR build,
-- it will be of the form `pr-branchname-sha`.
-- You can find the relevant SHA by inspecting the URL of the artifacts on the release page.
def tag : String := "nightly-2022-01-27"
def releaseRepo : String := "leanprover-community/mathport"
def oleanTarName : String := "mathlib3-binport.tar.gz"
def leanTarName : String := "mathlib3-synport.tar.gz"
def download (url : String) (to : FilePath) : BuildM PUnit := Lake.proc
{ -- We use `curl -O` to ensure we clobber any existing file.
cmd := "curl",
args := #["-L", "-O", url]
cwd := to }
def untar (file : FilePath) : BuildM PUnit := Lake.proc
{ cmd := "tar",
args := #["-xzvf", file.fileName.getD "."] -- really should throw an error if `file.fileName = none`
cwd := file.parent }
def getReleaseArtifact (repo tag artifact : String) (to : FilePath) : BuildM PUnit :=
download s!"https://github.com/{repo}/releases/download/{tag}/{artifact}" to
def untarReleaseArtifact (repo tag artifact : String) (to : FilePath) : BuildM PUnit := do
getReleaseArtifact repo tag artifact to
untar (to / artifact)
def fetchOleans (dir : FilePath) : OpaqueTarget := { info := (), task := fetch } where
fetch := async (m := BuildM) do
IO.FS.createDirAll libDir
let oldTrace := Hash.ofString (← Git.headRevision dir)
buildFileUnlessUpToDate (libDir / oleanTarName) oldTrace do
untarReleaseArtifact releaseRepo tag oleanTarName libDir
libDir : FilePath := dir / "build" / "lib"
def fetchLeans (dir : FilePath) : OpaqueTarget := { info := (), task := fetch } where
fetch := async (m := BuildM) do
IO.FS.createDirAll srcDir
let oldTrace := Hash.ofString (← Git.headRevision dir)
buildFileUnlessUpToDate (srcDir / leanTarName) oldTrace do
untarReleaseArtifact releaseRepo tag leanTarName srcDir
srcDir : FilePath := dir
package mathlib3port (dir) {
libRoots := #[]
libGlobs := #[`Mathbin]
extraDepTarget := Target.collectOpaqueList [fetchLeans dir, fetchOleans dir]
defaultFacet := PackageFacet.oleans
dependencies := #[{
name := "lean3port",
src := Source.git "https://github.com/leanprover-community/lean3port.git" "376835ea3c4dca48066838bcb1aad5c21995b261"
}]
}