cmake_file_api: New project command

Projects can use the new command to request file API replies for the current
run. No query files are generated, the query is tracked internally. Replies are
created in the file system at generation time in the usual way.

Fixes: #24951
This commit is contained in:
Craig Scott
2023-06-02 17:16:57 +10:00
committed by Brad King
parent 9a63aa8d57
commit 99b2ccf80d
17 changed files with 447 additions and 11 deletions

View File

@@ -978,3 +978,45 @@ Json::Value cmFileAPI::ReportCapabilities()
return capabilities;
}
bool cmFileAPI::AddProjectQuery(cmFileAPI::ObjectKind kind,
unsigned majorVersion, unsigned minorVersion)
{
switch (kind) {
case ObjectKind::CodeModel:
if (majorVersion != 2 || minorVersion > CodeModelV2Minor) {
return false;
}
break;
case ObjectKind::Cache:
if (majorVersion != 2 || minorVersion > CacheV2Minor) {
return false;
}
break;
case ObjectKind::CMakeFiles:
if (majorVersion != 1 || minorVersion > CMakeFilesV1Minor) {
return false;
}
break;
case ObjectKind::Toolchains:
if (majorVersion != 1 || minorVersion > ToolchainsV1Minor) {
return false;
}
break;
// These cannot be requested by the project
case ObjectKind::ConfigureLog:
case ObjectKind::InternalTest:
return false;
}
Object query;
query.Kind = kind;
query.Version = majorVersion;
if (std::find(this->TopQuery.Known.begin(), this->TopQuery.Known.end(),
query) == this->TopQuery.Known.end()) {
this->TopQuery.Known.emplace_back(query);
this->QueryExists = true;
}
return true;
}