Skip to content

Commit f948d25

Browse files
committed
B0ify.
Closes #38.
1 parent 9a54227 commit f948d25

File tree

12 files changed

+210
-85
lines changed

12 files changed

+210
-85
lines changed

.merlin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PKG fmt fmt.tty fmt.cli js_of_ocaml mtime.clock.os lwt
1+
PKG b0.kit fmt fmt.tty fmt.cli js_of_ocaml-compiler.runtime mtime.clock.os lwt
22
S src
33
S test
4-
B _build/**
4+
B _b0/**

B0.ml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
open B0_kit.V000
2+
open B00_std
3+
4+
(* OCaml library names *)
5+
6+
let mtime = B0_ocaml.libname "mtime"
7+
let mtime_clock_os = B0_ocaml.libname "mtime.clock.os"
8+
let unix = B0_ocaml.libname "unix"
9+
let threads = B0_ocaml.libname "threads.posix"
10+
let cmdliner = B0_ocaml.libname "cmdliner"
11+
let fmt = B0_ocaml.libname "fmt"
12+
let fmt_tty = B0_ocaml.libname "fmt.tty"
13+
let fmt_cli = B0_ocaml.libname "fmt.cli"
14+
let lwt = B0_ocaml.libname "lwt"
15+
let lwt_unix = B0_ocaml.libname "lwt.unix"
16+
let js_of_ocaml_compiler_runtime =
17+
B0_ocaml.libname "js_of_ocaml-compiler.runtime"
18+
19+
let logs = B0_ocaml.libname "logs"
20+
let logs_fmt = B0_ocaml.libname "logs.fmt"
21+
let logs_browser = B0_ocaml.libname "logs.browser"
22+
let logs_cli = B0_ocaml.libname "logs.cli"
23+
let logs_lwt = B0_ocaml.libname "logs.lwt"
24+
let logs_threaded = B0_ocaml.libname "logs.threaded"
25+
26+
(* Libraries *)
27+
28+
let mod_srcs m =
29+
let mli = Fmt.str "src/%s.mli" m and ml = Fmt.str "src/%s.ml" m in
30+
Fpath.[ `File (v mli); `File (v ml) ]
31+
32+
let logs_lib =
33+
let srcs = mod_srcs "logs" in
34+
B0_ocaml.lib logs ~doc:"The logs library" ~srcs ~requires:[]
35+
36+
let logs_fmt_lib =
37+
let srcs = mod_srcs "logs_fmt" in
38+
let requires = [logs; fmt] in
39+
B0_ocaml.lib logs_fmt ~doc:"The logs.fmt library" ~srcs ~requires
40+
41+
let logs_browser_lib =
42+
let srcs = mod_srcs "logs_browser" in
43+
let requires = [logs; js_of_ocaml_compiler_runtime] in
44+
B0_ocaml.lib logs_browser ~doc:"The logs.browser library" ~srcs ~requires
45+
46+
let logs_threaded_lib =
47+
let srcs = mod_srcs "logs_threaded" in
48+
let requires = [logs; threads] in
49+
B0_ocaml.lib logs_threaded ~doc:"The logs.threaded library" ~srcs ~requires
50+
51+
let logs_cli_lib =
52+
let srcs = mod_srcs "logs_cli" in
53+
let requires = [logs; cmdliner] in
54+
B0_ocaml.lib logs_cli ~doc:"The logs.cli library" ~srcs ~requires
55+
56+
let logs_lwt_lib =
57+
let srcs = mod_srcs "logs_lwt" in
58+
let requires = [logs; lwt] in
59+
B0_ocaml.lib logs_lwt ~doc:"The logs.lwt library" ~srcs ~requires
60+
61+
(* Tools *)
62+
63+
(* Tests *)
64+
65+
let test ?doc base ~requires =
66+
let srcs = Fpath.[`File (v (Fmt.str "test/%s.ml" base))] in
67+
B0_ocaml.exe base ?doc ~srcs ~requires
68+
69+
let test_fmt = test "test_fmt" ~requires:[logs; logs_fmt; fmt_tty]
70+
let test_tool =
71+
let requires = [logs; logs_fmt; logs_cli; fmt_cli; fmt_tty; cmdliner] in
72+
test "tool" ~requires
73+
74+
let test_tags = test "tags" ~requires:[logs; mtime; mtime_clock_os]
75+
let test_formatter = test "test_formatter" ~requires:[logs]
76+
let test_multi = test "test_multi" ~requires:[logs; logs_fmt; fmt_tty]
77+
let test_threaded =
78+
let requires = [logs; logs_fmt; logs_threaded; threads] in
79+
test "test_threaded" ~requires
80+
81+
let test_lwt =
82+
let requires = [logs; logs_fmt; logs_lwt; fmt; fmt_tty; lwt; lwt_unix] in
83+
test "test_lwt" ~requires
84+
85+
(* Packs *)
86+
87+
let default =
88+
let meta =
89+
let open B0_meta in
90+
empty
91+
|> add authors ["The logs programmers"]
92+
|> add maintainers ["Daniel Bünzli <daniel.buenzl [email protected]>"]
93+
|> add homepage "https://erratique.ch/software/logs"
94+
|> add online_doc "https://erratique.ch/software/logs/doc"
95+
|> add licenses ["ISC"]
96+
|> add repo "git+https://erratique.ch/repos/logs.git"
97+
|> add issues "https://github.com/dbuenzli/logs/issues"
98+
|> add description_tags ["log"; "system"; "org:erratique"; ]
99+
|> add B0_opam.Meta.build
100+
{|[["ocaml" "pkg/pkg.ml" "build" "--dev-pkg" "%{dev}%"
101+
"--with-js_of_ocaml" "%{js_of_ocaml:installed}%"
102+
"--with-fmt" "%{fmt:installed}%"
103+
"--with-cmdliner" "%{cmdliner:installed}%"
104+
"--with-lwt" "%{lwt:installed}%"
105+
"--with-base-threads" "%{base-threads:installed}%"]]|}
106+
|> add B0_opam.Meta.depopts ["cmdliner", "";
107+
"js_of_ocaml", "";
108+
"fmt", "";
109+
"lwt", "";
110+
"base-threads", ""]
111+
|> add B0_opam.Meta.conflicts [
112+
"cmdliner", {|< "1.1.0"|};
113+
"js_of_ocaml", {|< "4.0.0"|};
114+
"fmt", {|< "0.9.0"|}; ]
115+
|> add B0_opam.Meta.depends
116+
[ "ocaml", {|>= "4.08.0"|};
117+
"ocamlfind", {|build|};
118+
"ocamlbuild", {|build|};
119+
"topkg", {|build & >= "1.0.3"|};
120+
"mtime", {|with-test|};]
121+
|> tag B0_opam.tag
122+
in
123+
B0_pack.v "default" ~doc:"logs package" ~meta ~locked:true @@
124+
B0_unit.list ()

BRZO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(srcs-x tmp pkg)

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
3+
* Requires OCaml >= 4.08, Cmdliner >= 1.1.0, Fmt >= 0.9.0
4+
and js_of_ocaml-compiler >= 4.0.0
5+
* Depend on the `js_of_ocaml-compiler.runtime` library rather than
6+
`js_of_ocaml`.
7+
18
v0.7.0 2019-08-09 Zagreb
29
------------------------
310

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ instructions.
4040

4141
The documentation can be consulted [online][doc] or via `odig doc logs`.
4242

43+
Questions are welcome but better asked on the [OCaml forum][ocaml-forum]
44+
than on the issue tracker.
45+
46+
[doc]: https://erratique.ch/software/logs/doc
47+
[ocaml-forum]: https://discuss.ocaml.org/
48+
49+
4350
[doc]: http://erratique.ch/software/logs/doc/
4451

4552
## Sample programs

_tags

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ true : bin_annot, safe_string
22
<_b0> : -traverse
33
<src> : include
44
<src/logs_fmt*> : package(fmt)
5-
<src/logs_browser*> : package(js_of_ocaml)
5+
<src/logs_browser*> : package(js_of_ocaml-compiler.runtime)
66
<src/logs_cli*> : package(cmdliner)
77
<src/logs_lwt*> : package(lwt)
88
<src/logs_top*> : package(compiler-libs.toplevel)
@@ -13,7 +13,7 @@ true : bin_annot, safe_string
1313
<test/test_fmt*> : package(fmt), package(fmt.tty)
1414
<test/test_browser*> : package(fmt), package(js_of_ocaml)
1515
<test/test_lwt*> : package(lwt), package(lwt.unix), package(fmt), \
16-
package(fmt.tty)
16+
package(fmt.tty), thread, package(threads)
1717
<test/tags*> : package(mtime.clock.os)
1818
<test/test_multi*> : package(fmt), package(fmt.tty)
1919
<test/test_threaded*> : thread, package(threads), package(fmt)

build

Lines changed: 0 additions & 44 deletions
This file was deleted.

opam

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,65 @@
11
opam-version: "2.0"
2+
name: "logs"
3+
synopsis: "Logging infrastructure for OCaml"
4+
description: """\
5+
Logs provides a logging infrastructure for OCaml. Logging is performed
6+
on sources whose reporting level can be set independently. Log message
7+
report is decoupled from logging and is handled by a reporter.
8+
9+
A few optional log reporters are distributed with the base library and
10+
the API easily allows to implement your own.
11+
12+
`Logs` has no dependencies. The optional `Logs_fmt` reporter on OCaml
13+
formatters depends on [Fmt][fmt]. The optional `Logs_browser`
14+
reporter that reports to the web browser console depends on
15+
[js_of_ocaml][jsoo]. The optional `Logs_cli` library that provides
16+
command line support for controlling Logs depends on
17+
[`Cmdliner`][cmdliner]. The optional `Logs_lwt` library that provides
18+
Lwt logging functions depends on [`Lwt`][lwt]
19+
20+
Logs and its reporters are distributed under the ISC license.
21+
22+
[fmt]: http://erratique.ch/software/fmt
23+
[jsoo]: http://ocsigen.org/js_of_ocaml/
24+
[cmdliner]: http://erratique.ch/software/cmdliner
25+
[lwt]: http://ocsigen.org/lwt/
26+
27+
Home page: http://erratique.ch/software/logs"""
228
maintainer: "Daniel Bünzli <daniel.buenzl [email protected]>"
3-
authors: ["The logs programmers"]
29+
authors: "The logs programmers"
30+
license: "ISC"
31+
tags: ["log" "system" "org:erratique"]
432
homepage: "https://erratique.ch/software/logs"
533
doc: "https://erratique.ch/software/logs/doc"
6-
dev-repo: "git+https://erratique.ch/repos/logs.git"
734
bug-reports: "https://github.com/dbuenzli/logs/issues"
8-
tags: [ "log" "system" "org:erratique" ]
9-
license: "ISC"
1035
depends: [
11-
"ocaml" {>= "4.03.0"}
36+
"ocaml" {>= "4.08.0"}
1237
"ocamlfind" {build}
1338
"ocamlbuild" {build}
14-
"topkg" {build}
15-
"mtime" {with-test} ]
16-
depopts: [
17-
"js_of_ocaml"
18-
"fmt"
19-
"cmdliner" {>= "1.0.4."}
20-
"lwt"
21-
"base-threads"
39+
"topkg" {build & >= "1.0.3"}
40+
"mtime" {with-test}
2241
]
42+
depopts: ["cmdliner" "js_of_ocaml" "fmt" "lwt" "base-threads"]
2343
conflicts: [
24-
"js_of_ocaml" { < "3.3.0" } ]
25-
26-
build: [[
27-
"ocaml" "pkg/pkg.ml" "build"
28-
"--pinned" "%{pinned}%"
29-
"--with-js_of_ocaml" "%{js_of_ocaml:installed}%"
30-
"--with-fmt" "%{fmt:installed}%"
31-
"--with-cmdliner" "%{cmdliner:installed}%"
32-
"--with-lwt" "%{lwt:installed}%"
33-
"--with-base-threads" "%{base-threads:installed}%"
34-
]]
44+
"cmdliner" {< "1.1.0"}
45+
"js_of_ocaml" {< "4.0.0"}
46+
"fmt" {< "0.9.0"}
47+
]
48+
build: [
49+
"ocaml"
50+
"pkg/pkg.ml"
51+
"build"
52+
"--dev-pkg"
53+
"%{dev}%"
54+
"--with-js_of_ocaml"
55+
"%{js_of_ocaml:installed}%"
56+
"--with-fmt"
57+
"%{fmt:installed}%"
58+
"--with-cmdliner"
59+
"%{cmdliner:installed}%"
60+
"--with-lwt"
61+
"%{lwt:installed}%"
62+
"--with-base-threads"
63+
"%{base-threads:installed}%"
64+
]
65+
dev-repo: "git+https://erratique.ch/repos/logs.git"

pkg/META

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package "fmt" (
2020
package "browser" (
2121
description = "Browser console reporter for Logs"
2222
version = "%%VERSION_NUM%%"
23-
requires = "logs js_of_ocaml"
23+
requires = "logs js_of_ocaml-compiler.runtime"
2424
archive(byte) = "logs_browser.cma"
2525
archive(native) = "logs_browser.cmxa"
2626
plugin(byte) = "logs_browser.cma"

src/logs_browser.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
(* Console reporter *)
77

8-
open Js_of_ocaml
8+
open Jsoo_runtime
99

10-
let console_obj = Js.Unsafe.variable "console"
10+
let console_obj = Js.pure_js_expr "console"
1111
let console : Logs.level -> string -> unit =
1212
fun level s ->
1313
let meth = match level with
@@ -17,7 +17,7 @@ fun level s ->
1717
| Logs.Debug -> "debug"
1818
| Logs.App -> "log"
1919
in
20-
Js.Unsafe.meth_call console_obj meth [| Js.Unsafe.inject (Js.string s) |]
20+
ignore (Js.meth_call console_obj meth [| Js.string s |])
2121

2222
let ppf, flush =
2323
let b = Buffer.create 255 in

0 commit comments

Comments
 (0)