cmake --workflow: add --fresh option

Fixes: #24073
This commit is contained in:
Kyle Edwards
2022-10-25 11:13:35 -04:00
parent 7d9aa0f00c
commit 7ecbe324b0
7 changed files with 68 additions and 10 deletions
+8 -5
View File
@@ -3733,7 +3733,7 @@ std::function<int()> cmake::BuildWorkflowStep(
#endif
int cmake::Workflow(const std::string& presetName,
WorkflowListPresets listPresets)
WorkflowListPresets listPresets, WorkflowFresh fresh)
{
#ifndef CMAKE_BOOTSTRAP
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
@@ -3815,10 +3815,13 @@ int cmake::Workflow(const std::string& presetName,
if (!configurePreset) {
return 1;
}
steps.emplace_back(
stepNumber, "configure"_s, step.PresetName,
this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(),
"--preset", step.PresetName }));
std::vector<std::string> args{ cmSystemTools::GetCMakeCommand(),
"--preset", step.PresetName };
if (fresh == WorkflowFresh::Yes) {
args.emplace_back("--fresh");
}
steps.emplace_back(stepNumber, "configure"_s, step.PresetName,
this->BuildWorkflowStep(args));
} break;
case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: {
auto const* buildPreset = this->FindPresetForWorkflow(
+7 -1
View File
@@ -607,7 +607,13 @@ public:
No,
Yes,
};
int Workflow(const std::string& presetName, WorkflowListPresets listPresets);
enum class WorkflowFresh
{
No,
Yes,
};
int Workflow(const std::string& presetName, WorkflowListPresets listPresets,
WorkflowFresh fresh);
void UnwatchUnusedCli(const std::string& var);
void WatchUnusedCli(const std::string& var);
+10 -1
View File
@@ -918,8 +918,10 @@ int do_workflow(int ac, char const* const* av)
return -1;
#else
using WorkflowListPresets = cmake::WorkflowListPresets;
using WorkflowFresh = cmake::WorkflowFresh;
std::string presetName;
auto listPresets = WorkflowListPresets::No;
auto fresh = WorkflowFresh::No;
using CommandArgument =
cmCommandLineArgument<bool(std::string const& value)>;
@@ -932,6 +934,11 @@ int do_workflow(int ac, char const* const* av)
listPresets = WorkflowListPresets::Yes;
return true;
} },
CommandArgument{ "--fresh", CommandArgument::Values::Zero,
[&fresh](const std::string&) -> bool {
fresh = WorkflowFresh::Yes;
return true;
} },
};
std::vector<std::string> inputArgs;
@@ -968,6 +975,8 @@ int do_workflow(int ac, char const* const* av)
"Options:\n"
" --preset <preset> = Workflow preset to execute.\n"
" --list-presets = List available workflow presets.\n"
" --fresh = Configure a fresh build tree, removing any "
"existing cache file.\n"
;
/* clang-format on */
return 1;
@@ -982,7 +991,7 @@ int do_workflow(int ac, char const* const* av)
cmakemainProgressCallback(msg, prog, &cm);
});
return cm.Workflow(presetName, listPresets);
return cm.Workflow(presetName, listPresets, fresh);
#endif
}