Skip to content

Commit

Permalink
test(ctypes): showcase deps field not supporting the full dependency …
Browse files Browse the repository at this point in the history
…specification

Signed-off-by: Louis Roché (Ahrefs) <[email protected]>
  • Loading branch information
Khady committed Feb 5, 2025
1 parent 26d680d commit d3790ba
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 0 deletions.
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(executable
(name example)
(flags (:standard -w -9-27))
(ctypes
(external_library_name libexample)
(build_flags_resolver pkg_config)
(deps (:foo_h "foo.h") (:bar_h bar.h) baz.h)
(headers (include "example.h"))
(type_description
(instance Types)
(functor Type_description))
(function_description
(instance Functions)
(functor Function_description))
(generated_entry_point C)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(lang dune 3.8)

(using ctypes 0.3)

(use_standard_c_and_cxx_flags false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let () =
Printf.printf "%d\n" (C.Functions.add2 2)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
open Ctypes

module Types = Types_generated

module Functions (F : Ctypes.FOREIGN) = struct
open F
let add2 = foreign "example_add2" (int @-> returning int)
end
14 changes: 14 additions & 0 deletions test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Build an example library as a DLL and set up the environment so that it looks
like a system/distro library that can be probed with pkg-config and dynamically
loaded.

Then generate cstubs for it, build an executable that uses those cstubs, and
run the executable that tests the library through the cstubs.

$ LIBEX=$(realpath "$PWD/../libexample")
$ DYLD_LIBRARY_PATH="$LIBEX" LD_LIBRARY_PATH="$LIBEX" PKG_CONFIG_PATH="$LIBEX/pkgconfig" PKG_CONFIG_ARGN="--define-prefix" dune exec ./example.exe
File "dune", line 7, characters 8-24:
7 | (deps (:foo_h "foo.h") (:bar_h bar.h) baz.h)
^^^^^^^^^^^^^^^^
Error: Unexpected list
[1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Types (F : Ctypes.TYPE) = struct

end

0 comments on commit d3790ba

Please sign in to comment.