-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildTypeHelper.cpp
More file actions
98 lines (82 loc) · 3.55 KB
/
Copy pathBuildTypeHelper.cpp
File metadata and controls
98 lines (82 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "runcpp2/Data/BuildTypeHelper.hpp"
#include "runcpp2/PlatformUtil.hpp"
#include "ssLogger/ssLog.hpp"
namespace
{
using namespace runcpp2::Data;
std::vector<const FileProperties*>
GetOutputFileProperties(const FilesTypesInfo& filesTypes, BuildType buildType)
{
std::vector<const FileProperties*> properties;
static_assert(static_cast<int>(BuildType::COUNT) == 6, "Update This");
switch(buildType)
{
case BuildType::INTERNAL_EXECUTABLE_EXECUTABLE:
//NOTE: Currently this is a special case and handled outside
//TODO: Handle it as config
break;
case BuildType::INTERNAL_EXECUTABLE_SHARED:
case BuildType::SHARED:
properties.push_back(&filesTypes.SharedLibraryFile);
properties.push_back(&filesTypes.SharedLinkFile);
break;
case BuildType::STATIC:
properties.push_back(&filesTypes.StaticLinkFile);
break;
case BuildType::OBJECTS:
properties.push_back(&filesTypes.ObjectLinkFile);
break;
}
properties.push_back(&filesTypes.DebugSymbolFile);
return properties;
}
}
namespace runcpp2
{
bool Data::BuildTypeHelper::NeedsLinking(BuildType buildType)
{
return buildType != BuildType::OBJECTS;
}
bool Data::BuildTypeHelper::GetPossibleOutputPaths( const ghc::filesystem::path& buildDir,
const std::string& scriptName,
const Profile& profile,
const BuildType buildType,
std::vector<ghc::filesystem::path>& outPaths,
std::vector<bool>& outIsRunnable)
{
outPaths.clear();
outIsRunnable.clear();
//For executable build type with executable flag, use platform-specific extension
if(buildType == BuildType::INTERNAL_EXECUTABLE_EXECUTABLE)
{
#ifdef _WIN32
outPaths.push_back(buildDir / (scriptName + ".exe"));
#else
outPaths.push_back(buildDir / scriptName);
#endif
outIsRunnable.push_back(true);
}
//Get all relevant file properties
std::vector<const FileProperties*> fileProperties =
GetOutputFileProperties(profile.FilesTypes, buildType);
//Generate paths for each file type
for(const FileProperties* fileTypeInfo : fileProperties)
{
if(!fileTypeInfo)
{
ssLOG_ERROR("fileProperties should not contain nullptr");
return false;
}
const std::string* targetExt = runcpp2::GetValueFromPlatformMap(fileTypeInfo->Extension);
const std::string* targetPrefix = runcpp2::GetValueFromPlatformMap(fileTypeInfo->Prefix);
if(targetExt == nullptr || targetPrefix == nullptr)
continue;
if(targetExt->empty() && targetPrefix->empty())
continue;
outPaths.push_back(buildDir / (*targetPrefix + scriptName + *targetExt));
//Only SharedLibraryFile is runnable for non-direct executables
outIsRunnable.push_back(fileTypeInfo == &profile.FilesTypes.SharedLibraryFile);
}
return !outPaths.empty();
}
}