Skip to content

Commit f977885

Browse files
Ignore version extension
1 parent da7005f commit f977885

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

Include/runcpp2/PlatformUtil.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
#include <unordered_map>
1010
#include <vector>
1111

12+
namespace ghc
13+
{
14+
namespace filesystem
15+
{
16+
class path;
17+
}
18+
}
19+
1220
namespace runcpp2
1321
{
1422
std::string ProcessPath(const std::string& path);
@@ -55,6 +63,8 @@ namespace runcpp2
5563

5664
return nullptr;
5765
}
66+
67+
std::string GetFileExtensionWithoutVersion(const ghc::filesystem::path& path);
5868
}
5969

6070
#endif

Src/runcpp2/CompilingLinking.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,10 @@ namespace
406406
for(int i = 0; i < objectsFilesPaths.size(); ++i)
407407
{
408408
ssLOG_DEBUG("Trying to link " << objectsFilesPaths.at(i));
409+
using namespace runcpp2;
409410

410411
//Check if this is a file we can link
411-
std::string extension = objectsFilesPaths.at(i).extension();
412-
413-
using namespace runcpp2;
412+
std::string extension = GetFileExtensionWithoutVersion(objectsFilesPaths.at(i));
414413
Data::DependencyLibraryType currentLinkType = Data::DependencyLibraryType::COUNT;
415414

416415
if(!HasValueFromPlatformMap(profile.FilesTypes.ObjectLinkFile.Extension))

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ bool runcpp2::GatherDependenciesBinaries( const std::vector<Data::DependencyIn
637637
continue;
638638

639639
std::string currentFileName = it.path().stem().string();
640-
std::string currentExtension = it.path().extension().string();
640+
std::string currentExtension = runcpp2::GetFileExtensionWithoutVersion(it.path());
641641

642642
ssLOG_DEBUG("currentFileName: " << currentFileName);
643643
ssLOG_DEBUG("currentExtension: " << currentExtension);

Src/runcpp2/PlatformUtil.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "runcpp2/PlatformUtil.hpp"
22

33
#include "ssLogger/ssLog.hpp"
4+
#include "ghc/filesystem.hpp"
45
#include <stdio.h>
6+
#include <cctype>
57

68
namespace
79
{
@@ -156,3 +158,26 @@ bool runcpp2::RunCommandAndGetOutput( const std::string& command,
156158
return message;
157159
}
158160
#endif
161+
162+
std::string runcpp2::GetFileExtensionWithoutVersion(const ghc::filesystem::path& path)
163+
{
164+
std::string filename = path.filename().string();
165+
bool inNumericPart = true;
166+
int lastDotPos = filename.length();
167+
168+
for(int i = filename.length() - 1; i >= 0; --i)
169+
{
170+
if(filename[i] == '.')
171+
{
172+
if(!inNumericPart)
173+
return filename.substr(i, lastDotPos - i);
174+
175+
inNumericPart = true;
176+
lastDotPos = i;
177+
}
178+
else if(!std::isdigit(filename[i]))
179+
inNumericPart = false;
180+
}
181+
182+
return "";
183+
}

Src/runcpp2/runcpp2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
905905
for(int i = 0; i < gatheredBinariesPaths.size(); ++i)
906906
{
907907
ghc::filesystem::path filePath(gatheredBinariesPaths.at(i));
908-
std::string extension = filePath.extension().string();
908+
std::string extension = runcpp2::GetFileExtensionWithoutVersion(filePath);
909909

910910
//Check if the file is a link file based on its extension
911911
if(linkExtensions.find(extension) != linkExtensions.end())

0 commit comments

Comments
 (0)