2020#include < vix/cli/build/ObjectCache.hpp>
2121#include < vix/cli/build/BuildGraphExecutor.hpp>
2222#include < vix/cli/build/BuildStyle.hpp>
23+ #include < vix/cli/build/BuildContext.hpp>
2324
2425#include < algorithm>
2526#include < cctype>
@@ -95,17 +96,6 @@ namespace vix::commands::BuildCommand
9596 }
9697 };
9798
98- static std::map<std::string, process::Preset> builtin_presets ()
99- {
100- std::map<std::string, process::Preset> m;
101-
102- m.emplace (" dev" , process::Preset{" dev" , " Ninja" , " Debug" , " build-dev" });
103- m.emplace (" dev-ninja" , process::Preset{" dev-ninja" , " Ninja" , " Debug" , " build-ninja" });
104- m.emplace (" release" , process::Preset{" release" , " Ninja" , " Release" , " build-release" });
105-
106- return m;
107- }
108-
10999 static bool write_if_different (const fs::path &path, const std::string &content)
110100 {
111101 if (util::file_exists (path))
@@ -118,26 +108,6 @@ namespace vix::commands::BuildCommand
118108 return util::write_text_file_atomic (path, content);
119109 }
120110
121- static std::string graph_build_target_name (
122- const process::Options &opt,
123- const process::Plan &plan)
124- {
125- if (!opt.buildTarget .empty ())
126- return opt.buildTarget ;
127-
128- return plan.projectDir .filename ().string ();
129- }
130-
131- static std::string cmake_build_target_name (
132- const process::Options &opt,
133- const process::Plan &plan)
134- {
135- if (!opt.buildTarget .empty ())
136- return opt.buildTarget ;
137-
138- return plan.projectDir .filename ().string ();
139- }
140-
141111 static bool graph_executor_enabled ()
142112 {
143113 const char *value = std::getenv (" VIX_GRAPH_EXECUTOR" );
@@ -191,15 +161,6 @@ namespace vix::commands::BuildCommand
191161 return true ;
192162 }
193163
194- static std::optional<process::Preset> resolve_preset (const std::string &name)
195- {
196- const auto presets = builtin_presets ();
197- const auto it = presets.find (name);
198- if (it == presets.end ())
199- return std::nullopt ;
200- return it->second ;
201- }
202-
203164 static std::size_t count_built_targets_from_log (const std::string &log)
204165 {
205166 std::size_t count = 0 ;
@@ -927,7 +888,7 @@ namespace vix::commands::BuildCommand
927888 return std::nullopt ;
928889 }
929890
930- const auto presetOpt = resolve_preset (opt.preset );
891+ const auto presetOpt = build::resolve_builtin_preset (opt.preset );
931892 if (!presetOpt)
932893 return std::nullopt ;
933894
@@ -1848,7 +1809,7 @@ namespace vix::commands::BuildCommand
18481809 {
18491810 build::BuildGraphExecutorOptions executorOptions;
18501811 executorOptions.buildDir = plan_.buildDir ;
1851- executorOptions.target = graph_build_target_name (opt_, plan_);
1812+ executorOptions.target = build::default_graph_target_name (opt_, plan_);
18521813 executorOptions.jobs = opt_.jobs ;
18531814 executorOptions.quiet = opt_.quiet ;
18541815 executorOptions.verbose = verboseMode;
@@ -2088,7 +2049,7 @@ namespace vix::commands::BuildCommand
20882049
20892050 build::print_build_header_full (
20902051 std::cout,
2091- cmake_build_target_name (opt_, plan_),
2052+ build::default_build_target_name (opt_, plan_),
20922053 display_build_profile (plan_),
20932054 plan_.launcher ,
20942055 plan_.fastLinkerFlag ,
@@ -2098,7 +2059,7 @@ namespace vix::commands::BuildCommand
20982059 {
20992060 build::print_build_header_full (
21002061 std::cout,
2101- cmake_build_target_name (opt_, plan_),
2062+ build::default_build_target_name (opt_, plan_),
21022063 display_build_profile (plan_),
21032064 std::nullopt ,
21042065 std::nullopt ,
@@ -2280,7 +2241,7 @@ namespace vix::commands::BuildCommand
22802241 if (parseExit != 0 )
22812242 return parseExit;
22822243
2283- if (!resolve_preset (opt.preset ))
2244+ if (!build::resolve_builtin_preset (opt.preset ))
22842245 {
22852246 error (" Unknown preset: " + opt.preset );
22862247 hint (" Available presets: dev, dev-ninja, release" );
0 commit comments