Closed cspiel closed 5 years ago
Hi Chris,
there is an advanced set of macros I developed some time ago for the integration of omake into the now abandoned oasis tool. In particular, the macro OASIS_build_OCamlLibrary looks like it provides what you are searching for:
https://github.com/ocaml/oasis/blob/master/src/plugins/omake/oasis_lib.om#L343
I think the C objects must be given with .o extension (but I'm not sure).
I haven't found time yet to integrate this macro back into omake, where it sure would fit in well.
Let me know whether it works,
Gerd
Am 22.10.19 um 10:15 schrieb Chris Spiel:
I would like to build a native OCaml library that consists of several OCaml sources /and/ a C-source (a.k.a. "foreign source"). Obviously, OCamlLibrary http://projects.camlcity.org/projects/dl/omake-0.10.2/doc/html/omake-doc.html#sec508 cannot generate an appropriate target as its /FILES/-argument takes OCaml-module names only.
Is there a direct way to construct such a mixed-source-library target in omake or do I have to whip up such a function myself? It looks easy enough to built upon |OCamlLibrary| for e.g.
|OCamlMixedLibrary(library_name, ocaml_modules, foreign_modules) |
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ocaml-omake/omake/issues/120?email_source=notifications&email_token=AALLUWX7DZ3T4237GQIV4TDQP2ZBPA5CNFSM4JDMER5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HTNSJXA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLUWVA6UY3EK7K7V7VMKTQP2ZBPANCNFSM4JDMER5A.
--
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de
Thanks @gerd,
your function OASIS_build_OCamlLibrary
is massive! I used it as template
and extended OCamlLibrary
to the following code
public.OCamlMixedLibrary(library_name, ocaml_module_names, foreign_module_names) =
protected.LIBRARY_NAME = $(file $(library_name))
protected.OFILES = $(addsuffix $(EXT_OBJ), $(ocaml_module_names))
protected.FOREIGN_OFILES = $(addsuffix $(EXT_OBJ), $(foreign_module_names))
protected.CMOFILES = $(addsuffix .cmo, $(ocaml_module_names))
protected.CMXFILES = $(addsuffix .cmx, $(ocaml_module_names))
protected.CLIB = $(file $(LIBRARY_NAME)$(EXT_LIB))
protected.BYTELIB = $(file $(LIBRARY_NAME).cma)
protected.NATIVELIB = $(file $(LIBRARY_NAME).cmxa)
protected.SHAREDLIB = $(file $(LIBRARY_NAME).cmxs)
#
# Link commands
#
$(BYTELIB): $(CMOFILES) $(FOREIGN_OFILES)
$(OCAMLFIND) $(OCAMLLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) \
$(OCAMLFLAGS) $(OCAMLCFLAGS) \
$(OCAML_LIB_FLAGS) -a \
-o $@ \
$(OCamlLinkSort $(CMOFILES)) $(FOREIGN_OFILES)
$(NATIVELIB) $(CLIB): $(CMXFILES) $(OFILES) $(FOREIGN_OFILES)
$(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) \
$(OCAMLFLAGS) $(OCAMLOPTFLAGS) \
$(OCAML_LIB_FLAGS) -a \
-o $(NATIVELIB) \
$(OCamlLinkSort $(CMXFILES)) $(FOREIGN_OFILES)
$(SHAREDLIB): $(NATIVELIB) $(CLIB)
$(OCAMLFIND) $(OCAMLOPTLINK) -shared -cclib -L. -o $@ $(NATIVELIB)
return $(array $(if $(NATIVE_ENABLED), $(NATIVELIB)), \
$(if $(NATIVE_ENABLED), $(CLIB)), \
$(if $(BYTE_ENABLED), $(BYTELIB)), \
$(if $(CMXS_ENABLED), $(SHAREDLIB)))
The new function adheres to the OMake standard and takes module names not filenames also for the non-OCaml modules. This makes it consistent with the existing {C,OCaml}Library-functions and moreover completely separates compilation and dependency generation of the foreign modules.
I would like to build a native OCaml library that consists of several OCaml sources and a C-source (a.k.a. "foreign source"). Obviously, OCamlLibrary cannot generate an appropriate target as its FILES-argument takes OCaml-module names only.
Is there a direct way to construct such a mixed-source-library target in omake or do I have to whip up such a function myself? It looks easy enough to built upon
OCamlLibrary
for e.g.