kou commented on code in PR #51244: URL: https://github.com/apache/arrow/pull/51244#discussion_r4003288388
########## cpp/cmake_modules/FinduriparserAlt.cmake: ########## @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Find uriparser. +# +# Debian, Ubuntu and several other distributions ship a liburiparser-dev that +# provides only a pkg-config file, while upstream (and vcpkg, conda-forge) +# also install a CMake package configuration. Try the CMake config first, then +# fall back to pkg-config and finally to a plain library search. + +if(uriparserAlt_FOUND) + return() +endif() + +set(find_package_args) +if(uriparserAlt_FIND_VERSION) + list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) +endif() +if(uriparserAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(uriparser ${find_package_args} CONFIG) +if(uriparser_FOUND) + set(uriparserAlt_FOUND TRUE) + return() +endif() + +if(URIPARSER_ROOT) + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATHS ${URIPARSER_ROOT} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) +else() + find_package(PkgConfig QUIET) Review Comment: Could you add `QUIET` only when `uriparserAlt_FIND_QUIETLY`? ########## cpp/cmake_modules/FinduriparserAlt.cmake: ########## @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Find uriparser. +# +# Debian, Ubuntu and several other distributions ship a liburiparser-dev that +# provides only a pkg-config file, while upstream (and vcpkg, conda-forge) +# also install a CMake package configuration. Try the CMake config first, then +# fall back to pkg-config and finally to a plain library search. + +if(uriparserAlt_FOUND) + return() +endif() + +set(find_package_args) +if(uriparserAlt_FIND_VERSION) + list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) +endif() +if(uriparserAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(uriparser ${find_package_args} CONFIG) +if(uriparser_FOUND) + set(uriparserAlt_FOUND TRUE) + return() +endif() + +if(URIPARSER_ROOT) + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATHS ${URIPARSER_ROOT} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) +else() Review Comment: We don't need this check. We need to check only CMake package and pkg-config package. ########## cpp/cmake_modules/FinduriparserAlt.cmake: ########## @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Find uriparser. +# +# Debian, Ubuntu and several other distributions ship a liburiparser-dev that +# provides only a pkg-config file, while upstream (and vcpkg, conda-forge) +# also install a CMake package configuration. Try the CMake config first, then +# fall back to pkg-config and finally to a plain library search. + +if(uriparserAlt_FOUND) + return() +endif() + +set(find_package_args) +if(uriparserAlt_FIND_VERSION) + list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) +endif() +if(uriparserAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(uriparser ${find_package_args} CONFIG) +if(uriparser_FOUND) + set(uriparserAlt_FOUND TRUE) + return() +endif() + +if(URIPARSER_ROOT) + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATHS ${URIPARSER_ROOT} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) +else() + find_package(PkgConfig QUIET) + pkg_check_modules(URIPARSER_PC liburiparser) Review Comment: Could you add `QUIET` when `uriparserAlt_FIND_QUIETLY`? Could you add `IMPORTED_TARGET`? ########## cpp/cmake_modules/FinduriparserAlt.cmake: ########## @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Find uriparser. +# +# Debian, Ubuntu and several other distributions ship a liburiparser-dev that +# provides only a pkg-config file, while upstream (and vcpkg, conda-forge) +# also install a CMake package configuration. Try the CMake config first, then +# fall back to pkg-config and finally to a plain library search. + +if(uriparserAlt_FOUND) + return() +endif() + +set(find_package_args) +if(uriparserAlt_FIND_VERSION) + list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) +endif() +if(uriparserAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(uriparser ${find_package_args} CONFIG) +if(uriparser_FOUND) + set(uriparserAlt_FOUND TRUE) + return() +endif() + +if(URIPARSER_ROOT) + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATHS ${URIPARSER_ROOT} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) +else() + find_package(PkgConfig QUIET) + pkg_check_modules(URIPARSER_PC liburiparser) + if(URIPARSER_PC_FOUND) + set(URIPARSER_INCLUDE_DIR "${URIPARSER_PC_INCLUDEDIR}") + list(APPEND URIPARSER_PC_LIBRARY_DIRS "${URIPARSER_PC_LIBDIR}") + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_PC_LIBRARY_DIRS} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) + set(URIPARSER_VERSION "${URIPARSER_PC_VERSION}") + else() Review Comment: We don't need this because we want to use CMake target instead of variables. ########## ci/scripts/msys2_setup.sh: ########## @@ -36,6 +36,7 @@ case "${target}" in packages+=("${MINGW_PACKAGE_PREFIX}-gflags") packages+=("${MINGW_PACKAGE_PREFIX}-grpc") packages+=("${MINGW_PACKAGE_PREFIX}-gtest") + packages+=("${MINGW_PACKAGE_PREFIX}-uriparser") Review Comment: Can we revert this because we already have it in this list? ########## cpp/cmake_modules/FinduriparserAlt.cmake: ########## @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Find uriparser. +# +# Debian, Ubuntu and several other distributions ship a liburiparser-dev that +# provides only a pkg-config file, while upstream (and vcpkg, conda-forge) +# also install a CMake package configuration. Try the CMake config first, then +# fall back to pkg-config and finally to a plain library search. + +if(uriparserAlt_FOUND) + return() +endif() + +set(find_package_args) +if(uriparserAlt_FIND_VERSION) + list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) +endif() +if(uriparserAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(uriparser ${find_package_args} CONFIG) +if(uriparser_FOUND) + set(uriparserAlt_FOUND TRUE) + return() +endif() + +if(URIPARSER_ROOT) + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATHS ${URIPARSER_ROOT} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) +else() + find_package(PkgConfig QUIET) + pkg_check_modules(URIPARSER_PC liburiparser) + if(URIPARSER_PC_FOUND) + set(URIPARSER_INCLUDE_DIR "${URIPARSER_PC_INCLUDEDIR}") + list(APPEND URIPARSER_PC_LIBRARY_DIRS "${URIPARSER_PC_LIBDIR}") + find_library(URIPARSER_LIB + NAMES uriparser + PATHS ${URIPARSER_PC_LIBRARY_DIRS} + NO_DEFAULT_PATH + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) + set(URIPARSER_VERSION "${URIPARSER_PC_VERSION}") + else() + find_library(URIPARSER_LIB + NAMES uriparser + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) + find_path(URIPARSER_INCLUDE_DIR + NAMES uriparser/Uri.h + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) Review Comment: We don't need this fallback. ########## cpp/cmake_modules/ThirdpartyToolchain.cmake: ########## @@ -3256,6 +3261,65 @@ if(ARROW_WITH_BZ2) endif() endif() +# ---------------------------------------------------------------------- +# uriparser library + +macro(build_uriparser) + message(STATUS "Building uriparser from source") + set(URIPARSER_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/uriparser_ep-install") + if(MSVC) + set(URIPARSER_STATIC_LIB "${URIPARSER_PREFIX}/lib/uriparser.lib") + else() + set(URIPARSER_STATIC_LIB + "${URIPARSER_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}uriparser${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + + set(URIPARSER_CMAKE_ARGS + ${EP_COMMON_CMAKE_ARGS} + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_LIBDIR=lib + "-DCMAKE_INSTALL_PREFIX=${URIPARSER_PREFIX}" + -DURIPARSER_BUILD_DOCS=OFF + -DURIPARSER_BUILD_TESTS=OFF + -DURIPARSER_BUILD_TOOLS=OFF + # Arrow only uses the char (not wchar_t) flavor of the API. + -DURIPARSER_BUILD_WCHAR_T=OFF) + + if(MSVC AND ARROW_USE_STATIC_CRT) + list(APPEND URIPARSER_CMAKE_ARGS -DURIPARSER_MSVC_STATIC_CRT=ON) + endif() + + externalproject_add(uriparser_ep + ${EP_COMMON_OPTIONS} + CMAKE_ARGS ${URIPARSER_CMAKE_ARGS} + INSTALL_DIR ${URIPARSER_PREFIX} + URL ${ARROW_URIPARSER_SOURCE_URL} + URL_HASH "SHA256=${ARROW_URIPARSER_BUILD_SHA256_CHECKSUM}" + BUILD_BYPRODUCTS "${URIPARSER_STATIC_LIB}") Review Comment: Could you use FetchContent instead of ExternalProject? ########## cpp/cmake_modules/ThirdpartyToolchain.cmake: ########## @@ -3256,6 +3261,65 @@ if(ARROW_WITH_BZ2) endif() endif() +# ---------------------------------------------------------------------- +# uriparser library + +macro(build_uriparser) + message(STATUS "Building uriparser from source") + set(URIPARSER_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/uriparser_ep-install") + if(MSVC) + set(URIPARSER_STATIC_LIB "${URIPARSER_PREFIX}/lib/uriparser.lib") + else() + set(URIPARSER_STATIC_LIB + "${URIPARSER_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}uriparser${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + + set(URIPARSER_CMAKE_ARGS + ${EP_COMMON_CMAKE_ARGS} + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_LIBDIR=lib + "-DCMAKE_INSTALL_PREFIX=${URIPARSER_PREFIX}" + -DURIPARSER_BUILD_DOCS=OFF + -DURIPARSER_BUILD_TESTS=OFF + -DURIPARSER_BUILD_TOOLS=OFF + # Arrow only uses the char (not wchar_t) flavor of the API. + -DURIPARSER_BUILD_WCHAR_T=OFF) + + if(MSVC AND ARROW_USE_STATIC_CRT) + list(APPEND URIPARSER_CMAKE_ARGS -DURIPARSER_MSVC_STATIC_CRT=ON) + endif() + + externalproject_add(uriparser_ep + ${EP_COMMON_OPTIONS} + CMAKE_ARGS ${URIPARSER_CMAKE_ARGS} + INSTALL_DIR ${URIPARSER_PREFIX} + URL ${ARROW_URIPARSER_SOURCE_URL} + URL_HASH "SHA256=${ARROW_URIPARSER_BUILD_SHA256_CHECKSUM}" + BUILD_BYPRODUCTS "${URIPARSER_STATIC_LIB}") + + file(MAKE_DIRECTORY "${URIPARSER_PREFIX}/include") + add_library(uriparser::uriparser STATIC IMPORTED) + set_target_properties(uriparser::uriparser + PROPERTIES IMPORTED_LOCATION "${URIPARSER_STATIC_LIB}" + INTERFACE_COMPILE_DEFINITIONS "URI_STATIC_BUILD") + target_include_directories(uriparser::uriparser BEFORE + INTERFACE "${URIPARSER_PREFIX}/include") + + add_dependencies(uriparser::uriparser uriparser_ep) + + list(PREPEND ARROW_BUNDLED_STATIC_LIBS uriparser::uriparser) +endmacro() + +# uriparser is mandatory: arrow::util::Uri is part of core Arrow. +resolve_dependency(uriparser + HAVE_ALT + TRUE + REQUIRED_VERSION + "1.0.2" Review Comment: Can we require 0.9.6 or later for Ubuntu 22.04? ########## cpp/src/arrow/meson.build: ########## @@ -238,7 +223,34 @@ arrow_util_srcs = [ 'util/value_parsing.cc', ] -arrow_util_deps = [threads_dep] +uriparser_dep = dependency( + 'liburiparser', Review Comment: Does this search both of CMake package and pkg-config package? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
