Simple stubs test

C stub library and executable that will run it
This commit is contained in:
Rudi Grinberg 2017-12-23 11:26:49 +08:00
parent 7d8ca23b62
commit dfe0001b5a
10 changed files with 47 additions and 0 deletions

View File

@ -155,3 +155,10 @@
(action
(chdir test-cases/utop
(setenv JBUILDER ${bin:jbuilder} (run ${exe:cram.exe} run.t))))))
(alias
((name runtest)
(deps ((files_recursively_in test-cases/c-stubs)))
(action
(chdir test-cases/c-stubs
(setenv JBUILDER ${bin:jbuilder} (run ${exe:cram.exe} run.t))))))

View File

@ -0,0 +1 @@
(jbuild_version 1)

View File

@ -0,0 +1,5 @@
(jbuild_version 1)
(library
((name q)
(c_names (q_stub))))

View File

@ -0,0 +1 @@
#define ANSWER 42

View File

@ -0,0 +1,2 @@
external q : unit -> int = "ocaml_question"

View File

@ -0,0 +1,2 @@
val q : unit -> int

View File

@ -0,0 +1,9 @@
#include "q.h"
#include <caml/mlvalues.h>
#include <caml/memory.h>
CAMLprim value ocaml_question (value unit)
{
CAMLparam1 (unit);
CAMLreturn (Val_int(ANSWER));
}

View File

@ -0,0 +1,5 @@
(jbuild_version 1)
(executable
((name run)
(libraries (q))))

View File

@ -0,0 +1 @@
print_int (Q.q ());;

View File

@ -0,0 +1,14 @@
$ $JBUILDER exec -j1 ./qnativerun/run.exe --root .
ocamldep qnativerun/run.depends.ocamldep-output
ocamlc q/q_stub.o
ocamldep q/q.depends.ocamldep-output
ocamldep q/q.dependsi.ocamldep-output
ocamlmklib q/dllq_stubs.so,q/libq_stubs.a
ocamlc q/q.{cmi,cmti}
ocamlc qnativerun/run.{cmi,cmo,cmt}
ocamlopt q/q.{cmx,o}
ocamlopt qnativerun/run.{cmx,o}
ocamlopt q/q.{a,cmxa}
ocamlopt qnativerun/run.exe
42
# $ $JBUILDER exec -j1 ./qbyterun/run.bc --root .