Skip to content
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
127 changes: 20 additions & 107 deletions compiler/tests-check-prim/dune
Original file line number Diff line number Diff line change
@@ -1,119 +1,32 @@
(executables
(names main)
(include dune.inc)

(rule
(action
(with-stdout-to
dune.inc.gen
(run ./gen_dune.exe))))

(rule
(alias runtest)
(action
(diff dune.inc dune.inc.gen)))

(executable
(name main)
(libraries js_of_ocaml num str)
(link_flags
(:standard -linkall))
(modules main)
(modes byte))

(executables
(names unix)
(executable
(name unix)
(libraries js_of_ocaml num str unix)
(link_flags
(:standard -linkall))
(modules unix)
(modes byte))

(rule
(targets main.output)
(mode
(promote (until-clean)))
(enabled_if
(< %{ocaml_version} 5))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:main.bc}))))

(rule
(targets unix-unix.output)
(enabled_if
(and
(< %{ocaml_version} 5)
(= %{os_type} Unix)))
(mode
(promote (until-clean)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets unix-win32.output)
(enabled_if
(and
(< %{ocaml_version} 5)
(= %{os_type} Win32)))
(mode
(promote (until-clean)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets main.output5)
(mode
(promote (until-clean)))
(enabled_if
(>= %{ocaml_version} 5))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:main.bc}))))

(rule
(targets unix-unix.output5)
(enabled_if
(and
(>= %{ocaml_version} 5)
(= %{os_type} Unix)))
(mode
(promote (until-clean)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets unix-win32.output5)
(enabled_if
(and
(>= %{ocaml_version} 5)
(= %{os_type} Win32)))
(mode
(promote (until-clean)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))
(executable
(name gen_dune)
(modules gen_dune))
90 changes: 90 additions & 0 deletions compiler/tests-check-prim/dune.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(rule
(targets main.4.14.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:main.bc}))))

(rule
(targets unix-Win32.4.14.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Win32)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets unix-Unix.4.14.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Unix)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets main.5.2.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:main.bc}))))

(rule
(targets unix-Win32.5.2.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)(= %{os_type} Win32)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

(rule
(targets unix-Unix.5.2.output)
(mode
(promote (until-clean)))
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)(= %{os_type} Unix)))
(action
(with-stdout-to
%{targets}
(run
%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%{dep:unix.bc}))))

106 changes: 106 additions & 0 deletions compiler/tests-check-prim/gen_dune.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
(** *)

type version =
[ `V4_08
| `V4_09
| `V4_10
| `V4_11
| `V4_12
| `V4_13
| `V4_14
| `V5_0
| `V5_1
| `V5_2
| `V5_3
| `V5_4
]

let string_of_version : version -> string = function
| `V4_08 -> "4.08"
| `V4_09 -> "4.09"
| `V4_10 -> "4.10"
| `V4_11 -> "4.11"
| `V4_12 -> "4.12"
| `V4_13 -> "4.13"
| `V4_14 -> "4.14"
| `V5_0 -> "5.0"
| `V5_1 -> "5.1"
| `V5_2 -> "5.2"
| `V5_3 -> "5.3"
| `V5_4 -> "5.4"

let next_version : version -> version option = function
| `V4_08 -> Some `V4_09
| `V4_09 -> Some `V4_10
| `V4_10 -> Some `V4_11
| `V4_11 -> Some `V4_12
| `V4_12 -> Some `V4_13
| `V4_13 -> Some `V4_14
| `V4_14 -> Some `V5_0
| `V5_0 -> Some `V5_1
| `V5_1 -> Some `V5_2
| `V5_2 -> Some `V5_3
| `V5_3 -> Some `V5_4
| `V5_4 -> None

type os_type =
| Unix
| Win32

let string_of_os_type = function
| Unix -> "Unix"
| Win32 -> "Win32"

let rule bc ocaml_version os_type =
let vl =
[ Printf.sprintf "(>= %%{ocaml_version} %s)" (string_of_version ocaml_version) ]
in
let vu =
match next_version ocaml_version with
| None -> []
| Some up -> [ Printf.sprintf "(< %%{ocaml_version} %s)" (string_of_version up) ]
in
let os =
match os_type with
| None -> []
| Some os_type -> [ Printf.sprintf "(= %%{os_type} %s)" (string_of_os_type os_type) ]
in
let enabled_if = Printf.sprintf "(and %s)" (String.concat "" (vl @ vu @ os)) in

let target =
Filename.chop_extension bc
^ (match os_type with
| None -> ""
| Some os_type -> "-" ^ string_of_os_type os_type)
^ "."
^ string_of_version ocaml_version
^ ".output"
in
Printf.sprintf
{|(rule
(targets %s)
(mode
(promote (until-clean)))
(enabled_if %s)
(action
(with-stdout-to
%%{targets}
(run
%%{bin:js_of_ocaml}
check-runtime
+dynlink.js
+toplevel.js
%%{dep:%s}))))
|}
target
enabled_if
bc

let () =
let versions : version list = [ `V4_14; `V5_2 ] in
List.iter
(fun ocaml_version ->
List.iter
(fun (bc, os_type) -> print_endline (rule bc ocaml_version os_type))
[ "main.bc", None; "unix.bc", Some Win32; "unix.bc", Some Unix ])
versions
Loading