Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the threaded/unthreaded split in ctypes-foreign. #651

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 36 additions & 41 deletions .depend

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ gen_libffi_abi.log
src/ctypes/ctypes_primitives.ml
src/ctypes_config.h
src/ctypes_config.ml
src/ctypes-foreign-base/dl_stubs.c
src/ctypes-foreign-base/dl.ml
src/ctypes-foreign/dl_stubs.c
src/ctypes-foreign/dl.ml
src/discover/commands.cm*
src/discover/discover.cm*
src/configure/extract_from_c.cm*
Expand Down
7 changes: 1 addition & 6 deletions .merlin
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@ S src/libffi-abigen
S src/discover
S src/ctypes
S src/ctypes-top
S src/ctypes-foreign-threaded
S src/configure
S src/ctypes-foreign-base
S src/ctypes-foreign
S src/ctypes-foreign-unthreaded
B _build
B _build/src
B _build/src/cstubs
B _build/src/libffi-abigen
B _build/src/ctypes
B _build/src/ctypes-top
B _build/src/ctypes-foreign-threaded
B _build/src/configure
B _build/src/ctypes-foreign-base
B _build/src/ctypes-foreign-unthreaded
B _build/src/ctypes-foreign
PKG bytes
PKG integers
41 changes: 6 additions & 35 deletions META
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,10 @@ package "stubs" (
package "foreign" (
version = "0.17.1"
description = "Dynamic linking of C functions"
requires(-mt) = "ctypes.foreign.unthreaded"
requires(mt) = "ctypes.foreign.threaded"

package "base" (
version = "0.17.1"
description = "Dynamic linking of C functions (base package)"
requires = "ctypes"
archive(byte) = "ctypes-foreign-base.cma"
archive(byte, plugin) = "ctypes-foreign-base.cma"
archive(native) = "ctypes-foreign-base.cmxa"
archive(native, plugin) = "ctypes-foreign-base.cmxs"
exists_if = "ctypes-foreign-base.cma"
)

package "threaded" (
version = "0.17.1"
description = "Dynamic linking of C functions (for use in threaded programs)"
requires = "threads ctypes ctypes.foreign.base"
archive(byte) = "ctypes-foreign-threaded.cma"
archive(byte, plugin) = "ctypes-foreign-threaded.cma"
archive(native) = "ctypes-foreign-threaded.cmxa"
archive(native, plugin) = "ctypes-foreign-threaded.cmxs"
exists_if = "ctypes-foreign-threaded.cma"
)

package "unthreaded" (
version = "0.17.1"
description = "Dynamic linking of C functions (for use in unthreaded programs)"
requires = "ctypes ctypes.foreign.base"
archive(byte) = "ctypes-foreign-unthreaded.cma"
archive(byte, plugin) = "ctypes-foreign-unthreaded.cma"
archive(native) = "ctypes-foreign-unthreaded.cmxa"
archive(native, plugin) = "ctypes-foreign-unthreaded.cmxs"
exists_if = "ctypes-foreign-unthreaded.cma"
)
requires = "threads ctypes"
archive(byte) = "ctypes-foreign.cma"
archive(byte, plugin) = "ctypes-foreign.cma"
archive(native) = "ctypes-foreign.cmxa"
archive(native, plugin) = "ctypes-foreign.cmxs"
exists_if = "ctypes-foreign.cma"
)
81 changes: 25 additions & 56 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ OCAMLMKLIB=$(OCAMLFIND) ocamlmklib
VPATH=src examples
BUILDDIR=_build
BASE_PROJECTS=configure libffi-abigen configured ctypes ctypes-top
FOREIGN_PROJECTS=test-libffi ctypes-foreign-base ctypes-foreign-threaded ctypes-foreign-unthreaded
FOREIGN_PROJECTS=test-libffi ctypes-foreign
STUB_PROJECTS=cstubs
PROJECTS=$(BASE_PROJECTS) $(FOREIGN_PROJECTS) $(STUB_PROJECTS)
DEP_DIRS=$(foreach project,$(PROJECTS),$($(project).dir))
GENERATED=src/ctypes/ctypes_primitives.ml \
src/ctypes-foreign-base/libffi_abi.ml \
src/ctypes-foreign-base/dl.ml \
src/ctypes-foreign-base/dl_stubs.c \
src/ctypes-foreign/libffi_abi.ml \
src/ctypes-foreign/dl.ml \
src/ctypes-foreign/dl_stubs.c \
libffi.config \
asneeded.config \
discover \
Expand Down Expand Up @@ -89,52 +89,23 @@ cstubs.extra_hs = $(package_integers_path)/ocaml_integers.h
cstubs: PROJECT=cstubs
cstubs: $(cstubs.dir)/$(cstubs.extra_mls) $$(LIB_TARGETS)

# ctypes-foreign-base subproject
ctypes-foreign-base.public = dl libffi_abi
ctypes-foreign-base.install = yes
ctypes-foreign-base.install_native_objects = yes
ctypes-foreign-base.threads = no
ctypes-foreign-base.dir = src/ctypes-foreign-base
ctypes-foreign-base.deps = integers
ctypes-foreign-base.subproject_deps = ctypes
ctypes-foreign-base.extra_mls = libffi_abi.ml dl.ml
ctypes-foreign-base.extra_cs = dl_stubs.c
ctypes-foreign-base.link_flags = $(libffi_lib) $(lib_process)
ctypes-foreign-base.cmo_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign-base.cmx_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)

