Skip to content

Commit

Permalink
port ctypes-foreign to use virtual modules
Browse files Browse the repository at this point in the history
This turns ctypes-foreign.threaded/unthreaded into variant
libraries that implement the `foreign.mli` that is exposed
by the ctypes_foreign library.

The Makefile infrastructure did this by duplicating foreign.mli
and using -no-keep-locs.  The dune-based approach is a bit more
high-level as it verifies that there is no extra module leakage
aside from the virtual modules' cmi that are exposed.

Also add ppx_bisect conditionally while in here.
  • Loading branch information
avsm committed Jan 1, 2019
1 parent 262665b commit 25ec72a
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 108 deletions.
4 changes: 2 additions & 2 deletions ctypes.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ homepage: "https://github.com/ocamllabs/ocaml-ctypes"
bug-reports: "http://github.com/ocamllabs/ocaml-ctypes/issues"
pin-depends: [
[ "integers.dev" "git+http://github.com/yallop/ocaml-integers.git" ]
[ "dune.dev" "git+http://github.com/ocaml/dune.git" ]
[ "dune.dev" "git+http://github.com/Chris00/dune.git" ]
]
depends: [
"ocaml" {>= "4.02.3"}
"integers"
"bisect_ppx"
"dune" {build}
"conf-pkg-config" {build}
"lwt" {with-test & < "4.0.0"}
"ounit" {with-test}
"conf-ncurses" {with-test}
]
depopts: [
"bisect_ppx" {with-test}
"ocveralls" {with-test}
]
build: [
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 1.0)
(name ctypes)
(lang dune 1.7)
(name ctypes)
2 changes: 1 addition & 1 deletion examples/date/foreign/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executables
(names date)
(libraries ctypes-foreign))
(libraries ctypes-foreign.threaded))
2 changes: 1 addition & 1 deletion examples/fts/foreign/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executables
(names fts_cmd)
(libraries ctypes-foreign))
(libraries ctypes-foreign.threaded))
2 changes: 1 addition & 1 deletion examples/ncurses/foreign/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name ncurses)
(c_library_flags -lncurses)
(modules ncurses)
(libraries ctypes-foreign))
(libraries ctypes-foreign.threaded))

(executables
(names ncurses_cmd)
Expand Down
1 change: 1 addition & 0 deletions src/cstubs/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(library
(name ctypes_stubs)
(public_name ctypes.stubs)
(preprocess (pps bisect_ppx -conditional))
(wrapped false)
(libraries ctypes str))
1 change: 1 addition & 0 deletions src/ctypes-foreign-base/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
(library
(name ctypes_foreign_base)
(public_name ctypes-foreign.base)
(preprocess (pps bisect_ppx -conditional))
(wrapped false)
(libraries ctypes)
(c_library_flags (:include c_library_flags.sexp))
Expand Down
6 changes: 4 additions & 2 deletions src/ctypes-foreign-threaded/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(library
(name ctypes_foreign_threaded)
(public_name ctypes-foreign.threaded)
(wrapped false)
(libraries ctypes ctypes-foreign.base threads)
(preprocess (pps bisect_ppx -conditional))
(libraries ctypes threads)
(private_modules Ctypes_foreign_threaded_stubs)
(implements ctypes_foreign)
(c_names foreign_threaded_stubs))
6 changes: 4 additions & 2 deletions src/ctypes-foreign-unthreaded/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(library
(name ctypes_foreign_unthreaded)
(public_name ctypes-foreign.unthreaded)
(wrapped false)
(libraries ctypes ctypes-foreign.base))
(private_modules ctypes_gc_mutex)
(preprocess (pps bisect_ppx -conditional))
(implements ctypes-foreign)
(libraries ctypes))
95 changes: 0 additions & 95 deletions src/ctypes-foreign-unthreaded/foreign.mli

This file was deleted.

5 changes: 3 additions & 2 deletions src/ctypes-foreign/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(library
(name ctypes_foreign)
(public_name ctypes-foreign)
;; TODO below needed until https://github.com/ocaml/dune/issues/1724 is resolved
(libraries ctypes-foreign.threaded))
(wrapped false)
(libraries ctypes-foreign.base)
(virtual_modules foreign))
File renamed without changes.
1 change: 1 addition & 0 deletions src/ctypes/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
(wrapped false)
(libraries bigarray bytes integers)
(modules_without_implementation ctypes_types)
(preprocess (pps bisect_ppx -conditional))
(install_c_headers
ctypes_raw_pointer
ctypes_primitives
Expand Down

0 comments on commit 25ec72a

Please sign in to comment.