test: add test of LLVM integration into lake
This commit is contained in:
parent
3b175fdb0e
commit
5980e665a8
8 changed files with 72 additions and 0 deletions
3
src/lake/tests/llvm-bitcode-gen/.gitignore
vendored
Normal file
3
src/lake/tests/llvm-bitcode-gen/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/build
|
||||
/lakefile.olean
|
||||
/lake-packages/*
|
||||
3
src/lake/tests/llvm-bitcode-gen/LlvmBitcodeGen.lean
Normal file
3
src/lake/tests/llvm-bitcode-gen/LlvmBitcodeGen.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- This module serves as the root of the `LlvmBitcodeGen` library.
|
||||
-- Import modules here that should be built as part of the library.
|
||||
import «LlvmBitcodeGen».Basic
|
||||
|
|
@ -0,0 +1 @@
|
|||
def hello := "world"
|
||||
7
src/lake/tests/llvm-bitcode-gen/Main.lean
Normal file
7
src/lake/tests/llvm-bitcode-gen/Main.lean
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import «LlvmBitcodeGen»
|
||||
import Lean
|
||||
open Lean
|
||||
|
||||
|
||||
def main : IO Unit :=
|
||||
IO.println s!"LLVM backend enabled: '{Lean.Internal.hasLLVMBackend ()}'"
|
||||
3
src/lake/tests/llvm-bitcode-gen/clean.sh
Executable file
3
src/lake/tests/llvm-bitcode-gen/clean.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
rm -rf build
|
||||
rm -rf lakefile.olean
|
||||
rm -rf lake-manifest.json
|
||||
4
src/lake/tests/llvm-bitcode-gen/lake-manifest.json
Normal file
4
src/lake/tests/llvm-bitcode-gen/lake-manifest.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{"version": 6,
|
||||
"packagesDir": "lake-packages",
|
||||
"packages": [],
|
||||
"name": "«llvm-bitcode-gen»"}
|
||||
24
src/lake/tests/llvm-bitcode-gen/lakefile.lean
Normal file
24
src/lake/tests/llvm-bitcode-gen/lakefile.lean
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import Lake
|
||||
import Lean
|
||||
open Lean
|
||||
open Lake DSL
|
||||
|
||||
package «llvm-bitcode-gen» where
|
||||
-- add package configuration options here
|
||||
backend := .llvm
|
||||
|
||||
lean_lib «LlvmBitcodeGen» where
|
||||
-- add library configuration options here
|
||||
|
||||
@[default_target]
|
||||
lean_exe «llvm-bitcode-gen» where
|
||||
root := `Main
|
||||
-- Enables the use of the Lean interpreter by the executable (e.g.,
|
||||
-- `runFrontend`) at the expense of increased binary size on Linux.
|
||||
-- Remove this line if you do not need such functionality.
|
||||
supportInterpreter := true
|
||||
|
||||
script hasLLVMBackend do
|
||||
IO.println s!"Lake Lean.Internal.hasLLVMBackend: {Lean.Internal.hasLLVMBackend ()}"
|
||||
return 0
|
||||
|
||||
27
src/lake/tests/llvm-bitcode-gen/test.sh
Executable file
27
src/lake/tests/llvm-bitcode-gen/test.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
|
||||
LAKE=${LAKE:-../../build/bin/lake}
|
||||
|
||||
./clean.sh
|
||||
|
||||
# Skip test if we don't have LLVM backend in the Lean toolchain
|
||||
if [[ ! $(lean --features) =~ LLVM ]]; then
|
||||
echo "Skipping test: 'lean' does not have LLVM backend enabled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
$LAKE update
|
||||
$LAKE build -v | grep "Main.bc.o" # check that we build using the bitcode object file.
|
||||
|
||||
# If we have the LLVM backend, check that the `lakefile.lean` is aware of this.
|
||||
lake script run llvm-bitcode-gen/hasLLVMBackend | grep "true"
|
||||
|
||||
# If we have the LLVM backend in the Lean toolchain, then we expect this to
|
||||
# print `true`, as this queries the same flag that Lake queries to check the presence
|
||||
# of the LLVM toolchian.
|
||||
./build/bin/llvm-bitcode-gen | grep 'true'
|
||||
|
||||
# If we have the LLVM backend, check that lake builds bitcode artefacts.
|
||||
test -f build/ir/LlvmBitcodeGen.bc
|
||||
test -f build/ir/Main.bc
|
||||
Loading…
Add table
Reference in a new issue