-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutionPlanning.cpp
More file actions
116 lines (94 loc) · 2.58 KB
/
Copy pathExecutionPlanning.cpp
File metadata and controls
116 lines (94 loc) · 2.58 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @file ExecutionPlanning.cpp
*
* Pure execution plan layout assembly for Vix Engine.
*/
#include <vix/engine/ExecutionPlanning.hpp>
#include <string>
#include <utility>
namespace vix::engine
{
namespace
{
/**
* @brief Builds the canonical directory name for a build variant.
*
* Format:
*
* <preset>
* <preset>-<sanitizer>
* <preset>-<target-triple>
* <preset>-<sanitizer>-<target-triple>
*/
[[nodiscard]] std::string make_build_directory_name(
const ExecutionPlanLayoutOptions &options)
{
std::string name = options.preset.buildDirName;
const std::string sanitizerSuffix{
sanitizer_build_suffix(options.sanitizerMode)};
if (!sanitizerSuffix.empty())
{
name += "-";
name += sanitizerSuffix;
}
if (!options.targetTriple.empty())
{
name += "-";
name += options.targetTriple;
}
return name;
}
} // namespace
bool ExecutionPlanLayoutResult::success() const
{
return error.empty() && plan.valid();
}
ExecutionPlanLayoutResult make_execution_plan_layout(
const ExecutionPlanLayoutOptions &options)
{
ExecutionPlanLayoutResult result;
if (options.userProjectDir.empty())
{
result.error = "user project directory is required";
return result;
}
if (options.cmakeSourceDir.empty())
{
result.error = "CMake source directory is required";
return result;
}
if (!options.preset.valid())
{
result.error = "valid preset is required";
return result;
}
if (options.preset.buildDirName.empty())
{
result.error = "preset build directory name is required";
return result;
}
ExecutionPlan plan;
plan.userProjectDir =
options.userProjectDir.lexically_normal();
plan.cmakeSourceDir =
options.cmakeSourceDir.lexically_normal();
plan.projectDir = plan.userProjectDir;
plan.defaultTargetName = options.defaultTargetName;
plan.generatedFromVixApp = options.generatedFromVixApp;
plan.preset = options.preset;
plan.buildDir =
plan.userProjectDir /
make_build_directory_name(options);
plan.buildDir = plan.buildDir.lexically_normal();
plan.configureLog =
plan.buildDir / "configure.log";
plan.buildLog =
plan.buildDir / "build.log";
plan.sigFile =
plan.buildDir / ".vix-config.sig";
plan.toolchainFile =
plan.buildDir / "vix-toolchain.cmake";
result.plan = std::move(plan);
return result;
}
} // namespace vix::engine