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: 3 additions & 0 deletions Include/Tests/BuildsManager/MockComponents.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef RUNCPP2_UNIT_TESTS_BUILDS_MANAGER_MOCK_COMPONENTS_HPP
#define RUNCPP2_UNIT_TESTS_BUILDS_MANAGER_MOCK_COMPONENTS_HPP

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#include "ghc/filesystem.hpp"

#include "CppOverride.hpp"
Expand Down
5 changes: 4 additions & 1 deletion Include/Tests/IncludeManager/MockComponents.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef RUNCPP2_UNIT_TESTS_INCLUDE_MANAGER_MOCK_COMPONENTS_HPP
#define RUNCPP2_UNIT_TESTS_INCLUDE_MANAGER_MOCK_COMPONENTS_HPP

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#include "ghc/filesystem.hpp"
#include "CppOverride.hpp"

Expand Down Expand Up @@ -104,4 +107,4 @@ namespace std
#undef getline
#endif

#endif
#endif
3 changes: 3 additions & 0 deletions Include/runcpp2/BuildsManager.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef RUNCPP2_BUILDS_MANAGER_HPP
#define RUNCPP2_BUILDS_MANAGER_HPP

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#include "ghc/filesystem.hpp"

#include <unordered_map>
Expand Down
4 changes: 4 additions & 0 deletions Include/runcpp2/CompilingLinking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "runcpp2/Data/Profile.hpp"
#include "runcpp2/Data/ScriptInfo.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "ghc/filesystem.hpp"

#include <string>
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/ProfilesProcessPaths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#include "runcpp2/YamlLib.hpp"

#define NOMINMAX 1
#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#include "ghc/filesystem.hpp"

#include <unordered_map>
Expand Down
12 changes: 11 additions & 1 deletion Include/runcpp2/Data/ScriptInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#ifndef RUNCPP2_DATA_SCRIPT_INFO_HPP
#define RUNCPP2_DATA_SCRIPT_INFO_HPP


#include "runcpp2/Data/DependencyInfo.hpp"
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
#include "runcpp2/Data/ParseCommon.hpp"
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
#include "runcpp2/Data/ProfilesDefines.hpp"
#include "runcpp2/Data/ProfilesCommands.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "ghc/filesystem.hpp"

#include <string>
#include <vector>
#include <unordered_map>
Expand Down Expand Up @@ -38,8 +44,12 @@ namespace runcpp2
std::unordered_map<PlatformName, ProfilesCommands> PostBuild;
std::unordered_map<PlatformName, ProfilesCommands> Cleanup;

//Internal tracking
bool Populated = false;

ghc::filesystem::file_time_type LastWriteTime =
ghc::filesystem::file_time_type::min();

bool ParseYAML_Node(ryml::ConstNodeRef& node);
std::string ToString(std::string indentation) const;
bool Equals(const ScriptInfo& other) const;
Expand Down
4 changes: 4 additions & 0 deletions Include/runcpp2/DependenciesHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "runcpp2/Data/ScriptInfo.hpp"
#include "runcpp2/Data/Profile.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "ghc/filesystem.hpp"
#include <vector>

Expand Down
6 changes: 5 additions & 1 deletion Include/runcpp2/IncludeManager.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef RUNCPP2_INCLUDE_MANAGER_HPP
#define RUNCPP2_INCLUDE_MANAGER_HPP

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "ghc/filesystem.hpp"
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -41,4 +45,4 @@ namespace runcpp2
};
}

#endif
#endif
6 changes: 4 additions & 2 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "runcpp2/BuildsManager.hpp"
#include "runcpp2/IncludeManager.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#include "ghc/filesystem.hpp"

#include <string>
Expand Down Expand Up @@ -125,10 +128,9 @@ namespace runcpp2

using SourceIncludeMap = std::unordered_map<std::string, std::vector<ghc::filesystem::path>>;

