[PATCH ocaml 1/1] Add dune build system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce the dune build system to build ocaml-libvirt, providing
everything that the current autoconf-based build system has.

Add also an opam configuration files, as it is mandatory with dune.

Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>
---
 .gitignore             |  3 +++
 dune                   | 18 +++++++++++++
 dune-project           |  1 +
 dune.inc               | 22 ++++++++++++++++
 examples/dune          | 50 ++++++++++++++++++++++++++++++++++++
 libvirt/discover.ml    | 40 +++++++++++++++++++++++++++++
 libvirt/dune           | 57 ++++++++++++++++++++++++++++++++++++++++++
 libvirt/dune-project   |  2 ++
 libvirt/mllibvirt.opam | 33 ++++++++++++++++++++++++
 9 files changed, 226 insertions(+)
 create mode 100644 dune
 create mode 100644 dune-project
 create mode 100644 dune.inc
 create mode 100644 examples/dune
 create mode 100644 libvirt/discover.ml
 create mode 100644 libvirt/dune
 create mode 100644 libvirt/dune-project
 create mode 100644 libvirt/mllibvirt.opam

diff --git a/.gitignore b/.gitignore
index c52c1b8..814457b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,10 +10,12 @@
 *.opt
 *.so
 *~
+.merlin
 Make.rules
 Makefile
 core
 core.*
+/_build/
 /META
 /aclocal.m4
 /autom4te.cache
@@ -30,5 +32,6 @@ core.*
 /html/
 /libvirt/libvirt_generated.c
 /libvirt/libvirt_version.ml
+/libvirt/mllibvirt.install
 /ocaml-libvirt-*.exe
 /ocaml-libvirt-*.tar.gz
