Skip to content

Commit 8eee877

Browse files
committed
Bump to leanprover/lean4:v4.8.0
1 parent ad8b1dc commit 8eee877

8 files changed

+58
-41
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build/
66
**/*.pyc
77
codegen/tests/fixtures/all_methods.txt
88
lakefile.olean
9+
.lake/

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,17 @@
55
A work-in-progress Lean 4 binding to [GiNaC](https://www.ginac.de/), which is an open-source symbolic computation library in C++, it has extensive algebraic capabilities, and has been specifically developed to be an engine for high energy physics applications.
66

77
See [this doc](doc/ffi.md) to learn more.
8+
9+
10+
## Development
11+
12+
```bash
13+
bash ./scripts/build_ginac.sh
14+
bash ./scripts/check_ginac.sh
15+
lake -R build
16+
# Follow https://pre-commit.com/ to install pre-commit
17+
# pyenv shell 3.11
18+
# brew install pre-commit
19+
# pre-commit install
20+
21+
```

lake-manifest.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{"version": 7,
2+
"packagesDir": ".lake/packages",
3+
"packages": [],
4+
"name": "GinacLean",
5+
"lakeDir": ".lake"}

lakefile.lean

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ package «GinacLean» where
88
-- preferReleaseBuild := get_config? noCloudRelease |>.isNone
99
buildType := BuildType.debug
1010
-- buildArchive? := is_arm? |>.map (if · then "arm64" else "x86_64")
11-
moreLinkArgs := #[s!"-L{__dir__}/build/lib",
11+
moreLinkArgs := #[s!"-L{__dir__}/.lake/build/lib",
1212
-- "-L/usr/bin/../lib/gcc/aarch64-linux-gnu/11 -L/lib/aarch64-linux-gnu -L/usr/lib/aarch64-linux-gnu -L/usr/lib/llvm-14/bin/../lib -L/lib -L/usr/lib",
1313
"-lginac_ffi", "-lginac", "-lcln", "-lstdc++"] -- "-v", --, "-lc++", "-lc++abi", "-lunwind"] -- "-lstdc++"]
1414
weakLeanArgs := #[
15-
s!"--load-dynlib={__dir__}/build/lib/" ++ nameToSharedLib "cln",
16-
s!"--load-dynlib={__dir__}/build/lib/" ++ nameToSharedLib "ginac"
15+
s!"--load-dynlib={__dir__}/.lake/build/lib/" ++ nameToSharedLib "cln",
16+
s!"--load-dynlib={__dir__}/.lake/build/lib/" ++ nameToSharedLib "ginac"
1717
]
1818

1919
lean_lib «GinacLean» where
2020
roots := #[`Ginac]
21-
moreLinkArgs := #[s!"-L{__dir__}/build/lib",
21+
moreLinkArgs := #[s!"-L{__dir__}/.lake/build/lib",
2222
"-lginac_ffi",
2323
"-lstdc++"]
24-
extraDepTargets := #["libginac_ffi"]
24+
extraDepTargets := #[`libginac_ffi]
2525

2626
@[default_target]
2727
lean_exe «ginac_hello» where
@@ -51,22 +51,22 @@ def getLibPath (name : String) : IO (Option FilePath) := do
5151
return none
5252

5353

54-
def afterReleaseSync (pkg : Package) (build : SchedulerM (Job α)) : IndexBuildM (Job α) := do
54+
def afterReleaseSync (pkg : Package) (build : SpawnM (Job α)) : FetchM (Job α) := do
5555
if pkg.preferReleaseBuild ∧ pkg.name ≠ (← getRootPackage).name then
5656
(← pkg.release.fetch).bindAsync fun _ _ => build
5757
else
5858
build
5959

6060

61-
def afterReleaseAsync (pkg : Package) (build : BuildM α) : IndexBuildM (Job α) := do
61+
def afterReleaseAsync (pkg : Package) (build : JobM α) : FetchM (Job α) := do
6262
if pkg.preferReleaseBuild ∧ pkg.name ≠ (← getRootPackage).name then
6363
(← pkg.release.fetch).bindSync fun _ _ => build
6464
else
6565
Job.async build
6666

6767
-- #eval ("a.b.c".splitOn ".")[0]
6868

69-
def copyLibJob (pkg : Package) (libName : String) : IndexBuildM (BuildJob FilePath) :=
69+
def copyLibJob (pkg : Package) (libName : String) : FetchM (BuildJob FilePath) :=
7070
afterReleaseAsync pkg do
7171
if !Platform.isOSX then -- Only required for Linux
7272
let dst := pkg.nativeLibDir / libName
@@ -80,7 +80,7 @@ def copyLibJob (pkg : Package) (libName : String) : IndexBuildM (BuildJob FilePa
8080
-- }
8181
-- let src := srcLeanBundled
8282
let some src ← getLibPath libName | error s!"{libName} not found"
83-
logStep s!"Copying from {src} to {dst}"
83+
logVerbose s!"Copying from {src} to {dst}"
8484
proc {
8585
cmd := "cp"
8686
args := #[src.toString, dst.toString]
@@ -139,7 +139,7 @@ target libginac pkg : FilePath := do
139139
-- TODO figure out how to trigger the build from lake
140140
return (dst, trace)
141141

142-
def buildCpp (pkg : Package) (path : FilePath) (deps : List (BuildJob FilePath)) : SchedulerM (BuildJob FilePath) := do
142+
def buildCpp (pkg : Package) (path : FilePath) (deps : List (BuildJob FilePath)) : Lake.SpawnM (BuildJob FilePath) := do
143143
let oFile := pkg.buildDir / "cpp" / (path.withExtension "o").fileName.get!
144144
let srcJob ← inputFile <| path
145145
let optLevel := if pkg.buildType == .release then "-O3" else "-O0"
@@ -153,7 +153,7 @@ def buildCpp (pkg : Package) (path : FilePath) (deps : List (BuildJob FilePath))
153153
| some arch => flags := flags.push s!"--target={arch}"
154154
let args := flags ++ #["-I", (← getLeanIncludeDir).toString, "-I", (pkg.buildDir / "include").toString]
155155
buildFileAfterDepList oFile (srcJob :: deps) (extraDepTrace := computeHash flags) fun deps =>
156-
compileO path.toString oFile deps[0]! args clangxx
156+
compileO oFile deps[0]! args clangxx
157157

158158
target libginac_ffi pkg : FilePath := do
159159
-- TODO figure out why these are required for linking, otherwise
@@ -200,7 +200,7 @@ def removeDirIfExists (path : String) : IO Unit := do
200200

201201
script clear := do
202202
println! "Clearing all products of `lake build`, but keep built C++ libraries"
203-
let libDir := FilePath.mk s!"{__dir__}/build/lib/"
203+
let libDir := FilePath.mk s!"{__dir__}/.lake/build/lib/"
204204
let paths := <-libDir.walkDir -- fun path => do
205205
-- return !(<-path.isDir)
206206

@@ -211,8 +211,8 @@ script clear := do
211211
println! s!"Removing {path.toString}"
212212
IO.FS.removeFile path.toString
213213

214-
removeDirIfExists s!"{__dir__}/build/cpp/"
215-
removeDirIfExists s!"{__dir__}/build/ir/"
216-
removeDirIfExists s!"{__dir__}/build/lib/examples"
217-
removeDirIfExists s!"{__dir__}/build/lib/Ginac"
214+
removeDirIfExists s!"{__dir__}/.lake/build/cpp/"
215+
removeDirIfExists s!"{__dir__}/.lake/build/ir/"
216+
removeDirIfExists s!"{__dir__}/.lake/build/lib/examples"
217+
removeDirIfExists s!"{__dir__}/.lake/build/lib/Ginac"
218218
return 0

lean-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.2.0-rc3
1+
leanprover/lean4:v4.8.0

scripts/build_ginac.sh

+3-13
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
set -e
44
set -o pipefail
55

6-
SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
7-
# echo "SCRIPTS_DIR=$SCRIPTS_DIR"
8-
WORKSPACES="$SCRIPTS_DIR/../build"
9-
mkdir -p $WORKSPACES/
10-
WORKSPACES=$(cd $WORKSPACES && pwd)
11-
# echo "WORKSPACES=$WORKSPACES"
12-
INSTALLED_DIR=$WORKSPACES
13-
mkdir -p $INSTALLED_DIR/
14-
# echo "INSTALLED_DIR=$INSTALLED_DIR"
6+
source $(dirname "$0")/config.sh
157

168
show_warning()
179
{
@@ -59,8 +51,6 @@ download()
5951
mkdir -p $WORKSPACES
6052
cd $WORKSPACES
6153

62-
LIBCLN=cln-1.3.6
63-
6454
download https://www.ginac.de/CLN/$LIBCLN.tar.bz2
6555

6656
export CC="clang"
@@ -91,9 +81,9 @@ make install
9181

9282
cd $WORKSPACES
9383

94-
download https://www.ginac.de/ginac-1.8.7.tar.bz2
84+
download https://www.ginac.de/$LIBGINAC.tar.bz2
9585

96-
cd ginac-1.8.7
86+
cd $LIBGINAC
9787

9888
export CLN_CFLAGS="-I$INSTALLED_DIR/include"
9989
export CLN_LIBS="-L$INSTALLED_DIR/lib -lcln"

scripts/check_ginac.sh

+3-11
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,11 @@
33
set -e
44
set -o pipefail
55

6-
SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
7-
# echo "SCRIPTS_DIR=$SCRIPTS_DIR"
8-
WORKSPACES="$SCRIPTS_DIR/../build"
9-
mkdir -p $WORKSPACES/
10-
WORKSPACES=$(cd $WORKSPACES && pwd)
11-
# echo "WORKSPACES=$WORKSPACES"
12-
INSTALLED_DIR=$WORKSPACES
13-
mkdir -p $INSTALLED_DIR/
14-
# echo "INSTALLED_DIR=$INSTALLED_DIR"
6+
source $(dirname "$0")/config.sh
157

168
mkdir -p $WORKSPACES
179
cd $WORKSPACES
1810

19-
LIBCLN=cln-1.3.6
20-
2111
export CC="clang"
2212
export CXX="clang++"
2313

@@ -34,4 +24,6 @@ export CLN_LIBS="-L$INSTALLED_DIR/lib -lcln"
3424

3525
export CPPFLAGS=""
3626

27+
export PATH="$WORKSPACES/bin:$PATH"
28+
3729
make check -j4

scripts/config.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set -e
2+
set -o pipefail
3+
4+
SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
5+
# echo "SCRIPTS_DIR=$SCRIPTS_DIR"
6+
WORKSPACES="$SCRIPTS_DIR/../.lake/build"
7+
mkdir -p $WORKSPACES/
8+
WORKSPACES=$(cd $WORKSPACES && pwd)
9+
# echo "WORKSPACES=$WORKSPACES"
10+
INSTALLED_DIR=$WORKSPACES
11+
mkdir -p $INSTALLED_DIR/
12+
# echo "INSTALLED_DIR=$INSTALLED_DIR"
13+
14+
export LIBCLN=cln-1.3.7
15+
export LIBGINAC=ginac-1.8.7

0 commit comments

Comments
 (0)