Skip to content

Commit 9527a8d

Browse files
committed
Generate Unicode data using Dune
1 parent 0b59f3b commit 9527a8d

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

dune-project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
(depends
1818
(ocaml (>= 4.08.0))
1919
(cppo (and :build (>= 1.1.0)))
20-
(uutf (>= 1.0.0)))
20+
(uutf (>= 1.0.0))
21+
(uucp :with-dev-setup))
2122
(depopts
2223
lwt)
2324
(conflicts

notty.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ depends: [
1414
"ocaml" {>= "4.08.0"}
1515
"cppo" {build & >= "1.1.0"}
1616
"uutf" {>= "1.0.0"}
17+
"uucp" {with-dev-setup}
1718
"odoc" {with-doc}
1819
]
1920
depopts: ["lwt"]

src/no-uucp/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(rule
2+
(targets notty_uucp_data.ml notty_uucp_data.mli)
3+
(action
4+
(run ../../support/gen_unicode_props.exe))
5+
(mode promote))

support/dune

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(executable
2+
(name gen_unicode_props)
3+
(libraries uucp))

support/gen_unicode_props.ml

100755100644
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#!/usr/bin/env ocaml
21
(* Copyright (c) 2020 David Kaloper Meršinjak. All rights reserved.
32
See LICENSE.md. *)
43

5-
#use "topfind"
6-
#require "uucp"
7-
84
let filter p seq i = seq (fun x -> if p x then i x)
95
let map f seq i = seq (fun x -> i (f x))
106
let uchars it =
@@ -24,7 +20,7 @@ let intervals_kv seq i =
2420
seq f;
2521
match !s with Some e -> i e | _ -> ()
2622

27-
let intervals_p seq =
23+
let[@warning "-32"] intervals_p seq =
2824
map (fun x -> x, ()) seq |> intervals_kv |> map (fun (a, b, _) -> a, b)
2925

3026
(* Condenses code points into continuous range. *)
@@ -132,15 +128,15 @@ let extract (ppmli, ppml as ppfs) =
132128
133129
()
134130
135-
let file = "src/no-uucp/notty_uucp_data"
131+
let file = "notty_uucp_data"
136132
137133
let with_new name f =
138134
let o = open_out_gen [Open_trunc; Open_creat; Open_wronly] 0o664 name in
139135
let ppf = Format.formatter_of_out_channel o in
140136
f ppf; Format.pp_print_flush ppf (); close_out o
141137
142138
let () =
143-
Format.printf "Dumping Unicode v%s data to %s.@." Uucp.unicode_version file;
139+
Format.printf "Dumping Unicode v%s data to %s.ml and %s.mli.@." Uucp.unicode_version file file;
144140
with_new (file ^ ".mli") @@ fun ppmli ->
145141
with_new (file ^ ".ml") @@ fun ppml ->
146142
extract (ppmli, ppml)

0 commit comments

Comments
 (0)