Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / options.ml @ 29f59e36

History | View | Annotate | Download (5.32 KB)

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 include_path = Version.include_path
14

    
15
let print_version () = 
16
  Format.printf "Lustrec compiler, version %s@." version;
17
  Format.printf "Include directory: %s@." include_path  
18

    
19
let main_node = ref ""
20
let static_mem = ref true
21
let print_types = ref true
22
let print_clocks = ref true
23
let delay_calculus = ref true
24
let track_exceptions = ref true
25
let ansi = ref false
26
let check = ref false
27
let spec = ref "acsl"
28
let output = ref "C"
29
let dest_dir = ref "."
30
let verbose_level = ref 1
31
let global_inline = ref false
32
let witnesses = ref false
33
let optimization = ref 2
34
let lusi = ref false
35
let print_reuse = ref false
36

    
37
let horntraces = ref false
38
let horn_cex = ref false
39
let horn_queries = ref false
40

    
41
let scopes_mode = ref false
42
let show_scopes = ref false
43
let scopes : string list list ref = ref []
44
let inputs = ref []
45

    
46
let register_scopes s = 
47
  scopes_mode:= true;
48
  let scope_list = Str.split (Str.regexp ", *") s in
49
  let scope_list = List.map (fun scope -> Str.split (Str.regexp "\\.") scope) scope_list in
50
  scopes := scope_list
51

    
52
let register_inputs s = 
53
  scopes_mode:= true;
54
  let input_list = Str.split (Str.regexp "[;]") s in
55
  let input_list = List.map (fun s -> match Str.split (Str.regexp "=") s with | [v;e] -> v, e | _ -> raise (Invalid_argument ("Input list error: " ^ s))) input_list in
56
  let input_list = List.map (fun (v, e) -> v, Str.split (Str.regexp "[;]") e) input_list in
57
  inputs := input_list
58

    
59

    
60

    
61

    
62
let options =
63
  [ "-d", Arg.Set_string dest_dir,
64
    "uses the specified directory as root for generated/imported object and C files (default: .)";
65
    "-node", Arg.Set_string main_node, "specifies the main node";
66
    "-init", Arg.Set delay_calculus, "performs an initialisation analysis for Lustre nodes <default: no analysis>";
67
    "-dynamic", Arg.Clear static_mem, "specifies a dynamic allocation scheme for main Lustre node <default: static>";
68
    "-ansi", Arg.Set ansi, "specifies that generated C code is ansi C90 compliant <default: C99>";
69
    "-check-access", Arg.Set check, "checks at runtime that array accesses always lie within bounds <default: no check>";
70
    "-lusi", Arg.Set lusi, "only generates a .lusi interface source file from a Lustre source <default: no generation>";
71
    "-no-spec", Arg.Unit (fun () -> spec := "no"), "do not generate any specification";
72
    "-acsl-spec", Arg.Unit (fun () -> spec := "acsl"), "generates an ACSL encoding of the specification. Only meaningful for the C backend (default)";
73
    "-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";
74
    "-java", Arg.Unit (fun () -> output := "java"), "generates Java output instead of C";
75
    "-horn", Arg.Unit (fun () -> output := "horn"), "generates Horn clauses encoding output instead of C";
76
    "-horn-traces", Arg.Unit (fun () -> output := "horn"; horntraces:=true), "produce traceability file for Horn backend. Enable the horn backend.";
77
    "-horn-cex", Arg.Unit (fun () -> output := "horn"; horn_cex:=true), "generate cex enumeration. Enable the horn backend (work in progress)";
78
    "-horn-queries", Arg.Unit (fun () -> output := "horn"; horn_queries:=true), "generate queries in generated Horn file. Enable the horn backend (work in progress)";
79
    "-print_reuse", Arg.Set print_reuse, "prints variable reuse policy";
80
    "-lustre", Arg.Unit (fun () -> output := "lustre"), "generates Lustre output, performing all active optimizations";
81
    "-inline", Arg.Set global_inline, "inline all node calls (require a main node)";
82
    "-witnesses", Arg.Set witnesses, "enable production of witnesses during compilation";
83
    "-print_types", Arg.Set print_types, "prints node types";
84
    "-print_clocks", Arg.Set print_clocks, "prints node clocks";
85
    "-O", Arg.Set_int optimization, " changes optimization level <default: 2>";
86
    "-verbose", Arg.Set_int verbose_level, " changes verbose level <default: 1>";
87
    "-version", Arg.Unit print_version, " displays the version";]@
88
[
89
  "-scopes", Arg.String register_scopes, "specifies which variables to log";
90
  "-input", Arg.String register_inputs, "specifies the simulation input";
91
  "-show-possible-scopes", Arg.Unit (fun () -> show_scopes:= true; scopes_mode := true), "list possible variables to log";
92
] 
93

    
94
let get_witness_dir filename =
95
  (* Make sure the directory exists *)
96
  let dir = !dest_dir ^ "/" ^ (Filename.basename filename) ^ "_witnesses" in
97
  let _ = try
98
	    if not (Sys.is_directory dir) then (
99
	      Format.eprintf "File of name %s exists. It should be a directory.@." dir;
100
	      exit 1
101
	    )
102
    with Sys_error _ -> Unix.mkdir dir 0o750
103
  in
104
  dir
105

    
106
(* Local Variables: *)
107
(* compile-command:"make -C .." *)
108
(* End: *)