forked from mit-plv/koika
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathruleGen.ml
More file actions
72 lines (62 loc) · 1.8 KB
/
Copy pathruleGen.ml
File metadata and controls
72 lines (62 loc) · 1.8 KB
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
(** Generate build rules for examples and tests *)
(* Does not currently copy support files from *.etc into output directory. This
is used for further Make-based execution of simulation and synthesis. *)
let generate_rules theory fn =
let base = Filename.remove_extension fn in
let tgt = (match fn with
"method_call.v" -> Printf.sprintf "%s.%s" base "o"
| "rv32i.v" -> Printf.sprintf "rv32.v"
| "rv32e.v" -> Printf.sprintf "rv32.v"
| _ -> Printf.sprintf "%s.%s" base "v") in
match Filename.extension fn with
".v" -> Printf.printf
{|(subdir %s.d
(rule
(action
(write-file %s_extr.v
"Require Coq.extraction.Extraction %s.%s.
Extraction \"%s.ml\" %s.prog.\n")))
(coq.extraction
(prelude %s_extr)
(extracted_modules %s)
(theories Ltac2 Koika %s)
(flags "-w" "-overriding-logical-loadpath"))
(rule
(target %s)
(alias runtest)
(deps (package koika) %s.ml)
(action (run cuttlec %%{deps} -T all -o .))))
|}
fn base theory base base base base base theory tgt base
| ".lv" -> (match Filename.extension base with
".1" -> Printf.printf
{|(subdir %s.d
(rule
(target %s.v)
(alias runtest)
(deps (package koika) ../%s)
(action
(progn
(ignore-stderr (run cuttlec %%{deps} -T all -o . --expect-errors))
(run touch %%{target})))))
|}
fn base fn
| _ -> Printf.printf
{|(subdir %s.d
(rule
(target %s.v)
(alias runtest)
(deps (package koika) ../%s)
(action
(progn
(run cuttlec %%{deps} -T all -o .)
(run touch %%{target})))))
|}
fn base fn)
| _ -> raise(Failure (Printf.sprintf "cannot generate rules for %s" fn))
let () =
let args = Sys.argv |> Array.to_list |> List.tl in
let theory = List.hd args in
let rules = generate_rules theory in
List.tl args |> List.sort String.compare
|> List.iter rules