Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch build system to Dune #10

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
_build/
*.native
*.byte
*.install
logs-syslog.install
src/**/.merlin

example/mirage-unikernel-*.opam
example/.mirage.config
Expand All @@ -15,4 +14,4 @@ example/syslog*
*.key
*.pem
*.csr
certs/
certs/
8 changes: 0 additions & 8 deletions .merlin

This file was deleted.

14 changes: 0 additions & 14 deletions _tags

This file was deleted.

6 changes: 0 additions & 6 deletions doc/api.odocl

This file was deleted.

2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.1)
(name logs-syslog)
14 changes: 2 additions & 12 deletions opam → logs-syslog.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ license: "ISC"
available: [ ocaml-version >= "4.03.0"]

depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"topkg" {build}
"dune" {>= "1.1.0" & build}
"logs"
"ptime"
"syslog-message" {>= "0.0.2"}
Expand All @@ -30,12 +28,4 @@ conflicts: [
"tls" {< "0.8.0"}
]

build: [
[ "ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%"
"--with-lwt" "%{lwt:installed}%"
"--with-lwt-tls" "%{lwt+x509+tls+cstruct:installed}%"
"--with-mirage" "%{lwt+mirage-stack-lwt+mirage-console-lwt+mirage-clock+cstruct+ipaddr:installed}%"
"--with-mirage-tls" "%{lwt+mirage-kv-lwt+x509+tls+mirage-stack-lwt+mirage-console-lwt+mirage-clock+cstruct+ipaddr:installed}%"
]
]

build: [ "dune" "build" "-p" name "-j" jobs ]
63 changes: 0 additions & 63 deletions pkg/META

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/pkg.ml

This file was deleted.

16 changes: 16 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(env
(_ (flags -w +A-4-44 -safe-string -principal)))

(library
(name logs_syslog)
(public_name logs-syslog)
(synopsis "Emit logs via syslog")
(libraries logs syslog-message ptime)
(modules logs_syslog))

(library
(name logs_syslog_unix)
(public_name logs-syslog.unix)
(synopsis "Unix syslog reporter")
(libraries logs-syslog ptime.clock.os unix)
(modules logs_syslog_unix))
1 change: 0 additions & 1 deletion src/logs-syslog-lwt-tls.mllib

This file was deleted.

2 changes: 0 additions & 2 deletions src/logs-syslog-lwt.mllib

This file was deleted.

1 change: 0 additions & 1 deletion src/logs-syslog-mirage-tls.mllib

This file was deleted.

2 changes: 0 additions & 2 deletions src/logs-syslog-mirage.mllib

This file was deleted.

1 change: 0 additions & 1 deletion src/logs-syslog-unix.mllib

This file was deleted.

1 change: 0 additions & 1 deletion src/logs-syslog.mllib

This file was deleted.

6 changes: 6 additions & 0 deletions src/lwt-tls/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name logs_syslog_lwt_tls)
(public_name logs-syslog.lwt.tls)
(synopsis "Lwt TLS syslog reporter")
(libraries logs-syslog.lwt x509 tls tls.lwt cstruct)
(optional))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Lwt.Infix
open Logs_syslog_lwt_common
open Logs_syslog_lwt__Logs_syslog_lwt_common
open Logs_syslog

