Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace runcpp2
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
const ghc::filesystem::path& scriptDirectory,
const std::string& scriptName,
const Data::ScriptInfo* lastScriptInfo,
Data::ScriptInfo& outScriptInfo);

PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
Expand All @@ -62,7 +61,7 @@ namespace runcpp2
PipelineResult CheckScriptInfoChanges( const ghc::filesystem::path& buildDir,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& scriptDirectory,
const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo* lastScriptInfo,
bool& outRecompileNeeded,
bool& outRelinkNeeded,
Expand Down
65 changes: 46 additions & 19 deletions Src/runcpp2/PipelineSteps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ runcpp2::PipelineResult
runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptPath,
const ghc::filesystem::path& scriptDirectory,
const std::string& scriptName,
const Data::ScriptInfo* lastScriptInfo,
Data::ScriptInfo& outScriptInfo)
{
ssLOG_FUNC_INFO();
Expand Down Expand Up @@ -357,8 +356,8 @@ runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptP

if(!parsableInfo.empty())
{
ssLOG_INFO("Parsed script info YAML:");
ssLOG_INFO("\n" << outScriptInfo.ToString(""));
ssLOG_DEBUG("Parsed script info YAML:");
ssLOG_DEBUG("\n" << outScriptInfo.ToString(""));
}

return PipelineResult::SUCCESS;
Expand Down Expand Up @@ -507,7 +506,7 @@ runcpp2::PipelineResult
runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& scriptDirectory,
const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo* lastScriptInfo,
bool& outRecompileNeeded,
bool& outRelinkNeeded,
Expand All @@ -516,6 +515,7 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
ssLOG_FUNC_INFO();
INTERNAL_RUNCPP2_SAFE_START();

const ghc::filesystem::path scriptDirectory = absoluteScriptPath.parent_path();
ghc::filesystem::path lastScriptInfoFilePath = buildDir / "LastScriptInfo.yaml";
Data::ScriptInfo lastScriptInfoFromDisk;

Expand All @@ -540,18 +540,45 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,

//Compare script info in memory or from disk
const Data::ScriptInfo* lastInfo = lastScriptInfo;
if(lastScriptInfo == nullptr && ghc::filesystem::exists(lastScriptInfoFilePath, e))
if(lastInfo == nullptr && ghc::filesystem::exists(lastScriptInfoFilePath, e))
{
ssLOG_DEBUG("Last script info file exists: " << lastScriptInfoFilePath);
std::ifstream lastScriptInfoFile;
lastScriptInfoFile.open(lastScriptInfoFilePath);
std::stringstream lastScriptInfoBuffer;
lastScriptInfoBuffer << lastScriptInfoFile.rdbuf();

if(ParseScriptInfo(lastScriptInfoBuffer.str(), lastScriptInfoFromDisk))
int currentThreadTargetLevel = ssLOG_GET_CURRENT_THREAD_TARGET_LEVEL();
ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL(ssLOG_LEVEL_NONE);

do
{
{
bool result = ParseScriptInfo(lastScriptInfoBuffer.str(), lastScriptInfoFromDisk);
if(!result)
break;
}

//Resolve imports for last script info
runcpp2::PipelineResult result = ResolveScriptImports( lastScriptInfoFromDisk,
absoluteScriptPath,
buildDir);
if(result != PipelineResult::SUCCESS)
break;

lastInfo = &lastScriptInfoFromDisk;
}
while(false);

ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL(currentThreadTargetLevel);

if(lastInfo != nullptr)
ssLOG_INFO("Last script info parsed");
else
ssLOG_INFO("Failed to parse last script info");
}

//Check if the cached script info has changed
if(lastInfo != nullptr)
{
//Check link flags
Expand Down Expand Up @@ -626,6 +653,9 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
!lastDefines->Equals(*currentDefines)
);
}

if(outRecompileNeeded || outRelinkNeeded)
ssLOG_INFO("Last script info is out of date, recompiling or relinking...");
}
else
outRecompileNeeded = true;
Expand All @@ -647,34 +677,31 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
ssLOG_DEBUG("Wrote current script info to " << lastScriptInfoFilePath.string());
}

if(!lastInfo)
return PipelineResult::SUCCESS;

//Check if include paths have changed
std::vector<ghc::filesystem::path> currentIncludePaths;
if(!GatherIncludePaths( scriptDirectory,
scriptInfo,
profile,
{}, //Empty dependencies since we're just comparing paths
currentIncludePaths))
if(!GatherIncludePaths(scriptDirectory, scriptInfo, profile, {}, currentIncludePaths))
{
ssLOG_ERROR("Failed to gather current include paths");
return PipelineResult::UNEXPECTED_FAILURE;
}

std::vector<ghc::filesystem::path> lastIncludePaths;
if(lastScriptInfo && !GatherIncludePaths( scriptDirectory,
*lastScriptInfo,
profile,
{}, // Empty dependencies
lastIncludePaths))
if(!GatherIncludePaths(scriptDirectory, *lastInfo, profile, {}, lastIncludePaths))
{
ssLOG_ERROR("Failed to gather last include paths");
return PipelineResult::UNEXPECTED_FAILURE;
ssLOG_WARNING("Failed to gather last include paths");
return PipelineResult::SUCCESS;
}

if(currentIncludePaths != lastIncludePaths)
{
ssLOG_INFO("Include paths have changed");
outRecompileNeeded = true;
}
else if(!outRecompileNeeded && !outRelinkNeeded)
ssLOG_INFO("Using script info cache");

return PipelineResult::SUCCESS;

Expand Down Expand Up @@ -1236,7 +1263,7 @@ bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& fi

if(found)
{
ssLOG_INFO("Found include file: " << resolvedInclude.string());
ssLOG_DEBUG("Found include file: " << resolvedInclude.string());
currentIncludes.push_back(resolvedInclude);
filesToProcess.push(resolvedInclude);
}
Expand Down
7 changes: 3 additions & 4 deletions Src/runcpp2/runcpp2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace
ghc::filesystem::file_time_type lastExecutableWriteTime =
ghc::filesystem::last_write_time(exeToCopy, e);

if(lastExecutableWriteTime > currentFinalObjectWriteTime)
if(lastExecutableWriteTime >= currentFinalObjectWriteTime)
{
ssLOG_INFO("Using output cache");
outOutputCache = true;
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace
ghc::filesystem::file_time_type lastSharedLibWriteTime =
ghc::filesystem::last_write_time(sharedLibBuild, e);

if(lastSharedLibWriteTime > currentFinalObjectWriteTime)
if(lastSharedLibWriteTime >= currentFinalObjectWriteTime)
{
ssLOG_INFO("Using output cache");
outOutputCache = true;
Expand Down Expand Up @@ -425,7 +425,6 @@ runcpp2::StartPipeline( const std::string& scriptPath,
result = ParseAndValidateScriptInfo(absoluteScriptPath,
scriptDirectory,
scriptName,
lastScriptInfo,
scriptInfo);

if(result != PipelineResult::SUCCESS)
Expand Down Expand Up @@ -499,7 +498,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
result = CheckScriptInfoChanges(buildDir,
scriptInfo,
profiles.at(profileIndex),
scriptDirectory,
absoluteScriptPath,
lastScriptInfo,
recompileNeeded,
relinkNeeded,
Expand Down