From 7d1608b08d8e7b48e92e9acedbb8c9923d5a9cbb Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Tue, 24 Sep 2024 11:27:03 +0200 Subject: [PATCH 1/6] only link FS libs when needed (old compilers) Signed-off-by: Rainer Schoenberger --- src/libLocalDescriptorCache/CMakeLists.txt | 7 +++++-- src/utils/CMakeLists.txt | 13 ++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libLocalDescriptorCache/CMakeLists.txt b/src/libLocalDescriptorCache/CMakeLists.txt index 1ed82e9..09e71c6 100644 --- a/src/libLocalDescriptorCache/CMakeLists.txt +++ b/src/libLocalDescriptorCache/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +include(filesystem) set(TARGET_NAME "DescDbProxy") set(TARGET_SRC @@ -32,6 +32,9 @@ target_link_libraries(${TARGET_NAME} version reflection cli - stdc++fs ) +# Link FS library if required: +if (FILESYSTEM_LIB) + target_link_libraries(${TARGET_NAME} PRIVATE ${MANUAL_FILESYSTEM_LIB}) +endif() \ No newline at end of file diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 1da3d6e..2122fdd 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +include(filesystem) + set(TARGET_NAME "gwhisperUtils") set(TARGET_SRC ./gwhisperUtils.cpp @@ -21,11 +23,8 @@ target_include_directories(${TARGET_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/.. ) - - -target_link_libraries(${TARGET_NAME} - stdc++fs - ) - - +# Link FS library if required: +if (FILESYSTEM_LIB) + target_link_libraries(${TARGET_NAME} PRIVATE ${MANUAL_FILESYSTEM_LIB}) +endif() \ No newline at end of file From 1b4774b68a6500bf3087f5e334d317e3a2b01320 Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Tue, 24 Sep 2024 11:34:20 +0200 Subject: [PATCH 2/6] do not use `--no-as-needed,--whole-archive` on MacOS Signed-off-by: Rainer Schoenberger --- cmake/filesystem.cmake | 14 ++++++++++++++ tests/testServer/CMakeLists.txt | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 cmake/filesystem.cmake diff --git a/cmake/filesystem.cmake b/cmake/filesystem.cmake new file mode 100644 index 0000000..39067c5 --- /dev/null +++ b/cmake/filesystem.cmake @@ -0,0 +1,14 @@ +set(FILESYSTEM_LIB "") + +# Check for the the need to link FS library +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) + message(STATUS "Using GCC version less than 9.1, linking with -lstdc++fs") + set(FILESYSTEM_LIB stdc++fs) + endif() +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + message(STATUS "Using Clang version less than 9.0, linking with -lc++fs") + set(FILESYSTEM_LIB c++fs) + endif() +endif() \ No newline at end of file diff --git a/tests/testServer/CMakeLists.txt b/tests/testServer/CMakeLists.txt index df7c088..d87b712 100644 --- a/tests/testServer/CMakeLists.txt +++ b/tests/testServer/CMakeLists.txt @@ -53,6 +53,29 @@ target_link_libraries(${TARGET_NAME} protoDoc gwhisperUtils ) + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + target_link_libraries(${TARGET_NAME} + PUBLIC + ${TARGET_NAME}_protobuf + ${LIB_GRPC++_REFLECTION} + ) +else() + target_link_libraries(${TARGET_NAME} + PUBLIC + ${TARGET_NAME}_protobuf + # on linux we need to link the whole reflection lib, even though the compiler might + # think we do not use any symbols. (This is because gRPC dynamically + # checks if reflection is linked and has no hard dependency on any symbols + # there) + # This is done with --no-as-needed in case we link dynamically and + # --whole-archive in case we link statically. + -Wl,--push-state,--no-as-needed,--whole-archive ${LIB_GRPC++_REFLECTION} -Wl,--pop-state + ) + +endif() + + add_custom_command( OUTPUT cert-key-pair/ca.crt cert-key-pair/ca.key cert-key-pair/ca.srl cert-key-pair/client_crt.pem cert-key-pair/client_csr.pem cert-key-pair/client_key.pem cert-key-pair/server_crt.pem cert-key-pair/server_csr.pem cert-key-pair/server_key.pem From 3ee6a3b86ceab69d74fed5968b1fd5eda064c67e Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Wed, 25 Sep 2024 13:09:51 +0200 Subject: [PATCH 3/6] fix double linking of reflection Signed-off-by: Rainer Schoenberger --- tests/testServer/CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/testServer/CMakeLists.txt b/tests/testServer/CMakeLists.txt index d87b712..3f73bc7 100644 --- a/tests/testServer/CMakeLists.txt +++ b/tests/testServer/CMakeLists.txt @@ -41,15 +41,6 @@ MakeKeyCert target_link_libraries(${TARGET_NAME} PUBLIC ${TARGET_NAME}_protobuf - - # we need to link the whole reflection lib, even though the compiler might - # think we do not use any symbols. (This is because gRPC dynamically - # checks if reflection is linked and has no hard dependency on any symbols - # there) - # This is done with --no-as-needed in case we link dynamically and - # --whole-archive in case we link statically. - -Wl,--push-state,--no-as-needed,--whole-archive ${LIB_GRPC++_REFLECTION} -Wl,--pop-state - protoDoc gwhisperUtils ) From eea48fec3ac4e331aafe440341e09c72e655d365 Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Wed, 25 Sep 2024 13:16:51 +0200 Subject: [PATCH 4/6] CI now tests against macos-latest too Signed-off-by: Rainer Schoenberger --- .github/workflows/cmake.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index aac36a2..53206e1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -16,7 +16,11 @@ jobs: # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v2 From ed2f430fd470e4547c1dbf29b14e80d03a6479f8 Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Wed, 25 Sep 2024 13:20:38 +0200 Subject: [PATCH 5/6] update readme to support MacOS Signed-off-by: Rainer Schoenberger --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2742b2a..c334a8d 100644 --- a/README.md +++ b/README.md @@ -155,16 +155,20 @@ What is working: - Calling RPCs (unary + streaming) - Input and output of all protocol buffer types - Security: SSL is supported +- Performance: Caching of reflection queries Some notable things which are not yet working: - Using Proto files instead of Reflection API (currently gWhisper only works with servers which have reflection enabled) -- Performance: Caching of reflection queries ## Supported platforms -Development and testing is done on Fedora Linux 33 and Arch Linux. -We expect no bigger problems with building and running this software on different linux distributions. +We support the following platforms: +- Linux +- MacOS + +Development is done on Fedora Linux and Arch Linux. +CI tests are run on `ubuntu-latest` and `macos-latest` GitHub Action runners. ## Reporting issues From e5afb19d28ba19a27e180f6c403ab5e0edc38cfe Mon Sep 17 00:00:00 2001 From: Rainer Schoenberger Date: Wed, 25 Sep 2024 13:54:03 +0200 Subject: [PATCH 6/6] make output of tests more clear Signed-off-by: Rainer Schoenberger --- tests/functionTests/runFunctionTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functionTests/runFunctionTest.py b/tests/functionTests/runFunctionTest.py index 8f20411..5fb67c6 100755 --- a/tests/functionTests/runFunctionTest.py +++ b/tests/functionTests/runFunctionTest.py @@ -106,7 +106,7 @@ def prGreen(text): print("\033[92m {}\033[00m" .format(text)) for expectedLine in expected: if len(expected)>len(received): fail = True - failtext = "Test '{}' at line {} received not enough lines.".format(testname, testline) + failtext = "Test '{}' at line {} received not enough lines. expected: {}, received: {}".format(testname, testline, expected, received) break if(len(expected) <= idx): if(expectedLine.startswith("?")):