Skip to content

Commit

Permalink
Merge pull request #2 from NathanReb/update-dune-port
Browse files Browse the repository at this point in the history
Update dune port
  • Loading branch information
NathanReb authored May 4, 2022
2 parents fcf035b + b8ea898 commit 9ec9e8f
Show file tree
Hide file tree
Showing 71 changed files with 160 additions and 62 deletions.
4 changes: 2 additions & 2 deletions ctypes-foreign.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ depends: [
"dune-configurator"
"conf-pkg-config"
"lwt" {with-test}
"ounit" {with-test}
"ounit2" {with-test}
"conf-ncurses" {with-test}
"stdlib-shims" {with-test}
"conf-fts" {with-test}
"conf-fts" {with-test & os != "win32"}
"odoc" {with-doc}
]
build: [
Expand Down
5 changes: 3 additions & 2 deletions ctypes.opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ depends: [
"integers"
"dune-configurator"
"bigarray-compat"
"ounit" {with-test}
"conf-fts" {with-test}
"ounit2" {with-test}
"conf-fts" {with-test & os != "win32"}
"conf-pkg-config" {with-test}
"odoc" {with-doc}
]
build: [
Expand Down
9 changes: 5 additions & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
integers
dune-configurator
bigarray-compat
(ounit :with-test)
(conf-fts :with-test))
(ounit2 :with-test)
(conf-fts (and :with-test (<> :os win32)))
(conf-pkg-config :with-test))
(synopsis "Combinators for binding to C libraries without writing any C")
(description "
ctypes is a library for binding to C libraries using pure OCaml. The primary
Expand Down Expand Up @@ -47,10 +48,10 @@ This will make the `ctypes-foreign` ocamlfind subpackage available."))
dune-configurator
conf-pkg-config
(lwt :with-test)
(ounit :with-test)
(ounit2 :with-test)
(conf-ncurses :with-test)
(stdlib-shims :with-test)
(conf-fts :with-test))
(conf-fts (and :with-test (<> :os win32))))
(synopsis "Dynamic access to foreign C libraries using Ctypes")
(description "
This installs the `ctypes-foreign` interface which
Expand Down
25 changes: 25 additions & 0 deletions examples/fts/stub-generation/config/discover.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module C = Configurator.V1

let prepend opt flags =
if flags = [] then
[]
else
opt :: flags

let () =
C.main ~name:"fts_example" (fun c ->
let default : C.Pkg_config.package_conf = {
libs = [];
cflags = []
} in
let conf =
match C.Pkg_config.get c with
| None -> default
| Some pc ->
(match C.Pkg_config.query pc ~package:"libfts" with
| None -> default
| Some v -> v)
in
C.Flags.write_sexp "c_flags.sexp" (prepend "-ccopt" conf.cflags);
C.Flags.write_sexp "c_library_flags.sexp" (prepend "-cclib" conf.libs)
)
1 change: 1 addition & 0 deletions examples/fts/stub-generation/config/discover.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(* empty *)
8 changes: 8 additions & 0 deletions examples/fts/stub-generation/config/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(executable
(name discover)
(libraries dune-configurator))

(rule
(targets c_flags.sexp c_library_flags.sexp)
(action
(run ./discover.exe)))
5 changes: 4 additions & 1 deletion examples/fts/stub-generation/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
(name fts_cmd)
(enabled_if
(= %{os_type} Unix))
(libraries fts_stubs fts_generated))
(libraries fts_stubs fts_generated)
(link_flags
:standard
(:include config/c_library_flags.sexp)))

(rule
(alias runtest)
Expand Down
5 changes: 4 additions & 1 deletion examples/fts/stub-generation/stub-generator/dune
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
(modules fts_generated)
(foreign_stubs
(language c)
(names fts_stubs))
(names fts_stubs)
(flags
:standard
(:include ../config/c_flags.sexp)))
(libraries ctypes.stubs))
15 changes: 15 additions & 0 deletions tests/clib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,18 @@
(names test_functions))
(c_library_flags -pthread)
(libraries ctypes))

(rule
(target clib%{ext_dll})
(deps (source_tree ../../src/ctypes) test_functions.h)
(action
(run
%{cc}
-I
../../src/ctypes
-I
%{ocaml_where}
-o
%{target}
-shared
%{dep:test_functions.c})))
2 changes: 1 addition & 1 deletion tests/test-alignment/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(test
(package ctypes-foreign)
(name test_alignment)
(libraries oUnit ctypes ctypes-foreign))
(libraries ounit2 ctypes ctypes-foreign))
3 changes: 2 additions & 1 deletion tests/test-arrays/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_array)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
1 change: 1 addition & 0 deletions tests/test-arrays/test_array.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
open OUnit2
open Ctypes

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