bool GatherFilesIncludes( const std::vector<ghc::filesystem::path>& files,
bool GatherFilesIncludes( const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<ghc::filesystem::path>& includePaths,
SourceIncludeMap& outSourceIncludes);
}


#endif
5 changes: 5 additions & 0 deletions Include/runcpp2/PlatformUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include "runcpp2/Data/ParseCommon.hpp"
#include "runcpp2/Data/Profile.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "System2.h"

#include <cstdint>
Expand Down
4 changes: 4 additions & 0 deletions Include/runcpp2/YamlLib.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef RUNCPP2_YAML_LIB_HPP
#define RUNCPP2_YAML_LIB_HPP

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif

#include "c4/std/string.hpp"
#include "ryml.hpp"

Expand Down
3 changes: 2 additions & 1 deletion Include/runcpp2/runcpp2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace runcpp2
const std::vector<Data::Profile>& profiles,
const std::string& configPreferredProfile,
const Data::ScriptInfo& scriptInfo,
const std::unordered_map<CmdOptions, std::string>& currentOptions,
const std::unordered_map< CmdOptions,
std::string>& currentOptions,
bool& outNeedsUpdate);

PipelineResult StartPipeline( const std::string& scriptPath,
Expand Down
13 changes: 4 additions & 9 deletions Src/Tests/IncludeManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ int main(int argc, char** argv)
//Setup timestamps
const auto recordTime = ghc::filesystem::file_time_type::clock::now();
const auto sourceTime = recordTime - std::chrono::seconds(1);
const auto includeTime = recordTime + std::chrono::seconds(1);

//Mock source file time
std::shared_ptr<OverrideResult> sourceTimeResult = CreateOverrideResult();
Expand All @@ -736,17 +735,13 @@ int main(int argc, char** argv)
CO_SETUP_OVERRIDE (OverrideInstance, Mock_exists)
.WhenCalledWith<const ghc::filesystem::path&,
CO_ANY_TYPE>(includePaths[1], CO_ANY)
.Returns<bool>(true)
.Times(1)
.AssignResult(include2ExistsResult);

//Mock second include file time
std::shared_ptr<OverrideResult> include2TimeResult = CreateOverrideResult();
CO_SETUP_OVERRIDE (OverrideInstance, Mock_last_write_time)
.WhenCalledWith<const ghc::filesystem::path&,
CO_ANY_TYPE>(includePaths[1], CO_ANY)
.Returns<ghc::filesystem::file_time_type>(includeTime)
.Times(1)
.AssignResult(include2TimeResult);

std::vector<ghc::filesystem::path> includes = { includePaths[0], includePaths[1] };
Expand All @@ -759,10 +754,10 @@ int main(int argc, char** argv)
sourceTimeResult->GetSucceedCount(), 1);
ssTEST_OUTPUT_ASSERT( "First include exists should be checked",
include1ExistsResult->GetSucceedCount(), 1);
ssTEST_OUTPUT_ASSERT( "Second include exists should be checked",
include2ExistsResult->GetSucceedCount(), 1);
ssTEST_OUTPUT_ASSERT( "Second include time should be checked",
include2TimeResult->GetSucceedCount(), 1);
ssTEST_OUTPUT_ASSERT( "Second include exists should not be checked",
include2ExistsResult->GetStatusCount(), 0);
ssTEST_OUTPUT_ASSERT( "Second include time should not be checked",
include2TimeResult->GetStatusCount(), 0);
};

ssTEST("GetRecordPath Should Generate Valid And Unique Paths")
Expand Down
22 changes: 13 additions & 9 deletions Src/runcpp2/IncludeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,20 @@ namespace runcpp2

for(const ghc::filesystem::path& include : includes)
{
if(ghc::filesystem::exists(include, e))
if(!ghc::filesystem::exists(include, e))
{
ghc::filesystem::file_time_type includeTime =
ghc::filesystem::last_write_time(include, e);
if(includeTime > recordTime)
{
ssLOG_DEBUG("Include time for " << include.string() <<
" is newer than record time");
return true;
}
ssLOG_DEBUG("Include file does not exist: " << include.string());
return true;
}

ghc::filesystem::file_time_type includeTime =
ghc::filesystem::last_write_time(include, e);

if(includeTime > recordTime)
{
ssLOG_DEBUG("Include time for " << include.string() <<
" is newer than record time");
return true;
}
}

