Skip to content

Commit

Permalink
Ignore .tundra2 files in glob signature checking
Browse files Browse the repository at this point in the history
Use consistent exclusion rules in globbing and dag generation.
  • Loading branch information
deplinenoise committed Mar 26, 2018
1 parent 5417935 commit c83ca9f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/DagGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,22 @@ static bool CompileDag(const JsonObjectValue* root, BinaryWriter* writer, MemAll

for (size_t i = 0, count = subdirs->m_Count; i < count; ++i)
{
HashAddPath(&h, subdirs->m_Values[i]->GetString());
HashAddSeparator(&h);
const char* path = subdirs->m_Values[i]->GetString();
if (!ShouldFilter(path))
{
HashAddPath(&h, path);
HashAddSeparator(&h);
}
}

for (size_t i = 0, count = files->m_Count; i < count; ++i)
{
HashAddPath(&h, files->m_Values[i]->GetString());
HashAddSeparator(&h);
const char* path = files->m_Values[i]->GetString();
if (!ShouldFilter(path))
{
HashAddPath(&h, path);
HashAddSeparator(&h);
}
}

HashDigest digest;
Expand Down Expand Up @@ -1018,10 +1026,10 @@ static bool RunExternalTool(const char* options, ...)
char cmdline[1024];
snprintf(cmdline, sizeof cmdline, "%s%s%s %s", quotes, dag_gen_path, quotes, option_str);
cmdline[sizeof(cmdline)-1] = '\0';

cmdline_to_use = cmdline;
}

const bool echo = (GetLogFlags() & kDebug) ? true : false;

ExecResult result = ExecuteProcess(cmdline_to_use, 1, &env_var, 0, echo, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static bool DriverCheckDagSignatures(Driver* self)
qsort(ctx.m_Dirs.m_Storage, ctx.m_Dirs.m_Size, sizeof(const char*), IterContext::SortStringPtrs);
qsort(ctx.m_Files.m_Storage, ctx.m_Files.m_Size, sizeof(const char*), IterContext::SortStringPtrs);

// Compute digest
// Compute digest - note that this has to match DagGenerator.cpp
HashState h;
HashInit(&h);
for (const char* p : ctx.m_Dirs)
Expand Down
13 changes: 12 additions & 1 deletion src/FileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ FileInfo GetFileInfo(const char* path)
return result;
}

static bool ShouldFilter(const char* name, size_t len)
bool ShouldFilter(const char* name)
{
return ShouldFilter(name, strlen(name));
}

bool ShouldFilter(const char* name, size_t len)
{
// Filter out some common noise entries that only serve to cause DAG regeneration.

Expand All @@ -83,6 +88,12 @@ static bool ShouldFilter(const char* name, size_t len)
if (len >= 4 && name[0] == '.' && 0 == memcmp(name + len - 4, ".swp", 4))
return true;

// Weed out '.tundra2.*' files too, as the .json file gets removed in between
// regenerating, messing up glob signatures.
static const char t2_prefix[] = ".tundra2.";
if (len >= (sizeof t2_prefix) - 1 && 0 == memcmp(name, t2_prefix, (sizeof t2_prefix) - 1))
return true;

// Emacs foo~ files
if (len > 1 && name[len-1] == '~')
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/FileInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct FileInfo

FileInfo GetFileInfo(const char* path);

bool ShouldFilter(const char* name);
bool ShouldFilter(const char* name, size_t len);

void ListDirectory(
const char* dir,
void* user_data,
Expand Down

0 comments on commit c83ca9f

Please sign in to comment.