let tcp_tls_reporter
Expand All @@ -24,17 +24,17 @@ let tcp_tls_reporter
Tls_lwt.Unix.client_of_fd conf sock >|= fun t ->
tls := Some t ;
Ok ())
(fun exn ->
Lwt.return @@ match exn with
(function
| Unix.Unix_error (e, f, _) ->
let err =
Printf.sprintf "error %s in function %s while connecting to %s:%d"
(Unix.error_message e) f (Unix.string_of_inet_addr ip) port
in
Error err
Lwt.return @@ Error err
| Tls_lwt.Tls_failure f ->
let err = Tls.Engine.string_of_failure f in
Error (Printf.sprintf "TLS failure %s" err))
Lwt.return @@ Error (Printf.sprintf "TLS failure %s" err)
| exn -> Lwt.fail exn)
in
let reconnect k msg =
Lwt_mutex.lock m >>= fun () ->
Expand Down Expand Up @@ -73,7 +73,8 @@ let tcp_tls_reporter
Lwt.catch
(fun () -> Tls_lwt.Unix.close t)
(fun _ -> Lwt.return_unit) >>= fun () ->
reconnect send omsg)
reconnect send omsg
| exn -> Lwt.fail exn)
in
at_exit (fun () -> match !tls with
| None -> ()
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions src/lwt/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name logs_syslog_lwt)
(public_name logs-syslog.lwt)
(synopsis "Lwt syslog reporter")
(libraries logs-syslog ptime.clock.os lwt lwt.unix)
(optional))

(rule (copy ../logs_syslog_lwt_common.mli logs_syslog_lwt_common.mli))
(rule (copy ../logs_syslog_lwt_common.ml logs_syslog_lwt_common.ml))
12 changes: 8 additions & 4 deletions src/logs_syslog_lwt.ml → src/lwt/logs_syslog_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let udp_reporter ?hostname ip ?(port = 514) ?(truncate = 65535) ?facility () =
f (Unix.error_message e) (Unix.string_of_inet_addr ip) port
(Ptime.to_rfc3339 (Ptime_clock.now ()))
msg ;
Lwt.return_unit)
Lwt.return_unit
| exn -> Lwt.fail exn)
in
(match hostname with
| Some x -> Lwt.return x
Expand All @@ -40,7 +41,8 @@ let tcp_reporter ?hostname ip ?(port = 514) ?(truncate = 0) ?(framing = `Null) ?
Printf.sprintf "error %s in function %s while connecting to %s:%d"
(Unix.error_message e) f (Unix.string_of_inet_addr ip) port
in
Lwt.return (Error err))
Lwt.return (Error err)
| exn -> Lwt.fail exn)
in
let reconnect k msg =
Lwt_mutex.lock m >>= fun () ->
Expand Down Expand Up @@ -73,8 +75,10 @@ let tcp_reporter ?hostname ip ?(port = 514) ?(truncate = 0) ?(framing = `Null) ?
Printf.eprintf "error %s in function %s, reconnecting\n" err f ;
Lwt.catch
(fun () -> Lwt_unix.close sock)
(function Unix.Unix_error _ -> Lwt.return_unit) >>= fun () ->
reconnect send omsg >|= fun () -> should)) >>= fun n ->
(function Unix.Unix_error _ -> Lwt.return_unit
| exn -> Lwt.fail exn) >>= fun () ->
reconnect send omsg >|= fun () -> should
| exn -> Lwt.fail exn)) >>= fun n ->
if n = should then
Lwt.return_unit
else
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/mirage-tls/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name logs_syslog_mirage_tls)
(public_name logs-syslog.mirage.tls)
(synopsis "Mirage TLS syslog reporter")
(libraries logs-syslog.mirage x509 tls tls.mirage mirage-kv-lwt)
(optional))
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Tls (C : Mirage_console_lwt.S) (CLOCK : Mirage_clock.PCLOCK) (STACK : Mir
in
connect () >|= function
| Ok () ->
Ok (Logs_syslog_lwt_common.syslog_report_common
Ok (Logs_syslog_mirage__Logs_syslog_lwt_common.syslog_report_common
facility
hostname
truncate
Expand Down
9 changes: 9 additions & 0 deletions src/mirage/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name logs_syslog_mirage)
(public_name logs-syslog.mirage)
(synopsis "Mirage syslog reporter")
(libraries logs-syslog ipaddr lwt mirage-console-lwt mirage-clock mirage-stack-lwt cstruct)
(optional))

(rule (copy ../logs_syslog_lwt_common.mli logs_syslog_lwt_common.mli))
(rule (copy ../logs_syslog_lwt_common.ml logs_syslog_lwt_common.ml))
File renamed without changes.
File renamed without changes.