Skip to content

Commit ea95108

Browse files
Fixing output cache
1 parent b145fc0 commit ea95108

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Src/runcpp2/runcpp2.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "runcpp2/CompilingLinking.hpp"
66
#include "runcpp2/ConfigParsing.hpp"
77
#include "runcpp2/PlatformUtil.hpp"
8+
#include "runcpp2/Data/BuildTypeHelper.hpp"
89
#include "ssLogger/ssLog.hpp"
910
#include "ghc/filesystem.hpp"
1011

@@ -151,6 +152,7 @@ namespace
151152
bool HasOutputCache( const std::vector<bool>& sourceHasCache,
152153
const ghc::filesystem::path& buildDir,
153154
const runcpp2::Data::Profile& currentProfile,
155+
const runcpp2::Data::ScriptInfo& scriptInfo,
154156
bool buildExecutable,
155157
const std::string& scriptName,
156158
const std::string& exeExt,
@@ -228,34 +230,32 @@ namespace
228230
}
229231
else
230232
{
231-
//Check if there's any existing shared library build that is newer than the script
232-
const std::string* targetSharedLibExt =
233-
runcpp2::GetValueFromPlatformMap(currentProfile .FilesTypes
234-
.SharedLibraryFile
235-
.Extension);
233+
// Get the correct file properties based on build type
234+
const runcpp2::Data::FileProperties* fileProps =
235+
runcpp2::Data::BuildTypeHelper::GetOutputFileProperties(
236+
currentProfile.FilesTypes, scriptInfo.CurrentBuildType, false);
236237

237-
const std::string* targetSharedLibPrefix =
238-
runcpp2::GetValueFromPlatformMap(currentProfile .FilesTypes
239-
.SharedLibraryFile
240-
.Prefix);
238+
const std::string* targetPrefix = runcpp2::GetValueFromPlatformMap(fileProps->Prefix);
239+
const std::string* targetExt = runcpp2::GetValueFromPlatformMap(fileProps->Extension);
241240

242-
if(targetSharedLibExt == nullptr || targetSharedLibPrefix == nullptr)
241+
if(targetExt == nullptr || targetPrefix == nullptr)
243242
{
244-
ssLOG_ERROR("Shared library extension or prefix not found in compiler profile");
243+
ssLOG_ERROR("File extension or prefix not found in compiler profile for build type "
244+
<< runcpp2::Data::BuildTypeToString(scriptInfo.CurrentBuildType));
245245
outOutputCache = false;
246246
return false;
247247
}
248248

249-
ghc::filesystem::path sharedLibBuild = buildDir / *targetSharedLibPrefix;
250-
sharedLibBuild.concat(scriptName).concat(*targetSharedLibExt);
249+
ghc::filesystem::path outputBuild = buildDir / *targetPrefix;
250+
outputBuild.concat(scriptName).concat(*targetExt);
251251

252-
ssLOG_INFO("Trying to use output cache: " << sharedLibBuild.string());
252+
ssLOG_INFO("Trying to use output cache: " << outputBuild.string());
253253

254-
if( ghc::filesystem::exists(sharedLibBuild, e) &&
255-
ghc::filesystem::file_size(sharedLibBuild, e) > 0)
254+
if( ghc::filesystem::exists(outputBuild, e) &&
255+
ghc::filesystem::file_size(outputBuild, e) > 0)
256256
{
257257
ghc::filesystem::file_time_type lastSharedLibWriteTime =
258-
ghc::filesystem::last_write_time(sharedLibBuild, e);
258+
ghc::filesystem::last_write_time(outputBuild, e);
259259

260260
if(lastSharedLibWriteTime >= currentFinalObjectWriteTime)
261261
{
@@ -273,7 +273,7 @@ namespace
273273
}
274274
}
275275
else
276-
ssLOG_INFO(sharedLibBuild.string() << " doesn't exist");
276+
ssLOG_INFO(outputBuild.string() << " doesn't exist");
277277

278278
ssLOG_INFO("Not using output cache");
279279
outOutputCache = false;
@@ -668,7 +668,8 @@ runcpp2::StartPipeline( const std::string& scriptPath,
668668
bool outputCache = false;
669669
if(!HasOutputCache( sourceHasCache,
670670
buildDir,
671-
profiles.at(profileIndex),
671+
profiles.at(profileIndex),
672+
scriptInfo,
672673
currentOptions.count(CmdOptions::EXECUTABLE) > 0,
673674
scriptName,
674675
exeExt,

0 commit comments

Comments
 (0)