[Cmake-commits] CMake branch, master, updated. v3.9.1-709-g671cc74
Kitware Robot
kwrobot at kitware.com
Fri Sep 1 10:35:06 EDT 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via 671cc7490ca1dd732cbb3671d4732eb1ee1e180e (commit)
via 900f75868ce41620947ab4ca376d77e12d32830f (commit)
via 4f68692807494e944702747af24d412a2b26825b (commit)
via b568a18997ebb9d54a64cf86fa6443be3dd3bf7e (commit)
via bd777178006c643bcab4bcbb1c5432f9306568ec (commit)
via 068cc545d905a5b0fd8caa09494c04346d0ca936 (commit)
via 0e4d503384a254c843a065c26f77bc19dfccff16 (commit)
via 124424e9974ade26521bf4751f3701c1e7d91c3d (commit)
via 693fa0a96e111270337eb76a4da1255774657e1a (commit)
via 882dcef8e02e432e6469b7fca38aff212d1541ab (commit)
via 7ef28843618519c222806a0df82ed8f87ad2ca0c (commit)
via dc7a18d82eb0013a2afbdea9ba5fec131fc3179f (commit)
via f8fd5a979cb4acd8a37632c29b453a426e798178 (commit)
via 6afc7f8828e5199395edfb10ac1a55891596907d (commit)
via 1a50cd8c683413154a700bf4ef17e621e8e89d7a (commit)
via 546a58746967d10996075ca47a7198c1c375fdb2 (commit)
via d8e03e9ba6f5ad948839ba9b291caa014813d9da (commit)
via 2f3a07a981edfbc325f19ea252003e9da59dbcf5 (commit)
via a46024be877e7705494d75e0dad6879c2a9a9707 (commit)
via a47a853376184031051ed744ed4718a69876002d (commit)
from 9a509099f77ed32a0845e4e3fad7b8f1eb9be10b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=671cc7490ca1dd732cbb3671d4732eb1ee1e180e
commit 671cc7490ca1dd732cbb3671d4732eb1ee1e180e
Merge: 900f758 0e4d503
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 1 14:34:07 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 1 10:34:16 2017 -0400
Merge topic 'server-refactor'
0e4d5033 server: Added thread check to protect writedata
124424e9 server: Protect several fields from potentially pointing to bad memory
693fa0a9 server: Added assert to monitor uv_run status
882dcef8 server: Made connections in a server have a mutex to avoid use after frees
7ef28843 server: Moved buffer formatting into bufferstrategy
dc7a18d8 server: test buffer parsing
f8fd5a97 server: Made stdio connection accept different types of streams
6afc7f88 server: Remove unused fields / functions
...
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1111
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=900f75868ce41620947ab4ca376d77e12d32830f
commit 900f75868ce41620947ab4ca376d77e12d32830f
Merge: 4f68692 d8e03e9
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 1 14:33:07 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 1 10:33:15 2017 -0400
Merge topic 'flang'
d8e03e9b FindOpenMP: Add Flang flag.
2f3a07a9 Flang: Add support for flang Fortran compiler
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1141
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4f68692807494e944702747af24d412a2b26825b
commit 4f68692807494e944702747af24d412a2b26825b
Merge: b568a18 a46024b
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 1 14:26:38 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 1 10:26:44 2017 -0400
Merge topic 'vs-std-cxx17-flag-map'
a46024be VS: Add v141 flag table entry for -std:c++17
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1221
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b568a18997ebb9d54a64cf86fa6443be3dd3bf7e
commit b568a18997ebb9d54a64cf86fa6443be3dd3bf7e
Merge: bd77717 a47a853
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 1 14:26:01 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 1 10:26:08 2017 -0400
Merge topic 'tll-global-unknown-lib'
a47a8533 target_link_libraries: Allow linking to UNKNOWN IMPORTED GLOBAL libs
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1220
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bd777178006c643bcab4bcbb1c5432f9306568ec
commit bd777178006c643bcab4bcbb1c5432f9306568ec
Merge: 9a50909 068cc54
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 1 14:25:04 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 1 10:25:08 2017 -0400
Merge topic 'fix-genex-SOURCES'
068cc545 Genex: Fix TARGET_PROPERTY value of SOURCES
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1218
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=068cc545d905a5b0fd8caa09494c04346d0ca936
commit 068cc545d905a5b0fd8caa09494c04346d0ca936
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 31 11:00:52 2017 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Sep 1 10:23:37 2017 -0400
Genex: Fix TARGET_PROPERTY value of SOURCES
Refactoring in commit v3.8.0-rc1~445^2~2 (cmTarget: Move sanity checks
and computed property access to callers, 2016-10-13) exposed a typo in
commit v3.8.0-rc1~445^2~3 (cmGeneratorTarget: Implement
cmTargetPropertyComputer interface, 2016-10-13). Together they broke
the `$<TARGET_PROPERTY:mytgt,SOURCES>` generator expression in the case
that the `SOURCES` target property is populated in part by the
`target_sources` command. Add the missing `;`-separator.
Fixes: #17243
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 329c7a9..c9924f6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -158,7 +158,7 @@ const char* cmGeneratorTarget::GetSourcesProperty() const
}
static std::string value;
value.clear();
- value = cmJoin(values, "");
+ value = cmJoin(values, ";");
return value.c_str();
}
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index 63cd2da..2486259 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -32,6 +32,7 @@ run_cmake(COMPILE_LANGUAGE-unknown-lang)
run_cmake(TARGET_FILE-recursion)
run_cmake(OUTPUT_NAME-recursion)
run_cmake(TARGET_PROPERTY-LOCATION)
+run_cmake(TARGET_PROPERTY-SOURCES)
run_cmake(LINK_ONLY-not-linking)
run_cmake(ImportedTarget-TARGET_BUNDLE_DIR)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
new file mode 100644
index 0000000..f1452b5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
@@ -0,0 +1,9 @@
+file(READ ${RunCMake_TEST_BINARY_DIR}/foo.txt foo_sources)
+
+# VS generators inject CMakeLists.txt as a source. Remove it.
+string(REGEX REPLACE ";[^;]*CMakeLists.txt$" "" foo_sources "${foo_sources}")
+
+set(foo_expected "empty.c;empty2.c;empty3.c")
+if(NOT foo_sources STREQUAL foo_expected)
+ set(RunCMake_TEST_FAILED "foo SOURCES was:\n [[${foo_sources}]]\nbut expected:\n [[${foo_expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
new file mode 100644
index 0000000..dee7ead
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0070 NEW)
+enable_language(C)
+add_library(foo empty.c empty2.c)
+target_sources(foo PRIVATE empty3.c)
+file(GENERATE OUTPUT foo.txt CONTENT "$<TARGET_PROPERTY:foo,SOURCES>")
diff --git a/Tests/RunCMake/GeneratorExpression/empty2.c b/Tests/RunCMake/GeneratorExpression/empty2.c
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/GeneratorExpression/empty3.c b/Tests/RunCMake/GeneratorExpression/empty3.c
new file mode 100644
index 0000000..e69de29
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e4d503384a254c843a065c26f77bc19dfccff16
commit 0e4d503384a254c843a065c26f77bc19dfccff16
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Sat Jul 22 09:29:18 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:46 2017 -0400
server: Added thread check to protect writedata
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
index c0d1b82..f482412 100644
--- a/Source/cmConnection.cxx
+++ b/Source/cmConnection.cxx
@@ -69,6 +69,12 @@ bool cmEventBasedConnection::IsOpen() const
void cmEventBasedConnection::WriteData(const std::string& _data)
{
+#ifndef NDEBUG
+ auto curr_thread_id = uv_thread_self();
+ assert(this->Server);
+ assert(uv_thread_equal(&curr_thread_id, &this->Server->ServeThreadId));
+#endif
+
auto data = _data;
assert(this->WriteStream);
if (BufferStrategy) {
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index b1b4020..30d0f51 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -436,6 +436,12 @@ bool cmServerBase::StartServeThread()
bool cmServerBase::Serve(std::string* errorMessage)
{
+#ifndef NDEBUG
+ uv_thread_t blank_thread_t = {};
+ assert(uv_thread_equal(&blank_thread_t, &ServeThreadId));
+ ServeThreadId = uv_thread_self();
+#endif
+
errorMessage->clear();
uv_signal_init(&Loop, &this->SIGINTHandler);
diff --git a/Source/cmServer.h b/Source/cmServer.h
index d8f73c1..15fd2ba 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -67,6 +67,15 @@ protected:
bool ServeThreadRunning = false;
uv_thread_t ServeThread;
uv_async_t ShutdownSignal;
+#ifndef NDEBUG
+public:
+ // When the server starts it will mark down it's current thread ID,
+ // which is useful in other contexts to just assert that operations
+ // are performed on that same thread.
+ uv_thread_t ServeThreadId = {};
+
+protected:
+#endif
uv_loop_t Loop;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=124424e9974ade26521bf4751f3701c1e7d91c3d
commit 124424e9974ade26521bf4751f3701c1e7d91c3d
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Thu Jul 20 21:18:41 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:46 2017 -0400
server: Protect several fields from potentially pointing to bad memory
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
index 89013dc..c0d1b82 100644
--- a/Source/cmConnection.cxx
+++ b/Source/cmConnection.cxx
@@ -118,7 +118,9 @@ void cmEventBasedConnection::OnDisconnect(int onerror)
{
(void)onerror;
this->OnConnectionShuttingDown();
- this->Server->OnDisconnect(this);
+ if (this->Server) {
+ this->Server->OnDisconnect(this);
+ }
}
cmConnection::~cmConnection()
@@ -127,6 +129,7 @@ cmConnection::~cmConnection()
bool cmConnection::OnConnectionShuttingDown()
{
+ this->Server = nullptr;
return true;
}
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index e686403..44af75f 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -53,6 +53,9 @@ void cmStdIoConnection::SetupStream(uv_stream_t*& stream, int file_id)
void cmStdIoConnection::SetServer(cmServerBase* s)
{
cmConnection::SetServer(s);
+ if (!s) {
+ return;
+ }
SetupStream(this->ReadStream, 0);
SetupStream(this->WriteStream, 1);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=693fa0a96e111270337eb76a4da1255774657e1a
commit 693fa0a96e111270337eb76a4da1255774657e1a
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Tue Aug 22 09:46:00 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:46 2017 -0400
server: Added assert to monitor uv_run status
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index c7f8704..b1b4020 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -16,6 +16,7 @@
#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <iostream>
#include <memory>
#include <utility>
@@ -411,7 +412,10 @@ static void __start_thread(void* arg)
{
auto server = reinterpret_cast<cmServerBase*>(arg);
std::string error;
- server->Serve(&error);
+ bool success = server->Serve(&error);
+ if (!success || error.empty() == false) {
+ std::cerr << "Error during serve: " << error << std::endl;
+ }
}
static void __shutdownThread(uv_async_t* arg)
@@ -457,8 +461,12 @@ bool cmServerBase::Serve(std::string* errorMessage)
}
if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ // It is important we don't ever let the event loop exit with open handles
+ // at best this is a memory leak, but it can also introduce race conditions
+ // which can hang the program.
+ assert(false && "Event loop stopped in unclean state.");
+
*errorMessage = "Internal Error: Event loop stopped in unclean state.";
- StartShutDown();
return false;
}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=882dcef8e02e432e6469b7fca38aff212d1541ab
commit 882dcef8e02e432e6469b7fca38aff212d1541ab
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Wed Jul 19 22:04:13 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:44 2017 -0400
server: Made connections in a server have a mutex to avoid use after frees
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 6a63797..c7f8704 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -244,9 +244,11 @@ cmFileMonitor* cmServer::FileMonitor() const
void cmServer::WriteJsonObject(const Json::Value& jsonValue,
const DebugInfo* debug) const
{
+ uv_rwlock_rdlock(&ConnectionsMutex);
for (auto& connection : this->Connections) {
WriteJsonObject(connection.get(), jsonValue, debug);
}
+ uv_rwlock_rdunlock(&ConnectionsMutex);
}
void cmServer::WriteJsonObject(cmConnection* connection,
@@ -443,10 +445,15 @@ bool cmServerBase::Serve(std::string* errorMessage)
OnServeStart();
- for (auto& connection : Connections) {
- if (!connection->OnServeStart(errorMessage)) {
- return false;
+ {
+ uv_rwlock_rdlock(&ConnectionsMutex);
+ for (auto& connection : Connections) {
+ if (!connection->OnServeStart(errorMessage)) {
+ uv_rwlock_rdunlock(&ConnectionsMutex);
+ return false;
+ }
}
+ uv_rwlock_rdunlock(&ConnectionsMutex);
}
if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
@@ -479,10 +486,14 @@ void cmServerBase::StartShutDown()
uv_signal_stop(&this->SIGHUPHandler);
}
- for (auto& connection : Connections) {
- connection->OnConnectionShuttingDown();
+ {
+ uv_rwlock_wrlock(&ConnectionsMutex);
+ for (auto& connection : Connections) {
+ connection->OnConnectionShuttingDown();
+ }
+ Connections.clear();
+ uv_rwlock_wrunlock(&ConnectionsMutex);
}
- Connections.clear();
uv_walk(&Loop, on_walk_to_shutdown, nullptr);
}
@@ -496,7 +507,12 @@ bool cmServerBase::OnSignal(int signum)
cmServerBase::cmServerBase(cmConnection* connection)
{
- uv_loop_init(&Loop);
+ auto err = uv_loop_init(&Loop);
+ (void)err;
+ assert(err == 0);
+
+ err = uv_rwlock_init(&ConnectionsMutex);
+ assert(err == 0);
AddNewConnection(connection);
}
@@ -510,11 +526,14 @@ cmServerBase::~cmServerBase()
}
uv_loop_close(&Loop);
+ uv_rwlock_destroy(&ConnectionsMutex);
}
void cmServerBase::AddNewConnection(cmConnection* ownedConnection)
{
+ uv_rwlock_wrlock(&ConnectionsMutex);
Connections.emplace_back(ownedConnection);
+ uv_rwlock_wrunlock(&ConnectionsMutex);
ownedConnection->SetServer(this);
}
@@ -528,9 +547,11 @@ void cmServerBase::OnDisconnect(cmConnection* pConnection)
auto pred = [pConnection](const std::unique_ptr<cmConnection>& m) {
return m.get() == pConnection;
};
+ uv_rwlock_wrlock(&ConnectionsMutex);
Connections.erase(
std::remove_if(Connections.begin(), Connections.end(), pred),
Connections.end());
+ uv_rwlock_wrunlock(&ConnectionsMutex);
if (Connections.empty()) {
StartShutDown();
}
diff --git a/Source/cmServer.h b/Source/cmServer.h
index cb7df10..d8f73c1 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -61,6 +61,7 @@ public:
void OnDisconnect(cmConnection* pConnection);
protected:
+ mutable uv_rwlock_t ConnectionsMutex;
std::vector<std::unique_ptr<cmConnection>> Connections;
bool ServeThreadRunning = false;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ef28843618519c222806a0df82ed8f87ad2ca0c
commit 7ef28843618519c222806a0df82ed8f87ad2ca0c
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Wed Jul 19 20:23:34 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:04 2017 -0400
server: Moved buffer formatting into bufferstrategy
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
index 6cf8e5b..89013dc 100644
--- a/Source/cmConnection.cxx
+++ b/Source/cmConnection.cxx
@@ -67,9 +67,13 @@ bool cmEventBasedConnection::IsOpen() const
return this->WriteStream != nullptr;
}
-void cmEventBasedConnection::WriteData(const std::string& data)
+void cmEventBasedConnection::WriteData(const std::string& _data)
{
+ auto data = _data;
assert(this->WriteStream);
+ if (BufferStrategy) {
+ data = BufferStrategy->BufferOutMessage(data);
+ }
auto ds = data.size();
diff --git a/Source/cmConnection.h b/Source/cmConnection.h
index b1b51fe..ddb7744 100644
--- a/Source/cmConnection.h
+++ b/Source/cmConnection.h
@@ -39,6 +39,17 @@ public:
virtual std::string BufferMessage(std::string& rawBuffer) = 0;
/***
+ * Called to properly buffer an outgoing message.
+ *
+ * @param rawBuffer Message to format in the correct way
+ *
+ * @return Formatted message
+ */
+ virtual std::string BufferOutMessage(const std::string& rawBuffer) const
+ {
+ return rawBuffer;
+ };
+ /***
* Resets the internal state of the buffering
*/
virtual void clear();
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 14e1fd1..6a63797 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -282,8 +282,7 @@ void cmServer::WriteJsonObject(cmConnection* connection,
}
}
- connection->WriteData(std::string("\n") + kSTART_MAGIC + std::string("\n") +
- result + kEND_MAGIC + std::string("\n"));
+ connection->WriteData(result);
}
cmServerProtocol* cmServer::FindMatchingProtocol(
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index dd14932..e686403 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -153,6 +153,13 @@ void cmConnectionBufferStrategy::clear()
{
}
+std::string cmServerBufferStrategy::BufferOutMessage(
+ const std::string& rawBuffer) const
+{
+ return std::string("\n") + kSTART_MAGIC + std::string("\n") + rawBuffer +
+ kEND_MAGIC + std::string("\n");
+}
+
std::string cmServerBufferStrategy::BufferMessage(std::string& RawReadBuffer)
{
for (;;) {
diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h
index 7b0c9b6..4ca908d 100644
--- a/Source/cmServerConnection.h
+++ b/Source/cmServerConnection.h
@@ -25,6 +25,7 @@ class cmServerBufferStrategy : public cmConnectionBufferStrategy
{
public:
std::string BufferMessage(std::string& rawBuffer) override;
+ std::string BufferOutMessage(const std::string& rawBuffer) const override;
private:
std::string RequestBuffer;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc7a18d82eb0013a2afbdea9ba5fec131fc3179f
commit dc7a18d82eb0013a2afbdea9ba5fec131fc3179f
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Sat Jul 22 17:23:11 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:04 2017 -0400
server: test buffer parsing
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9e632e..c578ec3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -753,6 +753,9 @@ add_subdirectory(Tests)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
+ IF(TARGET CMakeServerLibTests)
+ CMAKE_SET_TARGET_FOLDER(CMakeServerLibTests "Tests")
+ ENDIF()
endif()
if(TARGET documentation)
CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index f0e58ee..516bc89 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -146,6 +146,10 @@ if(BUILD_TESTING)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
add_subdirectory(CMakeLib)
+
+ if(CMake_TEST_SERVER_MODE)
+ add_subdirectory(CMakeServerLib)
+ endif()
endif()
add_subdirectory(CMakeOnly)
add_subdirectory(RunCMake)
diff --git a/Tests/CMakeServerLib/CMakeLists.txt b/Tests/CMakeServerLib/CMakeLists.txt
new file mode 100644
index 0000000..f5351fd
--- /dev/null
+++ b/Tests/CMakeServerLib/CMakeLists.txt
@@ -0,0 +1,17 @@
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMake_BINARY_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source
+ )
+
+set(CMakeServerLib_TESTS
+ testServerBuffering
+ )
+
+create_test_sourcelist(CMakeLib_TEST_SRCS CMakeServerLibTests.cxx ${CMakeServerLib_TESTS})
+add_executable(CMakeServerLibTests ${CMakeLib_TEST_SRCS})
+target_link_libraries(CMakeServerLibTests CMakeLib CMakeServerLib)
+
+foreach(test ${CMakeServerLib_TESTS})
+ add_test(CMakeServerLib.${test} CMakeServerLibTests ${test} ${${test}_ARGS})
+endforeach()
diff --git a/Tests/CMakeServerLib/testServerBuffering.cpp b/Tests/CMakeServerLib/testServerBuffering.cpp
new file mode 100644
index 0000000..97be891
--- /dev/null
+++ b/Tests/CMakeServerLib/testServerBuffering.cpp
@@ -0,0 +1,86 @@
+#include "cmConnection.h"
+#include "cmServerConnection.h"
+#include <iostream>
+#include <stddef.h>
+#include <string>
+#include <vector>
+
+void print_error(const std::vector<std::string>& input,
+ const std::vector<std::string>& output)
+{
+ std::cerr << "Responses don't equal input messages input." << std::endl;
+ std::cerr << "Responses: " << std::endl;
+
+ for (auto& msg : output) {
+ std::cerr << "'" << msg << "'" << std::endl;
+ }
+
+ std::cerr << "Input messages" << std::endl;
+ for (auto& msg : input) {
+ std::cerr << "'" << msg << "'" << std::endl;
+ }
+}
+
+std::string trim_newline(const std::string& _buffer)
+{
+ auto buffer = _buffer;
+ while (!buffer.empty() && (buffer.back() == '\n' || buffer.back() == '\r')) {
+ buffer.pop_back();
+ }
+ return buffer;
+}
+
+int testServerBuffering(int, char** const)
+{
+ std::vector<std::string> messages = {
+ "{ \"test\": 10}", "{ \"test\": { \"test2\": false} }",
+ "{ \"test\": [1, 2, 3] }",
+ "{ \"a\": { \"1\": {}, \n\n\n \"2\":[] \t\t\t\t}}"
+ };
+
+ std::string fullMessage;
+ for (auto& msg : messages) {
+ fullMessage += "[== \"CMake Server\" ==[\n";
+ fullMessage += msg;
+ fullMessage += "\n]== \"CMake Server\" ==]\n";
+ }
+
+ // The buffering strategy should cope with any fragmentation, including
+ // just getting the characters one at a time.
+ auto bufferingStrategy =
+ std::unique_ptr<cmConnectionBufferStrategy>(new cmServerBufferStrategy);
+ std::vector<std::string> response;
+ std::string rawBuffer;
+ for (size_t i = 0; i < fullMessage.size(); i++) {
+ rawBuffer += fullMessage[i];
+ std::string packet = bufferingStrategy->BufferMessage(rawBuffer);
+ do {
+ if (!packet.empty() && packet != "\r\n") {
+ response.push_back(trim_newline(packet));
+ }
+ packet = bufferingStrategy->BufferMessage(rawBuffer);
+ } while (!packet.empty());
+ }
+
+ if (response != messages) {
+ print_error(messages, response);
+ return 1;
+ }
+
+ // We should also be able to deal with getting a bunch at once
+ response.clear();
+ std::string packet = bufferingStrategy->BufferMessage(fullMessage);
+ do {
+ if (!packet.empty() && packet != "\r\n") {
+ response.push_back(trim_newline(packet));
+ }
+ packet = bufferingStrategy->BufferMessage(fullMessage);
+ } while (!packet.empty());
+
+ if (response != messages) {
+ print_error(messages, response);
+ return 1;
+ }
+
+ return 0;
+}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8fd5a979cb4acd8a37632c29b453a426e798178
commit f8fd5a979cb4acd8a37632c29b453a426e798178
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Fri Jul 21 09:35:41 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:04 2017 -0400
server: Made stdio connection accept different types of streams
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
index bc29e41..6cf8e5b 100644
--- a/Source/cmConnection.cxx
+++ b/Source/cmConnection.cxx
@@ -144,9 +144,12 @@ bool cmConnection::OnServeStart(std::string* errString)
bool cmEventBasedConnection::OnConnectionShuttingDown()
{
- this->WriteStream->data = nullptr;
- this->ReadStream->data = nullptr;
-
+ if (this->WriteStream) {
+ this->WriteStream->data = nullptr;
+ }
+ if (this->ReadStream) {
+ this->ReadStream->data = nullptr;
+ }
this->ReadStream = nullptr;
this->WriteStream = nullptr;
return true;
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index d6bf1a8..dd14932 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -2,76 +2,136 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServerConnection.h"
+#include "cmConfigure.h"
#include "cmServer.h"
#include "cmServerDictionary.h"
+#ifdef _WIN32
+#include "io.h"
+#else
+#include <unistd.h>
+#endif
+#include <cassert>
cmStdIoConnection::cmStdIoConnection(
cmConnectionBufferStrategy* bufferStrategy)
: cmEventBasedConnection(bufferStrategy)
- , Input()
- , Output()
{
}
+void cmStdIoConnection::SetupStream(uv_stream_t*& stream, int file_id)
+{
+ assert(stream == nullptr);
+ switch (uv_guess_handle(file_id)) {
+ case UV_TTY: {
+ auto tty = new uv_tty_t();
+ uv_tty_init(this->Server->GetLoop(), tty, file_id, file_id == 0);
+ uv_tty_set_mode(tty, UV_TTY_MODE_NORMAL);
+ stream = reinterpret_cast<uv_stream_t*>(tty);
+ break;
+ }
+ case UV_FILE:
+ if (file_id == 0) {
+ return;
+ }
+ // Intentional fallthrough; stdin can _not_ be treated as a named
+ // pipe, however stdout can be.
+ CM_FALLTHROUGH;
+ case UV_NAMED_PIPE: {
+ auto pipe = new uv_pipe_t();
+ uv_pipe_init(this->Server->GetLoop(), pipe, 0);
+ uv_pipe_open(pipe, file_id);
+ stream = reinterpret_cast<uv_stream_t*>(pipe);
+ break;
+ }
+ default:
+ assert(false && "Unable to determine stream type");
+ return;
+ }
+ stream->data = static_cast<cmEventBasedConnection*>(this);
+}
+
void cmStdIoConnection::SetServer(cmServerBase* s)
{
cmConnection::SetServer(s);
- if (uv_guess_handle(1) == UV_TTY) {
- usesTty = true;
-
- this->Input.tty = new uv_tty_t();
- uv_tty_init(this->Server->GetLoop(), this->Input.tty, 0, 1);
- uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL);
- this->Input.tty->data = static_cast<cmEventBasedConnection*>(this);
- this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty);
-
- this->Output.tty = new uv_tty_t();
- uv_tty_init(this->Server->GetLoop(), this->Output.tty, 1, 0);
- uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL);
- this->Output.tty->data = static_cast<cmEventBasedConnection*>(this);
- this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty);
- } else {
- usesTty = false;
-
- this->Input.pipe = new uv_pipe_t();
- uv_pipe_init(this->Server->GetLoop(), this->Input.pipe, 0);
- uv_pipe_open(this->Input.pipe, 0);
- this->Input.pipe->data = static_cast<cmEventBasedConnection*>(this);
- this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe);
-
- this->Output.pipe = new uv_pipe_t();
- uv_pipe_init(this->Server->GetLoop(), this->Output.pipe, 0);
- uv_pipe_open(this->Output.pipe, 1);
- this->Output.pipe->data = static_cast<cmEventBasedConnection*>(this);
- this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe);
+ SetupStream(this->ReadStream, 0);
+ SetupStream(this->WriteStream, 1);
+}
+
+void shutdown_connection(uv_prepare_t* prepare)
+{
+ cmStdIoConnection* connection =
+ reinterpret_cast<cmStdIoConnection*>(prepare->data);
+
+ if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(prepare))) {
+ uv_close(reinterpret_cast<uv_handle_t*>(prepare),
+ &cmEventBasedConnection::on_close_delete<uv_prepare_t>);
}
+ connection->OnDisconnect(0);
}
bool cmStdIoConnection::OnServeStart(std::string* pString)
{
- uv_read_start(this->ReadStream, on_alloc_buffer, on_read);
Server->OnConnected(this);
+ if (this->ReadStream) {
+ uv_read_start(this->ReadStream, on_alloc_buffer, on_read);
+ } else if (uv_guess_handle(0) == UV_FILE) {
+ char buffer[1024];
+ while (auto len = read(0, buffer, sizeof(buffer))) {
+ ReadData(std::string(buffer, buffer + len));
+ }
+
+ // We can't start the disconnect from here, add a prepare hook to do that
+ // for us
+ auto prepare = new uv_prepare_t();
+ prepare->data = this;
+ uv_prepare_init(Server->GetLoop(), prepare);
+ uv_prepare_start(prepare, shutdown_connection);
+ }
return cmConnection::OnServeStart(pString);
}
-bool cmStdIoConnection::OnConnectionShuttingDown()
+void cmStdIoConnection::ShutdownStream(uv_stream_t*& stream)
{
- cmEventBasedConnection::OnConnectionShuttingDown();
+ if (!stream) {
+ return;
+ }
+ switch (stream->type) {
+ case UV_TTY: {
+ assert(!uv_is_closing(reinterpret_cast<uv_handle_t*>(stream)));
+ if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(stream))) {
+ uv_close(reinterpret_cast<uv_handle_t*>(stream),
+ &on_close_delete<uv_tty_t>);
+ }
+ break;
+ }
+ case UV_FILE:
+ case UV_NAMED_PIPE: {
+ assert(!uv_is_closing(reinterpret_cast<uv_handle_t*>(stream)));
+ if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(stream))) {
+ uv_close(reinterpret_cast<uv_handle_t*>(stream),
+ &on_close_delete<uv_pipe_t>);
+ }
+ break;
+ }
+ default:
+ assert(false && "Unable to determine stream type");
+ }
- if (usesTty) {
- uv_read_stop(reinterpret_cast<uv_stream_t*>(this->Input.tty));
- uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty),
- &on_close_delete<uv_tty_t>);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty),
- &on_close_delete<uv_tty_t>);
- } else {
- uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe),
- &on_close_delete<uv_pipe_t>);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe),
- &on_close_delete<uv_pipe_t>);
+ stream = nullptr;
+}
+
+bool cmStdIoConnection::OnConnectionShuttingDown()
+{
+ if (ReadStream) {
+ uv_read_stop(ReadStream);
}
+ ShutdownStream(ReadStream);
+ ShutdownStream(WriteStream);
+
+ cmEventBasedConnection::OnConnectionShuttingDown();
+
return true;
}
diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h
index df404ce..7b0c9b6 100644
--- a/Source/cmServerConnection.h
+++ b/Source/cmServerConnection.h
@@ -45,16 +45,8 @@ public:
bool OnServeStart(std::string* pString) override;
private:
- typedef union
- {
- uv_tty_t* tty;
- uv_pipe_t* pipe;
- } InOutUnion;
-
- bool usesTty = false;
-
- InOutUnion Input;
- InOutUnion Output;
+ void SetupStream(uv_stream_t*& stream, int file_id);
+ void ShutdownStream(uv_stream_t*& stream);
};
/***
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6afc7f8828e5199395edfb10ac1a55891596907d
commit 6afc7f8828e5199395edfb10ac1a55891596907d
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Sun Jul 23 12:25:05 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:03 2017 -0400
server: Remove unused fields / functions
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 2638ec2..14e1fd1 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -464,10 +464,6 @@ void cmServerBase::OnConnected(cmConnection*)
{
}
-void cmServerBase::OnDisconnect()
-{
-}
-
void cmServerBase::OnServeStart()
{
}
diff --git a/Source/cmServer.h b/Source/cmServer.h
index 93ac69e..cb7df10 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -37,13 +37,12 @@ public:
* This should almost always be called by the given connections
* directly.
*
- * @param connection The connectiont the request was received on
+ * @param connection The connection the request was received on
* @param request The actual request
*/
virtual void ProcessRequest(cmConnection* connection,
const std::string& request) = 0;
virtual void OnConnected(cmConnection* connection);
- virtual void OnDisconnect();
/***
* Start a dedicated thread. If this is used to start the server, it will
@@ -141,22 +140,6 @@ private:
cmServerProtocol* Protocol = nullptr;
std::vector<cmServerProtocol*> SupportedProtocols;
- std::string DataBuffer;
- std::string JsonData;
-
- typedef union
- {
- uv_tty_t tty;
- uv_pipe_t pipe;
- } InOutUnion;
-
- InOutUnion Input;
- InOutUnion Output;
- uv_stream_t* InputStream = nullptr;
- uv_stream_t* OutputStream = nullptr;
-
- mutable bool Writing = false;
-
friend class cmServerProtocol;
friend class cmServerRequest;
};
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a50cd8c683413154a700bf4ef17e621e8e89d7a
commit 1a50cd8c683413154a700bf4ef17e621e8e89d7a
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Sun Jul 23 11:54:42 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:03 2017 -0400
server: Fixed minor memory leaks
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index f14e755..2638ec2 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -57,10 +57,6 @@ cmServer::cmServer(cmConnection* conn, bool supportExperimental)
cmServer::~cmServer()
{
- if (!this->Protocol) { // Server was never fully started!
- return;
- }
-
for (cmServerProtocol* p : this->SupportedProtocols) {
delete p;
}
@@ -110,6 +106,7 @@ void cmServer::ProcessRequest(cmConnection* connection,
void cmServer::RegisterProtocol(cmServerProtocol* protocol)
{
if (protocol->IsExperimental() && !this->SupportExperimental) {
+ delete protocol;
return;
}
auto version = protocol->ProtocolVersion();
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=546a58746967d10996075ca47a7198c1c375fdb2
commit 546a58746967d10996075ca47a7198c1c375fdb2
Author: Justin Berger <j.david.berger at gmail.com>
AuthorDate: Wed Jul 19 12:47:01 2017 -0600
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:35:03 2017 -0400
server: Fixed mismatched new/delete; added proper shutdown procedure
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
index f3fc1ef..bc29e41 100644
--- a/Source/cmConnection.cxx
+++ b/Source/cmConnection.cxx
@@ -38,11 +38,6 @@ void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread,
delete[](buf->base);
}
-void cmEventBasedConnection::on_close_delete(uv_handle_t* handle)
-{
- delete handle;
-}
-
void cmEventBasedConnection::on_close(uv_handle_t* /*handle*/)
{
}
diff --git a/Source/cmConnection.h b/Source/cmConnection.h
index f9d50de..b1b51fe 100644
--- a/Source/cmConnection.h
+++ b/Source/cmConnection.h
@@ -100,7 +100,12 @@ public:
uv_stream_t* WriteStream = nullptr;
static void on_close(uv_handle_t* handle);
- static void on_close_delete(uv_handle_t* handle);
+
+ template <typename T>
+ static void on_close_delete(uv_handle_t* handle)
+ {
+ delete reinterpret_cast<T*>(handle);
+ }
protected:
std::string RawReadBuffer;
diff --git a/Source/cmPipeConnection.cxx b/Source/cmPipeConnection.cxx
index b18a1d6..9e565f6 100644
--- a/Source/cmPipeConnection.cxx
+++ b/Source/cmPipeConnection.cxx
@@ -19,7 +19,8 @@ void cmPipeConnection::Connect(uv_stream_t* server)
uv_pipe_init(this->Server->GetLoop(), rejectPipe, 0);
uv_accept(server, reinterpret_cast<uv_stream_t*>(rejectPipe));
- uv_close(reinterpret_cast<uv_handle_t*>(rejectPipe), &on_close_delete);
+ uv_close(reinterpret_cast<uv_handle_t*>(rejectPipe),
+ &on_close_delete<uv_pipe_t>);
return;
}
@@ -28,7 +29,8 @@ void cmPipeConnection::Connect(uv_stream_t* server)
this->ClientPipe->data = static_cast<cmEventBasedConnection*>(this);
auto client = reinterpret_cast<uv_stream_t*>(this->ClientPipe);
if (uv_accept(server, client) != 0) {
- uv_close(reinterpret_cast<uv_handle_t*>(client), &on_close_delete);
+ uv_close(reinterpret_cast<uv_handle_t*>(client),
+ &on_close_delete<uv_pipe_t>);
this->ClientPipe = nullptr;
return;
}
@@ -65,15 +67,16 @@ bool cmPipeConnection::OnConnectionShuttingDown()
{
if (this->ClientPipe) {
uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe),
- &on_close_delete);
+ &on_close_delete<uv_pipe_t>);
this->WriteStream->data = nullptr;
}
- uv_close(reinterpret_cast<uv_handle_t*>(this->ServerPipe), &on_close_delete);
+ uv_close(reinterpret_cast<uv_handle_t*>(this->ServerPipe),
+ &on_close_delete<uv_pipe_t>);
this->ClientPipe = nullptr;
this->ServerPipe = nullptr;
this->WriteStream = nullptr;
this->ReadStream = nullptr;
- return cmConnection::OnConnectionShuttingDown();
+ return cmEventBasedConnection::OnConnectionShuttingDown();
}
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index c3e6811..f14e755 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -416,9 +416,18 @@ static void __start_thread(void* arg)
server->Serve(&error);
}
+static void __shutdownThread(uv_async_t* arg)
+{
+ auto server = reinterpret_cast<cmServerBase*>(arg->data);
+ on_walk_to_shutdown(reinterpret_cast<uv_handle_t*>(arg), nullptr);
+ server->StartShutDown();
+}
+
bool cmServerBase::StartServeThread()
{
ServeThreadRunning = true;
+ uv_async_init(&Loop, &this->ShutdownSignal, __shutdownThread);
+ this->ShutdownSignal.data = this;
uv_thread_create(&ServeThread, __start_thread, this);
return true;
}
@@ -464,8 +473,6 @@ void cmServerBase::OnDisconnect()
void cmServerBase::OnServeStart()
{
- uv_signal_start(&this->SIGINTHandler, &on_signal, SIGINT);
- uv_signal_start(&this->SIGHUPHandler, &on_signal, SIGHUP);
}
void cmServerBase::StartShutDown()
@@ -485,11 +492,7 @@ void cmServerBase::StartShutDown()
}
Connections.clear();
- uv_stop(&Loop);
-
uv_walk(&Loop, on_walk_to_shutdown, nullptr);
-
- uv_run(&Loop, UV_RUN_DEFAULT);
}
bool cmServerBase::OnSignal(int signum)
@@ -503,12 +506,6 @@ cmServerBase::cmServerBase(cmConnection* connection)
{
uv_loop_init(&Loop);
- uv_signal_init(&Loop, &this->SIGINTHandler);
- uv_signal_init(&Loop, &this->SIGHUPHandler);
-
- this->SIGINTHandler.data = this;
- this->SIGHUPHandler.data = this;
-
AddNewConnection(connection);
}
@@ -516,7 +513,7 @@ cmServerBase::~cmServerBase()
{
if (ServeThreadRunning) {
- StartShutDown();
+ uv_async_send(&this->ShutdownSignal);
uv_thread_join(&ServeThread);
}
diff --git a/Source/cmServer.h b/Source/cmServer.h
index 9d8473d..93ac69e 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -66,6 +66,7 @@ protected:
bool ServeThreadRunning = false;
uv_thread_t ServeThread;
+ uv_async_t ShutdownSignal;
uv_loop_t Loop;
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index 4891131..d6bf1a8 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -62,14 +62,14 @@ bool cmStdIoConnection::OnConnectionShuttingDown()
if (usesTty) {
uv_read_stop(reinterpret_cast<uv_stream_t*>(this->Input.tty));
uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty),
- &on_close_delete);
+ &on_close_delete<uv_tty_t>);
uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty),
- &on_close_delete);
+ &on_close_delete<uv_tty_t>);
} else {
uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe),
- &on_close_delete);
+ &on_close_delete<uv_pipe_t>);
uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe),
- &on_close_delete);
+ &on_close_delete<uv_pipe_t>);
}
return true;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d8e03e9ba6f5ad948839ba9b291caa014813d9da
commit d8e03e9ba6f5ad948839ba9b291caa014813d9da
Author: Tin Huynh <ahuynh at nvidia.com>
AuthorDate: Thu Aug 31 09:50:31 2017 -0700
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:27:18 2017 -0400
FindOpenMP: Add Flang flag.
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index 1093be0..7566e4a 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -95,6 +95,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
set(OMP_FLAG_NAG "-openmp")
set(OMP_FLAG_Absoft "-openmp")
set(OMP_FLAG_PGI "-mp")
+ set(OMP_FLAG_Flang "-fopenmp")
set(OMP_FLAG_SunPro "-xopenmp")
set(OMP_FLAG_XL "-qsmp=omp")
# Cray compiles with OpenMP automatically
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f3a07a981edfbc325f19ea252003e9da59dbcf5
commit 2f3a07a981edfbc325f19ea252003e9da59dbcf5
Author: Tin Huynh <ahuynh at nvidia.com>
AuthorDate: Fri Aug 4 17:50:09 2017 -0700
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 15:24:59 2017 -0400
Flang: Add support for flang Fortran compiler
flang is a Fortran compiler built on top of clang [1]. Because flang
shares a lot of commonalities with clang, the flang module piggybacks
off the clang module and overrides certain options.
Add flang to Fortran compiler auto find list.
Update flang preprocessor macros to differentiate from PGI.
Add Flang-FindBinUtils.
[1] https://github.com/flang-compiler/flang
diff --git a/Help/release/dev/flang.rst b/Help/release/dev/flang.rst
new file mode 100644
index 0000000..9849f14
--- /dev/null
+++ b/Help/release/dev/flang.rst
@@ -0,0 +1,6 @@
+flang
+-----
+
+* The `flang`_ Fortran compiler is now supported, with compiler id ``Flang``.
+
+.. _`flang`: https://github.com/flang-compiler/flang
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index 5204044..2264269 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -27,6 +27,7 @@ include:
NVIDIA = NVIDIA CUDA Compiler (nvidia.com)
OpenWatcom = Open Watcom (openwatcom.org)
PGI = The Portland Group (pgroup.com)
+ Flang = Flang Fortran Compiler
PathScale = PathScale (pathscale.com)
SDCC = Small Device C Compiler (sdcc.sourceforge.net)
SunPro = Oracle Solaris Studio (oracle.com)
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 5559640..2549c22 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -52,6 +52,7 @@ else()
# frt: Fujitsu F77 compiler
# pathf90/pathf95/pathf2003: PathScale Fortran compiler
# pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers
+ # flang: Flang Fortran compiler
# xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
# lf95: Lahey-Fujitsu F95 compiler
# fl32: Microsoft Fortran 77 "PowerStation" compiler
@@ -68,7 +69,7 @@ else()
set(CMAKE_Fortran_COMPILER_LIST
ftn
ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95
- fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77
+ fort flang gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77
frt pgf77 xlf fl32 af77 g77 f77 nag
)
@@ -77,10 +78,11 @@ else()
set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc)
set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77)
set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77)
+ set(_Fortran_COMPILER_NAMES_Flang flang)
set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90)
set(_Fortran_COMPILER_NAMES_XL xlf)
set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf)
- set(_Fortran_COMPILER_NAMES_NAG nagfor)
+ set(_Fortran_COMPILER_NAMES_NAG nagfor)
endif()
_cmake_find_compiler(Fortran)
diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in
index 26b2ed6..49789f1 100644
--- a/Modules/CMakeFortranCompilerId.F.in
+++ b/Modules/CMakeFortranCompilerId.F.in
@@ -90,6 +90,13 @@
# if defined(__PGIC_PATCHLEVEL__)
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
# endif
+#elif defined(__FLANG)
+ PRINT *, 'INFO:compiler[Flang]'
+# define COMPILER_VERSION_MAJOR DEC(__FLANG_MAJOR__)
+# define COMPILER_VERSION_MINOR DEC(__FLANG_MINOR__)
+# if defined(__FLANG_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__FLANG_PATCHLEVEL__)
+# endif
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
PRINT *, 'INFO:compiler[MIPSpro]'
# if 0
diff --git a/Modules/Compiler/Flang-FindBinUtils.cmake b/Modules/Compiler/Flang-FindBinUtils.cmake
new file mode 100644
index 0000000..e721c87
--- /dev/null
+++ b/Modules/Compiler/Flang-FindBinUtils.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-FindBinUtils)
diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake
new file mode 100644
index 0000000..f17dec7
--- /dev/null
+++ b/Modules/Compiler/Flang-Fortran.cmake
@@ -0,0 +1,12 @@
+include(Compiler/Clang)
+__compiler_clang(Fortran)
+
+set(CMAKE_Fortran_PREPROCESS_SOURCE
+ "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")
+
+set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -fbounds-check")
+
+set(CMAKE_Fortran_MODDIR_FLAG "-J")
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a46024be877e7705494d75e0dad6879c2a9a9707
commit a46024be877e7705494d75e0dad6879c2a9a9707
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 31 14:58:44 2017 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 14:59:34 2017 -0400
VS: Add v141 flag table entry for -std:c++17
Fixes: #17171
diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h
index e8b8f5c..c780d46 100644
--- a/Source/cmVS141CLFlagTable.h
+++ b/Source/cmVS141CLFlagTable.h
@@ -79,6 +79,7 @@ static cmVS7FlagTable cmVS141CLFlagTable[] = {
{ "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
{ "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
+ { "LanguageStandard", "std:c++17", "ISO C++17 Standard", "stdcpp17", 0 },
{ "LanguageStandard", "std:c++14", "ISO C++14 Standard", "stdcpp14", 0 },
{ "LanguageStandard", "std:c++latest", "ISO C++ Latest Draft Standard",
"stdcpplatest", 0 },
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a47a853376184031051ed744ed4718a69876002d
commit a47a853376184031051ed744ed4718a69876002d
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 31 13:04:34 2017 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 31 13:10:26 2017 -0400
target_link_libraries: Allow linking to UNKNOWN IMPORTED GLOBAL libs
This combination was accidentally rejected. Allow it and add a test.
Fixes: #17245
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index bfae53c..d146640 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -366,6 +366,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
(tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::UNKNOWN_LIBRARY) &&
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
!tgt->IsExecutableWithExports()) {
std::ostringstream e;
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
index 1466fbf..b1c9435 100644
--- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -10,3 +10,4 @@ run_cmake(SubDirTarget)
run_cmake(SharedDepNotTarget)
run_cmake(StaticPrivateDepNotExported)
run_cmake(StaticPrivateDepNotTarget)
+run_cmake(UNKNOWN-IMPORTED-GLOBAL)
diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake
new file mode 100644
index 0000000..f52fa30
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
+add_library(mylib empty.c)
+target_link_libraries(mylib UnknownImportedGlobal)
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 3 +
Help/release/dev/flang.rst | 6 +
Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 +
Modules/CMakeDetermineFortranCompiler.cmake | 6 +-
Modules/CMakeFortranCompilerId.F.in | 7 +
Modules/Compiler/Flang-FindBinUtils.cmake | 1 +
Modules/Compiler/Flang-Fortran.cmake | 12 ++
Modules/FindOpenMP.cmake | 1 +
Source/cmConnection.cxx | 31 ++--
Source/cmConnection.h | 18 ++-
Source/cmGeneratorTarget.cxx | 2 +-
Source/cmPipeConnection.cxx | 13 +-
Source/cmServer.cxx | 86 +++++++----
Source/cmServer.h | 30 ++--
Source/cmServerConnection.cxx | 158 ++++++++++++++------
Source/cmServerConnection.h | 13 +-
Source/cmTargetLinkLibrariesCommand.cxx | 1 +
Source/cmVS141CLFlagTable.h | 1 +
Tests/CMakeLists.txt | 4 +
Tests/CMakeServerLib/CMakeLists.txt | 17 +++
Tests/CMakeServerLib/testServerBuffering.cpp | 86 +++++++++++
.../GeneratorExpression/RunCMakeTest.cmake | 1 +
.../TARGET_PROPERTY-SOURCES-check.cmake | 9 ++
.../TARGET_PROPERTY-SOURCES.cmake | 5 +
.../RunCMake/GeneratorExpression/empty2.c | 0
.../RunCMake/GeneratorExpression/empty3.c | 0
.../target_link_libraries/RunCMakeTest.cmake | 1 +
.../UNKNOWN-IMPORTED-GLOBAL.cmake | 4 +
28 files changed, 395 insertions(+), 122 deletions(-)
create mode 100644 Help/release/dev/flang.rst
create mode 100644 Modules/Compiler/Flang-FindBinUtils.cmake
create mode 100644 Modules/Compiler/Flang-Fortran.cmake
create mode 100644 Tests/CMakeServerLib/CMakeLists.txt
create mode 100644 Tests/CMakeServerLib/testServerBuffering.cpp
create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/GeneratorExpression/empty2.c (100%)
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/GeneratorExpression/empty3.c (100%)
create mode 100644 Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list