Passage à dune

This commit is contained in:
Matthieu Dubuget
2018-07-12 17:08:54 +02:00
parent 760c0b26e4
commit 3448741682
17 changed files with 100 additions and 98 deletions

7
lib/generator/dune Normal file
View File

@ -0,0 +1,7 @@
(executable
(name generator)
(libraries ctypes.stubs)
(flags -w "-9")
)
(copy_files stubs/{t,my_types}.ml)

View File

@ -1,6 +0,0 @@
(executable(
(name generator)
(libraries (ctypes.stubs))
))
(copy_files stubs/{t,my_types}.ml)

View File

@ -0,0 +1,9 @@
(executable
(name c_types_generator)
(libraries ctypes.stubs)
)
(rule
(targets t.ml)
(action (copy ../t.ml t.ml))
)

View File

@ -1,9 +0,0 @@
(executable(
(name c_types_generator)
(libraries (ctypes.stubs))
))
(rule(
(targets (t.ml))
(action (copy ../t.ml t.ml))
))

View File

@ -0,0 +1,4 @@
(executable
(name ctypes_cflags_generator)
(libraries findlib)
)

View File

@ -1,4 +0,0 @@
(executable(
(name ctypes_cflags_generator)
(libraries (findlib))
))

36
lib/generator/stubs/dune Normal file
View 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)))
)

View File

@ -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)))
))

View File

@ -0,0 +1,4 @@
(executable
(name libusb_cflags_generator)
(libraries dune.configurator)
)

View File

@ -1,4 +0,0 @@
(executable(
(name libusb_cflags_generator)
(libraries (configurator))
))

View File

@ -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"