summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2018-02-19 08:23:12 +0100
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2018-02-19 09:13:15 +0100
commitb7184e017e016ffaca38244d02bbb252a5e005e6 (patch)
treeddca2b28f7e76722c5dce27607a5787255c0e33f
parent42ff6e44b2f3a756a6af2b19f490b3b91572eee4 (diff)
downloadocaml-b7184e017e016ffaca38244d02bbb252a5e005e6.tar.gz
ocamltest: complete and clarify support for runtime flags
-rw-r--r--ocamltest/ocaml_backends.ml4
-rw-r--r--ocamltest/ocaml_backends.mli4
-rw-r--r--ocamltest/ocaml_directories.ml6
-rw-r--r--ocamltest/ocaml_directories.mli2
-rw-r--r--ocamltest/ocaml_flags.ml42
5 files changed, 36 insertions, 22 deletions
diff --git a/ocamltest/ocaml_backends.ml b/ocamltest/ocaml_backends.ml
index 5522206368..71e75a49eb 100644
--- a/ocamltest/ocaml_backends.ml
+++ b/ocamltest/ocaml_backends.ml
@@ -17,6 +17,10 @@
type t = Native | Bytecode
+let is_bytecode t = t=Bytecode
+
+let is_native t = t=Native
+
let string_of_backend = function
| Native -> "native"
| Bytecode -> "bytecode"
diff --git a/ocamltest/ocaml_backends.mli b/ocamltest/ocaml_backends.mli
index 8b83543034..5cc48e8587 100644
--- a/ocamltest/ocaml_backends.mli
+++ b/ocamltest/ocaml_backends.mli
@@ -17,6 +17,10 @@
type t = Native | Bytecode
+val is_bytecode : t -> bool
+
+val is_native : t -> bool
+
val string_of_backend : t -> string
val make_backend_function : 'a -> 'a -> t -> 'a
diff --git a/ocamltest/ocaml_directories.ml b/ocamltest/ocaml_directories.ml
index 064fd57cbb..f33880075c 100644
--- a/ocamltest/ocaml_directories.ml
+++ b/ocamltest/ocaml_directories.ml
@@ -29,3 +29,9 @@ let toplevel ocamlsrcdir =
let runtime ocamlsrcdir =
Filename.make_path [ocamlsrcdir; "byterun"]
+
+let runtime_library backend ocamlsrcdir =
+ let backend_lib_dir = match backend with
+ | Ocaml_backends.Native -> "asmrun"
+ | Ocaml_backends.Bytecode -> "byterun" in
+ Filename.make_path [ocamlsrcdir; backend_lib_dir]
diff --git a/ocamltest/ocaml_directories.mli b/ocamltest/ocaml_directories.mli
index 2d25d64f50..c7bb5b2df5 100644
--- a/ocamltest/ocaml_directories.mli
+++ b/ocamltest/ocaml_directories.mli
@@ -22,3 +22,5 @@ val stdlib : string -> string
val toplevel : string -> string
val runtime : string -> string
+
+val runtime_library : Ocaml_backends.t -> string -> string
diff --git a/ocamltest/ocaml_flags.ml b/ocamltest/ocaml_flags.ml
index bff8756d1e..a9266bbc38 100644
--- a/ocamltest/ocaml_flags.ml
+++ b/ocamltest/ocaml_flags.ml
@@ -26,25 +26,23 @@ let c_includes ocamlsrcdir =
let dir = Ocaml_directories.runtime ocamlsrcdir in
"-ccopt -I" ^ dir
-let runtime_flags ocamlsrcdir backend c_files = match backend with
- | Ocaml_backends.Native -> ""
- | Ocaml_backends.Bytecode ->
- if c_files then begin (* custm mode *)
- let runtime_variant = Ocaml_files.runtime_variant() in
- let variant_flag = match runtime_variant with
- | Ocaml_files.Normal -> ""
- | Ocaml_files.Debug -> " -runtime-variant d"
- | Ocaml_files.Instrumented -> " -runtime-variant i" in
- "-custom" ^ variant_flag ^ " -I " ^
- (Ocaml_directories.runtime ocamlsrcdir)
- (* when using the debug or instrumented runtimes, we need to include
- the byterun directory so that libcamlrund and libcamlruni
- can be found. This is not necessary with the normal runtime
- because libcamlrun is copied to the stdlib directory which
- will be included anyway
- *)
- end else begin (* non-custom mode *)
- let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in
- "-use-runtime " ^ ocamlrun
- end
- \ No newline at end of file
+let runtime_variant_flags () = match Ocaml_files.runtime_variant() with
+ | Ocaml_files.Normal -> ""
+ | Ocaml_files.Debug -> " -runtime-variant d"
+ | Ocaml_files.Instrumented -> " -runtime-variant i"
+
+let runtime_flags ocamlsrcdir backend c_files =
+ let runtime_library_flags = "-I " ^
+ (Ocaml_directories.runtime_library backend ocamlsrcdir) in
+ let rt_flags = match backend with
+ | Ocaml_backends.Native -> runtime_variant_flags ()
+ | Ocaml_backends.Bytecode ->
+ begin
+ if c_files then begin (* custom mode *)
+ "-custom " ^ (runtime_variant_flags ())
+ end else begin (* non-custom mode *)
+ "-use-runtime " ^ (Ocaml_files.ocamlrun ocamlsrcdir)
+ end
+ end in
+ rt_flags ^ " " ^ runtime_library_flags
+ \ No newline at end of file