fileapi: Add cross-compiling emulator to codemodel-v2

Fixes: #25408
This commit is contained in:
Ralf Habacker
2023-11-11 15:35:21 +01:00
committed by Brad King
parent 2d0b7798db
commit 80a64c9ce5
15 changed files with 369 additions and 6 deletions

View File

@@ -727,7 +727,7 @@ std::string cmFileAPI::NoSupportedVersion(
// The "codemodel" object kind.
// Update Help/manual/cmake-file-api.7.rst when updating this constant.
static unsigned int const CodeModelV2Minor = 6;
static unsigned int const CodeModelV2Minor = 7;
void cmFileAPI::BuildClientRequestCodeModel(
ClientRequest& r, std::vector<RequestVersion> const& versions)

View File

@@ -41,10 +41,12 @@
#include "cmInstallSubdirectoryGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmLinkLineComputer.h" // IWYU pragma: keep
#include "cmList.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceGroup.h"
#include "cmState.h"
@@ -503,6 +505,8 @@ class Target
Json::Value DumpDependencies();
Json::Value DumpDependency(cmTargetDepend const& td);
Json::Value DumpFolder();
Json::Value DumpLauncher(const char* name, const char* type);
Json::Value DumpLaunchers();
public:
Target(cmGeneratorTarget* gt, std::string const& config);
@@ -1223,6 +1227,13 @@ Json::Value Target::Dump()
target["archive"] = this->DumpArchive();
}
if (type == cmStateEnums::EXECUTABLE) {
Json::Value launchers = this->DumpLaunchers();
if (!launchers.empty()) {
target["launchers"] = std::move(launchers);
}
}
Json::Value dependencies = this->DumpDependencies();
if (!dependencies.empty()) {
target["dependencies"] = dependencies;
@@ -2075,6 +2086,41 @@ Json::Value Target::DumpFolder()
}
return folder;
}
Json::Value Target::DumpLauncher(const char* name, const char* type)
{
cmValue property = this->GT->GetProperty(name);
Json::Value launcher;
if (property) {
cmList commandWithArgs{ *property };
std::string command(commandWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(command);
launcher = Json::objectValue;
launcher["command"] = RelativeIfUnder(this->TopSource, command);
launcher["type"] = type;
Json::Value args;
for (std::string const& arg : cmMakeRange(commandWithArgs).advance(1)) {
args.append(arg);
}
launcher["arguments"] = args;
}
return launcher;
}
Json::Value Target::DumpLaunchers()
{
Json::Value launchers;
bool allow =
this->GT->Makefile->GetDefinition("CMAKE_CROSSCOMPILING").IsOn();
Json::Value launcher;
if (allow) {
launcher = DumpLauncher("CROSSCOMPILING_EMULATOR", "emulator");
if (!launcher.empty()) {
launchers.append(launcher);
}
}
return launchers;
}
}
Json::Value cmFileAPICodemodelDump(cmFileAPI& fileAPI, unsigned long version)