ctypes-foreign-base: PROJECT=ctypes-foreign-base
ctypes-foreign-base: $$(LIB_TARGETS)

# ctypes-foreign-threaded subproject
ctypes-foreign-threaded.public = foreign
ctypes-foreign-threaded.install = yes
ctypes-foreign-threaded.threads = yes
ctypes-foreign-threaded.dir = src/ctypes-foreign-threaded
ctypes-foreign-threaded.subproject_deps = ctypes ctypes-foreign-base
ctypes-foreign-threaded.link_flags = $(libffi_lib) $(lib_process)
ctypes-foreign-threaded.cmo_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign-threaded.cmx_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign-threaded.cmi_opts = $(OPAQUE) $(NO_KEEP_LOCS)
ctypes-foreign-threaded.install_native_objects = no

ctypes-foreign-threaded: PROJECT=ctypes-foreign-threaded
ctypes-foreign-threaded: $$(LIB_TARGETS)

# ctypes-foreign-unthreaded subproject
ctypes-foreign-unthreaded.public = foreign
ctypes-foreign-unthreaded.install = yes
ctypes-foreign-unthreaded.threads = no
ctypes-foreign-unthreaded.dir = src/ctypes-foreign-unthreaded
ctypes-foreign-unthreaded.subproject_deps = ctypes ctypes-foreign-base
ctypes-foreign-unthreaded.link_flags = $(libffi_lib) $(lib_process)
ctypes-foreign-unthreaded.cmo_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign-unthreaded.cmx_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign-unthreaded.cmi_opts = $(OPAQUE) $(NO_KEEP_LOCS)
ctypes-foreign-unthreaded.install_native_objects = no

ctypes-foreign-unthreaded: PROJECT=ctypes-foreign-unthreaded
ctypes-foreign-unthreaded: $$(LIB_TARGETS)
# ctypes-foreign subproject
ctypes-foreign.public = dl libffi_abi foreign
ctypes-foreign.dir = src/ctypes-foreign
ctypes-foreign.subproject_deps = ctypes
ctypes-foreign.deps = integers
ctypes-foreign.install = yes
ctypes-foreign.install_native_objects = yes
ctypes-foreign.extra_cs = dl_stubs.c
ctypes-foreign.extra_mls = libffi_abi.ml dl.ml
ctypes-foreign.cmi_opts = $(OPAQUE) $(NO_KEEP_LOCS)
ctypes-foreign.cmo_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign.cmx_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %)
ctypes-foreign.link_flags = $(libffi_lib) $(lib_process)
ctypes-foreign.threads = yes

ctypes-foreign: PROJECT=ctypes-foreign
ctypes-foreign: $$(LIB_TARGETS)

# ctypes-top subproject
ctypes-top.public = ctypes_printers
Expand All @@ -148,18 +119,18 @@ ctypes-top: PROJECT=ctypes-top
ctypes-top: $$(LIB_TARGETS)

# configuration
configured: src/ctypes/ctypes_primitives.ml src/ctypes-foreign-base/libffi_abi.ml src/ctypes-foreign-base/dl.ml src/ctypes-foreign-base/dl_stubs.c
configured: src/ctypes/ctypes_primitives.ml src/ctypes-foreign/libffi_abi.ml src/ctypes-foreign/dl.ml src/ctypes-foreign/dl_stubs.c

src/ctypes-foreign-base/dl.ml: src/ctypes-foreign-base/dl.ml$(OS_ALT_SUFFIX)
src/ctypes-foreign/dl.ml: src/ctypes-foreign/dl.ml$(OS_ALT_SUFFIX)
cp $< $@
src/ctypes-foreign-base/dl_stubs.c: src/ctypes-foreign-base/dl_stubs.c$(OS_ALT_SUFFIX)
src/ctypes-foreign/dl_stubs.c: src/ctypes-foreign/dl_stubs.c$(OS_ALT_SUFFIX)
cp $< $@

src/ctypes/ctypes_primitives.ml: src/configure/extract_from_c.ml src/configure/gen_c_primitives.ml
$(HOSTOCAMLFIND) ocamlc -o gen_c_primitives -package str -strict-sequence -linkpkg $^ -I src/configure
./gen_c_primitives > $@ 2> gen_c_primitives.log || (rm $@ && cat gen_c_primitives.log || false)

