Skip to content

Commit

Permalink
[hxb] separate hxb output from json/xml output to run them at differe…
Browse files Browse the repository at this point in the history
…nt times
  • Loading branch information
kLabz committed Jun 29, 2023
1 parent 5e41bea commit 3a8dbf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
8 changes: 2 additions & 6 deletions src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 21 additions & 19 deletions src/compiler/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3a8dbf4

Please sign in to comment.