Skip to content

Commit 0a4d0cd

Browse files
committed
Get magic number version from compiler-libs
1 parent eaea1a1 commit 0a4d0cd

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

compiler/lib/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
(public_name js_of_ocaml-compiler)
44
(synopsis "Js_of_ocaml compiler library")
55
(libraries
6-
compiler-libs.common
7-
compiler-libs.bytecomp
6+
ocaml-compiler-libs.common
7+
ocaml-compiler-libs.bytecomp
88
menhirLib
99
sedlex
1010
yojson)

compiler/lib/magic_number.ml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,14 @@ let compare (p1, n1) (p2, n2) =
6464

6565
let equal a b = compare a b = 0
6666

67-
let v =
67+
let () =
6868
let current = Ocaml_version.current in
69-
match current with
70-
| 4 :: 13 :: _ -> 30
71-
| 4 :: 14 :: _ -> 31
72-
| 5 :: 00 :: _ -> 32
73-
| 5 :: 01 :: _ -> 33
74-
| 5 :: 02 :: _ -> 34
75-
| 5 :: 03 :: _ -> 35
76-
| 5 :: 04 :: _ -> 36
77-
| _ ->
78-
if Ocaml_version.compare current [ 4; 13 ] < 0
79-
then failwith "OCaml version unsupported. Upgrade to OCaml 4.13 or newer."
80-
else (
81-
assert (Ocaml_version.compare current [ 5; 5 ] >= 0);
82-
failwith "OCaml version unsupported. Upgrade js_of_ocaml.")
69+
if Ocaml_version.compare current [ 4; 13 ] < 0
70+
then failwith "OCaml version unsupported. Upgrade to OCaml 4.13 or newer."
71+
else if Ocaml_version.compare current [ 5; 5 ] >= 0
72+
then failwith "OCaml version unsupported. Upgrade js_of_ocaml."
73+
74+
let v = snd (of_string Ocaml_common.Config.exec_magic_number)
8375

8476
let current_exe = "Caml1999X", v
8577

dune-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
(num :with-test)
2222
(ppx_expect (and (>= v0.16.1) :with-test))
2323
(ppxlib (>= 0.35))
24+
(ocaml-compiler-libs (>= v0.12.4))
2425
(re :with-test)
2526
(cmdliner (>= 1.1.0))
2627
(sedlex (>= 3.3))

js_of_ocaml-compiler.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ depends: [
1717
"num" {with-test}
1818
"ppx_expect" {>= "v0.16.1" & with-test}
1919
"ppxlib" {>= "0.35"}
20+
"ocaml-compiler-libs" {>= "v0.12.4"}
2021
"re" {with-test}
2122
"cmdliner" {>= "1.1.0"}
2223
"sedlex" {>= "3.3"}

0 commit comments

Comments
 (0)