src/ctypes-foreign-base/libffi_abi.ml: src/configure/extract_from_c.ml src/configure/gen_libffi_abi.ml
src/ctypes-foreign/libffi_abi.ml: src/configure/extract_from_c.ml src/configure/gen_libffi_abi.ml
$(HOSTOCAMLFIND) ocamlc -o gen_libffi_abi -package str -strict-sequence -linkpkg $^ -I src/configure
./gen_libffi_abi > $@ 2> gen_c_primitives.log || (rm $@ && cat gen_c_primitives.log || false)

Expand Down Expand Up @@ -199,8 +170,6 @@ DOCFILES=$(foreach project,$(PROJECTS),\
$(foreach mli,$($(project).public),\
$($(project).dir)/$(mli).mli))
DOCFLAGS=-I $(shell ocamlfind query integers) $(foreach project,$(PROJECTS),-I $(BUILDDIR)/$($(project).dir))
# Avoid passing duplicate interfaces to ocamldoc.
DOCFILES:=$(filter-out src/ctypes-foreign-threaded/foreign.mli,$(DOCFILES))

doc:
ocamldoc -html $(DOCFLAGS) $(DOCFILES)
Expand Down
22 changes: 14 additions & 8 deletions Makefile.examples
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
# subproject: fts with stub generation
fts-stubs.install = no
fts-stubs.dir = examples/fts/stub-generation/bindings
fts-stubs.threads = yes
fts-stubs.deps = integers
fts-stubs.subproject_deps = ctypes \
ctypes-foreign-base ctypes-foreign-unthreaded
fts-stubs.subproject_deps = ctypes ctypes-foreign
fts-stubs: PROJECT=fts-stubs
fts-stubs: $$(LIB_TARGETS)

fts-stub-generator.install = no
fts-stub-generator.dir = examples/fts/stub-generation/stub-generator
fts-stub-generator.threads = yes
fts-stub-generator.deps = integers
fts-stub-generator.subproject_deps = ctypes cstubs \
ctypes-foreign-base ctypes-foreign-unthreaded fts-stubs
ctypes-foreign fts-stubs
fts-stub-generator.deps = str unix bigarray integers
fts-stub-generator: PROJECT=fts-stub-generator
fts-stub-generator: $$(NATIVE_TARGET)

fts-cmd.install = no
fts-cmd.dir = examples/fts/stub-generation
fts-cmd.threads = yes
fts-cmd.subproject_deps = ctypes \
ctypes-foreign-base ctypes-foreign-unthreaded fts-stubs
ctypes-foreign fts-stubs
fts-cmd.deps = str unix bigarray integers
fts-cmd.extra_mls = fts_generated.ml
fts-cmd.extra_cs = fts_stubs.c
Expand All @@ -36,8 +38,9 @@ examples/fts/stub-generation/fts_generated.ml: fts-stub-generator
# subproject: fts using dynamic linking (foreign)
fts.install = no
fts.dir = examples/fts/foreign
fts.threads = yes
fts.deps = unix bigarray str integers
fts.subproject_deps = ctypes ctypes-foreign-base ctypes-foreign-unthreaded
fts.subproject_deps = ctypes ctypes-foreign
fts: PROJECT=fts
fts: $$(NATIVE_TARGET)

Expand Down Expand Up @@ -71,7 +74,8 @@ examples/date/stub-generation/date_generated.ml:
# subproject: date using dynamic linking (foreign)
date.install = no
date.dir = examples/date/foreign
date.subproject_deps = ctypes ctypes-foreign-base ctypes-foreign-unthreaded
date.threads = yes
date.subproject_deps = ctypes ctypes-foreign
date.deps = unix bigarray str integers
date: PROJECT=date
date: $$(NATIVE_TARGET)
Expand All @@ -86,9 +90,10 @@ ncurses-stubs: $$(NATIVE_TARGET) $$(LIB_TARGETS)

ncurses-stub-generator.install = no
ncurses-stub-generator.dir = examples/ncurses/stub-generation/stub-generator
ncurses-stub-generator.threads = yes
ncurses-stub-generator.deps = integers
ncurses-stub-generator.subproject_deps = ctypes cstubs \
ctypes-foreign-base ctypes-foreign-unthreaded ncurses-stubs
ctypes-foreign ncurses-stubs
ncurses-stub-generator.deps = str unix bigarray integers
ncurses-stub-generator: PROJECT=ncurses-stub-generator
ncurses-stub-generator: $$(NATIVE_TARGET)
Expand All @@ -110,7 +115,8 @@ examples/ncurses/stub-generation/ncurses_generated.ml: ncurses-stubs
# subproject: ncurses using dynamic linking (foreign)
ncurses.install = no
ncurses.dir = examples/ncurses/foreign
ncurses.subproject_deps = ctypes ctypes-foreign-base ctypes-foreign-unthreaded
ncurses.threads = yes
ncurses.subproject_deps = ctypes ctypes-foreign
ncurses.deps = unix bigarray str integers
ncurses.link_flags = -lncurses
ncurses: PROJECT=ncurses
Expand Down
Loading