From 3a8dbf4f4d853880a98bd70a44b9dd47c92ebdd5 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Thu, 29 Jun 2023 14:57:26 +0200 Subject: [PATCH] [hxb] separate hxb output from json/xml output to run them at different times --- src/compiler/compiler.ml | 8 ++------ src/compiler/generate.ml | 40 +++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/compiler/compiler.ml b/src/compiler/compiler.ml index 5c6950aa123..ceeefbfa3e7 100644 --- a/src/compiler/compiler.ml +++ b/src/compiler/compiler.ml @@ -352,14 +352,10 @@ let compile ctx actx callbacks = DisplayProcessing.handle_display_after_typing ctx tctx display_file_dot_path; finalize_typing ctx tctx; DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path; - com.callbacks#add_after_save (fun () -> - (* com.callbacks#add_before_save (fun () -> *) - (* TODO check if this is fine for xml and json output *) - Generate.check_auxiliary_output com actx; - ); + com.callbacks#add_before_save (fun () -> Generate.check_hxb_output com actx); filter ctx tctx; if ctx.has_error then raise Abort; - (* Generate.check_auxiliary_output com actx; *) + Generate.check_auxiliary_output com actx; com.stage <- CGenerationStart; if not actx.no_output then Generate.generate ctx tctx ext actx; com.stage <- CGenerationDone; diff --git a/src/compiler/generate.ml b/src/compiler/generate.ml index cfa20ee3ddd..f44af3db9f8 100644 --- a/src/compiler/generate.ml +++ b/src/compiler/generate.ml @@ -2,6 +2,24 @@ open Globals open CompilationContext open TType +let check_auxiliary_output com actx = + begin match actx.xml_out with + | None -> () + | Some "hx" -> + Genhxold.generate com + | Some file -> + Common.log com ("Generating xml: " ^ file); + Path.mkdir_from_path file; + Genxml.generate com file + end; + begin match actx.json_out with + | None -> () + | Some file -> + Common.log com ("Generating json : " ^ file); + Path.mkdir_from_path file; + Genjson.generate com.types file + end + let export_hxb com root m = if m.m_extra.m_kind = MCode then begin let anon_identification = new Genshared.tanon_identification ([],"") in @@ -19,26 +37,11 @@ let export_hxb com root m = close_out ch_file end -let check_auxiliary_output com actx = - begin match actx.xml_out with - | None -> () - | Some "hx" -> - Genhxold.generate com - | Some file -> - Common.log com ("Generating xml: " ^ file); - Path.mkdir_from_path file; - Genxml.generate com file - end; - begin match actx.json_out with - | None -> () - | Some file -> - Common.log com ("Generating json : " ^ file); - Path.mkdir_from_path file; - Genjson.generate com.types file - end; +let check_hxb_output com actx = begin match actx.hxb_out with | None -> () | Some path -> + (* TODO move somewhere else *) let clean_files path = let rec iter_files pack dir path = try let file = Unix.readdir dir in @@ -61,8 +64,7 @@ let check_auxiliary_output com actx = in let path = Path.add_trailing_slash path in - Common.log com ("Generating hxb : " ^ path); - Printf.eprintf "Generating hxb to %s\n" path; + Common.log com ("Generating hxb to " ^ path); Path.mkdir_from_path path; clean_files path; let t = Timer.timer ["generate";"hxb"] in