Daniele Bartolini 5 лет назад
Родитель
Сommit
fe60a138c2

+ 8 - 1
src/resource/compile_options.cpp

@@ -19,7 +19,7 @@
 #include "core/os.h"
 #include "core/process.h"
 #include "core/strings/dynamic_string.inl"
-#include "core/strings/string_stream.h"
+#include "core/strings/string_stream.inl"
 #include "device/log.h"
 #include "resource/compile_options.inl"
 #include "resource/data_compiler.h"
@@ -220,6 +220,13 @@ const char* CompileOptions::exe_path(const char* const* paths, u32 num)
 	return NULL;
 }
 
+void CompileOptions::read_output(StringStream& output, Process& pr)
+{
+	char err[512];
+	while (pr.fgets(err, sizeof(err)) != NULL)
+		output << err;
+}
+
 } // namespace crown
 
 #endif // CROWN_CAN_COMPILE

+ 5 - 0
src/resource/compile_options.h

@@ -13,7 +13,9 @@
 #include "core/filesystem/reader_writer.h"
 #include "core/filesystem/types.h"
 #include "core/os.h"
+#include "core/process.h"
 #include "core/strings/dynamic_string.h"
+#include "core/strings/string_stream.h"
 #include "core/strings/types.h"
 #include "resource/resource_id.h"
 #include "resource/types.h"
@@ -161,6 +163,9 @@ struct CompileOptions
 
 	/// Returns the first path with executable permissions or NULL if none found.
 	const char* exe_path(const char* const* paths, u32 num);
+
+	///
+	void read_output(StringStream& ss, Process& pr);
 };
 
 } // namespace crown

+ 1 - 6
src/resource/lua_resource.cpp

@@ -57,12 +57,7 @@ namespace lua_resource_internal
 			, argv[0]
 			);
 		StringStream output(ta);
-		// Read error messages if any
-		{
-			char err[512];
-			while (pr.fgets(err, sizeof(err)) != NULL)
-				output << err;
-		}
+		opts.read_output(output, pr);
 		s32 ec = pr.wait();
 		DATA_COMPILER_ASSERT(ec == 0
 			, opts

+ 2 - 12
src/resource/shader_resource.cpp

@@ -1301,12 +1301,7 @@ namespace shader_resource_internal
 			StringStream output_vert(ta);
 			StringStream output_frag(ta);
 
-			// Read error messages if any
-			{
-				char err[512];
-				while (pr_vert.fgets(err, sizeof(err)) != NULL)
-					output_vert << err;
-			}
+			_opts.read_output(output_vert, pr_vert);
 			ec = pr_vert.wait();
 			if (ec != 0)
 			{
@@ -1320,12 +1315,7 @@ namespace shader_resource_internal
 					);
 			}
 
-			// Read error messages if any
-			{
-				char err[512];
-				while (pr_frag.fgets(err, sizeof(err)) != NULL)
-					output_frag << err;
-			}
+			_opts.read_output(output_frag, pr_frag);
 			ec = pr_frag.wait();
 			if (ec != 0)
 			{

+ 1 - 6
src/resource/texture_resource.cpp

@@ -121,12 +121,7 @@ namespace texture_resource_internal
 			, argv[0]
 			);
 		StringStream output(ta);
-		// Read error messages if any
-		{
-			char err[512];
-			while (pr.fgets(err, sizeof(err)) != NULL)
-				output << err;
-		}
+		opts.read_output(output, pr);
 		s32 ec = pr.wait();
 		DATA_COMPILER_ASSERT(ec == 0
 			, opts