diff --git a/dune b/dune
new file mode 100644
index 0000000..5002345
--- /dev/null
+++ b/dune
@@ -0,0 +1,18 @@
+; OCaml bindings for libvirt.
+; (C) Copyright 2020 Pino Toscano, Red Hat Inc.
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+(include dune.inc)
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000..de4fc20
--- /dev/null
+++ b/dune-project
@@ -0,0 +1 @@
+(lang dune 1.0)
diff --git a/dune.inc b/dune.inc
new file mode 100644
index 0000000..2cfb767
--- /dev/null
+++ b/dune.inc
@@ -0,0 +1,22 @@
+; OCaml bindings for libvirt.
+; (C) Copyright 2020 Pino Toscano, Red Hat Inc.
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+(env
+  (dev
+    (flags (:standard -g -warn-error CDEFLMPSUVYZX-3 -w -9-27-34-37-50 -safe-string)))
+  (release
+    (flags (:standard -g -warn-error CDEFLMPSUVYZX-3 -w -9-27-34-37-50 -safe-string))))
diff --git a/examples/dune b/examples/dune
new file mode 100644
index 0000000..219727c
--- /dev/null
+++ b/examples/dune
@@ -0,0 +1,50 @@
+; OCaml bindings for libvirt.
+; (C) Copyright 2020 Pino Toscano, Red Hat Inc.
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+(executable
+  (name domain_events)
+  (modules Domain_events)
+  (libraries mllibvirt))
+
+(executable
+  (name get_all_domain_stats)
+  (modules Get_all_domain_stats)
+  (libraries mllibvirt unix))
+
+(executable
+  (name get_cpu_stats)
+  (modules Get_cpu_stats)
+  (libraries mllibvirt))
+
+(executable
+  (name list_domains)
+  (modules List_domains)
+  (libraries mllibvirt))
+
+(executable
+  (name list_secrets)
+  (modules List_secrets)
+  (libraries mllibvirt))
+
+(executable
+  (name node_info)
+  (modules Node_info)
+  (libraries mllibvirt))
+
+(alias
+  (name examples)
+  (deps domain_events.exe get_all_domain_stats.exe get_cpu_stats.exe list_domains.exe list_secrets.exe node_info.exe))
diff --git a/libvirt/discover.ml b/libvirt/discover.ml
new file mode 100644
index 0000000..a49ae7a
--- /dev/null
+++ b/libvirt/discover.ml
@@ -0,0 +1,40 @@
+(* OCaml bindings for libvirt.
+   (C) Copyright 2020 Pino Toscano, Red Hat Inc.
+   https://libvirt.org/
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+*)
+
+module C = Configurator.V1
+
+let discover c =
+  let package = "libvirt" in
+  let minversion = "1.2.8" in
+  let expr = package ^ " >= " ^ minversion in
+  let pkgconfig =
+    match C.Pkg_config.get c with
+    | None -> C.die "pkg-config not available"
+    | Some pc -> pc in
+  let conf =
+    match C.Pkg_config.query_expr pkgconfig ~package ~expr with
+    | None -> C.die "%s not found" package
+    | Some deps -> deps in
+  C.Flags.write_sexp "c_flags.sexp" conf.cflags;
+  C.Flags.write_sexp "c_library_flags.sexp" conf.libs;
+  if C.which c "perl" = None then
+    C.die "perl not found"
+
+let () =
+  C.main ~name:"discover" discover
diff --git a/libvirt/dune b/libvirt/dune
new file mode 100644
index 0000000..7e31a8e
--- /dev/null
+++ b/libvirt/dune
@@ -0,0 +1,57 @@
+; OCaml bindings for libvirt.
+; (C) Copyright 2020 Pino Toscano, Red Hat Inc.
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+(include ../dune.inc)
+
+(library
+  (name mllibvirt)
+  (synopsis "libvirt bindings for OCaml")
+  (public_name mllibvirt)
+  (modules Libvirt Libvirt_version)
+  (wrapped false)
+  (c_names libvirt_c_common libvirt_generated libvirt_c_oneoffs)
+  (c_flags (:include c_flags.sexp) -DCAML_NAME_SPACE -fPIC -Wall -g)
+  (c_library_flags (:include c_library_flags.sexp)))
+
+(executable
+  (name discover)
+  (modules Discover)
+  (libraries dune.configurator))
+
+(rule
+  (targets c_flags.sexp c_library_flags.sexp)
+  (deps (:discover discover.exe))
+  (action (run %{discover})))
+
+(rule
+  (targets libvirt_generated.c)
+  (deps (:generator generator.pl))
+  (action (run %{generator})))
+
+(rule
+  (targets libvirt_version.ml)
+  (deps (:version_in libvirt_version.ml.in))
+  (action (with-stdout-to %{targets}
+            (run sed "s/@PACKAGE_NAME@/ocaml-libvirt/;s/@PACKAGE_VERSION@/%{version:mllibvirt}/;" %{version_in}))))
+
+(alias
+  (name htmldoc)
+  (deps (universe))   ; let it run everytime
+  (action (progn
+            (run rm -rf html)
+            (run mkdir html)
+            (run ocamldoc -html -sort -colorize-code -d html %{dep:libvirt.mli} %{dep:libvirt_version.mli}))))
diff --git a/libvirt/dune-project b/libvirt/dune-project
new file mode 100644
index 0000000..5ede662
--- /dev/null
+++ b/libvirt/dune-project
@@ -0,0 +1,2 @@
+(lang dune 1.0)
+(version 0.6.1.5)
diff --git a/libvirt/mllibvirt.opam b/libvirt/mllibvirt.opam
new file mode 100644
index 0000000..23eee04
--- /dev/null
+++ b/libvirt/mllibvirt.opam
@@ -0,0 +1,33 @@
+opam-version: "2.0"
+name: "mllibvirt"
+authors: "Richard W.M. Jones <rjones@xxxxxxxxxx>"
+maintainer: "Richard W.M. Jones <rjones@xxxxxxxxxx>"
+homepage: "https://libvirt.org/ocaml/";
+dev-repo: "https://gitlab.com/libvirt/libvirt-ocaml.git";
+bug-reports: "https://libvirt.org/bugs.html";
+synopsis: "Libvirt bindings for OCaml"
+description: """libvirt bindings for OCaml
+
+Libvirt is a C toolkit to interact with the virtualization capabilities
+of recent versions of Linux (and other OSes)."""
+license: "LGPL-2+"
+tags: [
+  "libvirt"
+]
+build: [
+  ["dune" "build"]
+]
+depends: [
+  "conf-pkg-config" {build}
+  "ocamlfind" {build}
+]
+depexts: [
+  ["libvirt-dev"] {os-family = "debian"}
+  ["libvirt-devel"] {os-family = "rhel"}
+  ["libvirt-devel"] {os-family = "suse"}
+  ["libvirt-devel"] {os-distribution = "mageia"}
+  ["libvirt"] {os = "macos" & os-distribution = "homebrew"}
+  ["libvirt-dev"] {os-distribution = "alpine"}
+  ["libvirt"] {os-distribution = "nixos"}
+  ["libvirt"] {os-distribution = "arch"}
+]
-- 
2.25.2





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux