Просмотр исходного кода

[hxb] separate hxb output from json/xml output to run them at different times

Rudy Ges 2 лет назад
Родитель
Сommit
dff058ea52
2 измененных файлов с 23 добавлено и 25 удалено
  1. 2 6
      src/compiler/compiler.ml
  2. 21 19
      src/compiler/generate.ml

+ 2 - 6
src/compiler/compiler.ml

@@ -365,14 +365,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;
 		ServerMessage.compiler_stage com;
 		if not actx.no_output then Generate.generate ctx tctx ext actx;

+ 21 - 19
src/compiler/generate.ml

@@ -3,6 +3,24 @@ open CompilationContext
 open TType
 open Tanon_identification
 
+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 tanon_identification ([],"") in
@@ -20,26 +38,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
@@ -62,8 +65,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