Skip to content

Commit fa4e12c

Browse files
Removing Internal namespace
1 parent 7d7849e commit fa4e12c

24 files changed

+1602
-1694
lines changed

Include/runcpp2/CompilerProfileHelper.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33

44
#include "runcpp2/Data/CompilerProfile.hpp"
55
#include "runcpp2/Data/ScriptInfo.hpp"
6+
67
namespace runcpp2
78
{
8-
bool IsProfileAvailableOnSystem(const CompilerProfile& profile);
9-
10-
bool IsProfileValidForScript( const CompilerProfile& profile,
11-
const ScriptInfo& scriptInfo,
12-
const std::string& scriptPath);
13-
14-
std::vector<ProfileName> GetAvailableProfiles( const std::vector<CompilerProfile>& profiles,
15-
const ScriptInfo& scriptInfo,
16-
const std::string& scriptPath);
17-
189
int GetPreferredProfileIndex( const std::string& scriptPath,
1910
const ScriptInfo& scriptInfo,
2011
const std::vector<CompilerProfile>& profiles,

Include/runcpp2/CompilingLinking.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77

88
namespace runcpp2
99
{
10-
bool CompileScript( const std::string& scriptPath,
11-
const ScriptInfo& scriptInfo,
12-
const CompilerProfile& profile,
13-
std::string& outScriptObjectFilePath);
14-
15-
bool LinkScript( const std::string& scriptPath,
16-
const ScriptInfo& scriptInfo,
17-
const CompilerProfile& profile,
18-
const std::string& scriptObjectFilePath,
19-
const std::vector<std::string>& copiedDependenciesBinariesNames);
20-
21-
2210
bool CompileAndLinkScript( const std::string& scriptPath,
2311
const ScriptInfo& scriptInfo,
2412
const CompilerProfile& profile,

Include/runcpp2/ConfigParsing.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#include <vector>
88
namespace runcpp2
99
{
10-
bool ParseCompilerProfiles( const std::string& compilerProfilesString,
11-
std::vector<CompilerProfile>& outProfiles,
12-
std::string& outPreferredProfile);
13-
1410
bool ReadUserConfig(std::vector<CompilerProfile>& outProfiles,
1511
std::string& outPreferredProfile);
1612

Include/runcpp2/DependenciesSetupHelper.hpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,6 @@ namespace runcpp2
1010
{
1111
bool IsDependencyAvailableForThisPlatform(const DependencyInfo& dependency);
1212

13-
bool GetDependenciesPaths( const std::vector<DependencyInfo>& dependencies,
14-
std::vector<std::string>& outCopiesPaths,
15-
std::vector<std::string>& outSourcesPaths,
16-
std::string runcpp2ScriptDir,
17-
std::string scriptDir);
18-
19-
bool PopulateLocalDependencies( const std::vector<DependencyInfo>& dependencies,
20-
const std::vector<std::string>& dependenciesCopiesPaths,
21-
const std::vector<std::string>& dependenciesSourcesPaths,
22-
const std::string runcpp2ScriptDir);
23-
24-
bool PopulateAbsoluteIncludePaths( std::vector<DependencyInfo>& dependencies,
25-
const std::vector<std::string>& dependenciesCopiesPaths);
26-
27-
bool RunDependenciesSetupSteps( const ProfileName& profileName,
28-
std::vector<DependencyInfo>& dependencies,
29-
const std::vector<std::string>& dependenciesCopiesPaths);
3013

3114
bool SetupScriptDependencies( const ProfileName& profileName,
3215
const std::string& scriptPath,
@@ -35,10 +18,6 @@ namespace runcpp2
3518
std::vector<std::string>& outDependenciesLocalCopiesPaths,
3619
std::vector<std::string>& outDependenciesSourcePaths);
3720

38-
bool GetDependencyBinariesExtensionsToCopy( const DependencyInfo& dependencyInfo,
39-
const CompilerProfile& profile,
40-
std::vector<std::string>& outExtensionsToCopy);
41-
4221
bool CopyDependenciesBinaries( const std::string& scriptPath,
4322
const ScriptInfo& scriptInfo,
4423
const std::vector<std::string>& dependenciesCopiesPaths,

Include/runcpp2/ParseUtil.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
namespace runcpp2
77
{
8-
9-
//TODO: Use rapidyaml instead
10-
11-
namespace Internal
12-
{
8+
//TODO: Use rapidyaml instead
139
struct NodeRequirement
1410
{
1511
std::string Name;
@@ -25,10 +21,8 @@ namespace Internal
2521
};
2622

2723
bool CheckNodeRequirements(YAML::Node& node, const std::vector<NodeRequirement>& requirements);
28-
29-
bool GetParsableInfo(const std::string& contentToParse, std::string& outParsableInfo);
30-
}
3124

25+
bool GetParsableInfo(const std::string& contentToParse, std::string& outParsableInfo);
3226
}
3327

3428
#endif

Include/runcpp2/PlatformUtil.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,9 @@
77

88
namespace runcpp2
99
{
10-
11-
namespace Internal
12-
{
13-
char GetAltFileSystemSeparator();
14-
15-
char GetFileSystemSeparator();
16-
1710
std::string ProcessPath(const std::string& path);
18-
11+
1912
std::vector<std::string> GetPlatformNames();
2013
}
2114

22-
}
23-
2415
#endif

Include/runcpp2/StringUtil.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66

77
namespace runcpp2
88
{
9-
namespace Internal
10-
{
11-
12-
void TrimLeft(std::string& str);
13-
void TrimRight(std::string& str);
14-
void Trim(std::string& str);
15-
16-
void SplitString( const std::string& stringToSplit,
17-
const std::string& splitter,
18-
std::vector<std::string>& outStrings);
19-
}
9+
void TrimLeft(std::string& str);
10+
void TrimRight(std::string& str);
11+
void Trim(std::string& str);
2012

13+
void SplitString( const std::string& stringToSplit,
14+
const std::string& splitter,
15+
std::vector<std::string>& outStrings);
2116
}
2217

2318
#endif

Src/runcpp2/CompilerProfileHelper.cpp

Lines changed: 96 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -4,119 +4,123 @@
44
#include "ssLogger/ssLog.hpp"
55
#include "System2.h"
66

7-
bool runcpp2::IsProfileAvailableOnSystem(const CompilerProfile& profile)
7+
namespace
88
{
9-
//Check compiler
10-
std::string command = profile.Compiler.Executable + " -v";
11-
12-
System2CommandInfo compilerCommandInfo;
13-
SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &compilerCommandInfo);
14-
15-
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
16-
{
17-
ssLOG_ERROR("System2Run failed with result: " << sys2Result);
18-
return false;
19-
}
20-
21-
int returnCode = 0;
22-
sys2Result = System2GetCommandReturnValueSync(&compilerCommandInfo, &returnCode);
23-
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
24-
{
25-
ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result);
26-
return false;
27-
}
28-
29-
if(returnCode != 0)
30-
return false;
31-
32-
//Check linker
33-
command = profile.Linker.Executable + " -v";
34-
35-
System2CommandInfo linkerCommandInfo;
36-
sys2Result = System2Run(command.c_str(), &linkerCommandInfo);
37-
38-
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
39-
{
40-
ssLOG_ERROR("System2Run failed with result: " << sys2Result);
41-
return false;
42-
}
43-
44-
returnCode = 0;
45-
sys2Result = System2GetCommandReturnValueSync(&linkerCommandInfo, &returnCode);
46-
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
47-
{
48-
ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result);
49-
return false;
50-
}
51-
52-
if(returnCode != 0)
53-
return false;
549

55-
return true;
56-
}
57-
58-
bool runcpp2::IsProfileValidForScript( const CompilerProfile& profile,
59-
const ScriptInfo& scriptInfo,
60-
const std::string& scriptPath)
61-
{
62-
std::string scriptExtension = ghc::filesystem::path(scriptPath).extension().string();
63-
64-
if(profile.FileExtensions.find(scriptExtension.substr(1)) == profile.FileExtensions.end())
65-
return false;
66-
67-
if(!scriptInfo.Language.empty())
10+
bool IsProfileAvailableOnSystem(const runcpp2::CompilerProfile& profile)
6811
{
69-
if(profile.Languages.find(scriptInfo.Language) == profile.Languages.end())
12+
//Check compiler
13+
std::string command = profile.Compiler.Executable + " -v";
14+
15+
System2CommandInfo compilerCommandInfo;
16+
SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &compilerCommandInfo);
17+
18+
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
19+
{
20+
ssLOG_ERROR("System2Run failed with result: " << sys2Result);
7021
return false;
22+
}
23+
24+
int returnCode = 0;
25+
sys2Result = System2GetCommandReturnValueSync(&compilerCommandInfo, &returnCode);
26+
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
27+
{
28+
ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result);
29+
return false;
30+
}
31+
32+
if(returnCode != 0)
33+
return false;
34+
35+
//Check linker
36+
command = profile.Linker.Executable + " -v";
37+
38+
System2CommandInfo linkerCommandInfo;
39+
sys2Result = System2Run(command.c_str(), &linkerCommandInfo);
40+
41+
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
42+
{
43+
ssLOG_ERROR("System2Run failed with result: " << sys2Result);
44+
return false;
45+
}
46+
47+
returnCode = 0;
48+
sys2Result = System2GetCommandReturnValueSync(&linkerCommandInfo, &returnCode);
49+
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
50+
{
51+
ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result);
52+
return false;
53+
}
54+
55+
if(returnCode != 0)
56+
return false;
57+
58+
return true;
7159
}
72-
73-
if(!scriptInfo.RequiredProfiles.empty())
60+
61+
bool IsProfileValidForScript( const runcpp2::CompilerProfile& profile,
62+
const runcpp2::ScriptInfo& scriptInfo,
63+
const std::string& scriptPath)
7464
{
75-
std::vector<PlatformName> platformNames = Internal::GetPlatformNames();
65+
std::string scriptExtension = ghc::filesystem::path(scriptPath).extension().string();
7666

77-
for(int i = 0; i < platformNames.size(); ++i)
67+
if(profile.FileExtensions.find(scriptExtension.substr(1)) == profile.FileExtensions.end())
68+
return false;
69+
70+
if(!scriptInfo.Language.empty())
7871
{
79-
if(scriptInfo.RequiredProfiles.find(platformNames.at(i)) == scriptInfo.RequiredProfiles.end())
80-
continue;
72+
if(profile.Languages.find(scriptInfo.Language) == profile.Languages.end())
73+
return false;
74+
}
75+
76+
if(!scriptInfo.RequiredProfiles.empty())
77+
{
78+
std::vector<PlatformName> platformNames = runcpp2::GetPlatformNames();
8179

82-
const std::vector<ProfileName> allowedProfileNames = scriptInfo .RequiredProfiles
83-
.at(platformNames.at(i));
84-
85-
for(int j = 0; j < allowedProfileNames.size(); ++j)
80+
for(int i = 0; i < platformNames.size(); ++i)
8681
{
87-
if(allowedProfileNames.at(j) == profile.Name)
88-
return true;
82+
if(scriptInfo.RequiredProfiles.find(platformNames.at(i)) == scriptInfo.RequiredProfiles.end())
83+
continue;
84+
85+
const std::vector<ProfileName> allowedProfileNames = scriptInfo .RequiredProfiles
86+
.at(platformNames.at(i));
87+
88+
for(int j = 0; j < allowedProfileNames.size(); ++j)
89+
{
90+
if(allowedProfileNames.at(j) == profile.Name)
91+
return true;
92+
}
93+
94+
//If we went through all the specified profile names, exit
95+
return false;
8996
}
9097

91-
//If we went through all the specified profile names, exit
98+
//If we went through all the specified platform names for required profiles, exit
9299
return false;
93100
}
94101

95-
//If we went through all the specified platform names for required profiles, exit
96-
return false;
102+
return true;
97103
}
98-
99-
return true;
100-
}
101104

102-
std::vector<ProfileName> runcpp2::GetAvailableProfiles( const std::vector<CompilerProfile>& profiles,
103-
const ScriptInfo& scriptInfo,
104-
const std::string& scriptPath)
105-
{
106-
//Check which compiler is available
107-
std::vector<ProfileName> availableProfiles;
108-
109-
for(int i = 0; i < profiles.size(); ++i)
105+
std::vector<ProfileName> GetAvailableProfiles( const std::vector<runcpp2::CompilerProfile>& profiles,
106+
const runcpp2::ScriptInfo& scriptInfo,
107+
const std::string& scriptPath)
110108
{
111-
if(IsProfileAvailableOnSystem(profiles.at(i)) && IsProfileValidForScript( profiles.at(i),
112-
scriptInfo,
113-
scriptPath))
109+
//Check which compiler is available
110+
std::vector<ProfileName> availableProfiles;
111+
112+
for(int i = 0; i < profiles.size(); ++i)
114113
{
115-
availableProfiles.push_back(profiles.at(i).Name);
114+
if(IsProfileAvailableOnSystem(profiles.at(i)) && IsProfileValidForScript( profiles.at(i),
115+
scriptInfo,
116+
scriptPath))
117+
{
118+
availableProfiles.push_back(profiles.at(i).Name);
119+
}
116120
}
121+
122+
return availableProfiles;
117123
}
118-
119-
return availableProfiles;
120124
}
121125

122126

0 commit comments

Comments
 (0)