aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.hgignore5
-rw-r--r--tools/ocaml/libs/xl/Makefile28
-rw-r--r--tools/ocaml/libs/xl/genwrap.py42
-rw-r--r--tools/ocaml/libs/xl/xl.ml.in (renamed from tools/ocaml/libs/xl/xl.ml)2
-rw-r--r--tools/ocaml/libs/xl/xl.mli.in (renamed from tools/ocaml/libs/xl/xl.mli)2
-rw-r--r--tools/ocaml/libs/xl/xl_stubs.c4
6 files changed, 82 insertions, 1 deletions
diff --git a/.hgignore b/.hgignore
index 2c2dc4bd3e..b497e634e3 100644
--- a/.hgignore
+++ b/.hgignore
@@ -295,6 +295,11 @@
^tools/ocaml/.*/.*\.cmx?a$
^tools/ocaml/.*/META$
^tools/ocaml/.*/\.ocamldep\.make$
+^tools/ocaml/libs/xl/_libxl_types\.ml\.in$
+^tools/ocaml/libs/xl/_libxl_types\.mli\.in$
+^tools/ocaml/libs/xl/_libxl_types\.inc$
+^tools/ocaml/libs/xl/xl\.ml$
+^tools/ocaml/libs/xl/xl\.mli$
^tools/ocaml/xenstored/oxenstored$
^xen/\.banner.*$
^xen/BLOG$
diff --git a/tools/ocaml/libs/xl/Makefile b/tools/ocaml/libs/xl/Makefile
index 8e31b72424..8e87973814 100644
--- a/tools/ocaml/libs/xl/Makefile
+++ b/tools/ocaml/libs/xl/Makefile
@@ -15,8 +15,36 @@ xl_C_OBJS = xl_stubs
OCAML_LIBRARY = xl
+GENERATED_FILES += xl.ml xl.mli
+GENERATED_FILES += _libxl_types.ml.in _libxl_types.mli.in
+GENERATED_FILES += _libxl_types.inc
+
all: $(INTF) $(LIBS)
+xl.ml: xl.ml.in _libxl_types.ml.in
+ $(Q)sed -e '1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.ml.in and _libxl_types.ml.in\
+ *)\
+' \
+ -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.ml.in' \
+ < xl.ml.in > xl.ml
+
+xl.mli: xl.mli.in _libxl_types.mli.in
+ $(Q)sed -e '1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.mli.in and _libxl_types.mli.in\
+ *)\
+' \
+ -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.mli.in' \
+ < xl.mli.in > xl.mli
+
+_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \
+ $(XEN_ROOT)/tools/libxl/libxltypes.py
+ PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \
+ $(XEN_ROOT)/tools/libxl/libxl.idl \
+ _libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc
+
libs: $(LIBS)
.PHONY: install
diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
new file mode 100644
index 0000000000..3f1c6e5245
--- /dev/null
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import sys,os
+
+import libxltypes
+
+def autogen_header(open_comment, close_comment):
+ s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + "\n"
+ s += open_comment + " autogenerated by \n"
+ s += reduce(lambda x,y: x + " ", range(len(open_comment + " ")), "")
+ s += "%s" % " ".join(sys.argv)
+ s += "\n " + close_comment + "\n\n"
+ return s
+
+if __name__ == '__main__':
+ if len(sys.argv) < 4:
+ print >>sys.stderr, "Usage: genwrap.py <idl> <mli> <ml> <c-inc>"
+ sys.exit(1)
+
+ idl = sys.argv[1]
+ (_,types) = libxltypes.parse(idl)
+
+
+ _ml = sys.argv[3]
+ ml = open(_ml, 'w')
+ ml.write(autogen_header("(*", "*)"))
+
+ _mli = sys.argv[2]
+ mli = open(_mli, 'w')
+ mli.write(autogen_header("(*", "*)"))
+
+ _cinc = sys.argv[4]
+ cinc = open(_cinc, 'w')
+ cinc.write(autogen_header("/*", "*/"))
+
+ # TODO: autogenerate something
+
+ ml.write("(* END OF AUTO-GENERATED CODE *)\n")
+ ml.close()
+ mli.write("(* END OF AUTO-GENERATED CODE *)\n")
+ mli.close()
+ cinc.close()
diff --git a/tools/ocaml/libs/xl/xl.ml b/tools/ocaml/libs/xl/xl.ml.in
index 8b504b494e..96f116eb6b 100644
--- a/tools/ocaml/libs/xl/xl.ml
+++ b/tools/ocaml/libs/xl/xl.ml.in
@@ -17,6 +17,8 @@ exception Error of string
type domid = int
+(* @@LIBXL_TYPES@@ *)
+
type console_type =
| CONSOLETYPE_XENCONSOLED
| CONSOLETYPE_IOEMU
diff --git a/tools/ocaml/libs/xl/xl.mli b/tools/ocaml/libs/xl/xl.mli.in
index d52a37174e..55cfd25416 100644
--- a/tools/ocaml/libs/xl/xl.mli
+++ b/tools/ocaml/libs/xl/xl.mli.in
@@ -17,6 +17,8 @@ exception Error of string
type domid = int
+(* @@LIBXL_TYPES@@ *)
+
type console_type =
| CONSOLETYPE_XENCONSOLED
| CONSOLETYPE_IOEMU
diff --git a/tools/ocaml/libs/xl/xl_stubs.c b/tools/ocaml/libs/xl/xl_stubs.c
index ebbf476e97..62b3e3dc91 100644
--- a/tools/ocaml/libs/xl/xl_stubs.c
+++ b/tools/ocaml/libs/xl/xl_stubs.c
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <string.h>
-#include "libxl.h"
+#include <libxl.h>
struct caml_logger {
struct xentoollog_logger logger;
@@ -130,6 +130,8 @@ static int string_string_tuple_array_val (caml_gc *gc, char ***c_val, value v)
#endif
+#include "_libxl_types.inc"
+
static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
{
CAMLparam1(v);