From bd8099f2101b9239cddfcbcea1ccf1ffc1f90bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:10 +0200 Subject: [PATCH 01/41] cmake: severly reduce use of include_directories in global context --- benchmarks/CMakeLists.txt | 3 +- benchmarks/benchmarks.c | 2 +- benchmarks/cmp.c | 2 +- benchmarks/createkeys.c | 2 +- benchmarks/deepdup.c | 2 +- benchmarks/diff.c | 3 +- benchmarks/kdb.c | 4 ++- benchmarks/kdbget.c | 4 ++- benchmarks/kdbmodify.c | 4 ++- benchmarks/large.c | 2 +- benchmarks/memoryleak.c | 5 +-- benchmarks/opmphm.c | 2 +- benchmarks/storage.c | 4 ++- examples/CMakeLists.txt | 9 ++--- scripts/cmake/Modules/LibAddLib.cmake | 1 + scripts/cmake/Modules/LibAddMacros.cmake | 7 ---- scripts/cmake/Modules/LibAddPlugin.cmake | 25 ++++++++++---- scripts/cmake/Modules/LibAddTest.cmake | 6 ++-- src/CMakeLists.txt | 11 +++++++ src/bindings/cpp/benchmarks/CMakeLists.txt | 2 +- src/bindings/cpp/examples/CMakeLists.txt | 2 +- src/bindings/cpp/tests/CMakeLists.txt | 3 +- src/bindings/cpp/tests/testcpp_iter.cpp | 2 +- src/bindings/cpp/tests/testcpp_iter_name.cpp | 2 +- src/bindings/cpp/tests/testcpp_kdb.cpp | 2 +- src/bindings/cpp/tests/testcpp_key.cpp | 2 +- src/bindings/cpp/tests/testcpp_keyio.cpp | 2 +- src/bindings/cpp/tests/testcpp_ks.cpp | 2 +- src/bindings/cpp/tests/testcpp_ksget.cpp | 2 +- src/bindings/cpp/tests/testcpp_meta.cpp | 2 +- src/bindings/cpp/tests/tests.cpp | 2 +- src/bindings/glib/tests/CMakeLists.txt | 2 ++ .../intercept/env/benchmarks/CMakeLists.txt | 2 +- .../intercept/env/examples/CMakeLists.txt | 2 +- src/bindings/intercept/env/src/CMakeLists.txt | 1 + src/bindings/io/doc/CMakeLists.txt | 4 +-- src/bindings/io/ev/CMakeLists.txt | 4 +-- src/bindings/io/ev/example/CMakeLists.txt | 2 +- src/bindings/io/glib/CMakeLists.txt | 4 +-- src/bindings/io/glib/example/CMakeLists.txt | 2 +- src/bindings/io/uv/CMakeLists.txt | 2 +- src/bindings/io/uv/example/CMakeLists.txt | 2 +- src/bindings/swig/lua/CMakeLists.txt | 4 +-- src/bindings/swig/python/CMakeLists.txt | 3 +- src/bindings/swig/ruby/CMakeLists.txt | 2 +- src/libs/elektra/CMakeLists.txt | 4 +-- src/libs/notification/tests/CMakeLists.txt | 2 +- src/libs/pluginprocess/tests/CMakeLists.txt | 2 +- src/libs/tools/benchmarks/CMakeLists.txt | 3 +- src/libs/tools/examples/CMakeLists.txt | 3 +- src/libs/tools/src/CMakeLists.txt | 2 ++ src/libs/tools/tests/CMakeLists.txt | 2 ++ src/plugins/augeas/contract.h | 2 +- src/plugins/gopts/CMakeLists.txt | 1 + src/plugins/jni/CMakeLists.txt | 2 +- src/tools/gen-gpg-testkey/CMakeLists.txt | 2 +- src/tools/kdb/CMakeLists.txt | 3 +- src/tools/qt-gui/CMakeLists.txt | 33 +++++++++++-------- tests/CMakeLists.txt | 6 ++-- tests/abi/testabi_key.c | 16 ++++----- tests/abi/testabi_ks.c | 18 +++++----- tests/cframework/tests.c | 2 +- tests/ctest/CMakeLists.txt | 2 -- tests/ctest/test_ks_opmphm.c | 3 +- tests/ctest/test_opmphm.c | 3 +- tests/ctest/test_opmphm_predictor.c | 3 +- tests/ctest/test_size.c | 2 +- tests/kdb/testkdb_nested.cpp | 2 +- tests/kdb/testkdb_simple.cpp | 2 +- 69 files changed, 165 insertions(+), 114 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 4dc5b79a793..ed2bb6af002 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -3,9 +3,9 @@ include (LibAddMacros) add_headers (HDR_FILES) macro (do_benchmark source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${ADDITIONAL_SOURCES} benchmarks.c benchmarks.h ${source}.c) add_executable (benchmark_${source} ${SOURCES}) + target_include_directories (benchmark_${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (benchmark_${source} elektra-kdb elektra-meta) @@ -55,6 +55,7 @@ if (ENABLE_OPTIMIZATIONS AND NOT WIN32) endif (ENABLE_OPTIMIZATIONS AND NOT WIN32) add_executable (benchmark_plugingetset plugingetset.c) +target_include_directories (benchmark_plugingetset PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (benchmark_plugingetset elektra-core elektra-kdb) target_link_elektra (benchmark_diff elektra-kdb) diff --git a/benchmarks/benchmarks.c b/benchmarks/benchmarks.c index 8cce9aed31c..6b90cc82d41 100644 --- a/benchmarks/benchmarks.c +++ b/benchmarks/benchmarks.c @@ -7,7 +7,7 @@ */ #define _GNU_SOURCE -#include +#include "./benchmarks.h" #ifdef HAVE_HSEARCHR #include #endif diff --git a/benchmarks/cmp.c b/benchmarks/cmp.c index 4689d7b8e17..e20b31c74da 100644 --- a/benchmarks/cmp.c +++ b/benchmarks/cmp.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./benchmarks.h" #include diff --git a/benchmarks/createkeys.c b/benchmarks/createkeys.c index fa342cfd90e..50008090c55 100644 --- a/benchmarks/createkeys.c +++ b/benchmarks/createkeys.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./benchmarks.h" void benchmarkDel (void) { diff --git a/benchmarks/deepdup.c b/benchmarks/deepdup.c index bc6e66df71c..1393f5504f5 100644 --- a/benchmarks/deepdup.c +++ b/benchmarks/deepdup.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./benchmarks.h" Key * key; diff --git a/benchmarks/diff.c b/benchmarks/diff.c index b2976feaee7..03acd1862a0 100644 --- a/benchmarks/diff.c +++ b/benchmarks/diff.c @@ -1,4 +1,5 @@ -#include +#include "./benchmarks.h" + #include #include diff --git a/benchmarks/kdb.c b/benchmarks/kdb.c index 8b2a3ab9cfb..7004e6b0928 100644 --- a/benchmarks/kdb.c +++ b/benchmarks/kdb.c @@ -8,10 +8,12 @@ #include -#include +#include "./benchmarks.h" + #include #include #include + #define NUM_RUNS 7 #define CSV_STR_FMT "%s;%s;%d\n" diff --git a/benchmarks/kdbget.c b/benchmarks/kdbget.c index a352dfdb969..d44722df45f 100644 --- a/benchmarks/kdbget.c +++ b/benchmarks/kdbget.c @@ -8,10 +8,12 @@ #include -#include +#include "./benchmarks.h" + #include #include #include + #define CSV_STR_FMT "%s;%s;%d\n" diff --git a/benchmarks/kdbmodify.c b/benchmarks/kdbmodify.c index e095a2ef4e7..e4be7e47682 100644 --- a/benchmarks/kdbmodify.c +++ b/benchmarks/kdbmodify.c @@ -8,10 +8,12 @@ #include -#include +#include "./benchmarks.h" + #include #include #include + #define CSV_STR_FMT "%s;%s;%d\n" diff --git a/benchmarks/large.c b/benchmarks/large.c index 09996cc15da..36111238e10 100644 --- a/benchmarks/large.c +++ b/benchmarks/large.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./benchmarks.h" KDB * kdb; Key * key; diff --git a/benchmarks/memoryleak.c b/benchmarks/memoryleak.c index 089341c72b4..5d75bb1cf46 100644 --- a/benchmarks/memoryleak.c +++ b/benchmarks/memoryleak.c @@ -7,12 +7,13 @@ */ #include +#include + +#include "./benchmarks.h" -#include #include #include #include -#include #define NUM_RUNS 30 diff --git a/benchmarks/opmphm.c b/benchmarks/opmphm.c index dd8c13d9567..ebb4a2164a8 100644 --- a/benchmarks/opmphm.c +++ b/benchmarks/opmphm.c @@ -20,7 +20,7 @@ #endif // ==== INCLUDE SECTION ==== -#include "benchmarks.h" +#include "./benchmarks.h" #ifdef HAVE_HSEARCHR #include #endif diff --git a/benchmarks/storage.c b/benchmarks/storage.c index 360424fcc3c..808f0e06c2a 100644 --- a/benchmarks/storage.c +++ b/benchmarks/storage.c @@ -9,8 +9,10 @@ #include #include -#include +#include "./benchmarks.h" + #include + #include #define CSV_STR_FMT "%s;%s;%d\n" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ff12a20550b..17459b1ec59 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,9 +5,9 @@ include (LibAddBinding) add_headers (HDR_FILES) macro (do_example source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.c) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (${source} elektra-kdb) @@ -50,6 +50,7 @@ if (FOUND_NAME GREATER -1) set (SOURCES ${SRC_FILES} ${HDR_FILES}) add_executable (${EXAMPLE} ${SOURCES}) + target_include_directories (${EXAMPLE} PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (${EXAMPLE} elektra-kdb elektra-notification) @@ -67,6 +68,7 @@ if (FOUND_NAME GREATER -1) endif () add_executable (${EXAMPLE} ${SOURCES}) + target_include_directories (${EXAMPLE} PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (${EXAMPLE} elektra-kdb elektra-notification elektra-io elektra-io-uv) if (BUILD_FULL OR BUILD_STATIC) @@ -94,11 +96,10 @@ if (FOUND_NAME GREATER -1) set_source_files_properties (${SRC_FILES} PROPERTIES COMPILE_FLAGS "-Wno-pedantic") find_package (GLib QUIET) - include_directories (${GLib_INCLUDE_DIRS}) - list (APPEND SOURCES $) - add_executable (${EXAMPLE} ${SOURCES}) + target_include_directories (${EXAMPLE} PRIVATE ${GLib_INCLUDE_DIRS}) + target_include_directories (${EXAMPLE} PRIVATE "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") target_link_elektra (${EXAMPLE} elektra-kdb elektra-notification elektra-io elektra-io-glib) if (BUILD_FULL OR BUILD_STATIC) diff --git a/scripts/cmake/Modules/LibAddLib.cmake b/scripts/cmake/Modules/LibAddLib.cmake index 7fe92015820..f9feb1c955a 100644 --- a/scripts/cmake/Modules/LibAddLib.cmake +++ b/scripts/cmake/Modules/LibAddLib.cmake @@ -31,6 +31,7 @@ function (add_lib name) add_library (elektra-${name}-objects OBJECT ${ARG_SOURCES}) add_dependencies (elektra-${name}-objects generate_version_script) + # TODO: should probably done on a per library basis to allow decision between PRIVATE/PUBLIC/INTERFACE target_include_directories (elektra-${name}-objects PUBLIC ${ARG_INCLUDE_DIRECTORIES}) target_include_directories (elektra-${name}-objects SYSTEM PUBLIC ${ARG_INCLUDE_SYSTEM_DIRECTORIES}) diff --git a/scripts/cmake/Modules/LibAddMacros.cmake b/scripts/cmake/Modules/LibAddMacros.cmake index 8d794683a2b..66526f8b9dc 100644 --- a/scripts/cmake/Modules/LibAddMacros.cmake +++ b/scripts/cmake/Modules/LibAddMacros.cmake @@ -129,7 +129,6 @@ macro (mkdir dir) endmacro (mkdir) macro (add_testheaders HDR_FILES) - include_directories ("${PROJECT_SOURCE_DIR}/tests/cframework") file (GLOB BIN_HDR_FILES "${PROJECT_SOURCE_DIR}/tests/cframework/*.h") list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) endmacro (add_testheaders HDR_FILES) @@ -284,11 +283,9 @@ macro (add_headers HDR_FILES) set (BINARY_INCLUDE_DIR "${PROJECT_BINARY_DIR}/src/include") set (SOURCE_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/include") - include_directories (BEFORE "${BINARY_INCLUDE_DIR}") file (GLOB BIN_HDR_FILES ${BINARY_INCLUDE_DIR}/*.h) list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - include_directories (AFTER ${SOURCE_INCLUDE_DIR}) file (GLOB SRC_HDR_FILES ${SOURCE_INCLUDE_DIR}/*.h) list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) @@ -301,21 +298,17 @@ endmacro (add_headers) # Add all headers needed for cpp bindings # ~~~ macro (add_cppheaders HDR_FILES) - include_directories ("${PROJECT_BINARY_DIR}/src/bindings/cpp/include") file (GLOB BIN_HDR_FILES ${PROJECT_BINARY_DIR}/src/bindings/cpp/include/*.hpp) list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - include_directories ("${PROJECT_SOURCE_DIR}/src/bindings/cpp/include") file (GLOB SRC_HDR_FILES ${PROJECT_SOURCE_DIR}/src/bindings/cpp/include/*.hpp) list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) endmacro (add_cppheaders) macro (add_toolheaders HDR_FILES) - include_directories ("${PROJECT_BINARY_DIR}/src/libs/tools/include") file (GLOB_RECURSE BIN_HDR_FILES ${PROJECT_BINARY_DIR}/src/libtools/include/*) list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - include_directories ("${PROJECT_SOURCE_DIR}/src/libs/tools/include") file (GLOB_RECURSE SRC_HDR_FILES ${PROJECT_SOURCE_DIR}/src/libs/tools/include/*) list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) endmacro (add_toolheaders) diff --git a/scripts/cmake/Modules/LibAddPlugin.cmake b/scripts/cmake/Modules/LibAddPlugin.cmake index d4cb4ddd03c..a421e9735bd 100644 --- a/scripts/cmake/Modules/LibAddPlugin.cmake +++ b/scripts/cmake/Modules/LibAddPlugin.cmake @@ -142,11 +142,9 @@ function (add_plugintest testname) add_headers (TEST_SOURCES) add_testheaders (TEST_SOURCES) - include_directories ("${CMAKE_SOURCE_DIR}/tests/cframework") if (ARG_CPP) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testmod_${testname}.cpp") - include_directories (${CMAKE_SOURCE_DIR}/src/bindings/cpp/tests ${CMAKE_SOURCE_DIR}/src/bindings/cpp/include) else (ARG_CPP) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testmod_${testname}.c") endif (ARG_CPP) @@ -165,6 +163,14 @@ function (add_plugintest testname) set (testexename testmod_${testname}) add_executable (${testexename} ${TEST_SOURCES}) + if (ARG_CPP) + target_include_directories ( + ${testexename} + PRIVATE ${CMAKE_SOURCE_DIR}/src/bindings/cpp/tests + PRIVATE ${CMAKE_SOURCE_DIR}/src/bindings/cpp/include) + endif (ARG_CPP) + target_include_directories (${testexename} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") + if (BUILD_SHARED) if (ARG_LINK_PLUGIN) add_dependencies (${testexename} elektra-${ARG_LINK_PLUGIN}) @@ -612,11 +618,14 @@ function (add_plugin PLUGIN_SHORT_NAME) "PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}" "README=readme_${PLUGIN_SHORT_NAME}.c") + if (ARG_CPP) + target_include_directories (${PLUGIN_OBJS} PUBLIC "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") + endif (ARG_CPP) + target_include_directories (${PLUGIN_OBJS} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") # for readme set_property ( TARGET ${PLUGIN_OBJS} APPEND - PROPERTY INCLUDE_DIRECTORIES ${ARG_INCLUDE_DIRECTORIES} ${CMAKE_CURRENT_BINARY_DIR} # for readme - ) + PROPERTY INCLUDE_DIRECTORIES ${ARG_INCLUDE_DIRECTORIES}) set_property ( TARGET ${PLUGIN_OBJS} @@ -636,10 +645,14 @@ function (add_plugin PLUGIN_SHORT_NAME) set_property (TARGET ${PLUGIN_OBJS} PROPERTY CMAKE_POSITION_INDEPENDENT_CODE ON) if (BUILD_SHARED) + # TODO: why is this not built upon ${PLUGIN_OBJS} add_library (${PLUGIN_NAME} MODULE ${ARG_SOURCES} ${ARG_OBJECT_SOURCES}) # TODO: switch to -plugin- in CMake targets set_target_properties (${PLUGIN_NAME} PROPERTIES OUTPUT_NAME "elektra-plugin-${PLUGIN_SHORT_NAME}") + if (ARG_CPP) + target_include_directories (${PLUGIN_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") + endif (ARG_CPP) if (ARG_DEPENDS) add_dependencies (${PLUGIN_NAME} ${ARG_DEPENDS}) endif () @@ -658,11 +671,11 @@ function (add_plugin PLUGIN_SHORT_NAME) APPEND PROPERTY COMPILE_DEFINITIONS ${ARG_COMPILE_DEFINITIONS} ${ADDITIONAL_COMPILE_DEFINITIONS} "HAVE_KDBCONFIG_H" "PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}" "README=readme_${PLUGIN_SHORT_NAME}.c") + target_include_directories (${PLUGIN_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") # for readme set_property ( TARGET ${PLUGIN_NAME} APPEND - PROPERTY INCLUDE_DIRECTORIES ${ARG_INCLUDE_DIRECTORIES} ${CMAKE_CURRENT_BINARY_DIR} # for readme - ) + PROPERTY INCLUDE_DIRECTORIES ${ARG_INCLUDE_DIRECTORIES}) # do not strip rpath during install if (ARG_USE_LINK_RPATH) set_target_properties (${PLUGIN_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) diff --git a/scripts/cmake/Modules/LibAddTest.cmake b/scripts/cmake/Modules/LibAddTest.cmake index fd88a8070fa..cfddab25026 100644 --- a/scripts/cmake/Modules/LibAddTest.cmake +++ b/scripts/cmake/Modules/LibAddTest.cmake @@ -44,8 +44,10 @@ macro (add_gtest source) target_link_libraries (${source} ${CMAKE_THREAD_LIBS_INIT}) - include_directories (SYSTEM ${GOOGLETEST_ROOT}/include) - include_directories (${CMAKE_SOURCE_DIR}/tests/gtest-framework) + target_include_directories (${source} SYSTEM PRIVATE "${GOOGLETEST_ROOT}/include") + target_include_directories ( + ${source} PRIVATE "${CMAKE_SOURCE_DIR}/tests/gtest-framework" "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" + "${CMAKE_SOURCE_DIR}/src/libs/tools/include") if (INSTALL_TESTING) install ( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79a1a4134d3..446bea773f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,15 @@ set (ADDTESTING_PHASE OFF) + +include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include") + +# ~~~ +# RPATH settings, see http://www.itk.org/Wiki/CMake_RPATH_handling +# those settings are needed to find the plugins at runtime even without ld.so.conf +# search only in the prefix the user decided to install elektra +# (e.g. /usr/local/) +# ~~~ +set (ELEKTRA_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${TARGET_PLUGIN_FOLDER}") + add_subdirectory (plugins) add_subdirectory (libs) diff --git a/src/bindings/cpp/benchmarks/CMakeLists.txt b/src/bindings/cpp/benchmarks/CMakeLists.txt index c3a72a26b76..af402e1bc6c 100644 --- a/src/bindings/cpp/benchmarks/CMakeLists.txt +++ b/src/bindings/cpp/benchmarks/CMakeLists.txt @@ -4,9 +4,9 @@ add_headers (HDR_FILES) add_cppheaders (HDR_FILES) macro (do_benchmark source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include") target_link_elektra (${source} elektra-kdb elektra-meta) diff --git a/src/bindings/cpp/examples/CMakeLists.txt b/src/bindings/cpp/examples/CMakeLists.txt index 610dcef1c61..585dc30c0ed 100644 --- a/src/bindings/cpp/examples/CMakeLists.txt +++ b/src/bindings/cpp/examples/CMakeLists.txt @@ -4,9 +4,9 @@ add_headers (HDR_FILES) add_cppheaders (HDR_FILES) macro (do_example source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include") target_link_elektra (${source} elektra-kdb) diff --git a/src/bindings/cpp/tests/CMakeLists.txt b/src/bindings/cpp/tests/CMakeLists.txt index d07d3c7bb61..77a1d9daf3d 100644 --- a/src/bindings/cpp/tests/CMakeLists.txt +++ b/src/bindings/cpp/tests/CMakeLists.txt @@ -1,6 +1,7 @@ include (LibAddTest) -include_directories (${CMAKE_CURRENT_SOURCE_DIR}) +include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../include") + add_headers (HDR_FILES) add_cppheaders (HDR_FILES) diff --git a/src/bindings/cpp/tests/testcpp_iter.cpp b/src/bindings/cpp/tests/testcpp_iter.cpp index 6a9e58c7b5e..9e0ed4fb8e0 100644 --- a/src/bindings/cpp/tests/testcpp_iter.cpp +++ b/src/bindings/cpp/tests/testcpp_iter.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" #include #include diff --git a/src/bindings/cpp/tests/testcpp_iter_name.cpp b/src/bindings/cpp/tests/testcpp_iter_name.cpp index b7dbb9aa536..81235211623 100644 --- a/src/bindings/cpp/tests/testcpp_iter_name.cpp +++ b/src/bindings/cpp/tests/testcpp_iter_name.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" #include #include diff --git a/src/bindings/cpp/tests/testcpp_kdb.cpp b/src/bindings/cpp/tests/testcpp_kdb.cpp index b43df7fc754..9df413fadf3 100644 --- a/src/bindings/cpp/tests/testcpp_kdb.cpp +++ b/src/bindings/cpp/tests/testcpp_kdb.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" TEST (kdb, get_set) diff --git a/src/bindings/cpp/tests/testcpp_key.cpp b/src/bindings/cpp/tests/testcpp_key.cpp index 303b791cd43..aa22abe3978 100644 --- a/src/bindings/cpp/tests/testcpp_key.cpp +++ b/src/bindings/cpp/tests/testcpp_key.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" #include #include diff --git a/src/bindings/cpp/tests/testcpp_keyio.cpp b/src/bindings/cpp/tests/testcpp_keyio.cpp index fad9df9f0ec..772e274885c 100644 --- a/src/bindings/cpp/tests/testcpp_keyio.cpp +++ b/src/bindings/cpp/tests/testcpp_keyio.cpp @@ -8,7 +8,7 @@ #include -#include +#include "./tests.hpp" #include #include diff --git a/src/bindings/cpp/tests/testcpp_ks.cpp b/src/bindings/cpp/tests/testcpp_ks.cpp index dbe25a9ac51..04e05cad13f 100644 --- a/src/bindings/cpp/tests/testcpp_ks.cpp +++ b/src/bindings/cpp/tests/testcpp_ks.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" #include diff --git a/src/bindings/cpp/tests/testcpp_ksget.cpp b/src/bindings/cpp/tests/testcpp_ksget.cpp index a19d3116cd8..3716a8d6d03 100644 --- a/src/bindings/cpp/tests/testcpp_ksget.cpp +++ b/src/bindings/cpp/tests/testcpp_ksget.cpp @@ -8,7 +8,7 @@ #include -#include +#include "./tests.hpp" TEST (ks, get) { diff --git a/src/bindings/cpp/tests/testcpp_meta.cpp b/src/bindings/cpp/tests/testcpp_meta.cpp index 6f5f307446a..977909a8496 100644 --- a/src/bindings/cpp/tests/testcpp_meta.cpp +++ b/src/bindings/cpp/tests/testcpp_meta.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" #include #include diff --git a/src/bindings/cpp/tests/tests.cpp b/src/bindings/cpp/tests/tests.cpp index dc56e3d36fc..ebeb3beb4b7 100644 --- a/src/bindings/cpp/tests/tests.cpp +++ b/src/bindings/cpp/tests/tests.cpp @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include +#include "./tests.hpp" int nbError; int nbTest; diff --git a/src/bindings/glib/tests/CMakeLists.txt b/src/bindings/glib/tests/CMakeLists.txt index aa12b9f7459..06cc60f2646 100644 --- a/src/bindings/glib/tests/CMakeLists.txt +++ b/src/bindings/glib/tests/CMakeLists.txt @@ -11,6 +11,8 @@ macro (do_glib_test file) target_link_libraries (${name} PRIVATE ${GELEKTRA_LIBRARY}) + target_include_directories (${name} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") + add_test (NAME ${name} COMMAND "${CMAKE_BINARY_DIR}/bin/${name}" "${CMAKE_CURRENT_SOURCE_DIR}") set_property (TEST ${name} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib") diff --git a/src/bindings/intercept/env/benchmarks/CMakeLists.txt b/src/bindings/intercept/env/benchmarks/CMakeLists.txt index 329d9378fc9..f65c9c6f69a 100644 --- a/src/bindings/intercept/env/benchmarks/CMakeLists.txt +++ b/src/bindings/intercept/env/benchmarks/CMakeLists.txt @@ -6,9 +6,9 @@ add_cppheaders (HDR_FILES) set_source_files_properties (benchmark_getenv.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-result") macro (do_benchmark source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") target_link_elektra (${source}) diff --git a/src/bindings/intercept/env/examples/CMakeLists.txt b/src/bindings/intercept/env/examples/CMakeLists.txt index 002557b45f3..1aad09754c3 100644 --- a/src/bindings/intercept/env/examples/CMakeLists.txt +++ b/src/bindings/intercept/env/examples/CMakeLists.txt @@ -5,9 +5,9 @@ add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) macro (do_example source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.c) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") install ( TARGETS ${source} diff --git a/src/bindings/intercept/env/src/CMakeLists.txt b/src/bindings/intercept/env/src/CMakeLists.txt index 7b37209bc96..f8e5b8284d3 100644 --- a/src/bindings/intercept/env/src/CMakeLists.txt +++ b/src/bindings/intercept/env/src/CMakeLists.txt @@ -11,6 +11,7 @@ add_library (elektraintercept-env SHARED ${SOURCES}) target_link_libraries (elektraintercept-env ${CMAKE_DL_LIBS}) target_link_libraries (elektraintercept-env elektra-kdb elektra-meta) # must be shared! +target_include_directories (elektraintercept-env PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") set_target_properties ( elektraintercept-env diff --git a/src/bindings/io/doc/CMakeLists.txt b/src/bindings/io/doc/CMakeLists.txt index 1015a057c0d..f9a7fce7af4 100644 --- a/src/bindings/io/doc/CMakeLists.txt +++ b/src/bindings/io/doc/CMakeLists.txt @@ -15,7 +15,7 @@ set (SOURCES ${IO_VARIANT_SRC_FILES} ${IO_VARIANT_HDR_FILES} ${ELEKTRA_HEADERS}) set (IO_VARIANT_LIBRARY elektra-io-${BINDING_VARIANT}) add_library (${IO_VARIANT_LIBRARY} SHARED ${SOURCES}) -target_include_directories (${IO_VARIANT_LIBRARY} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories (${IO_VARIANT_LIBRARY} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) # ~~~ # If needed add a library (e.g. found with pkg_check_modules) @@ -46,7 +46,7 @@ if (BUILD_TESTING) add_executable (${testexename} ${TEST_SOURCES}) - target_include_directories (${testexename} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework") + target_include_directories (${testexename} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") target_link_elektra (${testexename} elektra-kdb elektra-plugin elektra-io ${IO_VARIANT_LIBRARY} ${ADDITIONAL_TEST_LIBRARIES}) diff --git a/src/bindings/io/ev/CMakeLists.txt b/src/bindings/io/ev/CMakeLists.txt index ca877f81541..8b8f57ab2ee 100644 --- a/src/bindings/io/ev/CMakeLists.txt +++ b/src/bindings/io/ev/CMakeLists.txt @@ -52,8 +52,8 @@ else () # Build library add_executable (${testexename} ${TEST_SOURCES}) - target_include_directories (${testexename} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework") - target_include_directories (${testexename} PUBLIC SYSTEM ${LIBEV_INCLUDE_DIRS}) + target_include_directories (${testexename} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") + target_include_directories (${testexename} PRIVATE SYSTEM ${LIBEV_INCLUDE_DIRS}) target_link_elektra (${testexename} elektra-kdb elektra-plugin elektra-io ${IO_VARIANT_LIBRARY} m) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/ev/example/CMakeLists.txt b/src/bindings/io/ev/example/CMakeLists.txt index d13bca744f4..b3a2aa6e748 100644 --- a/src/bindings/io/ev/example/CMakeLists.txt +++ b/src/bindings/io/ev/example/CMakeLists.txt @@ -15,7 +15,7 @@ set (example exampleio_ev) add_executable (${example} ${SOURCES}) -target_include_directories (${example} SYSTEM PUBLIC ${LIBEV_INCLUDE_DIRS}) +target_include_directories (${example} SYSTEM PRIVATE ${LIBEV_INCLUDE_DIRS}) target_link_elektra (${example} elektra-kdb elektra-io elektra-io-ev) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/glib/CMakeLists.txt b/src/bindings/io/glib/CMakeLists.txt index 7e49d56f900..40839ef2bbd 100644 --- a/src/bindings/io/glib/CMakeLists.txt +++ b/src/bindings/io/glib/CMakeLists.txt @@ -58,8 +58,8 @@ else () add_executable (${testexename} ${TEST_SOURCES}) - target_include_directories (${testexename} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework") - target_include_directories (${testexename} PUBLIC SYSTEM ${GLib_INCLUDE_DIRS}) + target_include_directories (${testexename} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") + target_include_directories (${testexename} PRIVATE SYSTEM ${GLib_INCLUDE_DIRS}) target_link_elektra (${testexename} elektra-kdb elektra-plugin elektra-io ${IO_VARIANT_LIBRARY} m) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/glib/example/CMakeLists.txt b/src/bindings/io/glib/example/CMakeLists.txt index 1c35c005b9c..cca039157ef 100644 --- a/src/bindings/io/glib/example/CMakeLists.txt +++ b/src/bindings/io/glib/example/CMakeLists.txt @@ -15,7 +15,7 @@ set (example exampleio_glib) add_executable (${example} ${SOURCES}) -target_include_directories (${example} SYSTEM PUBLIC ${GLib_INCLUDE_DIRS}) +target_include_directories (${example} SYSTEM PRIVATE ${GLib_INCLUDE_DIRS}) target_link_elektra (${example} elektra-kdb elektra-io elektra-io-glib) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/uv/CMakeLists.txt b/src/bindings/io/uv/CMakeLists.txt index 14c4f2cf9e1..96abb8569a9 100644 --- a/src/bindings/io/uv/CMakeLists.txt +++ b/src/bindings/io/uv/CMakeLists.txt @@ -66,7 +66,7 @@ else () add_executable (${TESTEXENAME} ${TEST_SOURCES}) - target_include_directories (${TESTEXENAME} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework" "${libuv_INCLUDE_DIRS}") + target_include_directories (${TESTEXENAME} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework" "${libuv_INCLUDE_DIRS}") target_link_elektra (${TESTEXENAME} elektra-kdb elektra-plugin elektra-io ${IO_UV_LIBRARY} m) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/uv/example/CMakeLists.txt b/src/bindings/io/uv/example/CMakeLists.txt index fba1ff2350a..77ee28e8b36 100644 --- a/src/bindings/io/uv/example/CMakeLists.txt +++ b/src/bindings/io/uv/example/CMakeLists.txt @@ -15,7 +15,7 @@ set (EXAMPLE exampleio_uv) add_executable (${EXAMPLE} ${SOURCES}) -target_include_directories (${EXAMPLE} SYSTEM PUBLIC ${libuv_INCLUDE_DIRS}) +target_include_directories (${EXAMPLE} SYSTEM PRIVATE ${libuv_INCLUDE_DIRS}) target_link_elektra (${EXAMPLE} elektra-kdb elektra-io elektra-io-uv) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/swig/lua/CMakeLists.txt b/src/bindings/swig/lua/CMakeLists.txt index 64f78f14758..54e30c0a07e 100644 --- a/src/bindings/swig/lua/CMakeLists.txt +++ b/src/bindings/swig/lua/CMakeLists.txt @@ -16,8 +16,8 @@ else () add_headers (HDR_FILES) add_cppheaders (HDR_FILES) - include_directories (${LUA_INCLUDE_DIR}) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}) + include_directories (SYSTEM ${LUA_INCLUDE_DIR}) + include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") set (CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}") set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SWIG_OUTDIR}") diff --git a/src/bindings/swig/python/CMakeLists.txt b/src/bindings/swig/python/CMakeLists.txt index e75ccbdd4f3..3f1fb6889c7 100644 --- a/src/bindings/swig/python/CMakeLists.txt +++ b/src/bindings/swig/python/CMakeLists.txt @@ -39,7 +39,8 @@ else () add_headers (HDR_FILES) - include_directories (${PYTHON_INCLUDE_DIRS}) + include_directories (SYSTEM ${PYTHON_INCLUDE_DIRS}) + include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_SOURCE_DIR}/src/libs/tools/include") set (CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/kdb") set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SWIG_OUTDIR}") diff --git a/src/bindings/swig/ruby/CMakeLists.txt b/src/bindings/swig/ruby/CMakeLists.txt index b12e6fe25da..ddc6dff16bd 100644 --- a/src/bindings/swig/ruby/CMakeLists.txt +++ b/src/bindings/swig/ruby/CMakeLists.txt @@ -33,7 +33,7 @@ else () add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}) + include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_SOURCE_DIR}/src/libs/tools/include") # minimal replacement for Ruby's mkmf.create_makefile execute_process (COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['vendorarchdir']" diff --git a/src/libs/elektra/CMakeLists.txt b/src/libs/elektra/CMakeLists.txt index d1bb1c11cae..95c2721ff03 100644 --- a/src/libs/elektra/CMakeLists.txt +++ b/src/libs/elektra/CMakeLists.txt @@ -128,8 +128,6 @@ if (BUILD_FULL OR BUILD_STATIC) # include the directories of all libraries for the static or full-shared build get_property (elektra-full_INCLUDES GLOBAL PROPERTY elektra-full_INCLUDES) - - include_directories (${elektra-full_INCLUDES}) endif (BUILD_FULL OR BUILD_STATIC) if (BUILD_FULL) @@ -168,6 +166,8 @@ if (BUILD_STATIC) add_dependencies (elektra-static generate_version_script) target_link_libraries (elektra-static ${elektra-full_LIBRARIES}) + # include the current binary directory to get exported_symbols.h + target_include_directories (elektra-static PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") set_target_properties ( elektra-static diff --git a/src/libs/notification/tests/CMakeLists.txt b/src/libs/notification/tests/CMakeLists.txt index 4dc4355309a..a324e6e81d5 100644 --- a/src/libs/notification/tests/CMakeLists.txt +++ b/src/libs/notification/tests/CMakeLists.txt @@ -16,7 +16,7 @@ if (BUILD_TESTING AND NOT ENABLE_ASAN) add_executable (${name} ${TEST_SOURCES}) - target_include_directories (${name} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework") + target_include_directories (${name} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") target_link_elektra (${name} elektra-kdb elektra-notification) diff --git a/src/libs/pluginprocess/tests/CMakeLists.txt b/src/libs/pluginprocess/tests/CMakeLists.txt index f3829d2f0ab..d07e2e79b5b 100644 --- a/src/libs/pluginprocess/tests/CMakeLists.txt +++ b/src/libs/pluginprocess/tests/CMakeLists.txt @@ -15,7 +15,7 @@ if (BUILD_TESTING) add_executable (${name} ${TEST_SOURCES}) - target_include_directories (${name} PUBLIC "${CMAKE_SOURCE_DIR}/tests/cframework") + target_include_directories (${name} PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") target_link_elektra (${name} elektra-kdb elektra-invoke elektra-pluginprocess) diff --git a/src/libs/tools/benchmarks/CMakeLists.txt b/src/libs/tools/benchmarks/CMakeLists.txt index 6d77e059b1c..d39515b81b7 100644 --- a/src/libs/tools/benchmarks/CMakeLists.txt +++ b/src/libs/tools/benchmarks/CMakeLists.txt @@ -5,9 +5,10 @@ add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) macro (do_benchmark source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" + "${CMAKE_CURRENT_SOURCE_DIR}/../include") target_link_elektratools (${source} elektra-kdb) diff --git a/src/libs/tools/examples/CMakeLists.txt b/src/libs/tools/examples/CMakeLists.txt index d2531c545d9..8c6b61c4272 100644 --- a/src/libs/tools/examples/CMakeLists.txt +++ b/src/libs/tools/examples/CMakeLists.txt @@ -5,9 +5,10 @@ add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) macro (do_example source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" + "${CMAKE_CURRENT_SOURCE_DIR}/../include") target_link_elektratools (${source}) diff --git a/src/libs/tools/src/CMakeLists.txt b/src/libs/tools/src/CMakeLists.txt index 5a17b10ca83..a77f8d2db94 100644 --- a/src/libs/tools/src/CMakeLists.txt +++ b/src/libs/tools/src/CMakeLists.txt @@ -1,5 +1,7 @@ include (LibAddMacros) +include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_CURRENT_SOURCE_DIR}/../include") + add_headers (HDR_FILES) add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) diff --git a/src/libs/tools/tests/CMakeLists.txt b/src/libs/tools/tests/CMakeLists.txt index bd5c783fd93..e260ec4010b 100644 --- a/src/libs/tools/tests/CMakeLists.txt +++ b/src/libs/tools/tests/CMakeLists.txt @@ -1,5 +1,7 @@ include (LibAddMacros) +include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_CURRENT_SOURCE_DIR}/../include") + add_headers (HDR_FILES) add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) diff --git a/src/plugins/augeas/contract.h b/src/plugins/augeas/contract.h index fc24708460e..9e197ae02be 100644 --- a/src/plugins/augeas/contract.h +++ b/src/plugins/augeas/contract.h @@ -30,7 +30,7 @@ ksNew (30, keyNew ("system:/elektra/modules/augeas/exports/close", KEY_FUNC, elektraAugeasClose, KEY_END), -#include "./readme_augeas.c" +#include ELEKTRA_README keyNew ("system:/elektra/modules/augeas/infos/version", KEY_VALUE, PLUGINVERSION, KEY_END), diff --git a/src/plugins/gopts/CMakeLists.txt b/src/plugins/gopts/CMakeLists.txt index efe77619d55..c0554cfc214 100644 --- a/src/plugins/gopts/CMakeLists.txt +++ b/src/plugins/gopts/CMakeLists.txt @@ -42,6 +42,7 @@ if (gopts_source) add_executable (elektra-gopts-testapp "${CMAKE_CURRENT_SOURCE_DIR}/testapp.c" ${TEST_SOURCES}) target_link_elektra (elektra-gopts-testapp elektra-core elektra-invoke elektra-opts) + target_include_directories (elektra-gopts-testapp PRIVATE "${CMAKE_SOURCE_DIR}/tests/cframework") set (TESTAPP_NAME "elektra-gopts-testapp") configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/config.c.in" "${CMAKE_CURRENT_BINARY_DIR}/config.c" @ONLY) diff --git a/src/plugins/jni/CMakeLists.txt b/src/plugins/jni/CMakeLists.txt index d7fd8ec1285..d1b22ace45e 100644 --- a/src/plugins/jni/CMakeLists.txt +++ b/src/plugins/jni/CMakeLists.txt @@ -48,7 +48,7 @@ if (ADDTESTING_PHASE) AND NOT ENABLE_ASAN) # do not install test, because it depends on build folder JNA fat jar add_plugintest (jni MEMLEAK USE_LINK_RPATH NO_INSTALL) - include_directories (${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories (testmod_jni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") # Generate header file set (libelektra_jar_all ${CMAKE_BINARY_DIR}/src/bindings/jna/libelektra/build/libs/libelektra-${KDB_VERSION}-all.jar) diff --git a/src/tools/gen-gpg-testkey/CMakeLists.txt b/src/tools/gen-gpg-testkey/CMakeLists.txt index ed890d35d99..b6e6000f7ac 100644 --- a/src/tools/gen-gpg-testkey/CMakeLists.txt +++ b/src/tools/gen-gpg-testkey/CMakeLists.txt @@ -4,8 +4,8 @@ if (NOT LIBGPGME_FOUND) else () # check GPGME version (requires at least 1.10) if (${LIBGPGME_VERSION} MATCHES "1[.][1-9][0-9]+.*") - include_directories (${LIBGPGME_INCLUDE_DIRS}) add_executable (gen-gpg-testkey gen-gpg-testkey.c) + target_include_directories (gen-gpg-testkey PRIVATE ${LIBGPGME_INCLUDE_DIRS}) target_link_libraries (gen-gpg-testkey ${LIBGPGME_LIBRARIES}) install ( TARGETS gen-gpg-testkey diff --git a/src/tools/kdb/CMakeLists.txt b/src/tools/kdb/CMakeLists.txt index b2530cffcb4..f5bb1400db9 100644 --- a/src/tools/kdb/CMakeLists.txt +++ b/src/tools/kdb/CMakeLists.txt @@ -4,7 +4,8 @@ file (GLOB HDR_FILES *.hpp gen/*.hpp gen/*/*.hpp) add_headers (HDR_FILES) add_cppheaders (HDR_FILES) add_toolheaders (HDR_FILES) -include_directories (${CMAKE_CURRENT_SOURCE_DIR}) +include_directories (${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" + "${CMAKE_SOURCE_DIR}/src/libs/tools/include") file (GLOB SRC_FILES *.cpp gen/*.cpp gen/*/*.cpp) list (REMOVE_ITEM SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/gen/templates/collect.cpp") diff --git a/src/tools/qt-gui/CMakeLists.txt b/src/tools/qt-gui/CMakeLists.txt index 61bd13aba21..0fafa7d91a1 100644 --- a/src/tools/qt-gui/CMakeLists.txt +++ b/src/tools/qt-gui/CMakeLists.txt @@ -35,19 +35,6 @@ else () add_definitions (-DHAVE_DBUS=1) endif () - include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - - include_directories ( - SYSTEM - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Qml_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Test_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} - src/markdownconverter) - file (GLOB qt-gui_HDRS "src/markdownconverter/*.h" "src/markdownconverter/template/*.h") add_headers (qt-gui_HDRS) @@ -63,9 +50,27 @@ else () add_executable (qt-gui ${qt-gui_SRCS} ${qt-gui_HDRS} ${UIS} ${RSCS} ${TRS}) + target_include_directories ( + qt-gui + PRIVATE ${CMAKE_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" + PRIVATE "${CMAKE_SOURCE_DIR}/src/libs/tools/include") + + target_include_directories ( + qt-gui SYSTEM + PRIVATE ${Qt5Quick_INCLUDE_DIRS} + ${Qt5Gui_INCLUDE_DIRS} + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Qml_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5Test_INCLUDE_DIRS} + ${Qt5Svg_INCLUDE_DIRS} + src/markdownconverter) + target_link_libraries (qt-gui Qt5::Quick Qt5::Gui Qt5::Core Qt5::Qml Qt5::Widgets) - include_directories (${DISCOUNT_INCLUDES}) + target_include_directories (qt-gui PRIVATE ${DISCOUNT_INCLUDES}) target_link_libraries (qt-gui ${DISCOUNT_LIBRARIES}) target_link_libraries ( diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c5cfe806dff..06c07f1d264 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,6 +10,8 @@ include (LibAddMacros) +include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/cframework" "${CMAKE_SOURCE_DIR}/src/include" "${CMAKE_BINARY_DIR}/src/include") + if (ENABLE_TESTING) include (FindGTest) @@ -42,11 +44,11 @@ endif (ENABLE_TESTING) add_headers (HDR_FILES) macro (do_test source) - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") set (SOURCES ${HDR_FILES} ${source}.c $) add_headers (SOURCES) add_testheaders (SOURCES) add_executable (${source} ${SOURCES}) + target_include_directories (${source} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") if (INSTALL_TESTING) install ( @@ -93,8 +95,6 @@ add_custom_target ( COMMAND "${CMAKE_BINARY_DIR}/scripts/dev/run_memcheck" "$" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -include_directories (data) - add_subdirectory (cframework) add_subdirectory (shell) add_subdirectory (abi) diff --git a/tests/abi/testabi_key.c b/tests/abi/testabi_key.c index 57d7983a3d4..5b228a7a376 100644 --- a/tests/abi/testabi_key.c +++ b/tests/abi/testabi_key.c @@ -2440,27 +2440,27 @@ static void test_keyEscape (void) succeed_if_same_string (buffer, A); \ } while (0) -#include +#include "../data/data_escape.c" keySetName (k, "spec:/valid"); -#include +#include "../data/data_escape.c" keySetName (k, "proc:/valid"); -#include +#include "../data/data_escape.c" keySetName (k, "dir:/valid"); -#include +#include "../data/data_escape.c" keySetName (k, "user:/valid"); -#include +#include "../data/data_escape.c" keySetName (k, "system:/valid"); -#include +#include "../data/data_escape.c" #undef TEST_ESCAPE_PART #define TEST_ESCAPE_PART(A, S) \ @@ -2476,7 +2476,7 @@ static void test_keyEscape (void) { keySetName (k, namespaces[i]); -#include +#include "../data/data_escape.c" } keySetName (k, "/"); @@ -2500,7 +2500,7 @@ static void test_keyEscape (void) { keySetName (k, namespaces[i]); -#include +#include "../data/data_escape.c" } keyDel (k); diff --git a/tests/abi/testabi_ks.c b/tests/abi/testabi_ks.c index 60b0be3ca01..5d7c2a2f6ae 100644 --- a/tests/abi/testabi_ks.c +++ b/tests/abi/testabi_ks.c @@ -1466,11 +1466,11 @@ static void test_ksAppend (void) keyDel (key); KeySet * returned = -#include "data_keyset.c" +#include "../data/data_keyset.c" KeySet * testDirectBelow = -#include "data_dbelow.c" +#include "../data/data_dbelow.c" KeySet * testReturned = -#include "data_others.c" +#include "../data/data_others.c" Key * parentKey[2]; parentKey[0] = keyNew ("user:/test/keyset", KEY_END); parentKey[1] = keyNew ("user:/test/keyset/dir1", KEY_END); @@ -2214,7 +2214,7 @@ static void test_below (void) KeySet * cmp_orig[16]; KeySet * cmp_result[16]; -#include "data_cut.c" +#include "../data/data_cut.c" for (int i = 0; i < 16; ++i) { @@ -2284,7 +2284,7 @@ static void test_cut (void) KeySet * cmp_orig[16]; KeySet * cmp_result[16]; -#include "data_cut.c" +#include "../data/data_cut.c" for (int i = 0; i < 16; ++i) { @@ -2350,7 +2350,7 @@ static void test_cascadingCutpoint (void) Key * cutpoint = keyNew ("/a/b/c", KEY_END); KeySet * orig = -#include +#include "../data/data_nscut.c" ksRewind (orig); ksNext (orig); succeed_if_same_string (keyName (ksCurrent (orig)), "spec:/a"); @@ -2403,7 +2403,7 @@ static void test_cascadingRootCutpoint (void) Key * cutpoint = keyNew ("/", KEY_END); KeySet * orig = -#include +#include "../data/data_nscut.c" ksRewind (orig); ksNext (orig); succeed_if_same_string (keyName (ksCurrent (orig)), "spec:/a"); @@ -2417,7 +2417,7 @@ static void test_cascadingRootCutpoint (void) ksDel (orig); KeySet * cmp_part = -#include +#include "../data/data_nscut.c" compare_keyset (part, cmp_part); // output_keyset(part); ksDel (part); @@ -2818,7 +2818,7 @@ static void test_nsLookup (void) printf ("Test lookup in all namespaces\n"); KeySet * ks = -#include +#include "../data/data_ns.c" for (int i = 0; i < NUMBER_OF_NAMESPACES; ++i) { diff --git a/tests/cframework/tests.c b/tests/cframework/tests.c index dd873ffb9ed..ab23cc6afa0 100644 --- a/tests/cframework/tests.c +++ b/tests/cframework/tests.c @@ -6,8 +6,8 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ +#include "./tests.h" #include -#include #ifdef HAVE_UNISTD_H #include diff --git a/tests/ctest/CMakeLists.txt b/tests/ctest/CMakeLists.txt index 8ef65bc7587..62779198f20 100644 --- a/tests/ctest/CMakeLists.txt +++ b/tests/ctest/CMakeLists.txt @@ -9,8 +9,6 @@ foreach (file ${TESTS}) endif (ENABLE_OPTIMIZATIONS OR NOT ${name} MATCHES "opmphm") endforeach (file ${TESTS}) -include_directories ("${CMAKE_SOURCE_DIR}/src/libs/elektra") - target_link_elektra (test_array elektra-ease) target_link_elektra (test_conversion elektra-ease) target_link_elektra (test_keyname elektra-ease) diff --git a/tests/ctest/test_ks_opmphm.c b/tests/ctest/test_ks_opmphm.c index 5e0848312c2..424b2af4b9b 100644 --- a/tests/ctest/test_ks_opmphm.c +++ b/tests/ctest/test_ks_opmphm.c @@ -6,7 +6,8 @@ * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ -#include +#include "../../src/libs/elektra/opmphm.c" + #include #include diff --git a/tests/ctest/test_opmphm.c b/tests/ctest/test_opmphm.c index c5620b89568..aa71be316a4 100644 --- a/tests/ctest/test_opmphm.c +++ b/tests/ctest/test_opmphm.c @@ -7,7 +7,8 @@ */ #define OPMPHM_TEST -#include +#include "../../src/libs/elektra/opmphm.c" + #include // dummy for testing diff --git a/tests/ctest/test_opmphm_predictor.c b/tests/ctest/test_opmphm_predictor.c index 0e66ead2198..cd27b006059 100644 --- a/tests/ctest/test_opmphm_predictor.c +++ b/tests/ctest/test_opmphm_predictor.c @@ -6,7 +6,8 @@ * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ -#include +#include "../../src/libs/elektra/opmphmpredictor.c" + #include #include diff --git a/tests/ctest/test_size.c b/tests/ctest/test_size.c index eb961a9f2d6..4b4e38f5669 100644 --- a/tests/ctest/test_size.c +++ b/tests/ctest/test_size.c @@ -90,7 +90,7 @@ static void test_ksResize (void) ksDel (ks); ks = -#include "data_keyset.c" +#include "../data/data_keyset.c" succeed_if (ksGetSize (ks) == 102, "Problem loading keyset with 102 keys"); succeed_if (ksGetAlloc (ks) == 102, "alloc size wrong"); diff --git a/tests/kdb/testkdb_nested.cpp b/tests/kdb/testkdb_nested.cpp index 69aef11947b..06fdf6a7245 100644 --- a/tests/kdb/testkdb_nested.cpp +++ b/tests/kdb/testkdb_nested.cpp @@ -97,7 +97,7 @@ kdb::KeySet getAll () { using namespace ckdb; return -#include +#include "../data/data_allns.c" } diff --git a/tests/kdb/testkdb_simple.cpp b/tests/kdb/testkdb_simple.cpp index 59da7386667..9642d10258f 100644 --- a/tests/kdb/testkdb_simple.cpp +++ b/tests/kdb/testkdb_simple.cpp @@ -133,7 +133,7 @@ kdb::KeySet getAll () { using namespace ckdb; return -#include +#include "../data/data_allns.c" } // TODO: replace with proper ContainerEq From 4b3ba3dc835212d3d4752cb3fc403a48bd841b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:13 +0200 Subject: [PATCH 02/41] general: split elektra folder into core and kdb also extract base and pluginload object libraries --- benchmarks/opmphm.c | 6 +- scripts/cmake/Modules/LibAddLib.cmake | 6 +- scripts/cmake/Modules/LibAddMacros.cmake | 4 - src/include/CMakeLists.txt | 1 - src/libs/CMakeLists.txt | 125 ++++++++++- src/libs/base/CMakeLists.txt | 14 ++ src/libs/{elektra => base}/internal.c | 41 +--- src/libs/{elektra => base}/log.c | 0 src/libs/{elektra => base}/nolog.c | 0 src/libs/core/CMakeLists.txt | 24 +++ src/libs/{elektra => core}/cow.c | 0 src/libs/{elektra => core}/errors.c | 0 src/libs/{elektra => core}/kdbenum.c | 0 src/libs/{elektra => core}/key.c | 0 src/libs/{elektra => core}/keyhelpers.c | 14 +- src/libs/{elektra => core}/keymeta.c | 20 +- src/libs/{elektra => core}/keyname.c | 0 src/libs/{elektra => core}/keyset.c | 0 src/libs/{elektra => core}/keytest.c | 0 src/libs/{elektra => core}/keyvalue.c | 0 src/libs/{elektra => core}/opmphm.c | 0 src/libs/{elektra => core}/opmphmpredictor.c | 0 src/libs/{elektra => core}/proposal.c | 0 src/libs/{elektra => core}/rand.c | 0 src/libs/{elektra => core}/symbols.map | 97 ++------- src/libs/elektra/CMakeLists.txt | 200 ------------------ src/libs/elektra/README.md | 48 ----- src/libs/kdb/CMakeLists.txt | 14 ++ src/libs/{elektra => kdb}/backends.c | 0 src/libs/{elektra => kdb}/backends.h | 0 src/libs/{elektra => kdb}/changetracking.c | 0 src/libs/{elektra => kdb}/contracts.c | 0 src/libs/{elektra => kdb}/diff.c | 0 src/libs/{elektra => kdb}/hooks.c | 0 src/libs/{elektra => kdb}/hooks.h | 0 src/libs/{elektra => kdb}/kdb.c | 42 +--- src/libs/{elektra => kdb}/plugin.c | 0 src/libs/kdb/symbols.map | 53 +++++ .../{loader => pluginload}/CMakeLists.txt | 16 +- src/libs/{loader => pluginload}/dl.c | 0 src/libs/{loader => pluginload}/doc.c | 0 src/libs/{loader => pluginload}/static.c | 0 src/libs/{loader => pluginload}/symbols.map | 0 tests/ctest/test_backends.c | 2 +- tests/ctest/test_diffprivate.c | 3 +- tests/ctest/test_hooks.c | 2 +- tests/ctest/test_keyCopy_memerror.c | 15 +- tests/ctest/test_ks_opmphm.c | 2 +- tests/ctest/test_opmphm.c | 2 +- tests/ctest/test_opmphm_predictor.c | 2 +- 50 files changed, 296 insertions(+), 457 deletions(-) create mode 100644 src/libs/base/CMakeLists.txt rename src/libs/{elektra => base}/internal.c (96%) rename src/libs/{elektra => base}/log.c (100%) rename src/libs/{elektra => base}/nolog.c (100%) create mode 100644 src/libs/core/CMakeLists.txt rename src/libs/{elektra => core}/cow.c (100%) rename src/libs/{elektra => core}/errors.c (100%) rename src/libs/{elektra => core}/kdbenum.c (100%) rename src/libs/{elektra => core}/key.c (100%) rename src/libs/{elektra => core}/keyhelpers.c (83%) rename src/libs/{elektra => core}/keymeta.c (99%) rename src/libs/{elektra => core}/keyname.c (100%) rename src/libs/{elektra => core}/keyset.c (100%) rename src/libs/{elektra => core}/keytest.c (100%) rename src/libs/{elektra => core}/keyvalue.c (100%) rename src/libs/{elektra => core}/opmphm.c (100%) rename src/libs/{elektra => core}/opmphmpredictor.c (100%) rename src/libs/{elektra => core}/proposal.c (100%) rename src/libs/{elektra => core}/rand.c (100%) rename src/libs/{elektra => core}/symbols.map (68%) delete mode 100644 src/libs/elektra/CMakeLists.txt delete mode 100644 src/libs/elektra/README.md create mode 100644 src/libs/kdb/CMakeLists.txt rename src/libs/{elektra => kdb}/backends.c (100%) rename src/libs/{elektra => kdb}/backends.h (100%) rename src/libs/{elektra => kdb}/changetracking.c (100%) rename src/libs/{elektra => kdb}/contracts.c (100%) rename src/libs/{elektra => kdb}/diff.c (100%) rename src/libs/{elektra => kdb}/hooks.c (100%) rename src/libs/{elektra => kdb}/hooks.h (100%) rename src/libs/{elektra => kdb}/kdb.c (99%) rename src/libs/{elektra => kdb}/plugin.c (100%) create mode 100644 src/libs/kdb/symbols.map rename src/libs/{loader => pluginload}/CMakeLists.txt (61%) rename src/libs/{loader => pluginload}/dl.c (100%) rename src/libs/{loader => pluginload}/doc.c (100%) rename src/libs/{loader => pluginload}/static.c (100%) rename src/libs/{loader => pluginload}/symbols.map (100%) diff --git a/benchmarks/opmphm.c b/benchmarks/opmphm.c index ebb4a2164a8..df1dd0663c5 100644 --- a/benchmarks/opmphm.c +++ b/benchmarks/opmphm.c @@ -29,9 +29,9 @@ #include #endif -#include "../src/libs/elektra/opmphm.c" -#include "../src/libs/elektra/opmphmpredictor.c" -#include "../src/libs/elektra/rand.c" +#include "../src/libs/core/opmphm.c" +#include "../src/libs/core/opmphmpredictor.c" +#include "../src/libs/core/rand.c" #include #include diff --git a/scripts/cmake/Modules/LibAddLib.cmake b/scripts/cmake/Modules/LibAddLib.cmake index f9feb1c955a..d60208623ed 100644 --- a/scripts/cmake/Modules/LibAddLib.cmake +++ b/scripts/cmake/Modules/LibAddLib.cmake @@ -31,7 +31,6 @@ function (add_lib name) add_library (elektra-${name}-objects OBJECT ${ARG_SOURCES}) add_dependencies (elektra-${name}-objects generate_version_script) - # TODO: should probably done on a per library basis to allow decision between PRIVATE/PUBLIC/INTERFACE target_include_directories (elektra-${name}-objects PUBLIC ${ARG_INCLUDE_DIRECTORIES}) target_include_directories (elektra-${name}-objects SYSTEM PUBLIC ${ARG_INCLUDE_SYSTEM_DIRECTORIES}) @@ -47,7 +46,10 @@ function (add_lib name) if (BUILD_SHARED) add_library (elektra-${name} SHARED $) - target_link_libraries (elektra-${name} elektra-core ${ARG_LINK_ELEKTRA}) + target_link_libraries (elektra-${name} ${ARG_LINK_ELEKTRA}) + if (NOT ${name} STREQUAL "core") + target_link_libraries (elektra-${name} elektra-core) + endif () endif (BUILD_SHARED) set_property (GLOBAL APPEND PROPERTY "elektra-full_SRCS" "$") diff --git a/scripts/cmake/Modules/LibAddMacros.cmake b/scripts/cmake/Modules/LibAddMacros.cmake index 66526f8b9dc..ad1f56a2482 100644 --- a/scripts/cmake/Modules/LibAddMacros.cmake +++ b/scripts/cmake/Modules/LibAddMacros.cmake @@ -288,10 +288,6 @@ macro (add_headers HDR_FILES) file (GLOB SRC_HDR_FILES ${SOURCE_INCLUDE_DIR}/*.h) list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) - - set_source_files_properties (${BINARY_INCLUDE_DIR}/kdberrors.h PROPERTIES GENERATED ON SKIP_AUTOMOC ON) - set_source_files_properties (${BINARY_INCLUDE_DIR}/elektra/errors.h PROPERTIES GENERATED ON SKIP_AUTOMOC ON) - list (APPEND ${HDR_FILES} "${BINARY_INCLUDE_DIR}/kdberrors.h") endmacro (add_headers) # ~~~ diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 3f8e844d8ee..e49f6b1a6c6 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -19,7 +19,6 @@ check_include_file (ctype.h HAVE_CTYPE_H) check_include_file (errno.h HAVE_ERRNO_H) check_include_file (features.h HAVE_FEATURES_H) check_include_file (locale.h HAVE_LOCALE_H) -check_include_file (stdio.h HAVE_STDIO_H) check_include_file (stdlib.h HAVE_STDLIB_H) check_include_file (string.h HAVE_STRING_H) check_include_file (time.h HAVE_TIME_H) diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index 539f829ba67..073d7f75669 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -2,7 +2,8 @@ include (LibAddLib) set ( SUBDIRS - loader + core + kdb ease globbing meta @@ -16,9 +17,6 @@ set ( merge opts) -# The subdirectory for LibElektra must be the last entry! -list (APPEND SUBDIRS elektra) - set (SYM_MAPS "") foreach (subdir ${SUBDIRS}) list (APPEND SYM_MAPS "${subdir}/symbols.map") @@ -27,6 +25,9 @@ endforeach (subdir) # tools has special symbol handling list (INSERT SUBDIRS 0 tools) +# object libraries -> don't have symbol.map +list (INSERT SUBDIRS 0 base pluginload) + add_custom_command ( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/symbols.map" COMMAND awk 1 ${SYM_MAPS} | awk -v vfile=versions.def -f version_gen.awk > "${CMAKE_CURRENT_BINARY_DIR}/symbols.map" @@ -48,3 +49,119 @@ generate_man_page ( 7 COMPONENT elektra-doc) + +# ########################################################################################################################################## +# Handling of BUILD_FULL AND BUILD_STATIC # +# ########################################################################################################################################## + +# do not include plugins configured with SHARED_ONLY in the exported symbols as those are only used for the FULL and STATIC builds +get_property (SHARED_ONLY_PLUGINS GLOBAL PROPERTY SHARED_ONLY_PLUGINS) +set (ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${ADDED_PLUGINS}) +if (SHARED_ONLY_PLUGINS) + list (REMOVE_ITEM ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${SHARED_ONLY_PLUGINS}) +endif (SHARED_ONLY_PLUGINS) + +include (ExportPluginSymbols) +elektra_export_plugin_symbols ( + SOURCE + "${CMAKE_BINARY_DIR}/src/exported_symbols.c" + HEADER + "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h" + RESOLVER + ${KDB_DEFAULT_RESOLVER} + STORAGE + ${KDB_DEFAULT_STORAGE} + PLUGINS + ${ADDED_PLUGINS_WITHOUT_ONLY_SHARED}) + +# collect all the source files +get_property (elektra_SRCS GLOBAL PROPERTY elektra_SRCS) + +set (SOURCES ${elektra_SRCS} ${HDR_FILES}) +list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h") + +# the targets built to export +set (targets_built) + +set (__symbols_file "${CMAKE_BINARY_DIR}/src/libs/symbols.map") + +if (BUILD_FULL OR BUILD_STATIC) + # for the next two builds, append some more sources + get_property (elektra-full_SRCS GLOBAL PROPERTY elektra-full_SRCS) + list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/exported_symbols.c") + + # and get all libraries to link against + get_property (elektra-full_LIBRARIES GLOBAL PROPERTY elektra-full_LIBRARIES) + + # include the directories of all libraries for the static or full-shared build + get_property (elektra-full_INCLUDES GLOBAL PROPERTY elektra-full_INCLUDES) +endif (BUILD_FULL OR BUILD_STATIC) + +if (BUILD_FULL) + set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) + add_library (elektra-full SHARED ${SOURCES}) + add_dependencies (elektra-full generate_version_script) + + target_link_libraries (elektra-full ${elektra-full_LIBRARIES}) + # include the current binary directory to get exported_symbols.h + target_include_directories (elektra-full PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") + + set_target_properties ( + elektra-full + PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" + VERSION ${KDB_VERSION} + SOVERSION ${SO_VERSION} + CLEAN_DIRECT_OUTPUT 1 + LINKER_LANGUAGE CXX + LINK_DEPENDS "${__symbols_file}") + if (${LD_ACCEPTS_VERSION_SCRIPT}) + set_target_properties (elektra-full PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") + endif () + + install ( + TARGETS elektra-full + DESTINATION lib${LIB_SUFFIX} + EXPORT ElektraTargetsLibelektra + COMPONENT libelektra${SO_VERSION}-full) + + list (APPEND targets_built elektra-full) +endif (BUILD_FULL) + +if (BUILD_STATIC) + set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) + add_library (elektra-static STATIC ${SOURCES}) + add_dependencies (elektra-static generate_version_script) + + target_link_libraries (elektra-static ${elektra-full_LIBRARIES}) + # include the current binary directory to get exported_symbols.h + target_include_directories (elektra-static PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") + + set_target_properties ( + elektra-static + PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" + VERSION ${KDB_VERSION} + SOVERSION ${SO_VERSION} + CLEAN_DIRECT_OUTPUT 1 + LINKER_LANGUAGE CXX + LINK_DEPENDS "${__symbols_file}") + if (${LD_ACCEPTS_VERSION_SCRIPT}) + set_target_properties (elektra-static PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") + endif () + + install ( + TARGETS elektra-static + DESTINATION lib${LIB_SUFFIX} + EXPORT ElektraTargetsLibelektra + COMPONENT libelektra${SO_VERSION}) + + list (APPEND targets_built elektra-static) +endif (BUILD_STATIC) + +export (TARGETS ${targets_built} FILE "${CMAKE_CURRENT_BINARY_DIR}/ElektraTargetsLibelektra.cmake") +install ( + EXPORT ElektraTargetsLibelektra + DESTINATION "${TARGET_CMAKE_FOLDER}" + COMPONENT libelektra-dev) + +# if you want the same name for those 3 libraries, here is how to do it: +# http://www.itk.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F diff --git a/src/libs/base/CMakeLists.txt b/src/libs/base/CMakeLists.txt new file mode 100644 index 00000000000..f4fd996dde8 --- /dev/null +++ b/src/libs/base/CMakeLists.txt @@ -0,0 +1,14 @@ +set (SOURCES "internal.c") + +if (HAVE_LOGGER) + list (APPEND SOURCES log.c) +else (HAVE_LOGGER) + list (APPEND SOURCES nolog.c) +endif (HAVE_LOGGER) + +add_library (elektra-base OBJECT ${SOURCES}) +set_property (TARGET elektra-base PROPERTY POSITION_INDEPENDENT_CODE ON) + +if (BUILD_FULL OR BUILD_STATIC) + add_sources (elektra-full $) +endif (BUILD_FULL OR BUILD_STATIC) diff --git a/src/libs/elektra/internal.c b/src/libs/base/internal.c similarity index 96% rename from src/libs/elektra/internal.c rename to src/libs/base/internal.c index af81b6ed0a6..3d5fc540346 100644 --- a/src/libs/elektra/internal.c +++ b/src/libs/base/internal.c @@ -6,45 +6,13 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include -#include -#ifdef HAVE_KDBCONFIG_H -#include -#endif - -#ifdef HAVE_STDIO_H -#include -#endif - -#ifdef HAVE_STDARG_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_ERRNO_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_CTYPE_H -#include -#endif #include #include #include #include #include + #include #include #include @@ -54,6 +22,13 @@ #include #include +#include +#include +#include +#include +#include +#include + /** * @brief Internal Methods for Elektra * diff --git a/src/libs/elektra/log.c b/src/libs/base/log.c similarity index 100% rename from src/libs/elektra/log.c rename to src/libs/base/log.c diff --git a/src/libs/elektra/nolog.c b/src/libs/base/nolog.c similarity index 100% rename from src/libs/elektra/nolog.c rename to src/libs/base/nolog.c diff --git a/src/libs/core/CMakeLists.txt b/src/libs/core/CMakeLists.txt new file mode 100644 index 00000000000..21078928ef3 --- /dev/null +++ b/src/libs/core/CMakeLists.txt @@ -0,0 +1,24 @@ +include (LibAddLib) + +set ( + SOURCES + cow.c + errors.c + key.c + keyhelpers.c + keymeta.c + keyname.c + keyset.c + keytest.c + keyvalue.c + proposal.c + rand.c) + +if (ENABLE_OPTIMIZATIONS) + list (APPEND SOURCES opmphm.c opmphmpredictor.c) +endif (ENABLE_OPTIMIZATIONS) + +add_lib (core SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) +if (BUILD_SHARED) + target_link_libraries (elektra-core $) +endif (BUILD_SHARED) diff --git a/src/libs/elektra/cow.c b/src/libs/core/cow.c similarity index 100% rename from src/libs/elektra/cow.c rename to src/libs/core/cow.c diff --git a/src/libs/elektra/errors.c b/src/libs/core/errors.c similarity index 100% rename from src/libs/elektra/errors.c rename to src/libs/core/errors.c diff --git a/src/libs/elektra/kdbenum.c b/src/libs/core/kdbenum.c similarity index 100% rename from src/libs/elektra/kdbenum.c rename to src/libs/core/kdbenum.c diff --git a/src/libs/elektra/key.c b/src/libs/core/key.c similarity index 100% rename from src/libs/elektra/key.c rename to src/libs/core/key.c diff --git a/src/libs/elektra/keyhelpers.c b/src/libs/core/keyhelpers.c similarity index 83% rename from src/libs/elektra/keyhelpers.c rename to src/libs/core/keyhelpers.c index a69c3c2b693..7856e4a0e74 100644 --- a/src/libs/elektra/keyhelpers.c +++ b/src/libs/core/keyhelpers.c @@ -6,26 +6,16 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#ifdef HAVE_KDBCONFIG_H -#include -#endif -#ifdef HAVE_STDARG_H #include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STDLIB_H #include -#endif +#include #include #include +#include #include /** diff --git a/src/libs/elektra/keymeta.c b/src/libs/core/keymeta.c similarity index 99% rename from src/libs/elektra/keymeta.c rename to src/libs/core/keymeta.c index d220390364a..f936007ca92 100644 --- a/src/libs/elektra/keymeta.c +++ b/src/libs/core/keymeta.c @@ -106,25 +106,11 @@ #include #include -#ifdef HAVE_STDIO_H -#include -#endif - -#ifdef HAVE_STDARG_H +#include #include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STDLIB_H +#include #include -#endif - -#ifdef HAVE_ERRNO_H -#include -#endif +#include /** * Get the next metadata entry of a Key diff --git a/src/libs/elektra/keyname.c b/src/libs/core/keyname.c similarity index 100% rename from src/libs/elektra/keyname.c rename to src/libs/core/keyname.c diff --git a/src/libs/elektra/keyset.c b/src/libs/core/keyset.c similarity index 100% rename from src/libs/elektra/keyset.c rename to src/libs/core/keyset.c diff --git a/src/libs/elektra/keytest.c b/src/libs/core/keytest.c similarity index 100% rename from src/libs/elektra/keytest.c rename to src/libs/core/keytest.c diff --git a/src/libs/elektra/keyvalue.c b/src/libs/core/keyvalue.c similarity index 100% rename from src/libs/elektra/keyvalue.c rename to src/libs/core/keyvalue.c diff --git a/src/libs/elektra/opmphm.c b/src/libs/core/opmphm.c similarity index 100% rename from src/libs/elektra/opmphm.c rename to src/libs/core/opmphm.c diff --git a/src/libs/elektra/opmphmpredictor.c b/src/libs/core/opmphmpredictor.c similarity index 100% rename from src/libs/elektra/opmphmpredictor.c rename to src/libs/core/opmphmpredictor.c diff --git a/src/libs/elektra/proposal.c b/src/libs/core/proposal.c similarity index 100% rename from src/libs/elektra/proposal.c rename to src/libs/core/proposal.c diff --git a/src/libs/elektra/rand.c b/src/libs/core/rand.c similarity index 100% rename from src/libs/elektra/rand.c rename to src/libs/core/rand.c diff --git a/src/libs/elektra/symbols.map b/src/libs/core/symbols.map similarity index 68% rename from src/libs/elektra/symbols.map rename to src/libs/core/symbols.map index dad31cdae04..e148f9ea9d4 100644 --- a/src/libs/elektra/symbols.map +++ b/src/libs/core/symbols.map @@ -1,15 +1,7 @@ libelektra_0.8 { - # kdbmodule.h - elektraModulesClose; - elektraModulesInit; - elektraModulesLoad; - - # plugin loading: - elektraPluginClose; - elektraPluginGetFunction; - elektraPluginOpen; - - # kdbhelper.h + # TODO: should not be exported here + elektraAbort; + elektraLog; elektraCalloc; elektraFormat; elektraFree; @@ -26,18 +18,6 @@ libelektra_0.8 { elektraVFormat; elektraWriteArrayNumber; - # kdbease.h - keyCompare; - keyCompareMeta; - - # kdb.h - ## KDB functions - kdbClose; - kdbGet; - kdbOpen; - kdbSet; - - ## Key functions keyAddBaseName; keyAddName; keyBaseName; @@ -79,7 +59,6 @@ libelektra_0.8 { keyValue; keyVNew; - ## KeySet functions ksAppend; ksAppendKey; ksAtCursor; @@ -108,7 +87,18 @@ libelektra_0.8 { }; libelektra_1.0 { - # kdberrors.h + keyIsLocked; + keyLock; + keyMeta; + + ksSearch; + ksIncRef; + ksDecRef; + ksGetRef; + + elektraReadNamespace; + + # FIXME: should be separate lib ELEKTRA_ERROR_CONFLICTING_STATE; ELEKTRA_ERROR_INSTALLATION; ELEKTRA_ERROR_INTERFACE; @@ -128,58 +118,14 @@ libelektra_1.0 { ELEKTRA_WARNING_RESOURCE; ELEKTRA_WARNING_VALIDATION_SEMANTIC; ELEKTRA_WARNING_VALIDATION_SYNTACTIC; - - # kdb.h - elektraGOptsContract; - elektraGOptsContractFromStrings; - - ## Key functions - keyIsLocked; - keyLock; - keyMeta; - - ## KeySet functions - ksSearch; - ksIncRef; - ksDecRef; - ksGetRef; - - # kdbchangetracking.h - elektraChangeTrackingGetContextFromKdb; - elektraChangeTrackingGetContextFromPlugin; - elektraChangeTrackingCalculateDiff; - - # kdbdiff.h - elektraDiffCalculate; - elektraDiffIsEmpty; - elektraDiffGetParentKey; - elektraDiffDel; - elektraDiffIncRef; - elektraDiffDecRef; - elektraDiffGetRef; - elektraDiffGetAddedKeys; - elektraDiffGetRemovedKeys; - elektraDiffGetModifiedKeys; - elektraDiffKeyValueChanged; - elektraDiffKeyOnlyMetaChanged; - elektraDiffGetAddedMetaKeys; - elektraDiffGetRemovedMetaKeys; - elektraDiffGetModifiedMetaKeys; - - }; libelektraprivate_1.0 { - # kdbprivate.h - elektraAbort; elektraKeyNameCanonicalize; elektraKeyNameEscapePart; elektraKeyNameUnescape; elektraKeyNameValidate; elektraKsPopAtCursor; - elektraFindInternalNotificationPlugin; - elektraPluginMissing; - elektraPluginVersion; elektraRenameKeys; keyIsDir; keyIsProc; @@ -201,21 +147,10 @@ libelektraprivate_1.0 { elektraIsArrayPart; elektraReadNamespace; - # TODO [new_backend]: should be removed, tests should depend differently on this - backendsDivide; - - elektraDiffNew; - elektraChangeTrackingCreateContextForTesting; - elektraChangeTrackingContextDel; - - # kdblogger.h - elektraLog; - - # kdbrand.h elektraRand; elektraRandGetInitSeed; - # kdberrors.h + # FIXME: should be separate lib elektraSetErrorCONFLICTING_STATE; elektraSetErrorINSTALLATION; elektraSetErrorINTERFACE; diff --git a/src/libs/elektra/CMakeLists.txt b/src/libs/elektra/CMakeLists.txt deleted file mode 100644 index 95c2721ff03..00000000000 --- a/src/libs/elektra/CMakeLists.txt +++ /dev/null @@ -1,200 +0,0 @@ -# do not include plugins configured with SHARED_ONLY in the exported symbols as those are only used for the FULL and STATIC builds -get_property (SHARED_ONLY_PLUGINS GLOBAL PROPERTY SHARED_ONLY_PLUGINS) -set (ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${ADDED_PLUGINS}) -if (SHARED_ONLY_PLUGINS) - list (REMOVE_ITEM ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${SHARED_ONLY_PLUGINS}) -endif (SHARED_ONLY_PLUGINS) - -include (ExportPluginSymbols) -elektra_export_plugin_symbols ( - SOURCE - "${CMAKE_BINARY_DIR}/src/exported_symbols.c" - HEADER - "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h" - RESOLVER - ${KDB_DEFAULT_RESOLVER} - STORAGE - ${KDB_DEFAULT_STORAGE} - PLUGINS - ${ADDED_PLUGINS_WITHOUT_ONLY_SHARED}) - -# Include the shared header files of the Elektra project -include (LibAddMacros) -add_headers (HDR_FILES) - -# now add all source files of this folder -file (GLOB SRC_FILES *.c) - -# remove those we don't want.. -file (GLOB RM_FILES kdbmainpage.c) -unset (RM_LOG_FILE) -if (HAVE_LOGGER) - file (GLOB RM_LOG_FILE nolog.c) -else (HAVE_LOGGER) - file (GLOB RM_LOG_FILE log.c) -endif (HAVE_LOGGER) -list (REMOVE_ITEM SRC_FILES ${RM_FILES} ${RM_LOG_FILE}) - -# remove the opmphm files -if (NOT ENABLE_OPTIMIZATIONS) - file (GLOB OPMPHM_FILES opmphm*.c) - list (REMOVE_ITEM SRC_FILES ${OPMPHM_FILES}) -endif (NOT ENABLE_OPTIMIZATIONS) - -# now add all source files of other folders -get_property (elektra_SRCS GLOBAL PROPERTY elektra_SRCS) -list (APPEND SRC_FILES ${elektra_SRCS}) - -set (SOURCES ${SRC_FILES} ${HDR_FILES}) -list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h") - -# the targets built to export -set (targets_built) - -set (__symbols_file "${CMAKE_BINARY_DIR}/src/libs/symbols.map") - -if (BUILD_SHARED) - file ( - GLOB - KDB_FILES - kdb.c - mount.c - hooks.c - backends.c - plugin.c - contracts.c - changetracking.c - diff.c) - set (CORE_FILES ${SOURCES}) - list (REMOVE_ITEM CORE_FILES ${KDB_FILES}) - set (KDB_FILES ${KDB_FILES} ${HDR_FILES}) - - get_property (elektra-shared_SRCS GLOBAL PROPERTY elektra-shared_SRCS) - add_library (elektra-core SHARED ${CORE_FILES} ${elektra-shared_SRCS}) - add_dependencies (elektra-core generate_version_script) - - get_property (elektra-shared_LIBRARIES GLOBAL PROPERTY elektra-shared_LIBRARIES) - target_link_libraries (elektra-core ${elektra-shared_LIBRARIES}) - - get_property (elektra-shared_INCLUDES GLOBAL PROPERTY elektra-shared_INCLUDES) - include_directories (${elektra-shared_INCLUDES}) - - add_library (elektra-kdb SHARED ${KDB_FILES}) - add_dependencies (elektra-kdb generate_version_script) - target_link_libraries (elektra-kdb elektra-core) - - get_property (elektra-extension_LIBRARIES GLOBAL PROPERTY elektra-extension_LIBRARIES) - - set (elektra-all_LIBRARIES elektra-core elektra-kdb ${elektra-extension_LIBRARIES}) - set_target_properties ( - ${elektra-all_LIBRARIES} - PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H" - VERSION ${KDB_VERSION} - SOVERSION ${SO_VERSION} - CLEAN_DIRECT_OUTPUT 1 - LINK_DEPENDS "${__symbols_file}") - - if (${LD_ACCEPTS_VERSION_SCRIPT}) - set_target_properties (${elektra-all_LIBRARIES} PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") - endif () - - # ~~~ - # RPATH settings, see http://www.itk.org/Wiki/CMake_RPATH_handling - # those settings are needed to find the plugins at runtime even without ld.so.conf - # search only in the prefix the user decided to install elektra - # (e.g. /usr/local/) - # ~~~ - set (ELEKTRA_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${TARGET_PLUGIN_FOLDER}") - set_target_properties (${elektra-all_LIBRARIES} PROPERTIES INSTALL_RPATH "${ELEKTRA_RPATH}") - - install ( - TARGETS elektra-core elektra-kdb - DESTINATION lib${LIB_SUFFIX} - EXPORT ElektraTargetsLibelektra - COMPONENT libelektra${SO_VERSION}) - - list (APPEND targets_built ${elektra-all_LIBRARIES}) -endif (BUILD_SHARED) - -if (BUILD_FULL OR BUILD_STATIC) - - # for the next two builds, append some more sources - get_property (elektra-full_SRCS GLOBAL PROPERTY elektra-full_SRCS) - list (APPEND SOURCES ${elektra-full_SRCS} ${BINARY_INCLUDE_DIR}/kdberrors.h) - list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/exported_symbols.c") - - # and get all libraries to link against - get_property (elektra-full_LIBRARIES GLOBAL PROPERTY elektra-full_LIBRARIES) - - # include the directories of all libraries for the static or full-shared build - get_property (elektra-full_INCLUDES GLOBAL PROPERTY elektra-full_INCLUDES) -endif (BUILD_FULL OR BUILD_STATIC) - -if (BUILD_FULL) - set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) - add_library (elektra-full SHARED ${SOURCES}) - add_dependencies (elektra-full generate_version_script) - - target_link_libraries (elektra-full ${elektra-full_LIBRARIES}) - # include the current binary directory to get exported_symbols.h - target_include_directories (elektra-full PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") - - set_target_properties ( - elektra-full - PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" - VERSION ${KDB_VERSION} - SOVERSION ${SO_VERSION} - CLEAN_DIRECT_OUTPUT 1 - LINKER_LANGUAGE CXX - LINK_DEPENDS "${__symbols_file}") - if (${LD_ACCEPTS_VERSION_SCRIPT}) - set_target_properties (elektra-full PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") - endif () - - install ( - TARGETS elektra-full - DESTINATION lib${LIB_SUFFIX} - EXPORT ElektraTargetsLibelektra - COMPONENT libelektra${SO_VERSION}-full) - - list (APPEND targets_built elektra-full) -endif (BUILD_FULL) - -if (BUILD_STATIC) - set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) - add_library (elektra-static STATIC ${SOURCES}) - add_dependencies (elektra-static generate_version_script) - - target_link_libraries (elektra-static ${elektra-full_LIBRARIES}) - # include the current binary directory to get exported_symbols.h - target_include_directories (elektra-static PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") - - set_target_properties ( - elektra-static - PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" - VERSION ${KDB_VERSION} - SOVERSION ${SO_VERSION} - CLEAN_DIRECT_OUTPUT 1 - LINKER_LANGUAGE CXX - LINK_DEPENDS "${__symbols_file}") - if (${LD_ACCEPTS_VERSION_SCRIPT}) - set_target_properties (elektra-static PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") - endif () - - install ( - TARGETS elektra-static - DESTINATION lib${LIB_SUFFIX} - EXPORT ElektraTargetsLibelektra - COMPONENT libelektra${SO_VERSION}) - - list (APPEND targets_built elektra-static) -endif (BUILD_STATIC) - -export (TARGETS ${targets_built} FILE "${CMAKE_CURRENT_BINARY_DIR}/ElektraTargetsLibelektra.cmake") -install ( - EXPORT ElektraTargetsLibelektra - DESTINATION "${TARGET_CMAKE_FOLDER}" - COMPONENT libelektra-dev) - -# if you want the same name for those 3 libraries, here is how to do it: -# http://www.itk.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F diff --git a/src/libs/elektra/README.md b/src/libs/elektra/README.md deleted file mode 100644 index 06702284f4e..00000000000 --- a/src/libs/elektra/README.md +++ /dev/null @@ -1,48 +0,0 @@ -This folder contains the core libraries of Elektra. - -> **Note:** Some information in this document is outdated and will change before the release of Elektra 1.0. - -# Content - -Since 0.8.15 this folder -contains multiple libraries: - -![Overview of Libraries](/doc/images/overview_libs.png) - -## Libelektra - -``` -libelektra.so -``` - -Libelektra is now only a stub for legacy applications. It basically only links all previous libraries -together. It should _not_ be used for new applications or plugins. - -## Libfull - -``` -libelektra-full.so -``` - -Contains all sources of Elektra linked to together in one large library. -Useful if you do not want dynamically loaded plugins. -Should only be used on embedded systems (where whole application stack is done by you) and for tests. - -## Libstatic - -``` -libelektra-static.so -``` - -Contains all sources of Elektra linked to together in one large library. -Useful if you need your application to be linked statically against Elektra. -Should only be used on embedded systems (where whole application stack is done by you) and for tests. - -## Libkdb - -``` -libelektra-kdb.so - (kdb*) -``` - -Contains `kdb*` symbols and applications should link against it. diff --git a/src/libs/kdb/CMakeLists.txt b/src/libs/kdb/CMakeLists.txt new file mode 100644 index 00000000000..126922881b4 --- /dev/null +++ b/src/libs/kdb/CMakeLists.txt @@ -0,0 +1,14 @@ +set ( + SOURCES + backends.c + contracts.c + hooks.c + kdb.c + plugin.c + changetracking.c + diff.c) + +add_lib (kdb SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) +if (BUILD_SHARED) + target_link_libraries (elektra-kdb $) +endif (BUILD_SHARED) diff --git a/src/libs/elektra/backends.c b/src/libs/kdb/backends.c similarity index 100% rename from src/libs/elektra/backends.c rename to src/libs/kdb/backends.c diff --git a/src/libs/elektra/backends.h b/src/libs/kdb/backends.h similarity index 100% rename from src/libs/elektra/backends.h rename to src/libs/kdb/backends.h diff --git a/src/libs/elektra/changetracking.c b/src/libs/kdb/changetracking.c similarity index 100% rename from src/libs/elektra/changetracking.c rename to src/libs/kdb/changetracking.c diff --git a/src/libs/elektra/contracts.c b/src/libs/kdb/contracts.c similarity index 100% rename from src/libs/elektra/contracts.c rename to src/libs/kdb/contracts.c diff --git a/src/libs/elektra/diff.c b/src/libs/kdb/diff.c similarity index 100% rename from src/libs/elektra/diff.c rename to src/libs/kdb/diff.c diff --git a/src/libs/elektra/hooks.c b/src/libs/kdb/hooks.c similarity index 100% rename from src/libs/elektra/hooks.c rename to src/libs/kdb/hooks.c diff --git a/src/libs/elektra/hooks.h b/src/libs/kdb/hooks.h similarity index 100% rename from src/libs/elektra/hooks.h rename to src/libs/kdb/hooks.h diff --git a/src/libs/elektra/kdb.c b/src/libs/kdb/kdb.c similarity index 99% rename from src/libs/elektra/kdb.c rename to src/libs/kdb/kdb.c index 5d040830ae8..25430ab24d8 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/kdb/kdb.c @@ -6,36 +6,6 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include - -#ifdef HAVE_LOCALE_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_STDARG_H -#include -#endif - -#ifdef HAVE_CTYPE_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STDIO_H -#include -#endif - -#ifdef HAVE_ERRNO_H -#include -#endif - #include #include #include @@ -59,6 +29,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + #include "./backends.h" #include "./hooks.h" @@ -1320,9 +1298,9 @@ static const char * phaseName (ElektraKdbPhase phase) return "RESOLVER"; case ELEKTRA_KDB_GET_PHASE_CACHECHECK: return "CACHECHECK"; - case ELEKTRA_KDB_GET_PHASE_PRE_STORAGE: // ELEKTRA_KDB_SET_PHASE_PRE_STORAGE + case ELEKTRA_KDB_GET_PHASE_PRE_STORAGE: // ELEKTRA_KDB_SET_PHASE_PRE_STORAGE return "PRE_STORAGE"; - case ELEKTRA_KDB_GET_PHASE_STORAGE: // ELEKTRA_KDB_SET_PHASE_STORAGE + case ELEKTRA_KDB_GET_PHASE_STORAGE: // ELEKTRA_KDB_SET_PHASE_STORAGE return "STORAGE"; case ELEKTRA_KDB_GET_PHASE_POST_STORAGE: // ELEKTRA_KDB_SET_PHASE_POST_STORAGE return "POST_STORAGE"; diff --git a/src/libs/elektra/plugin.c b/src/libs/kdb/plugin.c similarity index 100% rename from src/libs/elektra/plugin.c rename to src/libs/kdb/plugin.c diff --git a/src/libs/kdb/symbols.map b/src/libs/kdb/symbols.map new file mode 100644 index 00000000000..90c57816044 --- /dev/null +++ b/src/libs/kdb/symbols.map @@ -0,0 +1,53 @@ +libelektra_0.8 { + elektraModulesClose; + elektraModulesInit; + elektraModulesLoad; + + elektraPluginClose; + elektraPluginGetFunction; + elektraPluginOpen; + + kdbClose; + kdbGet; + kdbOpen; + kdbSet; +}; + +libelektra_1.0 { + elektraGOptsContract; + elektraGOptsContractFromStrings; + + # FIXME: should be separate lib + # kdbchangetracking.h + elektraChangeTrackingGetContextFromKdb; + elektraChangeTrackingGetContextFromPlugin; + elektraChangeTrackingCalculateDiff; + + # FIXME: separate lib? part of merge? + # kdbdiff.h + elektraDiffCalculate; + elektraDiffIsEmpty; + elektraDiffGetParentKey; + elektraDiffDel; + elektraDiffIncRef; + elektraDiffDecRef; + elektraDiffGetRef; + elektraDiffGetAddedKeys; + elektraDiffGetRemovedKeys; + elektraDiffGetModifiedKeys; + elektraDiffKeyValueChanged; + elektraDiffKeyOnlyMetaChanged; + elektraDiffGetAddedMetaKeys; + elektraDiffGetRemovedMetaKeys; + elektraDiffGetModifiedMetaKeys; +}; + +libelektraprivate_1.0 { + elektraFindInternalNotificationPlugin; + + # FIXME: separate lib? part of merge? + # kdbdiff.h + elektraDiffNew; + elektraChangeTrackingCreateContextForTesting; + elektraChangeTrackingContextDel; +}; diff --git a/src/libs/loader/CMakeLists.txt b/src/libs/pluginload/CMakeLists.txt similarity index 61% rename from src/libs/loader/CMakeLists.txt rename to src/libs/pluginload/CMakeLists.txt index 0fb8affec37..03f10e1be3e 100644 --- a/src/libs/loader/CMakeLists.txt +++ b/src/libs/pluginload/CMakeLists.txt @@ -1,11 +1,10 @@ include (LibAddMacros) -add_sources (elektra-full "static.c") +if (BUILD_FULL OR BUILD_STATIC) + add_sources (elektra-full "static.c") +endif (BUILD_FULL OR BUILD_STATIC) if (BUILD_SHARED) - add_sources (elektra-shared "dl.c") - add_includes (elektra-shared) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set (BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) @@ -22,8 +21,13 @@ if (BUILD_SHARED) CMAKE_ARGS ${BUILD_ARGS} BUILD_IN_SOURCE 1) - add_includes (elektra-shared "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/include") set (CMAKE_DL_LIBS "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/lib/libdl.dll.a") + + add_library (elektra-pluginload OBJECT ${CMAKE_DL_LIBS}) + target_include_directories (elektra-pluginload SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/include") + else () + add_library (elektra-pluginload OBJECT dl.c) endif () - add_libraries (elektra-shared ${CMAKE_DL_LIBS}) + + set_property (TARGET elektra-pluginload PROPERTY POSITION_INDEPENDENT_CODE ON) endif (BUILD_SHARED) diff --git a/src/libs/loader/dl.c b/src/libs/pluginload/dl.c similarity index 100% rename from src/libs/loader/dl.c rename to src/libs/pluginload/dl.c diff --git a/src/libs/loader/doc.c b/src/libs/pluginload/doc.c similarity index 100% rename from src/libs/loader/doc.c rename to src/libs/pluginload/doc.c diff --git a/src/libs/loader/static.c b/src/libs/pluginload/static.c similarity index 100% rename from src/libs/loader/static.c rename to src/libs/pluginload/static.c diff --git a/src/libs/loader/symbols.map b/src/libs/pluginload/symbols.map similarity index 100% rename from src/libs/loader/symbols.map rename to src/libs/pluginload/symbols.map diff --git a/tests/ctest/test_backends.c b/tests/ctest/test_backends.c index 9c2056375dc..90b69e23c34 100644 --- a/tests/ctest/test_backends.c +++ b/tests/ctest/test_backends.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include "../../src/libs/elektra/backends.h" +#include "../../src/libs/kdb/backends.c" #include #include diff --git a/tests/ctest/test_diffprivate.c b/tests/ctest/test_diffprivate.c index bbd6782d78e..ca9c3ee095a 100644 --- a/tests/ctest/test_diffprivate.c +++ b/tests/ctest/test_diffprivate.c @@ -1,4 +1,5 @@ -#include "../../src/libs/elektra/diff.c" +#include "../../src/libs/kdb/diff.c" + #include static void test_keyValueDifferent_bothNull_shouldReturnFalse (void) diff --git a/tests/ctest/test_hooks.c b/tests/ctest/test_hooks.c index 3397bbc47dc..af8d468eb1e 100644 --- a/tests/ctest/test_hooks.c +++ b/tests/ctest/test_hooks.c @@ -6,7 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include "../../src/libs/elektra/hooks.c" +#include "../../src/libs/kdb/hooks.c" #include diff --git a/tests/ctest/test_keyCopy_memerror.c b/tests/ctest/test_keyCopy_memerror.c index 5f68e0135e3..94d41a08bf5 100644 --- a/tests/ctest/test_keyCopy_memerror.c +++ b/tests/ctest/test_keyCopy_memerror.c @@ -6,14 +6,13 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#include "../../src/libs/elektra/cow.c" -#include "../../src/libs/elektra/internal.c" -#include "../../src/libs/elektra/key.c" -#include "../../src/libs/elektra/keyhelpers.c" -#include "../../src/libs/elektra/keyname.c" -#include "../../src/libs/elektra/keyvalue.c" -#include "../../src/libs/elektra/opmphm.c" -#include "../../src/libs/elektra/opmphmpredictor.c" +#include "../../src/libs/core/cow.c" +#include "../../src/libs/core/key.c" +#include "../../src/libs/core/keyhelpers.c" +#include "../../src/libs/core/keyname.c" +#include "../../src/libs/core/keyvalue.c" +#include "../../src/libs/core/opmphm.c" +#include "../../src/libs/core/opmphmpredictor.c" #include diff --git a/tests/ctest/test_ks_opmphm.c b/tests/ctest/test_ks_opmphm.c index 424b2af4b9b..1211710574b 100644 --- a/tests/ctest/test_ks_opmphm.c +++ b/tests/ctest/test_ks_opmphm.c @@ -6,7 +6,7 @@ * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ -#include "../../src/libs/elektra/opmphm.c" +#include "../../src/libs/core/opmphm.c" #include diff --git a/tests/ctest/test_opmphm.c b/tests/ctest/test_opmphm.c index aa71be316a4..3551c3e4c9f 100644 --- a/tests/ctest/test_opmphm.c +++ b/tests/ctest/test_opmphm.c @@ -7,7 +7,7 @@ */ #define OPMPHM_TEST -#include "../../src/libs/elektra/opmphm.c" +#include "../../src/libs/core/opmphm.c" #include diff --git a/tests/ctest/test_opmphm_predictor.c b/tests/ctest/test_opmphm_predictor.c index cd27b006059..fdcb95b433b 100644 --- a/tests/ctest/test_opmphm_predictor.c +++ b/tests/ctest/test_opmphm_predictor.c @@ -6,7 +6,7 @@ * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ -#include "../../src/libs/elektra/opmphmpredictor.c" +#include "../../src/libs/core/opmphmpredictor.c" #include From a6fb544adc8478bb419c038b2d6548246f3fbade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:14 +0200 Subject: [PATCH 03/41] utility: use static inline for some functions This changes many functions from internal.c into static inline since they are just wrappers with extra asserts. This change should improve the compiler's ability to perform optimizations, since it now always has insight into the functions. The static inline functions are only declared in internal headers. To make them available publically, we also re-export them via elektra-utility.so. --- src/include/elektra/utility/alloc.h | 24 +++ src/include/internal/utility/alloc.h | 22 +- src/include/internal/utility/alloc_impl.h | 194 +++++++++++++++++ src/include/internal/utility/compare.h | 71 +++++- src/include/internal/utility/string.h | 24 ++- src/libs/base/internal.c | 250 ---------------------- src/libs/core/symbols.map | 19 -- src/libs/utility/CMakeLists.txt | 3 +- src/libs/utility/alloc.c | 5 + src/libs/utility/symbols.map | 20 ++ 10 files changed, 347 insertions(+), 285 deletions(-) create mode 100644 src/include/elektra/utility/alloc.h create mode 100644 src/include/internal/utility/alloc_impl.h create mode 100644 src/libs/utility/alloc.c diff --git a/src/include/elektra/utility/alloc.h b/src/include/elektra/utility/alloc.h new file mode 100644 index 00000000000..b401410e3ca --- /dev/null +++ b/src/include/elektra/utility/alloc.h @@ -0,0 +1,24 @@ +/** + * @file + * + * @brief Helper for memory management. + * + * May be used to match the internally used allocator. + * + * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) + */ + +#ifndef ELEKTRA_UTILITY_ALLOC_H +#define ELEKTRA_UTILITY_ALLOC_H + +#include + +void * elektraMalloc (size_t size); +void * elektraCalloc (size_t size); +int elektraRealloc (void ** buffer, size_t size); +void elektraFree (void * ptr); + +char * elektraStrDup (const char * s); +void * elektraMemDup (const void * s, size_t n); + +#endif // ELEKTRA_UTILITY_ALLOC_H diff --git a/src/include/internal/utility/alloc.h b/src/include/internal/utility/alloc.h index 589589c2a50..00a4a186a11 100644 --- a/src/include/internal/utility/alloc.h +++ b/src/include/internal/utility/alloc.h @@ -12,8 +12,8 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ -#ifndef ELEKTRA_UTILITY_ALLOC_H -#define ELEKTRA_UTILITY_ALLOC_H +#ifndef ELEKTRA_UTILITY_ALLOC_INTERNAL_H +#define ELEKTRA_UTILITY_ALLOC_INTERNAL_H #include @@ -28,17 +28,21 @@ namespace ckdb extern "C" { #endif -int elektraRealloc (void ** buffer, size_t size); -void * elektraMalloc (size_t size); -void * elektraCalloc (size_t size); -void elektraFree (void * ptr); +static inline void * elektraMalloc (size_t size); +static inline void * elektraCalloc (size_t size); +static inline int elektraRealloc (void ** buffer, size_t size); +static inline void elektraFree (void * ptr); -char * elektraStrDup (const char * s); -void * elektraMemDup (const void * s, size_t n); +static inline char * elektraStrDup (const char * s); +static inline void * elektraMemDup (const void * s, size_t n); #ifdef __cplusplus } } #endif -#endif // ELEKTRA_UTILITY_ALLOC_H +// now that we have declared the functions as static inline, +// we include a copy of their implementation +#include + +#endif // ELEKTRA_UTILITY_ALLOC_INTERNAL_H diff --git a/src/include/internal/utility/alloc_impl.h b/src/include/internal/utility/alloc_impl.h new file mode 100644 index 00000000000..64f71169fec --- /dev/null +++ b/src/include/internal/utility/alloc_impl.h @@ -0,0 +1,194 @@ +/** + * @file + * + * @brief Helper for memory management. + * + * This file contains the implementations for the functions declared in + * and + * + * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) + */ + +#ifndef ELEKTRA_UTILITY_ALLOC_IMPL_H +#define ELEKTRA_UTILITY_ALLOC_IMPL_H + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +namespace ckdb +{ +extern "C" { +#endif + +/**Reallocate Storage in a save way. + * + *@code +if (elektraRealloc ((void **) & buffer, new_length) < 0) { + // here comes the failure handler + // you can still use the old buffer +#if DEBUG + fprintf (stderr, "Reallocation error\n"); +#endif + elektraFree (buffer); + buffer = 0; + // return with error +} + *@endcode + * + * @param buffer is a pointer to a elektraMalloc + * @param size is the new size for the memory + * @retval -1 on failure + * @retval 0 on success + * @ingroup internal + */ +int elektraRealloc (void ** buffer, size_t size) +{ + ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); + void * ptr; + void * svr = *buffer; + + ptr = realloc (*buffer, size); + ELEKTRA_ASSERT (ptr, "Memory (re)allocation failed with size %zu", size); + if (ptr == NULL) + { + // TODO: is this safe? couldn't the old buffer already be destroyed? + *buffer = svr; /* restore old buffer*/ + return -1; + } + else + { + *buffer = ptr; + return 0; + } +} + +/**Free memory of Elektra or its backends. + * + * @param ptr the pointer to free + * + * If ptr is NULL, no operation is performed. + * + * @ingroup internal + * @see elektraMalloc + */ +void elektraFree (void * ptr) +{ + free (ptr); +} + +/** + * Allocate memory for Elektra. + * + * @code +if ((buffer = elektraMalloc (length)) == 0) { + // here comes the failure handler + // no allocation happened here, so don't use buffer +#if DEBUG + fprintf (stderr, "Allocation error"); +#endif + // return with error +} + * @endcode + * + * @param size the requested size + * + * This function is compatible to ANSI-C malloc + * @see elektraFree + * @see elektraCalloc + */ +void * elektraMalloc (size_t size) +{ + ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); + void * ret = malloc (size); + ELEKTRA_ASSERT (ret, "Memory allocation failed with size %zu", size); + return ret; +} + +/**Allocate memory for Elektra. + * + * Memory will be set to 0. + * + * @param size the requested size + * @see elektraMalloc + */ +void * elektraCalloc (size_t size) +{ + ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); + void * ret = calloc (1, size); + ELEKTRA_ASSERT (ret, "Memory allocation failed with size %zu", size); + return ret; +} + +/**Copy string into new allocated memory. + * + * You need to free the memory yourself. + * + * @note that size is determined at runtime. + * So if you have a size information, don't use + * that function. + * + * @param s the null-terminated string to duplicate + * + * @ingroup internal + * @return 0 if out of memory, a pointer otherwise + * @pre s must be a c-string. + * @see elektraFree + * @see elektraStrLen + * @see elektraMemDup + */ +char * elektraStrDup (const char * s) +{ + char * tmp = 0; + size_t l = 0; + ELEKTRA_ASSERT (s, "Tried to duplicate null pointer"); + + l = strlen (s) + 1; + ELEKTRA_ASSERT (l, "Size of string to duplicate is zero"); +#ifdef __cplusplus + tmp = static_cast (elektraMalloc (l)); +#else + tmp = elektraMalloc (l); +#endif + if (tmp) + { + memcpy (tmp, s, l); + } + + return tmp; +} + +/**Copy buffer into new allocated memory. + * + * You need to free the memory yourself. + * + * This function also works with \\0 characters + * in the buffer. The length is taken as given, + * it must be correct. + * + * @return 0 if out of memory, a pointer otherwise + * @param s must be an allocated buffer + * @param n the number of bytes to copy from s + * @ingroup internal + */ +void * elektraMemDup (const void * s, size_t n) +{ + void * tmp = 0; + ELEKTRA_ASSERT (n, "Size of memory to duplicate is zero"); + + tmp = elektraMalloc (n); + if (tmp) memcpy (tmp, s, n); + + return tmp; +} + +#ifdef __cplusplus +} +} +#endif + +#endif // ELEKTRA_UTILITY_ALLOC_IMPL_H diff --git a/src/include/internal/utility/compare.h b/src/include/internal/utility/compare.h index 2f6f53a5e8f..65960ba9e7b 100644 --- a/src/include/internal/utility/compare.h +++ b/src/include/internal/utility/compare.h @@ -27,10 +27,73 @@ extern "C" { #define VOID_CAST(x) ((const void *) (x)) #endif -int elektraStrCmp (const char * s1, const char * s2); -int elektraStrNCmp (const char * s1, const char * s2, size_t n); -int elektraStrCaseCmp (const char * s1, const char * s2); -int elektraStrNCaseCmp (const char * s1, const char * s2, size_t n); +/**@brief Compare Strings. + * + * @param s1 The first string to be compared + * @param s2 The second string to be compared + * + * @ingroup internal + * @return a negative number if s1 is less than s2 + * @retval 0 if s1 matches s2 + * @return a positive number if s1 is greater than s2 + **/ +static inline int elektraStrCmp (const char * s1, const char * s2) +{ + ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", VOID_CAST (s1), VOID_CAST (s2)); + + return strcmp (s1, s2); +} + +/**@brief Compare Strings up to a maximum length. + * + * @param s1 The first string to be compared + * @param s2 The second string to be compared + * @param n The maximum length to be compared + * + * @ingroup internal + * @return a negative number if s1 is less than s2 + * @retval 0 if s1 matches s2 + * @return a positive number if s1 is greater than s2 + **/ +static inline int elektraStrNCmp (const char * s1, const char * s2, size_t n) +{ + ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", VOID_CAST (s1), VOID_CAST (s2)); + + return strncmp (s1, s2, n); +} + +/**@brief Compare Strings ignoring case. + * + * @param s1 The first string to be compared + * @param s2 The second string to be compared + * + * @ingroup internal + * @return a negative number if s1 is less than s2 + * @retval 0 if s1 matches s2 + * @return a positive number if s1 is greater than s2 + **/ +static inline int elektraStrCaseCmp (const char * s1, const char * s2) +{ + ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", VOID_CAST (s1), VOID_CAST (s2)); + return strcasecmp (s1, s2); +} + +/**@brief Compare Strings ignoring case up to a maximum length. + * + * @param s1 The first string to be compared + * @param s2 The second string to be compared + * @param n The maximum length to be compared + * + * @ingroup internal + * @return a negative number if s1 is less than s2 + * @retval 0 if s1 matches s2 + * @return a positive number if s1 is greater than s2 + **/ +static inline int elektraStrNCaseCmp (const char * s1, const char * s2, size_t n) +{ + ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", VOID_CAST (s1), VOID_CAST (s2)); + return strncasecmp (s1, s2, n); +} int elektraMemCaseCmp (const char * s1, const char * s2, size_t size); diff --git a/src/include/internal/utility/string.h b/src/include/internal/utility/string.h index d72166d2881..33371d24667 100644 --- a/src/include/internal/utility/string.h +++ b/src/include/internal/utility/string.h @@ -22,7 +22,29 @@ char * elektraLskip (char const * const keyname); char * elektraRstrip (char * const start, char ** end); char * elektraStrip (char * text); -size_t elektraStrLen (const char * s); +/** + * Calculates the length in bytes of a string. + * + * This function differs from strlen() because it is Unicode and multibyte + * chars safe. While strlen() counts characters and ignores the final NULL, + * elektraStrLen() count bytes including the ending NULL. + * + * It must not be used to search for / in the name, because it does not + * consider escaping. Instead use the unescaped name. + * + * @see keyUnescapedName() + * + * @ingroup internal + * @param s the string to get the length from + * @return number of bytes used by the string, including the final NULL. + * @ingroup internal + */ +static inline size_t elektraStrLen (const char * s) +{ + ELEKTRA_ASSERT (s, "Got null pointer"); + + return strlen (s) + 1; +} #ifdef __cplusplus diff --git a/src/libs/base/internal.c b/src/libs/base/internal.c index 3d5fc540346..8e6c5662d85 100644 --- a/src/libs/base/internal.c +++ b/src/libs/base/internal.c @@ -44,74 +44,6 @@ * */ -/**@brief Compare Strings. - * - * @param s1 The first string to be compared - * @param s2 The second string to be compared - * - * @ingroup internal - * @return a negative number if s1 is less than s2 - * @retval 0 if s1 matches s2 - * @return a positive number if s1 is greater than s2 - **/ -int elektraStrCmp (const char * s1, const char * s2) -{ - ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", (void *) s1, (void *) s2); - - return strcmp (s1, s2); -} - -/**@brief Compare Strings up to a maximum length. - * - * @param s1 The first string to be compared - * @param s2 The second string to be compared - * @param n The maximum length to be compared - * - * @ingroup internal - * @return a negative number if s1 is less than s2 - * @retval 0 if s1 matches s2 - * @return a positive number if s1 is greater than s2 - **/ -int elektraStrNCmp (const char * s1, const char * s2, size_t n) -{ - ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", (void *) s1, (void *) s2); - - return strncmp (s1, s2, n); -} - -/**@brief Compare Strings ignoring case. - * - * @param s1 The first string to be compared - * @param s2 The second string to be compared - * - * @ingroup internal - * @return a negative number if s1 is less than s2 - * @retval 0 if s1 matches s2 - * @return a positive number if s1 is greater than s2 - **/ -int elektraStrCaseCmp (const char * s1, const char * s2) -{ - ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", (void *) s1, (void *) s2); - return strcasecmp (s1, s2); -} - -/**@brief Compare Strings ignoring case up to a maximum length. - * - * @param s1 The first string to be compared - * @param s2 The second string to be compared - * @param n The maximum length to be compared - * - * @ingroup internal - * @return a negative number if s1 is less than s2 - * @retval 0 if s1 matches s2 - * @return a positive number if s1 is greater than s2 - **/ -int elektraStrNCaseCmp (const char * s1, const char * s2, size_t n) -{ - ELEKTRA_ASSERT (s1 != NULL && s2 != NULL, "Got null pointer s1: %p s2: %p", (void *) s1, (void *) s2); - return strncasecmp (s1, s2, n); -} - /** * @brief Compare two memory regions but make cmp chars uppercase before * comparison. @@ -141,188 +73,6 @@ int elektraMemCaseCmp (const char * s1, const char * s2, size_t size) return 0; } -/**Reallocate Storage in a save way. - * - *@code -if (elektraRealloc ((void **) & buffer, new_length) < 0) { - // here comes the failure handler - // you can still use the old buffer -#if DEBUG - fprintf (stderr, "Reallocation error\n"); -#endif - elektraFree (buffer); - buffer = 0; - // return with error -} - *@endcode - * - * @param buffer is a pointer to a elektraMalloc - * @param size is the new size for the memory - * @retval -1 on failure - * @retval 0 on success - * @ingroup internal - */ -int elektraRealloc (void ** buffer, size_t size) -{ - ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); - void * ptr; - void * svr = *buffer; - - ptr = realloc (*buffer, size); - ELEKTRA_ASSERT (ptr, "Memory (re)allocation failed with size %zu", size); - if (ptr == NULL) - { - *buffer = svr; /* restore old buffer*/ - return -1; - } - else - { - *buffer = ptr; - return 0; - } -} - -/** - * Allocate memory for Elektra. - * - * @code -if ((buffer = elektraMalloc (length)) == 0) { - // here comes the failure handler - // no allocation happened here, so don't use buffer -#if DEBUG - fprintf (stderr, "Allocation error"); -#endif - // return with error -} - * @endcode - * - * @param size the requested size - * - * This function is compatible to ANSI-C malloc - * @see elektraFree - * @see elektraCalloc - */ -void * elektraMalloc (size_t size) -{ - ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); - void * ret = malloc (size); - ELEKTRA_ASSERT (ret, "Memory allocation failed with size %zu", size); - return ret; -} - -/**Allocate memory for Elektra. - * - * Memory will be set to 0. - * - * @param size the requested size - * @see elektraMalloc - */ -void * elektraCalloc (size_t size) -{ - ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); - void * ret = calloc (1, size); - ELEKTRA_ASSERT (ret, "Memory allocation failed with size %zu", size); - return ret; -} - -/**Free memory of Elektra or its backends. - * - * @param ptr the pointer to free - * - * If ptr is NULL, no operation is performed. - * - * @ingroup internal - * @see elektraMalloc - */ -void elektraFree (void * ptr) -{ - free (ptr); -} - - -/**Copy string into new allocated memory. - * - * You need to free the memory yourself. - * - * @note that size is determined at runtime. - * So if you have a size information, don't use - * that function. - * - * @param s the null-terminated string to duplicate - * - * @ingroup internal - * @return 0 if out of memory, a pointer otherwise - * @pre s must be a c-string. - * @see elektraFree - * @see elektraStrLen - * @see elektraMemDup - */ -char * elektraStrDup (const char * s) -{ - void * tmp = 0; - size_t l = 0; - ELEKTRA_ASSERT (s, "Tried to duplicate null pointer"); - - l = elektraStrLen (s); - ELEKTRA_ASSERT (l, "Size of string to duplicate is zero"); - tmp = elektraMalloc (l); - if (tmp) memcpy (tmp, s, l); - - return tmp; -} - -/**Copy buffer into new allocated memory. - * - * You need to free the memory yourself. - * - * This function also works with \\0 characters - * in the buffer. The length is taken as given, - * it must be correct. - * - * @return 0 if out of memory, a pointer otherwise - * @param s must be an allocated buffer - * @param n the number of bytes to copy from s - * @ingroup internal - */ -void * elektraMemDup (const void * s, size_t n) -{ - void * tmp = 0; - ELEKTRA_ASSERT (n, "Size of memory to duplicate is zero"); - - tmp = elektraMalloc (n); - if (tmp) memcpy (tmp, s, n); - - return tmp; -} - - -/** - * Calculates the length in bytes of a string. - * - * This function differs from strlen() because it is Unicode and multibyte - * chars safe. While strlen() counts characters and ignores the final NULL, - * elektraStrLen() count bytes including the ending NULL. - * - * It must not be used to search for / in the name, because it does not - * consider escaping. Instead use the unescaped name. - * - * @see keyUnescapedName() - * - * @ingroup internal - * @param s the string to get the length from - * @return number of bytes used by the string, including the final NULL. - * @ingroup internal - */ -size_t elektraStrLen (const char * s) -{ - ELEKTRA_ASSERT (s, "Got null pointer"); - - char * found = strchr (s, 0); - if (found) return found - s + 1; - return 0; -} - - /** * @brief Does string formatting in fresh allocated memory * diff --git a/src/libs/core/symbols.map b/src/libs/core/symbols.map index e148f9ea9d4..7c821f70f4a 100644 --- a/src/libs/core/symbols.map +++ b/src/libs/core/symbols.map @@ -1,23 +1,4 @@ libelektra_0.8 { - # TODO: should not be exported here - elektraAbort; - elektraLog; - elektraCalloc; - elektraFormat; - elektraFree; - elektraMalloc; - elektraMemCaseCmp; - elektraMemDup; - elektraRealloc; - elektraStrCaseCmp; - elektraStrCmp; - elektraStrDup; - elektraStrLen; - elektraStrNCaseCmp; - elektraStrNCmp; - elektraVFormat; - elektraWriteArrayNumber; - keyAddBaseName; keyAddName; keyBaseName; diff --git a/src/libs/utility/CMakeLists.txt b/src/libs/utility/CMakeLists.txt index fb560c673bd..c9bdc65d5d2 100644 --- a/src/libs/utility/CMakeLists.txt +++ b/src/libs/utility/CMakeLists.txt @@ -1,2 +1 @@ -file (GLOB SOURCES *.c) -add_lib (utility SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) +add_lib (utility SOURCES text.c alloc.c COMPONENT libelektra${SO_VERSION}) diff --git a/src/libs/utility/alloc.c b/src/libs/utility/alloc.c new file mode 100644 index 00000000000..15a4d17fe3b --- /dev/null +++ b/src/libs/utility/alloc.c @@ -0,0 +1,5 @@ +#include + +// the public header declares the functions as normal external functions +// we now include the implementations to actually define them +#include diff --git a/src/libs/utility/symbols.map b/src/libs/utility/symbols.map index 8dff754b7a7..ee8dab30835 100644 --- a/src/libs/utility/symbols.map +++ b/src/libs/utility/symbols.map @@ -3,4 +3,24 @@ libelektra_0.8 { elektraLskip; elektraRstrip; elektraStrip; +}; + +libelektra_1.0 { + elektraAbort; + elektraLog; + elektraCalloc; + elektraFormat; + elektraFree; + elektraMalloc; + elektraMemCaseCmp; + elektraMemDup; + elektraRealloc; + elektraStrCaseCmp; + elektraStrCmp; + elektraStrDup; + elektraStrLen; + elektraStrNCaseCmp; + elektraStrNCmp; + elektraVFormat; + elektraWriteArrayNumber; }; \ No newline at end of file From b063fa1aa8baf6e14b5744dfb379260271decaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:15 +0200 Subject: [PATCH 04/41] doc: update details of library_split decision --- doc/decisions/5_partially_implemented/library_split.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/decisions/5_partially_implemented/library_split.md b/doc/decisions/5_partially_implemented/library_split.md index 59ed27fa4c7..bd986b36da1 100644 --- a/doc/decisions/5_partially_implemented/library_split.md +++ b/doc/decisions/5_partially_implemented/library_split.md @@ -102,7 +102,7 @@ All currently planned libraries and their respective API prefixes are listed in (Note: previously `libelektra-plugin` merged with `libelektra-invoke`) - `libelektra-pluginload`: - Internal static library, linked into `libelektra-plugin` (re-exported) and `libelektra-kdb` (not exported). + Internal object library, linked into `libelektra-plugin` (re-exported) and `libelektra-kdb` (not exported). Contains the code for loading plugins. **Prefix:**: `elektraPlugin*` (shared with `libelektra-plugin` because exported there) @@ -140,7 +140,7 @@ All currently planned libraries and their respective API prefixes are listed in **Prefix:** `elektraUtil*` - `libelektra-base`: - Internal static library, linked into `libelektra-core` (not exported) and `libelektra-utility` (partially re-exported). + Internal object library, linked into `libelektra-core` (not exported) and `libelektra-utility` (partially re-exported). Contains helper functions for e.g., memory allocations, string formatting, etc. **Prefix:** `elektra*` (for internal), `elektraUtil*` (for exported) From 78719b67a7911127a1710f2eaf69bdcbe25f65b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:16 +0200 Subject: [PATCH 05/41] types: split type system into separate library --- src/libs/CMakeLists.txt | 1 + src/libs/ease/CMakeLists.txt | 14 ++++++++++--- src/libs/ease/symbols.map | 29 --------------------------- src/libs/highlevel/CMakeLists.txt | 9 ++++++--- src/libs/opts/CMakeLists.txt | 1 + src/libs/type/CMakeLists.txt | 1 + src/libs/{ease => type}/conversion.c | 0 src/libs/type/symbols.map | 30 ++++++++++++++++++++++++++++ src/plugins/length/CMakeLists.txt | 2 +- src/plugins/type/CMakeLists.txt | 2 +- tests/ctest/CMakeLists.txt | 2 +- tests/shell/gen/CMakeLists.txt | 2 +- 12 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 src/libs/type/CMakeLists.txt rename src/libs/{ease => type}/conversion.c (100%) create mode 100644 src/libs/type/symbols.map diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index 073d7f75669..f008fb5ea14 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -4,6 +4,7 @@ set ( SUBDIRS core kdb + type ease globbing meta diff --git a/src/libs/ease/CMakeLists.txt b/src/libs/ease/CMakeLists.txt index 05889707e2d..a703492e035 100644 --- a/src/libs/ease/CMakeLists.txt +++ b/src/libs/ease/CMakeLists.txt @@ -1,3 +1,11 @@ -file (GLOB SOURCES *.c) -file (GLOB HEADERS *.h) -add_lib (ease SOURCES ${SOURCES} ${HEADERS} COMPONENT libelektra${SO_VERSION}) +add_lib ( + ease + SOURCES + array.c + functional.c + hash.c + keyname.c + reference.c + sha-256.c + COMPONENT + libelektra${SO_VERSION}) diff --git a/src/libs/ease/symbols.map b/src/libs/ease/symbols.map index 5c3eeec8075..bc2ae5ec724 100644 --- a/src/libs/ease/symbols.map +++ b/src/libs/ease/symbols.map @@ -13,35 +13,6 @@ libelektra_0.8 { }; libelektra_0.9 { - ## ToString; - elektraBooleanToString; - elektraCharToString; - elektraDoubleToString; - elektraFloatToString; - elektraLongDoubleToString; - elektraLongLongToString; - elektraLongToString; - elektraOctetToString; - elektraShortToString; - elektraUnsignedLongLongToString; - elektraUnsignedLongToString; - elektraUnsignedShortToString; - - ## FromKey; - elektraKeyToBoolean; - elektraKeyToChar; - elektraKeyToDouble; - elektraKeyToFloat; - elektraKeyToLong; - elektraKeyToLongDouble; - elektraKeyToLongLong; - elektraKeyToOctet; - elektraKeyToShort; - elektraKeyToString; - elektraKeyToUnsignedLong; - elektraKeyToUnsignedLongLong; - elektraKeyToUnsignedShort; - elektraKsToMemArray; calculateSpecificationToken; diff --git a/src/libs/highlevel/CMakeLists.txt b/src/libs/highlevel/CMakeLists.txt index 4f2bbbbb42e..e957734693d 100644 --- a/src/libs/highlevel/CMakeLists.txt +++ b/src/libs/highlevel/CMakeLists.txt @@ -7,13 +7,16 @@ add_lib ( LINK_ELEKTRA elektra-kdb elektra-ease + elektra-types COMPONENT libelektra${SO_VERSION}) if (BUILD_SHARED) - set (LIBRARIES "-lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core") - set (CODEGEN_LIBRARIES - "-lelektra-opts -lelektra-invoke -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core -lelektra-meta") + set (LIBRARIES "-lelektra-types -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core") + set ( + CODEGEN_LIBRARIES + "-lelektra-types -lelektra-opts -lelektra-invoke -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core -lelektra-meta -lelektra-utility" + ) elseif (BUILD_FULL) set (LIBRARIES "-lelektra-full") set (CODEGEN_LIBRARIES "-lelektra-full") diff --git a/src/libs/opts/CMakeLists.txt b/src/libs/opts/CMakeLists.txt index dfc24936f56..5a50edf22a1 100644 --- a/src/libs/opts/CMakeLists.txt +++ b/src/libs/opts/CMakeLists.txt @@ -6,5 +6,6 @@ add_lib ( ${SOURCES} LINK_ELEKTRA elektra-meta + elektra-types COMPONENT libelektra${SO_VERSION}) diff --git a/src/libs/type/CMakeLists.txt b/src/libs/type/CMakeLists.txt new file mode 100644 index 00000000000..27d9b8c3911 --- /dev/null +++ b/src/libs/type/CMakeLists.txt @@ -0,0 +1 @@ +add_lib (types SOURCES conversion.c COMPONENT libelektra${SO_VERSION}) diff --git a/src/libs/ease/conversion.c b/src/libs/type/conversion.c similarity index 100% rename from src/libs/ease/conversion.c rename to src/libs/type/conversion.c diff --git a/src/libs/type/symbols.map b/src/libs/type/symbols.map new file mode 100644 index 00000000000..c1e5f6c921c --- /dev/null +++ b/src/libs/type/symbols.map @@ -0,0 +1,30 @@ +libelektra_1.0 { + ## ToString; + elektraBooleanToString; + elektraCharToString; + elektraDoubleToString; + elektraFloatToString; + elektraLongDoubleToString; + elektraLongLongToString; + elektraLongToString; + elektraOctetToString; + elektraShortToString; + elektraUnsignedLongLongToString; + elektraUnsignedLongToString; + elektraUnsignedShortToString; + + ## FromKey; + elektraKeyToBoolean; + elektraKeyToChar; + elektraKeyToDouble; + elektraKeyToFloat; + elektraKeyToLong; + elektraKeyToLongDouble; + elektraKeyToLongLong; + elektraKeyToOctet; + elektraKeyToShort; + elektraKeyToString; + elektraKeyToUnsignedLong; + elektraKeyToUnsignedLongLong; + elektraKeyToUnsignedShort; +}; diff --git a/src/plugins/length/CMakeLists.txt b/src/plugins/length/CMakeLists.txt index 1a96b83005f..3bf20b1ce50 100644 --- a/src/plugins/length/CMakeLists.txt +++ b/src/plugins/length/CMakeLists.txt @@ -3,5 +3,5 @@ include (LibAddMacros) add_plugin ( length SOURCES length.h length.c test_length.h - LINK_ELEKTRA elektra-ease + LINK_ELEKTRA elektra-types ADD_TEST TEST_README COMPONENT libelektra${SO_VERSION}-experimental) diff --git a/src/plugins/type/CMakeLists.txt b/src/plugins/type/CMakeLists.txt index d78077fefa5..15828b22d49 100644 --- a/src/plugins/type/CMakeLists.txt +++ b/src/plugins/type/CMakeLists.txt @@ -1,5 +1,5 @@ add_plugin ( type SOURCES type.h type.c types.h types.c - LINK_ELEKTRA elektra-meta elektra-ease + LINK_ELEKTRA elektra-meta elektra-types ADD_TEST TEST_README COMPONENT libelektra${SO_VERSION}) diff --git a/tests/ctest/CMakeLists.txt b/tests/ctest/CMakeLists.txt index 62779198f20..f2e912fdb10 100644 --- a/tests/ctest/CMakeLists.txt +++ b/tests/ctest/CMakeLists.txt @@ -10,7 +10,7 @@ foreach (file ${TESTS}) endforeach (file ${TESTS}) target_link_elektra (test_array elektra-ease) -target_link_elektra (test_conversion elektra-ease) +target_link_elektra (test_conversion elektra-types) target_link_elektra (test_keyname elektra-ease) target_link_elektra (test_plugin elektra-plugin) diff --git a/tests/shell/gen/CMakeLists.txt b/tests/shell/gen/CMakeLists.txt index 15d9cad5a15..a0fe6dd8133 100644 --- a/tests/shell/gen/CMakeLists.txt +++ b/tests/shell/gen/CMakeLists.txt @@ -5,7 +5,7 @@ file ( *.sh) if (BUILD_SHARED) - set (ElektraCodegen_ALL_LIBRARIES "elektra-highlevel;elektra-opts;elektra-invoke;elektra-ease;elektra-kdb;elektra-core") + set (ElektraCodegen_ALL_LIBRARIES "elektra-highlevel;elektra-opts;elektra-invoke;elektra-ease;elektra-kdb;elektra-core;elektra-types;elektra-utility") elseif (BUILD_FULL) set (ElektraCodegen_ALL_LIBRARIES "elektra-full") elseif (BUILD_STATIC) From 8e908770e839c10db1cbe081edbe5c9ea3888077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:17 +0200 Subject: [PATCH 06/41] cmake: fix BUILD_FULL and BUILD_STATIC and cleanup cruft in the process --- benchmarks/CMakeLists.txt | 2 - examples/CMakeLists.txt | 3 - scripts/cmake/ElektraCache.cmake | 11 + scripts/cmake/Modules/LibAddLib.cmake | 25 +- scripts/cmake/Modules/LibAddMacros.cmake | 196 --------------- scripts/cmake/Modules/LibAddPlugin.cmake | 14 +- src/bindings/cpp/benchmarks/CMakeLists.txt | 3 - src/bindings/cpp/examples/CMakeLists.txt | 3 - src/bindings/cpp/tests/CMakeLists.txt | 3 - src/bindings/erl_nif/CMakeLists.txt | 1 - src/bindings/glib/CMakeLists.txt | 1 - src/bindings/glib/tests/CMakeLists.txt | 1 - .../intercept/env/benchmarks/CMakeLists.txt | 3 - .../intercept/env/examples/CMakeLists.txt | 4 - src/bindings/intercept/env/src/CMakeLists.txt | 3 - .../intercept/env/tests/CMakeLists.txt | 2 - src/bindings/intercept/fs/CMakeLists.txt | 1 - src/bindings/io/doc/CMakeLists.txt | 2 - src/bindings/io/ev/CMakeLists.txt | 2 - src/bindings/io/ev/example/CMakeLists.txt | 1 - src/bindings/io/glib/CMakeLists.txt | 2 - src/bindings/io/glib/example/CMakeLists.txt | 1 - src/bindings/io/uv/CMakeLists.txt | 2 - src/bindings/io/uv/example/CMakeLists.txt | 1 - src/bindings/swig/lua/CMakeLists.txt | 3 - src/bindings/swig/python/CMakeLists.txt | 4 - src/bindings/swig/ruby/CMakeLists.txt | 4 - src/bindings/xfconf/CMakeLists.txt | 4 +- src/libs/CMakeLists.txt | 223 +++++++++--------- src/libs/base/CMakeLists.txt | 4 - src/libs/kdb/CMakeLists.txt | 2 +- src/libs/merge/CMakeLists.txt | 6 - src/libs/meta/meta.c | 21 +- src/libs/notification/tests/CMakeLists.txt | 3 - src/libs/pluginload/CMakeLists.txt | 12 +- src/libs/pluginprocess/tests/CMakeLists.txt | 3 - src/libs/tools/benchmarks/CMakeLists.txt | 4 - src/libs/tools/examples/CMakeLists.txt | 4 - src/libs/tools/src/CMakeLists.txt | 4 - src/libs/tools/tests/CMakeLists.txt | 4 - src/plugins/dbus/CMakeLists.txt | 1 - src/plugins/specload/CMakeLists.txt | 2 - src/tools/hub-zeromq/CMakeLists.txt | 1 - src/tools/kdb/CMakeLists.txt | 4 +- src/tools/qt-gui/CMakeLists.txt | 4 - src/tools/race/CMakeLists.txt | 2 - tests/CMakeLists.txt | 5 - tests/cframework/CMakeLists.txt | 3 - tests/ctest/test_keyCopy_memerror.c | 4 +- tests/kdb/CMakeLists.txt | 4 - 50 files changed, 155 insertions(+), 467 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index ed2bb6af002..e76d42f2b27 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,7 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) - macro (do_benchmark source) set (SOURCES ${HDR_FILES} ${ADDITIONAL_SOURCES} benchmarks.c benchmarks.h ${source}.c) add_executable (benchmark_${source} ${SOURCES}) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 17459b1ec59..b53ae233706 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,9 +1,6 @@ include (LibAddMacros) include (LibAddBinding) -# don't call add_headers in a loop -add_headers (HDR_FILES) - macro (do_example source) set (SOURCES ${HDR_FILES} ${source}.c) add_executable (${source} ${SOURCES}) diff --git a/scripts/cmake/ElektraCache.cmake b/scripts/cmake/ElektraCache.cmake index 5bde98ae1b0..e89095b6bc3 100644 --- a/scripts/cmake/ElektraCache.cmake +++ b/scripts/cmake/ElektraCache.cmake @@ -56,6 +56,16 @@ set ( "" CACHE STRING ${BINDINGS_DOC} FORCE) +# +# set LIBRARIES cache variable +# + +set (ADDED_LIBRARIES_DOC "List of plugins already added, only for informational purposes. We always build all libraries.") +set ( + ADDED_LIBRARIES + "" + CACHE STRING ${ADDED_LIBRARIES_DOC} FORCE) + # # set TOOLS cache variable # @@ -465,6 +475,7 @@ mark_as_advanced ( REMOVED_PLUGINS REMOVED_TOOLS ADDED_BINDINGS + ADDED_LIBRARIES LIBGCRYPTCONFIG_EXECUTABLE jna Qt5Core_DIR diff --git a/scripts/cmake/Modules/LibAddLib.cmake b/scripts/cmake/Modules/LibAddLib.cmake index d60208623ed..66c64947859 100644 --- a/scripts/cmake/Modules/LibAddLib.cmake +++ b/scripts/cmake/Modules/LibAddLib.cmake @@ -18,10 +18,6 @@ function (add_lib name) "SOURCES;LINK_LIBRARIES;LINK_ELEKTRA;INCLUDE_DIRECTORIES;INCLUDE_SYSTEM_DIRECTORIES;COMPILE_DEFINITIONS" # multi value # keywords ${ARGN}) - add_headers (ARG_SOURCES) - if (ARG_CPP) - add_cppheaders (ARG_SOURCES) - endif (ARG_CPP) if (ARG_COMPONENT) set (HAS_COMPONENT ${ARG_COMPONENT}) @@ -52,10 +48,6 @@ function (add_lib name) endif () endif (BUILD_SHARED) - set_property (GLOBAL APPEND PROPERTY "elektra-full_SRCS" "$") - - set_property (GLOBAL APPEND PROPERTY "elektra-extension_LIBRARIES" elektra-${name}) - if (BUILD_SHARED) target_link_libraries (elektra-${name} ${ARG_LINK_LIBRARIES}) @@ -71,4 +63,21 @@ function (add_lib name) EXPORT ElektraTargetsLibelektra) endif (BUILD_SHARED) + if (ADDED_LIBRARIES) + set (TMP "${ADDED_LIBRARIES};${name}") + list (SORT TMP) + list (REMOVE_DUPLICATES TMP) + set ( + ADDED_LIBRARIES + "${TMP}" + CACHE STRING "${ADDED_LIBRARIES_DOC}" FORCE) + else () + set ( + ADDED_LIBRARIES + "${name}" + CACHE STRING "${ADDED_LIBRARIES_DOC}" FORCE) + endif () + + set_property (GLOBAL APPEND PROPERTY "ELEKTRA_LINK_LIBRARIES" "${ARG_LINK_LIBRARIES}") + endfunction () diff --git a/scripts/cmake/Modules/LibAddMacros.cmake b/scripts/cmake/Modules/LibAddMacros.cmake index ad1f56a2482..6f1d2a4329f 100644 --- a/scripts/cmake/Modules/LibAddMacros.cmake +++ b/scripts/cmake/Modules/LibAddMacros.cmake @@ -128,11 +128,6 @@ macro (mkdir dir) execute_process (COMMAND ${CMAKE_COMMAND} -E make_directory "${dir}") endmacro (mkdir) -macro (add_testheaders HDR_FILES) - file (GLOB BIN_HDR_FILES "${PROJECT_SOURCE_DIR}/tests/cframework/*.h") - list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) -endmacro (add_testheaders HDR_FILES) - # for generic targets (not tools) use this function to link against elektra function (target_link_elektra TARGET) if (BUILD_SHARED) @@ -264,51 +259,6 @@ endfunction ( util output) -# ~~~ -# - Adds all headerfiles of global include path to the given variable -# -# ADD_HEADERS (variable) -# -# example: -# add_headers (SOURCES) -# SOURCES now contain the names of all global header files -# -# thus the necessary directories are also included within the macro -# don't execute this within a loop. -# -# The added files will be always the same anyway. Example see in -# tests/CMakeLists.txt -# ~~~ -macro (add_headers HDR_FILES) - set (BINARY_INCLUDE_DIR "${PROJECT_BINARY_DIR}/src/include") - set (SOURCE_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/include") - - file (GLOB BIN_HDR_FILES ${BINARY_INCLUDE_DIR}/*.h) - list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - - file (GLOB SRC_HDR_FILES ${SOURCE_INCLUDE_DIR}/*.h) - list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) -endmacro (add_headers) - -# ~~~ -# Add all headers needed for cpp bindings -# ~~~ -macro (add_cppheaders HDR_FILES) - file (GLOB BIN_HDR_FILES ${PROJECT_BINARY_DIR}/src/bindings/cpp/include/*.hpp) - list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - - file (GLOB SRC_HDR_FILES ${PROJECT_SOURCE_DIR}/src/bindings/cpp/include/*.hpp) - list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) -endmacro (add_cppheaders) - -macro (add_toolheaders HDR_FILES) - file (GLOB_RECURSE BIN_HDR_FILES ${PROJECT_BINARY_DIR}/src/libtools/include/*) - list (APPEND ${HDR_FILES} ${BIN_HDR_FILES}) - - file (GLOB_RECURSE SRC_HDR_FILES ${PROJECT_SOURCE_DIR}/src/libs/tools/include/*) - list (APPEND ${HDR_FILES} ${SRC_HDR_FILES}) -endmacro (add_toolheaders) - # ~~~ # - Removes a plugin from the global cache # @@ -427,152 +377,6 @@ function (list_find input_list regexp_var output) # Reset output variable Extra endforeach (LIST_FILTER_item) endfunction (list_find) -# ~~~ -# - Add sources for a target -# -# ADD_SOURCES ( [ ...]) -# -# The target should add the sources using: -# -# get_property (elektra_SRCS GLOBAL PROPERTY elektra_SRCS) -# list (APPEND SRC_FILES ${elektra_SRCS}) -# -# descend into sub-directories -# add_subdirectory(a) -# add_subdirectory(b) -# -# get_property(super_SRCS GLOBAL PROPERTY super_SRCS) -# -# add_library(super STATIC ${super_SRCS}) -# -# -# a/CMakeLists.txt: -# -# add_sources(super -# a1.f -# a2.f -# a3.f -# ) -# -# -# b/CMakeLists.txt: -# -# add_sources(super -# b1.f -# b2.f -# ) -# -# -# Thank to Michael Wild -# -# -# elektra... are the sources for all elektra targets -# elektra-shared... are the additional sources -# for elektra SHARED only (excludes elektra-full) -# elektra-full... are the additional sources for the versions -# with all plugins built-in (excludes elektra-shared) -# ~~~ -function (add_sources target) # define the _SRCS properties if necessary - get_property ( - prop_defined GLOBAL - PROPERTY ${target}_SRCS - DEFINED) - if (NOT prop_defined) - define_property ( - GLOBAL - PROPERTY ${target}_SRCS - BRIEF_DOCS "Sources for the ${target} target" - FULL_DOCS "List of source files for the ${target} target") - endif (NOT prop_defined) # create list of sources (absolute paths) - set (SRCS) - foreach (src ${ARGN}) - if (NOT IS_ABSOLUTE "${src}") - get_filename_component (src "${src}" ABSOLUTE) - endif (NOT IS_ABSOLUTE "${src}") - list (APPEND SRCS "${src}") - endforeach (src ${ARGN}) # append to global property - set_property (GLOBAL APPEND PROPERTY "${target}_SRCS" "${SRCS}") -endfunction (add_sources) - -# ~~~ -# - Add includes for a target -# -# ADD_INCLUDES ( [ ...]) -# -# The target should do: -# -# get_property (elektra_INCLUDES GLOBAL PROPERTY elektra_INCLUDES) -# include_directories (${elektra_INCLUDES}) -# ~~~ -function (add_includes target) # define the _INCLUDES properties if necessary - get_property ( - prop_defined GLOBAL - PROPERTY ${target}_INCLUDES - DEFINED) - if (NOT prop_defined) - define_property ( - GLOBAL - PROPERTY ${target}_INCLUDES - BRIEF_DOCS "Sources for the ${target} target" - FULL_DOCS "List of source files for the ${target} target") - endif (NOT prop_defined) # create list of sources (absolute paths) - set (INCLUDES) - foreach (src ${ARGN}) - list (APPEND INCLUDES "${src}") - endforeach (src ${ARGN}) # append to global property - set_property (GLOBAL APPEND PROPERTY "${target}_INCLUDES" "${INCLUDES}") -endfunction (add_includes) - -# ~~~ -# - Add libraries for a target -# -# ADD_LIBRARIES ( [ ...]) -# -# The target should do: -# -# get_property (elektra_LIBRARIES GLOBAL PROPERTY elektra_LIBRARIES) -# target_link_libraries (elektra ${elektra_LIBRARIES}) -# -# ~~~ -function (add_libraries target) # define the _LIBRARIES properties if necessary - get_property ( - prop_defined GLOBAL - PROPERTY ${target}_LIBRARIES - DEFINED) - if (NOT prop_defined) - define_property ( - GLOBAL - PROPERTY ${target}_LIBRARIES - BRIEF_DOCS "Sources for the ${target} target" - FULL_DOCS "List of source files for the ${target} target") - endif (NOT prop_defined) # create list of sources (absolute paths) - set (LIBRARIES) - foreach (src ${ARGN}) - list (APPEND LIBRARIES "${src}") - endforeach (src ${ARGN}) # append to global property - set_property (GLOBAL APPEND PROPERTY "${target}_LIBRARIES" "${LIBRARIES}") -endfunction (add_libraries) - -# ~~~ -# - Create a static library from sources collected by MY_ADD_LIBRARY -# -# MY_ADD_STATIC_MODULE() -# -# Compiles a static library from the sources defined in -# MY_STATIC_MODULES__SOURCES by MY_ADD_LIBRARY(). This -# function must be called after all calls to MY_ADD_LIBRARY() -# contributing sources to this static module. -# -# Thanks to Michael Wild -# ~~~ -function (my_add_static_module name) - get_property (srcs GLOBAL PROPERTY MY_STATIC_MODULES_${name}_SOURCES) - if (not SRCS) - message (SEND_ERROR "No sources defined for static module ${name}") - endif (not SRCS) - add_library (${name} STATIC ${srcs}) -endfunction () - macro (remember_for_removal ELEMENTS TO_REMOVE_ELEMENTS) set (MY_ELEMENTS ${${ELEMENTS}}) set (MY_REMOVE_ELEMENTS "") diff --git a/scripts/cmake/Modules/LibAddPlugin.cmake b/scripts/cmake/Modules/LibAddPlugin.cmake index a421e9735bd..fe0d6296e97 100644 --- a/scripts/cmake/Modules/LibAddPlugin.cmake +++ b/scripts/cmake/Modules/LibAddPlugin.cmake @@ -140,9 +140,6 @@ function (add_plugintest testname) endif () endforeach () - add_headers (TEST_SOURCES) - add_testheaders (TEST_SOURCES) - if (ARG_CPP) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testmod_${testname}.cpp") else (ARG_CPP) @@ -593,11 +590,6 @@ function (add_plugin PLUGIN_SHORT_NAME) endif (ARG_ONLY_SHARED) message (STATUS "${STATUS_MESSAGE}") - add_headers (ARG_SOURCES) - if (ARG_CPP) - add_cppheaders (ARG_SOURCES) - endif (ARG_CPP) - add_library (${PLUGIN_OBJS} OBJECT ${ARG_SOURCES}) if (ARG_DEPENDS) @@ -697,11 +689,7 @@ function (add_plugin PLUGIN_SHORT_NAME) endif () if (NOT ARG_ONLY_SHARED) - - # message (STATUS "added ${PLUGIN_TARGET_OBJS}") - set_property (GLOBAL APPEND PROPERTY "elektra-full_SRCS" ${PLUGIN_TARGET_OBJS} ${ARG_OBJECT_SOURCES}) - - set_property (GLOBAL APPEND PROPERTY "elektra-full_LIBRARIES" "${ARG_LINK_LIBRARIES}") + set_property (GLOBAL APPEND PROPERTY "ELEKTRA_LINK_LIBRARIES" "${ARG_LINK_LIBRARIES}") endif (NOT ARG_ONLY_SHARED) # cleanup diff --git a/src/bindings/cpp/benchmarks/CMakeLists.txt b/src/bindings/cpp/benchmarks/CMakeLists.txt index af402e1bc6c..02bacba540b 100644 --- a/src/bindings/cpp/benchmarks/CMakeLists.txt +++ b/src/bindings/cpp/benchmarks/CMakeLists.txt @@ -1,8 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) - macro (do_benchmark source) set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) diff --git a/src/bindings/cpp/examples/CMakeLists.txt b/src/bindings/cpp/examples/CMakeLists.txt index 585dc30c0ed..f532fb49ce9 100644 --- a/src/bindings/cpp/examples/CMakeLists.txt +++ b/src/bindings/cpp/examples/CMakeLists.txt @@ -1,8 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) - macro (do_example source) set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) diff --git a/src/bindings/cpp/tests/CMakeLists.txt b/src/bindings/cpp/tests/CMakeLists.txt index 77a1d9daf3d..574001f58d6 100644 --- a/src/bindings/cpp/tests/CMakeLists.txt +++ b/src/bindings/cpp/tests/CMakeLists.txt @@ -2,9 +2,6 @@ include (LibAddTest) include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../include") -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) - set (CLANG_7_OR_LATER ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 7)) set (TESTCPP_CONTEXTUAL_BASIC_PROPERTIES "-Wno-gnu-zero-variadic-macro-arguments") diff --git a/src/bindings/erl_nif/CMakeLists.txt b/src/bindings/erl_nif/CMakeLists.txt index ec042d4951c..bbd69a11be5 100644 --- a/src/bindings/erl_nif/CMakeLists.txt +++ b/src/bindings/erl_nif/CMakeLists.txt @@ -11,7 +11,6 @@ else () set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/elixir/priv") file (GLOB ERL_NIF_SRC_FILES lib/*.c) - add_headers (ELEKTRA_HEADERS) set (SOURCES ${ERL_NIF_SRC_FILES} ${ELEKTRA_HEADERS}) add_library (nif_kdb SHARED ${SOURCES}) diff --git a/src/bindings/glib/CMakeLists.txt b/src/bindings/glib/CMakeLists.txt index 327adf5cdcf..94f207b19de 100644 --- a/src/bindings/glib/CMakeLists.txt +++ b/src/bindings/glib/CMakeLists.txt @@ -29,7 +29,6 @@ set ( file (GLOB GELEKTRA_HDR_FILES *.h) file (GLOB GELEKTRA_SRC_FILES *.c) -add_headers (ELEKTRA_HEADERS) set (SOURCES ${GELEKTRA_SRC_FILES} ${GELEKTRA_HDR_FILES} ${ELEKTRA_HEADERS}) add_library (${GELEKTRA_LIBRARY} SHARED ${SOURCES}) diff --git a/src/bindings/glib/tests/CMakeLists.txt b/src/bindings/glib/tests/CMakeLists.txt index 06cc60f2646..e74cc5c4afa 100644 --- a/src/bindings/glib/tests/CMakeLists.txt +++ b/src/bindings/glib/tests/CMakeLists.txt @@ -1,5 +1,4 @@ set (TEST_FILES $) -add_testheaders (TEST_FILES) macro (do_glib_test file) get_filename_component (name ${file} NAME_WE) diff --git a/src/bindings/intercept/env/benchmarks/CMakeLists.txt b/src/bindings/intercept/env/benchmarks/CMakeLists.txt index f65c9c6f69a..bcfece62aaa 100644 --- a/src/bindings/intercept/env/benchmarks/CMakeLists.txt +++ b/src/bindings/intercept/env/benchmarks/CMakeLists.txt @@ -1,8 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) - set_source_files_properties (benchmark_getenv.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-result") macro (do_benchmark source) diff --git a/src/bindings/intercept/env/examples/CMakeLists.txt b/src/bindings/intercept/env/examples/CMakeLists.txt index 1aad09754c3..df34d0e4800 100644 --- a/src/bindings/intercept/env/examples/CMakeLists.txt +++ b/src/bindings/intercept/env/examples/CMakeLists.txt @@ -1,9 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - macro (do_example source) set (SOURCES ${HDR_FILES} ${source}.c) add_executable (${source} ${SOURCES}) diff --git a/src/bindings/intercept/env/src/CMakeLists.txt b/src/bindings/intercept/env/src/CMakeLists.txt index f8e5b8284d3..48374fcee1a 100644 --- a/src/bindings/intercept/env/src/CMakeLists.txt +++ b/src/bindings/intercept/env/src/CMakeLists.txt @@ -1,8 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) - file (GLOB_RECURSE SRC_FILES *.cpp) set (SOURCES ${SRC_FILES} ${HDR_FILES}) diff --git a/src/bindings/intercept/env/tests/CMakeLists.txt b/src/bindings/intercept/env/tests/CMakeLists.txt index ec8d6432736..2e6f2c28659 100644 --- a/src/bindings/intercept/env/tests/CMakeLists.txt +++ b/src/bindings/intercept/env/tests/CMakeLists.txt @@ -1,7 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) - include (LibAddTest) file (GLOB TESTS test_*.cpp) diff --git a/src/bindings/intercept/fs/CMakeLists.txt b/src/bindings/intercept/fs/CMakeLists.txt index 2761555e856..9d7a7517ce2 100644 --- a/src/bindings/intercept/fs/CMakeLists.txt +++ b/src/bindings/intercept/fs/CMakeLists.txt @@ -9,7 +9,6 @@ else () add_binding (intercept_fs) include (LibAddMacros) - add_headers (HDR_FILES) set_source_files_properties (intercept.c PROPERTIES COMPILE_FLAGS "-Wno-unused-result") add_library (elektraintercept-fs SHARED "intercept.c") target_link_libraries (elektraintercept-fs elektra-kdb elektra-meta) diff --git a/src/bindings/io/doc/CMakeLists.txt b/src/bindings/io/doc/CMakeLists.txt index f9a7fce7af4..694a99fa326 100644 --- a/src/bindings/io/doc/CMakeLists.txt +++ b/src/bindings/io/doc/CMakeLists.txt @@ -9,7 +9,6 @@ set (BINDING_VARIANT doc) set (IO_VARIANT_HDR_FILES kdbio_doc.h) set (IO_VARIANT_SRC_FILES io_doc.c) -add_headers (ELEKTRA_HEADERS) set (SOURCES ${IO_VARIANT_SRC_FILES} ${IO_VARIANT_HDR_FILES} ${ELEKTRA_HEADERS}) set (IO_VARIANT_LIBRARY elektra-io-${BINDING_VARIANT}) @@ -39,7 +38,6 @@ if (BUILD_TESTING) set (ADDITIONAL_TEST_LIBRARIES "m") set (TEST_SOURCES $) - add_headers (TEST_SOURCES) file (GLOB IO_TEST_SRC_FILES "${CMAKE_SOURCE_DIR}/src/bindings/io/test/test*.c") list (APPEND TEST_SOURCES ${IO_TEST_SRC_FILES}) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testio_${BINDING_VARIANT}.c") diff --git a/src/bindings/io/ev/CMakeLists.txt b/src/bindings/io/ev/CMakeLists.txt index 8b8f57ab2ee..c21144fd35c 100644 --- a/src/bindings/io/ev/CMakeLists.txt +++ b/src/bindings/io/ev/CMakeLists.txt @@ -10,7 +10,6 @@ else () # Build library set (IO_VARIANT_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/io_ev.c") - add_headers (ELEKTRA_HEADERS) set (SOURCES ${IO_VARIANT_SRC_FILES} ${ELEKTRA_HEADERS}) set (IO_VARIANT_LIBRARY elektra-io-${BINDING_VARIANT}) @@ -41,7 +40,6 @@ else () # Build library set (testexename testio_${BINDING_VARIANT}) set (TEST_SOURCES $) - add_headers (TEST_SOURCES) file (GLOB IO_TEST_SRC_FILES "${CMAKE_SOURCE_DIR}/src/bindings/io/test/test*.c") list (APPEND TEST_SOURCES ${IO_TEST_SRC_FILES}) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testio_${BINDING_VARIANT}.c") diff --git a/src/bindings/io/ev/example/CMakeLists.txt b/src/bindings/io/ev/example/CMakeLists.txt index b3a2aa6e748..0d31e20fa3c 100644 --- a/src/bindings/io/ev/example/CMakeLists.txt +++ b/src/bindings/io/ev/example/CMakeLists.txt @@ -3,7 +3,6 @@ include (LibAddMacros) file (GLOB HDR_FILES *.h) file (GLOB SRC_FILES *.c) -add_headers (ELEKTRA_HEADERS) set (SOURCES ${SRC_FILES} ${HDR_FILES} ${ELEKTRA_HEADERS}) if (BUILD_FULL OR BUILD_STATIC) # add sources for elektra-io-ev for static and full builds diff --git a/src/bindings/io/glib/CMakeLists.txt b/src/bindings/io/glib/CMakeLists.txt index 40839ef2bbd..16f11c5f18b 100644 --- a/src/bindings/io/glib/CMakeLists.txt +++ b/src/bindings/io/glib/CMakeLists.txt @@ -15,7 +15,6 @@ else () set (IO_VARIANT_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/io_glib.c") - add_headers (ELEKTRA_HEADERS) set (SOURCES ${IO_VARIANT_SRC_FILES} ${ELEKTRA_HEADERS}) add_compile_options ("-Wno-pedantic") @@ -47,7 +46,6 @@ else () set (testexename testio_${BINDING_VARIANT}) set (TEST_SOURCES $) - add_headers (TEST_SOURCES) file (GLOB IO_TEST_SRC_FILES "${CMAKE_SOURCE_DIR}/src/bindings/io/test/test*.c") list (APPEND TEST_SOURCES ${IO_TEST_SRC_FILES}) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testio_${BINDING_VARIANT}.c") diff --git a/src/bindings/io/glib/example/CMakeLists.txt b/src/bindings/io/glib/example/CMakeLists.txt index cca039157ef..ce732a28902 100644 --- a/src/bindings/io/glib/example/CMakeLists.txt +++ b/src/bindings/io/glib/example/CMakeLists.txt @@ -3,7 +3,6 @@ include (LibAddMacros) file (GLOB HDR_FILES *.h) file (GLOB SRC_FILES *.c) -add_headers (ELEKTRA_HEADERS) set (SOURCES ${SRC_FILES} ${HDR_FILES} ${ELEKTRA_HEADERS}) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/io/uv/CMakeLists.txt b/src/bindings/io/uv/CMakeLists.txt index 96abb8569a9..1789b7ba589 100644 --- a/src/bindings/io/uv/CMakeLists.txt +++ b/src/bindings/io/uv/CMakeLists.txt @@ -16,7 +16,6 @@ else () set (IO_UV_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/io_uv.c") - add_headers (ELEKTRA_HEADERS) set (SOURCES ${IO_UV_SRC_FILES} ${ELEKTRA_HEADERS}) set (IO_UV_LIBRARY elektra-io-${BINDING_VARIANT}) @@ -54,7 +53,6 @@ else () set (TESTEXENAME testio_${BINDING_VARIANT}) set (TEST_SOURCES $) - add_headers (TEST_SOURCES) file (GLOB IO_TEST_SRC_FILES "${CMAKE_SOURCE_DIR}/src/bindings/io/test/test*.c") list (APPEND TEST_SOURCES ${IO_TEST_SRC_FILES}) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testio_${BINDING_VARIANT}.c") diff --git a/src/bindings/io/uv/example/CMakeLists.txt b/src/bindings/io/uv/example/CMakeLists.txt index 77ee28e8b36..90746d850cf 100644 --- a/src/bindings/io/uv/example/CMakeLists.txt +++ b/src/bindings/io/uv/example/CMakeLists.txt @@ -3,7 +3,6 @@ include (LibAddMacros) file (GLOB HDR_FILES *.h) file (GLOB SRC_FILES *.c) -add_headers (ELEKTRA_HEADERS) set (SOURCES ${SRC_FILES} ${HDR_FILES} ${ELEKTRA_HEADERS}) if (BUILD_FULL OR BUILD_STATIC) diff --git a/src/bindings/swig/lua/CMakeLists.txt b/src/bindings/swig/lua/CMakeLists.txt index 54e30c0a07e..4fbed9f456f 100644 --- a/src/bindings/swig/lua/CMakeLists.txt +++ b/src/bindings/swig/lua/CMakeLists.txt @@ -13,9 +13,6 @@ else () add_binding (lua) - add_headers (HDR_FILES) - add_cppheaders (HDR_FILES) - include_directories (SYSTEM ${LUA_INCLUDE_DIR}) include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include") diff --git a/src/bindings/swig/python/CMakeLists.txt b/src/bindings/swig/python/CMakeLists.txt index 3f1fb6889c7..aa37f42857b 100644 --- a/src/bindings/swig/python/CMakeLists.txt +++ b/src/bindings/swig/python/CMakeLists.txt @@ -37,8 +37,6 @@ else () message (WARNING "Python bindings might crash if generated with SWIG 2." " Please upgrade to SWIG 3 or later.") endif () - add_headers (HDR_FILES) - include_directories (SYSTEM ${PYTHON_INCLUDE_DIRS}) include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_SOURCE_DIR}/src/libs/tools/include") @@ -83,7 +81,6 @@ else () endmacro () # kdb module - add_cppheaders (HDR_FILES) add_python_binding (kdb kdb.i elektra-kdb) add_custom_command ( TARGET _swig-python-kdb @@ -96,7 +93,6 @@ else () if (${SWIG_VERSION} VERSION_LESS "4.0.0") message (WARNING "Python bindings for elektra tools require SWIG 4 or later. Not building.") else (${SWIG_VERSION} VERSION_LESS "4.0.0") - add_toolheaders (HDR_FILES) add_python_binding (tools tools.i elektratools) endif (${SWIG_VERSION} VERSION_LESS "4.0.0") diff --git a/src/bindings/swig/ruby/CMakeLists.txt b/src/bindings/swig/ruby/CMakeLists.txt index ddc6dff16bd..2ba7c55f8a0 100644 --- a/src/bindings/swig/ruby/CMakeLists.txt +++ b/src/bindings/swig/ruby/CMakeLists.txt @@ -29,10 +29,6 @@ else () add_binding (ruby) - add_headers (HDR_FILES) - add_cppheaders (HDR_FILES) - add_toolheaders (HDR_FILES) - include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_SOURCE_DIR}/src/libs/tools/include") # minimal replacement for Ruby's mkmf.create_makefile diff --git a/src/bindings/xfconf/CMakeLists.txt b/src/bindings/xfconf/CMakeLists.txt index fcf5d246d01..1c37aaf88f1 100644 --- a/src/bindings/xfconf/CMakeLists.txt +++ b/src/bindings/xfconf/CMakeLists.txt @@ -12,15 +12,13 @@ set ( xfconf-elektra CACHE INTERNAL "XFCONF_BINDING_LIBRARY") -add_headers (ELEKTRA_HEADERS) - include_directories (${GLIB_INCLUDE_DIRS}) include_directories (${XFCONF_INCLUDE_DIRS}) file (GLOB XFCONF_BINDING_HEADERS *.h) file (GLOB XFCONF_BINDING_SOURCES *.c) -set (SOURCES ${XFCONF_BINDING_HEADERS} ${XFCONF_BINDING_SOURCES} ${ELEKTRA_HEADERS}) +set (SOURCES ${XFCONF_BINDING_HEADERS} ${XFCONF_BINDING_SOURCES}) add_library (${XFCONF_BINDING_LIBRARY} SHARED ${SOURCES}) target_compile_options (${XFCONF_BINDING_LIBRARY} PUBLIC) target_link_libraries (${XFCONF_BINDING_LIBRARY} PUBLIC elektra-core elektra-kdb) diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index f008fb5ea14..53e3ace7450 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -1,7 +1,7 @@ include (LibAddLib) set ( - SUBDIRS + LIBRARIES core kdb type @@ -19,15 +19,9 @@ set ( opts) set (SYM_MAPS "") -foreach (subdir ${SUBDIRS}) - list (APPEND SYM_MAPS "${subdir}/symbols.map") -endforeach (subdir) - -# tools has special symbol handling -list (INSERT SUBDIRS 0 tools) - -# object libraries -> don't have symbol.map -list (INSERT SUBDIRS 0 base pluginload) +foreach (lib ${LIBRARIES}) + list (APPEND SYM_MAPS "${lib}/symbols.map") +endforeach (lib) add_custom_command ( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/symbols.map" @@ -38,9 +32,16 @@ add_custom_command ( VERBATIM) add_custom_target (generate_version_script DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/symbols.map") -foreach (subdir ${SUBDIRS}) - add_subdirectory ("${subdir}") -endforeach (subdir) +# object libraries don't have symbol.map +add_subdirectory (base) +add_subdirectory (pluginload) + +# tools has special symbol handling +add_subdirectory (tools) + +foreach (lib ${LIBRARIES}) + add_subdirectory ("${lib}") +endforeach (lib) generate_man_page ( elektra-libs @@ -51,112 +52,110 @@ generate_man_page ( COMPONENT elektra-doc) -# ########################################################################################################################################## -# Handling of BUILD_FULL AND BUILD_STATIC # -# ########################################################################################################################################## - -# do not include plugins configured with SHARED_ONLY in the exported symbols as those are only used for the FULL and STATIC builds -get_property (SHARED_ONLY_PLUGINS GLOBAL PROPERTY SHARED_ONLY_PLUGINS) -set (ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${ADDED_PLUGINS}) -if (SHARED_ONLY_PLUGINS) - list (REMOVE_ITEM ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${SHARED_ONLY_PLUGINS}) -endif (SHARED_ONLY_PLUGINS) - -include (ExportPluginSymbols) -elektra_export_plugin_symbols ( - SOURCE - "${CMAKE_BINARY_DIR}/src/exported_symbols.c" - HEADER - "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h" - RESOLVER - ${KDB_DEFAULT_RESOLVER} - STORAGE - ${KDB_DEFAULT_STORAGE} - PLUGINS - ${ADDED_PLUGINS_WITHOUT_ONLY_SHARED}) - -# collect all the source files -get_property (elektra_SRCS GLOBAL PROPERTY elektra_SRCS) - -set (SOURCES ${elektra_SRCS} ${HDR_FILES}) -list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h") - -# the targets built to export set (targets_built) - -set (__symbols_file "${CMAKE_BINARY_DIR}/src/libs/symbols.map") - if (BUILD_FULL OR BUILD_STATIC) - # for the next two builds, append some more sources - get_property (elektra-full_SRCS GLOBAL PROPERTY elektra-full_SRCS) - list (APPEND SOURCES "${CMAKE_BINARY_DIR}/src/exported_symbols.c") + get_property (SHARED_ONLY_PLUGINS GLOBAL PROPERTY SHARED_ONLY_PLUGINS) + get_property (EXTERNAL_LIBRARIES GLOBAL PROPERTY ELEKTRA_LINK_LIBRARIES) + + # do not include plugins configured with SHARED_ONLY in the exported symbols as those are only used for the FULL and STATIC builds + set (ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${ADDED_PLUGINS}) + if (SHARED_ONLY_PLUGINS) + list (REMOVE_ITEM ADDED_PLUGINS_WITHOUT_ONLY_SHARED ${SHARED_ONLY_PLUGINS}) + endif (SHARED_ONLY_PLUGINS) + + include (ExportPluginSymbols) + elektra_export_plugin_symbols ( + SOURCE + "${CMAKE_BINARY_DIR}/src/exported_symbols.c" + HEADER + "${CMAKE_BINARY_DIR}/src/include/internal/exported_symbols.h" + RESOLVER + ${KDB_DEFAULT_RESOLVER} + STORAGE + ${KDB_DEFAULT_STORAGE} + PLUGINS + ${ADDED_PLUGINS_WITHOUT_ONLY_SHARED}) + + set (__symbols_file "${CMAKE_BINARY_DIR}/src/libs/symbols.map") + + set (OBJ_TARGETS $ $) + foreach (lib ${ADDED_LIBRARIES}) + list (APPEND OBJ_TARGETS "$") + endforeach (lib) + foreach (plugin ${ADDED_PLUGINS_WITHOUT_ONLY_SHARED}) + list (APPEND OBJ_TARGETS "$") + endforeach (plugin) + if (TARGET io-adapter-dbus) + list (APPEND OBJ_TARGETS "$") + endif () + if (TARGET io-adapter-zeromq) + list (APPEND OBJ_TARGETS "$") + endif () - # and get all libraries to link against - get_property (elektra-full_LIBRARIES GLOBAL PROPERTY elektra-full_LIBRARIES) + if (BUILD_FULL) + add_library (elektra-full SHARED "${CMAKE_BINARY_DIR}/src/exported_symbols.c" ${OBJ_TARGETS}) + add_dependencies (elektra-full generate_version_script) + + target_link_libraries (elektra-full ${EXTERNAL_LIBRARIES}) + + set_target_properties ( + elektra-full + PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" + VERSION ${KDB_VERSION} + SOVERSION ${SO_VERSION} + CLEAN_DIRECT_OUTPUT 1 + LINKER_LANGUAGE C + LINK_DEPENDS "${__symbols_file}") + if (${LD_ACCEPTS_VERSION_SCRIPT}) + set_target_properties (elektra-full PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") + endif () + + install ( + TARGETS elektra-full + DESTINATION lib${LIB_SUFFIX} + EXPORT ElektraTargetsLibelektra + COMPONENT libelektra${SO_VERSION}-full) + + list (APPEND targets_built elektra-full) + endif (BUILD_FULL) + + if (BUILD_STATIC) + add_library (elektra-static STATIC "${CMAKE_BINARY_DIR}/src/exported_symbols.c" ${OBJ_TARGETS}) + add_dependencies (elektra-static generate_version_script) + + target_link_libraries (elektra-static ${EXTERNAL_LIBRARIES}) + + set_target_properties ( + elektra-static + PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" + VERSION ${KDB_VERSION} + SOVERSION ${SO_VERSION} + CLEAN_DIRECT_OUTPUT 1 + LINKER_LANGUAGE C + LINK_DEPENDS "${__symbols_file}") + if (${LD_ACCEPTS_VERSION_SCRIPT}) + set_target_properties (elektra-static PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") + endif () + + install ( + TARGETS elektra-static + DESTINATION lib${LIB_SUFFIX} + EXPORT ElektraTargetsLibelektra + COMPONENT libelektra${SO_VERSION}) + + list (APPEND targets_built elektra-static) + endif (BUILD_STATIC) - # include the directories of all libraries for the static or full-shared build - get_property (elektra-full_INCLUDES GLOBAL PROPERTY elektra-full_INCLUDES) endif (BUILD_FULL OR BUILD_STATIC) -if (BUILD_FULL) - set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) - add_library (elektra-full SHARED ${SOURCES}) - add_dependencies (elektra-full generate_version_script) - - target_link_libraries (elektra-full ${elektra-full_LIBRARIES}) - # include the current binary directory to get exported_symbols.h - target_include_directories (elektra-full PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") - - set_target_properties ( - elektra-full - PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" - VERSION ${KDB_VERSION} - SOVERSION ${SO_VERSION} - CLEAN_DIRECT_OUTPUT 1 - LINKER_LANGUAGE CXX - LINK_DEPENDS "${__symbols_file}") - if (${LD_ACCEPTS_VERSION_SCRIPT}) - set_target_properties (elektra-full PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") - endif () - - install ( - TARGETS elektra-full - DESTINATION lib${LIB_SUFFIX} - EXPORT ElektraTargetsLibelektra - COMPONENT libelektra${SO_VERSION}-full) - - list (APPEND targets_built elektra-full) -endif (BUILD_FULL) - -if (BUILD_STATIC) - set_source_files_properties (${PROJECT_BINARY_DIR}/src/error/elektra_errors.c PROPERTIES GENERATED ON) - add_library (elektra-static STATIC ${SOURCES}) - add_dependencies (elektra-static generate_version_script) - - target_link_libraries (elektra-static ${elektra-full_LIBRARIES}) - # include the current binary directory to get exported_symbols.h - target_include_directories (elektra-static PRIVATE ${elektra-full_INCLUDES} "${CMAKE_CURRENT_BINARY_DIR}") - - set_target_properties ( - elektra-static - PROPERTIES COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_STATIC" - VERSION ${KDB_VERSION} - SOVERSION ${SO_VERSION} - CLEAN_DIRECT_OUTPUT 1 - LINKER_LANGUAGE CXX - LINK_DEPENDS "${__symbols_file}") - if (${LD_ACCEPTS_VERSION_SCRIPT}) - set_target_properties (elektra-static PROPERTIES LINK_FLAGS "-Wl,--version-script='${__symbols_file}'") - endif () - - install ( - TARGETS elektra-static - DESTINATION lib${LIB_SUFFIX} - EXPORT ElektraTargetsLibelektra - COMPONENT libelektra${SO_VERSION}) +if (BUILD_SHARED) + foreach (lib ${ADDED_LIBRARIES}) + list (APPEND targets_built "elektra-${lib}") - list (APPEND targets_built elektra-static) -endif (BUILD_STATIC) + # TODO: should only be required for libs that load plugin (i.e. kdb and plugin) + set_target_properties (elektra-${lib} PROPERTIES INSTALL_RPATH "${ELEKTRA_RPATH}") + endforeach (lib) +endif (BUILD_SHARED) export (TARGETS ${targets_built} FILE "${CMAKE_CURRENT_BINARY_DIR}/ElektraTargetsLibelektra.cmake") install ( diff --git a/src/libs/base/CMakeLists.txt b/src/libs/base/CMakeLists.txt index f4fd996dde8..2611693af49 100644 --- a/src/libs/base/CMakeLists.txt +++ b/src/libs/base/CMakeLists.txt @@ -8,7 +8,3 @@ endif (HAVE_LOGGER) add_library (elektra-base OBJECT ${SOURCES}) set_property (TARGET elektra-base PROPERTY POSITION_INDEPENDENT_CODE ON) - -if (BUILD_FULL OR BUILD_STATIC) - add_sources (elektra-full $) -endif (BUILD_FULL OR BUILD_STATIC) diff --git a/src/libs/kdb/CMakeLists.txt b/src/libs/kdb/CMakeLists.txt index 126922881b4..97a5c3bb28b 100644 --- a/src/libs/kdb/CMakeLists.txt +++ b/src/libs/kdb/CMakeLists.txt @@ -10,5 +10,5 @@ set ( add_lib (kdb SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) if (BUILD_SHARED) - target_link_libraries (elektra-kdb $) + target_link_libraries (elektra-kdb $) endif (BUILD_SHARED) diff --git a/src/libs/merge/CMakeLists.txt b/src/libs/merge/CMakeLists.txt index ce50ec34e35..9f1fff9fabe 100644 --- a/src/libs/merge/CMakeLists.txt +++ b/src/libs/merge/CMakeLists.txt @@ -6,12 +6,6 @@ if (LibGit2_FOUND) add_definitions (-DLIBGITFOUND) endif () -# This is derived from LibAddPlugin. LibAddLib has no such functionality yet. This is required so that libelektra-full.so has defined -# references to the functions from libgit2.so. I am not sure if the second set_property from LibAddPlugin has to be here as well. It might -# not always be obvious, that this property has to be set. For example if the gitresolver plugin is included, then it sets the property -# itself and it appears as if setting it here were unnecessary. -set_property (GLOBAL APPEND PROPERTY "elektra-full_LIBRARIES" ${CMERGE_LIBRARY_DIRS}) - # elektra-ease is required for elektraArrayIncName and elektraArrayValidateName see add_plugin for how LINK_ELEKTRA etc. work # # we have to link CMERGE_LIBRARY_DIRS here so that elektra-merge.so has the functions from libgit2.so diff --git a/src/libs/meta/meta.c b/src/libs/meta/meta.c index 93e8a6a8f96..3c537e44b76 100644 --- a/src/libs/meta/meta.c +++ b/src/libs/meta/meta.c @@ -17,26 +17,11 @@ #include #include -#ifdef HAVE_STDIO_H -#include -#endif - -#ifdef HAVE_STDARG_H +#include #include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STDLIB_H +#include #include -#endif - -#ifdef HAVE_ERRNO_H -#include -#endif - +#include /** * @defgroup meta Meta Data proposal+compatibility diff --git a/src/libs/notification/tests/CMakeLists.txt b/src/libs/notification/tests/CMakeLists.txt index a324e6e81d5..ca48b7af6e1 100644 --- a/src/libs/notification/tests/CMakeLists.txt +++ b/src/libs/notification/tests/CMakeLists.txt @@ -2,9 +2,6 @@ include (LibAddMacros) # Clang with enabled ASAN reports that this test leaks memory: https://travis-ci.org/sanssecours/elektra/jobs/383014685#L2197 if (BUILD_TESTING AND NOT ENABLE_ASAN) - - add_headers (HDR_FILES) - set (TESTS testlib_notification.c) foreach (file ${TESTS}) diff --git a/src/libs/pluginload/CMakeLists.txt b/src/libs/pluginload/CMakeLists.txt index 03f10e1be3e..f4bd101f756 100644 --- a/src/libs/pluginload/CMakeLists.txt +++ b/src/libs/pluginload/CMakeLists.txt @@ -1,7 +1,8 @@ include (LibAddMacros) if (BUILD_FULL OR BUILD_STATIC) - add_sources (elektra-full "static.c") + add_library (elektra-pluginload-static OBJECT static.c) + set_property (TARGET elektra-pluginload-static PROPERTY POSITION_INDEPENDENT_CODE ON) endif (BUILD_FULL OR BUILD_STATIC) if (BUILD_SHARED) @@ -23,11 +24,10 @@ if (BUILD_SHARED) set (CMAKE_DL_LIBS "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/lib/libdl.dll.a") - add_library (elektra-pluginload OBJECT ${CMAKE_DL_LIBS}) - target_include_directories (elektra-pluginload SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/include") + add_library (elektra-pluginload-dl OBJECT ${CMAKE_DL_LIBS}) + target_include_directories (elektra-pluginload-dl SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32/include") else () - add_library (elektra-pluginload OBJECT dl.c) + add_library (elektra-pluginload-dl OBJECT dl.c) endif () - - set_property (TARGET elektra-pluginload PROPERTY POSITION_INDEPENDENT_CODE ON) + set_property (TARGET elektra-pluginload-dl PROPERTY POSITION_INDEPENDENT_CODE ON) endif (BUILD_SHARED) diff --git a/src/libs/pluginprocess/tests/CMakeLists.txt b/src/libs/pluginprocess/tests/CMakeLists.txt index d07e2e79b5b..4e96e8a8cb7 100644 --- a/src/libs/pluginprocess/tests/CMakeLists.txt +++ b/src/libs/pluginprocess/tests/CMakeLists.txt @@ -1,9 +1,6 @@ include (LibAddMacros) if (BUILD_TESTING) - - add_headers (HDR_FILES) - set (TESTS testlib_pluginprocess.c) foreach (file ${TESTS}) diff --git a/src/libs/tools/benchmarks/CMakeLists.txt b/src/libs/tools/benchmarks/CMakeLists.txt index d39515b81b7..1e318cfe6fe 100644 --- a/src/libs/tools/benchmarks/CMakeLists.txt +++ b/src/libs/tools/benchmarks/CMakeLists.txt @@ -1,9 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - macro (do_benchmark source) set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) diff --git a/src/libs/tools/examples/CMakeLists.txt b/src/libs/tools/examples/CMakeLists.txt index 8c6b61c4272..c9f45e995bd 100644 --- a/src/libs/tools/examples/CMakeLists.txt +++ b/src/libs/tools/examples/CMakeLists.txt @@ -1,9 +1,5 @@ include (LibAddMacros) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - macro (do_example source) set (SOURCES ${HDR_FILES} ${source}.cpp) add_executable (${source} ${SOURCES}) diff --git a/src/libs/tools/src/CMakeLists.txt b/src/libs/tools/src/CMakeLists.txt index a77f8d2db94..f586fb4c638 100644 --- a/src/libs/tools/src/CMakeLists.txt +++ b/src/libs/tools/src/CMakeLists.txt @@ -2,10 +2,6 @@ include (LibAddMacros) include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_CURRENT_SOURCE_DIR}/../include") -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - file (GLOB_RECURSE SRC_FILES *.cpp) # ~~~ diff --git a/src/libs/tools/tests/CMakeLists.txt b/src/libs/tools/tests/CMakeLists.txt index e260ec4010b..8912f3862b2 100644 --- a/src/libs/tools/tests/CMakeLists.txt +++ b/src/libs/tools/tests/CMakeLists.txt @@ -2,10 +2,6 @@ include (LibAddMacros) include_directories ("${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_CURRENT_SOURCE_DIR}/../include") -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - include (LibAddTest) list (FIND REMOVED_PLUGINS error error_index) diff --git a/src/plugins/dbus/CMakeLists.txt b/src/plugins/dbus/CMakeLists.txt index ab879a643b6..4849fee6712 100644 --- a/src/plugins/dbus/CMakeLists.txt +++ b/src/plugins/dbus/CMakeLists.txt @@ -21,7 +21,6 @@ if (ADDTESTING_PHASE) set (SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/example_dbus.c ${CMAKE_CURRENT_SOURCE_DIR}/sendmessage.c ${CMAKE_CURRENT_SOURCE_DIR}/receivemessage.c) set (HDR_FILES ${CMAKE_CURRENT_SOURCE_DIR}/dbus.h) - add_headers (ELEKTRA_HEADERS) set (SOURCES ${SRC_FILES} ${HDR_FILES} ${ELEKTRA_HEADERS}) add_executable (${example} ${SOURCES}) diff --git a/src/plugins/specload/CMakeLists.txt b/src/plugins/specload/CMakeLists.txt index 102894efb52..48c897b9162 100644 --- a/src/plugins/specload/CMakeLists.txt +++ b/src/plugins/specload/CMakeLists.txt @@ -19,8 +19,6 @@ if (ADDTESTING_PHASE) set (TEST_SOURCES $ ${ARG_OBJECT_SOURCES}) list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/test_testapp.c") - add_headers (TEST_SOURCES) - add_testheaders (TEST_SOURCES) add_executable (test_elektra-specload-testapp ${TEST_SOURCES}) target_link_elektra (test_elektra-specload-testapp elektra-core elektra-invoke) diff --git a/src/tools/hub-zeromq/CMakeLists.txt b/src/tools/hub-zeromq/CMakeLists.txt index 9e78d7cf461..32eb1ebf3ad 100644 --- a/src/tools/hub-zeromq/CMakeLists.txt +++ b/src/tools/hub-zeromq/CMakeLists.txt @@ -9,7 +9,6 @@ else () # find installation path set (SRC_FILES hub-zeromq.c) - add_headers (ELEKTRA_HEADERS) set (SOURCES ${SRC_FILES} ${ELEKTRA_HEADERS}) # Build hub diff --git a/src/tools/kdb/CMakeLists.txt b/src/tools/kdb/CMakeLists.txt index f5bb1400db9..23c9154d95a 100644 --- a/src/tools/kdb/CMakeLists.txt +++ b/src/tools/kdb/CMakeLists.txt @@ -1,9 +1,7 @@ include (LibAddMacros) file (GLOB HDR_FILES *.hpp gen/*.hpp gen/*/*.hpp) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) + include_directories (${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/src/bindings/cpp/include" "${CMAKE_SOURCE_DIR}/src/libs/tools/include") diff --git a/src/tools/qt-gui/CMakeLists.txt b/src/tools/qt-gui/CMakeLists.txt index 0fafa7d91a1..f1d508c09f4 100644 --- a/src/tools/qt-gui/CMakeLists.txt +++ b/src/tools/qt-gui/CMakeLists.txt @@ -37,10 +37,6 @@ else () file (GLOB qt-gui_HDRS "src/markdownconverter/*.h" "src/markdownconverter/template/*.h") - add_headers (qt-gui_HDRS) - add_cppheaders (qt-gui_HDRS) - add_toolheaders (qt-gui_HDRS) - file (GLOB qt-gui_SRCS "src/*.cpp" "src/markdownconverter/*.cpp" "src/markdownconverter/template/*.cpp") set (qt-gui_RSCS resources.qrc) diff --git a/src/tools/race/CMakeLists.txt b/src/tools/race/CMakeLists.txt index a95e3cabe62..c0a2b655c1b 100644 --- a/src/tools/race/CMakeLists.txt +++ b/src/tools/race/CMakeLists.txt @@ -11,8 +11,6 @@ else () return () endif () - add_headers (HDR_FILES) - add_executable (race race.c) tool_link_elektra (race) target_link_libraries (race ${CMAKE_THREAD_LIBS_INIT}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 06c07f1d264..81431a2a0e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,13 +40,8 @@ if (ENABLE_TESTING) set_property (TARGET gtest_main PROPERTY COMPILE_FLAGS "-Wno-undef") endif (ENABLE_TESTING) -# don't call add_headers in a loop -add_headers (HDR_FILES) - macro (do_test source) set (SOURCES ${HDR_FILES} ${source}.c $) - add_headers (SOURCES) - add_testheaders (SOURCES) add_executable (${source} ${SOURCES}) target_include_directories (${source} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tests/cframework/CMakeLists.txt b/tests/cframework/CMakeLists.txt index 57567d22240..81d7579fbbb 100644 --- a/tests/cframework/CMakeLists.txt +++ b/tests/cframework/CMakeLists.txt @@ -16,9 +16,6 @@ if (HAVE_NFTW) endif (HAVE_NFTW) set (SOURCES tests.c) -add_headers (SOURCES) -add_testheaders (SOURCES) - add_library (cframework OBJECT ${SOURCES}) set_target_properties (cframework PROPERTIES COMPILE_DEFINITIONS HAVE_KDBCONFIG_H) diff --git a/tests/ctest/test_keyCopy_memerror.c b/tests/ctest/test_keyCopy_memerror.c index 94d41a08bf5..71207fb17e7 100644 --- a/tests/ctest/test_keyCopy_memerror.c +++ b/tests/ctest/test_keyCopy_memerror.c @@ -6,6 +6,8 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ +#define ksDup ksDupFailing + #include "../../src/libs/core/cow.c" #include "../../src/libs/core/key.c" #include "../../src/libs/core/keyhelpers.c" @@ -16,7 +18,7 @@ #include -KeySet * ksDup (const KeySet * source ELEKTRA_UNUSED) +KeySet * ksDupFailing (const KeySet * source ELEKTRA_UNUSED) { // We override ksDup here to return NULL // This should cause keyCopy to fail diff --git a/tests/kdb/CMakeLists.txt b/tests/kdb/CMakeLists.txt index e13a86fee50..e4b13ee29ae 100644 --- a/tests/kdb/CMakeLists.txt +++ b/tests/kdb/CMakeLists.txt @@ -1,9 +1,5 @@ find_package (Threads QUIET) -add_headers (HDR_FILES) -add_cppheaders (HDR_FILES) -add_toolheaders (HDR_FILES) - include (LibAddTest) # This function checks information about the currently selected version of Xcode. From c855305d294c693e36e385e9bdca8955b181cb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:18 +0200 Subject: [PATCH 07/41] doc: fix links --- doc/CODING.md | 2 +- doc/Doxyfile | 4 +- doc/KEYNAMES.md | 2 +- .../2_solutions_clear/simplify_api.md | 2 +- doc/dev/data-structures.md | 2 +- doc/dev/symbol-versioning.md | 2 +- doc/help/elektra-key-names.md | 2 +- doc/man/man7/elektra-key-names.7 | 4 +- doc/man/man7/elektra-libs.7 | 12 +++--- doc/tutorials/profiling.md | 2 +- src/libs/README.md | 41 +++++++------------ 11 files changed, 31 insertions(+), 44 deletions(-) diff --git a/doc/CODING.md b/doc/CODING.md index 658df5126eb..c6a5aeecfea 100644 --- a/doc/CODING.md +++ b/doc/CODING.md @@ -130,7 +130,7 @@ You can also enable that formatting runs automatically before commiting using `s - C-Files have extension `.c`, Header files `.h`. - Use internal functions: prefer to use `elektraMalloc`, `elektraFree`. -**Example:** [src/libs/elektra/kdb.c](/src/libs/elektra/kdb.c) +**Example:** [src/libs/kdb/kdb.c](/src/libs/kdb/kdb.c) #### Clang Format diff --git a/doc/Doxyfile b/doc/Doxyfile index 43a18be982a..11c8bed784a 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -907,8 +907,8 @@ WARN_LOGFILE = @OUTPUT_DIRECTORY@/doxygen.log # Note: If this tag is empty the current directory is searched. INPUT = @PROJECT_SOURCE_DIR@/src/libs \ - @PROJECT_SOURCE_DIR@/src/libs/loader/doc.c \ - @PROJECT_SOURCE_DIR@/src/libs/getenv/README.md \ + @PROJECT_SOURCE_DIR@/src/libs/pluginload/doc.c \ + @PROJECT_SOURCE_DIR@/src/bindings/intercept/env/README.md \ @PROJECT_SOURCE_DIR@/src/include \ @PROJECT_SOURCE_DIR@/src/bindings/cpp/include \ @PROJECT_SOURCE_DIR@/src/bindings/jna/libelektra/src \ diff --git a/doc/KEYNAMES.md b/doc/KEYNAMES.md index efa0e84a417..ddd86b7ce6f 100644 --- a/doc/KEYNAMES.md +++ b/doc/KEYNAMES.md @@ -6,7 +6,7 @@ This document is a full explanation of how _key names_ work in Elektra. In addition to this document, a reference Python implementation can be found in [keynames.py](../scripts/keynames.py). The goal of the Python implementation is not to be fast, or to be used in any way other than as a reference. -If there are any discrepancies between this document, the Python implementation and the actual C implementation in [src/libs/elektra/keyname.c](../src/libs/elektra/keyname.c), you should consider them as follows: +If there are any discrepancies between this document, the Python implementation and the actual C implementation in [src/libs/elektra/keyname.c](../src/libs/core/keyname.c), you should consider them as follows: 1. The C implementation is optimized for speed and thus much harder to implement correctly. 2. In most cases, this document outranks the Python implementation. diff --git a/doc/decisions/2_solutions_clear/simplify_api.md b/doc/decisions/2_solutions_clear/simplify_api.md index 57a478a33d3..b4ffd638ef2 100644 --- a/doc/decisions/2_solutions_clear/simplify_api.md +++ b/doc/decisions/2_solutions_clear/simplify_api.md @@ -2,7 +2,7 @@ ## Problem -According to [symbols.map](/src/libs/elektra/symbols.map) the public core API has 124 symbols¹, which is arguable too much for a key-value API which has as highest goal simplicity. +According to [symbols.map](/src/libs/core/symbols.map) the public core API has 124 symbols¹, which is arguable too much for a key-value API which has as highest goal simplicity. In particular following areas have many functions and are not simple: diff --git a/doc/dev/data-structures.md b/doc/dev/data-structures.md index 8539f3c00ff..245cd94fc65 100644 --- a/doc/dev/data-structures.md +++ b/doc/dev/data-structures.md @@ -213,7 +213,7 @@ The OPMPHM is a non-dynamic randomized hash map of the Las Vegas type, that crea to gain O(1) access. The elements must be arranged in an array and each element must have a unique name, to identify the elements. -The source can be found in [opmphm.h](/src/include/internal/core/opmphm.h) and [opmphm.c](/src/libs/elektra/opmphm.c) +The source can be found in [opmphm.h](/src/include/internal/core/opmphm.h) and [opmphm.c](/src/libs/core/opmphm.c) and also works outside of Elektra. The OPMPHM does not store any buckets, your array of elements are the buckets and the OPMPHM represent an arbitrary diff --git a/doc/dev/symbol-versioning.md b/doc/dev/symbol-versioning.md index e998c45371d..7e9d0fef609 100644 --- a/doc/dev/symbol-versioning.md +++ b/doc/dev/symbol-versioning.md @@ -9,7 +9,7 @@ The setup used is based on the one used by FreeBSD. The main script [`version_ge (with small modifications to enable Alpine Linux compatibility). The main script, is called by CMake during the build process. It parses the `symbols.map` files of all libraries (e.g. -[`/src/libs/elektra/symbols.map`](/src/libs/elektra/symbols.map)) and combines them into a single file, which is then used by the compiler +[`/src/libs/core/symbols.map`](/src/libs/core/symbols.map)) and combines them into a single file, which is then used by the compiler and the linker. ### `versions.def` diff --git a/doc/help/elektra-key-names.md b/doc/help/elektra-key-names.md index fde7681c0ff..5bc07ece709 100644 --- a/doc/help/elektra-key-names.md +++ b/doc/help/elektra-key-names.md @@ -107,7 +107,7 @@ the key names of software-applications should always start with: - [see application integration tutorial](/doc/tutorials/application-integration.md) - [see namespaces tutorial](/doc/tutorials/namespaces.md) -- [key name source file](/src/libs/elektra/keyname.c) or [its rendered API documentation](https://doc.libelektra.org/api/master/html/group__keyname.html#details) +- [key name source file](/src/libs/core/keyname.c) or [its rendered API documentation](https://doc.libelektra.org/api/master/html/group__keyname.html#details) - [elektra-namespaces(7)](elektra-namespaces.md) - [elektra-cascading(7)](elektra-cascading.md) diff --git a/doc/man/man7/elektra-key-names.7 b/doc/man/man7/elektra-key-names.7 index ccd0ea207e4..d2ec074478c 100644 --- a/doc/man/man7/elektra-key-names.7 +++ b/doc/man/man7/elektra-key-names.7 @@ -1,6 +1,6 @@ .\" generated with Ronn-NG/v0.10.1 .\" http://github.com/apjanke/ronn-ng/tree/0.10.1.pre3 -.TH "ELEKTRA\-KEY\-NAMES" "7" "November 2021" "" +.TH "ELEKTRA\-KEY\-NAMES" "7" "April 2023" "" .SH "NAME" \fBelektra\-key\-names\fR \- the names of keys .P @@ -71,7 +71,7 @@ see application integration tutorial \fI/doc/tutorials/application\-integration\ .IP "\(bu" 4 see namespaces tutorial \fI/doc/tutorials/namespaces\.md\fR .IP "\(bu" 4 -key name source file \fI/src/libs/elektra/keyname\.c\fR or its rendered API documentation \fIhttps://doc\.libelektra\.org/api/master/html/group__keyname\.html#details\fR +key name source file \fI/src/libs/core/keyname\.c\fR or its rendered API documentation \fIhttps://doc\.libelektra\.org/api/master/html/group__keyname\.html#details\fR .IP "\(bu" 4 elektra\-namespaces(7) \fIelektra\-namespaces\.md\fR .IP "\(bu" 4 diff --git a/doc/man/man7/elektra-libs.7 b/doc/man/man7/elektra-libs.7 index a86348201ff..bb742cd127b 100644 --- a/doc/man/man7/elektra-libs.7 +++ b/doc/man/man7/elektra-libs.7 @@ -1,6 +1,6 @@ .\" generated with Ronn-NG/v0.10.1 .\" http://github.com/apjanke/ronn-ng/tree/0.10.1.pre3 -.TH "ELEKTRA\-LIBS" "7" "October 2022" "" +.TH "ELEKTRA\-LIBS" "7" "April 2023" "" .SH "NAME" \fBelektra\-libs\fR \- libs overview .IP "" 4 @@ -27,18 +27,18 @@ Using asynchronous I/O bindings \fIhttps://www\.libelektra\.org/examples/notific Reload KDB when Elektra's configuration has changed \fIhttps://www\.libelektra\.org/examples/notificationreload\fR .IP "" 0 .SH "Base Elektra Libraries" -Since version \fB0\.8\.15\fR \fBlibelektra \fIelektra/\fR\fR is split into following libraries: +Since version \fB0\.8\.15\fR \fBlibelektra\fR is split into following libraries: .P .SS "Libkdb" .nf libelektra\-kdb\.so .fi .P -Accesses the configuration files by orchestrating the plugins\. The implementation lives in \fIelektra\fR\. +Accesses the configuration files by orchestrating the plugins\. The implementation lives in \fIkdb\fR\. .P It coordinates the interactions between the applications and the plugins\. .P -\fBloader \fIloader/\fR\fR contains source files that implement the plugin loader functionality as used by \fBlibelektra\-kdb\fR\. +\fBpluginload \fIpluginload/\fR\fR contains source files that implement the plugin loader functionality as used by \fBlibelektra\-kdb\fR\. .SS "Libcore" .nf libelektra\-core\.so @@ -46,7 +46,7 @@ libelektra\-core\.so (key* and ks*) .fi .P -Contains the fundamental data\-structures every participant of Elektra needs to link against\. It should be the only part that access the internal data structures\. The implementation lives in \fIelektra\fR\. +Contains the fundamental data\-structures every participant of Elektra needs to link against\. It should be the only part that access the internal data structures\. The implementation lives in \fIcore\fR\. .SS "Libease" .nf libelektra\-ease\.so @@ -71,8 +71,6 @@ libelektra\-merge\.so .fi .P \fBlibmerge \fImerge/\fR\fR provides functionality for 3\-way merges of keysets\. -.SS "Libelektra" -Is a legacy library that provides the same functionality as \fBlibelektra\-kdb\fR and \fBlibelektra\-core\fR\. The sources can be found in \fBlibelektra \fIelektra/\fR\fR\. .SH "Other Libraries" .SS "Libpluginprocess" .nf diff --git a/doc/tutorials/profiling.md b/doc/tutorials/profiling.md index 0b9ca74e593..5709857884c 100644 --- a/doc/tutorials/profiling.md +++ b/doc/tutorials/profiling.md @@ -25,7 +25,7 @@ Since we want to improve the readability of the Callgrind output we choose a bui #### Disabling `dlclose` Calls -For this tutorial we decided to profile the [YAJL][] plugin. Since Elektra loads plugin code via `dlopen` and Callgrind [does not support the function `dlclose` properly](https://stackoverflow.com/questions/16719395) we remove the `dlclose` calls in the file [`dl.c`](../../src/libs/loader/dl.c) temporarily. At the time of writing one option to do that is deleting +For this tutorial we decided to profile the [YAJL][] plugin. Since Elektra loads plugin code via `dlopen` and Callgrind [does not support the function `dlclose` properly](https://stackoverflow.com/questions/16719395) we remove the `dlclose` calls in the file [`dl.c`](../../src/libs/pluginload/dl.c) temporarily. At the time of writing one option to do that is deleting - a single line `dlclose` statement, and - an `if`-statement that checks the return value of a `dlclose` call diff --git a/src/libs/README.md b/src/libs/README.md index b57fe8c957c..69d5da964e4 100644 --- a/src/libs/README.md +++ b/src/libs/README.md @@ -28,8 +28,9 @@ Usage examples: ## Base Elektra Libraries -Since version **0.8.15** **[libelektra](elektra/)** -is split into following libraries: + + +Since version **0.8.15** `libelektra` is split into following libraries: ![Overview of Libraries](/doc/images/overview_libs.png) @@ -40,12 +41,11 @@ libelektra-kdb.so ``` Accesses the configuration files by orchestrating the plugins. -The implementation lives in [elektra](elektra). +The implementation lives in [kdb](kdb). It coordinates the interactions between the applications and the plugins. -**[loader](loader/)** contains source files that implement the plugin -loader functionality as used by `libelektra-kdb`. +**[pluginload](pluginload/)** contains source files that implement the plugin loader functionality as used by `libelektra-kdb`. ### Libcore @@ -55,10 +55,8 @@ libelektra-core.so (key* and ks*) ``` -Contains the fundamental data-structures every participant of Elektra needs -to link against. It should be the only part that access the internal -data structures. -The implementation lives in [elektra](elektra). +Contains the fundamental data-structures every participant of Elektra needs to link against. It should be the only part that access the internal data structures. +The implementation lives in [core](core). ### Libease @@ -95,11 +93,6 @@ libelektra-merge.so **[libmerge](merge/)** provides functionality for 3-way merges of keysets. -### Libelektra - -Is a legacy library that provides the same functionality as `libelektra-kdb` and `libelektra-core`. -The sources can be found in **[libelektra](elektra/)**. - ## Other Libraries ### Libpluginprocess @@ -108,15 +101,12 @@ The sources can be found in **[libelektra](elektra/)**. libelektra-pluginprocess.so ``` -**[libpluginprocess](pluginprocess/)** contains functions aiding in executing plugins in a separate -process and communicating with those child processes. This child process is forked from Elektra's -main process each time such plugin is used and gets closed again afterwards. It uses a simple -communication protocol based on a KeySet that gets serialized through a pipe via the dump plugin to -orchestrate the processes. +**[libpluginprocess](pluginprocess/)** contains functions aiding in executing plugins in a separate process and communicating with those child processes. +This child process is forked from Elektra's main process each time such plugin is used and gets closed again afterwards. +It uses a simple communication protocol based on a KeySet that gets serialized through a pipe via the dump plugin to orchestrate the processes. -This is useful for plugins which cause memory leaks to be isolated in an own process. Furthermore -this is useful for runtimes or libraries that cannot be reinitialized in the same process after they -have been used. +This is useful for plugins which cause memory leaks to be isolated in an own process. +Furthermore this is useful for runtimes or libraries that cannot be reinitialized in the same process after they have been used. ### Libtools @@ -144,9 +134,7 @@ libelektra-invoke.so libelektra-io.so ``` -**[io](io/)** provides the -[common API](https://doc.libelektra.org/api/latest/html/group__kdbio.html) for -using asynchronous I/O bindings. +**[io](io/)** provides the [common API](https://doc.libelektra.org/api/latest/html/group__kdbio.html) for using asynchronous I/O bindings. ### Globbing @@ -156,7 +144,8 @@ libelektra-globbing.so **[globbing](globbing/)** provides globbing functionality for Elektra. -The supported syntax is a superset of the syntax used by `glob(7)`. The following extensions are supported: +The supported syntax is a superset of the syntax used by `glob(7)`. +The following extensions are supported: - `#`, when used as `/#/` (or `/#"` at the end of the pattern), matches a valid array item - `_` is the exact opposite; it matches anything but a valid array item From f56b0ee67b6ccff44a1cfe3d58dc25fea188ab84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:19 +0200 Subject: [PATCH 08/41] general: update includes after move --- benchmarks/benchmarks.c | 1 + benchmarks/changetracking.c | 3 +++ benchmarks/opmphm.c | 1 + benchmarks/plugingetset.c | 2 +- examples/notificationAsync.c | 1 + examples/notificationReload.c | 1 + src/bindings/cpp/tests/testcpp_contextual_policy.cpp | 2 ++ src/bindings/intercept/env/src/getenv.cpp | 1 + src/bindings/io/ev/example/exampleio_ev.c | 1 + src/bindings/io/ev/io_ev.c | 3 +++ src/bindings/io/glib/example/exampleio_glib.c | 1 + src/bindings/io/glib/io_glib.c | 3 +++ src/bindings/io/test/test_idle.c | 1 + src/bindings/io/test/test_mix.c | 1 + src/bindings/io/test/test_timer.c | 1 + src/bindings/io/uv/example/exampleio_uv.c | 1 + src/bindings/io/uv/io_uv.c | 2 ++ src/bindings/xfconf/elektra-xfconf-channel.c | 2 +- src/include/internal/utility/assert.h | 3 ++- src/include/internal/utility/logger.h | 3 ++- src/libs/base/internal.c | 2 +- src/libs/base/log.c | 4 +++- src/libs/base/nolog.c | 1 + src/libs/core/errors.c | 2 +- src/libs/core/keyset.c | 1 + src/libs/ease/array.c | 2 +- src/libs/highlevel/elektra.c | 4 ++-- src/libs/highlevel/elektra_array_value.c | 2 +- src/libs/highlevel/elektra_error.c | 2 +- src/libs/io/adapter/dbus/dbus.c | 1 + src/libs/kdb/hooks.c | 1 + src/libs/kdb/kdb.c | 1 + src/libs/opts/opts.c | 5 +++-- src/libs/pluginload/static.c | 1 - src/libs/type/conversion.c | 3 ++- src/plugins/augeas/augeas.c | 2 +- src/plugins/backend/backend.c | 1 + src/plugins/blacklist/blacklist.c | 5 +++-- src/plugins/blockresolver/blockresolver.c | 1 + src/plugins/c/c.c | 3 ++- src/plugins/cache/cache.c | 1 + src/plugins/conditionals/conditionals.c | 8 +++----- src/plugins/cpptemplate/cpptemplate.cpp | 3 +++ src/plugins/crypto/crypto.c | 1 + src/plugins/date/date.c | 1 + src/plugins/dbus/dbus.c | 2 ++ src/plugins/dbus/example_dbus.c | 1 + src/plugins/dbusrecv/dbusrecv.c | 1 + src/plugins/dbusrecv/testmod_dbusrecv.c | 1 + src/plugins/directoryvalue/directoryvalue_delegate.cpp | 1 + src/plugins/doc/doc.c | 2 ++ src/plugins/dpkg/dpkg.c | 1 + src/plugins/email/email.c | 1 + src/plugins/error/error.c | 2 ++ src/plugins/file/file.c | 1 + src/plugins/filecheck/filecheck.c | 1 + src/plugins/fstab/fstab.c | 1 + src/plugins/glob/glob.c | 2 ++ src/plugins/gopts/gopts_osx.h | 2 ++ src/plugins/gopts/gopts_procfs.h | 2 ++ src/plugins/gopts/gopts_sysctl.h | 2 ++ src/plugins/gopts/testmod_gopts.c | 2 +- src/plugins/gpgme/gpgme.c | 1 + src/plugins/hexcode/hexcode.c | 2 ++ src/plugins/hexnumber/hexnumber.c | 1 + src/plugins/hosts/hosts-get.c | 2 ++ src/plugins/hosts/hosts-set.c | 2 ++ src/plugins/hosts/keymetaformatting.c | 2 +- src/plugins/internalnotification/internalnotification.c | 2 ++ .../internalnotification/testmod_internalnotification.c | 2 +- src/plugins/ipaddr/ipaddr.c | 1 + src/plugins/iterate/iterate.c | 2 ++ src/plugins/kconfig/kconfig.cpp | 3 +++ src/plugins/keytometa/keytometa.c | 2 ++ src/plugins/length/length.c | 1 + src/plugins/line/line.c | 1 + src/plugins/macaddr/macaddr.c | 1 + src/plugins/mathcheck/mathcheck.c | 1 + src/plugins/missing/missing.c | 4 ++++ src/plugins/modules/modules.c | 1 + src/plugins/modules/testmod_modules.c | 1 + src/plugins/mozprefs/mozprefs.c | 1 + src/plugins/network/network.c | 2 ++ src/plugins/ni/ni.c | 1 + src/plugins/noresolver/noresolver.c | 1 + src/plugins/passwd/passwd.c | 1 + src/plugins/path/path.c | 1 + src/plugins/process/process.c | 4 ++-- src/plugins/profile/profile.c | 1 + src/plugins/range/range.c | 1 + src/plugins/reference/referencegraph.c | 2 +- src/plugins/resolver/filename.c | 3 ++- src/plugins/rgbcolor/rgbcolor.c | 1 + src/plugins/shell/shell.c | 1 + src/plugins/simpleini/simpleini.c | 3 ++- src/plugins/spec/arrayspec.c | 2 +- src/plugins/spec/spec.c | 4 +++- src/plugins/spec/testmod_spec.c | 2 +- src/plugins/specload/specload.c | 3 ++- src/plugins/sync/sync.c | 1 + src/plugins/template/template.c | 2 ++ src/plugins/timeofday/timeofday.c | 1 + src/plugins/toml/driver.c | 2 +- src/plugins/toml/type.c | 2 ++ src/plugins/type/testmod_type.c | 1 + src/plugins/type/type.c | 4 +++- src/plugins/type/types.c | 6 +++--- src/plugins/unit/unit.c | 1 + src/plugins/validation/validation.c | 1 + src/plugins/version/version.c | 1 + src/plugins/xerces/serializer.cpp | 1 + src/plugins/xerces/xerces.cpp | 1 + src/plugins/xfconf/xfconf.c | 3 ++- src/plugins/yajl/yajl_gen.c | 2 ++ src/plugins/zeromqrecv/testmod_zeromqrecv.c | 1 + src/plugins/zeromqrecv/zeromqrecv.c | 1 + src/plugins/zeromqsend/testmod_zeromqsend.c | 2 +- src/plugins/zeromqsend/zeromqsend.c | 1 + src/tools/kdb/gen/templates/highlevel.c.mustache | 7 +++---- src/tools/kdb/gen/templates/highlevel.h.mustache | 5 ++--- tests/abi/testabi_ks.c | 1 + tests/cframework/tests.c | 1 + tests/cframework/tests.h | 3 +++ tests/ctest/test_key.c | 2 +- tests/ctest/test_keyCopy_memerror.c | 2 ++ tests/ctest/test_opmphm.c | 1 + tests/kdb/testkdb_highlevel.cpp | 2 +- tests/shell/gen/highlevel/commands.expected.c | 7 +++---- tests/shell/gen/highlevel/commands.expected.h | 5 ++--- tests/shell/gen/highlevel/empty.expected.c | 7 +++---- tests/shell/gen/highlevel/empty.expected.h | 2 ++ tests/shell/gen/highlevel/enum.expected.c | 7 +++---- tests/shell/gen/highlevel/enum.expected.h | 2 ++ tests/shell/gen/highlevel/externalspec.expected.c | 7 +++---- tests/shell/gen/highlevel/externalspec.expected.h | 5 ++--- tests/shell/gen/highlevel/externalwithdefaults.expected.c | 7 +++---- tests/shell/gen/highlevel/externalwithdefaults.expected.h | 5 ++--- tests/shell/gen/highlevel/nosetter.expected.c | 7 +++---- tests/shell/gen/highlevel/nosetter.expected.h | 5 ++--- tests/shell/gen/highlevel/notype.expected.c | 7 +++---- tests/shell/gen/highlevel/notype.expected.h | 2 ++ tests/shell/gen/highlevel/simple.expected.c | 7 +++---- tests/shell/gen/highlevel/simple.expected.h | 5 ++--- tests/shell/gen/highlevel/struct.expected.c | 7 +++---- tests/shell/gen/highlevel/struct.expected.h | 5 ++--- 145 files changed, 233 insertions(+), 107 deletions(-) diff --git a/benchmarks/benchmarks.c b/benchmarks/benchmarks.c index 6b90cc82d41..8dfb7addb37 100644 --- a/benchmarks/benchmarks.c +++ b/benchmarks/benchmarks.c @@ -13,6 +13,7 @@ #endif #include +#include #include struct timeval start; diff --git a/benchmarks/changetracking.c b/benchmarks/changetracking.c index 36b9fbb944d..59a67dda04d 100644 --- a/benchmarks/changetracking.c +++ b/benchmarks/changetracking.c @@ -1,7 +1,10 @@ #include "./benchmarks.h" +#include + #include #include +#include size_t keys = 5000; char * keyNameFormat = "user:/test/sw/org/myapp/#0/current/section/subsection/key%zu"; diff --git a/benchmarks/opmphm.c b/benchmarks/opmphm.c index df1dd0663c5..39ad2d6b91f 100644 --- a/benchmarks/opmphm.c +++ b/benchmarks/opmphm.c @@ -36,6 +36,7 @@ #include #include +#include int32_t elektraRandBenchmarkInitSeed; diff --git a/benchmarks/plugingetset.c b/benchmarks/plugingetset.c index 7df47873f50..e2a2996d02e 100644 --- a/benchmarks/plugingetset.c +++ b/benchmarks/plugingetset.c @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include #include -#include int main (int argc, char ** argv) { diff --git a/examples/notificationAsync.c b/examples/notificationAsync.c index 84aa8ec114a..45d2174610d 100644 --- a/examples/notificationAsync.c +++ b/examples/notificationAsync.c @@ -23,6 +23,7 @@ #include // I/O binding constructor for uv (elektraIoUvNew) #include #include // notification functions +#include #include #include #include // uv functions diff --git a/examples/notificationReload.c b/examples/notificationReload.c index 25ed7b850bf..91a61cccd76 100644 --- a/examples/notificationReload.c +++ b/examples/notificationReload.c @@ -26,6 +26,7 @@ #include // notification functions #include // g_unix_signal_add() #include // glib functions +#include #include #include // signal() diff --git a/src/bindings/cpp/tests/testcpp_contextual_policy.cpp b/src/bindings/cpp/tests/testcpp_contextual_policy.cpp index ceb88407b54..61fe8686b0d 100644 --- a/src/bindings/cpp/tests/testcpp_contextual_policy.cpp +++ b/src/bindings/cpp/tests/testcpp_contextual_policy.cpp @@ -8,6 +8,8 @@ #include +#include + #include diff --git a/src/bindings/intercept/env/src/getenv.cpp b/src/bindings/intercept/env/src/getenv.cpp index 746d66b78d6..70232c247ea 100644 --- a/src/bindings/intercept/env/src/getenv.cpp +++ b/src/bindings/intercept/env/src/getenv.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/src/bindings/io/ev/example/exampleio_ev.c b/src/bindings/io/ev/example/exampleio_ev.c index 810348042f7..98e953a670f 100644 --- a/src/bindings/io/ev/example/exampleio_ev.c +++ b/src/bindings/io/ev/example/exampleio_ev.c @@ -26,6 +26,7 @@ #include // I/O binding functions (elektraIo*) #include // I/O binding constructor for ev (elektraIoEvNew) #include // ev functions +#include #include #include // assertions (ELEKTRA_NOT_NULL) diff --git a/src/bindings/io/ev/io_ev.c b/src/bindings/io/ev/io_ev.c index 3d7be76622c..f8cb15456fd 100644 --- a/src/bindings/io/ev/io_ev.c +++ b/src/bindings/io/ev/io_ev.c @@ -11,9 +11,12 @@ #include #include + +#include #include #include #include + typedef struct ev_loop ev_loop_t; /** diff --git a/src/bindings/io/glib/example/exampleio_glib.c b/src/bindings/io/glib/example/exampleio_glib.c index 254ce4b8484..cf67e8006cc 100644 --- a/src/bindings/io/glib/example/exampleio_glib.c +++ b/src/bindings/io/glib/example/exampleio_glib.c @@ -26,6 +26,7 @@ #include // I/O binding functions (elektraIo*) #include // I/O binding constructor for glib (elektraIoGlibNew) #include // glib functions +#include #include #include // assertions (ELEKTRA_NOT_NULL) diff --git a/src/bindings/io/glib/io_glib.c b/src/bindings/io/glib/io_glib.c index cca0643fa87..b5458233e7b 100644 --- a/src/bindings/io/glib/io_glib.c +++ b/src/bindings/io/glib/io_glib.c @@ -11,9 +11,12 @@ #include #include + +#include #include #include #include + typedef struct _GlibBindingData GlibBindingData; /** diff --git a/src/bindings/io/test/test_idle.c b/src/bindings/io/test/test_idle.c index ee6ba7da34b..2bc0aae5526 100644 --- a/src/bindings/io/test/test_idle.c +++ b/src/bindings/io/test/test_idle.c @@ -11,6 +11,7 @@ #include #include +#include #include #include diff --git a/src/bindings/io/test/test_mix.c b/src/bindings/io/test/test_mix.c index 8b50233894c..39f0fe5d4fa 100644 --- a/src/bindings/io/test/test_mix.c +++ b/src/bindings/io/test/test_mix.c @@ -18,6 +18,7 @@ #include "./test.h" #include #include +#include #include #define MIX_TIMER_INTERVAL 100 diff --git a/src/bindings/io/test/test_timer.c b/src/bindings/io/test/test_timer.c index 5169111e3a2..bd69632fb73 100644 --- a/src/bindings/io/test/test_timer.c +++ b/src/bindings/io/test/test_timer.c @@ -11,6 +11,7 @@ #include #include +#include #include #include diff --git a/src/bindings/io/uv/example/exampleio_uv.c b/src/bindings/io/uv/example/exampleio_uv.c index 052593f1b71..9139e9da875 100644 --- a/src/bindings/io/uv/example/exampleio_uv.c +++ b/src/bindings/io/uv/example/exampleio_uv.c @@ -25,6 +25,7 @@ #include // I/O binding functions (elektraIo*) #include // I/O binding constructor for uv (elektraIoUvNew) +#include #include #include // assertions (ELEKTRA_NOT_NULL) #include // uv functions diff --git a/src/bindings/io/uv/io_uv.c b/src/bindings/io/uv/io_uv.c index e4bce77b277..07af21d04e3 100644 --- a/src/bindings/io/uv/io_uv.c +++ b/src/bindings/io/uv/io_uv.c @@ -11,9 +11,11 @@ #include #include +#include #include #include #include + /** * Container for required additional information for * I/O binding operations & libuv Handles diff --git a/src/bindings/xfconf/elektra-xfconf-channel.c b/src/bindings/xfconf/elektra-xfconf-channel.c index da71313d1ae..7840bfbb8bf 100644 --- a/src/bindings/xfconf/elektra-xfconf-channel.c +++ b/src/bindings/xfconf/elektra-xfconf-channel.c @@ -5,9 +5,9 @@ #include #include +#include #include -#include #include #include diff --git a/src/include/internal/utility/assert.h b/src/include/internal/utility/assert.h index c94d93512e5..3546f4129c9 100644 --- a/src/include/internal/utility/assert.h +++ b/src/include/internal/utility/assert.h @@ -11,8 +11,9 @@ #include #include + #include -#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/include/internal/utility/logger.h b/src/include/internal/utility/logger.h index eaad8484836..178ffec9284 100644 --- a/src/include/internal/utility/logger.h +++ b/src/include/internal/utility/logger.h @@ -9,8 +9,9 @@ #ifndef KDBLOGGER_H #define KDBLOGGER_H +#include #include -#include + enum ElektraLogLevel { /** diff --git a/src/libs/base/internal.c b/src/libs/base/internal.c index 8e6c5662d85..41b0a6435db 100644 --- a/src/libs/base/internal.c +++ b/src/libs/base/internal.c @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/src/libs/base/log.c b/src/libs/base/log.c index 1370327cdf5..1a2768f4426 100644 --- a/src/libs/base/log.c +++ b/src/libs/base/log.c @@ -35,8 +35,10 @@ #include #endif +#include +#include #include -#include + #include #include #include diff --git a/src/libs/base/nolog.c b/src/libs/base/nolog.c index a3af5afec6c..7a30e9e4cf8 100644 --- a/src/libs/base/nolog.c +++ b/src/libs/base/nolog.c @@ -6,6 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ +#include #include #include diff --git a/src/libs/core/errors.c b/src/libs/core/errors.c index af67315f9be..ad30dc2dc09 100644 --- a/src/libs/core/errors.c +++ b/src/libs/core/errors.c @@ -7,8 +7,8 @@ */ #include +#include #include -#include #include #ifdef __cplusplus diff --git a/src/libs/core/keyset.c b/src/libs/core/keyset.c index e025d5b8e83..a2f1e1a2d67 100644 --- a/src/libs/core/keyset.c +++ b/src/libs/core/keyset.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libs/ease/array.c b/src/libs/ease/array.c index 2ccdb1b28e1..94139166fa3 100644 --- a/src/libs/ease/array.c +++ b/src/libs/ease/array.c @@ -14,9 +14,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/src/libs/highlevel/elektra.c b/src/libs/highlevel/elektra.c index 8c5264f5bd5..507bf8845d3 100644 --- a/src/libs/highlevel/elektra.c +++ b/src/libs/highlevel/elektra.c @@ -14,10 +14,10 @@ #include #include +#include +#include #include #include -#include -#include #include #include diff --git a/src/libs/highlevel/elektra_array_value.c b/src/libs/highlevel/elektra_array_value.c index 102a79e5d3f..51b47c901f2 100644 --- a/src/libs/highlevel/elektra_array_value.c +++ b/src/libs/highlevel/elektra_array_value.c @@ -13,8 +13,8 @@ #include #include +#include #include -#include #include #include diff --git a/src/libs/highlevel/elektra_error.c b/src/libs/highlevel/elektra_error.c index 855f877fcdd..d4d0c59eb3f 100644 --- a/src/libs/highlevel/elektra_error.c +++ b/src/libs/highlevel/elektra_error.c @@ -13,8 +13,8 @@ #include #include +#include #include -#include #include diff --git a/src/libs/io/adapter/dbus/dbus.c b/src/libs/io/adapter/dbus/dbus.c index 4650eb5a02d..1829c79c49f 100644 --- a/src/libs/io/adapter/dbus/dbus.c +++ b/src/libs/io/adapter/dbus/dbus.c @@ -6,6 +6,7 @@ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ #include +#include #include #include #include diff --git a/src/libs/kdb/hooks.c b/src/libs/kdb/hooks.c index 079c163e535..af61460cfc7 100644 --- a/src/libs/kdb/hooks.c +++ b/src/libs/kdb/hooks.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libs/kdb/kdb.c b/src/libs/kdb/kdb.c index 25430ab24d8..72006893343 100644 --- a/src/libs/kdb/kdb.c +++ b/src/libs/kdb/kdb.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libs/opts/opts.c b/src/libs/opts/opts.c index 0522eba4bdb..67fad0dbc15 100644 --- a/src/libs/opts/opts.c +++ b/src/libs/opts/opts.c @@ -15,13 +15,14 @@ #include #include #include +#include +#include #include -#include #include #include -#include #include +#include #ifdef _WIN32 static const char SEP_ENV_VALUE = ';'; diff --git a/src/libs/pluginload/static.c b/src/libs/pluginload/static.c index d7a8c807e92..ca0e1f24a7c 100644 --- a/src/libs/pluginload/static.c +++ b/src/libs/pluginload/static.c @@ -19,7 +19,6 @@ #include #include - int elektraModulesInit (KeySet * modules, Key * error ELEKTRA_UNUSED) { ksAppendKey (modules, keyNew ("system:/elektra/modules", KEY_END)); diff --git a/src/libs/type/conversion.c b/src/libs/type/conversion.c index 4a08b26d226..d23d6b3fd2b 100644 --- a/src/libs/type/conversion.c +++ b/src/libs/type/conversion.c @@ -8,8 +8,9 @@ #include #include +#include #include -#include +#include #include #include #include diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 4a296204580..690e4175741 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -14,12 +14,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include "./aug.h" diff --git a/src/plugins/backend/backend.c b/src/plugins/backend/backend.c index 16a0ada0ec0..5371b519c5b 100644 --- a/src/plugins/backend/backend.c +++ b/src/plugins/backend/backend.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/blacklist/blacklist.c b/src/plugins/blacklist/blacklist.c index 5bf7cf5d049..90531cf8835 100644 --- a/src/plugins/blacklist/blacklist.c +++ b/src/plugins/blacklist/blacklist.c @@ -8,10 +8,11 @@ */ #include +#include +#include +#include #include -#include #include -#include #include #include "./blacklist.h" diff --git a/src/plugins/blockresolver/blockresolver.c b/src/plugins/blockresolver/blockresolver.c index 704ab13335f..d4ccc9c1c7a 100644 --- a/src/plugins/blockresolver/blockresolver.c +++ b/src/plugins/blockresolver/blockresolver.c @@ -18,6 +18,7 @@ #include #include #include + #include #include #include diff --git a/src/plugins/c/c.c b/src/plugins/c/c.c index 8e9f70c8336..4209062ea5a 100644 --- a/src/plugins/c/c.c +++ b/src/plugins/c/c.c @@ -11,11 +11,12 @@ #include -#include #include #include #include #include + +#include #include static const char * const toEscape = "\"'\\?\n\r\t"; diff --git a/src/plugins/cache/cache.c b/src/plugins/cache/cache.c index 5217b100ffa..eb3aafaac45 100644 --- a/src/plugins/cache/cache.c +++ b/src/plugins/cache/cache.c @@ -16,6 +16,7 @@ #include // access() #include // nftw() #include +#include #include #include #include diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 81b942108e0..df2a88b995f 100644 --- a/src/plugins/conditionals/conditionals.c +++ b/src/plugins/conditionals/conditionals.c @@ -10,15 +10,13 @@ #include #include -#ifndef HAVE_KDBCONFIG #include -#endif +#include +#include +#include #include -#include #include -#include -#include #include #include #include diff --git a/src/plugins/cpptemplate/cpptemplate.cpp b/src/plugins/cpptemplate/cpptemplate.cpp index ff7642a288e..baed4138ffe 100644 --- a/src/plugins/cpptemplate/cpptemplate.cpp +++ b/src/plugins/cpptemplate/cpptemplate.cpp @@ -11,6 +11,9 @@ #include "./cpptemplate_delegate.hpp" #include + +#include + using ckdb::keyNew; using std::exception; diff --git a/src/plugins/crypto/crypto.c b/src/plugins/crypto/crypto.c index 74bee7b676b..3414da7e6d2 100644 --- a/src/plugins/crypto/crypto.c +++ b/src/plugins/crypto/crypto.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/date/date.c b/src/plugins/date/date.c index e549243f13b..66c2a6f42d9 100644 --- a/src/plugins/date/date.c +++ b/src/plugins/date/date.c @@ -11,6 +11,7 @@ #include "./date.h" #include #include +#include #include #include #include diff --git a/src/plugins/dbus/dbus.c b/src/plugins/dbus/dbus.c index 0d3dcbdb725..4a0cce32a07 100644 --- a/src/plugins/dbus/dbus.c +++ b/src/plugins/dbus/dbus.c @@ -13,7 +13,9 @@ #include +#include #include + int elektraDbusOpen (Plugin * handle, Key * errorKey ELEKTRA_UNUSED) { ElektraDbusPluginData * data = elektraPluginGetData (handle); diff --git a/src/plugins/dbus/example_dbus.c b/src/plugins/dbus/example_dbus.c index 742a88beeac..672626d4400 100644 --- a/src/plugins/dbus/example_dbus.c +++ b/src/plugins/dbus/example_dbus.c @@ -12,6 +12,7 @@ #include #endif +#include #include #include diff --git a/src/plugins/dbusrecv/dbusrecv.c b/src/plugins/dbusrecv/dbusrecv.c index 817c247df5a..4e048e10685 100644 --- a/src/plugins/dbusrecv/dbusrecv.c +++ b/src/plugins/dbusrecv/dbusrecv.c @@ -13,6 +13,7 @@ #include "./dbusrecv.h" +#include #include #include #include diff --git a/src/plugins/dbusrecv/testmod_dbusrecv.c b/src/plugins/dbusrecv/testmod_dbusrecv.c index 7ce7cbbbccf..0432d985b42 100644 --- a/src/plugins/dbusrecv/testmod_dbusrecv.c +++ b/src/plugins/dbusrecv/testmod_dbusrecv.c @@ -13,6 +13,7 @@ #include #include +#include #include #include diff --git a/src/plugins/directoryvalue/directoryvalue_delegate.cpp b/src/plugins/directoryvalue/directoryvalue_delegate.cpp index d30533b35db..169b5099e9b 100644 --- a/src/plugins/directoryvalue/directoryvalue_delegate.cpp +++ b/src/plugins/directoryvalue/directoryvalue_delegate.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/plugins/doc/doc.c b/src/plugins/doc/doc.c index 73dfb5b5407..1a56054851f 100644 --- a/src/plugins/doc/doc.c +++ b/src/plugins/doc/doc.c @@ -22,8 +22,10 @@ #include #include +#include #include #include + //! [global data] typedef struct { diff --git a/src/plugins/dpkg/dpkg.c b/src/plugins/dpkg/dpkg.c index 7fc77b7d702..2d1137b8656 100644 --- a/src/plugins/dpkg/dpkg.c +++ b/src/plugins/dpkg/dpkg.c @@ -10,6 +10,7 @@ #include "./dpkg.h" #include #include +#include #include #include #include diff --git a/src/plugins/email/email.c b/src/plugins/email/email.c index 13f6364ae00..f21f29c4e39 100644 --- a/src/plugins/email/email.c +++ b/src/plugins/email/email.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/src/plugins/error/error.c b/src/plugins/error/error.c index 94e8e204c22..af0a6076dd6 100644 --- a/src/plugins/error/error.c +++ b/src/plugins/error/error.c @@ -12,6 +12,8 @@ #include #endif +#include + #include // #include diff --git a/src/plugins/file/file.c b/src/plugins/file/file.c index 23527c7ed09..dcd8fdb4e31 100644 --- a/src/plugins/file/file.c +++ b/src/plugins/file/file.c @@ -10,6 +10,7 @@ #include "./file.h" #include #include +#include #include #include #include diff --git a/src/plugins/filecheck/filecheck.c b/src/plugins/filecheck/filecheck.c index aad8c463546..dd605d3ccd4 100644 --- a/src/plugins/filecheck/filecheck.c +++ b/src/plugins/filecheck/filecheck.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/fstab/fstab.c b/src/plugins/fstab/fstab.c index 7b10457667b..3ca4fd35fb9 100644 --- a/src/plugins/fstab/fstab.c +++ b/src/plugins/fstab/fstab.c @@ -9,6 +9,7 @@ #include "./fstab.h" #include +#include #include #include #include diff --git a/src/plugins/glob/glob.c b/src/plugins/glob/glob.c index d757304f19f..ccc9c218287 100644 --- a/src/plugins/glob/glob.c +++ b/src/plugins/glob/glob.c @@ -14,7 +14,9 @@ #endif #include +#include #include + struct GlobFlagMap { char * name; diff --git a/src/plugins/gopts/gopts_osx.h b/src/plugins/gopts/gopts_osx.h index a7c927b3b87..de729728b95 100644 --- a/src/plugins/gopts/gopts_osx.h +++ b/src/plugins/gopts/gopts_osx.h @@ -10,6 +10,8 @@ #ifndef ELEKTRA_GOPTS_SYSCTL_H #define ELEKTRA_GOPTS_SYSCTL_H +#include + #include #include diff --git a/src/plugins/gopts/gopts_procfs.h b/src/plugins/gopts/gopts_procfs.h index b595775b579..fd5382d22f3 100644 --- a/src/plugins/gopts/gopts_procfs.h +++ b/src/plugins/gopts/gopts_procfs.h @@ -15,7 +15,9 @@ #include #include +#include #include + extern char ** environ; static int loadArgs (char *** argvp) diff --git a/src/plugins/gopts/gopts_sysctl.h b/src/plugins/gopts/gopts_sysctl.h index c63e11180d7..960f4059929 100644 --- a/src/plugins/gopts/gopts_sysctl.h +++ b/src/plugins/gopts/gopts_sysctl.h @@ -16,7 +16,9 @@ #include #include +#include #include + extern char ** environ; static int loadArgs (char *** argvp) diff --git a/src/plugins/gopts/testmod_gopts.c b/src/plugins/gopts/testmod_gopts.c index 222db0288f4..d3b84915152 100644 --- a/src/plugins/gopts/testmod_gopts.c +++ b/src/plugins/gopts/testmod_gopts.c @@ -11,8 +11,8 @@ #include #include +#include #include -#include #include diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index b06fab1b7d1..0c34fe36693 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/hexcode/hexcode.c b/src/plugins/hexcode/hexcode.c index d38aa3c0a83..c2d2b840f13 100644 --- a/src/plugins/hexcode/hexcode.c +++ b/src/plugins/hexcode/hexcode.c @@ -12,7 +12,9 @@ #include #endif +#include #include + #include #include diff --git a/src/plugins/hexnumber/hexnumber.c b/src/plugins/hexnumber/hexnumber.c index 76ee130fe98..0ba1c88380d 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/hosts/hosts-get.c b/src/plugins/hosts/hosts-get.c index 42a0f1be045..ef222f8b9d5 100644 --- a/src/plugins/hosts/hosts-get.c +++ b/src/plugins/hosts/hosts-get.c @@ -16,8 +16,10 @@ #include #include +#include #include #include + typedef void CommentConstructor (KeySet *, size_t, const char *, const char *); /* diff --git a/src/plugins/hosts/hosts-set.c b/src/plugins/hosts/hosts-set.c index b63400b92a2..2874385da5c 100644 --- a/src/plugins/hosts/hosts-set.c +++ b/src/plugins/hosts/hosts-set.c @@ -13,8 +13,10 @@ #include #include #include +#include #include #include + static int keyCmpOrderWrapper (const void * a, const void * b) { return elektraKeyCmpOrder (*((const Key **) a), *((const Key **) b)); diff --git a/src/plugins/hosts/keymetaformatting.c b/src/plugins/hosts/keymetaformatting.c index 3d081e1cd90..15adfbcebf0 100644 --- a/src/plugins/hosts/keymetaformatting.c +++ b/src/plugins/hosts/keymetaformatting.c @@ -18,11 +18,11 @@ #include #include +#include #include #include #include #include -#include #include #include diff --git a/src/plugins/internalnotification/internalnotification.c b/src/plugins/internalnotification/internalnotification.c index e9402239177..304018a5fb4 100644 --- a/src/plugins/internalnotification/internalnotification.c +++ b/src/plugins/internalnotification/internalnotification.c @@ -18,6 +18,8 @@ #include // isspace() #include // errno + +#include #include #include #include diff --git a/src/plugins/internalnotification/testmod_internalnotification.c b/src/plugins/internalnotification/testmod_internalnotification.c index 721bf9f3ceb..bafae8ff05e 100644 --- a/src/plugins/internalnotification/testmod_internalnotification.c +++ b/src/plugins/internalnotification/testmod_internalnotification.c @@ -13,13 +13,13 @@ #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/src/plugins/ipaddr/ipaddr.c b/src/plugins/ipaddr/ipaddr.c index 460c755da3c..49c61247991 100644 --- a/src/plugins/ipaddr/ipaddr.c +++ b/src/plugins/ipaddr/ipaddr.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/src/plugins/iterate/iterate.c b/src/plugins/iterate/iterate.c index 156945d6f26..56c094122c1 100644 --- a/src/plugins/iterate/iterate.c +++ b/src/plugins/iterate/iterate.c @@ -9,7 +9,9 @@ #include "./iterate.h" +#include #include + int elektraIterateOpen (Plugin * handle ELEKTRA_UNUSED, Key * errorKey ELEKTRA_UNUSED) { // plugin initialization logic diff --git a/src/plugins/kconfig/kconfig.cpp b/src/plugins/kconfig/kconfig.cpp index dbb046f37c1..813a6484eb6 100644 --- a/src/plugins/kconfig/kconfig.cpp +++ b/src/plugins/kconfig/kconfig.cpp @@ -12,6 +12,9 @@ #include "./kconfig_serializer.hpp" #include + +#include + #include using ckdb::keyNew; diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index 00a06446914..e3dd2be9cc6 100644 --- a/src/plugins/keytometa/keytometa.c +++ b/src/plugins/keytometa/keytometa.c @@ -13,8 +13,10 @@ #include #include +#include #include #include + #include #include diff --git a/src/plugins/length/length.c b/src/plugins/length/length.c index 190471a2560..c10db9aa704 100644 --- a/src/plugins/length/length.c +++ b/src/plugins/length/length.c @@ -10,6 +10,7 @@ #include "./length.h" #include #include +#include #include #include diff --git a/src/plugins/line/line.c b/src/plugins/line/line.c index 51b5fe55b7c..9ac5a09e215 100644 --- a/src/plugins/line/line.c +++ b/src/plugins/line/line.c @@ -13,6 +13,7 @@ #include "./line.h" #include +#include #include #include diff --git a/src/plugins/macaddr/macaddr.c b/src/plugins/macaddr/macaddr.c index fbe728188ca..543081108ad 100644 --- a/src/plugins/macaddr/macaddr.c +++ b/src/plugins/macaddr/macaddr.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/mathcheck/mathcheck.c b/src/plugins/mathcheck/mathcheck.c index c08e10df22a..a4d5c1e88fc 100644 --- a/src/plugins/mathcheck/mathcheck.c +++ b/src/plugins/mathcheck/mathcheck.c @@ -16,6 +16,7 @@ #include "./mathcheck.h" #include #include +#include #include #include #include diff --git a/src/plugins/missing/missing.c b/src/plugins/missing/missing.c index 6d4277f1651..6992e702670 100644 --- a/src/plugins/missing/missing.c +++ b/src/plugins/missing/missing.c @@ -8,10 +8,14 @@ */ #include "./missing.h" + #include #include #include + +#include #include + int elektraMissingGet (Plugin * plugin ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UNUSED, Key * parentKey) { if (!elektraStrCmp (keyName (parentKey), "system:/elektra/modules/missing")) diff --git a/src/plugins/modules/modules.c b/src/plugins/modules/modules.c index e14be2ef378..eebfcc360df 100644 --- a/src/plugins/modules/modules.c +++ b/src/plugins/modules/modules.c @@ -11,6 +11,7 @@ #include +#include #include #include diff --git a/src/plugins/modules/testmod_modules.c b/src/plugins/modules/testmod_modules.c index 069558dde34..6be6c172cdf 100644 --- a/src/plugins/modules/testmod_modules.c +++ b/src/plugins/modules/testmod_modules.c @@ -12,6 +12,7 @@ #include +#include #include diff --git a/src/plugins/mozprefs/mozprefs.c b/src/plugins/mozprefs/mozprefs.c index b023bb67fc9..6e50bf1d219 100644 --- a/src/plugins/mozprefs/mozprefs.c +++ b/src/plugins/mozprefs/mozprefs.c @@ -9,6 +9,7 @@ #include "./mozprefs.h" +#include #include #include #include diff --git a/src/plugins/network/network.c b/src/plugins/network/network.c index 421694811f1..74804f1f561 100644 --- a/src/plugins/network/network.c +++ b/src/plugins/network/network.c @@ -9,7 +9,9 @@ #include "./network.h" #include +#include #include + /* Obtain address(es) matching host/port */ int elektraNetworkAddrInfo (Key * toCheck) { diff --git a/src/plugins/ni/ni.c b/src/plugins/ni/ni.c index 50e786a09c7..68e0298078d 100644 --- a/src/plugins/ni/ni.c +++ b/src/plugins/ni/ni.c @@ -9,6 +9,7 @@ #include "./ni.h" #include +#include #include #include diff --git a/src/plugins/noresolver/noresolver.c b/src/plugins/noresolver/noresolver.c index 5075460ab04..68117229aa1 100644 --- a/src/plugins/noresolver/noresolver.c +++ b/src/plugins/noresolver/noresolver.c @@ -11,6 +11,7 @@ #endif #include "./noresolver.h" +#include #include #include diff --git a/src/plugins/passwd/passwd.c b/src/plugins/passwd/passwd.c index 787eefe7e55..04e7b99bf15 100644 --- a/src/plugins/passwd/passwd.c +++ b/src/plugins/passwd/passwd.c @@ -10,6 +10,7 @@ #include "./passwd.h" #include +#include #include #include #include diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index af70208e6db..f2039422ea7 100644 --- a/src/plugins/path/path.c +++ b/src/plugins/path/path.c @@ -9,6 +9,7 @@ #include "./path.h" #include +#include #include #include diff --git a/src/plugins/process/process.c b/src/plugins/process/process.c index 1468516c788..b233e80916d 100644 --- a/src/plugins/process/process.c +++ b/src/plugins/process/process.c @@ -12,11 +12,11 @@ #include #include +#include +#include #include #include -#include #include -#include #include #include diff --git a/src/plugins/profile/profile.c b/src/plugins/profile/profile.c index 1dfdbe97f60..cd7cf3b2f9a 100644 --- a/src/plugins/profile/profile.c +++ b/src/plugins/profile/profile.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/range/range.c b/src/plugins/range/range.c index 1a931b85095..fd1e861ffd8 100644 --- a/src/plugins/range/range.c +++ b/src/plugins/range/range.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/reference/referencegraph.c b/src/plugins/reference/referencegraph.c index 09e87479b02..855e108128e 100644 --- a/src/plugins/reference/referencegraph.c +++ b/src/plugins/reference/referencegraph.c @@ -2,8 +2,8 @@ #include #include #include +#include #include -#include #include struct _RefGraph diff --git a/src/plugins/resolver/filename.c b/src/plugins/resolver/filename.c index 2e693ba3a1b..df97ad5bace 100644 --- a/src/plugins/resolver/filename.c +++ b/src/plugins/resolver/filename.c @@ -10,9 +10,10 @@ #include +#include #include +#include #include -#include #include #include diff --git a/src/plugins/rgbcolor/rgbcolor.c b/src/plugins/rgbcolor/rgbcolor.c index ec7a81bc17f..ab35b2af189 100644 --- a/src/plugins/rgbcolor/rgbcolor.c +++ b/src/plugins/rgbcolor/rgbcolor.c @@ -10,6 +10,7 @@ #include "./rgbcolor.h" #include #include +#include #include #include #include diff --git a/src/plugins/shell/shell.c b/src/plugins/shell/shell.c index f110f90d6aa..8752134c474 100644 --- a/src/plugins/shell/shell.c +++ b/src/plugins/shell/shell.c @@ -10,6 +10,7 @@ #include "./shell.h" #include #include +#include #include #include #include diff --git a/src/plugins/simpleini/simpleini.c b/src/plugins/simpleini/simpleini.c index 06f15cc4bde..f30fbb1f69b 100644 --- a/src/plugins/simpleini/simpleini.c +++ b/src/plugins/simpleini/simpleini.c @@ -8,11 +8,12 @@ #define _GNU_SOURCE #include "./simpleini.h" +#include #include #include +#include #include #include -#include #include #include diff --git a/src/plugins/spec/arrayspec.c b/src/plugins/spec/arrayspec.c index 0ba2f14990b..1f520800fe3 100644 --- a/src/plugins/spec/arrayspec.c +++ b/src/plugins/spec/arrayspec.c @@ -2,11 +2,11 @@ #include "./matching.h" #include +#include #include #include #include -#include #include #include #include diff --git a/src/plugins/spec/spec.c b/src/plugins/spec/spec.c index 7837e0b9275..d8b2ec13c5a 100644 --- a/src/plugins/spec/spec.c +++ b/src/plugins/spec/spec.c @@ -3,11 +3,13 @@ #include "./matching.h" #include +#include +#include #include #include -#include #include + #include #include diff --git a/src/plugins/spec/testmod_spec.c b/src/plugins/spec/testmod_spec.c index a479985b6e6..a9c147ffeb2 100644 --- a/src/plugins/spec/testmod_spec.c +++ b/src/plugins/spec/testmod_spec.c @@ -9,9 +9,9 @@ #include "./spec.h" #include +#include #include -#include #include diff --git a/src/plugins/specload/specload.c b/src/plugins/specload/specload.c index 01cbfa59f97..da66b38f148 100644 --- a/src/plugins/specload/specload.c +++ b/src/plugins/specload/specload.c @@ -12,10 +12,11 @@ #include #include #include +#include +#include #include #include #include -#include #include #include #include diff --git a/src/plugins/sync/sync.c b/src/plugins/sync/sync.c index 13e7e12adf0..9583b7a1f5d 100644 --- a/src/plugins/sync/sync.c +++ b/src/plugins/sync/sync.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/template/template.c b/src/plugins/template/template.c index c61b890b489..a51dd3c0d24 100644 --- a/src/plugins/template/template.c +++ b/src/plugins/template/template.c @@ -9,7 +9,9 @@ #include "./template.h" +#include #include + int elektraTemplateOpen (Plugin * handle ELEKTRA_UNUSED, Key * errorKey ELEKTRA_UNUSED) { // plugin initialization logic diff --git a/src/plugins/timeofday/timeofday.c b/src/plugins/timeofday/timeofday.c index 34141d8288f..9a511bdc841 100644 --- a/src/plugins/timeofday/timeofday.c +++ b/src/plugins/timeofday/timeofday.c @@ -7,6 +7,7 @@ */ #include "./timeofday.h" +#include #include #include diff --git a/src/plugins/toml/driver.c b/src/plugins/toml/driver.c index 2ab031abd7d..c52318db96a 100644 --- a/src/plugins/toml/driver.c +++ b/src/plugins/toml/driver.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include "./driver.h" diff --git a/src/plugins/toml/type.c b/src/plugins/toml/type.c index c1d78479df8..c895fad565f 100644 --- a/src/plugins/toml/type.c +++ b/src/plugins/toml/type.c @@ -10,8 +10,10 @@ #include "./type.h" +#include #include #include + #include #include #include diff --git a/src/plugins/type/testmod_type.c b/src/plugins/type/testmod_type.c index ab6e852019a..2d9c1924970 100644 --- a/src/plugins/type/testmod_type.c +++ b/src/plugins/type/testmod_type.c @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/src/plugins/type/type.c b/src/plugins/type/type.c index a071fdda9cf..08320fc1b55 100644 --- a/src/plugins/type/type.c +++ b/src/plugins/type/type.c @@ -15,10 +15,12 @@ #include #include #include +#include +#include #include -#include #include + struct _Type { const char * name; diff --git a/src/plugins/type/types.c b/src/plugins/type/types.c index 3176c81df9e..09ec8f4b0d2 100644 --- a/src/plugins/type/types.c +++ b/src/plugins/type/types.c @@ -17,11 +17,11 @@ #include #include - +#include +#include #include #include -#include -#include + #define CHECK_TYPE(key, var, toValue) \ { \ if (strlen (keyString (key)) == 0 || toValue (key, &var) != 1) \ diff --git a/src/plugins/unit/unit.c b/src/plugins/unit/unit.c index ce15cca059b..94095a49f55 100644 --- a/src/plugins/unit/unit.c +++ b/src/plugins/unit/unit.c @@ -10,6 +10,7 @@ #include "./unit.h" #include #include +#include #include #include #include diff --git a/src/plugins/validation/validation.c b/src/plugins/validation/validation.c index 96374a7be6c..3a3df99c48e 100644 --- a/src/plugins/validation/validation.c +++ b/src/plugins/validation/validation.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/version/version.c b/src/plugins/version/version.c index 5998a565462..60e8d583f5a 100644 --- a/src/plugins/version/version.c +++ b/src/plugins/version/version.c @@ -10,6 +10,7 @@ #include "./version.h" #include +#include #include int ELEKTRA_PLUGIN_FUNCTION (init) (Plugin * handle ELEKTRA_UNUSED, KeySet * definition ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSED) diff --git a/src/plugins/xerces/serializer.cpp b/src/plugins/xerces/serializer.cpp index 3e014aa6654..3db5a6a9fae 100644 --- a/src/plugins/xerces/serializer.cpp +++ b/src/plugins/xerces/serializer.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/src/plugins/xerces/xerces.cpp b/src/plugins/xerces/xerces.cpp index 40fee723cc6..1d712ba6a25 100644 --- a/src/plugins/xerces/xerces.cpp +++ b/src/plugins/xerces/xerces.cpp @@ -19,6 +19,7 @@ #include #include #include + using namespace ckdb; using namespace xerces; diff --git a/src/plugins/xfconf/xfconf.c b/src/plugins/xfconf/xfconf.c index 26d7f91736d..7293c3b8286 100644 --- a/src/plugins/xfconf/xfconf.c +++ b/src/plugins/xfconf/xfconf.c @@ -14,8 +14,9 @@ #include #include #include +#include +#include #include -#include #include #include #include diff --git a/src/plugins/yajl/yajl_gen.c b/src/plugins/yajl/yajl_gen.c index 66e36e2fd2b..35a97f8e8b4 100644 --- a/src/plugins/yajl/yajl_gen.c +++ b/src/plugins/yajl/yajl_gen.c @@ -10,8 +10,10 @@ #include #include +#include #include #include + /** * @brief Return the first character of next name level * diff --git a/src/plugins/zeromqrecv/testmod_zeromqrecv.c b/src/plugins/zeromqrecv/testmod_zeromqrecv.c index 28b5d08a91c..59ad8cb9b46 100644 --- a/src/plugins/zeromqrecv/testmod_zeromqrecv.c +++ b/src/plugins/zeromqrecv/testmod_zeromqrecv.c @@ -20,6 +20,7 @@ #include +#include #include /** zmq context for tests */ diff --git a/src/plugins/zeromqrecv/zeromqrecv.c b/src/plugins/zeromqrecv/zeromqrecv.c index 66553550df6..ea4ca892521 100644 --- a/src/plugins/zeromqrecv/zeromqrecv.c +++ b/src/plugins/zeromqrecv/zeromqrecv.c @@ -13,6 +13,7 @@ #include "./zeromqrecv.h" +#include #include #include #include diff --git a/src/plugins/zeromqsend/testmod_zeromqsend.c b/src/plugins/zeromqsend/testmod_zeromqsend.c index 30e3606baeb..32952a3e411 100644 --- a/src/plugins/zeromqsend/testmod_zeromqsend.c +++ b/src/plugins/zeromqsend/testmod_zeromqsend.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include diff --git a/src/plugins/zeromqsend/zeromqsend.c b/src/plugins/zeromqsend/zeromqsend.c index e24bf2e658a..92ee03b51f4 100644 --- a/src/plugins/zeromqsend/zeromqsend.c +++ b/src/plugins/zeromqsend/zeromqsend.c @@ -16,6 +16,7 @@ #include "./zeromqsend.h" #include // errno +#include #include #include #include // strtol() diff --git a/src/tools/kdb/gen/templates/highlevel.c.mustache b/src/tools/kdb/gen/templates/highlevel.c.mustache index f71a60117c8..9eb8a86ccba 100644 --- a/src/tools/kdb/gen/templates/highlevel.c.mustache +++ b/src/tools/kdb/gen/templates/highlevel.c.mustache @@ -41,10 +41,9 @@ For the full text see ./highlevel/LICENSE.txt #include #include #include - -#include -#include -#include +#include +#include +#include /*%# embed_spec? %*/ static KeySet * embeddedSpec (void) diff --git a/src/tools/kdb/gen/templates/highlevel.h.mustache b/src/tools/kdb/gen/templates/highlevel.h.mustache index ea7608c3f4a..a2a9805147b 100644 --- a/src/tools/kdb/gen/templates/highlevel.h.mustache +++ b/src/tools/kdb/gen/templates/highlevel.h.mustache @@ -36,9 +36,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/abi/testabi_ks.c b/tests/abi/testabi_ks.c index 5d7c2a2f6ae..49b929ed2a1 100644 --- a/tests/abi/testabi_ks.c +++ b/tests/abi/testabi_ks.c @@ -7,6 +7,7 @@ */ #include +#include #include #define NUMBER_OF_NAMESPACES 5 diff --git a/tests/cframework/tests.c b/tests/cframework/tests.c index ab23cc6afa0..5aace53fa15 100644 --- a/tests/cframework/tests.c +++ b/tests/cframework/tests.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include diff --git a/tests/cframework/tests.h b/tests/cframework/tests.h index 7dd1d80e4ee..d913a23b2b3 100644 --- a/tests/cframework/tests.h +++ b/tests/cframework/tests.h @@ -21,6 +21,9 @@ #include #include + +#include + #define BUFFER_LENGTH 4096 #define ELEKTRA_TEST_ROOT "/tests/ckdb/" diff --git a/tests/ctest/test_key.c b/tests/ctest/test_key.c index bcbdd8599dc..91e06330ff6 100644 --- a/tests/ctest/test_key.c +++ b/tests/ctest/test_key.c @@ -8,7 +8,7 @@ #include -#include +#include #ifdef HAVE_TIME_H #include diff --git a/tests/ctest/test_keyCopy_memerror.c b/tests/ctest/test_keyCopy_memerror.c index 71207fb17e7..f97e8976b7e 100644 --- a/tests/ctest/test_keyCopy_memerror.c +++ b/tests/ctest/test_keyCopy_memerror.c @@ -18,6 +18,8 @@ #include +#include + KeySet * ksDupFailing (const KeySet * source ELEKTRA_UNUSED) { // We override ksDup here to return NULL diff --git a/tests/ctest/test_opmphm.c b/tests/ctest/test_opmphm.c index 3551c3e4c9f..1209620482e 100644 --- a/tests/ctest/test_opmphm.c +++ b/tests/ctest/test_opmphm.c @@ -9,6 +9,7 @@ #define OPMPHM_TEST #include "../../src/libs/core/opmphm.c" +#include #include // dummy for testing diff --git a/tests/kdb/testkdb_highlevel.cpp b/tests/kdb/testkdb_highlevel.cpp index 9bb9c0fb425..380d81cb427 100644 --- a/tests/kdb/testkdb_highlevel.cpp +++ b/tests/kdb/testkdb_highlevel.cpp @@ -11,7 +11,7 @@ #include -#include +#include #define EXPECT_KEYVALUE(Key, Value) EXPECT_PRED2 (keyHasValue, Key, Value) #define EXPECT_KEYMETA(Key, Meta, Value) EXPECT_PRED3 (keyHasMetaValue, Key, Meta, Value) diff --git a/tests/shell/gen/highlevel/commands.expected.c b/tests/shell/gen/highlevel/commands.expected.c index 100904de7fc..25e452d3f4f 100644 --- a/tests/shell/gen/highlevel/commands.expected.c +++ b/tests/shell/gen/highlevel/commands.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/commands.expected.h b/tests/shell/gen/highlevel/commands.expected.h index 37c7b002c5c..465971d7636 100644 --- a/tests/shell/gen/highlevel/commands.expected.h +++ b/tests/shell/gen/highlevel/commands.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/shell/gen/highlevel/empty.expected.c b/tests/shell/gen/highlevel/empty.expected.c index 98e4e28261b..0e9117f112a 100644 --- a/tests/shell/gen/highlevel/empty.expected.c +++ b/tests/shell/gen/highlevel/empty.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/empty.expected.h b/tests/shell/gen/highlevel/empty.expected.h index d7abc59859b..4b0d1b5389a 100644 --- a/tests/shell/gen/highlevel/empty.expected.h +++ b/tests/shell/gen/highlevel/empty.expected.h @@ -33,6 +33,8 @@ extern "C" { #endif #include +#include +#include #include #include diff --git a/tests/shell/gen/highlevel/enum.expected.c b/tests/shell/gen/highlevel/enum.expected.c index f72717e6760..2320b80560a 100644 --- a/tests/shell/gen/highlevel/enum.expected.c +++ b/tests/shell/gen/highlevel/enum.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/enum.expected.h b/tests/shell/gen/highlevel/enum.expected.h index d43360e9f82..1024a181c7b 100644 --- a/tests/shell/gen/highlevel/enum.expected.h +++ b/tests/shell/gen/highlevel/enum.expected.h @@ -33,6 +33,8 @@ extern "C" { #endif #include +#include +#include #include #include diff --git a/tests/shell/gen/highlevel/externalspec.expected.c b/tests/shell/gen/highlevel/externalspec.expected.c index 8fc6b64d7f2..1b104291f3f 100644 --- a/tests/shell/gen/highlevel/externalspec.expected.c +++ b/tests/shell/gen/highlevel/externalspec.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include diff --git a/tests/shell/gen/highlevel/externalspec.expected.h b/tests/shell/gen/highlevel/externalspec.expected.h index 123259c1c38..e2865ab1f3c 100644 --- a/tests/shell/gen/highlevel/externalspec.expected.h +++ b/tests/shell/gen/highlevel/externalspec.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/shell/gen/highlevel/externalwithdefaults.expected.c b/tests/shell/gen/highlevel/externalwithdefaults.expected.c index 69b5002fc29..afd877fb1f0 100644 --- a/tests/shell/gen/highlevel/externalwithdefaults.expected.c +++ b/tests/shell/gen/highlevel/externalwithdefaults.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include diff --git a/tests/shell/gen/highlevel/externalwithdefaults.expected.h b/tests/shell/gen/highlevel/externalwithdefaults.expected.h index d992941ffb9..2beb412febb 100644 --- a/tests/shell/gen/highlevel/externalwithdefaults.expected.h +++ b/tests/shell/gen/highlevel/externalwithdefaults.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/shell/gen/highlevel/nosetter.expected.c b/tests/shell/gen/highlevel/nosetter.expected.c index 8b381afda1f..27647bb29ac 100644 --- a/tests/shell/gen/highlevel/nosetter.expected.c +++ b/tests/shell/gen/highlevel/nosetter.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/nosetter.expected.h b/tests/shell/gen/highlevel/nosetter.expected.h index deca72f3cea..c08b7e2943d 100644 --- a/tests/shell/gen/highlevel/nosetter.expected.h +++ b/tests/shell/gen/highlevel/nosetter.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/shell/gen/highlevel/notype.expected.c b/tests/shell/gen/highlevel/notype.expected.c index 1e950df1ca0..324e9d407ec 100644 --- a/tests/shell/gen/highlevel/notype.expected.c +++ b/tests/shell/gen/highlevel/notype.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/notype.expected.h b/tests/shell/gen/highlevel/notype.expected.h index e104495355a..7a4eabf29e7 100644 --- a/tests/shell/gen/highlevel/notype.expected.h +++ b/tests/shell/gen/highlevel/notype.expected.h @@ -33,6 +33,8 @@ extern "C" { #endif #include +#include +#include #include #include diff --git a/tests/shell/gen/highlevel/simple.expected.c b/tests/shell/gen/highlevel/simple.expected.c index 41228ed904f..840022ae37b 100644 --- a/tests/shell/gen/highlevel/simple.expected.c +++ b/tests/shell/gen/highlevel/simple.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/simple.expected.h b/tests/shell/gen/highlevel/simple.expected.h index 2d3718e2fe2..c2c5a2765c1 100644 --- a/tests/shell/gen/highlevel/simple.expected.h +++ b/tests/shell/gen/highlevel/simple.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include diff --git a/tests/shell/gen/highlevel/struct.expected.c b/tests/shell/gen/highlevel/struct.expected.c index 26fdb7fd7a5..c37b85e479f 100644 --- a/tests/shell/gen/highlevel/struct.expected.c +++ b/tests/shell/gen/highlevel/struct.expected.c @@ -36,10 +36,9 @@ #include #include #include - -#include -#include -#include +#include +#include +#include static KeySet * embeddedSpec (void) { diff --git a/tests/shell/gen/highlevel/struct.expected.h b/tests/shell/gen/highlevel/struct.expected.h index 16bfe213f07..32b0ae2d7ec 100644 --- a/tests/shell/gen/highlevel/struct.expected.h +++ b/tests/shell/gen/highlevel/struct.expected.h @@ -33,9 +33,8 @@ extern "C" { #endif #include - -#include -#include +#include +#include #include From 679085bc80f95a0b5bfd581278bc81591ee9e3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:20 +0200 Subject: [PATCH 09/41] general: fix new gcc warnings --- src/libs/opts/opts.c | 18 +++++++++++++----- src/libs/pluginprocess/pluginprocess.c | 2 +- src/plugins/dbus/testmod_dbus.c | 12 ++++++------ src/plugins/keytometa/keytometa.c | 2 +- src/plugins/rename/rename.c | 4 ++-- src/plugins/simpleini/simpleini.c | 6 +++++- src/plugins/toml/node.c | 2 +- src/plugins/xfconf/xfconf.c | 2 +- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/libs/opts/opts.c b/src/libs/opts/opts.c index 67fad0dbc15..a693c6119a9 100644 --- a/src/libs/opts/opts.c +++ b/src/libs/opts/opts.c @@ -1987,15 +1987,15 @@ char * generateUsageLine (const char * progname, Key * command, const Key * comm KeySet * args = elektraMetaArrayToKS (command, "args"); char * indexedArgs; - - if (ksGetSize (args) <= 0) + ssize_t argsSize = ksGetSize (args); + if (argsSize <= 0) { indexedArgs = elektraStrDup (""); } else { size_t argsTotalSize = 0; - for (elektraCursor i = 1; i < ksGetSize (args); ++i) // start at one to skip size + for (elektraCursor i = 1; i < argsSize; ++i) // start at one to skip size { argsTotalSize += strlen (keyString (ksAtCursor (args, i))) + 3; // + 3 for space and [] } @@ -2003,14 +2003,22 @@ char * generateUsageLine (const char * progname, Key * command, const Key * comm indexedArgs = elektraMalloc (argsTotalSize + 1); char * pos = indexedArgs; size_t size = argsTotalSize + 1; - for (elektraCursor i = 1; i < ksGetSize (args); i++) // start at one to skip size + for (elektraCursor i = 1; i < argsSize; i++) // start at one to skip size { *pos++ = '<'; pos = memccpy (pos, keyString (ksAtCursor (args, i)), '\0', size); *(pos - 1) = '>'; *pos++ = ' '; } - *(pos - 1) = '\0'; + + if (argsSize > 1) + { + *(pos - 1) = '\0'; + } + else + { + *pos = '\0'; + } } bool hasSubCommands = keyGetMeta (command, "hassubcommands") != NULL; diff --git a/src/libs/pluginprocess/pluginprocess.c b/src/libs/pluginprocess/pluginprocess.c index d4f24f15db0..0b94bcb46e2 100644 --- a/src/libs/pluginprocess/pluginprocess.c +++ b/src/libs/pluginprocess/pluginprocess.c @@ -404,7 +404,7 @@ static char * concat (const char * str1, const char * str2) const int str2Len = strlen (str2); char * concat = elektraMalloc (str1Len + str2Len + 1); strcpy (concat, str1); - strncpy (concat + str1Len, str2, str2Len + 1); + strcpy (concat + str1Len, str2); return concat; } diff --git a/src/plugins/dbus/testmod_dbus.c b/src/plugins/dbus/testmod_dbus.c index 38a5fa9fc1d..485e81c429a 100644 --- a/src/plugins/dbus/testmod_dbus.c +++ b/src/plugins/dbus/testmod_dbus.c @@ -225,8 +225,8 @@ static void test_keyAdded (void) succeed_if_same_string (keyName (toAdd), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); ksDel (ks); keyDel (parentKey); @@ -273,8 +273,8 @@ static void test_keyChanged (void) succeed_if_same_string (keyName (toChange), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); ksDel (ks); keyDel (parentKey); @@ -318,8 +318,8 @@ static void test_keyDeleted (void) succeed_if_same_string (keyName (toDelete), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); keyDel (toDelete); ksDel (ks); @@ -374,8 +374,8 @@ static void test_announceOnce (void) succeed_if_same_string (keyName (parentKey), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); ksDel (ks); keyDel (parentKey); @@ -420,8 +420,8 @@ static void test_cascadedChangeNotification (void) succeed_if_same_string (keyName (toAdd), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); ksDel (ks); keyDel (parentKey); @@ -466,8 +466,8 @@ static void test_cascadedAnnounceOnce (void) succeed_if_same_string (keyName (completeParentKey), context->receivedKeyName); - elektraFree (context); elektraDbusTeardownReceiveMessage (connection, receiveMessageHandler, (void *) context); + elektraFree (context); dbus_connection_unref (connection); ksDel (ks); keyDel (parentKey); diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index e3dd2be9cc6..0705ab79cd0 100644 --- a/src/plugins/keytometa/keytometa.c +++ b/src/plugins/keytometa/keytometa.c @@ -99,7 +99,7 @@ int elektraKeyAppendMetaLine (Key * target, const char * metaName, const char * keyGetString (existingMeta, buffer, keyGetValueSize (existingMeta)); strcat (buffer, "\n"); - strncat (buffer, line, elektraStrLen (line)); + strcat (buffer, line); keySetMeta (target, metaName, buffer); elektraFree (buffer); diff --git a/src/plugins/rename/rename.c b/src/plugins/rename/rename.c index e5b2b104390..62cdff17296 100644 --- a/src/plugins/rename/rename.c +++ b/src/plugins/rename/rename.c @@ -101,14 +101,14 @@ Key * elektraKeyCreateNewName (const Key * key, const Key * parentKey, const cha strncpy (newName, afterParentString, (ptr - afterParentString)); if (replaceWith) { - strncpy (newName + strlen (newName), replaceWith, elektraStrLen (replaceWith)); + strcat (newName, replaceWith); } strncat (newName, ptr + (strlen (cutPath)), strlen (afterParentString) - strlen (cutPath)); replace = 1; } else { - strncpy (newName, afterParentString, elektraStrLen (afterParentString)); + strcpy (newName, afterParentString); } int toLower = toLowerPath ? atoi (toLowerPath) : 0; int toUpper = toUpperPath ? atoi (toUpperPath) : 0; diff --git a/src/plugins/simpleini/simpleini.c b/src/plugins/simpleini/simpleini.c index f30fbb1f69b..ee643f17b35 100644 --- a/src/plugins/simpleini/simpleini.c +++ b/src/plugins/simpleini/simpleini.c @@ -112,7 +112,11 @@ static struct lineFormat getFormat (Plugin * handle) ret.format[j] = c; } } - --j; // discard null byte that is already there + if (userFormatSize > 0) + { + // discard null byte that is already there + --j; + } ELEKTRA_ASSERT (ret.format[j] == '\0', "should be null byte at end of string but was %c", ret.format[j]); ret.format[j++] = '\n'; ret.format[j] = '\0'; diff --git a/src/plugins/toml/node.c b/src/plugins/toml/node.c index 55ea08c2136..e79a397b854 100644 --- a/src/plugins/toml/node.c +++ b/src/plugins/toml/node.c @@ -197,7 +197,7 @@ static Node * createNode (Key * key, Node * parent) destroyTree (node); return NULL; } - strncpy (concatName, tableAncestor->relativeName, len); + strcpy (concatName, tableAncestor->relativeName); concatName[split] = '.'; strncat (&concatName[split + 1], node->relativeName, len - split - 1); elektraFree (node->relativeName); diff --git a/src/plugins/xfconf/xfconf.c b/src/plugins/xfconf/xfconf.c index 7293c3b8286..649e13d25a2 100644 --- a/src/plugins/xfconf/xfconf.c +++ b/src/plugins/xfconf/xfconf.c @@ -209,7 +209,7 @@ int elektraXfconfSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_ } char * xfconfKeyName = elektraMalloc ((elektraStrLen (currentKeyName) + 2) * sizeof (char *)); xfconfKeyName[0] = '/'; - strncpy (&xfconfKeyName[1], currentKeyName, elektraStrLen (currentKeyName)); + strcpy (&xfconfKeyName[1], currentKeyName); ELEKTRA_LOG_DEBUG ("setting key %s to %s\n", xfconfKeyName, keyString (cur)); if (keyGetMeta (cur, "array") != NULL) { From b7e7377158b9fe6f6da1662e884ead6bfb758067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:21 +0200 Subject: [PATCH 10/41] general: fix formatting --- src/libs/kdb/kdb.c | 4 ++-- tests/shell/gen/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/kdb/kdb.c b/src/libs/kdb/kdb.c index 72006893343..4e4aa34fb25 100644 --- a/src/libs/kdb/kdb.c +++ b/src/libs/kdb/kdb.c @@ -1299,9 +1299,9 @@ static const char * phaseName (ElektraKdbPhase phase) return "RESOLVER"; case ELEKTRA_KDB_GET_PHASE_CACHECHECK: return "CACHECHECK"; - case ELEKTRA_KDB_GET_PHASE_PRE_STORAGE: // ELEKTRA_KDB_SET_PHASE_PRE_STORAGE + case ELEKTRA_KDB_GET_PHASE_PRE_STORAGE: // ELEKTRA_KDB_SET_PHASE_PRE_STORAGE return "PRE_STORAGE"; - case ELEKTRA_KDB_GET_PHASE_STORAGE: // ELEKTRA_KDB_SET_PHASE_STORAGE + case ELEKTRA_KDB_GET_PHASE_STORAGE: // ELEKTRA_KDB_SET_PHASE_STORAGE return "STORAGE"; case ELEKTRA_KDB_GET_PHASE_POST_STORAGE: // ELEKTRA_KDB_SET_PHASE_POST_STORAGE return "POST_STORAGE"; diff --git a/tests/shell/gen/CMakeLists.txt b/tests/shell/gen/CMakeLists.txt index a0fe6dd8133..7148eb2abfd 100644 --- a/tests/shell/gen/CMakeLists.txt +++ b/tests/shell/gen/CMakeLists.txt @@ -5,7 +5,8 @@ file ( *.sh) if (BUILD_SHARED) - set (ElektraCodegen_ALL_LIBRARIES "elektra-highlevel;elektra-opts;elektra-invoke;elektra-ease;elektra-kdb;elektra-core;elektra-types;elektra-utility") + set (ElektraCodegen_ALL_LIBRARIES + "elektra-highlevel;elektra-opts;elektra-invoke;elektra-ease;elektra-kdb;elektra-core;elektra-types;elektra-utility") elseif (BUILD_FULL) set (ElektraCodegen_ALL_LIBRARIES "elektra-full") elseif (BUILD_STATIC) From 58387fd5f9b6b5217952e52b7cabd23177504efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:22 +0200 Subject: [PATCH 11/41] doc: move decisions to 6_implemented --- doc/decisions/4_decided/private_api.md | 4 ++-- .../header_file_structure.md | 0 .../header_include.md | 0 .../library_directory_structure.md | 0 .../library_split.md | 0 doc/news/_preparation_next_release.md | 5 ++++- 6 files changed, 6 insertions(+), 3 deletions(-) rename doc/decisions/{5_partially_implemented => 6_implemented}/header_file_structure.md (100%) rename doc/decisions/{5_partially_implemented => 6_implemented}/header_include.md (100%) rename doc/decisions/{5_partially_implemented => 6_implemented}/library_directory_structure.md (100%) rename doc/decisions/{5_partially_implemented => 6_implemented}/library_split.md (100%) diff --git a/doc/decisions/4_decided/private_api.md b/doc/decisions/4_decided/private_api.md index 70894a82862..72bdf07a1a2 100644 --- a/doc/decisions/4_decided/private_api.md +++ b/doc/decisions/4_decided/private_api.md @@ -24,7 +24,7 @@ All other headers are anybody's guess. - Also allow other libraries (e.g. a new `libelektra-operations`) to access non-public API. Such libraries need to have a good reason (e.g. performance, impossible otherwise, etc.) why they access non-public API and they need to be kept up-to-date. If a library cannot provide a stable API on top of the unstable non-public API, it clearly needs to state which APIs are not stable. -- Put struct definitions of Key/KeySet in a separate header file, which gets included by parts that need it (see also [Header File Structure](../5_partially_implemented/header_file_structure.md)). +- Put struct definitions of Key/KeySet in a separate header file, which gets included by parts that need it (see also [Header File Structure](../6_implemented/header_file_structure.md)). ## Rationale @@ -48,6 +48,6 @@ All other headers are anybody's guess. ## Related Decisions -- [Header File Structure](../5_partially_implemented/header_file_structure.md) +- [Header File Structure](../6_implemented/header_file_structure.md) ## Notes diff --git a/doc/decisions/5_partially_implemented/header_file_structure.md b/doc/decisions/6_implemented/header_file_structure.md similarity index 100% rename from doc/decisions/5_partially_implemented/header_file_structure.md rename to doc/decisions/6_implemented/header_file_structure.md diff --git a/doc/decisions/5_partially_implemented/header_include.md b/doc/decisions/6_implemented/header_include.md similarity index 100% rename from doc/decisions/5_partially_implemented/header_include.md rename to doc/decisions/6_implemented/header_include.md diff --git a/doc/decisions/5_partially_implemented/library_directory_structure.md b/doc/decisions/6_implemented/library_directory_structure.md similarity index 100% rename from doc/decisions/5_partially_implemented/library_directory_structure.md rename to doc/decisions/6_implemented/library_directory_structure.md diff --git a/doc/decisions/5_partially_implemented/library_split.md b/doc/decisions/6_implemented/library_split.md similarity index 100% rename from doc/decisions/5_partially_implemented/library_split.md rename to doc/decisions/6_implemented/library_split.md diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 8f06bedb120..547ea4048a5 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -230,7 +230,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> - <> -- Added `scripts/dev/check-includes.sh` which checks our [new rules](/doc/decisions/5_partially_implemented/header_include.md) for `#include`s _(@kodebach)_ +- Added `scripts/dev/check-includes.sh` which checks our [new rules](/doc/decisions/6_implemented/header_include.md) for `#include`s _(@kodebach)_ - <> - <> - <> @@ -291,10 +291,13 @@ This section keeps you up-to-date with the multi-language support provided by El - Started implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ - <> - Continued implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ +- Started implementing the decisions [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). _(@kodebach)_ - <> - <> - <> - <> +- Finished implementing the decisions [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). _(@kodebach)_ +- <> - <> - <> - <> From 5dd0940ea786f2ee3c3097b0acfd0d78f1ad6723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:41:23 +0200 Subject: [PATCH 12/41] doc: add release notes highlight --- doc/news/_preparation_next_release.md | 49 +++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 547ea4048a5..078b72a33cc 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -48,7 +48,53 @@ docker run -it elektra/elektra - <> - <> -### <> +### BREAKING: New header and library structure + +We implemented the previously decided, new [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). +With this change it should be easier to find things in source code and know which headers are public (i.e., included in packages) and which are just internal to the repository. + +#### Changed headers + +For developers building applications/libraries that link against Elektra, this means a breaking change. +The biggest part is the source-breaking change of the header structure. +Please look at `src/include/elektra` to find the headers containing the symbols you need and include them in your code as e.g. + +```c +#include +``` + +Importantly, it is no longer required to set additional include paths. +Only the standard include paths (`/usr/include`, or `/usr/local/include` when you install from source) are required. + +The new `src/include/elektra` folder includes all headers that Elektra installs (*), it is copied directly to `/usr/include` on install. +The layout of `src/include/elektra` (and consequently the layout of installed headers), follows a fixed pattern: + +```c +// include all/default symbols of library libelektra-[LIB].so +// almost all libraries provide such a header +#include + +// include only foo symbols of library libelektra-[LIB].so +// not all libraries provide modularized headers like this +#include +``` + + +(*) For now, some bindings (e.g., the C++ binding) still install additional headers located in other places. + These will also be moved to `src/include/elektra` in the future. + +#### Changed libraries + +For the actual libraries `libelektra-*.so`, the biggest change was restructuring the source code for easier development. +However, there are a few breaking changes for third party code as well: + +- `libelektra-types.so` is a new library implementing the type conversion functions `elektraKeyTo*` and `elektra*ToString`, which were previously part of `libelektra-ease.so`. +- `libelektra-utility.so` is a new library implementing some low-level helper functions that don't require Elektra-specific types, which were previously part of `libelektra-core.so`. + Because of the way these libraries are built internally, both `libelektra-utility.so` and `libelektra-core.so` are dependency-free. + You can still use `libelektra-core.so` without linking against additional libraries. + This is works, because the functions exported by `libelektra-utility.so` which are required by `libelektra-core.so` are statically linked into `libelektra-core.so` and not exported there. + If you need e.g., `elektraFree` then link against `libelektra-utility.so`. + While `elektraFree` is included in `libelektra-core.so`, it is not exported anymore. ### <> @@ -291,7 +337,6 @@ This section keeps you up-to-date with the multi-language support provided by El - Started implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ - <> - Continued implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ -- Started implementing the decisions [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). _(@kodebach)_ - <> - <> - <> From 844bac7a974e5d772ad26b1f22328fee29dbeec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 19:58:58 +0200 Subject: [PATCH 13/41] doc: fix formatting --- doc/news/_preparation_next_release.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 078b72a33cc..3bf59e9b17f 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -66,7 +66,7 @@ Please look at `src/include/elektra` to find the headers containing the symbols Importantly, it is no longer required to set additional include paths. Only the standard include paths (`/usr/include`, or `/usr/local/include` when you install from source) are required. -The new `src/include/elektra` folder includes all headers that Elektra installs (*), it is copied directly to `/usr/include` on install. +The new `src/include/elektra` folder includes all headers that Elektra installs (\*), it is copied directly to `/usr/include` on install. The layout of `src/include/elektra` (and consequently the layout of installed headers), follows a fixed pattern: ```c @@ -79,9 +79,8 @@ The layout of `src/include/elektra` (and consequently the layout of installed he #include ``` - -(*) For now, some bindings (e.g., the C++ binding) still install additional headers located in other places. - These will also be moved to `src/include/elektra` in the future. +(\*) For now, some bindings (e.g., the C++ binding) still install additional headers located in other places. +These will also be moved to `src/include/elektra` in the future. #### Changed libraries From 63da4556fe8b3fcbd54ab76d21d6c26ff171f565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 20:02:40 +0200 Subject: [PATCH 14/41] doc: fix links --- doc/news/_preparation_next_release.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 3bf59e9b17f..54920c15f9e 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -333,9 +333,9 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> - <> -- Started implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ +- Started implementing the decisions [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). _(@kodebach)_ - <> -- Continued implementing the decisions [Header File Structure](/doc/decisions/5_partially_implemented/header_file_structure.md), [Including Headers](/doc/decisions/5_partially_implemented/header_include.md), [Library Directory Structure](/doc/decisions/5_partially_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/5_partially_implemented/library_split.md). _(@kodebach)_ +- Continued implementing the decisions [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). _(@kodebach)_ - <> - <> - <> From 7b2354e2845b7821f4c1c405e895e4cbf8acb90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Thu, 1 Jun 2023 12:43:13 +0200 Subject: [PATCH 15/41] include: move stuff needed for highlevel codegen to installed headers --- src/include/elektra/macros/attributes.h | 5 +++++ src/include/{internal => elektra}/utility/array.h | 0 src/include/{internal => elektra}/utility/format.h | 3 ++- src/include/internal/macros/attributes.h | 6 ------ 4 files changed, 7 insertions(+), 7 deletions(-) rename src/include/{internal => elektra}/utility/array.h (100%) rename src/include/{internal => elektra}/utility/format.h (93%) diff --git a/src/include/elektra/macros/attributes.h b/src/include/elektra/macros/attributes.h index 039448e71be..9313198fd58 100644 --- a/src/include/elektra/macros/attributes.h +++ b/src/include/elektra/macros/attributes.h @@ -35,5 +35,10 @@ #define ELEKTRA_WEAK __attribute__ ((weak)) #endif +#ifdef __GNUC__ +#define ELEKTRA_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) __attribute__ ((format (archetype, stringIndex, firstToCheck))) +#else +#define ELEKTRA_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) +#endif #endif // ELEKTRA_MACROS_ATTRIBUTES_H diff --git a/src/include/internal/utility/array.h b/src/include/elektra/utility/array.h similarity index 100% rename from src/include/internal/utility/array.h rename to src/include/elektra/utility/array.h diff --git a/src/include/internal/utility/format.h b/src/include/elektra/utility/format.h similarity index 93% rename from src/include/internal/utility/format.h rename to src/include/elektra/utility/format.h index dbc7aedaaac..c1cb7c0efa5 100644 --- a/src/include/internal/utility/format.h +++ b/src/include/elektra/utility/format.h @@ -12,7 +12,8 @@ #ifndef ELEKTRA_UTILITY_FORMAT_H #define ELEKTRA_UTILITY_FORMAT_H -#include +#include + #include #include diff --git a/src/include/internal/macros/attributes.h b/src/include/internal/macros/attributes.h index b65584b2ed0..e306eb7cb18 100644 --- a/src/include/internal/macros/attributes.h +++ b/src/include/internal/macros/attributes.h @@ -24,10 +24,4 @@ #define ELEKTRA_FALLTHROUGH #endif -#ifdef __GNUC__ -#define ELEKTRA_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) __attribute__ ((format (archetype, stringIndex, firstToCheck))) -#else -#define ELEKTRA_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) -#endif - #endif // ELEKTRA_MACROS_ATTRIBUTES_INTERNAL_H From 9d84d7c580344cbec9b4fb19919ada9ed1e1cc35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 20:57:25 +0200 Subject: [PATCH 16/41] doc: fix man page --- doc/man/man7/elektra-libs.7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/man7/elektra-libs.7 b/doc/man/man7/elektra-libs.7 index bb742cd127b..e684fed6ea1 100644 --- a/doc/man/man7/elektra-libs.7 +++ b/doc/man/man7/elektra-libs.7 @@ -1,6 +1,6 @@ .\" generated with Ronn-NG/v0.10.1 .\" http://github.com/apjanke/ronn-ng/tree/0.10.1.pre3 -.TH "ELEKTRA\-LIBS" "7" "April 2023" "" +.TH "ELEKTRA\-LIBS" "7" "June 2023" "" .SH "NAME" \fBelektra\-libs\fR \- libs overview .IP "" 4 From 3023170b101d1f11621a0bbebcc757861ef4a52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 20:57:39 +0200 Subject: [PATCH 17/41] core: fix duplicate symbol --- src/libs/core/symbols.map | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/core/symbols.map b/src/libs/core/symbols.map index 7c821f70f4a..97c22ef15d1 100644 --- a/src/libs/core/symbols.map +++ b/src/libs/core/symbols.map @@ -77,8 +77,6 @@ libelektra_1.0 { ksDecRef; ksGetRef; - elektraReadNamespace; - # FIXME: should be separate lib ELEKTRA_ERROR_CONFLICTING_STATE; ELEKTRA_ERROR_INSTALLATION; From d7859aba678f085006e0b0e4260402c43f088e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 21:06:38 +0200 Subject: [PATCH 18/41] tests: fix codegen tests --- tests/shell/gen/highlevel/empty.expected.h | 3 --- tests/shell/gen/highlevel/enum.expected.h | 3 --- tests/shell/gen/highlevel/notype.expected.h | 3 --- 3 files changed, 9 deletions(-) diff --git a/tests/shell/gen/highlevel/empty.expected.h b/tests/shell/gen/highlevel/empty.expected.h index 4b0d1b5389a..59e4c5ad695 100644 --- a/tests/shell/gen/highlevel/empty.expected.h +++ b/tests/shell/gen/highlevel/empty.expected.h @@ -36,9 +36,6 @@ extern "C" { #include #include -#include -#include - #include diff --git a/tests/shell/gen/highlevel/enum.expected.h b/tests/shell/gen/highlevel/enum.expected.h index 1024a181c7b..4fb841899f0 100644 --- a/tests/shell/gen/highlevel/enum.expected.h +++ b/tests/shell/gen/highlevel/enum.expected.h @@ -36,9 +36,6 @@ extern "C" { #include #include -#include -#include - #include #include "colors.h" diff --git a/tests/shell/gen/highlevel/notype.expected.h b/tests/shell/gen/highlevel/notype.expected.h index 7a4eabf29e7..5dddf2d64b3 100644 --- a/tests/shell/gen/highlevel/notype.expected.h +++ b/tests/shell/gen/highlevel/notype.expected.h @@ -36,9 +36,6 @@ extern "C" { #include #include -#include -#include - #include From 8c0390f6212198fa5c2fd611d5609c3b49c49e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Fri, 2 Jun 2023 21:11:52 +0200 Subject: [PATCH 19/41] doc: fix man pages --- doc/man/man7/elektra-key-names.7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/man7/elektra-key-names.7 b/doc/man/man7/elektra-key-names.7 index d2ec074478c..019bd50c2db 100644 --- a/doc/man/man7/elektra-key-names.7 +++ b/doc/man/man7/elektra-key-names.7 @@ -1,6 +1,6 @@ .\" generated with Ronn-NG/v0.10.1 .\" http://github.com/apjanke/ronn-ng/tree/0.10.1.pre3 -.TH "ELEKTRA\-KEY\-NAMES" "7" "April 2023" "" +.TH "ELEKTRA\-KEY\-NAMES" "7" "June 2023" "" .SH "NAME" \fBelektra\-key\-names\fR \- the names of keys .P From 24e9aa535821c004db57b3e33c2c0d5214e94310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= <23529132+kodebach@users.noreply.github.com> Date: Sat, 3 Jun 2023 12:12:35 +0200 Subject: [PATCH 20/41] base: Remove unnecessary svr from elektraRealloc --- src/include/internal/utility/alloc_impl.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/include/internal/utility/alloc_impl.h b/src/include/internal/utility/alloc_impl.h index 64f71169fec..2a753ef71e5 100644 --- a/src/include/internal/utility/alloc_impl.h +++ b/src/include/internal/utility/alloc_impl.h @@ -49,22 +49,16 @@ if (elektraRealloc ((void **) & buffer, new_length) < 0) { int elektraRealloc (void ** buffer, size_t size) { ELEKTRA_ASSERT (size, "Size to allocate is zero (implementation defined behavior)"); - void * ptr; - void * svr = *buffer; - ptr = realloc (*buffer, size); + void * ptr = realloc (*buffer, size); ELEKTRA_ASSERT (ptr, "Memory (re)allocation failed with size %zu", size); if (ptr == NULL) { - // TODO: is this safe? couldn't the old buffer already be destroyed? - *buffer = svr; /* restore old buffer*/ return -1; } - else - { - *buffer = ptr; - return 0; - } + + *buffer = ptr; + return 0; } /**Free memory of Elektra or its backends. From 32095797c1ecddc03be9ee27ef72583746904fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 13:19:32 +0200 Subject: [PATCH 21/41] kdb: fix rpath --- src/tools/kdb/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/kdb/CMakeLists.txt b/src/tools/kdb/CMakeLists.txt index 23c9154d95a..4f1659190a5 100644 --- a/src/tools/kdb/CMakeLists.txt +++ b/src/tools/kdb/CMakeLists.txt @@ -19,6 +19,7 @@ endif (BUILD_SHARED OR BUILD_FULL) if (BUILD_SHARED) add_executable (kdb $) add_dependencies (kdb kdb_gen_templates_generated) + set_target_properties (kdb PROPERTIES INSTALL_RPATH "${ELEKTRA_RPATH}") find_package (Threads) target_link_libraries ( From a2f7c21ee35582976091b6145d77fd5eb04b6142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 13:34:07 +0200 Subject: [PATCH 22/41] Revert "kdb: fix rpath" This reverts commit 32095797c1ecddc03be9ee27ef72583746904fb2. --- src/tools/kdb/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/kdb/CMakeLists.txt b/src/tools/kdb/CMakeLists.txt index 4f1659190a5..23c9154d95a 100644 --- a/src/tools/kdb/CMakeLists.txt +++ b/src/tools/kdb/CMakeLists.txt @@ -19,7 +19,6 @@ endif (BUILD_SHARED OR BUILD_FULL) if (BUILD_SHARED) add_executable (kdb $) add_dependencies (kdb kdb_gen_templates_generated) - set_target_properties (kdb PROPERTIES INSTALL_RPATH "${ELEKTRA_RPATH}") find_package (Threads) target_link_libraries ( From 63e13f37dab98b58c616240e38eda7abdfae06ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 13:40:53 +0200 Subject: [PATCH 23/41] ci: re-enable webui tests on Jenkins --- scripts/jenkins/Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/jenkins/Jenkinsfile b/scripts/jenkins/Jenkinsfile index f074033aac4..54efcf03134 100644 --- a/scripts/jenkins/Jenkinsfile +++ b/scripts/jenkins/Jenkinsfile @@ -786,8 +786,7 @@ def generateFullBuildStages() { ) // We need the webui_base image to build webui images later - // TODO: re-enable when go binding fixed - // tasks << dockerUtils.buildImageStage(DOCKER_IMAGES.webui_base) + tasks << dockerUtils.buildImageStage(DOCKER_IMAGES.webui_base) return tasks } @@ -1224,8 +1223,7 @@ def generateArtifactStages() { // tasks << buildOpenwrtPackage(DOCKER_IMAGES.openwrt_sdk) tasks << buildWebsite() - // TODO: re-enable when go binding fixed - //tasks << buildWebUI() + tasks << buildWebUI() return tasks } From 8fea904a98b8d5f072250d67af55ff32b2eb0858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Mon, 24 Apr 2023 23:00:57 +0200 Subject: [PATCH 24/41] general: add todos --- scripts/cmake/Modules/LibAddPlugin.cmake | 2 ++ src/bindings/cpp/include/CMakeLists.txt | 1 + src/bindings/glib/CMakeLists.txt | 1 + src/bindings/intercept/env/include/CMakeLists.txt | 1 + src/bindings/io/doc/CMakeLists.txt | 1 + src/bindings/swig/python/CMakeLists.txt | 1 + src/bindings/swig/ruby/CMakeLists.txt | 1 + src/include/CMakeLists.txt | 2 +- src/libs/tools/include/CMakeLists.txt | 4 ++++ src/plugins/python/CMakeLists.txt | 2 +- src/plugins/ruby/CMakeLists.txt | 1 + src/tools/fuse/CMakeLists.txt | 2 +- src/tools/webd/CMakeLists.txt | 3 ++- src/tools/website/CMakeLists.txt | 2 +- src/tools/webui/CMakeLists.txt | 3 ++- tests/shell/CMakeLists.txt | 2 ++ tests/shell/external/CMakeLists.txt | 7 +------ tests/shell/gen/CMakeLists.txt | 2 ++ 18 files changed, 26 insertions(+), 12 deletions(-) diff --git a/scripts/cmake/Modules/LibAddPlugin.cmake b/scripts/cmake/Modules/LibAddPlugin.cmake index fe0d6296e97..6fb620290dd 100644 --- a/scripts/cmake/Modules/LibAddPlugin.cmake +++ b/scripts/cmake/Modules/LibAddPlugin.cmake @@ -194,6 +194,7 @@ function (add_plugintest testname) endforeach (ee ${ARG_EXTRA_EXECUTABLES}) if (ARG_INSTALL_TEST_DATA) + # TODO: make more clear via repo structure that this happens install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${testname}" DESTINATION "${TARGET_TEST_DATA_FOLDER}" @@ -464,6 +465,7 @@ function (add_plugin PLUGIN_SHORT_NAME) if (ADDTESTING_PHASE) if (ARG_INSTALL_TEST_DATA AND NOT ARG_ADD_TEST) if (INSTALL_TESTING) + # TODO: make more clear via repo structure that this happens install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_SHORT_NAME}" DESTINATION "${TARGET_TEST_DATA_FOLDER}" diff --git a/src/bindings/cpp/include/CMakeLists.txt b/src/bindings/cpp/include/CMakeLists.txt index 5c0c4e2cbab..73c9b666b5d 100644 --- a/src/bindings/cpp/include/CMakeLists.txt +++ b/src/bindings/cpp/include/CMakeLists.txt @@ -1,5 +1,6 @@ file (GLOB HEADER_FILES *.hpp) +# TODO: move installed headers install ( FILES ${HEADER_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER} diff --git a/src/bindings/glib/CMakeLists.txt b/src/bindings/glib/CMakeLists.txt index 94f207b19de..d4816b27b52 100644 --- a/src/bindings/glib/CMakeLists.txt +++ b/src/bindings/glib/CMakeLists.txt @@ -43,6 +43,7 @@ target_link_libraries (${GELEKTRA_LIBRARY} PUBLIC ${GOBJECT_LDFLAGS}) install (TARGETS ${GELEKTRA_LIBRARY} LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT glib-elektra) +# TODO: move installed headers install ( FILES ${GELEKTRA_HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER} diff --git a/src/bindings/intercept/env/include/CMakeLists.txt b/src/bindings/intercept/env/include/CMakeLists.txt index ef1d0dcce51..ca7d0835409 100644 --- a/src/bindings/intercept/env/include/CMakeLists.txt +++ b/src/bindings/intercept/env/include/CMakeLists.txt @@ -1,5 +1,6 @@ file (GLOB HDR_FILES *.h) +# TODO: move installed headers install ( FILES ${HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER} diff --git a/src/bindings/io/doc/CMakeLists.txt b/src/bindings/io/doc/CMakeLists.txt index 694a99fa326..d948a08b26e 100644 --- a/src/bindings/io/doc/CMakeLists.txt +++ b/src/bindings/io/doc/CMakeLists.txt @@ -26,6 +26,7 @@ target_link_elektra (${IO_VARIANT_LIBRARY} elektra-io) install (TARGETS ${IO_VARIANT_LIBRARY} LIBRARY DESTINATION lib${LIB_SUFFIX}) +# TODO: move installed headers install (FILES ${IO_VARIANT_HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER}) # configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/${IO_VARIANT_LIBRARY}.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${IO_VARIANT_LIBRARY}.pc" @ONLY ) diff --git a/src/bindings/swig/python/CMakeLists.txt b/src/bindings/swig/python/CMakeLists.txt index aa37f42857b..d3090145c82 100644 --- a/src/bindings/swig/python/CMakeLists.txt +++ b/src/bindings/swig/python/CMakeLists.txt @@ -107,6 +107,7 @@ else () OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) + # TODO: move installed headers install ( DIRECTORY ${CMAKE_SWIG_OUTDIR} DESTINATION ${PYTHON_SITE_PACKAGES} diff --git a/src/bindings/swig/ruby/CMakeLists.txt b/src/bindings/swig/ruby/CMakeLists.txt index 2ba7c55f8a0..3b4d4d73b05 100644 --- a/src/bindings/swig/ruby/CMakeLists.txt +++ b/src/bindings/swig/ruby/CMakeLists.txt @@ -143,6 +143,7 @@ else () endif () install (TARGETS swig-ruby swig-ruby-tools LIBRARY DESTINATION ${RUBY_LIB_INSTALL_DIR} COMPONENT ruby-elektra) + # TODO: move installed headers install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/kdb.rb ${CMAKE_CURRENT_SOURCE_DIR}/kdbtools.rb DESTINATION ${RUBY_MODULE_INSTALL_DIR} diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index e49f6b1a6c6..a1c1a541f40 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -160,7 +160,6 @@ test_big_endian (ELEKTRA_BIG_ENDIAN) configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/elektra/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/elektra/config.h") configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/internal/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/internal/config.h") -# DO NOT install kdbconfig.h it may cause conflicts with applications own config.h files install ( DIRECTORY elektra DESTINATION include @@ -168,6 +167,7 @@ install ( FILES_MATCHING PATTERN "*.h") +# TODO: restrict to generated config.h TODO: make sure config.h cannot conflict with headers from other software install ( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/elektra" DESTINATION include diff --git a/src/libs/tools/include/CMakeLists.txt b/src/libs/tools/include/CMakeLists.txt index 292fb3bc91a..5674c99f1ac 100644 --- a/src/libs/tools/include/CMakeLists.txt +++ b/src/libs/tools/include/CMakeLists.txt @@ -1,5 +1,6 @@ file (GLOB HDR_FILES *.hpp) +# TODO: move installed headers install ( FILES ${HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER} @@ -7,6 +8,7 @@ install ( file (GLOB ERROR_HDR_FILES errors/*.hpp) +# TODO: move installed headers install ( FILES ${ERROR_HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER}/errors @@ -14,6 +16,7 @@ install ( file (GLOB HELPER_HDR_FILES helper/*.hpp) +# TODO: move installed headers install ( FILES ${HELPER_HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER}/helper @@ -21,6 +24,7 @@ install ( file (GLOB MERGING_HDR_FILES merging/*.hpp) +# TODO: move installed headers install ( FILES ${MERGING_HDR_FILES} DESTINATION include/${TARGET_INCLUDE_FOLDER}/merging diff --git a/src/plugins/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt index 3bf23d3e743..1417188a33e 100644 --- a/src/plugins/python/CMakeLists.txt +++ b/src/plugins/python/CMakeLists.txt @@ -64,7 +64,7 @@ if (ADDTESTING_PHASE) add_plugintest (python MEMLEAK WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bindings/swig/python/) if (INSTALL_TESTING) - + # TODO: make clear via repo structure that this happens install ( DIRECTORY ${CMAKE_SOURCE_DIR}/src/plugins/python/python/ DESTINATION "${TARGET_TEST_DATA_FOLDER}/python" diff --git a/src/plugins/ruby/CMakeLists.txt b/src/plugins/ruby/CMakeLists.txt index ccd407f2a39..4dacea15646 100644 --- a/src/plugins/ruby/CMakeLists.txt +++ b/src/plugins/ruby/CMakeLists.txt @@ -78,6 +78,7 @@ if (ADDTESTING_PHASE) ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/src/bindings/swig/ruby:${CMAKE_SOURCE_DIR}/src/bindings/swig/ruby") if (INSTALL_TESTING) + # TODO: make clear via repo structure that this happens install (DIRECTORY ruby/ruby_test_scripts DESTINATION ${TARGET_TEST_DATA_FOLDER}) endif () else () diff --git a/src/tools/fuse/CMakeLists.txt b/src/tools/fuse/CMakeLists.txt index 125385351d6..5338663a0b8 100644 --- a/src/tools/fuse/CMakeLists.txt +++ b/src/tools/fuse/CMakeLists.txt @@ -59,7 +59,7 @@ install ( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )") # Copy the just created 'fuse' directory to the global installation directory. (This indirection is performed so that CPack knows about the -# directory.) +# directory.) TODO: make clear via repo structure that this happens install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fuse DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_TOOL_DATA_FOLDER}" diff --git a/src/tools/webd/CMakeLists.txt b/src/tools/webd/CMakeLists.txt index 5699efc2e77..31f4eef0037 100644 --- a/src/tools/webd/CMakeLists.txt +++ b/src/tools/webd/CMakeLists.txt @@ -20,13 +20,14 @@ else () configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/run.sh" "${CMAKE_CURRENT_BINARY_DIR}/run-webd") configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/build.sh" "${CMAKE_CURRENT_BINARY_DIR}/build-webd") - # install files to destination + # install files to destination TODO: make clear via repo structure that this happens install ( DIRECTORY . DESTINATION ${install_directory} PATTERN "node_modules" EXCLUDE PATTERN "build" EXCLUDE) + # TODO: isn't this redundant? install (FILES README.md DESTINATION ${install_directory}) install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run-webd ${CMAKE_CURRENT_BINARY_DIR}/build-webd DESTINATION ${TARGET_TOOL_EXEC_FOLDER}) diff --git a/src/tools/website/CMakeLists.txt b/src/tools/website/CMakeLists.txt index 8396d84e2e6..baabcdfb0b0 100644 --- a/src/tools/website/CMakeLists.txt +++ b/src/tools/website/CMakeLists.txt @@ -25,7 +25,7 @@ else () configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/mount-config.sh" "${CMAKE_CURRENT_BINARY_DIR}/mount-${tool}-config") configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/README.md" "${CMAKE_CURRENT_BINARY_DIR}/README.md") - # install files to destination + # install files to destination TODO: make clear via repo structure that this happens install (DIRECTORY public resources DESTINATION ${install_directory}) install (FILES package.json README.md ${CMAKE_CURRENT_BINARY_DIR}/Gruntfile.js application-config.json DESTINATION ${install_directory}) diff --git a/src/tools/webui/CMakeLists.txt b/src/tools/webui/CMakeLists.txt index 3e4261c463d..e2c94514e09 100644 --- a/src/tools/webui/CMakeLists.txt +++ b/src/tools/webui/CMakeLists.txt @@ -10,13 +10,14 @@ else () # find installation path set (install_directory ${TARGET_TOOL_DATA_FOLDER}/webui) - # install files to destination + # install files to destination TODO: make clear via repo structure that this happens install ( DIRECTORY . DESTINATION ${install_directory} PATTERN "node_modules" EXCLUDE PATTERN "build" EXCLUDE) + # TODO: isn't this redundant? install (FILES README.md DESTINATION ${install_directory}) install (CODE "message (\"-- Installing: elektra-web > webui\")") diff --git a/tests/shell/CMakeLists.txt b/tests/shell/CMakeLists.txt index 05bac1a39d3..f4f31a99c55 100644 --- a/tests/shell/CMakeLists.txt +++ b/tests/shell/CMakeLists.txt @@ -76,6 +76,7 @@ function (add_scripttest testname) set (RACE_COMMAND "$KDB race") set (INCLUDE_COMMON "${INCLUDE_COMMON_INSTALLED_FILE}") configure_file ("${filename}" "${CMAKE_CURRENT_BINARY_DIR}/${testname}" @ONLY) + # TODO: make clear via repo structure that this happens install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/${testname}" DESTINATION ${TARGET_TOOL_EXEC_FOLDER} @@ -124,6 +125,7 @@ function (add_scripttest testname) endfunction (add_scripttest) if (INSTALL_TESTING) + # TODO: make clear via repo structure that this happens install ( DIRECTORY "shell" DESTINATION ${TARGET_TEST_DATA_FOLDER} diff --git a/tests/shell/external/CMakeLists.txt b/tests/shell/external/CMakeLists.txt index a96f017b953..78890daf942 100644 --- a/tests/shell/external/CMakeLists.txt +++ b/tests/shell/external/CMakeLists.txt @@ -20,11 +20,7 @@ function (add_externaltest testname) set (testscriptname "${CMAKE_CURRENT_BINARY_DIR}/${testname}") configure_file ("${filename}" "${testscriptname}" @ONLY) # don't actually add as test, only run via `kdb run_all` - - # FIXME: re-enable tests - - #[[ - install ( + install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/${testname}" DESTINATION ${TARGET_TOOL_EXEC_FOLDER} PERMISSIONS @@ -37,7 +33,6 @@ function (add_externaltest testname) WORLD_EXECUTE RENAME "check_external_${testname_we}" COMPONENT elektra-tests) - ]] endif (ENABLE_KDB_TESTING AND INSTALL_TESTING) endfunction (add_externaltest) diff --git a/tests/shell/gen/CMakeLists.txt b/tests/shell/gen/CMakeLists.txt index 7148eb2abfd..f337baa940f 100644 --- a/tests/shell/gen/CMakeLists.txt +++ b/tests/shell/gen/CMakeLists.txt @@ -26,10 +26,12 @@ endforeach () unset (C_FLAG_32BIT) if (INSTALL_TESTING) + # TODO: make clear via repo structure that this happens install ( DIRECTORY "." DESTINATION "${TARGET_TEST_DATA_FOLDER}/gen" COMPONENT elektra-tests) + # TODO: make clear via repo structure that this happens install ( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DESTINATION "${TARGET_TEST_DATA_FOLDER}/gen" From 70f5d308b6d56a2e02617532c856757260b13702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 13:51:08 +0200 Subject: [PATCH 25/41] cmake: fix kdb lib --- src/libs/highlevel/CMakeLists.txt | 2 +- src/libs/kdb/CMakeLists.txt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/highlevel/CMakeLists.txt b/src/libs/highlevel/CMakeLists.txt index e957734693d..45a6b7e6cee 100644 --- a/src/libs/highlevel/CMakeLists.txt +++ b/src/libs/highlevel/CMakeLists.txt @@ -15,7 +15,7 @@ if (BUILD_SHARED) set (LIBRARIES "-lelektra-types -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core") set ( CODEGEN_LIBRARIES - "-lelektra-types -lelektra-opts -lelektra-invoke -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core -lelektra-meta -lelektra-utility" + "-lelektra-types -lelektra-opts -lelektra-invoke -lelektra-highlevel -lelektra-kdb -lelektra-ease -lelektra-core -lelektra-meta -lelektra-utility" ) elseif (BUILD_FULL) set (LIBRARIES "-lelektra-full") diff --git a/src/libs/kdb/CMakeLists.txt b/src/libs/kdb/CMakeLists.txt index 97a5c3bb28b..1f5f9014db5 100644 --- a/src/libs/kdb/CMakeLists.txt +++ b/src/libs/kdb/CMakeLists.txt @@ -1,4 +1,5 @@ -set ( +add_lib ( + kdb SOURCES backends.c contracts.c @@ -6,9 +7,9 @@ set ( kdb.c plugin.c changetracking.c - diff.c) - -add_lib (kdb SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) + diff.c + COMPONENT + libelektra${SO_VERSION}) if (BUILD_SHARED) - target_link_libraries (elektra-kdb $) + target_sources (elektra-kdb PRIVATE $) endif (BUILD_SHARED) From 4ff4e9d61f42640cf8b07cd82572cac8bf2c80a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 14:03:00 +0200 Subject: [PATCH 26/41] cmake: fix core lib --- src/libs/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/core/CMakeLists.txt b/src/libs/core/CMakeLists.txt index 21078928ef3..b746b3ec7ac 100644 --- a/src/libs/core/CMakeLists.txt +++ b/src/libs/core/CMakeLists.txt @@ -20,5 +20,5 @@ endif (ENABLE_OPTIMIZATIONS) add_lib (core SOURCES ${SOURCES} COMPONENT libelektra${SO_VERSION}) if (BUILD_SHARED) - target_link_libraries (elektra-core $) + target_sources (elektra-core PRIVATE $) endif (BUILD_SHARED) From 9454c1b093691ea855d7c4f8a88eac5159a0735e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 14:09:43 +0200 Subject: [PATCH 27/41] cmake: fix dlopen etc. symbols --- src/libs/kdb/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/kdb/CMakeLists.txt b/src/libs/kdb/CMakeLists.txt index 1f5f9014db5..91b60da1a2d 100644 --- a/src/libs/kdb/CMakeLists.txt +++ b/src/libs/kdb/CMakeLists.txt @@ -13,3 +13,4 @@ add_lib ( if (BUILD_SHARED) target_sources (elektra-kdb PRIVATE $) endif (BUILD_SHARED) +target_link_libraries (elektra-kdb ${CMAKE_DL_LIBS}) From cc711040a15c7eb2800b6c767998bf1d85ff9110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sun, 4 Jun 2023 18:49:11 +0200 Subject: [PATCH 28/41] cmake: fix kdb lib built without shared --- src/libs/kdb/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/kdb/CMakeLists.txt b/src/libs/kdb/CMakeLists.txt index 91b60da1a2d..02a9142aac3 100644 --- a/src/libs/kdb/CMakeLists.txt +++ b/src/libs/kdb/CMakeLists.txt @@ -12,5 +12,5 @@ add_lib ( libelektra${SO_VERSION}) if (BUILD_SHARED) target_sources (elektra-kdb PRIVATE $) + target_link_libraries (elektra-kdb ${CMAKE_DL_LIBS}) endif (BUILD_SHARED) -target_link_libraries (elektra-kdb ${CMAKE_DL_LIBS}) From 3fbba2a555e1e2d46a5a268121a553ebbbe3e03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Mon, 5 Jun 2023 09:45:16 +0200 Subject: [PATCH 29/41] benchmark: fix uninit bug --- benchmarks/cmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/cmp.c b/benchmarks/cmp.c index e20b31c74da..ee7afa2f832 100644 --- a/benchmarks/cmp.c +++ b/benchmarks/cmp.c @@ -86,7 +86,7 @@ int main (void) long long nrIterations = 100000000; const char str1[] = "some string to be compared with/some\\/more with a long common part, and only a bit different"; char * str2 = elektraMalloc (sizeof (str1)); - strcat (str2, str1); + strcpy (str2, str1); str2[sizeof (str1) - 5] = 'X'; int res = 0; From b29778f082cd5c3beaac8b56c594deb66d6f038a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 6 Jun 2023 21:11:15 +0200 Subject: [PATCH 30/41] ci: run more tests on ubuntu kinetic to diagnose packaging issue --- scripts/jenkins/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jenkins/Jenkinsfile b/scripts/jenkins/Jenkinsfile index 54efcf03134..59e2af087a5 100644 --- a/scripts/jenkins/Jenkinsfile +++ b/scripts/jenkins/Jenkinsfile @@ -678,7 +678,7 @@ def generateFullBuildStages() { "ubuntu-kinetic", DOCKER_IMAGES.kinetic, CMAKE_FLAGS_BUILD_ALL, - [TEST.ALL] + [TEST.ALL, TEST.MEM, TEST.NOKDB, TEST.INSTALL] ) // Build Elektra on a minimal Debian buster Docker image From 73b4bf731c3a6451c85a7151ceb418e9ee0a1989 Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sat, 10 Jun 2023 23:11:47 +0200 Subject: [PATCH 31/41] doc: update release notes --- doc/news/_preparation_next_release.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 54920c15f9e..0ebbf9995f1 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -292,7 +292,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> -- <> +- Fix bug in Doxygen comment for `const char * keyName (const Key * key)` which lead to failed building of the refman.pdf on recent TeX Live releases - <> - <> - <> From a2fd51591246c18b8cd23990bbe521c10d4d9001 Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sat, 10 Jun 2023 23:30:05 +0200 Subject: [PATCH 32/41] CI: Update Dockerfile for Arch on Cirrus - The package `texlive-most` is not available anymore, I've replaced it with `texlive-core` and `texlive-bin` --- doc/news/_preparation_next_release.md | 3 ++- scripts/docker/cirrus/arch/Dockerfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 0ebbf9995f1..e55475bb3b3 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -292,7 +292,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> -- Fix bug in Doxygen comment for `const char * keyName (const Key * key)` which lead to failed building of the refman.pdf on recent TeX Live releases +- Fix bug in Doxygen comment for `const char * keyName (const Key * key)` which lead to failed building of the refman.pdf on recent TeX Live releases _(Florian Lindner @flo91)_ - <> - <> - <> @@ -495,6 +495,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> +- The arch package `texlive-most` is no longer available, replaced it with `texlive-core` and `texlive-bin`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ - <> - <> - <> diff --git a/scripts/docker/cirrus/arch/Dockerfile b/scripts/docker/cirrus/arch/Dockerfile index 4d1ad625efb..8ea19cf8ee2 100644 --- a/scripts/docker/cirrus/arch/Dockerfile +++ b/scripts/docker/cirrus/arch/Dockerfile @@ -13,7 +13,8 @@ RUN pacman -Sy --noconfirm \ qt5-base \ qt5-declarative \ rubygems \ - texlive-most \ + texlive-core \ + texlive-bin \ wget \ xfconf \ yajl \ From 22f584d8444947f6d490e2d5c155586169cb378a Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sat, 10 Jun 2023 23:57:17 +0200 Subject: [PATCH 33/41] bindings: include in key.hpp for uint8_t fix error in Cirrus CI build --- src/bindings/cpp/include/key.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings/cpp/include/key.hpp b/src/bindings/cpp/include/key.hpp index eb1f43edbc5..f6b2bcac43c 100644 --- a/src/bindings/cpp/include/key.hpp +++ b/src/bindings/cpp/include/key.hpp @@ -10,6 +10,7 @@ #define ELEKTRA_KEY_HPP #include +#include #include #if __GNUC__ >= 12 From 061dfc2fa05d88fcf671e8ddeef18880d1702738 Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sun, 11 Jun 2023 00:14:09 +0200 Subject: [PATCH 34/41] Cirrus: Add `texlive-latexextra` for varwidth.sty --- doc/news/_preparation_next_release.md | 27 ++++++++++++++++++++++++++- scripts/docker/cirrus/arch/Dockerfile | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index e55475bb3b3..2c9f950b314 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -213,6 +213,31 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> - <> +- <> + +### C++ + +- Provide getter for the underlying C object of KDB _(Maximilian Irlinger @atmaxinger)_ +- Add `ElektraDiff` binding for C++ _(Maximilian Irlinger @atmaxinger)_ +- The `dup` method of `KeySet` now returns a wrapped object _(Maximilian Irlinger @atmaxinger)_ +- Add an overload for `KeySet::cut` that accepts a string for the keyname _(Maximilian Irlinger)_ +- The `dup` method of `Key` now returns a wrapped object _(Maximilian Irlinger @atmaxinger)_ +- Add overloads for `Key::isBelow`, `Key::isBelowOrSame` and `Key::isDirectBelow` that accept a string as the key name _(Maximilian Irlinger @atmaxinger)_ +- Include the header `cstdint` in `key.hpp`. It is needed for an enum of type `std::uint8_t` _(Florian Lindner @flo91)_ + +### <> + +- <> +- <> +- <> + +### Python + +- Add `ElektraDiff` binding _(Maximilian Irlinger @atmaxinger)_ +- The `__meta__` attribute on a key now returns a proper keyset _(Maximilian Irlinger @atmaxinger)_ +- Add new module `kdb.errors` to simplify extracting errors and warnings from keys _(Maximilian Irlinger @atmaxinger)_ +- Add new module `kdb.record` for interfacing with the session recording capabilities of Elektra _(Maximilian Irlinger @atmaxinger)_ +- Add `getConflictingKeys` method to `kdb.merge.MergeResult`. _(Maximilian Irlinger @atmaxinger)_ ### <> @@ -495,7 +520,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> -- The arch package `texlive-most` is no longer available, replaced it with `texlive-core` and `texlive-bin`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ +- The arch package `texlive-most` is no longer available, replaced it with `texlive-core`, `texlive-bin` and `texlive-latexextra`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ - <> - <> - <> diff --git a/scripts/docker/cirrus/arch/Dockerfile b/scripts/docker/cirrus/arch/Dockerfile index 8ea19cf8ee2..14a67e098a5 100644 --- a/scripts/docker/cirrus/arch/Dockerfile +++ b/scripts/docker/cirrus/arch/Dockerfile @@ -15,6 +15,7 @@ RUN pacman -Sy --noconfirm \ rubygems \ texlive-core \ texlive-bin \ + texlive-latexextra \ wget \ xfconf \ yajl \ From 4e5d5c3cabf217400e50cdd32445991c38717609 Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sun, 11 Jun 2023 00:29:32 +0200 Subject: [PATCH 35/41] Cirrus: Add `texlive-fontsextra` for stix.sty --- doc/news/_preparation_next_release.md | 2 +- scripts/docker/cirrus/arch/Dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 2c9f950b314..02629a298f6 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -520,7 +520,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> -- The arch package `texlive-most` is no longer available, replaced it with `texlive-core`, `texlive-bin` and `texlive-latexextra`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ +- The arch package `texlive-most` is no longer available, replaced it with `texlive-core`, `texlive-bin`, `texlive-latexextra` abd `texlive-fontsextra`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ - <> - <> - <> diff --git a/scripts/docker/cirrus/arch/Dockerfile b/scripts/docker/cirrus/arch/Dockerfile index 14a67e098a5..a85ee814826 100644 --- a/scripts/docker/cirrus/arch/Dockerfile +++ b/scripts/docker/cirrus/arch/Dockerfile @@ -16,6 +16,7 @@ RUN pacman -Sy --noconfirm \ texlive-core \ texlive-bin \ texlive-latexextra \ + texlive-fontsextra \ wget \ xfconf \ yajl \ From b4afa92ffa1f25ef060bc0da28e76344bb189c0a Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sun, 11 Jun 2023 00:41:46 +0200 Subject: [PATCH 36/41] Cirrus: Add `texlive-science` --- doc/news/_preparation_next_release.md | 2 +- scripts/docker/cirrus/arch/Dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 02629a298f6..933eaa6b67b 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -520,7 +520,7 @@ This section keeps you up-to-date with the multi-language support provided by El - <> - <> -- The arch package `texlive-most` is no longer available, replaced it with `texlive-core`, `texlive-bin`, `texlive-latexextra` abd `texlive-fontsextra`. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ +- The arch package `texlive-most` is no longer available, replaced it with other texlive packages. See https://archlinux.org/packages/?q=texlive _(Florian Lindner @flo91)_ - <> - <> - <> diff --git a/scripts/docker/cirrus/arch/Dockerfile b/scripts/docker/cirrus/arch/Dockerfile index a85ee814826..01b235c18a8 100644 --- a/scripts/docker/cirrus/arch/Dockerfile +++ b/scripts/docker/cirrus/arch/Dockerfile @@ -17,6 +17,7 @@ RUN pacman -Sy --noconfirm \ texlive-bin \ texlive-latexextra \ texlive-fontsextra \ + texlive-science \ wget \ xfconf \ yajl \ From 2ea3fec9a5825f78d9594d895a887612edaa7bb8 Mon Sep 17 00:00:00 2001 From: Florian Lindner Date: Sat, 10 Jun 2023 22:56:52 +0200 Subject: [PATCH 37/41] doc: fix Doxygen for `keyName` function - fixes failed build of refman.pdf with recent TeX Live versions - see issue #4966 --- src/libs/core/keyname.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libs/core/keyname.c b/src/libs/core/keyname.c index 5d1b5302918..71dd6df909d 100644 --- a/src/libs/core/keyname.c +++ b/src/libs/core/keyname.c @@ -410,11 +410,12 @@ static char * findStartOfLastPart (char * name, size_t len) * * * @retval "" when there is no keyName. The reason is + * * @code -key=keyNew(0); -keySetName(key,""); -keyName(key); // you would expect "" here -keyDel(key); + * key=keyNew(0); + * keySetName(key,""); + * keyName(key); // you would expect "" here + * keyDel(key); * @endcode * * Valid key names are: From f3b783b8907ef2baa28741c056a920b7364022e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 13 Jun 2023 16:20:48 +0200 Subject: [PATCH 38/41] ci: fix cirrus clone script --- .cirrus.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 09a54a89d87..e522b95f5de 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -266,7 +266,8 @@ task: $CIRRUS_WORKING_DIR git reset --hard $CIRRUS_CHANGE_IN_REPO else - git clone https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR + git clone --branch=$CIRRUS_BASE_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git \ + $CIRRUS_WORKING_DIR git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR git config user.email "nobody@example.com" git config user.name "nobody" @@ -309,7 +310,8 @@ task: $CIRRUS_WORKING_DIR git reset --hard $CIRRUS_CHANGE_IN_REPO else - git clone https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR + git clone --branch=$CIRRUS_BASE_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git \ + $CIRRUS_WORKING_DIR git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR git config user.email "nobody@example.com" git config user.name "nobody" From 3ec05e11be35f28c62e565de559384e7e9ee4489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 13 Jun 2023 20:02:44 +0200 Subject: [PATCH 39/41] ci: fix macos python issue --- .github/workflows/macOS.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 4ff9b17b0bb..13e410fb866 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -75,12 +75,31 @@ jobs: - name: Install Dependencies run: | - brew update + set -ex + brew config - # Unlink parallel package, because of conflict with moreutils - brew unlink parallel || >&2 printf 'Unlinking parallel failed.`\n' - # Uninstall old Python versions and azure-cli due to file conflicts - brew remove azure-cli pipx python@3.10 python@3.11|| >&2 printf 'Uninstalling old python versions and azure-cli failed.`\n' + + brew update + + # homebrew fails to upgrade python due to unlinking failure + # (cf. https://github.com/actions/setup-python/issues/577 ) + rm -f /usr/local/bin/2to3 + rm -f /usr/local/bin/idle3 + rm -f /usr/local/bin/pydoc3 + rm -f /usr/local/bin/python3 + rm -f /usr/local/bin/python3-config + rm -f /usr/local/bin/2to3-3.11 + rm -f /usr/local/bin/idle3.11 + rm -f /usr/local/bin/pydoc3.11 + rm -f /usr/local/bin/python3.11 + rm -f /usr/local/bin/python3.11-config + rm -f /usr/local/lib/libtcl8.6.dylib + rm -f /usr/local/lib/libtk8.6.dylib + rm -f /usr/local/bin/go + rm -f /usr/local/bin/gofmt + + brew upgrade + brew install augeas \ antlr \ antlr4-cpp-runtime \ @@ -113,10 +132,13 @@ jobs: yajl \ yaml-cpp \ zeromq + if [ "$CC" = 'clang' ]; then brew install --cask oclint fi + brew install --cask adoptopenjdk + # Try to install `checkbashisms` (The file server that hosts the package is unfortunately quite unreliable.) brew install checkbashisms || >&2 printf 'Warning: Unable to install `checkbashims`\n' From 3af13a20f5fb48d6a2e6180add245c82da357f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 13 Jun 2023 20:54:55 +0200 Subject: [PATCH 40/41] toml: use elektraWriteArrayNumber instead of custom code --- src/plugins/toml/utility.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/plugins/toml/utility.c b/src/plugins/toml/utility.c index bec0b4a2901..31f31b3a001 100644 --- a/src/plugins/toml/utility.c +++ b/src/plugins/toml/utility.c @@ -9,6 +9,7 @@ #include "./utility.h" #include +#include #include #include #include @@ -37,21 +38,9 @@ void keyUpdateArrayMetakey (Key * key, size_t newIndex) char * indexToArrayString (size_t index) { - size_t digits = 1; - for (size_t value = index; value > 9; digits++) - { - value /= 10; - } - int strLen = 1 + // '#' - (digits - 1) + // underscores - digits + // actual digits - 1; // '\0' - char * str = (char *) elektraCalloc (sizeof (char) * strLen); - memset (str, '_', sizeof (char) * strLen); - str[0] = '#'; - str[strLen - 1] = 0; - snprintf (str + 1 + (digits - 1), strLen, "%lu", index); - return str; + char newName[ELEKTRA_MAX_ARRAY_SIZE]; + elektraWriteArrayNumber (newName, index); + return elektraStrDup (newName); } size_t arrayStringToIndex (const char * indexStr) From 26537ec12b4f7d43bb9bc5e99576dda859157412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= <23529132+kodebach@users.noreply.github.com> Date: Wed, 14 Jun 2023 00:44:16 +0200 Subject: [PATCH 41/41] general: apply suggestions from code review Co-authored-by: Maximilian Irlinger --- doc/KEYNAMES.md | 2 +- doc/news/_preparation_next_release.md | 4 ++-- src/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/KEYNAMES.md b/doc/KEYNAMES.md index ddd86b7ce6f..1d431ac9a1e 100644 --- a/doc/KEYNAMES.md +++ b/doc/KEYNAMES.md @@ -6,7 +6,7 @@ This document is a full explanation of how _key names_ work in Elektra. In addition to this document, a reference Python implementation can be found in [keynames.py](../scripts/keynames.py). The goal of the Python implementation is not to be fast, or to be used in any way other than as a reference. -If there are any discrepancies between this document, the Python implementation and the actual C implementation in [src/libs/elektra/keyname.c](../src/libs/core/keyname.c), you should consider them as follows: +If there are any discrepancies between this document, the Python implementation and the actual C implementation in [src/libs/core/keyname.c](../src/libs/core/keyname.c), you should consider them as follows: 1. The C implementation is optimized for speed and thus much harder to implement correctly. 2. In most cases, this document outranks the Python implementation. diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index 933eaa6b67b..84e3f6dbb31 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -51,7 +51,7 @@ docker run -it elektra/elektra ### BREAKING: New header and library structure We implemented the previously decided, new [Header File Structure](/doc/decisions/6_implemented/header_file_structure.md), [Including Headers](/doc/decisions/6_implemented/header_include.md), [Library Directory Structure](/doc/decisions/6_implemented/library_directory_structure.md) and [Library Split](/doc/decisions/6_implemented/library_split.md). -With this change it should be easier to find things in source code and know which headers are public (i.e., included in packages) and which are just internal to the repository. +With this change it should be easier to navigate the source code and know which headers are public (i.e., included in packages) and which are just internal to the repository. #### Changed headers @@ -66,7 +66,7 @@ Please look at `src/include/elektra` to find the headers containing the symbols Importantly, it is no longer required to set additional include paths. Only the standard include paths (`/usr/include`, or `/usr/local/include` when you install from source) are required. -The new `src/include/elektra` folder includes all headers that Elektra installs (\*), it is copied directly to `/usr/include` on install. +The new `src/include/elektra` folder, which contains all headers that Elektra installs (\*), is copied directly to `/usr/include` on install. The layout of `src/include/elektra` (and consequently the layout of installed headers), follows a fixed pattern: ```c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 446bea773f3..3d9e3d067b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ set (ADDTESTING_PHASE OFF) include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include") # ~~~ -# RPATH settings, see http://www.itk.org/Wiki/CMake_RPATH_handling +# RPATH settings, see https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling # those settings are needed to find the plugins at runtime even without ld.so.conf # search only in the prefix the user decided to install elektra # (e.g. /usr/local/)