From 4b414d60eeaa00f6fbbbdb2f937b26601e903ee9 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Fri, 26 May 2023 22:35:17 +0000 Subject: [PATCH] Squashed 'third_party/utf8_range/' changes from 72c943dea..d863bc33e d863bc33e cleanup: avoid "unused function" errors in OSS land f4948c4f2 internal change cd1507d14 Fix typo in pkg-config file to properly link the utf8_range libraries 3f179d134 Add pkg-config file declaring Abseil dependency of utf8_range git-subtree-dir: third_party/utf8_range git-subtree-split: d863bc33e15cba6d873c878dcca9e6fe52b2f8cb --- .github/workflows/bazel_tests.yml | 9 ++++++++- BUILD.bazel | 6 ++++++ CMakeLists.txt | 5 +++++ cmake/utf8_range.pc.cmake | 11 +++++++++++ utf8_validity.cc | 2 ++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 cmake/utf8_range.pc.cmake diff --git a/.github/workflows/bazel_tests.yml b/.github/workflows/bazel_tests.yml index ae3e970419..adf711859a 100644 --- a/.github/workflows/bazel_tests.yml +++ b/.github/workflows/bazel_tests.yml @@ -29,8 +29,15 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Setup Bazel + run: | + echo "BAZEL=bazel" >> $GITHUB_ENV + echo "USE_BAZEL_VERSION=5.1.1" >> $GITHUB_ENV + - name: Setup Bazel (macOS) + if: runner.os == 'macOS' + run: echo "BAZEL=bazelisk" >> $GITHUB_ENV - name: Install dependencies run: sudo apt update && sudo apt install -y ${{ matrix.install }} if: matrix.install != '' - name: Run tests - run: cd ${{ github.workspace }} && CC=${{ matrix.CC }} bazel test --test_output=errors ... ${{ matrix.flags }} + run: cd ${{ github.workspace }} && CC=${{ matrix.CC }} ${{ env.BAZEL }} test --test_output=errors ... ${{ matrix.flags }} diff --git a/BUILD.bazel b/BUILD.bazel index 361baf0d01..b9ba04e17c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,6 +4,12 @@ # license that can be found in the LICENSE file or at # https://opensource.org/licenses/MIT. +DEFAULT_VISIBILITY = [ + "//third_party/protobuf:__subpackages__", + "//:__subpackages__", + "//util/utf8/internal:__subpackages__", +] + package(default_visibility = ["//visibility:public"]) licenses(["notice"]) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69a4d89907..344952d38c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,11 @@ if (utf8_range_ENABLE_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/utf8_range.pc.cmake + ${CMAKE_CURRENT_BINARY_DIR}/utf8_range.pc @ONLY) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/utf8_range.pc + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") # Install public headers explicitly. install(FILES utf8_range.h utf8_validity.h diff --git a/cmake/utf8_range.pc.cmake b/cmake/utf8_range.pc.cmake new file mode 100644 index 0000000000..64b4b770b2 --- /dev/null +++ b/cmake/utf8_range.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: UTF8 Range +Description: Google's UTF8 Library +Version: 1.0 +Requires: absl_strings +Libs: -L${libdir} -lutf8_validity -lutf8_range @CMAKE_THREAD_LIBS_INIT@ +Cflags: -I${includedir} diff --git a/utf8_validity.cc b/utf8_validity.cc index db811993f8..9e94576673 100644 --- a/utf8_validity.cc +++ b/utf8_validity.cc @@ -133,6 +133,7 @@ size_t ValidUTF8Span(const char* data, const char* end) { return err_pos + (1 - ReturnPosition); } +#ifdef __SSE4_1__ /* Returns the number of bytes needed to skip backwards to get to the first byte of codepoint. */ @@ -148,6 +149,7 @@ inline int CodepointSkipBackwards(int32_t codepoint_word) { } return 0; } +#endif // __SSE4_1__ /* Skipping over ASCII as much as possible, per 8 bytes. It is intentional as most strings to check for validity consist only of 1 byte codepoints.