~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to toplevel/topmain.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
(*                                                                     *)
11
11
(***********************************************************************)
12
12
 
13
 
(* $Id: topmain.ml 6758 2005-01-28 17:52:58Z doligez $ *)
 
13
(* $Id: topmain.ml 10444 2010-05-20 14:06:29Z doligez $ *)
14
14
 
15
15
open Clflags
16
16
 
21
21
let prepare ppf =
22
22
  Toploop.set_paths ();
23
23
  try
24
 
    let res = 
 
24
    let res =
25
25
      List.for_all (Topdirs.load_file ppf) (List.rev !preload_objects) in
26
26
    !Toploop.toplevel_startup_hook ();
27
27
    res
50
50
  exit 0;
51
51
;;
52
52
 
 
53
let print_version_num () =
 
54
  Printf.printf "%s\n" Sys.ocaml_version;
 
55
  exit 0;
 
56
;;
 
57
 
 
58
module Options = Main_args.Make_bytetop_options (struct
 
59
  let set r () = r := true
 
60
  let clear r () = r := false
 
61
 
 
62
  let _I dir =
 
63
    let dir = Misc.expand_directory Config.standard_library dir in
 
64
    include_dirs := dir :: !include_dirs
 
65
  let _init s = init_file := Some s
 
66
  let _labels = clear classic
 
67
  let _no_app_funct = clear applicative_functors
 
68
  let _noassert = set noassert
 
69
  let _nolabels = set classic
 
70
  let _noprompt = set noprompt
 
71
  let _nostdlib = set no_std_include
 
72
  let _principal = set principal
 
73
  let _rectypes = set recursive_types
 
74
  let _strict_sequence = set strict_sequence
 
75
  let _unsafe = set fast
 
76
  let _version () = print_version ()
 
77
  let _vnum () = print_version_num ()
 
78
  let _w s = Warnings.parse_options false s
 
79
  let _warn_error s = Warnings.parse_options true s
 
80
  let _warn_help = Warnings.help_warnings
 
81
  let _dparsetree = set dump_parsetree
 
82
  let _drawlambda = set dump_rawlambda
 
83
  let _dlambda = set dump_lambda
 
84
  let _dinstr = set dump_instr
 
85
 
 
86
  let anonymous s = file_argument s
 
87
end);;
 
88
 
 
89
 
53
90
let main () =
54
 
  Arg.parse [
55
 
     "-I", Arg.String(fun dir ->
56
 
       let dir = Misc.expand_directory Config.standard_library dir in
57
 
       include_dirs := dir :: !include_dirs),
58
 
           "<dir>  Add <dir> to the list of include directories";
59
 
     "-init", Arg.String (fun s -> init_file := Some s),
60
 
           "<file>  Load <file> instead of default init file";
61
 
     "-labels", Arg.Clear classic, " Labels commute (default)";
62
 
     "-noassert", Arg.Set noassert, " Do not compile assertion checks";
63
 
     "-nolabels", Arg.Set classic, " Ignore labels and do not commute";
64
 
     "-noprompt", Arg.Set noprompt, " Suppress all prompts";
65
 
     "-nostdlib", Arg.Set no_std_include,
66
 
           " do not add default directory to the list of include directories";
67
 
     "-principal", Arg.Set principal, " Check principality of type inference";
68
 
     "-rectypes", Arg.Set recursive_types, " Allow arbitrary recursive types";
69
 
     "-unsafe", Arg.Set fast, " No bound checking on array and string access";
70
 
     "-version", Arg.Unit print_version, " Print version and exit";
71
 
     "-w", Arg.String (Warnings.parse_options false),
72
 
           "<flags>  Enable or disable warnings according to <flags>:\n\
73
 
       \032    A/a enable/disable all warnings\n\
74
 
       \032    C/c enable/disable suspicious comment\n\
75
 
       \032    D/d enable/disable deprecated features\n\
76
 
       \032    E/e enable/disable fragile match\n\
77
 
       \032    F/f enable/disable partially applied function\n\
78
 
       \032    L/l enable/disable labels omitted in application\n\
79
 
       \032    M/m enable/disable overriden method\n\
80
 
       \032    P/p enable/disable partial match\n\
81
 
       \032    S/s enable/disable non-unit statement\n\
82
 
       \032    U/u enable/disable unused match case\n\
83
 
       \032    V/v enable/disable hidden instance variable\n\
84
 
       \032    Y/y enable/disable suspicious unused variables\n\
85
 
       \032    Z/z enable/disable all other unused variables\n\
86
 
       \032    X/x enable/disable all other warnings\n\
87
 
       \032    default setting is \"Aelz\"";
88
 
     "-warn-error" , Arg.String (Warnings.parse_options true),
89
 
       "<flags>  Treat the warnings of <flags> as errors, if they are enabled.\n\
90
 
         \032    (see option -w for the list of flags)\n\
91
 
         \032    default setting is a (all warnings are non-fatal)";
92
 
 
93
 
     "-dparsetree", Arg.Set dump_parsetree, " (undocumented)";
94
 
     "-drawlambda", Arg.Set dump_rawlambda, " (undocumented)";
95
 
     "-dlambda", Arg.Set dump_lambda, " (undocumented)";
96
 
     "-dinstr", Arg.Set dump_instr, " (undocumented)";
97
 
    ] file_argument usage;
 
91
  Arg.parse Options.list file_argument usage;
98
92
  if not (prepare Format.err_formatter) then exit 2;
99
93
  Toploop.loop Format.std_formatter
100