diff options
author | Brad King <brad.king@kitware.com> | 2019-06-04 12:35:05 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-06-04 12:37:55 (GMT) |
commit | 842f70c49359bfd9a13e333f2571371f64d163e1 (patch) | |
tree | 7bb365330ba84dd07bdce19963f12fee3e6a6c59 /Source | |
parent | a7d2efc15b117e404aeaf952c762a96ba34787a3 (diff) | |
parent | fec441ec17d74b6444fad2a3e32a47dd19f1be5b (diff) | |
download | CMake-842f70c49359bfd9a13e333f2571371f64d163e1.zip CMake-842f70c49359bfd9a13e333f2571371f64d163e1.tar.gz CMake-842f70c49359bfd9a13e333f2571371f64d163e1.tar.bz2 |
Merge topic 'emulator-arguments'
fec441ec17 Teach CROSSCOMPILING_EMULATOR to support arguments
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3402
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 57 | ||||
-rw-r--r-- | Source/cmCustomCommandGenerator.h | 4 |
2 files changed, 48 insertions, 13 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; diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 7fd60c0..766f4b8 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -22,10 +22,12 @@ class cmCustomCommandGenerator bool MakeVars; cmGeneratorExpression* GE; cmCustomCommandLines CommandLines; + std::vector<std::vector<std::string>> EmulatorsWithArguments; std::vector<std::string> Depends; std::string WorkingDirectory; - const char* GetCrossCompilingEmulator(unsigned int c) const; + void FillEmulatorsWithArguments(); + std::vector<std::string> GetCrossCompilingEmulator(unsigned int c) const; const char* GetArgv0Location(unsigned int c) const; public: |