Generator main program.
[wrappi.git] / generator / wrappi_main.ml
1 (* wrappi
2  * Copyright (C) 2011 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 open Printf
20
21 let eps = Wrappi_globals.get_entry_points ()
22
23 let dump_and_exit () =
24   printf "entry points:\n";
25
26   List.iter (fun ep ->
27     printf "  %s\n" (Wrappi_types.string_of_entry_point ep)
28   ) eps;
29
30   exit 0
31
32 (* Parse command line arguments. *)
33 let () =
34   let display_version () =
35     printf "%s %s\n" Config.package_name Config.package_version;
36     exit 0
37   in
38
39   let argspec = Arg.align [
40     "--dump", Arg.Unit dump_and_exit, " Dump API data and exit.";
41     "--version", Arg.Unit display_version, " Display version number and exit.";
42   ] in
43   let anon_fun str = raise (Arg.Bad "generator: unknown parameter") in
44   let usage_msg = "wrappi generator: generates lots of code
45
46 To run the generator normally (note it MUST be run from the top
47 level SOURCE directory):
48
49   ./generator/generator
50
51 Options are for debugging only:
52
53   ./generator/generator [--options]
54
55 OPTIONS" in
56   Arg.parse argspec anon_fun usage_msg
57
58 let () =
59   printf "generator, %d entry points\n" (List.length eps)