Skip to content

Commit dc97e58

Browse files
committed
test(ctypes): showcase deps field not supporting the full dependency specification
1 parent 26d680d commit dc97e58

File tree

9 files changed

+47
-0
lines changed

9 files changed

+47
-0
lines changed

test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/bar.h

Whitespace-only changes.

test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/baz.h

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(executable
2+
(name example)
3+
(flags (:standard -w -9-27))
4+
(ctypes
5+
(external_library_name libexample)
6+
(build_flags_resolver pkg_config)
7+
(deps (:foo_h "foo.h") (:bar_h bar.h) baz.h)
8+
(headers (include "example.h"))
9+
(type_description
10+
(instance Types)
11+
(functor Type_description))
12+
(function_description
13+
(instance Functions)
14+
(functor Function_description))
15+
(generated_entry_point C)))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(lang dune 3.8)
2+
3+
(using ctypes 0.3)
4+
5+
(use_standard_c_and_cxx_flags false)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let () =
2+
Printf.printf "%d\n" (C.Functions.add2 2)

test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/foo.h

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
open Ctypes
2+
3+
module Types = Types_generated
4+
5+
module Functions (F : Ctypes.FOREIGN) = struct
6+
open F
7+
let add2 = foreign "example_add2" (int @-> returning int)
8+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Build an example library as a DLL and set up the environment so that it looks
2+
like a system/distro library that can be probed with pkg-config and dynamically
3+
loaded.
4+
5+
Then generate cstubs for it, build an executable that uses those cstubs, and
6+
run the executable that tests the library through the cstubs.
7+
8+
$ LIBEX=$(realpath "$PWD/../libexample")
9+
$ DYLD_LIBRARY_PATH="$LIBEX" LD_LIBRARY_PATH="$LIBEX" PKG_CONFIG_PATH="$LIBEX/pkgconfig" PKG_CONFIG_ARGN="--define-prefix" dune exec ./example.exe
10+
File "dune", line 7, characters 8-24:
11+
7 | (deps (:foo_h "foo.h") (:bar_h bar.h) baz.h)
12+
^^^^^^^^^^^^^^^^
13+
Error: Unexpected list
14+
[1]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Types (F : Ctypes.TYPE) = struct
2+
3+
end

0 commit comments

Comments
 (0)