From 7945cb91fe52952c127d3668d007aea1ec9ceb65 Mon Sep 17 00:00:00 2001 From: "Markus Kitsinger (SwooshyCueb)" Date: Sat, 2 Mar 2024 00:48:18 -0500 Subject: [PATCH] [2080,2154,irods/irods_7265] Minor reorganization + CMake TLC - Project tree structure reorganized to match that of main irods repo. - Removed unused read_shared_memory.cpp. - Fixed some system #includes not having angle brackets. - Added quotes around paths in CMake files. - Changed all instances of CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR. - Removed CMAKE_SHARED_LINKER_FLAGS_INIT and CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT, as no shared libraries are built. - Added IRODS_PLUGINS_DIRECTORY to CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION. - Added CMAKE_EXE_LINKER_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT for unit tests. - [2080] Rewrote unit test cmake to match that of main irods repo. - [2154] Replaced curl-devel package dependency declaration with libcurl --- CMakeLists.txt | 164 ++++-------------- libs3/CMakeLists.txt | 49 ++++++ s3/s3_transport/read_shared_memory.cpp | 61 ------- s3/s3_transport/unit_tests/CMakeLists.txt | 131 -------------- .../test_config/irods_s3_transport.cmake | 24 --- s3_resource/CMakeLists.txt | 55 ++++++ .../private/s3_resource}/s3_operations.hpp | 4 +- .../s3_plugin_logging_category.hpp | 8 +- .../irods/private/s3_resource/s3_resource.hpp | 4 +- {s3 => s3_resource/src}/s3_operations.cpp | 8 +- .../src/s3_resource.cpp | 10 +- s3_transport/CMakeLists.txt | 53 ++++++ .../irods/private/s3_transport/callbacks.hpp | 10 +- .../private/s3_transport}/circular_buffer.hpp | 2 +- .../s3_transport}/lock_and_wait_strategy.hpp | 0 .../private/s3_transport/logging_category.hpp | 2 +- .../managed_shared_memory_object.hpp | 8 +- .../s3_transport/multipart_shared_data.hpp | 8 +- .../private/s3_transport}/s3_transport.hpp | 12 +- .../irods/private/s3_transport/types.hpp | 2 +- .../irods/private/s3_transport/util.hpp | 6 +- .../src/s3_transport.cpp | 8 +- unit_tests/CMakeLists.txt | 56 ++++++ .../test_config/irods_s3_transport.cmake | 13 ++ .../cmake/utils.cmake | 1 + .../create_unit_test_files.sh | 0 .../unit_tests => unit_tests}/src/main.cpp | 0 .../src/test_s3_transport.cpp | 8 +- .../unit_tests_list.json | 0 29 files changed, 310 insertions(+), 397 deletions(-) create mode 100644 libs3/CMakeLists.txt delete mode 100644 s3/s3_transport/read_shared_memory.cpp delete mode 100644 s3/s3_transport/unit_tests/CMakeLists.txt delete mode 100644 s3/s3_transport/unit_tests/cmake/test_config/irods_s3_transport.cmake create mode 100644 s3_resource/CMakeLists.txt rename {s3 => s3_resource/include/irods/private/s3_resource}/s3_operations.hpp (98%) rename {s3 => s3_resource/include/irods/private/s3_resource}/s3_plugin_logging_category.hpp (87%) rename s3/libirods_s3.hpp => s3_resource/include/irods/private/s3_resource/s3_resource.hpp (99%) rename {s3 => s3_resource/src}/s3_operations.cpp (99%) rename s3/libirods_s3.cpp => s3_resource/src/s3_resource.cpp (99%) create mode 100644 s3_transport/CMakeLists.txt rename s3/s3_transport/include/s3_transport_callbacks.hpp => s3_transport/include/irods/private/s3_transport/callbacks.hpp (99%) rename {s3/s3_transport/include => s3_transport/include/irods/private/s3_transport}/circular_buffer.hpp (98%) rename {s3/s3_transport/include => s3_transport/include/irods/private/s3_transport}/lock_and_wait_strategy.hpp (100%) rename s3/s3_transport/include/s3_transport_logging_category.hpp => s3_transport/include/irods/private/s3_transport/logging_category.hpp (97%) rename {s3/s3_transport/include => s3_transport/include/irods/private/s3_transport}/managed_shared_memory_object.hpp (95%) rename s3/s3_transport/include/s3_multipart_shared_data.hpp => s3_transport/include/irods/private/s3_transport/multipart_shared_data.hpp (95%) rename {s3/s3_transport/include => s3_transport/include/irods/private/s3_transport}/s3_transport.hpp (99%) rename s3/s3_transport/include/s3_transport_types.hpp => s3_transport/include/irods/private/s3_transport/types.hpp (95%) rename s3/s3_transport/include/s3_transport_util.hpp => s3_transport/include/irods/private/s3_transport/util.hpp (97%) rename {s3/s3_transport => s3_transport}/src/s3_transport.cpp (99%) create mode 100644 unit_tests/CMakeLists.txt create mode 100644 unit_tests/cmake/test_config/irods_s3_transport.cmake rename {s3/s3_transport/unit_tests => unit_tests}/cmake/utils.cmake (87%) rename {s3/s3_transport/unit_tests => unit_tests}/create_unit_test_files.sh (100%) rename {s3/s3_transport/unit_tests => unit_tests}/src/main.cpp (100%) rename {s3/s3_transport/unit_tests => unit_tests}/src/test_s3_transport.cpp (99%) rename {s3/s3_transport/unit_tests => unit_tests}/unit_tests_list.json (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d0ce4dc..0ba65d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,17 +10,17 @@ set(IRODS_PACKAGE_REVISION "0") include(IrodsCXXCompiler) set(CMAKE_CXX_STANDARD ${IRODS_CXX_STANDARD}) +set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--export-dynamic -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs") set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc") set(CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc") -set(CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc") include(IrodsRunpathDefaults) project(irods_resource_plugin-s3 VERSION "${IRODS_PLUGIN_VERSION}" LANGUAGES C CXX) -include(${IRODS_TARGETS_PATH}) +include("${IRODS_TARGETS_PATH}") include(GNUInstallDirs) @@ -45,6 +45,10 @@ endif() add_compile_options(-Wall -Wextra) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options($<$:-fpermissive>) +endif() + if (NOT DEFINED THREADS_PREFER_PTHREAD_FLAG) set(THREADS_PREFER_PTHREAD_FLAG TRUE) endif() @@ -55,147 +59,43 @@ find_package(fmt "8.1.1" find_package(CURL REQUIRED) find_package(OpenSSL REQUIRED) find_package(LibXml2 REQUIRED) - include(ObjectTargetHelpers) -add_library( - libs3_obj - OBJECT - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/bucket.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/bucket_metadata.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/error_parser.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/general.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/multipart.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/object.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/request.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/request_context.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/response_headers_handler.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/service.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/service_access_logging.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/simplexml.c" - "${CMAKE_CURRENT_SOURCE_DIR}/libs3/src/util.c" -) -target_link_libraries( - libs3_obj - PUBLIC - CURL::libcurl - LibXml2::LibXml2 - OpenSSL::Crypto - Threads::Threads -) -target_include_directories( - libs3_obj - PUBLIC - "$" -) -target_compile_definitions( - libs3_obj - PRIVATE - LIBS3_VER_MAJOR="4" - LIBS3_VER_MINOR="1" - __STRICT_ANSI__ - _ISOC99_SOURCE - _POSIX_C_SOURCE=200112L - OPENSSL_API_COMPAT=10100 -) -target_compile_options(libs3_obj PRIVATE -Wshadow) -set_target_properties(libs3_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -set_target_properties(libs3_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE) -set_target_properties(libs3_obj PROPERTIES EXCLUDE_FROM_ALL TRUE) +add_subdirectory(libs3) +add_subdirectory(s3_transport) +add_subdirectory(s3_resource) +add_subdirectory(unit_tests) -add_library( - irods_s3_plugin - MODULE - ${CMAKE_SOURCE_DIR}/s3/libirods_s3.cpp - ${CMAKE_SOURCE_DIR}/s3/s3_operations.cpp - ${CMAKE_SOURCE_DIR}/s3/s3_transport/src/s3_transport.cpp - ) -target_link_objects(irods_s3_plugin PRIVATE libs3_obj) -target_link_libraries( - irods_s3_plugin - PRIVATE - irods_server - irods_common - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_thread.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so - Threads::Threads - nlohmann_json::nlohmann_json - fmt::fmt - rt - ) -target_include_directories( +add_library(irods_s3_plugin MODULE) +target_link_objects( irods_s3_plugin PRIVATE - ${IRODS_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/s3/s3_transport/include - ${IRODS_EXTERNALS_FULLPATH_BOOST}/include - ${IRODS_EXTERNALS_FULLPATH_S3}/include - ) -target_compile_definitions( - irods_s3_plugin - PRIVATE - IRODS_QUERY_ENABLE_SERVER_SIDE_API - IRODS_ENABLE_SYSLOG - ${IRODS_COMPILE_DEFINITIONS} - ${IRODS_COMPILE_DEFINITIONS_PRIVATE} - BOOST_SYSTEM_NO_DEPRECATED - ) + libs3_obj + s3_transport_obj + s3_resource_obj +) set_property(TARGET irods_s3_plugin PROPERTY OUTPUT_NAME s3) -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(irods_s3_plugin PRIVATE $<$:-fpermissive>) -endif() - -target_compile_options(irods_s3_plugin PRIVATE -Wno-unused-parameter) - -# due to OPENSSL_NO_DEPRECATED_1_1_0 -target_compile_options(irods_s3_plugin PRIVATE -Wno-unused-function) - -include(CheckCXXCompilerFlag) - -# due to boost headers -check_cxx_compiler_flag(-Wno-error=deprecated-copy CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) -if (CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) - target_compile_options(irods_s3_plugin PRIVATE $<$:-Wno-error=deprecated-copy>) -endif() - install( TARGETS irods_s3_plugin LIBRARY - DESTINATION ${IRODS_PLUGINS_DIRECTORY}/resources - ) + DESTINATION "${IRODS_PLUGINS_DIRECTORY}/resources" +) install( FILES - ${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3.py - ${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_minio.py - ${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_ceph.py - ${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_gcs.py - ${CMAKE_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_fujifilm.py - ${CMAKE_SOURCE_DIR}/packaging/resource_suite_s3_nocache.py - ${CMAKE_SOURCE_DIR}/packaging/resource_suite_s3_cache.py - ${CMAKE_SOURCE_DIR}/packaging/s3plugin_lib.py - DESTINATION ${IRODS_HOME_DIRECTORY}/scripts/irods/test + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_minio.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_ceph.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_gcs.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_irods_resource_plugin_s3_fujifilm.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/resource_suite_s3_nocache.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/resource_suite_s3_cache.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/s3plugin_lib.py" + DESTINATION "${IRODS_HOME_DIRECTORY}/scripts/irods/test" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - ) - -if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "ubuntu" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "debian") - if (NOT IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME) - execute_process( - COMMAND "lsb_release" "-s" "-c" - RESULT_VARIABLE IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME - OUTPUT_VARIABLE IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME - ) - string(STRIP ${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME} IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME) - if (NOT ${IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME} STREQUAL "0") - message(FATAL_ERROR "Linux lsb_release shortname detection failed\n${IRODS_PLUGIN_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME}") - endif() - set(IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME ${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME} CACHE STRING "Linux distribution version codename, e.g. {precise, wheezy, trusty, jessie, ...}." FORCE) - message(STATUS "Setting unspecified IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME to '${IRODS_PLUGIN_LINUX_DISTRIBUTION_VERSION_CODENAME}'") - endif() -endif() +) if (NOT CPACK_GENERATOR) set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE) @@ -205,6 +105,8 @@ endif() include(IrodsCPackCommon) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}/resources") list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts") list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods") list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods/test") @@ -257,9 +159,9 @@ endif () set(CPACK_RPM_PACKAGE_NAME "irods-resource-plugin-s3") if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "opensuse") - set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, curl-devel, libopenssl1_0_0") + set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, libcurl, libopenssl1_0_0") else() - set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, curl-devel, libxml2") + set(CPACK_RPM_PACKAGE_REQUIRES "irods-runtime = ${IRODS_VERSION}, libcurl, libxml2") endif() include(CPack) diff --git a/libs3/CMakeLists.txt b/libs3/CMakeLists.txt new file mode 100644 index 00000000..9e7e4031 --- /dev/null +++ b/libs3/CMakeLists.txt @@ -0,0 +1,49 @@ +add_library( + libs3_obj + OBJECT + "${CMAKE_CURRENT_SOURCE_DIR}/src/bucket.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/bucket_metadata.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/error_parser.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/general.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/multipart.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/object.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/request.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/request_context.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/response_headers_handler.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/service.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/service_access_logging.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/simplexml.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/util.c" +) +target_link_libraries( + libs3_obj + PUBLIC + CURL::libcurl + LibXml2::LibXml2 + OpenSSL::Crypto +) +target_include_directories( + libs3_obj + PUBLIC + "$" +) +target_compile_definitions( + libs3_obj + PRIVATE + LIBS3_VER_MAJOR="4" + LIBS3_VER_MINOR="1" + __STRICT_ANSI__ + _ISOC99_SOURCE + _POSIX_C_SOURCE=200112L + OPENSSL_API_COMPAT=10100 +) +target_compile_options( + libs3_obj + PRIVATE + -Wshadow + -Wno-unused-function # due to OPENSSL_NO_DEPRECATED_1_1_0 +) +set_target_properties(libs3_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +set_target_properties(libs3_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE) + +set_target_properties(libs3_obj PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/s3/s3_transport/read_shared_memory.cpp b/s3/s3_transport/read_shared_memory.cpp deleted file mode 100644 index dae8bb31..00000000 --- a/s3/s3_transport/read_shared_memory.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// stdlib and misc includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// boost includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// local includes -#include "s3_multipart_shared_data.hpp" -#include "managed_shared_memory_object.hpp" -#include "s3_transport_util.hpp" -#include "s3_transport_types.hpp" -#include "s3_transport_callbacks.hpp" - -int main(int argc, char **argv) { - - using named_shared_memory_object = - irods::experimental::interprocess::shared_memory::named_shared_memory_object - ; - - if (argc != 2) { - fprintf(stderr, "Need shmem key\n"); - return 0; - } - - const char *key = argv[1]; - - named_shared_memory_object shm_obj{key, 60, - irods::experimental::io::s3_transport::constants::MAX_S3_SHMEM_SIZE}; - - shm_obj.atomic_exec([](auto& data) - { - printf("[threads_remaining_to_close=%d][upload_id=%s][last_error_code=%d][cache_file_download_progress=%d]" - "[ref_count=%d]\n", data.threads_remaining_to_close, data.upload_id.c_str(), data.last_error_code, - data.cache_file_download_progress, data.ref_count); - }); - - return 0; -} - diff --git a/s3/s3_transport/unit_tests/CMakeLists.txt b/s3/s3_transport/unit_tests/CMakeLists.txt deleted file mode 100644 index 785214db..00000000 --- a/s3/s3_transport/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,131 +0,0 @@ -cmake_minimum_required(VERSION ${CMAKE_VERSION}) -project(unit_tests LANGUAGES C CXX) - -find_package(IRODS 4.3.0 EXACT REQUIRED) - -include(IrodsExternals) - -IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(S3 libs3e4674774-0) - -message(STATUS "CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}") -message(STATUS "IRODS_EXTERNALS_FULLPATH_S3=${IRODS_EXTERNALS_FULLPATH_S3}") -message(STATUS "IRODS_CXX_STANDARD=${IRODS_CXX_STANDARD}") - -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE) - message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'. This is the correct setting for normal builds.") -endif() - -if (NOT IRODS_EXTERNALS_PACKAGE_ROOT) - set(IRODS_EXTERNALS_PACKAGE_ROOT "/opt/irods-externals" CACHE STRING "Choose the location of iRODS external packages." FORCE) - message(STATUS "Setting unspecified IRODS_EXTERNALS_PACKAGE_ROOT to '${IRODS_EXTERNALS_PACKAGE_ROOT}'. This is the correct setting for normal builds.") -endif() - -macro(IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH DEPENDENCY_NAME DEPENDENCY_SUBDIRECTORY) - if (IS_DIRECTORY ${IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}}) - message(STATUS "Using user-specified value for IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}: ${IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}}") - else() - if (NOT IS_DIRECTORY ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY}) - message(FATAL_ERROR "${DEPENDENCY_NAME} not found at ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY}") - endif() - set(IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME} ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY}) - endif() -endmacro() - -macro(IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST DEPENDENCY_NAME DEPENDENCY_SUBDIRECTORY) - IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH(${DEPENDENCY_NAME} ${DEPENDENCY_SUBDIRECTORY}) - list(APPEND IRODS_PACKAGE_DEPENDENCIES_LIST irods-externals-${DEPENDENCY_SUBDIRECTORY}) -endmacro() - -set(BUILD_UNIT_TESTS YES CACHE BOOL "Build unit tests") -set(UNIT_TESTS_RUN_AFTER_BUILD NO CACHE BOOL "Run after building unit tests") -set(UNIT_TESTS_REPORTING_STYLE "junit" CACHE STRING "The style of output used for unit test reporting [console, compact, junit, xml]") -set(UNIT_TESTS_REPORT_FILENAME "report.xml" CACHE STRING "The filename of the unit test report") - -if (NOT BUILD_UNIT_TESTS) - message(STATUS "NOT BUILD UNIT TESTS") - return() -endif() - -IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(CATCH2 catch22.3.0-0) -string(REPLACE ";" ", " IRODS_PACKAGE_DEPENDENCIES_STRING "${IRODS_PACKAGE_DEPENDENCIES_LIST}") - -set(CMAKE_C_COMPILER ${IRODS_EXTERNALS_FULLPATH_CLANG}/bin/clang) -set(CMAKE_CXX_COMPILER ${IRODS_EXTERNALS_FULLPATH_CLANG}/bin/clang++) -set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") -set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -stdlib=libc++ -Wl,-z,defs") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++ -Wl,-z,defs") - -add_compile_options(-nostdinc++ -Wall -Wextra -Werror) -add_compile_options(-Wno-unused-parameter) # Until fix of irods_re_plugin.hpp -add_compile_options(-Wno-unneeded-internal-declaration) # Until fix of https://github.com/irods/irods/issues/3396 - -add_compile_definitions(PRIVATE - SPDLOG_FMT_EXTERNAL) - -link_libraries(c++abi - curl - xml2 - crypto - pthread - irods_server - irods_common - ${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so) - -include_directories(${IRODS_INCLUDE_DIRS} - ${IRODS_EXTERNALS_FULLPATH_CLANG}/include/c++/v1 - ${IRODS_EXTERNALS_FULLPATH_JSON}/include - ${IRODS_EXTERNALS_FULLPATH_SPDLOG}/include - ${IRODS_EXTERNALS_FULLPATH_FMT}/include) - -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -set(CMAKE_INSTALL_RPATH ${IRODS_EXTERNALS_FULLPATH_CLANG_RUNTIME}/lib) -set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - -# Enable CTest support. -enable_testing() - -set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - -# Update the CMake module path so that the test compilation variables -# can be found. Prepends the new path to the beginning of the list. -list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -# Include helper functions and other utilities. - -if (UNIT_TESTS_RUN_AFTER_BUILD) - set(TEST_RUNNER_ARGS -r ${UNIT_TESTS_REPORTING_STYLE} - -o ${UNIT_TESTS_REPORT_FILENAME}) -endif() - -# List of cmake files defined under ./cmake/test_config. -# Each file in the ./cmake/test_config directory defines variables for a specific test. -# New tests should be added to this list. -set(TEST_INCLUDE_LIST test_config/irods_s3_transport - ) - -foreach(IRODS_TEST_CONFIG ${TEST_INCLUDE_LIST}) - #unset_irods_test_variables() - - include(${IRODS_TEST_CONFIG}) - add_executable(${IRODS_TEST_TARGET} ${IRODS_TEST_SOURCE_FILES}) - set_property(TARGET ${IRODS_TEST_TARGET} PROPERTY CXX_STANDARD ${IRODS_CXX_STANDARD}) - target_include_directories(${IRODS_TEST_TARGET} PRIVATE ${IRODS_TEST_INCLUDE_PATH}) - target_link_libraries(${IRODS_TEST_TARGET} PRIVATE ${IRODS_TEST_LINK_LIBRARIES}) - - # ======================= - # Post Build Instructions - # ======================= - - if (UNIT_TESTS_RUN_AFTER_BUILD) - # Run the test immediately following successful compilation. - add_custom_command(TARGET ${IRODS_TEST_TARGET} - POST_BUILD - COMMAND ${IRODS_TEST_TARGET} ${TEST_RUNNER_ARGS}) - endif() - - # Make the new test available to CTest. - add_test(NAME ${IRODS_TEST_TARGET} COMMAND ${IRODS_TEST_TARGET} ${TEST_RUNNER_ARGS}) -endforeach() - diff --git a/s3/s3_transport/unit_tests/cmake/test_config/irods_s3_transport.cmake b/s3/s3_transport/unit_tests/cmake/test_config/irods_s3_transport.cmake deleted file mode 100644 index ec99fa17..00000000 --- a/s3/s3_transport/unit_tests/cmake/test_config/irods_s3_transport.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(IRODS_TEST_TARGET irods_s3_transport) - -set(IRODS_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/test_s3_transport.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../src/s3_transport.cpp) - - set(IRODS_TEST_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${IRODS_EXTERNALS_FULLPATH_CATCH2}/include - ${IRODS_EXTERNALS_FULLPATH_BOOST}/include - ${IRODS_EXTERNALS_FULLPATH_JSON}/include - ${IRODS_EXTERNALS_FULLPATH_S3}/include - /usr/include/libxml2 - ${IRODS_INCLUDE_DIRS} - ) - -set(IRODS_TEST_LINK_LIBRARIES irods_common - irods_client - c++abi - rt - ${IRODS_EXTERNALS_FULLPATH_S3}/lib/libs3.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_thread.so - ) diff --git a/s3_resource/CMakeLists.txt b/s3_resource/CMakeLists.txt new file mode 100644 index 00000000..0915aa25 --- /dev/null +++ b/s3_resource/CMakeLists.txt @@ -0,0 +1,55 @@ +include(ObjectTargetHelpers) + +add_library( + s3_resource_obj + OBJECT + "${CMAKE_CURRENT_SOURCE_DIR}/src/s3_resource.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/s3_operations.cpp" +) +target_link_objects( + s3_resource_obj + PUBLIC + libs3_obj + s3_transport_obj +) +target_link_libraries( + s3_resource_obj + PUBLIC + irods_common + irods_server + fmt::fmt + Threads::Threads + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_thread.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so" +) +target_include_directories( + s3_resource_obj + PUBLIC + "$" + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/include" +) +target_compile_definitions( + s3_resource_obj + PRIVATE + IRODS_QUERY_ENABLE_SERVER_SIDE_API + IRODS_ENABLE_SYSLOG + ${IRODS_COMPILE_DEFINITIONS} + ${IRODS_COMPILE_DEFINITIONS_PRIVATE} + BOOST_SYSTEM_NO_DEPRECATED +) + +include(CheckCXXCompilerFlag) + +# due to boost headers +check_cxx_compiler_flag(-Wno-error=deprecated-copy CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) +if (CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) + target_compile_options(s3_resource_obj PRIVATE $<$:-Wno-error=deprecated-copy>) +endif() + +set_target_properties(s3_resource_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +set_target_properties(s3_resource_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE) + +set_target_properties(s3_resource_obj PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/s3/s3_operations.hpp b/s3_resource/include/irods/private/s3_resource/s3_operations.hpp similarity index 98% rename from s3/s3_operations.hpp rename to s3_resource/include/irods/private/s3_resource/s3_operations.hpp index 672e0a81..3381cf3d 100644 --- a/s3/s3_operations.hpp +++ b/s3_resource/include/irods/private/s3_resource/s3_operations.hpp @@ -1,5 +1,5 @@ -#ifndef _IRODS_S3_CACHELESS_OPERATIONS_H -#define _IRODS_S3_CACHELESS_OPERATIONS_H +#ifndef IRODS_S3_RESOURCE_OPERATIONS_HPP +#define IRODS_S3_RESOURCE_OPERATIONS_HPP // =-=-=-=-=-=-=- // irods includes diff --git a/s3/s3_plugin_logging_category.hpp b/s3_resource/include/irods/private/s3_resource/s3_plugin_logging_category.hpp similarity index 87% rename from s3/s3_plugin_logging_category.hpp rename to s3_resource/include/irods/private/s3_resource/s3_plugin_logging_category.hpp index faf96226..dfe482df 100644 --- a/s3/s3_plugin_logging_category.hpp +++ b/s3_resource/include/irods/private/s3_resource/s3_plugin_logging_category.hpp @@ -1,8 +1,8 @@ -#ifndef S3_PLUGIN_LOGGING_CATEGORY_HPP -#define S3_PLUGIN_LOGGING_CATEGORY_HPP +#ifndef IRODS_S3_RESOURCE_PLUGIN_LOGGING_CATEGORY_HPP +#define IRODS_S3_RESOURCE_PLUGIN_LOGGING_CATEGORY_HPP -#include "irods/irods_logger.hpp" +#include // 1. Declare the custom category tag. // This structure does not need to define a body. @@ -41,4 +41,4 @@ namespace irods::experimental } // namespace irods::experimental -#endif //S3_PLUGIN_LOGGING_CATEGORY_HPP +#endif //IRODS_S3_RESOURCE_PLUGIN_LOGGING_CATEGORY_HPP diff --git a/s3/libirods_s3.hpp b/s3_resource/include/irods/private/s3_resource/s3_resource.hpp similarity index 99% rename from s3/libirods_s3.hpp rename to s3_resource/include/irods/private/s3_resource/s3_resource.hpp index 37364e68..f7945ccf 100644 --- a/s3/libirods_s3.hpp +++ b/s3_resource/include/irods/private/s3_resource/s3_resource.hpp @@ -1,7 +1,7 @@ /* -*- mode: c++; fill-column: 132; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -#ifndef _LIBIRODS_S3_HPP_ -#define _LIBIRODS_S3_HPP_ +#ifndef IRODS_S3_RESOURCE_HPP +#define IRODS_S3_RESOURCE_HPP // Needed to support pread with > 2GB offsets #define _USE_FILE_OFFSET64 diff --git a/s3/s3_operations.cpp b/s3_resource/src/s3_operations.cpp similarity index 99% rename from s3/s3_operations.cpp rename to s3_resource/src/s3_operations.cpp index dd403b41..98f5134f 100644 --- a/s3/s3_operations.cpp +++ b/s3_resource/src/s3_operations.cpp @@ -1,9 +1,9 @@ // =-=-=-=-=-=-=- // local includes -#include "s3_operations.hpp" -#include "libirods_s3.hpp" -#include "s3_transport.hpp" -#include "s3_plugin_logging_category.hpp" +#include "irods/private/s3_resource/s3_operations.hpp" +#include "irods/private/s3_resource/s3_resource.hpp" +#include "irods/private/s3_transport/s3_transport.hpp" +#include "irods/private/s3_resource/s3_plugin_logging_category.hpp" // =-=-=-=-=-=-=- // irods includes diff --git a/s3/libirods_s3.cpp b/s3_resource/src/s3_resource.cpp similarity index 99% rename from s3/libirods_s3.cpp rename to s3_resource/src/s3_resource.cpp index 96567ece..5ef358cd 100644 --- a/s3/libirods_s3.cpp +++ b/s3_resource/src/s3_resource.cpp @@ -1,10 +1,10 @@ // =-=-=-=-=-=-=- // local includes -#include "libirods_s3.hpp" -#include "s3_operations.hpp" -#include "s3_plugin_logging_category.hpp" -#include "s3_transport/include/s3_transport_logging_category.hpp" -#include "s3_transport/include/s3_transport.hpp" +#include "irods/private/s3_resource/s3_resource.hpp" +#include "irods/private/s3_resource/s3_operations.hpp" +#include "irods/private/s3_resource/s3_plugin_logging_category.hpp" +#include "irods/private/s3_transport/logging_category.hpp" +#include "irods/private/s3_transport/s3_transport.hpp" // =-=-=-=-=-=-=- // irods includes diff --git a/s3_transport/CMakeLists.txt b/s3_transport/CMakeLists.txt new file mode 100644 index 00000000..830f6019 --- /dev/null +++ b/s3_transport/CMakeLists.txt @@ -0,0 +1,53 @@ +include(ObjectTargetHelpers) + +add_library( + s3_transport_obj + OBJECT + "${CMAKE_CURRENT_SOURCE_DIR}/src/s3_transport.cpp" +) +target_link_objects( + s3_transport_obj + PUBLIC + libs3_obj +) +target_link_libraries( + s3_transport_obj + PUBLIC + irods_common + irods_server + nlohmann_json::nlohmann_json + fmt::fmt + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so" +) +target_include_directories( + s3_transport_obj + PUBLIC + "$" + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/include" +) +target_compile_definitions( + s3_transport_obj + PRIVATE + IRODS_ENABLE_SYSLOG + ${IRODS_COMPILE_DEFINITIONS} + ${IRODS_COMPILE_DEFINITIONS_PRIVATE} + BOOST_SYSTEM_NO_DEPRECATED +) + +target_compile_options(s3_transport_obj PUBLIC -Wno-unused-parameter) + +include(CheckCXXCompilerFlag) + +# due to boost headers +check_cxx_compiler_flag(-Wno-error=deprecated-copy CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) +if (CMAKE_CXX_COMPILER_W_DEPRECATED_COPY) + target_compile_options(s3_transport_obj PRIVATE $<$:-Wno-error=deprecated-copy>) +endif() + +set_target_properties(s3_transport_obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +set_target_properties(s3_transport_obj PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE TRUE) + +set_target_properties(s3_transport_obj PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/s3/s3_transport/include/s3_transport_callbacks.hpp b/s3_transport/include/irods/private/s3_transport/callbacks.hpp similarity index 99% rename from s3/s3_transport/include/s3_transport_callbacks.hpp rename to s3_transport/include/irods/private/s3_transport/callbacks.hpp index 61909754..54dc3801 100644 --- a/s3/s3_transport/include/s3_transport_callbacks.hpp +++ b/s3_transport/include/irods/private/s3_transport/callbacks.hpp @@ -30,11 +30,11 @@ #include // local includes -#include "circular_buffer.hpp" -#include "managed_shared_memory_object.hpp" -#include "s3_multipart_shared_data.hpp" -#include "s3_transport_types.hpp" -#include "s3_transport_logging_category.hpp" +#include "irods/private/s3_transport/circular_buffer.hpp" +#include "irods/private/s3_transport/managed_shared_memory_object.hpp" +#include "irods/private/s3_transport/multipart_shared_data.hpp" +#include "irods/private/s3_transport/types.hpp" +#include "irods/private/s3_transport/logging_category.hpp" namespace irods::experimental::io::s3_transport { diff --git a/s3/s3_transport/include/circular_buffer.hpp b/s3_transport/include/irods/private/s3_transport/circular_buffer.hpp similarity index 98% rename from s3/s3_transport/include/circular_buffer.hpp rename to s3_transport/include/irods/private/s3_transport/circular_buffer.hpp index bb6ca0dc..695ba507 100644 --- a/s3/s3_transport/include/circular_buffer.hpp +++ b/s3_transport/include/irods/private/s3_transport/circular_buffer.hpp @@ -2,7 +2,7 @@ #define IRODS_RING_BUFFER_HPP #include -#include "lock_and_wait_strategy.hpp" +#include "irods/private/s3_transport/lock_and_wait_strategy.hpp" #include namespace irods { diff --git a/s3/s3_transport/include/lock_and_wait_strategy.hpp b/s3_transport/include/irods/private/s3_transport/lock_and_wait_strategy.hpp similarity index 100% rename from s3/s3_transport/include/lock_and_wait_strategy.hpp rename to s3_transport/include/irods/private/s3_transport/lock_and_wait_strategy.hpp diff --git a/s3/s3_transport/include/s3_transport_logging_category.hpp b/s3_transport/include/irods/private/s3_transport/logging_category.hpp similarity index 97% rename from s3/s3_transport/include/s3_transport_logging_category.hpp rename to s3_transport/include/irods/private/s3_transport/logging_category.hpp index e317c15a..e986ab85 100644 --- a/s3/s3_transport/include/s3_transport_logging_category.hpp +++ b/s3_transport/include/irods/private/s3_transport/logging_category.hpp @@ -1,7 +1,7 @@ #ifndef S3_TRANSPORT_LOGGING_CATEGORY_HPP #define S3_TRANSPORT_LOGGING_CATEGORY_HPP -#include "irods/irods_logger.hpp" +#include // 1. Declare the custom category tag. // This structure does not need to define a body. diff --git a/s3/s3_transport/include/managed_shared_memory_object.hpp b/s3_transport/include/irods/private/s3_transport/managed_shared_memory_object.hpp similarity index 95% rename from s3/s3_transport/include/managed_shared_memory_object.hpp rename to s3_transport/include/irods/private/s3_transport/managed_shared_memory_object.hpp index e0e38202..63726f10 100644 --- a/s3/s3_transport/include/managed_shared_memory_object.hpp +++ b/s3_transport/include/irods/private/s3_transport/managed_shared_memory_object.hpp @@ -1,5 +1,5 @@ -#ifndef MANAGED_SHARED_MEMORY_OBJECT_HPP -#define MANAGED_SHARED_MEMORY_OBJECT_HPP +#ifndef S3_TRANSPORT_MANAGED_SHARED_MEMORY_OBJECT_HPP +#define S3_TRANSPORT_MANAGED_SHARED_MEMORY_OBJECT_HPP #include @@ -9,7 +9,7 @@ #include #include -#include "s3_transport_logging_category.hpp" +#include "irods/private/s3_transport/logging_category.hpp" namespace irods::experimental::interprocess { @@ -156,4 +156,4 @@ namespace irods::experimental::interprocess } // namespace shared_memory } // namespace irods::experimental::ipc -#endif // MANAGED_SHARED_MEMORY_OBJECT_HPP +#endif // S3_TRANSPORT_MANAGED_SHARED_MEMORY_OBJECT_HPP diff --git a/s3/s3_transport/include/s3_multipart_shared_data.hpp b/s3_transport/include/irods/private/s3_transport/multipart_shared_data.hpp similarity index 95% rename from s3/s3_transport/include/s3_multipart_shared_data.hpp rename to s3_transport/include/irods/private/s3_transport/multipart_shared_data.hpp index fc8cfa37..d0189aef 100644 --- a/s3/s3_transport/include/s3_multipart_shared_data.hpp +++ b/s3_transport/include/irods/private/s3_transport/multipart_shared_data.hpp @@ -1,5 +1,5 @@ -#ifndef S3_MULTIPART_TEST_SHARED_DATA -#define S3_MULTIPART_TEST_SHARED_DATA +#ifndef S3_TRANSPORT_MULTIPART_SHARED_DATA_HPP +#define S3_TRANSPORT_MULTIPART_SHARED_DATA_HPP #include #include @@ -12,7 +12,7 @@ #include #include -#include "s3_transport_types.hpp" +#include "irods/private/s3_transport/types.hpp" namespace irods::experimental::io::s3_transport::shared_data { @@ -94,4 +94,4 @@ namespace irods::experimental::io::s3_transport::shared_data -#endif // S3_MULTIPART_TEST_SHARED_DATA +#endif // S3_TRANSPORT_MULTIPART_SHARED_DATA_HPP diff --git a/s3/s3_transport/include/s3_transport.hpp b/s3_transport/include/irods/private/s3_transport/s3_transport.hpp similarity index 99% rename from s3/s3_transport/include/s3_transport.hpp rename to s3_transport/include/irods/private/s3_transport/s3_transport.hpp index 58820450..f055e06e 100644 --- a/s3/s3_transport/include/s3_transport.hpp +++ b/s3_transport/include/irods/private/s3_transport/s3_transport.hpp @@ -1,7 +1,7 @@ #ifndef S3_TRANSPORT_HPP #define S3_TRANSPORT_HPP -#include "circular_buffer.hpp" +#include "irods/private/s3_transport/circular_buffer.hpp" // iRODS includes #include @@ -44,11 +44,11 @@ #include // local includes -#include "s3_multipart_shared_data.hpp" -#include "s3_transport_types.hpp" -#include "s3_transport_util.hpp" -#include "s3_transport_callbacks.hpp" -#include "s3_transport_logging_category.hpp" +#include "irods/private/s3_transport/multipart_shared_data.hpp" +#include "irods/private/s3_transport/types.hpp" +#include "irods/private/s3_transport/util.hpp" +#include "irods/private/s3_transport/callbacks.hpp" +#include "irods/private/s3_transport/logging_category.hpp" extern const unsigned int S3_DEFAULT_NON_DATA_TRANSFER_TIMEOUT_SECONDS; diff --git a/s3/s3_transport/include/s3_transport_types.hpp b/s3_transport/include/irods/private/s3_transport/types.hpp similarity index 95% rename from s3/s3_transport/include/s3_transport_types.hpp rename to s3_transport/include/irods/private/s3_transport/types.hpp index f66652ec..9cbfd6d9 100644 --- a/s3/s3_transport/include/s3_transport_types.hpp +++ b/s3_transport/include/irods/private/s3_transport/types.hpp @@ -1,7 +1,7 @@ #ifndef S3_TRANSPORT_TYPES_HPP #define S3_TRANSPORT_TYPES_HPP -#include "circular_buffer.hpp" +#include "irods/private/s3_transport/circular_buffer.hpp" #include "libs3/libs3.h" namespace irods::experimental::io::s3_transport diff --git a/s3/s3_transport/include/s3_transport_util.hpp b/s3_transport/include/irods/private/s3_transport/util.hpp similarity index 97% rename from s3/s3_transport/include/s3_transport_util.hpp rename to s3_transport/include/irods/private/s3_transport/util.hpp index c3c5583b..5a113b59 100644 --- a/s3/s3_transport/include/s3_transport_util.hpp +++ b/s3_transport/include/irods/private/s3_transport/util.hpp @@ -1,7 +1,7 @@ #ifndef S3_TRANSPORT_UTIL_HPP #define S3_TRANSPORT_UTIL_HPP -#include "circular_buffer.hpp" +#include "irods/private/s3_transport/circular_buffer.hpp" // iRODS includes #include @@ -38,9 +38,9 @@ #include // local includes -#include "s3_multipart_shared_data.hpp" +#include "irods/private/s3_transport/multipart_shared_data.hpp" -#include "s3_transport_types.hpp" +#include "irods/private/s3_transport/types.hpp" namespace irods::experimental::io::s3_transport { diff --git a/s3/s3_transport/src/s3_transport.cpp b/s3_transport/src/s3_transport.cpp similarity index 99% rename from s3/s3_transport/src/s3_transport.cpp rename to s3_transport/src/s3_transport.cpp index 34b7e51c..8d038c48 100644 --- a/s3/s3_transport/src/s3_transport.cpp +++ b/s3_transport/src/s3_transport.cpp @@ -1,4 +1,4 @@ -#include "circular_buffer.hpp" +#include "irods/private/s3_transport/circular_buffer.hpp" // iRODS includes #include @@ -35,9 +35,9 @@ #include // local includes -#include "s3_multipart_shared_data.hpp" -#include "s3_transport.hpp" -#include "s3_transport_logging_category.hpp" +#include "irods/private/s3_transport/multipart_shared_data.hpp" +#include "irods/private/s3_transport/s3_transport.hpp" +#include "irods/private/s3_transport/logging_category.hpp" namespace irods::experimental::io::s3_transport diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt new file mode 100644 index 00000000..483da4df --- /dev/null +++ b/unit_tests/CMakeLists.txt @@ -0,0 +1,56 @@ +set(IRODS_UNIT_TESTS_BUILD NO CACHE BOOL "Build unit tests") +set(IRODS_UNIT_TESTS_REPORTING_STYLE "junit" CACHE STRING "The style of output used for unit test reporting [console, compact, junit, xml]") +set(IRODS_UNIT_TESTS_REPORT_FILENAME "report.xml" CACHE STRING "The filename of the unit test report") + +if (DEFINED IRODS_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH_INIT) + set(DEFAULT_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH ${IRODS_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH_INIT}) +else() + set(DEFAULT_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH YES) +endif() +set(IRODS_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH "${DEFAULT_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH}" CACHE BOOL "Build unit tests with install RPATH/RUNPATH") + +if (NOT IRODS_UNIT_TESTS_BUILD) + return() +endif() + +find_package(Catch2 "2.3.0" REQUIRED) + +# create phony target to build all unit tests +add_custom_target(all-unit_tests) + +# Enable CTest support. +enable_testing() + +# Include helper functions and other utilities. +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake") + +# Each file in the ./cmake/test_config directory defines variables for a specific test. +# New tests should be added to this list. +set( + IRODS_PLUGIN_UNIT_TESTS + s3_transport +) + +foreach(test IN LISTS IRODS_PLUGIN_UNIT_TESTS) + unset_irods_test_variables() + + include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_config/irods_${test}.cmake") + add_executable(${IRODS_TEST_TARGET} ${IRODS_TEST_SOURCE_FILES}) + target_compile_definitions(${IRODS_TEST_TARGET} PRIVATE ${IRODS_COMPILE_DEFINITIONS_PRIVATE}) + if (DEFINED IRODS_TEST_LINK_OBJLIBRARIES) + target_link_objects(${IRODS_TEST_TARGET} PRIVATE ${IRODS_TEST_LINK_OBJLIBRARIES}) + endif() + target_link_libraries(${IRODS_TEST_TARGET} PRIVATE Catch2::Catch2 ${IRODS_TEST_LINK_LIBRARIES}) + if (DEFINED IRODS_TEST_INCLUDE_PATH) + target_include_directories(${IRODS_TEST_TARGET} PRIVATE ${IRODS_TEST_INCLUDE_PATH}) + endif() + set_property(TARGET ${IRODS_TEST_TARGET} PROPERTY BUILD_WITH_INSTALL_RPATH ${IRODS_UNIT_TESTS_BUILD_WITH_INSTALL_RPATH}) + if (IRODS_UNIT_TESTS_ENABLE_ALL) + target_compile_definitions(${IRODS_TEST_TARGET} PRIVATE IRODS_ENABLE_ALL_UNIT_TESTS) + endif() + + add_dependencies(all-unit_tests ${IRODS_TEST_TARGET}) + + # Make the new test available to CTest. + add_test(NAME ${IRODS_TEST_TARGET} COMMAND ${IRODS_TEST_TARGET} -r ${IRODS_UNIT_TESTS_REPORTING_STYLE} -o ${IRODS_UNIT_TESTS_REPORT_FILENAME}) +endforeach() diff --git a/unit_tests/cmake/test_config/irods_s3_transport.cmake b/unit_tests/cmake/test_config/irods_s3_transport.cmake new file mode 100644 index 00000000..9d1d8bb6 --- /dev/null +++ b/unit_tests/cmake/test_config/irods_s3_transport.cmake @@ -0,0 +1,13 @@ +set(IRODS_TEST_TARGET irods_s3_transport) + +set(IRODS_TEST_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/test_s3_transport.cpp") + +set(IRODS_TEST_LINK_OBJLIBRARIES s3_transport_obj) + +set(IRODS_TEST_INCLUDE_PATH ${IRODS_EXTERNALS_FULLPATH_BOOST}/include) + +set(IRODS_TEST_LINK_LIBRARIES fmt::fmt + ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so + ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so + ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_thread.so) diff --git a/s3/s3_transport/unit_tests/cmake/utils.cmake b/unit_tests/cmake/utils.cmake similarity index 87% rename from s3/s3_transport/unit_tests/cmake/utils.cmake rename to unit_tests/cmake/utils.cmake index 305aa6af..a8bca093 100644 --- a/s3/s3_transport/unit_tests/cmake/utils.cmake +++ b/unit_tests/cmake/utils.cmake @@ -7,4 +7,5 @@ function(unset_irods_test_variables) unset(IRODS_TEST_SOURCE_FILES) unset(IRODS_TEST_INCLUDE_PATH) unset(IRODS_TEST_LINK_LIBRARIES) + unset(IRODS_TEST_LINK_OBJLIBRARIES) endfunction() diff --git a/s3/s3_transport/unit_tests/create_unit_test_files.sh b/unit_tests/create_unit_test_files.sh similarity index 100% rename from s3/s3_transport/unit_tests/create_unit_test_files.sh rename to unit_tests/create_unit_test_files.sh diff --git a/s3/s3_transport/unit_tests/src/main.cpp b/unit_tests/src/main.cpp similarity index 100% rename from s3/s3_transport/unit_tests/src/main.cpp rename to unit_tests/src/main.cpp diff --git a/s3/s3_transport/unit_tests/src/test_s3_transport.cpp b/unit_tests/src/test_s3_transport.cpp similarity index 99% rename from s3/s3_transport/unit_tests/src/test_s3_transport.cpp rename to unit_tests/src/test_s3_transport.cpp index 69b0f355..ff5b39cb 100644 --- a/s3/s3_transport/unit_tests/src/test_s3_transport.cpp +++ b/unit_tests/src/test_s3_transport.cpp @@ -1,8 +1,8 @@ #include -#include "s3_transport.hpp" -#include "s3_transport_util.hpp" -#include "s3_multipart_shared_data.hpp" +#include "irods/private/s3_transport/s3_transport.hpp" +#include "irods/private/s3_transport/util.hpp" +#include "irods/private/s3_transport/multipart_shared_data.hpp" #include #include #include @@ -19,7 +19,7 @@ #include #include #include -#include "../../include/s3_transport_logging_category.hpp" +#include "irods/private/s3_transport/logging_category.hpp" // to run the following unit tests, the aws command line utility needs to be available in // the path and "aws configure" needs to be run to set up the keys diff --git a/s3/s3_transport/unit_tests/unit_tests_list.json b/unit_tests/unit_tests_list.json similarity index 100% rename from s3/s3_transport/unit_tests/unit_tests_list.json rename to unit_tests/unit_tests_list.json