@greenlabs/ppx-spice 0.1.8 → 0.1.9-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/docs/GUIDE.md +139 -0
- package/package.json +1 -1
- package/ppx-windows.exe +0 -0
- package/.github/workflows/build_linux.yml +0 -41
- package/.github/workflows/build_macos.yml +0 -41
- package/.github/workflows/build_windows.yml +0 -41
- package/.github/workflows/print_esy_cache.js +0 -13
- package/.github/workflows/publish.yml +0 -161
- package/.github/workflows/publish_prerelease.yml +0 -177
- package/.vscode/settings.json +0 -6
- package/src/.ocamlformat +0 -0
- package/src/bin/bin.ml +0 -1
- package/src/bin/dune +0 -5
- package/src/dune +0 -1
- package/src/dune-project +0 -2
- package/src/dune-workspace +0 -3
- package/src/esy.lock/.gitattributes +0 -3
- package/src/esy.lock/.gitignore +0 -3
- package/src/esy.lock/index.json +0 -1196
- package/src/esy.lock/opam/astring.0.8.5/opam +0 -37
- package/src/esy.lock/opam/base-bytes.base/opam +0 -9
- package/src/esy.lock/opam/base-threads.base/opam +0 -6
- package/src/esy.lock/opam/base-unix.base/opam +0 -6
- package/src/esy.lock/opam/base.v0.14.1/opam +0 -36
- package/src/esy.lock/opam/biniou.1.2.1/opam +0 -45
- package/src/esy.lock/opam/cmdliner.1.0.4/opam +0 -36
- package/src/esy.lock/opam/cppo.1.6.8/opam +0 -37
- package/src/esy.lock/opam/csexp.1.5.1/opam +0 -60
- package/src/esy.lock/opam/dot-merlin-reader.4.1/opam +0 -30
- package/src/esy.lock/opam/dune-build-info.2.9.1/opam +0 -42
- package/src/esy.lock/opam/dune-configurator.2.9.1/opam +0 -47
- package/src/esy.lock/opam/dune.2.9.1/opam +0 -58
- package/src/esy.lock/opam/easy-format.1.3.2/opam +0 -46
- package/src/esy.lock/opam/fix.20201120/opam +0 -24
- package/src/esy.lock/opam/fpath.0.7.3/opam +0 -36
- package/src/esy.lock/opam/menhir.20211012/opam +0 -28
- package/src/esy.lock/opam/menhirLib.20211012/opam +0 -29
- package/src/esy.lock/opam/menhirSdk.20211012/opam +0 -29
- package/src/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +0 -39
- package/src/esy.lock/opam/ocaml-lsp-server.1.8.3/opam +0 -54
- package/src/esy.lock/opam/ocamlbuild.0.14.0/opam +0 -36
- package/src/esy.lock/opam/ocamlfind.1.9.1/opam +0 -44
- package/src/esy.lock/opam/ocamlformat-rpc-lib.0.18.0/opam +0 -40
- package/src/esy.lock/opam/ocamlformat.0.19.0/opam +0 -55
- package/src/esy.lock/opam/ocp-indent.1.8.1/opam +0 -57
- package/src/esy.lock/opam/odoc-parser.0.9.0/opam +0 -45
- package/src/esy.lock/opam/pp.1.1.2/opam +0 -58
- package/src/esy.lock/opam/ppx_derivers.1.2.1/opam +0 -23
- package/src/esy.lock/opam/ppx_yojson_conv_lib.v0.14.0/opam +0 -24
- package/src/esy.lock/opam/ppxlib.0.23.0/opam +0 -62
- package/src/esy.lock/opam/re.1.10.3/opam +0 -46
- package/src/esy.lock/opam/result.1.5/opam +0 -22
- package/src/esy.lock/opam/seq.base/files/META.seq +0 -4
- package/src/esy.lock/opam/seq.base/files/seq.install +0 -3
- package/src/esy.lock/opam/seq.base/opam +0 -15
- package/src/esy.lock/opam/sexplib0.v0.14.0/opam +0 -26
- package/src/esy.lock/opam/stdio.v0.14.0/opam +0 -27
- package/src/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -31
- package/src/esy.lock/opam/topkg.1.0.4/opam +0 -44
- package/src/esy.lock/opam/uchar.0.0.2/opam +0 -36
- package/src/esy.lock/opam/uucp.14.0.0/opam +0 -41
- package/src/esy.lock/opam/uuseg.14.0.0/opam +0 -43
- package/src/esy.lock/opam/uutf.1.0.2/opam +0 -40
- package/src/esy.lock/opam/yojson.1.7.0/opam +0 -38
- package/src/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch +0 -463
- package/src/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json +0 -27
- package/src/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override/files/findlib-1.9.1.patch +0 -471
- package/src/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override/package.json +0 -61
- package/src/ppx/codecs.ml +0 -120
- package/src/ppx/decode_cases.ml +0 -18
- package/src/ppx/dune +0 -9
- package/src/ppx/polyvariants.ml +0 -288
- package/src/ppx/ppx_spice.ml +0 -19
- package/src/ppx/records.ml +0 -163
- package/src/ppx/signature.ml +0 -86
- package/src/ppx/structure.ml +0 -109
- package/src/ppx/tuple.ml +0 -68
- package/src/ppx/utils.ml +0 -117
- package/src/ppx/variants.ml +0 -257
- package/src/ppx_spice.opam +0 -21
- package/test/__tests__/test_optional_field_records.js +0 -91
- package/test/__tests__/test_optional_field_records.res +0 -98
- package/test/__tests__/test_polyvariants.js +0 -57
- package/test/__tests__/test_polyvariants.res +0 -41
- package/test/__tests__/test_records.js +0 -100
- package/test/__tests__/test_records.res +0 -111
- package/test/__tests__/test_variants.js +0 -85
- package/test/__tests__/test_variants.res +0 -63
- package/test/bsconfig.json +0 -27
- package/test/package.json +0 -18
- package/test/src/OptionalFieldRecords.js +0 -237
- package/test/src/OptionalFieldRecords.res +0 -23
- package/test/src/Polyvariants.js +0 -94
- package/test/src/Polyvariants.res +0 -5
- package/test/src/Polyvariants.resi +0 -5
- package/test/src/Records.js +0 -186
- package/test/src/Records.res +0 -17
- package/test/src/Records.resi +0 -17
- package/test/src/Spice.js +0 -448
- package/test/src/Spice_Codecs.js +0 -57
- package/test/src/Variants.js +0 -115
- package/test/src/Variants.res +0 -11
- package/test/src/Variants.resi +0 -11
- package/test/yarn.lock +0 -4194
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
--- ./Makefile
|
|
2
|
-
+++ ./Makefile
|
|
3
|
-
@@ -57,16 +57,16 @@
|
|
4
|
-
cat findlib.conf.in | \
|
|
5
|
-
$(SH) tools/patch '@SITELIB@' '$(OCAML_SITELIB)' >findlib.conf
|
|
6
|
-
if ./tools/cmd_from_same_dir ocamlc; then \
|
|
7
|
-
- echo 'ocamlc="ocamlc.opt"' >>findlib.conf; \
|
|
8
|
-
+ echo 'ocamlc="ocamlc.opt$(EXEC_SUFFIX)"' >>findlib.conf; \
|
|
9
|
-
fi
|
|
10
|
-
if ./tools/cmd_from_same_dir ocamlopt; then \
|
|
11
|
-
- echo 'ocamlopt="ocamlopt.opt"' >>findlib.conf; \
|
|
12
|
-
+ echo 'ocamlopt="ocamlopt.opt$(EXEC_SUFFIX)"' >>findlib.conf; \
|
|
13
|
-
fi
|
|
14
|
-
if ./tools/cmd_from_same_dir ocamldep; then \
|
|
15
|
-
- echo 'ocamldep="ocamldep.opt"' >>findlib.conf; \
|
|
16
|
-
+ echo 'ocamldep="ocamldep.opt$(EXEC_SUFFIX)"' >>findlib.conf; \
|
|
17
|
-
fi
|
|
18
|
-
if ./tools/cmd_from_same_dir ocamldoc; then \
|
|
19
|
-
- echo 'ocamldoc="ocamldoc.opt"' >>findlib.conf; \
|
|
20
|
-
+ echo 'ocamldoc="ocamldoc.opt$(EXEC_SUFFIX)"' >>findlib.conf; \
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
.PHONY: install-doc
|
|
24
|
-
--- ./src/findlib/findlib_config.mlp
|
|
25
|
-
+++ ./src/findlib/findlib_config.mlp
|
|
26
|
-
@@ -24,3 +24,5 @@
|
|
27
|
-
| "MacOS" -> "" (* don't know *)
|
|
28
|
-
| _ -> failwith "Unknown Sys.os_type"
|
|
29
|
-
;;
|
|
30
|
-
+
|
|
31
|
-
+let exec_suffix = "@EXEC_SUFFIX@";;
|
|
32
|
-
--- ./src/findlib/findlib.ml
|
|
33
|
-
+++ ./src/findlib/findlib.ml
|
|
34
|
-
@@ -28,15 +28,20 @@
|
|
35
|
-
let conf_ldconf = ref "";;
|
|
36
|
-
let conf_ignore_dups_in = ref ([] : string list);;
|
|
37
|
-
|
|
38
|
-
-let ocamlc_default = "ocamlc";;
|
|
39
|
-
-let ocamlopt_default = "ocamlopt";;
|
|
40
|
-
-let ocamlcp_default = "ocamlcp";;
|
|
41
|
-
-let ocamloptp_default = "ocamloptp";;
|
|
42
|
-
-let ocamlmklib_default = "ocamlmklib";;
|
|
43
|
-
-let ocamlmktop_default = "ocamlmktop";;
|
|
44
|
-
-let ocamldep_default = "ocamldep";;
|
|
45
|
-
-let ocamlbrowser_default = "ocamlbrowser";;
|
|
46
|
-
-let ocamldoc_default = "ocamldoc";;
|
|
47
|
-
+let add_exec str =
|
|
48
|
-
+ match Findlib_config.exec_suffix with
|
|
49
|
-
+ | "" -> str
|
|
50
|
-
+ | a -> str ^ a ;;
|
|
51
|
-
+let ocamlc_default = add_exec "ocamlc";;
|
|
52
|
-
+let ocamlopt_default = add_exec "ocamlopt";;
|
|
53
|
-
+let ocamlcp_default = add_exec "ocamlcp";;
|
|
54
|
-
+let ocamloptp_default = add_exec "ocamloptp";;
|
|
55
|
-
+let ocamlmklib_default = add_exec "ocamlmklib";;
|
|
56
|
-
+let ocamlmktop_default = add_exec "ocamlmktop";;
|
|
57
|
-
+let ocamldep_default = add_exec "ocamldep";;
|
|
58
|
-
+let ocamlbrowser_default = add_exec "ocamlbrowser";;
|
|
59
|
-
+let ocamldoc_default = add_exec "ocamldoc";;
|
|
60
|
-
+
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
let init_manually
|
|
64
|
-
--- ./src/findlib/fl_package_base.ml
|
|
65
|
-
+++ ./src/findlib/fl_package_base.ml
|
|
66
|
-
@@ -133,7 +133,15 @@
|
|
67
|
-
List.find (fun def -> def.def_var = "exists_if") p.package_defs in
|
|
68
|
-
let files = Fl_split.in_words def.def_value in
|
|
69
|
-
List.exists
|
|
70
|
-
- (fun file -> Sys.file_exists (Filename.concat d' file))
|
|
71
|
-
+ (fun file ->
|
|
72
|
-
+ let fln = Filename.concat d' file in
|
|
73
|
-
+ let e = Sys.file_exists fln in
|
|
74
|
-
+ (* necessary for ppx executables *)
|
|
75
|
-
+ if e || Sys.os_type <> "Win32" || Filename.check_suffix fln ".exe" then
|
|
76
|
-
+ e
|
|
77
|
-
+ else
|
|
78
|
-
+ Sys.file_exists (fln ^ ".exe")
|
|
79
|
-
+ )
|
|
80
|
-
files
|
|
81
|
-
with Not_found -> true in
|
|
82
|
-
|
|
83
|
-
--- ./src/findlib/fl_split.ml
|
|
84
|
-
+++ ./src/findlib/fl_split.ml
|
|
85
|
-
@@ -126,10 +126,17 @@
|
|
86
|
-
| '/' | '\\' -> true
|
|
87
|
-
| _ -> false in
|
|
88
|
-
let norm_dir_win() =
|
|
89
|
-
- if l >= 1 && s.[0] = '/' then
|
|
90
|
-
- Buffer.add_char b '\\' else Buffer.add_char b s.[0];
|
|
91
|
-
- if l >= 2 && s.[1] = '/' then
|
|
92
|
-
- Buffer.add_char b '\\' else Buffer.add_char b s.[1];
|
|
93
|
-
+ if l >= 1 then (
|
|
94
|
-
+ if s.[0] = '/' then
|
|
95
|
-
+ Buffer.add_char b '\\'
|
|
96
|
-
+ else
|
|
97
|
-
+ Buffer.add_char b s.[0] ;
|
|
98
|
-
+ if l >= 2 then
|
|
99
|
-
+ if s.[1] = '/' then
|
|
100
|
-
+ Buffer.add_char b '\\'
|
|
101
|
-
+ else
|
|
102
|
-
+ Buffer.add_char b s.[1];
|
|
103
|
-
+ );
|
|
104
|
-
for k = 2 to l - 1 do
|
|
105
|
-
let c = s.[k] in
|
|
106
|
-
if is_slash c then (
|
|
107
|
-
--- ./src/findlib/frontend.ml
|
|
108
|
-
+++ ./src/findlib/frontend.ml
|
|
109
|
-
@@ -31,10 +31,18 @@
|
|
110
|
-
else
|
|
111
|
-
Sys_error (arg ^ ": " ^ Unix.error_message code)
|
|
112
|
-
|
|
113
|
-
+let is_win = Sys.os_type = "Win32"
|
|
114
|
-
+
|
|
115
|
-
+let () =
|
|
116
|
-
+ match Findlib_config.system with
|
|
117
|
-
+ | "win32" | "win64" | "mingw" | "cygwin" | "mingw64" | "cygwin64" ->
|
|
118
|
-
+ (try set_binary_mode_out stdout true with _ -> ());
|
|
119
|
-
+ (try set_binary_mode_out stderr true with _ -> ());
|
|
120
|
-
+ | _ -> ()
|
|
121
|
-
|
|
122
|
-
let slashify s =
|
|
123
|
-
match Findlib_config.system with
|
|
124
|
-
- | "mingw" | "mingw64" | "cygwin" ->
|
|
125
|
-
+ | "win32" | "win64" | "mingw" | "cygwin" | "mingw64" | "cygwin64" ->
|
|
126
|
-
let b = Buffer.create 80 in
|
|
127
|
-
String.iter
|
|
128
|
-
(function
|
|
129
|
-
@@ -49,7 +57,7 @@
|
|
130
|
-
|
|
131
|
-
let out_path ?(prefix="") s =
|
|
132
|
-
match Findlib_config.system with
|
|
133
|
-
- | "mingw" | "mingw64" | "cygwin" ->
|
|
134
|
-
+ | "win32" | "win64" | "mingw" | "mingw64" | "cygwin" ->
|
|
135
|
-
let u = slashify s in
|
|
136
|
-
prefix ^
|
|
137
|
-
(if String.contains u ' ' then
|
|
138
|
-
@@ -273,11 +281,9 @@
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let identify_dir d =
|
|
142
|
-
- match Sys.os_type with
|
|
143
|
-
- | "Win32" ->
|
|
144
|
-
- failwith "identify_dir" (* not available *)
|
|
145
|
-
- | _ ->
|
|
146
|
-
- let s = Unix.stat d in
|
|
147
|
-
+ if is_win then
|
|
148
|
-
+ failwith "identify_dir"; (* not available *)
|
|
149
|
-
+ let s = Unix.stat d in
|
|
150
|
-
(s.Unix.st_dev, s.Unix.st_ino)
|
|
151
|
-
;;
|
|
152
|
-
|
|
153
|
-
@@ -459,6 +465,96 @@
|
|
154
|
-
)
|
|
155
|
-
packages
|
|
156
|
-
|
|
157
|
-
+let rewrite_cmd s =
|
|
158
|
-
+ if s = "" || not is_win then
|
|
159
|
-
+ s
|
|
160
|
-
+ else
|
|
161
|
-
+ let s =
|
|
162
|
-
+ let l = String.length s in
|
|
163
|
-
+ let b = Buffer.create l in
|
|
164
|
-
+ for i = 0 to pred l do
|
|
165
|
-
+ match s.[i] with
|
|
166
|
-
+ | '/' -> Buffer.add_char b '\\'
|
|
167
|
-
+ | x -> Buffer.add_char b x
|
|
168
|
-
+ done;
|
|
169
|
-
+ Buffer.contents b
|
|
170
|
-
+ in
|
|
171
|
-
+ if (Filename.is_implicit s && String.contains s '\\' = false) ||
|
|
172
|
-
+ Filename.check_suffix (String.lowercase s) ".exe" then
|
|
173
|
-
+ s
|
|
174
|
-
+ else
|
|
175
|
-
+ let s' = s ^ ".exe" in
|
|
176
|
-
+ if Sys.file_exists s' then
|
|
177
|
-
+ s'
|
|
178
|
-
+ else
|
|
179
|
-
+ s
|
|
180
|
-
+
|
|
181
|
-
+let rewrite_cmd s =
|
|
182
|
-
+ if s = "" || not is_win then s else
|
|
183
|
-
+ let s =
|
|
184
|
-
+ let l = String.length s in
|
|
185
|
-
+ let b = Buffer.create l in
|
|
186
|
-
+ for i = 0 to pred l do
|
|
187
|
-
+ match s.[i] with
|
|
188
|
-
+ | '/' -> Buffer.add_char b '\\'
|
|
189
|
-
+ | x -> Buffer.add_char b x
|
|
190
|
-
+ done;
|
|
191
|
-
+ Buffer.contents b
|
|
192
|
-
+ in
|
|
193
|
-
+ if (Filename.is_implicit s && String.contains s '\\' = false) ||
|
|
194
|
-
+ Filename.check_suffix (String.lowercase s) ".exe" then
|
|
195
|
-
+ s
|
|
196
|
-
+ else
|
|
197
|
-
+ let s' = s ^ ".exe" in
|
|
198
|
-
+ if Sys.file_exists s' then
|
|
199
|
-
+ s'
|
|
200
|
-
+ else
|
|
201
|
-
+ s
|
|
202
|
-
+
|
|
203
|
-
+let rewrite_pp cmd =
|
|
204
|
-
+ if not is_win then cmd else
|
|
205
|
-
+ let module T = struct exception Keep end in
|
|
206
|
-
+ let is_whitespace = function
|
|
207
|
-
+ | ' ' | '\011' | '\012' | '\n' | '\r' | '\t' -> true
|
|
208
|
-
+ | _ -> false in
|
|
209
|
-
+ (* characters that triggers special behaviour (cmd.exe, not unix shell) *)
|
|
210
|
-
+ let is_unsafe_char = function
|
|
211
|
-
+ | '(' | ')' | '%' | '!' | '^' | '<' | '>' | '&' -> true
|
|
212
|
-
+ | _ -> false in
|
|
213
|
-
+ let len = String.length cmd in
|
|
214
|
-
+ let buf = Buffer.create (len + 4) in
|
|
215
|
-
+ let buf_cmd = Buffer.create len in
|
|
216
|
-
+ let rec iter_ws i =
|
|
217
|
-
+ if i >= len then () else
|
|
218
|
-
+ let cur = cmd.[i] in
|
|
219
|
-
+ if is_whitespace cur then (
|
|
220
|
-
+ Buffer.add_char buf cur;
|
|
221
|
-
+ iter_ws (succ i)
|
|
222
|
-
+ )
|
|
223
|
-
+ else
|
|
224
|
-
+ iter_cmd i
|
|
225
|
-
+ and iter_cmd i =
|
|
226
|
-
+ if i >= len then add_buf_cmd () else
|
|
227
|
-
+ let cur = cmd.[i] in
|
|
228
|
-
+ if is_unsafe_char cur || cur = '"' || cur = '\'' then
|
|
229
|
-
+ raise T.Keep;
|
|
230
|
-
+ if is_whitespace cur then (
|
|
231
|
-
+ add_buf_cmd ();
|
|
232
|
-
+ Buffer.add_substring buf cmd i (len - i)
|
|
233
|
-
+ )
|
|
234
|
-
+ else (
|
|
235
|
-
+ Buffer.add_char buf_cmd cur;
|
|
236
|
-
+ iter_cmd (succ i)
|
|
237
|
-
+ )
|
|
238
|
-
+ and add_buf_cmd () =
|
|
239
|
-
+ if Buffer.length buf_cmd > 0 then
|
|
240
|
-
+ Buffer.add_string buf (rewrite_cmd (Buffer.contents buf_cmd))
|
|
241
|
-
+ in
|
|
242
|
-
+ try
|
|
243
|
-
+ iter_ws 0;
|
|
244
|
-
+ Buffer.contents buf
|
|
245
|
-
+ with
|
|
246
|
-
+ | T.Keep -> cmd
|
|
247
|
-
|
|
248
|
-
let process_pp_spec syntax_preds packages pp_opts =
|
|
249
|
-
(* Returns: pp_command *)
|
|
250
|
-
@@ -549,7 +645,7 @@
|
|
251
|
-
None -> []
|
|
252
|
-
| Some cmd ->
|
|
253
|
-
["-pp";
|
|
254
|
-
- cmd ^ " " ^
|
|
255
|
-
+ (rewrite_cmd cmd) ^ " " ^
|
|
256
|
-
String.concat " " (List.map Filename.quote pp_i_options) ^ " " ^
|
|
257
|
-
String.concat " " (List.map Filename.quote pp_archives) ^ " " ^
|
|
258
|
-
String.concat " " (List.map Filename.quote pp_opts)]
|
|
259
|
-
@@ -625,9 +721,11 @@
|
|
260
|
-
in
|
|
261
|
-
try
|
|
262
|
-
let preprocessor =
|
|
263
|
-
+ rewrite_cmd (
|
|
264
|
-
resolve_path
|
|
265
|
-
~base ~explicit:true
|
|
266
|
-
- (package_property predicates pname "ppx") in
|
|
267
|
-
+ (package_property predicates pname "ppx") )
|
|
268
|
-
+ in
|
|
269
|
-
["-ppx"; String.concat " " (preprocessor :: options)]
|
|
270
|
-
with Not_found -> []
|
|
271
|
-
)
|
|
272
|
-
@@ -895,6 +993,14 @@
|
|
273
|
-
switch (e.g. -L<path> instead of -L <path>)
|
|
274
|
-
*)
|
|
275
|
-
|
|
276
|
-
+(* We may need to remove files on which we do not have complete control.
|
|
277
|
-
+ On Windows, removing a read-only file fails so try to change the
|
|
278
|
-
+ mode of the file first. *)
|
|
279
|
-
+let remove_file fname =
|
|
280
|
-
+ try Sys.remove fname
|
|
281
|
-
+ with Sys_error _ when is_win ->
|
|
282
|
-
+ (try Unix.chmod fname 0o666 with Unix.Unix_error _ -> ());
|
|
283
|
-
+ Sys.remove fname
|
|
284
|
-
|
|
285
|
-
let ocamlc which () =
|
|
286
|
-
|
|
287
|
-
@@ -1022,9 +1128,12 @@
|
|
288
|
-
|
|
289
|
-
"-intf",
|
|
290
|
-
Arg.String (fun s -> pass_files := !pass_files @ [ Intf(slashify s) ]);
|
|
291
|
-
-
|
|
292
|
-
+
|
|
293
|
-
"-pp",
|
|
294
|
-
- Arg.String (fun s -> pp_specified := true; add_spec_fn "-pp" s);
|
|
295
|
-
+ Arg.String (fun s -> pp_specified := true; add_spec_fn "-pp" (rewrite_pp s));
|
|
296
|
-
+
|
|
297
|
-
+ "-ppx",
|
|
298
|
-
+ Arg.String (fun s -> add_spec_fn "-ppx" (rewrite_pp s));
|
|
299
|
-
|
|
300
|
-
"-thread",
|
|
301
|
-
Arg.Unit (fun _ -> threads := threads_default);
|
|
302
|
-
@@ -1237,7 +1346,7 @@
|
|
303
|
-
with
|
|
304
|
-
any ->
|
|
305
|
-
close_out initl;
|
|
306
|
-
- Sys.remove initl_file_name;
|
|
307
|
-
+ remove_file initl_file_name;
|
|
308
|
-
raise any
|
|
309
|
-
end;
|
|
310
|
-
|
|
311
|
-
@@ -1245,9 +1354,9 @@
|
|
312
|
-
at_exit
|
|
313
|
-
(fun () ->
|
|
314
|
-
let tr f x = try f x with _ -> () in
|
|
315
|
-
- tr Sys.remove initl_file_name;
|
|
316
|
-
- tr Sys.remove (Filename.chop_extension initl_file_name ^ ".cmi");
|
|
317
|
-
- tr Sys.remove (Filename.chop_extension initl_file_name ^ ".cmo");
|
|
318
|
-
+ tr remove_file initl_file_name;
|
|
319
|
-
+ tr remove_file (Filename.chop_extension initl_file_name ^ ".cmi");
|
|
320
|
-
+ tr remove_file (Filename.chop_extension initl_file_name ^ ".cmo");
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
let exclude_list = [ stdlibdir; threads_dir; vmthreads_dir ] in
|
|
324
|
-
@@ -1493,7 +1602,9 @@
|
|
325
|
-
[ "-v", Arg.Unit (fun () -> verbose := Verbose);
|
|
326
|
-
"-pp", Arg.String (fun s ->
|
|
327
|
-
pp_specified := true;
|
|
328
|
-
- options := !options @ ["-pp"; s]);
|
|
329
|
-
+ options := !options @ ["-pp"; rewrite_pp s]);
|
|
330
|
-
+ "-ppx", Arg.String (fun s ->
|
|
331
|
-
+ options := !options @ ["-ppx"; rewrite_pp s]);
|
|
332
|
-
]
|
|
333
|
-
)
|
|
334
|
-
)
|
|
335
|
-
@@ -1672,7 +1783,9 @@
|
|
336
|
-
Arg.String (fun s -> add_spec_fn "-I" (slashify (resolve_path s)));
|
|
337
|
-
|
|
338
|
-
"-pp", Arg.String (fun s -> pp_specified := true;
|
|
339
|
-
- add_spec_fn "-pp" s);
|
|
340
|
-
+ add_spec_fn "-pp" (rewrite_pp s));
|
|
341
|
-
+ "-ppx", Arg.String (fun s -> add_spec_fn "-ppx" (rewrite_pp s));
|
|
342
|
-
+
|
|
343
|
-
]
|
|
344
|
-
)
|
|
345
|
-
)
|
|
346
|
-
@@ -1830,7 +1943,10 @@
|
|
347
|
-
output_string ch_out append;
|
|
348
|
-
close_out ch_out;
|
|
349
|
-
close_in ch_in;
|
|
350
|
-
- Unix.utimes outpath s.Unix.st_mtime s.Unix.st_mtime;
|
|
351
|
-
+ (try Unix.utimes outpath s.Unix.st_mtime s.Unix.st_mtime
|
|
352
|
-
+ with Unix.Unix_error(e,_,_) ->
|
|
353
|
-
+ prerr_endline("Warning: setting utimes for " ^ outpath
|
|
354
|
-
+ ^ ": " ^ Unix.error_message e));
|
|
355
|
-
|
|
356
|
-
prerr_endline("Installed " ^ outpath);
|
|
357
|
-
with
|
|
358
|
-
@@ -1882,6 +1998,8 @@
|
|
359
|
-
Unix.openfile (Filename.concat dir owner_file) [Unix.O_RDONLY] 0 in
|
|
360
|
-
let f =
|
|
361
|
-
Unix.in_channel_of_descr fd in
|
|
362
|
-
+ if is_win then
|
|
363
|
-
+ set_binary_mode_in f false;
|
|
364
|
-
try
|
|
365
|
-
let line = input_line f in
|
|
366
|
-
let is_my_file = (line = pkg) in
|
|
367
|
-
@@ -2208,7 +2326,7 @@
|
|
368
|
-
let lines = read_ldconf !ldconf in
|
|
369
|
-
let dlldir_norm = Fl_split.norm_dir dlldir in
|
|
370
|
-
let dlldir_norm_lc = string_lowercase_ascii dlldir_norm in
|
|
371
|
-
- let ci_filesys = (Sys.os_type = "Win32") in
|
|
372
|
-
+ let ci_filesys = is_win in
|
|
373
|
-
let check_dir d =
|
|
374
|
-
let d' = Fl_split.norm_dir d in
|
|
375
|
-
(d' = dlldir_norm) ||
|
|
376
|
-
@@ -2356,7 +2474,7 @@
|
|
377
|
-
List.iter
|
|
378
|
-
(fun file ->
|
|
379
|
-
let absfile = Filename.concat dlldir file in
|
|
380
|
-
- Sys.remove absfile;
|
|
381
|
-
+ remove_file absfile;
|
|
382
|
-
prerr_endline ("Removed " ^ absfile)
|
|
383
|
-
)
|
|
384
|
-
dll_files
|
|
385
|
-
@@ -2365,7 +2483,7 @@
|
|
386
|
-
(* Remove the files from the package directory: *)
|
|
387
|
-
if Sys.file_exists pkgdir then begin
|
|
388
|
-
let files = Sys.readdir pkgdir in
|
|
389
|
-
- Array.iter (fun f -> Sys.remove (Filename.concat pkgdir f)) files;
|
|
390
|
-
+ Array.iter (fun f -> remove_file (Filename.concat pkgdir f)) files;
|
|
391
|
-
Unix.rmdir pkgdir;
|
|
392
|
-
prerr_endline ("Removed " ^ pkgdir)
|
|
393
|
-
end
|
|
394
|
-
@@ -2415,7 +2533,9 @@
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
let print_configuration() =
|
|
398
|
-
+ let sl = slashify in
|
|
399
|
-
let dir s =
|
|
400
|
-
+ let s = sl s in
|
|
401
|
-
if Sys.file_exists s then
|
|
402
|
-
s
|
|
403
|
-
else
|
|
404
|
-
@@ -2453,27 +2573,27 @@
|
|
405
|
-
if md = "" then "the corresponding package directories" else dir md
|
|
406
|
-
);
|
|
407
|
-
Printf.printf "The standard library is assumed to reside in:\n %s\n"
|
|
408
|
-
- (Findlib.ocaml_stdlib());
|
|
409
|
-
+ (sl (Findlib.ocaml_stdlib()));
|
|
410
|
-
Printf.printf "The ld.conf file can be found here:\n %s\n"
|
|
411
|
-
- (Findlib.ocaml_ldconf());
|
|
412
|
-
+ (sl (Findlib.ocaml_ldconf()));
|
|
413
|
-
flush stdout
|
|
414
|
-
| Some "conf" ->
|
|
415
|
-
- print_endline (Findlib.config_file())
|
|
416
|
-
+ print_endline (sl (Findlib.config_file()))
|
|
417
|
-
| Some "path" ->
|
|
418
|
-
- List.iter print_endline (Findlib.search_path())
|
|
419
|
-
+ List.iter ( fun x -> print_endline (sl x)) (Findlib.search_path())
|
|
420
|
-
| Some "destdir" ->
|
|
421
|
-
- print_endline (Findlib.default_location())
|
|
422
|
-
+ print_endline ( sl (Findlib.default_location()))
|
|
423
|
-
| Some "metadir" ->
|
|
424
|
-
- print_endline (Findlib.meta_directory())
|
|
425
|
-
+ print_endline ( sl (Findlib.meta_directory()))
|
|
426
|
-
| Some "metapath" ->
|
|
427
|
-
let mdir = Findlib.meta_directory() in
|
|
428
|
-
let ddir = Findlib.default_location() in
|
|
429
|
-
- print_endline
|
|
430
|
-
- (if mdir <> "" then mdir ^ "/META.%s" else ddir ^ "/%s/META")
|
|
431
|
-
+ print_endline ( sl
|
|
432
|
-
+ (if mdir <> "" then mdir ^ "/META.%s" else ddir ^ "/%s/META"))
|
|
433
|
-
| Some "stdlib" ->
|
|
434
|
-
- print_endline (Findlib.ocaml_stdlib())
|
|
435
|
-
+ print_endline ( sl (Findlib.ocaml_stdlib()))
|
|
436
|
-
| Some "ldconf" ->
|
|
437
|
-
- print_endline (Findlib.ocaml_ldconf())
|
|
438
|
-
+ print_endline ( sl (Findlib.ocaml_ldconf()))
|
|
439
|
-
| _ ->
|
|
440
|
-
assert false
|
|
441
|
-
;;
|
|
442
|
-
@@ -2481,7 +2601,7 @@
|
|
443
|
-
|
|
444
|
-
let ocamlcall pkg cmd =
|
|
445
|
-
let dir = package_directory pkg in
|
|
446
|
-
- let path = Filename.concat dir cmd in
|
|
447
|
-
+ let path = rewrite_cmd (Filename.concat dir cmd) in
|
|
448
|
-
begin
|
|
449
|
-
try Unix.access path [ Unix.X_OK ]
|
|
450
|
-
with
|
|
451
|
-
@@ -2647,6 +2767,10 @@
|
|
452
|
-
| Sys_error f ->
|
|
453
|
-
prerr_endline ("ocamlfind: " ^ f);
|
|
454
|
-
exit 2
|
|
455
|
-
+ | Unix.Unix_error (e, fn, f) ->
|
|
456
|
-
+ prerr_endline ("ocamlfind: " ^ fn ^ " " ^ f
|
|
457
|
-
+ ^ ": " ^ Unix.error_message e);
|
|
458
|
-
+ exit 2
|
|
459
|
-
| Findlib.No_such_package(pkg,info) ->
|
|
460
|
-
prerr_endline ("ocamlfind: Package `" ^ pkg ^ "' not found" ^
|
|
461
|
-
(if info <> "" then " - " ^ info else ""));
|
|
462
|
-
--- ./src/findlib/Makefile
|
|
463
|
-
+++ ./src/findlib/Makefile
|
|
464
|
-
@@ -90,6 +90,7 @@
|
|
465
|
-
cat findlib_config.mlp | \
|
|
466
|
-
$(SH) $(TOP)/tools/patch '@CONFIGFILE@' '$(OCAMLFIND_CONF)' | \
|
|
467
|
-
$(SH) $(TOP)/tools/patch '@STDLIB@' '$(OCAML_CORE_STDLIB)' | \
|
|
468
|
-
+ $(SH) $(TOP)/tools/patch '@EXEC_SUFFIX@' '$(EXEC_SUFFIX)' | \
|
|
469
|
-
sed -e 's;@AUTOLINK@;$(OCAML_AUTOLINK);g' \
|
|
470
|
-
-e 's;@SYSTEM@;$(SYSTEM);g' \
|
|
471
|
-
>findlib_config.ml
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"build": [
|
|
3
|
-
[
|
|
4
|
-
"bash",
|
|
5
|
-
"-c",
|
|
6
|
-
"#{os == 'windows' ? 'patch -p1 < findlib-1.9.1.patch' : 'true'}"
|
|
7
|
-
],
|
|
8
|
-
[
|
|
9
|
-
"./configure",
|
|
10
|
-
"-bindir",
|
|
11
|
-
"#{self.bin}",
|
|
12
|
-
"-sitelib",
|
|
13
|
-
"#{self.lib}",
|
|
14
|
-
"-mandir",
|
|
15
|
-
"#{self.man}",
|
|
16
|
-
"-config",
|
|
17
|
-
"#{self.lib}/findlib.conf",
|
|
18
|
-
"-no-custom",
|
|
19
|
-
"-no-topfind"
|
|
20
|
-
],
|
|
21
|
-
[
|
|
22
|
-
"make",
|
|
23
|
-
"all"
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
"make",
|
|
27
|
-
"opt"
|
|
28
|
-
]
|
|
29
|
-
],
|
|
30
|
-
"install": [
|
|
31
|
-
[
|
|
32
|
-
"make",
|
|
33
|
-
"install"
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
"install",
|
|
37
|
-
"-m",
|
|
38
|
-
"0755",
|
|
39
|
-
"ocaml-stub",
|
|
40
|
-
"#{self.bin}/ocaml"
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
"mkdir",
|
|
44
|
-
"-p",
|
|
45
|
-
"#{self.toplevel}"
|
|
46
|
-
],
|
|
47
|
-
[
|
|
48
|
-
"install",
|
|
49
|
-
"-m",
|
|
50
|
-
"0644",
|
|
51
|
-
"src/findlib/topfind",
|
|
52
|
-
"#{self.toplevel}/topfind"
|
|
53
|
-
]
|
|
54
|
-
],
|
|
55
|
-
"exportedEnv": {
|
|
56
|
-
"OCAML_TOPLEVEL_PATH": {
|
|
57
|
-
"val": "#{self.toplevel}",
|
|
58
|
-
"scope": "global"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/ppx/codecs.ml
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
open Ppxlib
|
|
2
|
-
open Parsetree
|
|
3
|
-
open Ast_helper
|
|
4
|
-
open Utils
|
|
5
|
-
|
|
6
|
-
let rec parameterize_codecs type_args encoder_func decoder_func
|
|
7
|
-
generator_settings =
|
|
8
|
-
let sub_encoders, sub_decoders =
|
|
9
|
-
type_args
|
|
10
|
-
|> List.map (fun core_type -> generate_codecs generator_settings core_type)
|
|
11
|
-
|> List.split
|
|
12
|
-
in
|
|
13
|
-
( (match encoder_func with
|
|
14
|
-
| None -> None
|
|
15
|
-
| Some encoder_func ->
|
|
16
|
-
sub_encoders
|
|
17
|
-
|> List.map (fun e -> (Asttypes.Nolabel, Option.get e))
|
|
18
|
-
|> Exp.apply encoder_func |> Option.some),
|
|
19
|
-
match decoder_func with
|
|
20
|
-
| None -> None
|
|
21
|
-
| Some decoder_func ->
|
|
22
|
-
sub_decoders
|
|
23
|
-
|> List.map (fun e -> (Asttypes.Nolabel, Option.get e))
|
|
24
|
-
|> Exp.apply decoder_func |> Option.some )
|
|
25
|
-
|
|
26
|
-
and generate_constr_codecs { do_encode; do_decode }
|
|
27
|
-
{ Location.txt = identifier; loc } =
|
|
28
|
-
let open Longident in
|
|
29
|
-
match identifier with
|
|
30
|
-
| Lident "string" ->
|
|
31
|
-
( some_if_true do_encode [%expr Spice.stringToJson],
|
|
32
|
-
some_if_true do_decode [%expr Spice.stringFromJson] )
|
|
33
|
-
| Lident "int" ->
|
|
34
|
-
( some_if_true do_encode [%expr Spice.intToJson],
|
|
35
|
-
some_if_true do_decode [%expr Spice.intFromJson] )
|
|
36
|
-
| Lident "int64" ->
|
|
37
|
-
( some_if_true do_encode [%expr Spice.int64ToJson],
|
|
38
|
-
some_if_true do_decode [%expr Spice.int64FromJson] )
|
|
39
|
-
| Lident "float" ->
|
|
40
|
-
( some_if_true do_encode [%expr Spice.floatToJson],
|
|
41
|
-
some_if_true do_decode [%expr Spice.floatFromJson] )
|
|
42
|
-
| Lident "bool" ->
|
|
43
|
-
( some_if_true do_encode [%expr Spice.boolToJson],
|
|
44
|
-
some_if_true do_decode [%expr Spice.boolFromJson] )
|
|
45
|
-
| Lident "unit" ->
|
|
46
|
-
( some_if_true do_encode [%expr Spice.unitToJson],
|
|
47
|
-
some_if_true do_decode [%expr Spice.unitFromJson] )
|
|
48
|
-
| Lident "array" ->
|
|
49
|
-
( some_if_true do_encode [%expr Spice.arrayToJson],
|
|
50
|
-
some_if_true do_decode [%expr Spice.arrayFromJson] )
|
|
51
|
-
| Lident "list" ->
|
|
52
|
-
( some_if_true do_encode [%expr Spice.listToJson],
|
|
53
|
-
some_if_true do_decode [%expr Spice.listFromJson] )
|
|
54
|
-
| Lident "option" ->
|
|
55
|
-
( some_if_true do_encode [%expr Spice.optionToJson],
|
|
56
|
-
some_if_true do_decode [%expr Spice.optionFromJson] )
|
|
57
|
-
| Ldot (Ldot (Lident "Belt", "Result"), "t") ->
|
|
58
|
-
( some_if_true do_encode [%expr Spice.resultToJson],
|
|
59
|
-
some_if_true do_decode [%expr Spice.resultFromJson] )
|
|
60
|
-
| Ldot (Ldot (Lident "Js", "Dict"), "t") ->
|
|
61
|
-
( some_if_true do_encode [%expr Spice.dictToJson],
|
|
62
|
-
some_if_true do_decode [%expr Spice.dictFromJson] )
|
|
63
|
-
| Ldot (Ldot (Lident "Js", "Json"), "t") ->
|
|
64
|
-
( some_if_true do_encode [%expr fun v -> v],
|
|
65
|
-
some_if_true do_decode [%expr fun v -> Belt.Result.Ok v] )
|
|
66
|
-
| Lident s ->
|
|
67
|
-
( some_if_true do_encode (make_ident_expr (s ^ Utils.encoder_func_suffix)),
|
|
68
|
-
some_if_true do_decode (make_ident_expr (s ^ Utils.decoder_func_suffix))
|
|
69
|
-
)
|
|
70
|
-
| Ldot (left, right) ->
|
|
71
|
-
( some_if_true do_encode
|
|
72
|
-
(Exp.ident (mknoloc (Ldot (left, right ^ Utils.encoder_func_suffix)))),
|
|
73
|
-
some_if_true do_decode
|
|
74
|
-
(Exp.ident (mknoloc (Ldot (left, right ^ Utils.decoder_func_suffix))))
|
|
75
|
-
)
|
|
76
|
-
| Lapply (_, _) -> fail loc "Lapply syntax not yet handled by spice"
|
|
77
|
-
|
|
78
|
-
and generate_codecs ({ do_encode; do_decode } as generator_settings)
|
|
79
|
-
{ ptyp_desc; ptyp_loc; ptyp_attributes } =
|
|
80
|
-
match ptyp_desc with
|
|
81
|
-
| Ptyp_any -> fail ptyp_loc "Can't generate codecs for `any` type"
|
|
82
|
-
| Ptyp_arrow (_, _, _) ->
|
|
83
|
-
fail ptyp_loc "Can't generate codecs for function type"
|
|
84
|
-
| Ptyp_package _ -> fail ptyp_loc "Can't generate codecs for module type"
|
|
85
|
-
| Ptyp_tuple types ->
|
|
86
|
-
let composite_codecs =
|
|
87
|
-
List.map (generate_codecs generator_settings) types
|
|
88
|
-
in
|
|
89
|
-
( some_if_true do_encode
|
|
90
|
-
(composite_codecs
|
|
91
|
-
|> List.map (fun (e, _) -> Option.get e)
|
|
92
|
-
|> Tuple.generate_encoder),
|
|
93
|
-
some_if_true do_decode
|
|
94
|
-
(composite_codecs
|
|
95
|
-
|> List.map (fun (_, d) -> Option.get d)
|
|
96
|
-
|> Tuple.generate_decoder) )
|
|
97
|
-
| Ptyp_var s ->
|
|
98
|
-
( some_if_true do_encode (make_ident_expr (encoder_var_prefix ^ s)),
|
|
99
|
-
some_if_true do_decode (make_ident_expr (decoder_var_prefix ^ s)) )
|
|
100
|
-
| Ptyp_constr (constr, typeArgs) -> (
|
|
101
|
-
let custom_codec = get_attribute_by_name ptyp_attributes "spice.codec" in
|
|
102
|
-
let encode, decode =
|
|
103
|
-
match custom_codec with
|
|
104
|
-
| Ok None -> generate_constr_codecs generator_settings constr
|
|
105
|
-
| Ok (Some attribute) ->
|
|
106
|
-
let expr = get_expression_from_payload attribute in
|
|
107
|
-
( some_if_true do_encode
|
|
108
|
-
[%expr
|
|
109
|
-
let e, _ = [%e expr] in
|
|
110
|
-
e],
|
|
111
|
-
some_if_true do_decode
|
|
112
|
-
[%expr
|
|
113
|
-
let _, d = [%e expr] in
|
|
114
|
-
d] )
|
|
115
|
-
| Error s -> fail ptyp_loc s
|
|
116
|
-
in
|
|
117
|
-
match List.length typeArgs = 0 with
|
|
118
|
-
| true -> (encode, decode)
|
|
119
|
-
| false -> parameterize_codecs typeArgs encode decode generator_settings)
|
|
120
|
-
| _ -> fail ptyp_loc "This syntax is not yet handled by spice"
|
package/src/ppx/decode_cases.ml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
open Ppxlib
|
|
2
|
-
open Parsetree
|
|
3
|
-
open Ast_helper
|
|
4
|
-
open Utils
|
|
5
|
-
|
|
6
|
-
let generate_error_case numArgs i _ =
|
|
7
|
-
{
|
|
8
|
-
pc_lhs =
|
|
9
|
-
Array.init numArgs (fun which ->
|
|
10
|
-
match which == i with
|
|
11
|
-
| true -> [%pat? Belt.Result.Error (e : Spice.decodeError)]
|
|
12
|
-
| false -> [%pat? _])
|
|
13
|
-
|> Array.to_list
|
|
14
|
-
|> tuple_or_singleton Pat.tuple;
|
|
15
|
-
pc_guard = None;
|
|
16
|
-
pc_rhs =
|
|
17
|
-
[%expr Belt.Result.Error { e with path = [%e index_const i] ^ e.path }];
|
|
18
|
-
}
|