Skip to content

Commit

Permalink
ppx: further dependency cleanup and drop use of ppxfind
Browse files Browse the repository at this point in the history
Signed-off-by: Marcello Seri <[email protected]>
  • Loading branch information
mseri committed Aug 31, 2018
1 parent 1e7ca14 commit 86a44b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
12 changes: 3 additions & 9 deletions ppx/jbuild
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
(rule
((targets (ppx_deriving_rpc.ml))
(deps (ppx_deriving_rpc.cppo.ml))
(action (run ${bin:cppo} -V OCAML:${ocaml_version} ${<} -o ${@}))))


(library
((name ppx_deriving_rpc)
(public_name ppx_deriving_rpc)
(synopsis "[@@deriving rpc]")
(kind ppx_deriver)
(libraries (
ppx_deriving.api
(libraries (ppx_deriving.api
rpclib.core))
(preprocess (action (run ppxfind -legacy ppx_deriving.runtime,ppx_tools.metaquot --as-pp ${<})))
(preprocess (pps (ppx_tools_versioned.metaquot_406))
)
(wrapped false)
))
14 changes: 2 additions & 12 deletions ppx/ppx_deriving_rpc.cppo.ml → ppx/ppx_deriving_rpc.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Ast_406

open Longident
open Asttypes
open Parsetree
Expand Down Expand Up @@ -137,27 +139,21 @@ module Of_rpc = struct
tags |> List.map (fun field ->
match field with
| Rtag (label, attrs, true, []) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
let label' = String.lowercase_ascii label in
Exp.case
[%pat? Rpc.String [%p pstr (attr_name label' attrs)]]
(Exp.variant label None)
| Rtag (label, attrs, false, [ { ptyp_desc = Ptyp_tuple typs; _ }]) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
let label' = String.lowercase_ascii label in
let exprs = List.mapi (fun i typ -> [%expr [%e expr_of_typ typ] [%e evar (argn i) ] ] ) typs in
Exp.case
[%pat? Rpc.Enum [Rpc.String [%p pstr (attr_name label' attrs)];
Rpc.Enum [%p plist (List.mapi (fun i _ -> pvar (argn i)) typs)]]]
(Exp.variant label (Some (tuple exprs)))
| Rtag (label, attrs, false, [typ]) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
let label' = String.lowercase_ascii label in
Exp.case
[%pat? Rpc.Enum [Rpc.String [%p pstr (attr_name label' attrs)]; y]]
Expand Down Expand Up @@ -318,25 +314,19 @@ module Rpc_of = struct
fields |> List.map (fun field ->
match field with
| Rtag (label, attrs, true, []) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
Exp.case
(Pat.variant label None)
[%expr Rpc.String [%e str (attr_name label attrs)]]
| Rtag (label, attrs, false, [{ ptyp_desc = Ptyp_tuple typs; _ }]) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
let l = list (List.mapi (fun i typ -> app (expr_of_typ typ) [evar (argn i)]) typs) in
Exp.case
(Pat.variant label (Some (ptuple (List.mapi (fun i _ -> pvar (argn i)) typs))))
[%expr Rpc.Enum ( Rpc.String ([%e str (attr_name label attrs)]) ::
[Rpc.Enum [%e l]])]
| Rtag (label, attrs, false, [typ]) ->
#if OCAML_VERSION > (4, 05, 0)
let label = label.txt in
#endif
Exp.case
(Pat.variant label (Some [%pat? x]))
[%expr Rpc.Enum ( (Rpc.String ([%e str (attr_name label attrs)])) :: [ [%e expr_of_typ typ] x])]
Expand Down
2 changes: 2 additions & 0 deletions ppx/ppx_deriving_rpcty.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Ast_406

open Longident
open Asttypes
open Parsetree
Expand Down
4 changes: 1 addition & 3 deletions ppx_deriving_rpc.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ build: [["jbuilder" "build" "-p" name "-j" jobs]]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
depends: [
"jbuilder" {build}
"cppo" {build}
"rpclib" {>= "5.0.0"}
"rresult"
"ppx_deriving"
"ppx_tools"
"ppxfind"
"ppx_tools_versioned"
"rpclib-lwt" {test & >= "5.0.0"}
"rpclib-async" {test & >= "5.0.0"}
"lwt" {test & >= "3.0.0"}
Expand Down

0 comments on commit 86a44b0

Please sign in to comment.