diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 47 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmServer.cxx | 36 | ||||
-rw-r--r-- | Source/cmServerConnection.cxx | 3 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 42 |
6 files changed, 81 insertions, 58 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 27ca0ca..9a10ddb 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 6) -set(CMake_VERSION_PATCH 20160923) +set(CMake_VERSION_PATCH 20160926) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 6523e3e..9b5248e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1506,22 +1506,17 @@ std::string cmCTest::Base64EncodeFile(std::string const& file) | std::ios::binary #endif ); - unsigned char* file_buffer = new unsigned char[len + 1]; - ifs.read(reinterpret_cast<char*>(file_buffer), len); + std::vector<char> file_buffer(len + 1); + ifs.read(&file_buffer[0], len); ifs.close(); - unsigned char* encoded_buffer = new unsigned char[(len * 3) / 2 + 5]; + std::vector<char> encoded_buffer((len * 3) / 2 + 5); - size_t const rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + size_t const rlen = cmsysBase64_Encode( + reinterpret_cast<unsigned char*>(&file_buffer[0]), len, + reinterpret_cast<unsigned char*>(&encoded_buffer[0]), 1); - std::string base64 = ""; - for (size_t i = 0; i < rlen; i++) { - base64 += encoded_buffer[i]; - } - delete[] file_buffer; - delete[] encoded_buffer; - - return base64; + return std::string(&encoded_buffer[0], rlen); } bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files) @@ -2795,48 +2790,42 @@ bool cmCTest::CompressString(std::string& str) int ret; z_stream strm; - unsigned char* in = - reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str())); - // zlib makes the guarantee that this is the maximum output size - int outSize = - static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0); - unsigned char* out = new unsigned char[outSize]; - strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = deflateInit(&strm, -1); // default compression level if (ret != Z_OK) { - delete[] out; return false; } + unsigned char* in = + reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str())); + // zlib makes the guarantee that this is the maximum output size + int outSize = + static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0); + std::vector<unsigned char> out(outSize); + strm.avail_in = static_cast<uInt>(str.size()); strm.next_in = in; strm.avail_out = outSize; - strm.next_out = out; + strm.next_out = &out[0]; ret = deflate(&strm, Z_FINISH); if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) { cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." << std::endl); - delete[] out; return false; } (void)deflateEnd(&strm); // Now base64 encode the resulting binary string - unsigned char* base64EncodedBuffer = new unsigned char[(outSize * 3) / 2]; + std::vector<unsigned char> base64EncodedBuffer((outSize * 3) / 2); size_t rlen = - cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1); - - str = ""; - str.append(reinterpret_cast<char*>(base64EncodedBuffer), rlen); + cmsysBase64_Encode(&out[0], strm.total_out, &base64EncodedBuffer[0], 1); - delete[] base64EncodedBuffer; - delete[] out; + str.assign(reinterpret_cast<char*>(&base64EncodedBuffer[0]), rlen); return true; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 997f46c..0d5de06 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2996,6 +2996,15 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( buildSettings->AddAttribute("GCC_VERSION", this->CreateString(this->GeneratorToolset)); } + if (this->GetLanguageEnabled("Swift")) { + std::string swiftVersion = "2.3"; + if (const char* vers = this->CurrentMakefile->GetDefinition( + "CMAKE_Swift_LANGUAGE_VERSION")) { + swiftVersion = vers; + } + buildSettings->AddAttribute("SWIFT_VERSION", + this->CreateString(swiftVersion)); + } std::string symroot = root->GetCurrentBinaryDirectory(); symroot += "/build"; diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index d5dac4e..46c1946 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -123,8 +123,9 @@ void cmServer::RegisterProtocol(cmServerProtocol* protocol) [version](cmServerProtocol* p) { return p->ProtocolVersion() == version; }); - if (it == this->SupportedProtocols.end()) + if (it == this->SupportedProtocols.end()) { this->SupportedProtocols.push_back(protocol); + } } void cmServer::PrintHello() const @@ -181,37 +182,44 @@ void cmServer::reportMessage(const char* msg, const char* title, cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) { - if (request.Type != kHANDSHAKE_TYPE) + if (request.Type != kHANDSHAKE_TYPE) { return request.ReportError("Waiting for type \"" + kHANDSHAKE_TYPE + "\"."); + } Json::Value requestedProtocolVersion = request.Data[kPROTOCOL_VERSION_KEY]; - if (requestedProtocolVersion.isNull()) + if (requestedProtocolVersion.isNull()) { return request.ReportError("\"" + kPROTOCOL_VERSION_KEY + "\" is required for \"" + kHANDSHAKE_TYPE + "\"."); + } - if (!requestedProtocolVersion.isObject()) + if (!requestedProtocolVersion.isObject()) { return request.ReportError("\"" + kPROTOCOL_VERSION_KEY + "\" must be a JSON object."); + } Json::Value majorValue = requestedProtocolVersion[kMAJOR_KEY]; - if (!majorValue.isInt()) + if (!majorValue.isInt()) { return request.ReportError("\"" + kMAJOR_KEY + "\" must be set and an integer."); + } Json::Value minorValue = requestedProtocolVersion[kMINOR_KEY]; - if (!minorValue.isNull() && !minorValue.isInt()) + if (!minorValue.isNull() && !minorValue.isInt()) { return request.ReportError("\"" + kMINOR_KEY + "\" must be unset or an integer."); + } const int major = majorValue.asInt(); const int minor = minorValue.isNull() ? -1 : minorValue.asInt(); - if (major < 0) + if (major < 0) { return request.ReportError("\"" + kMAJOR_KEY + "\" must be >= 0."); - if (!minorValue.isNull() && minor < 0) + } + if (!minorValue.isNull() && minor < 0) { return request.ReportError("\"" + kMINOR_KEY + "\" must be >= 0 when set."); + } this->Protocol = this->FindMatchingProtocol(this->SupportedProtocols, major, minor); @@ -284,12 +292,15 @@ cmServerProtocol* cmServer::FindMatchingProtocol( cmServerProtocol* bestMatch = nullptr; for (auto protocol : protocols) { auto version = protocol->ProtocolVersion(); - if (major != version.first) + if (major != version.first) { continue; - if (minor == version.second) + } + if (minor == version.second) { return protocol; - if (!bestMatch || bestMatch->ProtocolVersion().second < version.second) + } + if (!bestMatch || bestMatch->ProtocolVersion().second < version.second) { bestMatch = protocol; + } } return minor < 0 ? bestMatch : nullptr; } @@ -317,8 +328,9 @@ void cmServer::WriteMessage(const cmServerRequest& request, const std::string& message, const std::string& title) const { - if (message.empty()) + if (message.empty()) { return; + } Json::Value obj = Json::objectValue; obj[kTYPE_KEY] = kMESSAGE_TYPE; diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index 112cafd..0b3db9f 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -146,8 +146,9 @@ void cmServerConnection::ReadData(const std::string& data) } std::string line = this->RawReadBuffer.substr(0, needle); const auto ls = line.size(); - if (ls > 1 && line.at(ls - 1) == '\r') + if (ls > 1 && line.at(ls - 1) == '\r') { line.erase(ls - 1, 1); + } this->RawReadBuffer.erase(this->RawReadBuffer.begin(), this->RawReadBuffer.begin() + static_cast<long>(needle) + 1); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index e42b18a..755de0c 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -97,10 +97,10 @@ bool cmServerResponse::IsError() const std::string cmServerResponse::ErrorMessage() const { - if (this->m_Payload == PAYLOAD_ERROR) + if (this->m_Payload == PAYLOAD_ERROR) { return this->m_ErrorMessage; - else - return std::string(); + } + return std::string(); } Json::Value cmServerResponse::Data() const @@ -117,16 +117,18 @@ bool cmServerProtocol::Activate(cmServer* server, this->m_Server = server; this->m_CMakeInstance = std::make_unique<cmake>(); const bool result = this->DoActivate(request, errorMessage); - if (!result) + if (!result) { this->m_CMakeInstance = CM_NULLPTR; + } return result; } void cmServerProtocol::SendSignal(const std::string& name, const Json::Value& data) const { - if (this->m_Server) + if (this->m_Server) { this->m_Server->WriteSignal(name, data); + } } cmake* cmServerProtocol::CMakeInstance() const @@ -155,17 +157,19 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string extraGenerator = request.Data[kEXTRA_GENERATOR_KEY].asString(); if (buildDirectory.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kBUILD_DIRECTORY_KEY + "\" is missing."; + } return false; } cmake* cm = CMakeInstance(); if (cmSystemTools::PathExists(buildDirectory)) { if (!cmSystemTools::FileIsDirectory(buildDirectory)) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kBUILD_DIRECTORY_KEY + "\" exists but is not a directory."; + } return false; } @@ -177,18 +181,20 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, const std::string cachedGenerator = std::string(state->GetCacheEntryValue("CMAKE_GENERATOR")); if (cachedGenerator.empty() && generator.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" is required but unset."; + } return false; } if (generator.empty()) { generator = cachedGenerator; } if (generator != cachedGenerator) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" set but incompatible with configured generator."; + } return false; } @@ -197,9 +203,10 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string(state->GetCacheEntryValue("CMAKE_EXTRA_GENERATOR")); if (!cachedExtraGenerator.empty() && !extraGenerator.empty() && cachedExtraGenerator != extraGenerator) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kEXTRA_GENERATOR_KEY + "\" is set but incompatible with configured extra generator."; + } return false; } if (extraGenerator.empty()) { @@ -211,9 +218,10 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY")); if (!cachedSourceDirectory.empty() && !sourceDirectory.empty() && cachedSourceDirectory != sourceDirectory) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is set but incompatible with configured source directory."; + } return false; } if (sourceDirectory.empty()) { @@ -223,21 +231,24 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, } if (sourceDirectory.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is unset but required."; + } return false; } if (!cmSystemTools::FileIsDirectory(sourceDirectory)) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is not a directory."; + } return false; } if (generator.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" is unset but required."; + } return false; } @@ -247,10 +258,11 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName); if (!gg) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("Could not set up the requested combination of \"") + kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\""; + } return false; } |