-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildTypeHelper.hpp
More file actions
102 lines (85 loc) · 3.33 KB
/
Copy pathBuildTypeHelper.hpp
File metadata and controls
102 lines (85 loc) · 3.33 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
99
100
101
102
#ifndef RUNCPP2_DATA_BUILD_TYPE_HELPER_HPP
#define RUNCPP2_DATA_BUILD_TYPE_HELPER_HPP
#include "runcpp2/Data/BuildType.hpp"
#include "runcpp2/Data/FilesTypesInfo.hpp"
#include "runcpp2/Data/Profile.hpp"
#include "runcpp2/Data/FileProperties.hpp"
#include "runcpp2/PlatformUtil.hpp"
#include "ghc/filesystem.hpp"
#include "ssLogger/ssLog.hpp"
#include <string>
#include <vector>
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:
properties.push_back(&filesTypes.ExecutableFile);
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
{
namespace Data
{
namespace BuildTypeHelper
{
inline bool NeedsLinking(BuildType buildType)
{
return buildType != BuildType::OBJECTS;
}
inline bool 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();
//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;
outPaths.push_back(buildDir / (*targetPrefix + scriptName + *targetExt));
//Only ExecutableFile or SharedLibraryFile are runnable for non-direct executables
outIsRunnable.push_back(fileTypeInfo == &profile.FilesTypes.SharedLibraryFile ||
fileTypeInfo == &profile.FilesTypes.ExecutableFile);
}
return !outPaths.empty();
}
}
}
}
#endif