Expand Down
28 changes: 21 additions & 7 deletions Src/runcpp2/PipelineSteps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptP
ssLOG_FUNC_INFO();
INTERNAL_RUNCPP2_SAFE_START();

//TODO: Record last script info write time. Use last script info if possible to reduce disk io

//Check if there's script info as yaml file instead
std::error_code e;
std::string parsableInfo;
Expand All @@ -320,13 +318,29 @@ runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptP

if(ghc::filesystem::exists(dedicatedYamlLoc, e))
{
//Record write time for yaml file
outScriptInfo.LastWriteTime = ghc::filesystem::last_write_time(dedicatedYamlLoc, e);
if(e)
{
ssLOG_ERROR("Failed to get last write time for: " << dedicatedYamlLoc);
return PipelineResult::INVALID_SCRIPT_INFO;
}

inputFile.open(dedicatedYamlLoc);
std::stringstream buffer;
buffer << inputFile.rdbuf();
parsableInfo = buffer.str();
}
else
{
//Record write time for script file
outScriptInfo.LastWriteTime = ghc::filesystem::last_write_time(absoluteScriptPath, e);
if(e)
{
ssLOG_ERROR("Failed to get last write time for: " << absoluteScriptPath);
return PipelineResult::INVALID_SCRIPT_INFO;
}

inputFile.open(absoluteScriptPath);

if (!inputFile)
Expand Down Expand Up @@ -1192,7 +1206,7 @@ bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
}

bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& files,
bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<ghc::filesystem::path>& includePaths,
SourceIncludeMap& outSourceIncludes)
{
Expand All @@ -1202,13 +1216,13 @@ bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& fi
outSourceIncludes.clear();
std::unordered_set<std::string> visitedFiles;

for(const ghc::filesystem::path& file : files)
for(const ghc::filesystem::path& source : sourceFiles)
{
ssLOG_INFO("Gathering includes for " << file.string());
ssLOG_INFO("Gathering includes for " << source.string());

std::vector<ghc::filesystem::path>& currentIncludes = outSourceIncludes[file.string()];
std::vector<ghc::filesystem::path>& currentIncludes = outSourceIncludes[source.string()];
std::queue<ghc::filesystem::path> filesToProcess;
filesToProcess.push(file);
filesToProcess.push(source);

while(!filesToProcess.empty())
{
Expand Down
3 changes: 2 additions & 1 deletion Src/runcpp2/ProfileHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "runcpp2/ProfileHelper.hpp"
#include "ghc/filesystem.hpp"
#include "runcpp2/PlatformUtil.hpp"

#include "ghc/filesystem.hpp"
#include "ssLogger/ssLog.hpp"

namespace
Expand Down
12 changes: 11 additions & 1 deletion Src/runcpp2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "ghc/filesystem.hpp"


//TODO: Merge long and short options into a single structure
int ParseArgs( const std::unordered_map<std::string, runcpp2::OptionInfo>& longOptionsMap,
const std::unordered_map<std::string, const runcpp2::OptionInfo&>& shortOptionsMap,
Expand Down Expand Up @@ -446,6 +445,17 @@ int main(int argc, char* argv[])

if(needsRunning)
{
//Clear the screen
if(ssLOG_GET_CURRENT_THREAD_TARGET_LEVEL() <= ssLOG_LEVEL_WARNING)
{
#if defined(_WIN32)
system("cls");
#else
//https://stackoverflow.com/a/53925508
std::cout << "\033c";
#endif
}

int result = 0;
runcpp2::PipelineResult pipelineResult =
runcpp2::StartPipeline( script,
Expand Down
Loading