Skip to content

Commit

Permalink
Packaging: factor out packages to lessen depopts
Browse files Browse the repository at this point in the history
This is a breaking change. Originally set in motion in #301.
  • Loading branch information
aantron committed Apr 9, 2017
1 parent a05be1e commit 321cebb
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 35 deletions.
6 changes: 6 additions & 0 deletions _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand 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)
Expand 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)
Expand Down
1 change: 0 additions & 1 deletion doc/lwt_glib.descr

This file was deleted.

1 change: 0 additions & 1 deletion doc/lwt_react.descr

This file was deleted.

1 change: 0 additions & 1 deletion doc/lwt_ssl.descr

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/util/lwt.install → opam/files/lwt.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib: "lwt.opam" { "opam" }
lib: "opam/opam" { "opam" }
doc: [
"README.md"
"CHANGES"
Expand Down
8 changes: 0 additions & 8 deletions lwt.opam → opam/opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
]
Expand All @@ -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"]
Expand Down
3 changes: 0 additions & 3 deletions src/glib/META

This file was deleted.

25 changes: 25 additions & 0 deletions src/glib/_oasis
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/glib/lwt_glib_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <caml/callback.h>
#include <glib.h>

#include "../unix/lwt_unix.h"
extern void *lwt_unix_malloc(size_t size);

GMainContext *gc;
GPollFD *gpollfds = NULL;
Expand Down
60 changes: 60 additions & 0 deletions src/glib/myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 12 additions & 5 deletions lwt_glib.opam → src/glib/opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
opam-version: "1.2"
name: "lwt_glib"
version: "dev"
maintainer: "Anton Bachin <[email protected]>"
version: "1.0.1"
maintainer: [
"Anton Bachin <[email protected]>"
]
authors: [
"Jérémie Dimino"
]
Expand All @@ -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}
]
3 changes: 0 additions & 3 deletions src/react/META

This file was deleted.

20 changes: 20 additions & 0 deletions src/react/_oasis
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions lwt_react.opam → src/react/opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
opam-version: "1.2"
name: "lwt_react"
version: "dev"
maintainer: "Anton Bachin <[email protected]>"
version: "1.0.1"
maintainer: [
"Anton Bachin <[email protected]>"
]
authors: [
"Jérémie Dimino"
]
Expand All @@ -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"}
]
3 changes: 0 additions & 3 deletions src/ssl/META

This file was deleted.

20 changes: 20 additions & 0 deletions src/ssl/_oasis
Original file line number Diff line number Diff line change
@@ -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
15 changes: 11 additions & 4 deletions lwt_ssl.opam → src/ssl/opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
opam-version: "1.2"
name: "lwt_ssl"
version: "dev"
maintainer: "Anton Bachin <[email protected]>"
version: "1.0.1"
maintainer: [
"Anton Bachin <[email protected]>"
]
authors: [
"Jérôme Vouillon"
"Jérémie Dimino"
Expand All @@ -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"
]

0 comments on commit 321cebb

Please sign in to comment.