diff options
author | Marek Antoniak <kfazol@gmail.com> | 2019-05-30 14:11:10 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-06-03 14:17:17 (GMT) |
commit | fec441ec17d74b6444fad2a3e32a47dd19f1be5b (patch) | |
tree | 073dc1ab354485e4be0caba5730b83bad97a979f /Source/cmCustomCommandGenerator.cxx | |
parent | 3cb5a8d9b3add4394b12d61b5ce83ea6ca148fd1 (diff) | |
download | CMake-fec441ec17d74b6444fad2a3e32a47dd19f1be5b.zip CMake-fec441ec17d74b6444fad2a3e32a47dd19f1be5b.tar.gz CMake-fec441ec17d74b6444fad2a3e32a47dd19f1be5b.tar.bz2 |
Teach CROSSCOMPILING_EMULATOR to support arguments
Fixes: #19321
Diffstat (limited to 'Source/cmCustomCommandGenerator.cxx')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index e58fc76..89aaad0 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -75,6 +75,8 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, cmSystemTools::CollapseFullPath(this->WorkingDirectory, build_dir); } } + + this->FillEmulatorsWithArguments(); } cmCustomCommandGenerator::~cmCustomCommandGenerator() @@ -87,19 +89,38 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const return static_cast<unsigned int>(this->CC.GetCommandLines().size()); } -const char* cmCustomCommandGenerator::GetCrossCompilingEmulator( - unsigned int c) const +void cmCustomCommandGenerator::FillEmulatorsWithArguments() { if (!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")) { - return nullptr; + return; } - std::string const& argv0 = this->CommandLines[c][0]; - cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); - if (target && target->GetType() == cmStateEnums::EXECUTABLE && - !target->IsImported()) { - return target->GetProperty("CROSSCOMPILING_EMULATOR"); + + for (unsigned int c = 0; c < this->GetNumberOfCommands(); ++c) { + std::string const& argv0 = this->CommandLines[c][0]; + cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); + if (target && target->GetType() == cmStateEnums::EXECUTABLE && + !target->IsImported()) { + + const char* emulator_property = + target->GetProperty("CROSSCOMPILING_EMULATOR"); + if (!emulator_property) { + continue; + } + + this->EmulatorsWithArguments.emplace_back(); + cmSystemTools::ExpandListArgument(emulator_property, + this->EmulatorsWithArguments[c]); + } } - return nullptr; +} + +std::vector<std::string> cmCustomCommandGenerator::GetCrossCompilingEmulator( + unsigned int c) const +{ + if (c >= this->EmulatorsWithArguments.size()) { + return std::vector<std::string>(); + } + return this->EmulatorsWithArguments[c]; } const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const @@ -129,8 +150,9 @@ bool cmCustomCommandGenerator::HasOnlyEmptyCommandLines() const std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { - if (const char* emulator = this->GetCrossCompilingEmulator(c)) { - return std::string(emulator); + std::vector<std::string> emulator = this->GetCrossCompilingEmulator(c); + if (!emulator.empty()) { + return emulator[0]; } if (const char* location = this->GetArgv0Location(c)) { return std::string(location); @@ -168,9 +190,20 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c, std::string& cmd) const { unsigned int offset = 1; - if (this->GetCrossCompilingEmulator(c) != nullptr) { + std::vector<std::string> emulator = this->GetCrossCompilingEmulator(c); + if (!emulator.empty()) { + for (unsigned j = 1; j < emulator.size(); ++j) { + cmd += " "; + if (this->OldStyle) { + cmd += escapeForShellOldStyle(emulator[j]); + } else { + cmd += this->LG->EscapeForShell(emulator[j], this->MakeVars); + } + } + offset = 0; } + cmCustomCommandLine const& commandLine = this->CommandLines[c]; for (unsigned int j = offset; j < commandLine.size(); ++j) { std::string arg; |