Generator main program.
[wrappi.git] / generator / wrappi_main.ml
diff --git a/generator/wrappi_main.ml b/generator/wrappi_main.ml
new file mode 100644 (file)
index 0000000..aaf3719
--- /dev/null
@@ -0,0 +1,59 @@
+(* wrappi
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Printf
+
+let eps = Wrappi_globals.get_entry_points ()
+
+let dump_and_exit () =
+  printf "entry points:\n";
+
+  List.iter (fun ep ->
+    printf "  %s\n" (Wrappi_types.string_of_entry_point ep)
+  ) eps;
+
+  exit 0
+
+(* Parse command line arguments. *)
+let () =
+  let display_version () =
+    printf "%s %s\n" Config.package_name Config.package_version;
+    exit 0
+  in
+
+  let argspec = Arg.align [
+    "--dump", Arg.Unit dump_and_exit, " Dump API data and exit.";
+    "--version", Arg.Unit display_version, " Display version number and exit.";
+  ] in
+  let anon_fun str = raise (Arg.Bad "generator: unknown parameter") in
+  let usage_msg = "wrappi generator: generates lots of code
+
+To run the generator normally (note it MUST be run from the top
+level SOURCE directory):
+
+  ./generator/generator
+
+Options are for debugging only:
+
+  ./generator/generator [--options]
+
+OPTIONS" in
+  Arg.parse argspec anon_fun usage_msg
+
+let () =
+  printf "generator, %d entry points\n" (List.length eps)