1
|
(********************************************************************)
|
2
|
(* *)
|
3
|
(* The LustreC compiler toolset / The LustreC Development Team *)
|
4
|
(* Copyright 2012 - -- ONERA - CNRS - INPT *)
|
5
|
(* *)
|
6
|
(* LustreC is free software, distributed WITHOUT ANY WARRANTY *)
|
7
|
(* under the terms of the GNU Lesser General Public License *)
|
8
|
(* version 2.1. *)
|
9
|
(* *)
|
10
|
(********************************************************************)
|
11
|
|
12
|
let version = Version.number
|
13
|
let codename = Version.codename
|
14
|
let include_dir = ref "."
|
15
|
let include_path =
|
16
|
if (!include_dir != ".") then Version.prefix ^ !include_dir
|
17
|
else Version.include_path
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
let print_version () =
|
23
|
Format.printf "Lustrec compiler, version %s (%s)@." version codename;
|
24
|
Format.printf "Include directory: %s@." include_path;
|
25
|
Format.printf "User selected include directory: %s@." !include_dir
|
26
|
|
27
|
let main_node = ref ""
|
28
|
let static_mem = ref true
|
29
|
let print_types = ref true
|
30
|
let print_clocks = ref true
|
31
|
let delay_calculus = ref true
|
32
|
let track_exceptions = ref true
|
33
|
let ansi = ref false
|
34
|
let check = ref false
|
35
|
let spec = ref "acsl"
|
36
|
let output = ref "C"
|
37
|
let dest_dir = ref "."
|
38
|
let verbose_level = ref 1
|
39
|
let global_inline = ref false
|
40
|
let witnesses = ref false
|
41
|
let optimization = ref 2
|
42
|
let lusi = ref false
|
43
|
let print_reuse = ref false
|
44
|
let const_unfold = ref false
|
45
|
let mpfr = ref false
|
46
|
let mpfr_prec = ref 0
|
47
|
|
48
|
let traces = ref false
|
49
|
let horn_cex = ref false
|
50
|
let horn_query = ref true
|
51
|
|
52
|
let cpp = ref false
|
53
|
let int_type = ref "int"
|
54
|
let real_type = ref "double"
|
55
|
let print_prec_double = ref 15
|
56
|
let print_prec_float = ref 10
|
57
|
|
58
|
let sfunction = ref ""
|
59
|
|
60
|
let mauve = ref ""
|
61
|
(* test generation options *)
|
62
|
let nb_mutants = ref 1000
|
63
|
let gen_mcdc = ref false
|
64
|
let no_mutation_suffix = ref false
|
65
|
|
66
|
|
67
|
|
68
|
|
69
|
let set_mpfr prec =
|
70
|
if prec > 0 then (
|
71
|
mpfr := true;
|
72
|
mpfr_prec := prec;
|
73
|
(* salsa_enabled := false; (* We deactivate salsa *) TODO *)
|
74
|
)
|
75
|
else
|
76
|
failwith "mpfr requires a positive integer"
|
77
|
|
78
|
let common_options =
|
79
|
[ "-d", Arg.Set_string dest_dir, "uses the specified \x1b[4mdirectory\x1b[0m as root for generated/imported object and C files <default: .>";
|
80
|
"-I", Arg.Set_string include_dir, "sets include \x1b[4mdirectory\x1b[0m";
|
81
|
"-node", Arg.Set_string main_node, "specifies the \x1b[4mmain\x1b[0m node";
|
82
|
"-print-types", Arg.Set print_types, "prints node types";
|
83
|
"-print-clocks", Arg.Set print_clocks, "prints node clocks";
|
84
|
"-verbose", Arg.Set_int verbose_level, "changes verbose \x1b[4mlevel\x1b[0m <default: 1>";
|
85
|
"-version", Arg.Unit print_version, " displays the version";
|
86
|
]
|
87
|
|
88
|
let lustrec_options =
|
89
|
common_options @
|
90
|
[
|
91
|
"-init", Arg.Set delay_calculus, "performs an initialisation analysis for Lustre nodes <default: no analysis>";
|
92
|
"-dynamic", Arg.Clear static_mem, "specifies a dynamic allocation scheme for main Lustre node <default: static>";
|
93
|
"-check-access", Arg.Set check, "checks at runtime that array accesses always lie within bounds <default: no check>";
|
94
|
"-mpfr", Arg.Int set_mpfr, "replaces FP numbers by the MPFR library multiple precision numbers with a precision of \x1b[4mprec\x1b[0m bits <default: keep FP numbers>";
|
95
|
"-lusi", Arg.Set lusi, "only generates a .lusi interface source file from a Lustre source <default: no generation>";
|
96
|
"-no-spec", Arg.Unit (fun () -> spec := "no"), "do not generate any specification";
|
97
|
"-acsl-spec", Arg.Unit (fun () -> spec := "acsl"), "generates an ACSL encoding of the specification. Only meaningful for the C backend <default>";
|
98
|
"-c-spec", Arg.Unit (fun () -> spec := "c"), "generates a C encoding of the specification instead of ACSL contracts and annotations. Only meaningful for the C backend";
|
99
|
"-java", Arg.Unit (fun () -> output := "java"), "generates Java output instead of C";
|
100
|
"-horn", Arg.Unit (fun () -> output := "horn"), "generates Horn clauses encoding output instead of C";
|
101
|
"-horn-traces", Arg.Unit (fun () -> output := "horn"; traces:=true), "produces traceability file for Horn backend. Enable the horn backend.";
|
102
|
"-horn-cex", Arg.Unit (fun () -> output := "horn"; horn_cex:=true), "generates cex enumeration. Enable the horn backend (work in progress)";
|
103
|
"-horn-query", Arg.Unit (fun () -> output := "horn"; horn_query:=true), "generates queries in generated Horn file. Enable the horn backend (work in progress)";
|
104
|
"-horn-sfunction", Arg.Set_string sfunction, "gets the endpoint predicate of the \x1b[4msfunction\x1b[0m";
|
105
|
"-print-reuse", Arg.Set print_reuse, "prints variable reuse policy";
|
106
|
"-lustre", Arg.Unit (fun () -> output := "lustre"), "generates Lustre output, performing all active optimizations";
|
107
|
"-inline", Arg.Unit (fun () -> global_inline := true; const_unfold := true), "inlines all node calls (require a main node). Implies constant unfolding";
|
108
|
"-witnesses", Arg.Set witnesses, "enables production of witnesses during compilation";
|
109
|
"-O", Arg.Set_int optimization, "changes optimization \x1b[4mlevel\x1b[0m <default: 2>";
|
110
|
"-verbose", Arg.Set_int verbose_level, "changes verbose \x1b[4mlevel\x1b[0m <default: 1>";
|
111
|
|
112
|
"-c++" , Arg.Set cpp , "c++ backend";
|
113
|
"-int" , Arg.Set_string int_type , "specifies the integer type (default=\"int\")";
|
114
|
"-real", Arg.Set_string real_type, "specifies the real type (default=\"double\" without mpfr option)";
|
115
|
"-real-print-prec", Arg.Set_int print_prec_double, "specifies the number of digits to be printed for real values (default=15)";
|
116
|
|
117
|
"-mauve", Arg.String (fun node -> mauve := node; cpp := true; static_mem := false), "generates the mauve code";
|
118
|
]
|
119
|
|
120
|
let lustret_options =
|
121
|
common_options @
|
122
|
[ "-nb-mutants", Arg.Set_int nb_mutants, "\x1b[4mnumber\x1b[0m of mutants to produce <default: 1000>";
|
123
|
"-mcdc-cond", Arg.Set gen_mcdc, "generates MC/DC coverage";
|
124
|
"-no-mutation-suffix", Arg.Set no_mutation_suffix, "does not rename node with the _mutant suffix"
|
125
|
]
|
126
|
|
127
|
let plugin_opt (name, activate, options) =
|
128
|
( "-" ^ name , Arg.Unit activate, "activate plugin " ^ name ) ::
|
129
|
(List.map (fun (opt, act, desc) -> "-" ^ name ^ opt, act, desc) options)
|
130
|
|
131
|
|
132
|
let get_witness_dir filename =
|
133
|
(* Make sure the directory exists *)
|
134
|
let dir = !dest_dir ^ "/" ^ (Filename.basename filename) ^ "_witnesses" in
|
135
|
let _ = try
|
136
|
if not (Sys.is_directory dir) then (
|
137
|
Format.eprintf "File of name %s exists. It should be a directory.@." dir;
|
138
|
exit 1
|
139
|
)
|
140
|
with Sys_error _ -> Unix.mkdir dir 0o750
|
141
|
in
|
142
|
dir
|
143
|
|
144
|
(* Local Variables: *)
|
145
|
(* compile-command:"make -C .." *)
|
146
|
(* End: *)
|