diff options
Diffstat (limited to 'Source/CTest/cmCTestP4.cxx')
-rw-r--r-- | Source/CTest/cmCTestP4.cxx | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 5d71b84..0e002b9 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -149,16 +149,17 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) auto it = this->Users.find(username); if (it == this->Users.end()) { - std::vector<std::string> p4_users; + std::vector<char const*> p4_users; this->SetP4Options(p4_users); p4_users.push_back("users"); p4_users.push_back("-m"); p4_users.push_back("1"); - p4_users.push_back(username); + p4_users.push_back(username.c_str()); + p4_users.push_back(nullptr); UserParser out(this, "users-out> "); OutputLogger err(this->Log, "users-err> "); - this->RunChild(p4_users, &out, &err); + this->RunChild(p4_users.data(), &out, &err); // The user should now be added to the map. Search again. it = this->Users.find(username); @@ -302,10 +303,10 @@ private: } }; -void cmCTestP4::SetP4Options(std::vector<std::string>& CommandOptions) +void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions) { if (this->P4Options.empty()) { - std::string p4 = this->CommandLineTool; + const char* p4 = this->CommandLineTool.c_str(); this->P4Options.emplace_back(p4); // The CTEST_P4_CLIENT variable sets the P4 client used when issuing @@ -327,12 +328,15 @@ void cmCTestP4::SetP4Options(std::vector<std::string>& CommandOptions) cm::append(this->P4Options, cmSystemTools::ParseArguments(opts)); } - CommandOptions = this->P4Options; + CommandOptions.clear(); + for (std::string const& o : this->P4Options) { + CommandOptions.push_back(o.c_str()); + } } std::string cmCTestP4::GetWorkingRevision() { - std::vector<std::string> p4_identify; + std::vector<char const*> p4_identify; this->SetP4Options(p4_identify); p4_identify.push_back("changes"); @@ -341,13 +345,14 @@ std::string cmCTestP4::GetWorkingRevision() p4_identify.push_back("-t"); std::string source = this->SourceDirectory + "/...#have"; - p4_identify.push_back(source); + p4_identify.push_back(source.c_str()); + p4_identify.push_back(nullptr); std::string rev; IdentifyParser out(this, "p4_changes-out> ", rev); OutputLogger err(this->Log, "p4_changes-err> "); - bool result = this->RunChild(p4_identify, &out, &err); + bool result = this->RunChild(p4_identify.data(), &out, &err); // If there was a problem contacting the server return "<unknown>" if (!result) { @@ -383,7 +388,7 @@ bool cmCTestP4::NoteNewRevision() bool cmCTestP4::LoadRevisions() { - std::vector<std::string> p4_changes; + std::vector<char const*> p4_changes; this->SetP4Options(p4_changes); // Use 'p4 changes ...@old,new' to get a list of changelists @@ -404,36 +409,38 @@ bool cmCTestP4::LoadRevisions() .append(this->NewRevision); p4_changes.push_back("changes"); - p4_changes.push_back(range); + p4_changes.push_back(range.c_str()); + p4_changes.push_back(nullptr); ChangesParser out(this, "p4_changes-out> "); OutputLogger err(this->Log, "p4_changes-err> "); this->ChangeLists.clear(); - this->RunChild(p4_changes, &out, &err); + this->RunChild(p4_changes.data(), &out, &err); if (this->ChangeLists.empty()) { return true; } // p4 describe -s ...@1111111,2222222 - std::vector<std::string> p4_describe; + std::vector<char const*> p4_describe; for (std::string const& i : cmReverseRange(this->ChangeLists)) { this->SetP4Options(p4_describe); p4_describe.push_back("describe"); p4_describe.push_back("-s"); - p4_describe.push_back(i); + p4_describe.push_back(i.c_str()); + p4_describe.push_back(nullptr); DescribeParser outDescribe(this, "p4_describe-out> "); OutputLogger errDescribe(this->Log, "p4_describe-err> "); - this->RunChild(p4_describe, &outDescribe, &errDescribe); + this->RunChild(p4_describe.data(), &outDescribe, &errDescribe); } return true; } bool cmCTestP4::LoadModifications() { - std::vector<std::string> p4_diff; + std::vector<char const*> p4_diff; this->SetP4Options(p4_diff); p4_diff.push_back("diff"); @@ -441,11 +448,12 @@ bool cmCTestP4::LoadModifications() // Ideally we would use -Od but not all clients support it p4_diff.push_back("-dn"); std::string source = this->SourceDirectory + "/..."; - p4_diff.push_back(source); + p4_diff.push_back(source.c_str()); + p4_diff.push_back(nullptr); DiffParser out(this, "p4_diff-out> "); OutputLogger err(this->Log, "p4_diff-err> "); - this->RunChild(p4_diff, &out, &err); + this->RunChild(p4_diff.data(), &out, &err); return true; } @@ -453,14 +461,17 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) { cmList p4_custom_command{ custom, cmList::EmptyElements::Yes }; - std::vector<std::string> p4_custom; - p4_custom.reserve(p4_custom_command.size()); - cm::append(p4_custom, p4_custom_command); + std::vector<char const*> p4_custom; + p4_custom.reserve(p4_custom_command.size() + 1); + for (std::string const& i : p4_custom_command) { + p4_custom.push_back(i.c_str()); + } + p4_custom.push_back(nullptr); OutputLogger custom_out(this->Log, "p4_customsync-out> "); OutputLogger custom_err(this->Log, "p4_customsync-err> "); - return this->RunUpdateCommand(p4_custom, &custom_out, &custom_err); + return this->RunUpdateCommand(p4_custom.data(), &custom_out, &custom_err); } bool cmCTestP4::UpdateImpl() @@ -477,7 +488,7 @@ bool cmCTestP4::UpdateImpl() return false; } - std::vector<std::string> p4_sync; + std::vector<char const*> p4_sync; this->SetP4Options(p4_sync); p4_sync.push_back("sync"); @@ -488,7 +499,9 @@ bool cmCTestP4::UpdateImpl() opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } std::vector<std::string> args = cmSystemTools::ParseArguments(opts); - cm::append(p4_sync, args); + for (std::string const& arg : args) { + p4_sync.push_back(arg.c_str()); + } std::string source = this->SourceDirectory + "/..."; @@ -502,10 +515,11 @@ bool cmCTestP4::UpdateImpl() source.append("@\"").append(date).append("\""); } - p4_sync.push_back(source); + p4_sync.push_back(source.c_str()); + p4_sync.push_back(nullptr); OutputLogger out(this->Log, "p4_sync-out> "); OutputLogger err(this->Log, "p4_sync-err> "); - return this->RunUpdateCommand(p4_sync, &out, &err); + return this->RunUpdateCommand(p4_sync.data(), &out, &err); } |