-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildContext.cpp
More file actions
86 lines (73 loc) · 2.02 KB
/
Copy pathBuildContext.cpp
File metadata and controls
86 lines (73 loc) · 2.02 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
/**
*
* @file BuildContext.cpp
* @author Gaspard Kirira
*
* Copyright 2026, Gaspard Kirira. All rights reserved.
* https://github.com/vixcpp/vix
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Vix.cpp
*
* Shared engine build context helpers
*
*/
#include <vix/engine/BuildContext.hpp>
namespace vix::engine
{
namespace
{
static std::string fallback_project_name(const ExecutionPlan &plan)
{
if (!plan.projectDir.empty())
return plan.projectDir.filename().string();
return plan.userProjectDir.filename().string();
}
} // namespace
std::string default_build_target_name(
const BuildTargetOptions &options,
const ExecutionPlan &plan)
{
return default_build_target_name(options.buildTarget, plan);
}
std::string default_graph_target_name(
const BuildTargetOptions &options,
const ExecutionPlan &plan)
{
return default_graph_target_name(options.buildTarget, plan);
}
std::filesystem::path default_project_executable_path(
const BuildTargetOptions &options,
const ExecutionPlan &plan)
{
return default_project_executable_path(options.buildTarget, plan);
}
std::string default_build_target_name(
std::string_view buildTarget,
const ExecutionPlan &plan)
{
if (!buildTarget.empty())
return std::string(buildTarget);
if (!plan.defaultTargetName.empty())
return plan.defaultTargetName;
return fallback_project_name(plan);
}
std::string default_graph_target_name(
std::string_view buildTarget,
const ExecutionPlan &plan)
{
return default_build_target_name(buildTarget, plan);
}
std::filesystem::path default_project_executable_path(
std::string_view buildTarget,
const ExecutionPlan &plan)
{
const std::string target = default_build_target_name(buildTarget, plan);
#ifdef _WIN32
return plan.buildDir / (target + ".exe");
#else
return plan.buildDir / target;
#endif
}
} // namespace vix::engine