dev-ml/ppx_optcomp: fix build with ocaml 4.03
authorAlexis Ballier <aballier@gentoo.org>
Sun, 1 May 2016 18:09:14 +0000 (20:09 +0200)
committerAlexis Ballier <aballier@gentoo.org>
Tue, 3 May 2016 09:13:52 +0000 (11:13 +0200)
Package-Manager: portage-2.2.28
Signed-off-by: Alexis Ballier <aballier@gentoo.org>
dev-ml/ppx_optcomp/files/oc43.patch [new file with mode: 0644]
dev-ml/ppx_optcomp/ppx_optcomp-113.33.00.ebuild

diff --git a/dev-ml/ppx_optcomp/files/oc43.patch b/dev-ml/ppx_optcomp/files/oc43.patch
new file mode 100644 (file)
index 0000000..6203c07
--- /dev/null
@@ -0,0 +1,93 @@
+diff -uNr ppx_optcomp-113.33.00/_oasis ppx_optcomp-113.33.00+4.03/_oasis
+--- ppx_optcomp-113.33.00/_oasis       2016-03-09 16:44:54.000000000 +0100
++++ ppx_optcomp-113.33.00+4.03/_oasis  2016-03-22 15:13:51.000000000 +0100
+@@ -1,8 +1,8 @@
+ OASISFormat:      0.4
+-OCamlVersion:     >= 4.02.3
++OCamlVersion:     >= 4.03.0
+ FindlibVersion:   >= 1.3.2
+ Name:             ppx_optcomp
+-Version:          113.33.00
++Version:          113.33.00+4.03
+ Synopsis:         Optional compilation for OCaml
+ Authors:          Jane Street Group, LLC <opensource@janestreet.com>
+ Copyrights:       (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
+diff -uNr ppx_optcomp-113.33.00/opam ppx_optcomp-113.33.00+4.03/opam
+--- ppx_optcomp-113.33.00/opam 2016-03-18 12:08:01.000000000 +0100
++++ ppx_optcomp-113.33.00+4.03/opam    2016-03-22 17:51:37.000000000 +0100
+@@ -15,4 +15,4 @@
+   "ppx_core"
+   "ppx_tools"  {>= "0.99.3"}
+ ]
+-available: [ ocaml-version >= "4.02.3" ]
++available: [ ocaml-version >= "4.03.0" ]
+diff -uNr ppx_optcomp-113.33.00/src/ppx_optcomp.ml ppx_optcomp-113.33.00+4.03/src/ppx_optcomp.ml
+--- ppx_optcomp-113.33.00/src/ppx_optcomp.ml   2016-03-09 16:44:54.000000000 +0100
++++ ppx_optcomp-113.33.00+4.03/src/ppx_optcomp.ml      2016-03-22 15:13:51.000000000 +0100
+@@ -169,12 +169,19 @@
+   Location.raise_errorf ~loc:e.pexp_loc "optcomp: expression not supported"
+ ;;
++let parse_int loc x =
++  match int_of_string x with
++  | v -> v
++  | exception _ ->
++    Location.raise_errorf ~loc "optcomp: invalid integer"
++;;
++
+ let rec eval env e : Value.t =
+   let loc = e.pexp_loc in
+   match e.pexp_desc with
+-  | Pexp_constant (Const_int     x    ) -> Int    x
+-  | Pexp_constant (Const_char    x    ) -> Char   x
+-  | Pexp_constant (Const_string (x, _)) -> String x
++  | Pexp_constant (Pconst_integer    (x, None)) -> Int (parse_int loc x)
++  | Pexp_constant (Pconst_char    x       ) -> Char x
++  | Pexp_constant (Pconst_string (x, _   )) -> String x
+   | Pexp_construct ({ txt = Lident "true" ; _ }, None) -> Bool true
+   | Pexp_construct ({ txt = Lident "false"; _ }, None) -> Bool false
+@@ -192,7 +199,7 @@
+   | Pexp_apply ({ pexp_desc = Pexp_ident { txt = Lident s; _ }; _ }, args) -> begin
+       let args =
+-        List.map args ~f:(fun (l, x) -> if l <> "" then not_supported e else x)
++        List.map args ~f:(fun (l, x) -> if l <> Asttypes.Nolabel then not_supported e else x)
+       in
+       match s, args with
+       | "="  , [x; y] -> eval_cmp     env ( = )   x y
+@@ -283,12 +290,13 @@
+   | _ -> not_supported e
+ and bind env patt value =
++  let loc = patt.ppat_loc in
+   match patt.ppat_desc, value with
+   | Ppat_any, _ -> env
+-  | Ppat_constant (Const_int     x    ), Int    y when x = y -> env
+-  | Ppat_constant (Const_char    x    ), Char   y when x = y -> env
+-  | Ppat_constant (Const_string (x, _)), String y when x = y -> env
++  | Ppat_constant (Pconst_integer    (x, None)), Int    y when parse_int loc x = y -> env
++  | Ppat_constant (Pconst_char    x       ), Char   y when               x = y -> env
++  | Ppat_constant (Pconst_string (x, _   )), String y when               x = y -> env
+   | Ppat_construct ({ txt = Lident "true" ; _ }, None), Bool true  -> env
+   | Ppat_construct ({ txt = Lident "false"; _ }, None), Bool false -> env
+@@ -506,7 +514,7 @@
+           | Pexp_construct (x, Some y) ->
+             let id = var_of_lid x in
+             Let (ppat_var ~loc:id.loc id, y)
+-          | Pexp_apply (x, [("", y)]) ->
++          | Pexp_apply (x, [(Nolabel, y)]) ->
+             let id = var_of_expr x in
+             Let (ppat_var ~loc:id.loc id, y)
+           | _ ->
+@@ -517,7 +525,7 @@
+       | LIDENT "import" -> begin
+           let e = get_expr () in
+           match e.pexp_desc with
+-          | Pexp_constant (Const_string (s, _)) -> Import s
++          | Pexp_constant (Pconst_string (s, _)) -> Import s
+           | _ ->
+             Location.raise_errorf ~loc:e.pexp_loc "optcomp: #import expect a string"
+         end
index a644d2daa385b2d51ce5baa937c7f0fe07bb9cbd..f3ad68d7ea84baa6aed202c0e8a100b024d16385 100644 (file)
@@ -4,7 +4,7 @@
 
 EAPI="5"
 
-inherit oasis
+inherit oasis eutils
 
 DESCRIPTION="Optional compilation for OCaml"
 HOMEPAGE="http://www.janestreet.com/ocaml"
@@ -20,6 +20,10 @@ DEPEND="dev-ml/ppx_tools:=
 
 RDEPEND="${DEPEND}"
 
+src_prepare() {
+       has_version '>=dev-lang/ocaml-4.03' && epatch "${FILESDIR}/oc43.patch"
+}
+
 src_configure() {
        emake setup.exe
        OASIS_SETUP_COMMAND="./setup.exe" oasis_src_configure