Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update libhdfs3 #7

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,162 changes: 0 additions & 1,162 deletions CMake/FindBoost.cmake

This file was deleted.

27 changes: 0 additions & 27 deletions CMake/FindGSasl.cmake

This file was deleted.

12 changes: 12 additions & 0 deletions CMake/FindGsasl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
find_path(GSASL_INCLUDE_DIRS NAMES gsasl.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH)
find_library(GSASL_LIBRARIES NAMES gsasl PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
if(NOT GSASL_INCLUDE_DIRS OR NOT GSASL_LIBRARIES)
message(FATAL_ERROR "Broken installation of vcpkg port gsasl")
endif()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSASL DEFAULT_MSG GSASL_LIBRARIES GSASL_INCLUDE_DIRS)

MARK_AS_ADVANCED(GSASL_LIBRARIES GSASL_INCLUDE_DIRS)

message("*** GSASL_LIBRARIES: ${GSASL_LIBRARIES} **")
message("*** GSASL_INCLUDE_DIRS: ${GSASL_INCLUDE_DIRS} **")
23 changes: 0 additions & 23 deletions CMake/FindKERBEROS.cmake

This file was deleted.

41 changes: 41 additions & 0 deletions CMake/FindKrb5.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# - Find kerberos
# Find the native KERBEROS includes and library
#
# KERBEROS_INCLUDE_DIRS - where to find krb5.h, etc.
# KERBEROS_LIBRARIES - List of libraries when using krb5.
# KERBEROS_FOUND - True if krb5 found.

find_path(KERBEROS_INCLUDE_DIRS krb5.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH)

