Newer
Older
(* Time-stamp: <modified the 10/07/2018 (at 10:42) by Erwan Jahier> *)
Erwan Jahier
committed
(* generate ocaml glue code that makes it possible to call lus2lic
from ocaml with the current set of arguments (with Lv6Run.make).
Erwan Jahier
committed
*)
Erwan Jahier
committed
let (f: string array -> Lv6MainArgs.t -> unit) =
fun argv opt ->
let outfile = if opt.outfile <> "" then opt.outfile else
let file = List.hd opt.infiles in
try (Filename.chop_extension (Filename.basename file))^ ".ml"
with _ ->
print_string ("*** Error: '"^file^"'is a bad file name.\n"); exit 2
Erwan Jahier
committed
in
let cma_file = (Filename.chop_extension outfile) ^".cma" in
let remove_me = ["-exec"; "-ocaml";"-o";opt.outfile] in
let args =
Array.fold_right (fun x acc -> if List.mem x remove_me then acc else x::acc) argv []
in
let args_str = "\"" ^ (String.concat "\";\"" args) ^"\"" in
let oc = open_out (outfile) in
Lv6util.entete oc "(*" "*)";
Erwan Jahier
committed
Printf.fprintf oc "
Erwan Jahier
committed
let args = Array.of_list [%s] in
Erwan Jahier
committed
let dyn_file = (Dynlink.adapt_filename \"%s\")
let _ =
OcamlRM.reg_plugin dyn_file plugin
Erwan Jahier
committed
" args_str cma_file