Passage à dune
This commit is contained in:
parent
760c0b26e4
commit
3448741682
3
dune-project
Normal file
3
dune-project
Normal file
@ -0,0 +1,3 @@
|
||||
(lang dune 1.0)
|
||||
(name libusb)
|
||||
(version 2018-07-12-1)
|
32
lib/dune
Normal file
32
lib/dune
Normal file
@ -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}))
|
||||
)
|
7
lib/generator/dune
Normal file
7
lib/generator/dune
Normal file
@ -0,0 +1,7 @@
|
||||
(executable
|
||||
(name generator)
|
||||
(libraries ctypes.stubs)
|
||||
(flags -w "-9")
|
||||
)
|
||||
|
||||
(copy_files stubs/{t,my_types}.ml)
|
@ -1,6 +0,0 @@
|
||||
(executable(
|
||||
(name generator)
|
||||
(libraries (ctypes.stubs))
|
||||
))
|
||||
|
||||
(copy_files stubs/{t,my_types}.ml)
|
9
lib/generator/stubs/c_types_generator/dune
Normal file
9
lib/generator/stubs/c_types_generator/dune
Normal file
@ -0,0 +1,9 @@
|
||||
(executable
|
||||
(name c_types_generator)
|
||||
(libraries ctypes.stubs)
|
||||
)
|
||||
|
||||
(rule
|
||||
(targets t.ml)
|
||||
(action (copy ../t.ml t.ml))
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
(executable(
|
||||
(name c_types_generator)
|
||||
(libraries (ctypes.stubs))
|
||||
))
|
||||
|
||||
(rule(
|
||||
(targets (t.ml))
|
||||
(action (copy ../t.ml t.ml))
|
||||
))
|
4
lib/generator/stubs/ctypes_cflags_generator/dune
Normal file
4
lib/generator/stubs/ctypes_cflags_generator/dune
Normal file
@ -0,0 +1,4 @@
|
||||
(executable
|
||||
(name ctypes_cflags_generator)
|
||||
(libraries findlib)
|
||||
)
|
@ -1,4 +0,0 @@
|
||||
(executable(
|
||||
(name ctypes_cflags_generator)
|
||||
(libraries (findlib))
|
||||
))
|
36
lib/generator/stubs/dune
Normal file
36
lib/generator/stubs/dune
Normal file
@ -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)))
|
||||
)
|
@ -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)))
|
||||
))
|
4
lib/generator/stubs/libusb_cflags_generator/dune
Normal file
4
lib/generator/stubs/libusb_cflags_generator/dune
Normal file
@ -0,0 +1,4 @@
|
||||
(executable
|
||||
(name libusb_cflags_generator)
|
||||
(libraries dune.configurator)
|
||||
)
|
@ -1,4 +0,0 @@
|
||||
(executable(
|
||||
(name libusb_cflags_generator)
|
||||
(libraries (configurator))
|
||||
))
|
@ -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"
|
||||
|
30
lib/jbuild
30
lib/jbuild
@ -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 ${<}))
|
||||
))
|
@ -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
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
opam-version: "1.2"
|
||||
version: "2018-06-24-1"
|
||||
version: "2018-07-12-1"
|
||||
maintainer: "Matthieu Dubuget <matthieu.dubuget@gmail.com>"
|
||||
authors: "Matthieu Dubuget <matthieu.dubuget@gmail.com>"
|
||||
|
||||
@ -7,15 +7,13 @@ homepage: "none"
|
||||
bug-reports: "Matthieu Dubuget <matthieu.dubuget@gmail.com>"
|
||||
|
||||
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}
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user