From 321cebb92038c41dbb0a0e9b0ecc577bbbabaf9e Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Sun, 9 Apr 2017 14:36:45 -0500 Subject: [PATCH] Packaging: factor out packages to lessen depopts This is a breaking change. Originally set in motion in #301. --- _oasis | 6 +++ doc/lwt_glib.descr | 1 - doc/lwt_react.descr | 1 - doc/lwt_ssl.descr | 1 - doc/lwt.descr => opam/descr | 0 {src/util => opam/files}/lwt.install | 2 +- lwt.opam => opam/opam | 8 ---- src/glib/META | 3 -- src/glib/_oasis | 25 ++++++++++++ src/glib/lwt_glib_stubs.c | 2 +- src/glib/myocamlbuild.ml | 60 ++++++++++++++++++++++++++++ lwt_glib.opam => src/glib/opam | 17 +++++--- src/react/META | 3 -- src/react/_oasis | 20 ++++++++++ lwt_react.opam => src/react/opam | 14 +++++-- src/ssl/META | 3 -- src/ssl/_oasis | 20 ++++++++++ lwt_ssl.opam => src/ssl/opam | 15 +++++-- 18 files changed, 166 insertions(+), 35 deletions(-) delete mode 100644 doc/lwt_glib.descr delete mode 100644 doc/lwt_react.descr delete mode 100644 doc/lwt_ssl.descr rename doc/lwt.descr => opam/descr (100%) rename {src/util => opam/files}/lwt.install (69%) rename lwt.opam => opam/opam (91%) delete mode 100644 src/glib/META create mode 100644 src/glib/_oasis create mode 100644 src/glib/myocamlbuild.ml rename lwt_glib.opam => src/glib/opam (64%) delete mode 100644 src/react/META create mode 100644 src/react/_oasis rename lwt_react.opam => src/react/opam (70%) delete mode 100644 src/ssl/META create mode 100644 src/ssl/_oasis rename lwt_ssl.opam => src/ssl/opam (69%) diff --git a/_oasis b/_oasis index 8a90c56bbf..a970cf8cdc 100644 --- a/_oasis +++ b/_oasis @@ -199,6 +199,8 @@ Library "lwt-simple-top" BuildDepends: lwt, lwt.unix, compiler-libs.common XMETADescription: Lwt-OCaml top level integration (deprecated; use utop) +# This library is built through this build system only in development. For the +# release build system, see src/react/_oasis. Library "lwt-react" Build$: flag(react) || flag(all) Install$: flag(react) || flag(all) @@ -219,6 +221,8 @@ Library "lwt-preemptive" BuildDepends: lwt, lwt.unix, threads XMETADescription: Preemptive thread support for Lwt +# This library is built through this build system only in development. For the +# release build system, see src/glib/_oasis. Library "lwt-glib" Build$: flag(glib) || flag(all) Install$: flag(glib) || flag(all) @@ -230,6 +234,8 @@ Library "lwt-glib" BuildDepends: lwt, lwt.unix XMETADescription: GLib integration for Lwt (deprecated; use package lwt_glib) +# This library is built through this build system only in development. For the +# release build system, see src/ssl/_oasis. Library "lwt-ssl" Build$: flag(ssl) || flag(all) Install$: flag(ssl) || flag(all) diff --git a/doc/lwt_glib.descr b/doc/lwt_glib.descr deleted file mode 100644 index 63f52e5afb..0000000000 --- a/doc/lwt_glib.descr +++ /dev/null @@ -1 +0,0 @@ -GLib integration for Lwt diff --git a/doc/lwt_react.descr b/doc/lwt_react.descr deleted file mode 100644 index c313b9ac02..0000000000 --- a/doc/lwt_react.descr +++ /dev/null @@ -1 +0,0 @@ -Helpers for using React with Lwt diff --git a/doc/lwt_ssl.descr b/doc/lwt_ssl.descr deleted file mode 100644 index fc6c583d95..0000000000 --- a/doc/lwt_ssl.descr +++ /dev/null @@ -1 +0,0 @@ -Lwt-friendly OpenSSL bindings diff --git a/doc/lwt.descr b/opam/descr similarity index 100% rename from doc/lwt.descr rename to opam/descr diff --git a/src/util/lwt.install b/opam/files/lwt.install similarity index 69% rename from src/util/lwt.install rename to opam/files/lwt.install index bdf849695e..d88814c3cd 100644 --- a/src/util/lwt.install +++ b/opam/files/lwt.install @@ -1,4 +1,4 @@ -lib: "lwt.opam" { "opam" } +lib: "opam/opam" { "opam" } doc: [ "README.md" "CHANGES" diff --git a/lwt.opam b/opam/opam similarity index 91% rename from lwt.opam rename to opam/opam index 1c3698c058..d33d262e01 100644 --- a/lwt.opam +++ b/opam/opam @@ -21,11 +21,8 @@ build: [ "--prefix" prefix "--%{conf-libev:enable}%-libev" "--%{camlp4:enable}%-camlp4" - "--%{react:enable}%-react" - "--%{ssl:enable}%-ssl" "--%{base-unix:enable}%-unix" "--%{base-threads:enable}%-preemptive" - "--%{lablgtk:enable}%-glib" "--%{ppx_tools:enable}%-ppx"] [make "build"] ] @@ -50,13 +47,8 @@ depopts: [ "base-unix" "conf-libev" "camlp4" - "ssl" - "lablgtk" - "react" ] conflicts: [ - "react" {< "1.0.0"} - "ssl" {< "0.5.0"} "ppx_tools" {< "1.0.0" } ] available: [ocaml-version >= "4.02.0" & compiler != "4.02.1+BER"] diff --git a/src/glib/META b/src/glib/META deleted file mode 100644 index dd2f7e001d..0000000000 --- a/src/glib/META +++ /dev/null @@ -1,3 +0,0 @@ -version = "1.0.0" -description = "GLib integration for Lwt" -requires = "lwt.glib" diff --git a/src/glib/_oasis b/src/glib/_oasis new file mode 100644 index 0000000000..3c3f3da57b --- /dev/null +++ b/src/glib/_oasis @@ -0,0 +1,25 @@ +# This is only for generating the release build system for this package. In +# development, the main Lwt build system is used. + +# To generate, run +# oasis setup -setup-update none + +OASISFormat: 0.4 +OCamlVersion: >= 4.02 +Name: lwt_glib +Version: 1.0.1 +Synopsis: GLib integration for Lwt +Authors: Jérémie Dimino +License: LGPL-2.1 +Plugins: DevFiles (0.4), META (0.4) + +AlphaFeatures: ocamlbuild_more_args +XOCamlbuildPluginTags: use_str + +Library lwt_glib + Path: . + BuildTools: ocamlbuild + Modules: Lwt_glib + CSources: lwt_glib_stubs.c + BuildDepends: lwt.unix + XMETADescription: GLib integration for Lwt diff --git a/src/glib/lwt_glib_stubs.c b/src/glib/lwt_glib_stubs.c index 3a469df778..9698d94434 100644 --- a/src/glib/lwt_glib_stubs.c +++ b/src/glib/lwt_glib_stubs.c @@ -31,7 +31,7 @@ #include #include -#include "../unix/lwt_unix.h" +extern void *lwt_unix_malloc(size_t size); GMainContext *gc; GPollFD *gpollfds = NULL; diff --git a/src/glib/myocamlbuild.ml b/src/glib/myocamlbuild.ml new file mode 100644 index 0000000000..ecb96cb316 --- /dev/null +++ b/src/glib/myocamlbuild.ml @@ -0,0 +1,60 @@ +(* OASIS_START *) +(* OASIS_STOP *) + +(* This is largely based on the Glib-related code in the main build system, + though rewritten somewhat. *) + +let split = + let regexp = Str.regexp " +" in + fun s -> Str.split regexp s + +(* Runs pkg-config with the given arguments. *) +let pkg_config arguments = + let command = Printf.sprintf "pkg-config %s" arguments in + let input_channel = Unix.open_process_in command in + let result = + try Pervasives.input_line input_channel + with End_of_file -> "" + in + let status = Unix.close_process_in input_channel in + match status with + | Unix.WEXITED 0 -> split result + | _ -> + Printf.eprintf "Command failed: %s" command; + exit 1 + +(* Loads values from setup.data. In particular, this build needs to check + whether ccomp_type, as detected by configure, is "msvc". *) +let env = + BaseEnvLight.load + ~allow_empty:true + ~filename:(Pathname.basename BaseEnvLight.default_filename) + () + +let () = + dispatch begin fun hook -> + dispatch_default hook; + + match hook with + | After_rules -> + (* Get compiler and linker options using pkg-config. *) + let cflags = pkg_config "--cflags glib-2.0" in + let libs = + let ccomp_type = BaseEnvLight.var_get "ccomp_type" env in + if ccomp_type = "msvc" then + pkg_config "--libs-only-L glib-2.0" @ + pkg_config "--libs-only-l --msvc_syntax glib-2.0" + else + pkg_config "--libs glib-2.0" + in + + (* Forward compiler and linker options to Ocamlbuild. *) + flag ["ocamlmklib"; "c"] @@ + S (List.map (fun s -> A s) libs); + flag ["compile"; "c"] @@ + S (List.map (fun s -> S [A "-ccopt"; A s]) cflags); + flag ["link"; "ocaml"] @@ + S (List.map (fun s -> S [A "-cclib"; A s]) libs); + + | _ -> () + end diff --git a/lwt_glib.opam b/src/glib/opam similarity index 64% rename from lwt_glib.opam rename to src/glib/opam index 2ac264d74f..081165bc23 100644 --- a/lwt_glib.opam +++ b/src/glib/opam @@ -1,7 +1,9 @@ opam-version: "1.2" name: "lwt_glib" -version: "dev" -maintainer: "Anton Bachin " +version: "1.0.1" +maintainer: [ + "Anton Bachin " +] authors: [ "Jérémie Dimino" ] @@ -10,13 +12,18 @@ doc: "https://ocsigen.org/lwt/manual/" dev-repo: "https://github.com/ocsigen/lwt.git" bug-reports: "https://github.com/ocsigen/lwt/issues" license: "LGPL with OpenSSL linking exception" +build: [ + [make "configure"] + [make "build"] +] install: [ - ["ocamlfind" "install" "lwt_glib" "src/glib/META"] + [make "install"] ] remove: [ ["ocamlfind" "remove" "lwt_glib"] ] depends: [ - "lwt" {= "dev"} - "lablgtk" + "lwt" {>= "3.0.0"} + "base-unix" + "conf-pkg-config" {build} ] diff --git a/src/react/META b/src/react/META deleted file mode 100644 index 3ba9590513..0000000000 --- a/src/react/META +++ /dev/null @@ -1,3 +0,0 @@ -version = "1.0.0" -description = "Reactive programming helpers for Lwt" -requires = "lwt.react" diff --git a/src/react/_oasis b/src/react/_oasis new file mode 100644 index 0000000000..4ac1217b08 --- /dev/null +++ b/src/react/_oasis @@ -0,0 +1,20 @@ +# This is only for generating the release build system for this package. In +# development, the main Lwt build system is used. + +# To generate, run +# oasis setup -setup-update none + +OASISFormat: 0.4 +Name: lwt_react +Version: 1.0.1 +Synopsis: Helpers for using React with Lwt +Authors: Jérémie Dimino +License: LGPL-2.1 +Plugins: DevFiles (0.4), META (0.4) + +Library lwt_react + Path: . + BuildTools: ocamlbuild + Modules: Lwt_react + BuildDepends: lwt, react + XMETADescription: Helpers for using React with Lwt diff --git a/lwt_react.opam b/src/react/opam similarity index 70% rename from lwt_react.opam rename to src/react/opam index d014442796..d88ae46f63 100644 --- a/lwt_react.opam +++ b/src/react/opam @@ -1,7 +1,9 @@ opam-version: "1.2" name: "lwt_react" -version: "dev" -maintainer: "Anton Bachin " +version: "1.0.1" +maintainer: [ + "Anton Bachin " +] authors: [ "Jérémie Dimino" ] @@ -10,13 +12,17 @@ doc: "https://ocsigen.org/lwt/manual/" dev-repo: "https://github.com/ocsigen/lwt.git" bug-reports: "https://github.com/ocsigen/lwt/issues" license: "LGPL with OpenSSL linking exception" +build: [ + [make "configure"] + [make "build"] +] install: [ - ["ocamlfind" "install" "lwt_react" "src/react/META"] + [make "install"] ] remove: [ ["ocamlfind" "remove" "lwt_react"] ] depends: [ - "lwt" {= "dev"} + "lwt" {>= "3.0.0"} "react" {>= "1.0.0"} ] diff --git a/src/ssl/META b/src/ssl/META deleted file mode 100644 index 80c936246e..0000000000 --- a/src/ssl/META +++ /dev/null @@ -1,3 +0,0 @@ -version = "1.0.0" -description = "SSL support for Lwt" -requires = "lwt.ssl" diff --git a/src/ssl/_oasis b/src/ssl/_oasis new file mode 100644 index 0000000000..fa393dedf2 --- /dev/null +++ b/src/ssl/_oasis @@ -0,0 +1,20 @@ +# This is only for generating the release build system for this package. In +# development, the main Lwt build system is used. + +# To generate, run +# oasis setup -setup-update none + +OASISFormat: 0.4 +Name: lwt_ssl +Version: 1.0.1 +Synopsis: Lwt-friendly OpenSSL bindings +Authors: Jérémie Dimino +License: LGPL-2.1 +Plugins: DevFiles (0.4), META (0.4) + +Library lwt_ssl + Path: . + BuildTools: ocamlbuild + Modules: Lwt_ssl + BuildDepends: lwt.unix, ssl + XMETADescription: Lwt-friendly OpenSSL bindings diff --git a/lwt_ssl.opam b/src/ssl/opam similarity index 69% rename from lwt_ssl.opam rename to src/ssl/opam index 187001fb3a..c6a5dbe675 100644 --- a/lwt_ssl.opam +++ b/src/ssl/opam @@ -1,7 +1,9 @@ opam-version: "1.2" name: "lwt_ssl" -version: "dev" -maintainer: "Anton Bachin " +version: "1.0.1" +maintainer: [ + "Anton Bachin " +] authors: [ "Jérôme Vouillon" "Jérémie Dimino" @@ -11,13 +13,18 @@ doc: "https://ocsigen.org/lwt/manual/" dev-repo: "https://github.com/ocsigen/lwt.git" bug-reports: "https://github.com/ocsigen/lwt/issues" license: "LGPL with OpenSSL linking exception" +build: [ + [make "configure"] + [make "build"] +] install: [ - ["ocamlfind" "install" "lwt_ssl" "src/ssl/META"] + [make "install"] ] remove: [ ["ocamlfind" "remove" "lwt_ssl"] ] depends: [ - "lwt" {= "dev"} + "lwt" {>= "3.0.0"} "ssl" {>= "0.5.0"} + "base-unix" ]