forked from hhugo/ppx_deriving
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyocamlbuild.ml
More file actions
27 lines (23 loc) · 825 Bytes
/
myocamlbuild.ml
File metadata and controls
27 lines (23 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
open Ocamlbuild_plugin
let split delim str =
let rec loop i last acc =
if i = String.length str then
String.sub str last (i - last) :: acc
else if ((String.get str i) = delim) then
loop (i + 1) (i + 1) (String.sub str last (i - last) :: acc)
else
loop (i + 1) last acc
in
List.rev (loop 0 0 [])
let plugin_cmas names =
split ',' names |>
List.map (fun name -> "src_plugins/ppx_deriving_" ^ name ^ ".cma") |>
String.concat " "
let () = dispatch (
function
| After_rules ->
pflag ["ocaml"; "compile"; "ppx_byte"] "deriving" (fun names ->
S[A"-ppx"; A("src/ppx_deriving_main.byte " ^ (plugin_cmas names))]);
pflag ["ocaml"; "compile"; "ppx_native"] "deriving" (fun names ->
S[A"-ppx"; A("src/ppx_deriving_main.native " ^ (plugin_cmas names))]);
| _ -> ())