(*
Creating multidimensional arrays, and reading and writing elements.
Expand Down
3 changes: 2 additions & 1 deletion tests/test-bigarrays/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_bigarrays)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 2 additions & 0 deletions tests/test-bigarrays/test_bigarrays.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
module Std_array = Array
type 'a std_array = 'a array

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

open OUnit2
open Ctypes
module BA = Bigarray_compat
Expand Down
3 changes: 2 additions & 1 deletion tests/test-bools/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_bools)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 2 additions & 0 deletions tests/test-bools/test_bools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

open OUnit2

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
struct
Expand Down
2 changes: 1 addition & 1 deletion tests/test-builtins/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name test_builtins)
(package ctypes-foreign)
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
3 changes: 2 additions & 1 deletion tests/test-callback_lifetime/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_callback_lifetime)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
1 change: 1 addition & 0 deletions tests/test-callback_lifetime/test_callback_lifetime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
open OUnit2
open Foreign

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
Expand Down
3 changes: 2 additions & 1 deletion tests/test-closure-type-promotion/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_closure_type_promotion)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

open OUnit2

let _testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

(*
* Using the closure API of libffi is error prone due to differences
* in endianess and calling conventions.
Expand Down
2 changes: 1 addition & 1 deletion tests/test-coercions/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name test_coercions)
(package ctypes-foreign)
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
3 changes: 2 additions & 1 deletion tests/test-complex/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_complex)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 2 additions & 0 deletions tests/test-complex/test_complex.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
open OUnit2
open Ctypes

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
struct
Expand Down
3 changes: 2 additions & 1 deletion tests/test-constants/dune
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
(test
(name test_constants)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(modules test_constants)
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 1 addition & 1 deletion tests/test-constants/test_constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open OUnit2
open Ctypes


let testlib = Dl.(dlopen ~filename:"../clib/dlltest_functions_stubs.so" ~flags:[RTLD_NOW])
let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Constants = Types.Struct_stubs(Generated_struct_bindings)

Expand Down
2 changes: 1 addition & 1 deletion tests/test-cstdlib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name test_cstdlib)
(package ctypes-foreign)
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 1 addition & 1 deletion tests/test-custom_ops/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(test
(name test_custom_ops)
(libraries oUnit ctypes))
(libraries ounit2 ctypes))
2 changes: 1 addition & 1 deletion tests/test-enums/dune
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
(name test_enums)
(modules test_enums)
(package ctypes-foreign)
(libraries oUnit ctypes test_enums_generated test_enums_stubs))
(libraries ounit2 ctypes test_enums_generated test_enums_stubs))
2 changes: 1 addition & 1 deletion tests/test-finalisers/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(test
(name test_finalisers)
(libraries ctypes oUnit))
(libraries ctypes ounit2))
2 changes: 1 addition & 1 deletion tests/test-foreign-errno/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(test
(name test_errno)
(package ctypes-foreign)
(libraries oUnit ctypes ctypes-foreign))
(libraries ounit2 ctypes ctypes-foreign))
3 changes: 2 additions & 1 deletion tests/test-foreign_values/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_foreign_values)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
1 change: 1 addition & 0 deletions tests/test-foreign_values/test_foreign_values.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
open OUnit2
open Ctypes

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
Expand Down
3 changes: 2 additions & 1 deletion tests/test-higher_order/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_higher_order)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
1 change: 1 addition & 0 deletions tests/test-higher_order/test_higher_order.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

open OUnit2

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
Expand Down
3 changes: 2 additions & 1 deletion tests/test-integers/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(test
(name test_integers)
(package ctypes-foreign)
(deps ../clib/clib%{ext_dll})
(link_flags
(:include ../flags/link-flags.sexp))
(libraries
oUnit
ounit2
ctypes
ctypes.stubs
ctypes-foreign
Expand Down
2 changes: 2 additions & 0 deletions tests/test-integers/test_integers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ open OUnit2
open Ctypes
open Unsigned

let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])

module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a
and type 'a return = 'a) =
struct
Expand Down
Loading

0 comments on commit 9ec9e8f

Please sign in to comment.