@@ -24,6 +24,8 @@ let times = Debug.find "times"
24
24
25
25
let debug_mem = Debug. find " mem"
26
26
27
+ let debug_wat = Debug. find " wat"
28
+
27
29
let () = Sys. catch_break true
28
30
29
31
let update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content sourcemap_file =
@@ -425,7 +427,11 @@ let run
425
427
else None )
426
428
@@ fun opt_tmp_map_file ->
427
429
let unit_data =
428
- Fs. with_intermediate_file (Filename. temp_file unit_name " .wat" )
430
+ (if debug_wat ()
431
+ then
432
+ fun f ->
433
+ f (Filename. concat (Filename. dirname output_file) (unit_name ^ " .wat" ))
434
+ else Fs. with_intermediate_file (Filename. temp_file unit_name " .wat" ))
429
435
@@ fun wat_file ->
430
436
let strings, fragments =
431
437
output_gen wat_file (output code ~unit_name: (Some unit_name))
@@ -454,7 +460,9 @@ let run
454
460
ic
455
461
in
456
462
if times () then Format. eprintf " parsing: %a@." Timer. print t1;
457
- Fs. with_intermediate_file (Filename. temp_file " code" " .wat" )
463
+ (if debug_wat ()
464
+ then fun f -> f (Filename. chop_extension output_file ^ " .wat" )
465
+ else Fs. with_intermediate_file (Filename. temp_file " code" " .wat" ))
458
466
@@ fun wat_file ->
459
467
let dir = Filename. chop_extension output_file ^ " .assets" in
460
468
Link. gen_dir dir
@@ -575,8 +583,10 @@ let info name =
575
583
~doc: " Wasm_of_ocaml compiler"
576
584
~description: " Wasm_of_ocaml is a compiler from OCaml bytecode to WebAssembly."
577
585
578
- let term = Cmdliner.Term. (const run $ Cmd_arg. options)
586
+ let options = Cmd_arg. options ()
587
+
588
+ let term = Cmdliner.Term. (const run $ options)
579
589
580
590
let command =
581
- let t = Cmdliner.Term. (const run $ Cmd_arg. options) in
591
+ let t = Cmdliner.Term. (const run $ options) in
582
592
Cmdliner.Cmd. v (info " compile" ) t
0 commit comments