Browse thread
Producing a C wrapper with ocamlbuild or OMake
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Joel Reymont <joelr1@g...> |
| Subject: | Re: [Caml-list] Producing a C wrapper with ocamlbuild or OMake |
Nicolas,
I think I'm missing one more bit:
ocamlbuild main
+ ocamlfind ocamlopt -package ounit -output-obj morpher.ml -o
morphercaml.o
No implementations provided for the following modules:
Symtab referenced from morpher.cmx
Ninja referenced from morpher.cmx
Easy_lexer referenced from morpher.cmx
Easy_parser referenced from morpher.cmx
Ppninja referenced from morpher.cmx
Pretty referenced from morpher.cmx
Parser_util referenced from morpher.cmx
Ninja_morph referenced from morpher.cmx
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in
00:00:00.
My complete plugin file is below. I can build my test program just
fine using
ocamlbuild test.byte
but trying to produce the library gives me the above error.
What am I missing? How can I have morpher.ml automatically pull in
the other modules?
I do open modules at the top of morpher.ml like this
open Ninja_morph
open Parser_util
module PP = Ppninja
module N = Ninja
Thanks, Joel
---
open Ocamlbuild_plugin;;
open Command;;
let cc = A"cc";;
let ar = A"ar";;
let packages = "ounit" (* "pkg1,pkg2,..." *);;
let ocamlfind cmd =
S[A"ocamlfind"; A cmd; A"-package"; A packages];;
flag ["ocaml"; "link"] (A"-linkpkg");;
dispatch begin function
| After_options ->
Options.ocamlc := ocamlfind "ocamlc";
Options.ocamlopt := ocamlfind "ocamlopt";
| After_rules ->
rule "output C obj"
~dep:"%.ml"
~prod:"%caml.o"
begin fun env _ ->
let caml_o = env "%caml.o" and ml = env "%.ml" in
Cmd(S[!Options.ocamlopt; A"-output-obj"; P ml; A"-o"; Px
caml_o])
end;
rule "build C lib"
~deps:["%_stubs.o"; "%caml.o"]
~prod:"lib%.a"
begin fun env _ ->
let wrap_o = env "%wrap.o"
and caml_o = env "%caml.o"
and libasmrun = !
*Ocamlbuild_pack.Ocaml_utils.stdlib_dir/"libasmrun.a"
and lib_a = env "lib%.a" in
Seq[cp libasmrun lib_a;
Cmd(S[ar; A"r"; Px lib_a; P caml_o; P wrap_o])]
end;
rule "build morpher"
~deps:["libmorpher.a"; "main.o"]
~prod:"main"
begin fun _ _ ->
Cmd(S[cc; P"morpher.o"; P"libmorpher.a"; A"-o"; Px"main"])
end;
| _ -> ()
end
--
http://wagerlabs.com/