diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..4049bb7 --- /dev/null +++ b/dune-project @@ -0,0 +1,3 @@ +(lang dune 1.0) +(name libusb) +(version 2018-07-12-1) \ No newline at end of file diff --git a/jbuild-workspace b/dune-workspace similarity index 100% rename from jbuild-workspace rename to dune-workspace diff --git a/lib/dune b/lib/dune new file mode 100644 index 0000000..e563b98 --- /dev/null +++ b/lib/dune @@ -0,0 +1,32 @@ +(library + (name libusb) + (public_name libusb) + (flags -w "-9") + (libraries ctypes) + (c_names cstub_libusb) + (c_flags (:include libusb_cflags_and_no_discarded_qualifiers)) + (c_library_flags -lusb-1.0) +) + +(rule + (targets libusb_cflags_and_no_discarded_qualifiers) + (deps generator/stubs/libusb_cflags) + (action + (with-stdout-to %{targets} + (progn (echo "(") + (cat %{deps}) + (echo " -Wno-discarded-qualifiers") + (echo ")") + ) + ) + ) +) + +(copy_files generator/g.ml) +(copy_files generator/stubs/{t,my_types}.ml) + +(rule + (targets cstub_libusb.c bindings.ml) + (deps generator/generator.exe) + (action (run %{deps})) +) diff --git a/lib/generator/dune b/lib/generator/dune new file mode 100644 index 0000000..a2539d6 --- /dev/null +++ b/lib/generator/dune @@ -0,0 +1,7 @@ +(executable + (name generator) + (libraries ctypes.stubs) + (flags -w "-9") +) + +(copy_files stubs/{t,my_types}.ml) diff --git a/lib/generator/jbuild b/lib/generator/jbuild deleted file mode 100644 index a16878a..0000000 --- a/lib/generator/jbuild +++ /dev/null @@ -1,6 +0,0 @@ -(executable( - (name generator) - (libraries (ctypes.stubs)) -)) - -(copy_files stubs/{t,my_types}.ml) diff --git a/lib/generator/stubs/c_types_generator/dune b/lib/generator/stubs/c_types_generator/dune new file mode 100644 index 0000000..3616eb3 --- /dev/null +++ b/lib/generator/stubs/c_types_generator/dune @@ -0,0 +1,9 @@ +(executable + (name c_types_generator) + (libraries ctypes.stubs) +) + +(rule + (targets t.ml) + (action (copy ../t.ml t.ml)) +) diff --git a/lib/generator/stubs/c_types_generator/jbuild b/lib/generator/stubs/c_types_generator/jbuild deleted file mode 100644 index 73fd296..0000000 --- a/lib/generator/stubs/c_types_generator/jbuild +++ /dev/null @@ -1,9 +0,0 @@ -(executable( - (name c_types_generator) - (libraries (ctypes.stubs)) -)) - -(rule( - (targets (t.ml)) - (action (copy ../t.ml t.ml)) -)) diff --git a/lib/generator/stubs/ctypes_cflags_generator/dune b/lib/generator/stubs/ctypes_cflags_generator/dune new file mode 100644 index 0000000..76aa174 --- /dev/null +++ b/lib/generator/stubs/ctypes_cflags_generator/dune @@ -0,0 +1,4 @@ +(executable + (name ctypes_cflags_generator) + (libraries findlib) +) diff --git a/lib/generator/stubs/ctypes_cflags_generator/jbuild b/lib/generator/stubs/ctypes_cflags_generator/jbuild deleted file mode 100644 index 9da5cb8..0000000 --- a/lib/generator/stubs/ctypes_cflags_generator/jbuild +++ /dev/null @@ -1,4 +0,0 @@ -(executable( - (name ctypes_cflags_generator) - (libraries (findlib)) -)) diff --git a/lib/generator/stubs/dune b/lib/generator/stubs/dune new file mode 100644 index 0000000..4c8f4bb --- /dev/null +++ b/lib/generator/stubs/dune @@ -0,0 +1,36 @@ +(rule + (targets my_types.ml) + (deps my_types_generator.exe) + (action (with-stdout-to %{targets} (run %{deps}))) +) + +(rule + (targets my_types_generator.exe) + (deps my_types_generator.c) + (action (run %{cc} + -o %{targets} + %{read:libusb_cflags} + %{read:ctypes_cflags} + -I%{ocaml-config:standard_library} + %{deps})) +) + +(rule + (targets my_types_generator.c) + (action (with-stdout-to %{targets} + (run c_types_generator/c_types_generator.exe))) +) + +(rule + (targets ctypes_cflags) + (action + (with-stdout-to %{targets} + (run ctypes_cflags_generator/ctypes_cflags_generator.exe))) +) + +(rule + (targets libusb_cflags) + (action + (with-stdout-to %{targets} + (run libusb_cflags_generator/libusb_cflags_generator.exe))) +) diff --git a/lib/generator/stubs/jbuild b/lib/generator/stubs/jbuild deleted file mode 100644 index 10e3725..0000000 --- a/lib/generator/stubs/jbuild +++ /dev/null @@ -1,36 +0,0 @@ -(rule( - (targets (my_types.ml)) - (deps (my_types_generator.exe)) - (action (with-stdout-to ${@} (run ${<}))) -)) - -(rule( - (targets (my_types_generator.exe)) - (deps (my_types_generator.c)) - (action (run ${CC} - -o ${@} - ${read:libusb_cflags} - ${read:ctypes_cflags} - -I${ocaml-config:standard_library} - ${<})) -)) - -(rule( - (targets (my_types_generator.c)) - (action - (with-stdout-to ${@} - (run c_types_generator/c_types_generator.exe) - )) -)) - -(rule( - (targets (ctypes_cflags)) - (action (with-stdout-to ${@} - (run ctypes_cflags_generator/ctypes_cflags_generator.exe))) -)) - -(rule( - (targets (libusb_cflags)) - (action (with-stdout-to ${@} - (run libusb_cflags_generator/libusb_cflags_generator.exe))) -)) diff --git a/lib/generator/stubs/libusb_cflags_generator/dune b/lib/generator/stubs/libusb_cflags_generator/dune new file mode 100644 index 0000000..48efc07 --- /dev/null +++ b/lib/generator/stubs/libusb_cflags_generator/dune @@ -0,0 +1,4 @@ +(executable + (name libusb_cflags_generator) + (libraries dune.configurator) +) diff --git a/lib/generator/stubs/libusb_cflags_generator/jbuild b/lib/generator/stubs/libusb_cflags_generator/jbuild deleted file mode 100644 index 10f79c1..0000000 --- a/lib/generator/stubs/libusb_cflags_generator/jbuild +++ /dev/null @@ -1,4 +0,0 @@ -(executable( - (name libusb_cflags_generator) - (libraries (configurator)) -)) diff --git a/lib/generator/stubs/libusb_cflags_generator/libusb_cflags_generator.ml b/lib/generator/stubs/libusb_cflags_generator/libusb_cflags_generator.ml index c6367b6..e06c786 100644 --- a/lib/generator/stubs/libusb_cflags_generator/libusb_cflags_generator.ml +++ b/lib/generator/stubs/libusb_cflags_generator/libusb_cflags_generator.ml @@ -1,11 +1,11 @@ let (>>|) a f = match a with None -> None | Some a -> f a let libusb_c_flags = - let open Configurator in + let open Configurator.V1 in create "c" |> Pkg_config.get >>| Pkg_config.query ~package:"libusb-1.0" - >>| (fun Pkg_config.{cflags} -> + >>| (fun Pkg_config.{cflags;_} -> Some (String.concat " " cflags)) |> (function | None -> "libusb flag not found" diff --git a/lib/jbuild b/lib/jbuild deleted file mode 100644 index 1052b6b..0000000 --- a/lib/jbuild +++ /dev/null @@ -1,30 +0,0 @@ -(library( - (name libusb) - (public_name libusb) - (libraries (ctypes)) - (c_names (cstub_libusb)) - (c_flags (:include libusb_cflags_and_no_discarded_qualifiers)) - (c_library_flags (-lusb-1.0)) -)) - -(rule( - (targets (libusb_cflags_and_no_discarded_qualifiers)) - (deps (generator/stubs/libusb_cflags)) - (action (with-stdout-to ${@} - (progn - (echo "(") - (cat ${<}) - (echo " -Wno-discarded-qualifiers") - (echo ")") - ) - )) -)) - -(copy_files generator/g.ml) -(copy_files generator/stubs/{t,my_types}.ml) - -(rule( - (targets (cstub_libusb.c bindings.ml)) - (deps (generator/generator.exe)) - (action (run ${<})) -)) diff --git a/lib/libusb.mli b/lib/libusb.mli index f86855a..72f3e03 100644 --- a/lib/libusb.mli +++ b/lib/libusb.mli @@ -8,8 +8,6 @@ - in order to experiment more in depth with {{:https://github.com/ocamllabs/ocaml-ctypes} Ctypes}; - and because I needed something more portable than {{:https://github.com/letoh/ocaml-usb} ocaml-usb}: this one is working on Windows. *) - -open Ctypes include module type of T diff --git a/libusb.opam b/libusb.opam index ef3b7a1..a114ee5 100644 --- a/libusb.opam +++ b/libusb.opam @@ -1,5 +1,5 @@ opam-version: "1.2" -version: "2018-06-24-1" +version: "2018-07-12-1" maintainer: "Matthieu Dubuget " authors: "Matthieu Dubuget " @@ -7,15 +7,13 @@ homepage: "none" bug-reports: "Matthieu Dubuget " build: [ - ["jbuilder" "subst" "-n" name] {pinned} - [ "jbuilder" "build" "-p" name "-j" jobs ] + [ "dune" "build" "-p" name "-j" jobs ] ] license: "Not yet decided" depends: [ - "jbuilder" {build & >= "1.0+beta13"} + "dune" {build} "ctypes" {build} - "configurator" {build} "ocamlfind" {build} ]