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
2 changes: 1 addition & 1 deletion External/ssLogger
Submodule ssLogger updated 1 files
+2 −2 CMakeLists.txt
21 changes: 13 additions & 8 deletions Src/runcpp2/BuildsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ namespace runcpp2
return false;
}

std::string processScriptPathStr = ProcessPath(scriptPath.string());
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
std::string processScriptPathStr = ProcessPath(cleanScriptPath.string());

if(Mappings.count(processScriptPathStr) > 0)
return true;
Expand All @@ -204,7 +205,7 @@ namespace runcpp2

if(counter == MAX_TRIES)
{
ssLOG_ERROR("Failed to get unique hash for " << scriptPath.string() <<
ssLOG_ERROR("Failed to get unique hash for " << cleanScriptPath.string() <<
" after " << MAX_TRIES << " attempts");
return false;
}
Expand All @@ -229,7 +230,7 @@ namespace runcpp2
return false;
}

ssLOG_INFO("Build path " << scriptBuildPath << " for " << scriptPath);
ssLOG_INFO("Build path " << scriptBuildPath << " for " << cleanScriptPath);
Mappings[processScriptPathStr] = scriptBuildPathStr;
ReverseMappings[scriptBuildPathStr] = processScriptPathStr;
return true;
Expand All @@ -246,7 +247,8 @@ namespace runcpp2
return false;
}

std::string processScriptPathStr = ProcessPath(scriptPath.string());
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
std::string processScriptPathStr = ProcessPath(cleanScriptPath.string());
if(Mappings.count(processScriptPathStr) == 0)
return true;

Expand All @@ -267,7 +269,8 @@ namespace runcpp2
return false;
}

return Mappings.count(ProcessPath(scriptPath.string()));
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
return Mappings.count(ProcessPath(cleanScriptPath.string()));
}

bool BuildsManager::GetBuildMapping(const ghc::filesystem::path& scriptPath,
Expand All @@ -282,14 +285,16 @@ namespace runcpp2
return false;
}

ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();

//If it doesn't exist, create the mapping
if(!Mappings.count(ProcessPath(scriptPath.string())))
if(!Mappings.count(ProcessPath(cleanScriptPath.string())))
{
if(!CreateBuildMapping(scriptPath))
if(!CreateBuildMapping(cleanScriptPath))
return false;
}

outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(scriptPath.string()));
outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(cleanScriptPath.string()));
return true;
}

Expand Down
22 changes: 15 additions & 7 deletions Src/runcpp2/DependenciesHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ namespace
const std::unordered_map< PlatformName,
runcpp2::Data::ProfilesCommands> steps,
const std::string& dependenciesCopiedDirectory,
bool required)
bool required,
bool redirectIO)
{
ssLOG_FUNC_INFO();

Expand Down Expand Up @@ -291,18 +292,22 @@ namespace
std::string output;

if(!runcpp2::RunCommand(commands->at(k),
true,
redirectIO,
processedDependencyPath,
output,
returnCode))
{
ssLOG_ERROR("Failed to run command with result: " << returnCode);
ssLOG_ERROR("Was trying to run: " << commands->at(k));
ssLOG_ERROR("Output: \n" << output);
if(redirectIO)
ssLOG_ERROR("Output: \n" << output);
return false;
}
else
ssLOG_INFO("Output: \n" << output);
{
if(redirectIO)
ssLOG_INFO("Output: \n" << output);
}
}

