diff options
author | Son Ho | 2022-11-11 12:46:23 +0100 |
---|---|---|
committer | Son HO | 2022-11-11 15:26:17 +0100 |
commit | 0b4e739f6be83e0fe9337f6363343587b35c5752 (patch) | |
tree | 313127807b75d1733e8cb667525a46255a948b57 /Makefile | |
parent | 60803708ef34d480277e8e6e13ce87b54f534c19 (diff) |
Make the Nix build work
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 92 |
1 files changed, 63 insertions, 29 deletions
@@ -3,27 +3,51 @@ ifeq (3.81,$(MAKE_VERSION)) install make, then invoke gmake instead of make) endif -all: build-tests-verify +all: build -CHARON_HOME = ../charon -DEST_DIR = tests +#################################### +# Variables customizable by the user +#################################### -# We use those variables, whose definition depends on the rule we apply -CHARON_TESTS_DIR = -CHARON_OPTIONS = -CHARON_TESTS_SRC = +# Set this variable to any value to call Charon to regenerate the .llbc source +# files before running the tests +REGEN_LLBC ?= + +# The path to Charon +CHARON_HOME ?= ../charon + +# The paths to the test directories in Charon (Aeneas will look for the .llbc +# files in there). +CHARON_TESTS_REGULAR_DIR ?= $(CHARON_HOME)/tests +CHARON_TESTS_POLONIUS_DIR ?= $(CHARON_HOME)/tests-polonius AENEAS_DRIVER = driver.exe -# The user can specify additional translation options for Aeneas: -OPTIONS += -unfold-monads +# The path to the Aeneas executable to run the tests - we need the ability to +# change this path for the Nix package. +AENEAS_EXE ?= compiler/_build/default/$(AENEAS_DRIVER) -# Default translation options: +# The user can specify additional translation options for Aeneas. +# By default we do: +# - unfold all the monadic let bindings to matches (required by F*) # - insert calls to the normalizer in the translated code to test the # generated unit functions -TRANS_OPTIONS := -test-trans-units $(OPTIONS) +OPTIONS += -unfold-monads -test-trans-units + +# +# The rules use (and update) the following variables +# +# The Charon test directory where to look for the .llbc files +CHARON_TEST_DIR = +# The options with which to call Charon +CHARON_OPTIONS = +# The directory in which to extract the result of the translation SUBDIR := +#################################### +# The rules +#################################### + # Build the project, test it and verify the generated files .PHONY: build-test-verify build-tests-verify: build tests verify @@ -50,7 +74,7 @@ clean: # Test the project by translating test files to F* .PHONY: tests -tests: build trans-no_nested_borrows trans-paper \ +tests: trans-no_nested_borrows trans-paper \ trans-hashmap trans-hashmap_main \ trans-external trans-constants \ trans-polonius-betree_polonius trans-polonius-betree_main \ @@ -67,41 +91,45 @@ format: cd compiler && dune promote # The commands to run Charon to generate the .llbc files -CHARON_CMD = cd $(CHARON_HOME)/$(CHARON_TEST_SUBFOLDER) && NOT_ALL_TESTS=1 $(MAKE) test-$* +ifeq (, $(REGEN_LLBC)) +else +CHARON_CMD = cd $(CHARON_TEST_DIR) && NOT_ALL_TESTS=1 $(MAKE) test-$* +endif # The command to run Aeneas on the proper llbc file -AENEAS_CMD = cd compiler && dune exec -- ./$(AENEAS_DRIVER) ../$(CHARON_TESTS_DIR)/$(FILE).llbc -dest ../$(DEST_DIR)/$(SUBDIR) $(TRANS_OPTIONS) +AENEAS_CMD = $(AENEAS_EXE) $(CHARON_TEST_DIR)/llbc/$(FILE).llbc -dest ../tests/$(SUBDIR) $(OPTIONS) + # Add specific options to some tests trans-no_nested_borrows trans-paper: \ - TRANS_OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses + OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses trans-no_nested_borrows trans-paper: SUBDIR:=misc -trans-hashmap: TRANS_OPTIONS += -template-clauses -no-state +trans-hashmap: OPTIONS += -template-clauses -no-state trans-hashmap: SUBDIR:=hashmap -trans-hashmap_main: TRANS_OPTIONS += -template-clauses +trans-hashmap_main: OPTIONS += -template-clauses trans-hashmap_main: SUBDIR:=hashmap_on_disk -trans-polonius-betree_polonius: TRANS_OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses +trans-polonius-betree_polonius: OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses trans-polonius-betree_polonius: SUBDIR:=misc -trans-constants: TRANS_OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses +trans-constants: OPTIONS += -test-units -test-trans-units -no-split-files -no-state -no-decreases-clauses trans-constants: SUBDIR:=misc -trans-external: TRANS_OPTIONS += +trans-external: OPTIONS += trans-external: SUBDIR:=misc BETREE_OPTIONS = -template-clauses -trans-polonius-betree_main: TRANS_OPTIONS += $(BETREE_OPTIONS) -backward-no-state-update +trans-polonius-betree_main: OPTIONS += $(BETREE_OPTIONS) -backward-no-state-update trans-polonius-betree_main: SUBDIR:=betree # Additional test on the betree: translate it without `-backward-no-state-update`. # This generates very ugly code, but is good to test the translation. test-trans-polonius-betree_main: trans-polonius-betree_main -test-trans-polonius-betree_main: TRANS_OPTIONS += $(BETREE_OPTIONS) +test-trans-polonius-betree_main: OPTIONS += $(BETREE_OPTIONS) test-trans-polonius-betree_main: SUBDIR:=betree_back_stateful -test-trans-polonius-betree_main: CHARON_TESTS_DIR = $(CHARON_HOME)/tests-polonius/llbc +test-trans-polonius-betree_main: CHARON_TEST_DIR = $(CHARON_TESTS_POLONIUS_DIR) test-trans-polonius-betree_main: FILE = betree_main test-trans-polonius-betree_main: $(AENEAS_CMD) @@ -110,21 +138,22 @@ test-trans-polonius-betree_main: # We use the rules in Charon's Makefile to generate the .llbc files: the options # vary with the test files. .PHONY: gen-llbc-polonius-% -gen-llbc-polonius-%: CHARON_TEST_SUBFOLDER = tests-polonius -gen-llbc-polonius-%: build +gen-llbc-polonius-%: CHARON_TEST_DIR = $(CHARON_TESTS_POLONIUS_DIR) +gen-llbc-polonius-%: $(CHARON_CMD) .PHONY: gen-llbc-% -gen-llbc-%: CHARON_TEST_SUBFOLDER = tests -gen-llbc-%: build +gen-llbc-%: CHARON_TEST_DIR = $(CHARON_TESTS_REGULAR_DIR) +gen-llbc-%: $(CHARON_CMD) # Generic rule to test the translation of an LLBC file. # Note that the files requiring the Polonius borrow-checker are generated # in the tests-polonius subdirectory. .PHONY: trans-% -trans-%: CHARON_TESTS_DIR = $(CHARON_HOME)/tests/llbc -trans-polonius-%: CHARON_TESTS_DIR = $(CHARON_HOME)/tests-polonius/llbc +trans-%: +trans-polonius-%: CHARON_TEST_DIR = $(CHARON_TESTS_POLONIUS_DIR) +trans-%: CHARON_TEST_DIR = $(CHARON_TESTS_REGULAR_DIR) trans-polonius-%: FILE = $* trans-polonius-%: gen-llbc-polonius-% @@ -133,3 +162,8 @@ trans-polonius-%: gen-llbc-polonius-% trans-%: FILE = $* trans-%: gen-llbc-% $(AENEAS_CMD) + +# Nix +.PHONY: nix +nix: + nix build .#checks.x86_64-linux.aeneas-tests --show-trace -L |