Revision 990210f3 src/options.ml
src/options.ml | ||
---|---|---|
11 | 11 |
|
12 | 12 |
let version = Version.number |
13 | 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
|
|
14 |
let include_dirs = ref ["."]
|
|
15 |
(* let include_path = *)
|
|
16 |
(* if (!include_dir <> ".") then Version.prefix ^ !include_dir *)
|
|
17 |
(* else Version.include_path *)
|
|
18 | 18 |
|
19 | 19 |
|
20 | 20 |
|
21 | 21 |
|
22 | 22 |
let print_version () = |
23 | 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 |
|
24 |
Format.printf "Standard lib: %s@." Version.include_path; |
|
25 |
Format.printf "User provided include directory: @[<h>%a@]@." |
|
26 |
(Utils.fprintf_list ~sep:"@ " Format.pp_print_string) !include_dirs |
|
26 | 27 |
|
27 | 28 |
let main_node = ref "" |
28 | 29 |
let static_mem = ref true |
... | ... | |
61 | 62 |
let gen_mcdc = ref false |
62 | 63 |
let no_mutation_suffix = ref false |
63 | 64 |
|
65 |
let add_include_dir dir = |
|
66 |
let removed_slash_suffix = |
|
67 |
let len = String.length dir in |
|
68 |
if dir.[len-1] = '/' then |
|
69 |
String.sub dir 0 (len - 1) |
|
70 |
else |
|
71 |
dir |
|
72 |
in |
|
73 |
include_dirs := removed_slash_suffix :: !include_dirs |
|
74 |
|
|
75 |
|
|
76 |
(** Solving the path of required library: |
|
77 |
If local: look in the folders described in !Options.include_dirs |
|
78 |
If non local: look first as a local, then in Version.include_path: |
|
79 |
ie. in Version.include_path::!Options.include_dirs |
|
80 |
Note that in options.ml, include folder are added as heads. One need to |
|
81 |
perform a fold_right to respect the order |
|
82 |
*) |
|
83 |
let search_lib_path (local, full_file_name) = |
|
84 |
let paths = (if local then !include_dirs else Version.include_path::!include_dirs) in |
|
85 |
let name = |
|
86 |
List.fold_right (fun dir res -> |
|
87 |
match res with Some _ -> res |
|
88 |
| None -> |
|
89 |
let path_to_lib = dir ^ "/" ^ full_file_name in |
|
90 |
if Sys.file_exists path_to_lib then |
|
91 |
Some dir |
|
92 |
else |
|
93 |
None |
|
94 |
) |
|
95 |
paths |
|
96 |
None |
|
97 |
in |
|
98 |
match name with |
|
99 |
| None -> Format.eprintf "Unable to find library %s in paths %a@.@?" full_file_name (Utils.fprintf_list ~sep:", " Format.pp_print_string) paths;raise Not_found |
|
100 |
| Some s -> s |
|
101 |
|
|
102 |
(* Search for path of core libs (without lusic: arrow and io_frontend *) |
|
103 |
let core_dependency lib_name = |
|
104 |
search_lib_path (false, lib_name ^ ".h") |
|
105 |
|
|
106 |
let name_dependency (local, dep) = |
|
107 |
let dir = search_lib_path (false, dep ^ ".lusic") in |
|
108 |
dir ^ "/" ^ dep |
|
109 |
|
|
64 | 110 |
let set_mpfr prec = |
65 | 111 |
if prec > 0 then ( |
66 | 112 |
mpfr := true; |
... | ... | |
72 | 118 |
|
73 | 119 |
let common_options = |
74 | 120 |
[ "-d", Arg.Set_string dest_dir, "uses the specified \x1b[4mdirectory\x1b[0m as root for generated/imported object and C files <default: .>"; |
75 |
"-I", Arg.Set_string include_dir, "sets include \x1b[4mdirectory\x1b[0m";
|
|
121 |
"-I", Arg.String add_include_dir, "sets include \x1b[4mdirectory\x1b[0m";
|
|
76 | 122 |
"-node", Arg.Set_string main_node, "specifies the \x1b[4mmain\x1b[0m node"; |
77 | 123 |
"-print-types", Arg.Set print_types, "prints node types"; |
78 | 124 |
"-print-clocks", Arg.Set print_clocks, "prints node clocks"; |
Also available in: Unified diff