Skip to content

Commit 7e1bcd2

Browse files
committed
OxCaml: check primitives
1 parent bb60014 commit 7e1bcd2

File tree

4 files changed

+759
-11
lines changed

4 files changed

+759
-11
lines changed

compiler/tests-check-prim/dune.inc

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(targets main.4.14.output)
33
(mode
44
(promote (until-clean)))
5-
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)))
5+
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(not %{oxcaml_supported})))
66
(action
77
(with-stdout-to
88
%{targets}
@@ -17,7 +17,7 @@
1717
(targets unix-Win32.4.14.output)
1818
(mode
1919
(promote (until-clean)))
20-
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Win32)))
20+
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Win32)(not %{oxcaml_supported})))
2121
(action
2222
(with-stdout-to
2323
%{targets}
@@ -32,7 +32,7 @@
3232
(targets unix-Unix.4.14.output)
3333
(mode
3434
(promote (until-clean)))
35-
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Unix)))
35+
(enabled_if (and (>= %{ocaml_version} 4.14)(< %{ocaml_version} 5.0)(= %{os_type} Unix)(not %{oxcaml_supported})))
3636
(action
3737
(with-stdout-to
3838
%{targets}
@@ -47,7 +47,7 @@
4747
(targets main.5.4.output)
4848
(mode
4949
(promote (until-clean)))
50-
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)))
50+
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)(not %{oxcaml_supported})))
5151
(action
5252
(with-stdout-to
5353
%{targets}
@@ -62,7 +62,7 @@
6262
(targets unix-Win32.5.4.output)
6363
(mode
6464
(promote (until-clean)))
65-
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)(= %{os_type} Win32)))
65+
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)(= %{os_type} Win32)(not %{oxcaml_supported})))
6666
(action
6767
(with-stdout-to
6868
%{targets}
@@ -77,7 +77,52 @@
7777
(targets unix-Unix.5.4.output)
7878
(mode
7979
(promote (until-clean)))
80-
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)(= %{os_type} Unix)))
80+
(enabled_if (and (>= %{ocaml_version} 5.4)(< %{ocaml_version} 5.5)(= %{os_type} Unix)(not %{oxcaml_supported})))
81+
(action
82+
(with-stdout-to
83+
%{targets}
84+
(run
85+
%{bin:js_of_ocaml}
86+
check-runtime
87+
+dynlink.js
88+
+toplevel.js
89+
%{dep:unix.bc}))))
90+
91+
(rule
92+
(targets main.5.2+ox.output)
93+
(mode
94+
(promote (until-clean)))
95+
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)%{oxcaml_supported}))
96+
(action
97+
(with-stdout-to
98+
%{targets}
99+
(run
100+
%{bin:js_of_ocaml}
101+
check-runtime
102+
+dynlink.js
103+
+toplevel.js
104+
%{dep:main.bc}))))
105+
106+
(rule
107+
(targets unix-Win32.5.2+ox.output)
108+
(mode
109+
(promote (until-clean)))
110+
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)(= %{os_type} Win32)%{oxcaml_supported}))
111+
(action
112+
(with-stdout-to
113+
%{targets}
114+
(run
115+
%{bin:js_of_ocaml}
116+
check-runtime
117+
+dynlink.js
118+
+toplevel.js
119+
%{dep:unix.bc}))))
120+
121+
(rule
122+
(targets unix-Unix.5.2+ox.output)
123+
(mode
124+
(promote (until-clean)))
125+
(enabled_if (and (>= %{ocaml_version} 5.2)(< %{ocaml_version} 5.3)(= %{os_type} Unix)%{oxcaml_supported}))
81126
(action
82127
(with-stdout-to
83128
%{targets}

compiler/tests-check-prim/gen_dune.ml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ type version =
1111
| `V5_5
1212
]
1313

14+
type variant =
15+
[ `Mainstream
16+
| `OxCaml
17+
]
18+
1419
let string_of_version : version -> string = function
1520
| `V4_13 -> "4.13"
1621
| `V4_14 -> "4.14"
@@ -39,7 +44,7 @@ let string_of_os_type = function
3944
| Unix -> "Unix"
4045
| Win32 -> "Win32"
4146

42-
let rule bc ocaml_version os_type =
47+
let rule bc ocaml_version os_type ocaml_variant =
4348
let vl =
4449
[ Printf.sprintf "(>= %%{ocaml_version} %s)" (string_of_version ocaml_version) ]
4550
in
@@ -53,7 +58,13 @@ let rule bc ocaml_version os_type =
5358
| None -> []
5459
| Some os_type -> [ Printf.sprintf "(= %%{os_type} %s)" (string_of_os_type os_type) ]
5560
in
56-
let enabled_if = Printf.sprintf "(and %s)" (String.concat "" (vl @ vu @ os)) in
61+
let ox =
62+
[ (match ocaml_variant with
63+
| `Mainstream -> "(not %{oxcaml_supported})"
64+
| `OxCaml -> "%{oxcaml_supported}")
65+
]
66+
in
67+
let enabled_if = Printf.sprintf "(and %s)" (String.concat "" (vl @ vu @ os @ ox)) in
5768

5869
let target =
5970
Filename.chop_extension bc
@@ -62,6 +73,9 @@ let rule bc ocaml_version os_type =
6273
| Some os_type -> "-" ^ string_of_os_type os_type)
6374
^ "."
6475
^ string_of_version ocaml_version
76+
^ (match ocaml_variant with
77+
| `Mainstream -> ""
78+
| `OxCaml -> "+ox")
6579
^ ".output"
6680
in
6781
Printf.sprintf
@@ -85,11 +99,13 @@ let rule bc ocaml_version os_type =
8599
bc
86100

87101
let () =
88-
let versions : version list = [ `V4_14; `V5_4 ] in
102+
let versions : (version * variant) list =
103+
[ `V4_14, `Mainstream; `V5_4, `Mainstream; `V5_2, `OxCaml ]
104+
in
89105
set_binary_mode_out stdout true;
90106
List.iter
91-
(fun ocaml_version ->
107+
(fun (ocaml_version, ocaml_variant) ->
92108
List.iter
93-
(fun (bc, os_type) -> print_endline (rule bc ocaml_version os_type))
109+
(fun (bc, os_type) -> print_endline (rule bc ocaml_version os_type ocaml_variant))
94110
[ "main.bc", None; "unix.bc", Some Win32; "unix.bc", Some Unix ])
95111
versions

0 commit comments

Comments
 (0)