-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
146 lines (111 loc) · 4.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Settings
# --------
build_dir:=.build
defn_dir:=$(build_dir)/defn
k_submodule:=$(build_dir)/k
k_bin:=$(k_submodule)/k-distribution/target/release/k/bin
kompile:=$(k_bin)/kompile
krun:=$(k_bin)/krun
pandoc_tangle_submodule:=$(build_dir)/pandoc-tangle
tangler:=$(pandoc_tangle_submodule)/tangle.lua
LUA_PATH:=$(pandoc_tangle_submodule)/?.lua;;
export LUA_PATH
pandoc:=pandoc --from markdown --to markdown --lua-filter "$(tangler)"
test_dir:=tests
test_output:=.build/logs
.PHONY: deps deps-k deps-ocaml deps-tangle \
defn defn-imp defn-imp-kcompile defn-imp-krun defn-fun defn-fun-krun defn-fun-kcompile \
build build-imp build-imp-kcompile build-imp-krun build-fun build-fun-krun build-fun-kcompile \
test test-imp test-fun
all: build
clean:
rm -rf $(build_dir)
# Dependencies
# ------------
deps: deps-k deps-ocaml deps-tangle
deps-k: $(k_submodule)/make.timestamp
deps-tangle: $(pandoc_tangle_submodule)/make.timestamp
$(k_submodule)/make.timestamp:
git submodule update --init -- $(k_submodule)
cd $(k_submodule) \
&& mvn package -q -DskipTests
touch $(k_submodule)/make.timestamp
$(pandoc_tangle_submodule)/make.timestamp:
git submodule update --init -- $(pandoc_tangle_submodule)
touch $(pandoc_tangle_submodule)/make.timestamp
deps-ocaml:
opam init --quiet --no-setup
opam repository add k "$(k_submodule)/k-distribution/target/release/k/lib/opam" \
|| opam repository set-url k "$(k_submodule)/k-distribution/target/release/k/lib/opam"
opam update
opam switch 4.06.1+k
eval $$(opam config env) \
opam install --yes mlgmp zarith uuidm ocaml-protoc rlp yojson hex ocp-ocamlres
# Build definition
# ----------------
imp_dir=$(defn_dir)/imp
imp_kcompile_files:=$(patsubst %, $(imp_dir)/kcompile/%, kat-imp.k kat.k imp.k)
imp_krun_files:=$(patsubst %, $(imp_dir)/krun/%, imp.k)
fun_dir=$(defn_dir)/fun
fun_kcompile_files:=$(patsubst %, $(fun_dir)/kcompile/%, kat-fun.k kat.k fun.k)
fun_krun_files:=$(patsubst %, $(fun_dir)/krun/%, fun.k)
defn: defn-imp defn-fun
defn-imp: defn-imp-kcompile defn-imp-krun
defn-imp-kcompile: $(imp_kcompile_files)
defn-imp-krun: $(imp_krun_files)
$(imp_dir)/kcompile/%.k: %.md
@echo >&2 "== tangle: $@"
mkdir -p $(dir $@)
$(pandoc) --metadata=code:'.k,.kcompile' $< > $@
$(imp_dir)/krun/%.k: %.md
@echo >&2 "== tangle: $@"
mkdir -p $(dir $@)
$(pandoc) --metadata=code:'.k,.krun' $< > $@
defn-fun: defn-fun-kcompile defn-fun-krun
defn-fun-kcompile: $(fun_kcompile_files)
defn-fun-krun: $(fun_krun_files)
$(fun_dir)/kcompile/%.k: %.md
@echo >&2 "== tangle: $@"
mkdir -p $(dir $@)
$(pandoc) --metadata=code:'.k,.kcompile' $< > $@
$(fun_dir)/krun/%.k: %.md
@echo >&2 "== tangle: $@"
mkdir -p $(dir $@)
$(pandoc) --metadata=code:'.k,.krun' $< > $@
# Backends (for running and compiling)
build: build-imp build-fun
build-imp: build-imp-kcompile build-imp-krun
build-imp-kcompile: $(imp_dir)/kcompile/kat-imp-kompiled/timestamp
build-imp-krun: $(imp_dir)/krun/imp-kompiled/interpreter
$(imp_dir)/kcompile/kat-imp-kompiled/timestamp: $(imp_kcompile_files)
@echo "== kompile: $@"
$(kompile) --main-module IMP-ANALYSIS --backend java \
--syntax-module IMP-ANALYSIS $< --directory $(imp_dir)/kcompile
$(imp_dir)/krun/imp-kompiled/interpreter: $(imp_krun_files)
@echo "== kompile: $@"
eval $$(opam config env) \
$(kompile) --main-module IMP --backend ocaml \
--syntax-module IMP $< --directory $(imp_dir)/krun
build-fun: build-fun-kcompile build-fun-krun
build-fun-kcompile: $(fun_dir)/kcompile/kat-fun-kompiled/timestamp
build-fun-krun: $(fun_dir)/krun/fun-kompiled/interpreter
$(fun_dir)/kcompile/kat-fun-kompiled/timestamp: $(fun_kcompile_files)
@echo "== kompile: $@"
eval $$(opam config env) \
$(kompile) --main-module FUN-ANALYSIS --backend java \
--syntax-module FUN-UNTYPED-SYNTAX $< --directory $(fun_dir)/kcompile
$(fun_dir)/krun/fun-kompiled/interpreter: $(fun_krun_files)
@echo "== kompile: $@"
eval $$(opam config env) \
$(kompile) --main-module FUN-UNTYPED --backend ocaml \
--syntax-module FUN-UNTYPED-SYNTAX $< --directory $(fun_dir)/krun
# Testing
# -------
test_imp_files:=$(wildcard $(test_dir)/imp/*.strat)
test_fun_files:=$(wildcard $(test_dir)/fun/*.strat)
TEST=./kat test
test: test-imp test-fun
test-imp: $(test_imp_files:=.test)
test-fun: $(test_fun_files:=.test)
%.strat.test:
$(TEST) $*