From nobody Thu May 2 14:15:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1586859818; cv=none; d=zohomail.com; s=zohoarc; b=Ocpy96ORUHFo/igewqsMNMikFSsH2Xq3ETQuiKWYoKaC1E3HLHH9s9g3+0E+KziFCCtb9vlgVtisWqRvAtrIgdKQ5wgna3CMFyh4aOnOTURF1IH9uDZ9IXhdJNTQh8YbHTqg3AA/mQ3oudRxwdXnFxKGqHV7PuRZyptPt3yeGV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586859818; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JeZ6Dcks7LylVFMyrlRCMkCODDSuIjNfypuIHEryDC4=; b=Rbh4R6W2n15b10C2ChWcOrsQ9qWmtGZhdV+CxsenY3H8/fG7goyQDTIMrE96fUTlhfNaUZ901/mrwLXd63l3kY6dLlI8gWoINGyVxw/jqBMZ0b8od6GKUT3bTT91m/Jm1dR049k3vzyaGOTs3RtfOOxalTrrjWh0KrxoZ41tPvY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1586859818969294.0079863062791; Tue, 14 Apr 2020 03:23:38 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-Z2OePqkQOhO34awMqdPyJw-1; Tue, 14 Apr 2020 06:23:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E9A818C35B2; Tue, 14 Apr 2020 10:23:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF27F271B2; Tue, 14 Apr 2020 10:23:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5DE98934E3; Tue, 14 Apr 2020 10:23:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03EAMuLU022597 for ; Tue, 14 Apr 2020 06:22:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9256C11D2C1; Tue, 14 Apr 2020 10:22:56 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.40.192.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9A4A12650D; Tue, 14 Apr 2020 10:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586859817; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JeZ6Dcks7LylVFMyrlRCMkCODDSuIjNfypuIHEryDC4=; b=RVQmOMcnshf5680W3iGCCgePARKi28Ob1s1+R9bz9fcfjku8tMfcECbeHcelVu+qG5McEX VDxu0J09G4VKXse9hdqQSN7YcI6qac74kHVwTFLn9TlUsIW1DfWw1v50GNw8ztWZ7w6fyc QzQebkh7fecZ6EO6pLukLfWS6A3K/DY= X-MC-Unique: Z2OePqkQOhO34awMqdPyJw-1 From: Pino Toscano To: libvir-list@redhat.com Subject: [PATCH ocaml 1/1] Add dune build system Date: Tue, 14 Apr 2020 12:22:49 +0200 Message-Id: <20200414102249.3107835-2-ptoscano@redhat.com> In-Reply-To: <20200414102249.3107835-1-ptoscano@redhat.com> References: <20200414102249.3107835-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- .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 -sa= fe-string))) + (release + (flags (:standard -g -warn-error CDEFLMPSUVYZX-3 -w -9-27-34-37-50 -sa= fe-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-130= 1 USA +*) + +module C =3D Configurator.V1 + +let discover c =3D + let package =3D "libvirt" in + let minversion =3D "1.2.8" in + let expr =3D package ^ " >=3D " ^ minversion in + let pkgconfig =3D + match C.Pkg_config.get c with + | None -> C.die "pkg-config not available" + | Some pc -> pc in + let conf =3D + 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" =3D None then + C.die "perl not found" + +let () =3D + 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 " +maintainer: "Richard W.M. Jones " +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 =3D "debian"} + ["libvirt-devel"] {os-family =3D "rhel"} + ["libvirt-devel"] {os-family =3D "suse"} + ["libvirt-devel"] {os-distribution =3D "mageia"} + ["libvirt"] {os =3D "macos" & os-distribution =3D "homebrew"} + ["libvirt-dev"] {os-distribution =3D "alpine"} + ["libvirt"] {os-distribution =3D "nixos"} + ["libvirt"] {os-distribution =3D "arch"} +] --=20 2.25.2