feat: leanmake: auto-detect PKG

This commit is contained in:
Sebastian Ullrich 2020-06-13 14:11:49 +02:00
parent 43caef0130
commit 46065a9b3b
4 changed files with 12 additions and 5 deletions

View file

@ -1,9 +1,6 @@
In this example, we use the Lean C code generator to construct a simple program.
1- Generate `build/bin/test` program using `leanmake` (assuming `bin/` from e.g. the stage 0.5 build directory is in your `PATH`)
```
leanmake bin PKG=test
```
1- Generate `build/bin/test` program using `leanmake bin` (assuming `bin/` from e.g. the stage 0.5 build directory is in your `PATH`)
2- Execute test program
```

View file

@ -7,6 +7,7 @@
# * `leanmake PKG=Foo` # compile package Foo into .olean files (in `build/Foo`, by default)
# * `leanmake bin PKG=Foo` # build the binary `build/bin/Foo`
# * `leanmake lib PKG=Foo` # build the library `build/lib/libFoo.a`
# If there is exactly one .lean file in the current directory, you can omit `PKG`
set -euo pipefail

View file

@ -1,6 +1,15 @@
# Copyright (c) 2018 Simon Hudon. All rights reserved.
# Released under Apache 2.0 license as described in the file LICENSE.
# Authors: Simon Hudon, Sebastian Ullrich, Leonardo de Moura
# We compile all source files in $PKG/ as well as $PKG.lean. $PKG is also used for naming binary files.
ifndef PKG
PKG = $(strip $(subst .lean,, $(wildcard *.lean)))
ifneq ($(words $(PKG)), 1)
$(error no unique .lean file found in current directory, please specify PKG)
endif
endif
OUT = build
OLEAN_OUT = $(OUT)
TEMP_OUT = $(OUT)/temp

View file

@ -88,7 +88,7 @@ add_test(NAME leancomptest_foreign
COMMAND bash -c "${LEAN_BIN}/leanmake && ./build/bin/test")
add_test(NAME leancomptest_doc_example
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../doc/examples/compiler"
COMMAND bash -c "${LEAN_BIN}/leanmake bin PKG=test && ./build/bin/test hello world")
COMMAND bash -c "${LEAN_BIN}/leanmake bin && ./build/bin/test hello world")
# LEAN INTERPRETER TESTS
file(GLOB LEANINTERPTESTS "${LEAN_SOURCE_DIR}/../tests/compiler/*.lean")