1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
(***********************************************************************)
(* *)
(* CamlIDL *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1999 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License LGPL v2.1 *)
(* *)
(***********************************************************************)
(* $Id: main.ml,v 1.16 2002-04-19 13:24:29 xleroy Exp $ *)
open Printf
open Clflags
open Utils
open Idltypes
open File
let process_file name =
let pref =
if Filename.check_suffix name ".idl"
then Filename.chop_suffix name ".idl"
else name in
let intf = Normalize.normalize_file name in
eval_constants intf;
let oc = open_out (pref ^ ".mli") in
begin try
gen_mli_file oc intf;
close_out oc
with x ->
close_out oc; remove_file (pref ^ ".mli"); raise x
end;
let oc = open_out (pref ^ ".ml") in
begin try
gen_ml_file oc intf;
close_out oc
with x ->
close_out oc; remove_file (pref ^ ".ml"); raise x
end;
let oc = open_out (pref ^ "_stubs.c") in
begin try
gen_c_stub oc intf;
close_out oc
with x ->
close_out oc; remove_file (pref ^ "_stubs.c"); raise x
end;
if !Clflags.gen_header then begin
let oc = open_out (pref ^ ".h") in
begin try
gen_c_header oc intf;
close_out oc
with x ->
close_out oc; remove_file (pref ^ ".h"); raise x
end
end
let _ =
try
Arg.parse
["-I", Arg.String(fun s -> search_path := !search_path @ [s]),
"<dir> Add directory to search path";
"-D", Arg.String(fun s -> prepro_defines := !prepro_defines @ [s]),
"<symbol> Pass -D<symbol> to the C preprocessor";
"-cpp", Arg.Set use_cpp,
" Pass the .idl files through the C preprocessor (default)";
"-nocpp", Arg.Clear use_cpp,
" Do not pass the .idl files through the C preprocessor";
"-prepro", Arg.String(fun s -> preprocessor := s),
"<cmd> Use <cmd> as the preprocessor instead of the C preprocessor";
"-header", Arg.Set gen_header,
" Generate a .h file containing all type definitions";
"-no-include", Arg.Clear include_header,
" Do not #include the .h file in the generated .c file";
"-prefix-all-labels", Arg.Set prefix_all_labels,
" Prefix all ML name of record labels with name of enclosing struct";
"-keep-labels", Arg.Set keep_labels,
" Do not prefix ML names of record labels, even if ambiguous"
]
process_file
"Usage: camlidl [options]<.idl file> ... <.idl file>\nOptions are:\n"
with Error ->
exit 2
|