@@ -24,6 +24,8 @@ let times = Debug.find "times"
2424
2525let debug_mem = Debug. find " mem"
2626
27+ let debug_wat = Debug. find " wat"
28+
2729let () = Sys. catch_break true
2830
2931let update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content sourcemap_file =
@@ -425,7 +427,11 @@ let run
425427 else None )
426428 @@ fun opt_tmp_map_file ->
427429 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" ))
429435 @@ fun wat_file ->
430436 let strings, fragments =
431437 output_gen wat_file (output code ~unit_name: (Some unit_name))
@@ -454,7 +460,9 @@ let run
454460 ic
455461 in
456462 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" ))
458466 @@ fun wat_file ->
459467 let dir = Filename. chop_extension output_file ^ " .assets" in
460468 Link. gen_dir dir
@@ -575,8 +583,10 @@ let info name =
575583 ~doc: " Wasm_of_ocaml compiler"
576584 ~description: " Wasm_of_ocaml is a compiler from OCaml bytecode to WebAssembly."
577585
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)
579589
580590let command =
581- let t = Cmdliner.Term. (const run $ Cmd_arg. options) in
591+ let t = Cmdliner.Term. (const run $ options) in
582592 Cmdliner.Cmd. v (info " compile" ) t
0 commit comments