-
BRUN Lelio authoredBRUN Lelio authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
options_management.ml 8.55 KiB
(********************************************************************)
(* *)
(* The LustreC compiler toolset / The LustreC Development Team *)
(* Copyright 2012 - -- ONERA - CNRS - INPT *)
(* *)
(* LustreC is free software, distributed WITHOUT ANY WARRANTY *)
(* under the terms of the GNU Lesser General Public License *)
(* version 2.1. *)
(* *)
(********************************************************************)
open Options
let print_version () =
Format.printf "Lustrec compiler, version %s (%s)@." version codename;
Format.printf "Standard lib: %s@." Version.include_path;
Format.printf "User provided include directory: @[<h>%a@]@."
(Utils.fprintf_list ~sep:"@ " Format.pp_print_string) !include_dirs
let add_include_dir dir =
let removed_slash_suffix =
let len = String.length dir in
if dir.[len-1] = '/' then
String.sub dir 0 (len - 1)
else
dir
in
include_dirs := removed_slash_suffix :: !include_dirs
(** Solving the path of required library:
If local: look in the folders described in !Options.include_dirs
If non local: look first as a local, then in Version.include_path:
ie. in Version.include_path::!Options.include_dirs
Note that in options.ml, include folder are added as heads. One need to
perform a fold_right to respect the order
*)
let search_lib_path (local, full_file_name) =
let paths = (if local then !include_dirs else Version.include_path::!include_dirs) in
let name =
List.fold_right (fun dir res ->
match res with Some _ -> res
| None ->
let path_to_lib = dir ^ "/" ^ full_file_name in
if Sys.file_exists path_to_lib then
Some dir
else
None
)
paths
None
in
match name with
| 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
| Some s -> s
(* Search for path of core libs (without lusic: arrow and io_frontend *)
let core_dependency lib_name =
search_lib_path (false, lib_name ^ ".h")
let name_dependency (local, dep) ext =
let dir = search_lib_path (false, dep ^ ext) in
dir ^ "/" ^ dep
let set_mpfr prec =
if prec > 0 then (
mpfr := true;