From 715f9424de1c7a6e5a317fa599377acaca4095ea Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 1 Jun 2021 16:53:12 +0200 Subject: [PATCH 1/3] build with dune Signed-off-by: Olaf Hering --- config/discover.ml | 21 +++++++++++++++++++++ config/dune | 3 +++ dune | 17 +++++++++++++++++ dune-project | 25 +++++++++++++++++++++++++ zip.opam | 22 ++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 config/discover.ml create mode 100644 config/dune create mode 100644 dune create mode 100644 dune-project create mode 100644 zip.opam diff --git a/config/discover.ml b/config/discover.ml new file mode 100644 index 0000000..04fc75b --- /dev/null +++ b/config/discover.ml @@ -0,0 +1,21 @@ +module C = Configurator.V1 + +let () = +C.main ~name:"zip" (fun c -> + +let stale_gzip : C.Pkg_config.package_conf = { + libs = [ "-lz" ]; + cflags = [] +} in + +let conf = + match C.Pkg_config.get c with + | None -> C.die "'pkg-config' missing" + | Some pc -> + match (C.Pkg_config.query pc ~package:"zlib") with + | None -> stale_gzip + | Some deps -> deps + in + + C.Flags.write_sexp "c_flags.sexp" conf.cflags; + C.Flags.write_sexp "c_library_flags.sexp" conf.libs) diff --git a/config/dune b/config/dune new file mode 100644 index 0000000..21a5f9a --- /dev/null +++ b/config/dune @@ -0,0 +1,3 @@ +(executable + (name discover) + (libraries dune.configurator)) diff --git a/dune b/dune new file mode 100644 index 0000000..6cbe8d0 --- /dev/null +++ b/dune @@ -0,0 +1,17 @@ +(library + (public_name zip) + (synopsis "OCaml ZIP interface") + (wrapped false) + (modules gzip zip zlib) + (c_names zlibstubs) + (c_flags + (:include c_flags.sexp)) + (c_library_flags + (:include c_library_flags.sexp))) + +(rule + (targets c_flags.sexp c_library_flags.sexp) + (deps + (:discover config/discover.exe)) + (action + (run %{discover}))) diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..93ac475 --- /dev/null +++ b/dune-project @@ -0,0 +1,25 @@ +(lang dune 1.10) + +(generate_opam_files true) + +(license "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception") + +(authors "Xavier Leroy") + +(maintainers "Cryptosense ") + +(homepage "https://github.com/xavierleroy/camlzip") + +(bug_reports "https://github.com/xavierleroy/camlzip/issues") + +(package + (name zip) + (synopsis + "Provides easy access to compressed files in ZIP, GZIP and JAR format") + (description "Reading and writing zip and gzip files from OCaml.") + (depends + dune-configurator + dune + conf-zlib + (ocaml + (>= 4.02.0)))) diff --git a/zip.opam b/zip.opam new file mode 100644 index 0000000..94858e2 --- /dev/null +++ b/zip.opam @@ -0,0 +1,22 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} +] +maintainer: ["Cryptosense "] +authors: ["Xavier Leroy"] +bug-reports: "https://github.com/xavierleroy/camlzip/issues" +homepage: "https://github.com/xavierleroy/camlzip" +license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" +synopsis: + "Provides easy access to compressed files in ZIP, GZIP and JAR format" +description: "Reading and writing zip and gzip files from OCaml." +depends: [ + "dune-configurator" + "dune" + "conf-zlib" + "ocaml" {>= "4.02.0"} +] From fd6960d4a6cc3e6a20f3a85d076bbcf18d032b3c Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 1 Jun 2021 16:53:14 +0200 Subject: [PATCH 2/3] update gitignore for dune Signed-off-by: Olaf Hering --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c1fe288..fc9cd6e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ *.so *.cmt *.cmti +.merlin +config/.merlin test/minigzip test/minizip test/testzlib From 485620c9cc7b33e4fe45b13df52ea2fba3f6baf9 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 1 Jun 2021 16:53:16 +0200 Subject: [PATCH 3/3] replace Pervasives with stdlib-shims Signed-off-by: Olaf Hering --- dune | 1 + dune-project | 1 + zip.opam | 1 + 3 files changed, 3 insertions(+) diff --git a/dune b/dune index 6cbe8d0..78489d2 100644 --- a/dune +++ b/dune @@ -3,6 +3,7 @@ (synopsis "OCaml ZIP interface") (wrapped false) (modules gzip zip zlib) + (libraries stdlib-shims) (c_names zlibstubs) (c_flags (:include c_flags.sexp)) diff --git a/dune-project b/dune-project index 93ac475..b9afc80 100644 --- a/dune-project +++ b/dune-project @@ -20,6 +20,7 @@ (depends dune-configurator dune + stdlib-shims conf-zlib (ocaml (>= 4.02.0)))) diff --git a/zip.opam b/zip.opam index 94858e2..cfa78cb 100644 --- a/zip.opam +++ b/zip.opam @@ -17,6 +17,7 @@ description: "Reading and writing zip and gzip files from OCaml." depends: [ "dune-configurator" "dune" + "stdlib-shims" "conf-zlib" "ocaml" {>= "4.02.0"} ]