set(LIB_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib")
# libkrb5_otp
find_library(Krb5_otp_LIB_PATH NAMES krb5_otp PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** Krb5_otp_LIB_PATH: ${Krb5_otp_LIB_PATH} **")
# libkrb5_k5tls
find_library(Krb5_k5tls_LIB_PATH NAMES krb5_k5tls PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** Krb5_k5tls_LIB_PATH: ${Krb5_k5tls_LIB_PATH} **")
# libkrb5support
find_library(Krb5support_LIB_PATH NAMES krb5support PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** Krb5support_LIB_PATH: ${Krb5support_LIB_PATH} **")
# libkrb5
find_library(Krb5_LIB_PATH NAMES krb5 PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** Krb5_LIB_PATH: ${Krb5_LIB_PATH} **")

# libk5crypto
find_library(K5crypto_LIB_PATH NAMES k5crypto PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** K5crypto_LIB_PATH: ${K5crypto_LIB_PATH} **")

# libcom_err
find_library(Com_err_LIB_PATH NAMES com_err PATHS "${LIB_DIR}" NO_DEFAULT_PATH)
message("*** Com_err_LIB_PATH: ${Com_err_LIB_PATH} **")

# Note: Must notice the library link orders
set(KERBEROS_LIBRARIES ${Krb5_LIB_PATH}
${Com_err_LIB_PATH} ${Krb5_otp_LIB_PATH}
${Krb5_k5tls_LIB_PATH} ${K5crypto_LIB_PATH}
${Krb5support_LIB_PATH})

MARK_AS_ADVANCED(KERBEROS_LIBRARIES KERBEROS_INCLUDE_DIRS)

message("*** KERBEROS_LIBRARIES: ${KERBEROS_LIBRARIES} **")
message("*** KERBEROS_INCLUDE_DIRS: ${KERBEROS_INCLUDE_DIRS} **")
23 changes: 0 additions & 23 deletions CMake/FindLibUUID.cmake

This file was deleted.

24 changes: 0 additions & 24 deletions CMake/FindLibXml2.cmake

This file was deleted.

8 changes: 2 additions & 6 deletions CMake/Options.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
OPTION(ENABLE_COVERAGE "enable code coverage" OFF)
OPTION(ENABLE_DEBUG "enable debug build" OFF)
OPTION(ENABLE_SSE "enable SSE4.2 buildin function" ON)
OPTION(BUILD_STATIC "build static library" ON)
OPTION(ENABLE_FRAME_POINTER "enable frame pointer on 64bit system with flag -fno-omit-frame-pointer, on 32bit system, it is always enabled" ON)
OPTION(ENABLE_LIBCPP "using libc++ instead of libstdc++, only valid for clang compiler" OFF)
OPTION(ENABLE_BOOST "using boost instead of native compiler c++0x support" OFF)
Expand Down Expand Up @@ -166,9 +167,4 @@ TRY_COMPILE(HAVE_STD_ATOMIC
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
OUTPUT_VARIABLE OUTPUT)

if (NOT DEFINED WITH_KERBEROS)
SET(WITH_KERBEROS false)
MESSAGE(STATUS "libhdfs3 will be build without kerberos support")
endif()
OUTPUT_VARIABLE OUTPUT)
15 changes: 15 additions & 0 deletions CMake/Platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,18 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX)
MESSAGE(FATAL_ERROR "Unsupported compiler: \"${CMAKE_CXX_COMPILER}\"")
ENDIF(COMPILER_OUTPUT MATCHES "clang")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
if(BUILD_STATIC)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# Note: If bring the -static option, apple will fail to link
if(NOT APPLE)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
endif()

if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Security -framework CoreFoundation -framework Kerberos")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed -ldl")
endif()
29 changes: 10 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)

SET(CMAKE_VERBOSE_MAKEFILE ON CACHE STRING "Verbose build." FORCE)

Expand All @@ -9,10 +9,6 @@ ENDIF()
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
SET(DOXYFILE_PATH ${CMAKE_SOURCE_DIR}/docs)

if (NOT DEFINED URL_BASE)
set(URL_BASE "github.com")
endif()

# vcpkg init
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
find_package(Git REQUIRED)
Expand All @@ -22,24 +18,19 @@ endif()

PROJECT(libhdfs3 VERSION "3.0.0")

find_package(libxml2 REQUIRED)

find_package(protobuf REQUIRED)

if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
find_package(unofficial-libuuid REQUIRED)
set(LIBUUID_LIBRARIES unofficial::UUID::uuid)
endif()

set(HDFS3_TARGET libhdfs3)
INCLUDE(Platform)
INCLUDE(Functions)
INCLUDE(Options)

IF (WITH_KERBEROS)
FIND_PACKAGE(KERBEROS REQUIRED)
ENDIF()
find_package(libxml2 REQUIRED)
find_package(protobuf REQUIRED)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
find_package(unofficial-libuuid REQUIRED)
endif()

FIND_PACKAGE(GSasl REQUIRED)
include(FindGsasl)
include (FindKrb5)

ADD_SUBDIRECTORY(mock)
ADD_SUBDIRECTORY(src)
Expand All @@ -61,4 +52,4 @@ ADD_CUSTOM_TARGET(style
COMMAND astyle --style=attach --indent=spaces=4 --indent-preprocessor --break-blocks --pad-oper --pad-header --unpad-paren --delete-empty-lines --suffix=none --align-pointer=middle --lineend=linux --indent-col1-comments ${secure_SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "format code style..."
)
)
4 changes: 1 addition & 3 deletions hdfs_benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ set(CMAKE_C_FLAGS_RELEASE "-O3 -march=native -msse -msse2")

set(SOURCE_FILES main.cpp)
add_executable(hdfs_benchmark ${SOURCE_FILES})
add_dependencies(hdfs_benchmark libhdfs3-shared)

target_link_libraries(hdfs_benchmark pthread libhdfs3-shared)
target_link_libraries(hdfs_benchmark PUBLIC ${HDFS3_TARGET})
73 changes: 13 additions & 60 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,90 +62,43 @@ SET(HEADER
common/Exception.h
common/XmlConfig.h)

ADD_LIBRARY(libhdfs3-static STATIC ${libhdfs3_SOURCES} ${libhdfs3_PROTO_SOURCES} ${PROTO_SRCS})
ADD_LIBRARY(libhdfs3-shared SHARED ${libhdfs3_SOURCES} ${libhdfs3_PROTO_SOURCES} ${PROTO_SRCS})

ADD_LIBRARY(${HDFS3_TARGET} ${libhdfs3_SOURCES} ${libhdfs3_PROTO_SOURCES} ${PROTO_SRCS})
ADD_CUSTOM_COMMAND(
TARGET libhdfs3-shared libhdfs3-static
TARGET ${HDFS3_TARGET}
PRE_BUILD
COMMAND echo ${libhdfs3_VERSION_STRING} > version
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

TARGET_LINK_LIBRARIES(libhdfs3-static pthread)
TARGET_LINK_LIBRARIES(libhdfs3-shared pthread)

IF(NEED_BOOST)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(libhdfs3-static boost_thread)
TARGET_LINK_LIBRARIES(libhdfs3-static boost_chrono)
TARGET_LINK_LIBRARIES(libhdfs3-static boost_system)
TARGET_LINK_LIBRARIES(libhdfs3-static boost_atomic)
TARGET_LINK_LIBRARIES(libhdfs3-static boost_iostreams)
TARGET_LINK_LIBRARIES(libhdfs3-shared boost_thread)
TARGET_LINK_LIBRARIES(libhdfs3-shared boost_chrono)
TARGET_LINK_LIBRARIES(libhdfs3-shared boost_system)
TARGET_LINK_LIBRARIES(libhdfs3-shared boost_atomic)
TARGET_LINK_LIBRARIES(libhdfs3-shared boost_iostreams)
ENDIF(NEED_BOOST)
if(NEED_BOOST)
find_package(Boost COMPONENTS atomic chrono iostreams thread system)
TARGET_LINK_LIBRARIES(${HDFS3_TARGET} PUBLIC pthread Boost::thread Boost::chrono Boost::system Boost::iostreams Boost::thread)
endif()

IF(NEED_GCCEH)
TARGET_LINK_LIBRARIES(libhdfs3-static gcc_eh)
TARGET_LINK_LIBRARIES(libhdfs3-shared gcc_eh)
TARGET_LINK_LIBRARIES(${HDFS3_TARGET} PUBLIC gcc_eh)
ENDIF(NEED_GCCEH)

IF(OS_LINUX)
TARGET_LINK_LIBRARIES(libhdfs3-static unofficial::UUID::uuid)
TARGET_LINK_LIBRARIES(libhdfs3-shared unofficial::UUID::uuid)
TARGET_LINK_LIBRARIES(${HDFS3_TARGET} PUBLIC unofficial::UUID::uuid)
ENDIF(OS_LINUX)

INCLUDE_DIRECTORIES(${libhdfs3_ROOT_SOURCES_DIR})
INCLUDE_DIRECTORIES(${libhdfs3_COMMON_SOURCES_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

IF (WITH_KERBEROS)
INCLUDE_DIRECTORIES(${KERBEROS_INCLUDE_DIRS})
ENDIF()

INCLUDE_DIRECTORIES(${GSASL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GSASL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/mock)

TARGET_LINK_LIBRARIES(libhdfs3-static PRIVATE protobuf::libprotobuf)
TARGET_LINK_LIBRARIES(libhdfs3-static LibXml2::LibXml2)

IF (WITH_KERBEROS)
TARGET_LINK_LIBRARIES(libhdfs3-static ${KERBEROS_LIBRARIES})
ENDIF()

IF (APPLE)
TARGET_LINK_LIBRARIES(libhdfs3-static ${GSASL_LIBRARIES})
ELSE()
TARGET_LINK_LIBRARIES(libhdfs3-static ${GSASL_STATIC_LIBRARIES})
ENDIF()

TARGET_LINK_LIBRARIES(libhdfs3-shared protobuf::libprotobuf)
TARGET_LINK_LIBRARIES(libhdfs3-shared LibXml2::LibXml2)

IF (WITH_KERBEROS)
TARGET_LINK_LIBRARIES(libhdfs3-shared ${KERBEROS_LIBRARIES})
ENDIF()

TARGET_LINK_LIBRARIES(libhdfs3-shared ${GSASL_LIBRARIES})

SET_TARGET_PROPERTIES(libhdfs3-static PROPERTIES OUTPUT_NAME "hdfs3")
SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES OUTPUT_NAME "hdfs3")

IF(NEED_BOOST)
SET_TARGET_PROPERTIES(libhdfs3-shared libhdfs3-static PROPERTIES LINK_FLAGS "-L${Boost_LIBRARY_DIRS}")
ENDIF(NEED_BOOST)
# Note: pthread maybe conflict with libc when build static library, so should put it into the first place when linking
TARGET_LINK_LIBRARIES(${HDFS3_TARGET} PUBLIC pthread ${GSASL_LIBRARIES} ${KERBEROS_LIBRARIES} protobuf::libprotobuf LibXml2::LibXml2 resolv)

SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES
VERSION ${libhdfs3_VERSION_MAJOR}.${libhdfs3_VERSION_MINOR}.${libhdfs3_VERSION_PATCH}
SOVERSION ${libhdfs3_VERSION_API})
SET_TARGET_PROPERTIES(${HDFS3_TARGET} PROPERTIES OUTPUT_NAME "hdfs3")

include(InstallConfig)
install(
TARGETS libhdfs3-static libhdfs3-shared
TARGETS ${HDFS3_TARGET}
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
6 changes: 0 additions & 6 deletions src/client/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@

#include <algorithm>
#include <string>
#if WITH_KERBEROS
#include <krb5/krb5.h>
#endif

using namespace Hdfs::Internal;

Expand All @@ -52,7 +50,6 @@ namespace Internal {

static std::string ExtractPrincipalFromTicketCache(
const std::string & cachePath) {
#if WITH_KERBEROS
krb5_context cxt = NULL;
krb5_ccache ccache = NULL;
krb5_principal principal = NULL;
Expand Down Expand Up @@ -117,9 +114,6 @@ static std::string ExtractPrincipalFromTicketCache(
}

return retval;
#else
THROW(HdfsIOException, "libhdfs3 built without kerberos support");
#endif
}


Expand Down
Loading