return true;
Expand Down Expand Up @@ -499,6 +504,7 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile,
if(!RunDependenciesSteps( profile,
availableDependencies.at(i)->Cleanup,
dependenciesLocalCopiesPaths.at(i),
false,
false))
{
ssLOG_ERROR("Failed to cleanup dependency " << availableDependencies.at(i)->Name);
Expand Down Expand Up @@ -586,7 +592,8 @@ bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile,
if(!RunDependenciesSteps( profile,
availableDependencies.at(i)->Setup,
dependenciesLocalCopiesPaths.at(i),
true))
true,
false))
{
ssLOG_ERROR("Failed to setup dependency " <<
availableDependencies.at(i)->Name);
Expand Down Expand Up @@ -694,7 +701,8 @@ bool runcpp2::BuildDependencies(const runcpp2::Data::Profile& profile,
if(!RunDependenciesSteps( profile,
availableDependencies.at(i)->Build,
dependenciesLocalCopiesPaths.at(i),
true))
true,
false))
{
ssLOG_ERROR("Failed to build dependency " << availableDependencies.at(i)->Name);
return false;
Expand Down Expand Up @@ -971,7 +979,7 @@ bool runcpp2::GatherDependenciesBinaries( const std::vector<Data::DependencyIn
//Do a check to see if any dependencies are copied
if(outBinariesPaths.size() - nonLinkFilesCount < minimumDependenciesCopiesCount)
{
ssLOG_WARNING("We could missing some link files for dependencies");
ssLOG_WARNING("We could be missing some link files for dependencies");

for(int i = 0; i < outBinariesPaths.size(); ++i)
ssLOG_WARNING("outBinariesPaths[" << i << "]: " << outBinariesPaths.at(i));
Expand Down
3 changes: 2 additions & 1 deletion Src/runcpp2/IncludeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ namespace runcpp2
{
CO_OVERRIDE_MEMBER_IMPL(OverrideInstance, ghc::filesystem::path, (sourceFile));

std::size_t pathHash = std::hash<std::string>{}(sourceFile.string());
ghc::filesystem::path cleanSourceFile = sourceFile.lexically_normal();
std::size_t pathHash = std::hash<std::string>{}(cleanSourceFile.string());
return IncludeRecordDir / (std::to_string(pathHash) + ".Includes");
}
}
2 changes: 1 addition & 1 deletion Src/runcpp2/ProfileHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int runcpp2::GetPreferredProfileIndex( const std::string& scriptPath,

if(availableProfiles.empty())
{
ssLOG_ERROR("No compilers/linkers found");
ssLOG_ERROR("No compilers/linkers found that can be used for " << scriptPath);
return -1;
}

Expand Down
96 changes: 48 additions & 48 deletions Src/runcpp2/runcpp2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,6 @@ namespace
}
}

//Update the include records
runcpp2::SourceIncludeMap sourcesIncludes;
if(!runcpp2::GatherFilesIncludes(sourcesNeedGathering, includePaths, sourcesIncludes))
return false;

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 false;
}
}

return true;
}

Expand Down Expand Up @@ -456,10 +440,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
configPreferredProfile);

if(profileIndex == -1)
{
ssLOG_ERROR("Failed to find a profile to run");
return PipelineResult::NO_AVAILABLE_PROFILE;
}

//Parsing the script, setting up dependencies, compiling and linking
std::vector<std::string> filesToCopyPaths;
Expand Down Expand Up @@ -586,34 +567,6 @@ 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 Expand Up @@ -664,6 +617,49 @@ runcpp2::StartPipeline( const std::string& scriptPath,
for(int i = 0; i < cachedObjectsFiles.size(); ++i)
linkFilesPaths.push_back(cachedObjectsFiles.at(i));

auto updateIncludeRecords =
[
&sourceFiles,
&includePaths,
&sourceHasCache,
&includeManager
] () -> PipelineResult
{
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;
}
}
}

return PipelineResult::SUCCESS;
};

if(currentOptions.count(CmdOptions::WATCH) > 0)
{
if(!CompileScriptOnly( buildDir,
Expand All @@ -680,7 +676,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
return PipelineResult::COMPILE_LINK_FAILED;
}

return PipelineResult::SUCCESS;
return updateIncludeRecords();
}
else if(!CompileAndLinkScript( buildDir,
absoluteScriptPath,
Expand All @@ -698,6 +694,10 @@ runcpp2::StartPipeline( const std::string& scriptPath,
ssLOG_ERROR("Failed to compile or link script");
return PipelineResult::COMPILE_LINK_FAILED;
}

result = updateIncludeRecords();
if(result != PipelineResult::SUCCESS)
return result;
}
}

Expand Down
3 changes: 2 additions & 1 deletion mkdocs/docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
- Add ability to reference local YAML for user config
- Add version for user config and prompt for update
- Add wildcard support for filenames and extensions (Files Globbing)

- Add the ability to query script build directory
- Add the ability to list script dependencies

## Not planned yet

Expand Down