clean build.c output to exclude note src locations
This commit is contained in:
parent
46c7414f71
commit
c7315327f4
95
build.c
95
build.c
@ -114,6 +114,80 @@ void ExecuteSteps(void)
|
|||||||
T_Execute(&sl->tq);
|
T_Execute(&sl->tq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Clean result output
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
/* TODO: Move to buildit */
|
||||||
|
Size StringFind(String s, String pattern)
|
||||||
|
{
|
||||||
|
Size pos = -1;
|
||||||
|
for (Size i = 0; i < s.len; ++i) {
|
||||||
|
if ((s.len - i) >= pattern.len) {
|
||||||
|
String cmp = { 0 };
|
||||||
|
cmp.text = s.text + i;
|
||||||
|
cmp.len = pattern.len;
|
||||||
|
if (StringEqual(cmp, pattern)) {
|
||||||
|
pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
String CleanResultOutput(Arena *arena, String output)
|
||||||
|
{
|
||||||
|
TempArena scratch = ScratchBegin(arena);
|
||||||
|
StringList res_lines = { 0 };
|
||||||
|
|
||||||
|
StringList patterns = { 0 };
|
||||||
|
StringListAppend(scratch.arena, &patterns, Lit("\r\n"));
|
||||||
|
StringListAppend(scratch.arena, &patterns, Lit("\r\n"));
|
||||||
|
StringListAppend(scratch.arena, &patterns, Lit("\n"));
|
||||||
|
StringList lines = StringSplit(scratch.arena, output, patterns);
|
||||||
|
for (StringListNode *n = lines.first; n; n = n->next) {
|
||||||
|
String line = n->string;
|
||||||
|
String line_cleaned = line;
|
||||||
|
|
||||||
|
/* Ignore MSVC header include messages */
|
||||||
|
if (StringContains(line, Lit("Note: including file"))) {
|
||||||
|
line_cleaned.len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Truncate note src locations.
|
||||||
|
* This is a hack to get around visual studio's "GoToNextLocation"
|
||||||
|
* picking up noise from clang & msvc notes since src location
|
||||||
|
* info is present, rather than going to the next error. */
|
||||||
|
if (StringContains(line_cleaned, Lit(": note: "))) {
|
||||||
|
String trunc = Lit("power_play\\src\\");
|
||||||
|
Size pos = StringFind(line_cleaned, trunc);
|
||||||
|
if (pos < 0) {
|
||||||
|
trunc = Lit("power_play\\src/");
|
||||||
|
pos = StringFind(line_cleaned, trunc);
|
||||||
|
}
|
||||||
|
String line_trunced = line_cleaned;
|
||||||
|
if (pos >= 0) {
|
||||||
|
line_trunced.text += pos + trunc.len;
|
||||||
|
line_trunced.len -= pos + trunc.len;
|
||||||
|
line_cleaned = StringCopy(scratch.arena, Lit("[note]: "));
|
||||||
|
line_cleaned.len += StringCopy(scratch.arena, line_trunced).len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line_cleaned.len > 0) {
|
||||||
|
StringListAppend(scratch.arena, &res_lines, line_cleaned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String res = StringFromStringList(arena, Lit("\n"), res_lines);
|
||||||
|
ScratchEnd(scratch);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Build steps
|
* Build steps
|
||||||
* ========================== */
|
* ========================== */
|
||||||
@ -141,14 +215,16 @@ void BuildStepSimpleCommand(void *arg_raw)
|
|||||||
|
|
||||||
{
|
{
|
||||||
OS_Lock res_lock = OS_MutexLockE(&s->res_mutex);
|
OS_Lock res_lock = OS_MutexLockE(&s->res_mutex);
|
||||||
if (result.output.len > 0) {
|
|
||||||
|
String result_output_cleaned = CleanResultOutput(scratch.arena, result.output);
|
||||||
|
if (result_output_cleaned.len > 0) {
|
||||||
OS_Lock sl_lock = OS_MutexLockE(&sl->mutex);
|
OS_Lock sl_lock = OS_MutexLockE(&sl->mutex);
|
||||||
{
|
{
|
||||||
s->res_output.text = ArenaPushArrayNoZero(&sl->arena, Byte, result.output.len);
|
s->res_output.text = ArenaPushArrayNoZero(&sl->arena, Byte, result_output_cleaned.len);
|
||||||
}
|
}
|
||||||
OS_MutexUnlock(&sl_lock);
|
OS_MutexUnlock(&sl_lock);
|
||||||
s->res_output.len = result.output.len;
|
s->res_output.len = result_output_cleaned.len;
|
||||||
MemoryCopy(s->res_output.text, result.output.text, result.output.len);
|
MemoryCopy(s->res_output.text, result_output_cleaned.text, result_output_cleaned.len);
|
||||||
}
|
}
|
||||||
s->res_status = result.error ? StepStatus_Failure : StepStatus_Success;
|
s->res_status = result.error ? StepStatus_Failure : StepStatus_Success;
|
||||||
OS_ConditionVariableBroadcast(&s->res_cv);
|
OS_ConditionVariableBroadcast(&s->res_cv);
|
||||||
@ -171,16 +247,17 @@ void BuildStepMsvcCompileCommand(void *arg_raw)
|
|||||||
D_ClearWrite(arg->output_depfile, depfile_data);
|
D_ClearWrite(arg->output_depfile, depfile_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String result_output_cleaned = CleanResultOutput(scratch.arena, result.output);
|
||||||
{
|
{
|
||||||
OS_Lock res_lock = OS_MutexLockE(&s->res_mutex);
|
OS_Lock res_lock = OS_MutexLockE(&s->res_mutex);
|
||||||
if (result.output.len > 0) {
|
if (result_output_cleaned.len > 0) {
|
||||||
OS_Lock sl_lock = OS_MutexLockE(&sl->mutex);
|
OS_Lock sl_lock = OS_MutexLockE(&sl->mutex);
|
||||||
{
|
{
|
||||||
s->res_output.text = ArenaPushArrayNoZero(&sl->arena, Byte, result.output.len);
|
s->res_output.text = ArenaPushArrayNoZero(&sl->arena, Byte, result_output_cleaned.len);
|
||||||
}
|
}
|
||||||
OS_MutexUnlock(&sl_lock);
|
OS_MutexUnlock(&sl_lock);
|
||||||
s->res_output.len = result.output.len;
|
s->res_output.len = result_output_cleaned.len;
|
||||||
MemoryCopy(s->res_output.text, result.output.text, result.output.len);
|
MemoryCopy(s->res_output.text, result_output_cleaned.text, result_output_cleaned.len);
|
||||||
}
|
}
|
||||||
s->res_status = result.error ? StepStatus_Failure : StepStatus_Success;
|
s->res_status = result.error ? StepStatus_Failure : StepStatus_Success;
|
||||||
OS_ConditionVariableBroadcast(&s->res_cv);
|
OS_ConditionVariableBroadcast(&s->res_cv);
|
||||||
@ -855,7 +932,7 @@ void OnBuild(StringList cli_args)
|
|||||||
if (s->res_status != StepStatus_Success) {
|
if (s->res_status != StepStatus_Success) {
|
||||||
Assert(false);
|
Assert(false);
|
||||||
success = false;
|
success = false;
|
||||||
SH_PrintF(Lit("%F\n"), FmtStr(output));
|
SH_PrintF(Lit("%F\n\n"), FmtStr(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
s = s->next;
|
s = s->next;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user