lean4-htt/tests/compiler/foreign
David Thrane Christiansen 8fef03d1cc
feat: support Lake for building Lean core oleans (#3886)
This is from a ~~pair~~triple programming session with @tydeu and
@mhuisi.

If stage 1 is built with `-DUSE_LAKE=ON`, the CMake run will generate
`lakefile.toml` files for the root, `src`, and `tests`. These Lake
configuration files can then be used to build core oleans. While they do
not yet allow Lake to be used to build the Lean binaries. they do allow
Lake to be used for working interactively with the Lean source. In our
preliminary experiments, this allowed updates to `Init.Data.Nat` to be
noticed automatically when reloading downstream files, rather than
requiring a full manual compiler rebuild. This will make it easier to
work on the system.

As part of this change, Lake is added to stage 0. This allows Lake to
function in `src`, which uses the stage 0 toolchain.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-06-13 16:18:24 +00:00
..
Main chore: fix tests 2022-06-14 17:27:13 -07:00
.gitignore feat: support Lake for building Lean core oleans (#3886) 2024-06-13 16:18:24 +00:00
Main.lean test: --load-dynlib 2021-11-04 15:32:07 -07:00
Makefile fix: split libInit_shared out of libleanshared (#3421) 2024-02-22 19:16:32 +00:00
myfuns.cpp test: fix foreign function signatures 2022-07-29 14:10:15 +02:00
README.md test: --load-dynlib 2021-11-04 15:32:07 -07:00

Small project implemented using Lean and C++. The C++ file myfuns.cpp wraps a C++ object using an lean_external_object. The file myfuns.cpp exposes pure and effectful primitives. The file Main.lean contains a small Lean program that uses the exported primitives.

Build instructions

Assuming the Lean bin/ directory (e.g. from build/release/stage1) is in your PATH, executing leanmake build/bin/test will create the executable build/bin/test; see the Makefile for further variants.

The executable build/bin/test should produce the output

30
hello
foobla
world