Project

General

Profile

Download (5.01 KB) Statistics
| Branch: | Tag: | Revision:
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 (dev)@." 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
let const_unfold = ref false
37
let mpfr = ref false
38
let mpfr_prec = ref 0
39

    
40
let horntraces = ref false
41
let horn_cex = ref false
42
let horn_queries = ref false
43

    
44

    
45
let set_mpfr prec =
46
  if prec > 0 then (
47
    mpfr := true;
48
    mpfr_prec := prec;
49
    (* salsa_enabled := false; (* We deactivate salsa *) TODO *)
50
  )
51
  else
52
    failwith "mpfr requires a positive integer"
53
			
54
let options =
55
  [ "-d", Arg.Set_string dest_dir,
56
    "uses the specified directory \x1b[4mdir\x1b[0m as root for generated/imported object and C files <default: .>";
57
    "-node", Arg.Set_string main_node, "specifies the \x1b[4mmain\x1b[0m node";
58
    "-init", Arg.Set delay_calculus, "performs an initialisation analysis for Lustre nodes <default: no analysis>";
59
    "-dynamic", Arg.Clear static_mem, "specifies a dynamic allocation scheme for main Lustre node <default: static>";
60
    "-check-access", Arg.Set check, "checks at runtime that array accesses always lie within bounds <default: no check>";
61
    "-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>";
62
    "-lusi", Arg.Set lusi, "only generates a .lusi interface source file from a Lustre source <default: no generation>";
63
    "-no-spec", Arg.Unit (fun () -> spec := "no"), "do not generate any specification";
64
    "-acsl-spec", Arg.Unit (fun () -> spec := "acsl"), "generates an ACSL encoding of the specification. Only meaningful for the C backend <default>";
65
    "-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";
66
    "-java", Arg.Unit (fun () -> output := "java"), "generates Java output instead of C";
67
    "-horn", Arg.Unit (fun () -> output := "horn"), "generates Horn clauses encoding output instead of C";
68
    "-horn-traces", Arg.Unit (fun () -> output := "horn"; horntraces:=true), "produce traceability file for Horn backend. Enable the horn backend.";
69
    "-horn-cex", Arg.Unit (fun () -> output := "horn"; horn_cex:=true), "generate cex enumeration. Enable the horn backend (work in progress)";
70
    "-horn-queries", Arg.Unit (fun () -> output := "horn"; horn_queries:=true), "generate queries in generated Horn file. Enable the horn backend (work in progress)";
71
    "-print_reuse", Arg.Set print_reuse, "prints variable reuse policy";
72
    "-lustre", Arg.Unit (fun () -> output := "lustre"), "generates Lustre output, performing all active optimizations";
73
    "-inline", Arg.Unit (fun () -> global_inline := true; const_unfold := true), "inline all node calls (require a main node). Implies constant unfolding";
74
    "-witnesses", Arg.Set witnesses, "enable production of witnesses during compilation";
75
    "-print_types", Arg.Set print_types, "prints node types";
76
    "-print_clocks", Arg.Set print_clocks, "prints node clocks";
77
    "-O", Arg.Set_int optimization, "changes optimization \x1b[4mlevel\x1b[0m <default: 2>";
78
    "-verbose", Arg.Set_int verbose_level, "changes verbose \x1b[4mlevel\x1b[0m <default: 1>";
79
    "-version", Arg.Unit print_version, " displays the version";]
80

    
81

    
82
let plugin_opt (name, activate, options) =
83
  ( "-" ^ name , Arg.Unit activate, "activate plugin " ^ name ) ::
84
    (List.map (fun (opt, act, desc) -> "-" ^ name ^ opt, act, desc) options)
85
 
86

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

    
99
(* Local Variables: *)
100
(* compile-command:"make -C .." *)
101
(* End: *)
(38-38/53)