Skip to content

Commit e33cae9

Browse files
committed
Run some pre-commit
- fix end of files - trim trailing whitespace
1 parent 676ff4f commit e33cae9

File tree

15 files changed

+16
-20
lines changed

15 files changed

+16
-20
lines changed

.devcontainer/devcontainer.bak.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
"remoteEnv": {
1515
"PATH" : "${containerEnv:PATH}:/home/vscode/.elan/bin:/home/vscode/.local/bin"
1616
}
17-
}
17+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
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.
44

5-
See [this doc](doc/ffi.md) to learn more.
5+
See [this doc](doc/ffi.md) to learn more.

codegen/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
libclang==16.0.6
22
Jinja2==3.1.2
3-
PyYAML==6.0
3+
PyYAML==6.0

codegen/templates/cpp/class.cpp.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ extern "C" LEAN_EXPORT lean_obj_res {{namespace}}_{{type.lean}}_{{method.lean}}(
2525
}
2626
{% endif %}
2727
{% endfor %}
28-
{% endblock %}
28+
{% endblock %}

codegen/templates/helper.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ _ret_{{name|replace('::', '_')}}
3737
{% for param in params %}
3838
{{ sep() }}({{param.name}} : {{param.type.lean}})
3939
{%- endfor %}
40-
{%- endmacro %}
40+
{%- endmacro %}

codegen/templates/lean/base.lean.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ namespace {{namespace}}
66

77
{% block content %}{% endblock %}
88

9-
end {{namespace}}
9+
end {{namespace}}

codegen/templates/lean/class.lean.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ instance : Nonempty ({{type.lean}}) := ({{type.lean}}Pointed).property
1616
opaque {{type.lean}}.{{method.lean}} {{list_sig_params_lean(method.params)}} : {{method.return_type.lean}}
1717

1818
{% endfor %}
19-
{% endblock %}
19+
{% endblock %}

cpp/CppClass.h

-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ lean_object * cppClass_make_exclusive(lean_object * o) {
4343
return of_cppClass(t_unique);
4444
}
4545
}
46-

cpp/GinacFFI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" uint32_t my_add(uint32_t a, uint32_t b) {
1212
extern "C" lean_obj_res my_lean_fun() {
1313
symbol x("x"), y("y"), z("z");
1414
ex MyEx1 = sin(x + 2*y) + 3*z + 41;
15-
ex MyEx2 = MyEx1 + 1;
15+
ex MyEx2 = MyEx1 + 1;
1616

1717
cout << MyEx2 << endl;
1818

cpp/Symbol.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ extern "C" LEAN_EXPORT lean_obj_res Ginac_Symbol_name(b_lean_obj_arg _sym) {
1313
auto sym = to_cppClass<symbol>(_sym);
1414
return lean_mk_string(sym->get_name().c_str());
1515
}
16-

dev/prep.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ sudo apt install -y curl wget git git-lfs clang lld libc++-dev
55
sudo apt install -y libunwind-dev || true
66

77
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | bash -s -- -y
8-
source ~/.profile
8+
source ~/.profile

dev/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
sudo docker exec -it -u vscode -w /workspaces/ginac-lean ginac-lean bash
33

44
# First time: run this in the container
5-
# source dev/prep.sh
5+
# source dev/prep.sh

doc/ffi.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ In Lean 4 unit tests, there's [a minimal FFI to C++ example](https://github.com/
2424

2525
What EigenLean didn't explore, is to work with a non-header-only C++ library, which is the case for GiNaC, as well as many other C++ libraries. One particularly common case is that you have some C++ header and a pre-compiled shared library, whether it's due to the unavailability of the source code, or the difficulties to compile and link, including long compilation time. Its lakefiles is thus very simple and applicable only to libraries with less complications from its source code or binary distribution.
2626

27-
This is mostly covered by [LeanInfer](https://github.com/lean-dojo/LeanInfer), which does a great job to make binary-only runtime to work with Lean, integreated with the Lake's [cloud build releases](https://github.com/leanprover/lean4/tree/master/src/lake#cloud-releases) to bundle binaries like pre-compiled linker-happy shared libraries for supported platforms.
27+
This is mostly covered by [LeanInfer](https://github.com/lean-dojo/LeanInfer), which does a great job to make binary-only runtime to work with Lean, integreated with the Lake's [cloud build releases](https://github.com/leanprover/lean4/tree/master/src/lake#cloud-releases) to bundle binaries like pre-compiled linker-happy shared libraries for supported platforms.
2828

2929
Some limitations of LeanInfer's solution: At the time of writing, it relies on local builds by the authors, including building LLVM, Clang and its standard library `libc++` from source, no CI has been set up to run this continuously to make it applicable for other projects. It also requires to build the C++ part with `clang++` and its standard library `libc++` on all platforms, which could be chanllenaging for FFI binding developers who are not familiar with C++ toolchains, also some libraries requires heavy patching to compile and link with `libc++` instead of the more widely available `libstdc++` from GNU.
3030

@@ -89,5 +89,3 @@ Some possible future explorations:
8989
- the binding generating capability can become a spin-off project, which can be reused in other Lean 4 binding projects
9090
- explore creating bindings to Rust libraries(e.g. [egglog](https://github.com/egraphs-good/egglog/)) and making them idiomatic in Lean, like [egglog's Python binding](https://egg-smol-python.readthedocs.io/en/latest/)
9191
- explore reverse-FFI, i.e. calling Lean functions from C++/Rust code, even from JavaScript in the browser provided [Lean 4 WASM build makes progress](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/wasm.20build)
92-
93-

lakefile.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package «GinacLean» where
77
-- preferReleaseBuild := get_config? noCloudRelease |>.isNone
88
buildType := BuildType.debug
99
-- buildArchive? := is_arm? |>.map (if · then "arm64" else "x86_64")
10-
moreLinkArgs := #[s!"-L{__dir__}/build/lib",
10+
moreLinkArgs := #[s!"-L{__dir__}/build/lib",
1111
-- "-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",
1212
"-lginac_ffi", "-lginac", "-lcln", "-lstdc++"] -- "-v", --, "-lc++", "-lc++abi", "-lunwind"] -- "-lstdc++"]
1313
weakLeanArgs := #[
@@ -18,7 +18,7 @@ package «GinacLean» where
1818
lean_lib «GinacLean» where
1919
roots := #[`Ginac]
2020
moreLinkArgs := #[s!"-L{__dir__}/build/lib",
21-
"-lginac_ffi",
21+
"-lginac_ffi",
2222
"-lstdc++"]
2323
extraDepTargets := #["libginac_ffi"]
2424

@@ -173,7 +173,7 @@ target libginac_ffi pkg : FilePath := do
173173
]
174174

175175
let mut buildJobs : Array (BuildJob FilePath) := Array.mkEmpty srcFiles.size
176-
176+
177177
for srcFile in srcFiles do
178178
let job ← buildCpp pkg srcFile [ginac, cln]
179179
buildJobs := buildJobs.push job
@@ -214,4 +214,4 @@ script clear := do
214214
removeDirIfExists s!"{__dir__}/build/ir/"
215215
removeDirIfExists s!"{__dir__}/build/lib/examples"
216216
removeDirIfExists s!"{__dir__}/build/lib/Ginac"
217-
return 0
217+
return 0

lean/Ginac/Symbol.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ opaque Symbol.mk (name : @&String) : Symbol
1010
@[extern "Ginac_Symbol_name"]
1111
opaque Symbol.name : Symbol → String
1212

13-
end Ginac
13+
end Ginac

0 commit comments

Comments
 (0)