show script compilation errors in the log

This commit is contained in:
Mikulas Florek 2014-01-01 12:45:38 +01:00
parent 077740e922
commit 8fff5a7606
4 changed files with 63 additions and 26 deletions

View file

@ -66,16 +66,16 @@ void LogEvent::read(Blob& stream)
{
stream.read(tmp, len);
tmp[len] = 0;
}
message = tmp;
/* stream.read(&index, sizeof(index));
int32_t count;
stream.read(&count, sizeof(count));
components.resize(count);
for(int i = 0; i < count; ++i)
}
else
{
stream.read(&components[i], sizeof(components[i]));
}*/
char* buf = new char[len+1];
stream.read(buf, len);
buf[len] = 0;
message = buf;
delete[] buf;
}
}

View file

@ -1,6 +1,6 @@
#include "editor_native/script_compiler.h"
#include <cstdio>
#include "core/log.h"
void ScriptCompiler::compileAll()
{
@ -29,6 +29,18 @@ void ScriptCompiler::compile(const char path[])
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
char cmd_line[255];
HANDLE read_pipe, write_pipe;
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
CreatePipe(&read_pipe, &write_pipe, &saAttr, 0);
SetHandleInformation(read_pipe, HANDLE_FLAG_INHERIT, 0);
si.hStdInput = read_pipe;
si.hStdOutput = write_pipe;
si.dwFlags |= STARTF_USESTDHANDLES;
sprintf(cmd_line, "/C scripts\\compile.bat %s", path);
if ( CreateProcess("C:\\windows\\system32\\cmd.exe", // Application name
cmd_line,
@ -44,8 +56,14 @@ void ScriptCompiler::compile(const char path[])
Process* p = new Process();
p->m_handle = pi.hProcess;
p->m_path = path;
p->m_pipe = read_pipe;
p->m_write_pipe = write_pipe;
m_processes.push_back(p);
}
else
{
ASSERT(false);
}
}
void ScriptCompiler::checkFinished()
@ -60,6 +78,22 @@ void ScriptCompiler::checkFinished()
Process* p = m_processes[i];
m_processes.eraseFast(i);
m_delegates.invoke(p->m_path.c_str(), code);
char buf[512];
DWORD read;
if(code != 0)
{
static Lux::string text = "";
do
{
ReadFile(p->m_pipe, buf, 512, &read, NULL);
buf[read] = '\0';
text += buf;
}
while(read == 512);
Lux::g_log_info.log("compile script", text.c_str());
}
CloseHandle(p->m_pipe);
CloseHandle(p->m_write_pipe);
delete p;
}
}

View file

@ -23,6 +23,8 @@ class ScriptCompiler
struct Process
{
HANDLE m_handle;
HANDLE m_pipe;
HANDLE m_write_pipe;
Lux::string m_path;
};

View file

@ -289,7 +289,8 @@ namespace UI
while(*c)
{
OpenGLRendererImpl::Character character;
m_impl->m_characters.find(*c, character);
if(m_impl->m_characters.find(*c, character))
{
float cur_y = y + character.y_offset;
verts[i*6].set(cur_x, cur_y, z);
verts[i*6+1].set(cur_x, cur_y + character.pixel_h, z);
@ -308,10 +309,10 @@ namespace UI
uvs[i*6+3].set(character.left, character.top);
uvs[i*6+4].set(character.right, character.bottom);
uvs[i*6+5].set(character.right, character.top);
++c;
++i;
}
++c;
}
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
renderImage(m_impl->m_font_image, &verts[0].x, &uvs[0].x, verts.size());