Project

General

Profile

Download (5.7 KB) Statistics
| Branch: | Tag: | Revision:
1 a2d97a3e ploc
(********************************************************************)
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 22fe1c93 ploc
12 1e48ef45 ploc
let version = Version.number
13 41e48ef3 Eric NOULARD
let codename = Version.codename
14 fc476249 Teme
let include_dir = ref "."
15
let include_path =
16
if (!include_dir != ".") then Version.prefix ^ !include_dir
17
else Version.include_path
18 1b57e111 Teme
19 fc476249 Teme
20
21 1e48ef45 ploc
22 5cf953ec tkahsai
let print_version () =
23 41e48ef3 Eric NOULARD
  Format.printf "Lustrec compiler, version %s (%s)@." version codename;
24 fc476249 Teme
  Format.printf "Include directory: %s@." include_path;
25
  Format.printf "User selected Include directory: %s@." !include_dir
26 1e48ef45 ploc
27 22fe1c93 ploc
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 d4107cf2 ploc
let spec = ref "acsl"
36 3ee1012f ploc
let output = ref "C"
37 7291cb80 xthirioux
let dest_dir = ref "."
38 22fe1c93 ploc
let verbose_level = ref 1
39 e2380d4d ploc
let global_inline = ref false
40
let witnesses = ref false
41 c1adf235 ploc
let optimization = ref 2
42 ed81df06 xthirioux
let lusi = ref false
43 89a70069 xthirioux
let print_reuse = ref false
44 04a63d25 xthirioux
let const_unfold = ref false
45
let mpfr = ref false
46
let mpfr_prec = ref 0
47 a2d97a3e ploc
48 04a63d25 xthirioux
let traces = ref false
49 43aa67ec tkahsai
let horn_cex = ref false
50 2c083577 tkahsai
let horn_query = ref true
51 22fe1c93 ploc
52 04a63d25 xthirioux
let salsa_enabled = ref true
53 1e48ef45 ploc
54 52c5ba00 David Doose
let cpp       = ref false
55
let int_type  = ref "int"
56
let real_type = ref "double"
57
58 1b57e111 Teme
let sfunction = ref ""
59
60 04a63d25 xthirioux
let set_mpfr prec =
61
  if prec > 0 then (
62
    mpfr := true;
63
    mpfr_prec := prec;
64
    salsa_enabled := false; (* We deactivate salsa *)
65
  )
66
  else
67
    failwith "mpfr requires a positive integer"
68
			
69 22fe1c93 ploc
let options =
70 fc476249 Teme
[ "-d", Arg.Set_string dest_dir,
71
"uses the specified directory \x1b[4mdir\x1b[0m as root for generated/imported object and C files <default: .>";
72
"-I", Arg.Set_string include_dir, "Include directory";
73 04a63d25 xthirioux
    "-node", Arg.Set_string main_node, "specifies the \x1b[4mmain\x1b[0m node";
74 ed81df06 xthirioux
    "-init", Arg.Set delay_calculus, "performs an initialisation analysis for Lustre nodes <default: no analysis>";
75
    "-dynamic", Arg.Clear static_mem, "specifies a dynamic allocation scheme for main Lustre node <default: static>";
76
    "-check-access", Arg.Set check, "checks at runtime that array accesses always lie within bounds <default: no check>";
77 04a63d25 xthirioux
    "-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>";
78 ed81df06 xthirioux
    "-lusi", Arg.Set lusi, "only generates a .lusi interface source file from a Lustre source <default: no generation>";
79 d4107cf2 ploc
    "-no-spec", Arg.Unit (fun () -> spec := "no"), "do not generate any specification";
80 04a63d25 xthirioux
    "-acsl-spec", Arg.Unit (fun () -> spec := "acsl"), "generates an ACSL encoding of the specification. Only meaningful for the C backend <default>";
81 d4107cf2 ploc
    "-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";
82 3ee1012f ploc
    "-java", Arg.Unit (fun () -> output := "java"), "generates Java output instead of C";
83
    "-horn", Arg.Unit (fun () -> output := "horn"), "generates Horn clauses encoding output instead of C";
84 ea1c2906 ploc
    "-horn-traces", Arg.Unit (fun () -> output := "horn"; traces:=true), "produce traceability file for Horn backend. Enable the horn backend.";
85 a2d97a3e ploc
    "-horn-cex", Arg.Unit (fun () -> output := "horn"; horn_cex:=true), "generate cex enumeration. Enable the horn backend (work in progress)";
86 2c083577 tkahsai
    "-horn-query", Arg.Unit (fun () -> output := "horn"; horn_query:=true), "generate queries in generated Horn file. Enable the horn backend (work in progress)";
87 dcafc99b Ploc
    "-horn-sfunction", Arg.Set_string sfunction, "Get the endpoint predicate of the sfunction";
88 89a70069 xthirioux
    "-print_reuse", Arg.Set print_reuse, "prints variable reuse policy";
89 c1adf235 ploc
    "-lustre", Arg.Unit (fun () -> output := "lustre"), "generates Lustre output, performing all active optimizations";
90 04a63d25 xthirioux
    "-inline", Arg.Unit (fun () -> global_inline := true; const_unfold := true), "inline all node calls (require a main node). Implies constant unfolding";
91 e2380d4d ploc
    "-witnesses", Arg.Set witnesses, "enable production of witnesses during compilation";
92 22fe1c93 ploc
    "-print_types", Arg.Set print_types, "prints node types";
93
    "-print_clocks", Arg.Set print_clocks, "prints node clocks";
94 04a63d25 xthirioux
    "-O", Arg.Set_int optimization, "changes optimization \x1b[4mlevel\x1b[0m <default: 2>";
95
    "-verbose", Arg.Set_int verbose_level, "changes verbose \x1b[4mlevel\x1b[0m <default: 1>";
96 52c5ba00 David Doose
    "-version", Arg.Unit print_version, " displays the version";
97
98
    "-c++" , Arg.Set        cpp      , "c++ backend";
99
    "-int" , Arg.Set_string int_type , "specifies the integer type (default=\"int\")";
100
    "-real", Arg.Set_string real_type, "specifies the real type (default=\"double\" without mpfr option)";
101
]
102 22fe1c93 ploc
103 ec433d69 xthirioux
104 04a63d25 xthirioux
let plugin_opt (name, activate, options) =
105
  ( "-" ^ name , Arg.Unit activate, "activate plugin " ^ name ) ::
106
    (List.map (fun (opt, act, desc) -> "-" ^ name ^ opt, act, desc) options)
107
 
108
109 592f508c ploc
let get_witness_dir filename =
110
  (* Make sure the directory exists *)
111
  let dir = !dest_dir ^ "/" ^ (Filename.basename filename) ^ "_witnesses" in
112
  let _ = try
113
	    if not (Sys.is_directory dir) then (
114
	      Format.eprintf "File of name %s exists. It should be a directory.@." dir;
115
	      exit 1
116
	    )
117
    with Sys_error _ -> Unix.mkdir dir 0o750
118
  in
119 43aa67ec tkahsai
  dir
120 22fe1c93 ploc
121
(* Local Variables: *)
122
(* compile-command:"make -C .." *)
123
(* End: *)