From 032d9a6d05d80b503173646f24f772e0662f6c68 Mon Sep 17 00:00:00 2001 From: luffy-zh Date: Thu, 27 Jun 2024 17:27:48 +0800 Subject: [PATCH 01/10] ORC-1732:[C++] fix failure to detect Protobuf installed by Homebrew on macOS --- cmake_modules/FindProtobuf.cmake | 26 +++++++++++++++++++++++--- tools/test/TestFileScan.cc | 15 ++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index 82429a23f5..80e64e307c 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -47,6 +47,7 @@ message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}") find_package (Protobuf CONFIG) if (Protobuf_FOUND) + if(TARGET protobuf::libprotobuf) set (PROTOBUF_LIBRARY protobuf::libprotobuf) set (PROTOBUF_STATIC_LIB PROTOBUF_STATIC_LIB-NOTFOUND) set (PROTOC_LIBRARY protobuf::libprotoc) @@ -55,15 +56,34 @@ if (Protobuf_FOUND) get_target_property (target_type protobuf::libprotobuf TYPE) if (target_type STREQUAL "STATIC_LIBRARY") - set(PROTOBUF_STATIC_LIB protobuf::libprotobuf) + set (PROTOBUF_STATIC_LIB protobuf::libprotobuf) endif () get_target_property (target_type protobuf::libprotoc TYPE) if (target_type STREQUAL "STATIC_LIBRARY") - set (PROTOC_STATIC_LIB protobuf::libprotoc) + set (PROTOC_STATIC_LIB protobuf::libprotoc) endif () - get_target_property (PROTOBUF_INCLUDE_DIR protobuf::libprotoc INTERFACE_INCLUDE_DIRECTORIES) + get_target_property (PROTOBUF_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) + if (NOT PROTOBUF_INCLUDE_DIR) + set (PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIRS}) + if (NOT PROTOBUF_INCLUDE_DIR) + message(FATAL_ERROR "Cannot determine Protobuf include directory.") + endif () + endif () + else () + set (PROTOBUF_LIBRARY ${Protobuf_LIBRARIES}) + set (PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIRS}) + if (NOT PROTOBUF_INCLUDE_DIR) + message(FATAL_ERROR "Cannot determine Protobuf include directory.") + endif () + + if (Protobuf_LIBRARIES MATCHES "\\.a$") + set (PROTOBUF_STATIC_LIB ${Protobuf_LIBRARIES}) + else () + set (PROTOBUF_STATIC_LIB PROTOBUF_STATIC_LIB-NOTFOUND) + endif () + endif () else() find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/zero_copy_stream.h HINTS diff --git a/tools/test/TestFileScan.cc b/tools/test/TestFileScan.cc index 2e35d86ef0..5fb43d5d25 100644 --- a/tools/test/TestFileScan.cc +++ b/tools/test/TestFileScan.cc @@ -211,9 +211,22 @@ void checkForError(const std::string& filename, const std::string& errorMsg) { EXPECT_NE(std::string::npos, error.find(errorMsg)) << error; } +void checkForError(const std::string& filename, const std::string& errorMsg1, + const std::string& errorMsg2) { + const std::string pgm = findProgram("tools/src/orc-scan"); + std::string output; + std::string error; + EXPECT_EQ(1, runProgram({pgm, filename}, output, error)); + EXPECT_EQ("", output); + if (error.find(errorMsg1) == std::string::npos && error.find(errorMsg2) == std::string::npos) { + FAIL() << error; + } +} + TEST(TestFileScan, testErrorHandling) { checkForError(findExample("corrupt/stripe_footer_bad_column_encodings.orc"), - "bad number of ColumnEncodings in StripeFooter: expected=6, actual=0"); + "bad number of ColumnEncodings in StripeFooter: expected=6, actual=0", + "bad StripeFooter from zlib"); checkForError(findExample("corrupt/negative_dict_entry_lengths.orc"), "Negative dictionary entry length"); checkForError(findExample("corrupt/missing_length_stream_in_string_dict.orc"), From 18dac8c49e4cbe94ac7c636e3f548924007a8805 Mon Sep 17 00:00:00 2001 From: luffy-zh Date: Thu, 27 Jun 2024 17:42:13 +0800 Subject: [PATCH 02/10] format code --- cmake_modules/FindProtobuf.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index 80e64e307c..c709995cb6 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -47,7 +47,7 @@ message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}") find_package (Protobuf CONFIG) if (Protobuf_FOUND) - if(TARGET protobuf::libprotobuf) + if (TARGET protobuf::libprotobuf) set (PROTOBUF_LIBRARY protobuf::libprotobuf) set (PROTOBUF_STATIC_LIB PROTOBUF_STATIC_LIB-NOTFOUND) set (PROTOC_LIBRARY protobuf::libprotoc) From 6f29a36ca5626c49859d74786d8052504b615087 Mon Sep 17 00:00:00 2001 From: luffy-zh Date: Mon, 1 Jul 2024 22:54:58 +0800 Subject: [PATCH 03/10] add macos ci job test --- .github/workflows/build_and_test.yml | 27 +++++++++++++++++++++++++++ cmake_modules/FindProtobuf.cmake | 12 ++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 30d374e75e..4e82152135 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -197,3 +197,30 @@ jobs: with: config: .github/.licenserc.yaml + macos-c++-check: + name: "C++ Test on macOS" + strategy: + fail-fast: false + matrix: + version: [12, 14] + + runs-on: macos-${{ matrix.version }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + brew update + brew install protobuf + + - name: Test + run: | + CMAKE_PREFIX_PATH=$(brew --prefix protobuf) + mkdir build + cd build + cmake .. -DBUILD_JAVA=OFF -DPROTOBUF_HOME=${CMAKE_PREFIX_PATH} + run: cmake --build build + run: ctest --test-dir build --output-on-failure + diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index c709995cb6..837c143b51 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -45,6 +45,14 @@ endif() message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}") +if (NOT DEFINED CMAKE_STATIC_LIBRARY_SUFFIX) + if (WIN32) + set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") + else() + set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") + endif() +endif() + find_package (Protobuf CONFIG) if (Protobuf_FOUND) if (TARGET protobuf::libprotobuf) @@ -68,7 +76,7 @@ if (Protobuf_FOUND) if (NOT PROTOBUF_INCLUDE_DIR) set (PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIRS}) if (NOT PROTOBUF_INCLUDE_DIR) - message(FATAL_ERROR "Cannot determine Protobuf include directory.") + message(FATAL_ERROR "Cannot determine Protobuf include directory from protobuf::libprotobuf and Protobuf_INCLUDE_DIRS.") endif () endif () else () @@ -78,7 +86,7 @@ if (Protobuf_FOUND) message(FATAL_ERROR "Cannot determine Protobuf include directory.") endif () - if (Protobuf_LIBRARIES MATCHES "\\.a$") + if (Protobuf_LIBRARIES MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") set (PROTOBUF_STATIC_LIB ${Protobuf_LIBRARIES}) else () set (PROTOBUF_STATIC_LIB PROTOBUF_STATIC_LIB-NOTFOUND) From 4abc8d1640bfc1d1aece95545d1a324071dc11ad Mon Sep 17 00:00:00 2001 From: luffy-zh Date: Wed, 3 Jul 2024 11:45:19 +0800 Subject: [PATCH 04/10] fix build_and_test run failure --- .github/workflows/build_and_test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4e82152135..128ada8da7 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -218,9 +218,8 @@ jobs: - name: Test run: | CMAKE_PREFIX_PATH=$(brew --prefix protobuf) - mkdir build + mkdir -p build cd build cmake .. -DBUILD_JAVA=OFF -DPROTOBUF_HOME=${CMAKE_PREFIX_PATH} - run: cmake --build build - run: ctest --test-dir build --output-on-failure + make package test-out From e6ad6567c558cd8bc9ef561115543e7afd54fce2 Mon Sep 17 00:00:00 2001 From: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:33:17 +0800 Subject: [PATCH 05/10] Update .github/workflows/build_and_test.yml Co-authored-by: Gang Wu --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 128ada8da7..44620611db 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -197,7 +197,7 @@ jobs: with: config: .github/.licenserc.yaml - macos-c++-check: + macos-cpp-check: name: "C++ Test on macOS" strategy: fail-fast: false From 30108ae7ca3637eaf1ee84b422f758803d3905a2 Mon Sep 17 00:00:00 2001 From: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:33:23 +0800 Subject: [PATCH 06/10] Update .github/workflows/build_and_test.yml Co-authored-by: Gang Wu --- .github/workflows/build_and_test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 44620611db..3585cc7822 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -203,18 +203,14 @@ jobs: fail-fast: false matrix: version: [12, 14] - runs-on: macos-${{ matrix.version }} - steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Install dependencies run: | brew update brew install protobuf - - name: Test run: | CMAKE_PREFIX_PATH=$(brew --prefix protobuf) From 89585593a2c39395eb5e75e73d6c86d944e5b180 Mon Sep 17 00:00:00 2001 From: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:07:08 +0800 Subject: [PATCH 07/10] Update cmake_modules/FindProtobuf.cmake Co-authored-by: Sutou Kouhei --- cmake_modules/FindProtobuf.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index 837c143b51..13f37d7e39 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -47,11 +47,11 @@ message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}") if (NOT DEFINED CMAKE_STATIC_LIBRARY_SUFFIX) if (WIN32) - set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") - else() - set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") - endif() -endif() + set (CMAKE_STATIC_LIBRARY_SUFFIX ".lib") + else () + set (CMAKE_STATIC_LIBRARY_SUFFIX ".a") + endif () +endif () find_package (Protobuf CONFIG) if (Protobuf_FOUND) From a9326e8ea0e3db7f5dda632a2c957bd923792c02 Mon Sep 17 00:00:00 2001 From: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:07:14 +0800 Subject: [PATCH 08/10] Update cmake_modules/FindProtobuf.cmake Co-authored-by: Sutou Kouhei --- cmake_modules/FindProtobuf.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index 13f37d7e39..d35272e267 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -83,7 +83,7 @@ if (Protobuf_FOUND) set (PROTOBUF_LIBRARY ${Protobuf_LIBRARIES}) set (PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIRS}) if (NOT PROTOBUF_INCLUDE_DIR) - message(FATAL_ERROR "Cannot determine Protobuf include directory.") + message (FATAL_ERROR "Cannot determine Protobuf include directory.") endif () if (Protobuf_LIBRARIES MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") From 7ddf8ced61c8223f85313d133323d4b0834a47e2 Mon Sep 17 00:00:00 2001 From: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:07:20 +0800 Subject: [PATCH 09/10] Update cmake_modules/FindProtobuf.cmake Co-authored-by: Sutou Kouhei --- cmake_modules/FindProtobuf.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index d35272e267..ca91fb5ade 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -76,7 +76,7 @@ if (Protobuf_FOUND) if (NOT PROTOBUF_INCLUDE_DIR) set (PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIRS}) if (NOT PROTOBUF_INCLUDE_DIR) - message(FATAL_ERROR "Cannot determine Protobuf include directory from protobuf::libprotobuf and Protobuf_INCLUDE_DIRS.") + message (FATAL_ERROR "Cannot determine Protobuf include directory from protobuf::libprotobuf and Protobuf_INCLUDE_DIRS.") endif () endif () else () From d479f05ea662e5d818bf7a0b214cad42bbafe537 Mon Sep 17 00:00:00 2001 From: luffy-zh Date: Thu, 11 Jul 2024 11:37:18 +0800 Subject: [PATCH 10/10] add 12 to macOS version list --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 3585cc7822..89460a5436 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -202,7 +202,7 @@ jobs: strategy: fail-fast: false matrix: - version: [12, 14] + version: [12, 13, 14] runs-on: macos-${{ matrix.version }} steps: - name: Checkout repository