Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixing records not being updated in certain conditions
  • Loading branch information
Neko-Box-Coder committed Dec 17, 2024
commit f9a2e8e982769cd4d24d1773eb2510c4fd218c97
55 changes: 35 additions & 20 deletions Src/runcpp2/runcpp2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ runcpp2::CheckSourcesNeedUpdate( const std::string& scriptPath,

//Initialize BuildsManager and IncludeManager
ghc::filesystem::path configDir = GetConfigFilePath();
configDir = configDir.parent_path();
if(!ghc::filesystem::is_directory(configDir, e))
{
ssLOG_FATAL("Unexpected path for config directory: " << configDir.string());
return PipelineResult::INVALID_CONFIG_PATH;
}

ghc::filesystem::path buildDir;
BuildsManager buildsManager("/tmp");
IncludeManager includeManager;
Expand Down Expand Up @@ -581,27 +588,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
ghc::filesystem::file_time_type finalObjectWriteTime;

if(currentOptions.count(runcpp2::CmdOptions::RESET_CACHE) > 0 || recompileNeeded)
{
sourceHasCache = std::vector<bool>(sourceFiles.size(), false);

//Update the include records
{
runcpp2::SourceIncludeMap sourcesIncludes;
if(!runcpp2::GatherFilesIncludes(sourceFiles, includePaths, sourcesIncludes))
return PipelineResult::UNEXPECTED_FAILURE;

for(auto it = sourcesIncludes.cbegin(); it != sourcesIncludes.cend(); ++it)
{
ssLOG_DEBUG("Updating include record for " << it->first);
if(!includeManager.WriteIncludeRecord( ghc::filesystem::path(it->first),
it->second))
{
ssLOG_ERROR("Failed to write include record for " << it->first);
return PipelineResult::UNEXPECTED_FAILURE;
}
}
}
}
else if(!HasCompiledCache( absoluteScriptPath,
sourceFiles,
buildDir,
Expand All @@ -616,6 +603,34 @@ runcpp2::StartPipeline( const std::string& scriptPath,
return PipelineResult::UNEXPECTED_FAILURE;
}

//Update the include records
{
runcpp2::SourceIncludeMap sourcesIncludes;
if(!runcpp2::GatherFilesIncludes(sourceFiles, includePaths, sourcesIncludes))
return PipelineResult::UNEXPECTED_FAILURE;

for(int i = 0; i < sourceFiles.size(); ++i)
{
ssLOG_DEBUG("Updating include record for " << sourceFiles.at(i).string());
if(!sourceHasCache.at(i))
{
if(sourcesIncludes.count(sourceFiles.at(i)) == 0)
{
ssLOG_WARNING("Includes not gathered for " << sourceFiles.at(i).string());
continue;
}

if(!includeManager.WriteIncludeRecord( sourceFiles.at(i),
sourcesIncludes.at(sourceFiles.at(i))))
{
ssLOG_ERROR("Failed to write include record for " <<
sourceFiles.at(i).string());
return PipelineResult::UNEXPECTED_FAILURE;
}
}
}
}

std::vector<std::string> linkFilesPaths;
SeparateDependencyFiles(profiles.at(profileIndex).FilesTypes,
gatheredBinariesPaths,
Expand Down