Skip to content
Permalink
Browse files

Merge pull request #2686 from Piankero/error_codes_implementation

Error codes implementation
  • Loading branch information...
markus2330 committed Jun 27, 2019
2 parents 2e38a6c + b3c46c9 commit 76f2b79f39c963c0ad6bf3e4bfad7e0f42fd3165
Showing with 1,880 additions and 3,459 deletions.
  1. +35 −9 cmake/Modules/LibAddLib.cmake
  2. +0 −2 cmake/Modules/LibAddMacros.cmake
  3. +5 −0 cmake/Modules/LibAddPlugin.cmake
  4. +5 −1 doc/news/_preparation_next_release.md
  5. +3 −3 doc/tutorials/plugins.md
  6. +6 −6 doc/tutorials/validation.md
  7. +11 −11 examples/CMakeLists.txt
  8. +1 −1 src/bindings/cpp/include/kdbplugin.hpp
  9. +2 −2 src/bindings/haskell/src/Elektra/Errors.chs
  10. +2 −2 src/bindings/haskell/src/c/hskdberrors.c
  11. +2 −2 src/bindings/haskell/src/include/hskdberrors.h
  12. +10 −13 src/bindings/io/ev/CMakeLists.txt
  13. +1 −1 src/bindings/io/ev/example/CMakeLists.txt
  14. +10 −13 src/bindings/io/glib/CMakeLists.txt
  15. +1 −1 src/bindings/io/glib/example/CMakeLists.txt
  16. +14 −27 src/bindings/io/uv/CMakeLists.txt
  17. +1 −1 src/bindings/io/uv/example/CMakeLists.txt
  18. +6 −12 src/error/CMakeLists.txt
  19. +283 −493 src/error/exporterrors.cpp
  20. +8 −7 src/error/parser.cpp
  21. +36 −1,337 src/error/specification
  22. +0 −1 src/include/elektra/CMakeLists.txt
  23. +8 −1 src/include/elektra/error.h
  24. +29 −12 src/include/kdbmacros.h
  25. +17 −43 src/include/kdbprivate.h
  26. +18 −7 src/libs/elektra/backend.c
  27. +45 −34 src/libs/elektra/kdb.c
  28. +7 −7 src/libs/elektra/mount.c
  29. +19 −13 src/libs/elektra/plugin.c
  30. +1 −1 src/libs/elektra/split.c
  31. +1 −1 src/libs/highlevel/README.md
  32. +11 −218 src/libs/highlevel/elektra.c
  33. +0 −1 src/libs/highlevel/elektra_array_value.c
  34. +167 −135 src/libs/highlevel/elektra_error.c
  35. +0 −1 src/libs/highlevel/elektra_value.c
  36. +5 −4 src/libs/loader/dl.c
  37. +3 −2 src/libs/loader/static.c
  38. +43 −45 src/libs/opts/opts.c
  39. +9 −7 src/libs/pluginprocess/pluginprocess.c
  40. +14 −26 src/plugins/augeas/augeas.c
  41. +6 −6 src/plugins/base64/base64.c
  42. +14 −14 src/plugins/blockresolver/blockresolver.c
  43. +8 −8 src/plugins/boolean/boolean.c
  44. +3 −3 src/plugins/cache/cache.c
  45. +2 −1 src/plugins/cachefilter/cachefilter.c
  46. +4 −4 src/plugins/camel/camel.c
  47. +3 −3 src/plugins/conditionals/README.md
  48. +48 −42 src/plugins/conditionals/conditionals.c
  49. +1 −1 src/plugins/cpptemplate/cpptemplate.cpp
  50. +2 −2 src/plugins/cpptype/README.md
  51. +1 −1 src/plugins/cpptype/cpptype.cpp
  52. +7 −10 src/plugins/crypto/botan_operations.cpp
  53. +16 −6 src/plugins/crypto/crypto.c
  54. +21 −19 src/plugins/crypto/gcrypt_operations.c
  55. +22 −22 src/plugins/crypto/gpg.c
  56. +14 −14 src/plugins/crypto/helper.c
  57. +26 −27 src/plugins/crypto/openssl_operations.c
  58. +17 −16 src/plugins/csvstorage/csvstorage.c
  59. +25 −26 src/plugins/curlget/curlget.c
  60. +7 −7 src/plugins/date/date.c
  61. +3 −3 src/plugins/dbusrecv/CMakeLists.txt
  62. +4 −4 src/plugins/directoryvalue/directoryvalue.cpp
  63. +3 −3 src/plugins/doc/doc.c
  64. +7 −2 src/plugins/dump/dump.cpp
  65. +4 −4 src/plugins/enum/README.md
  66. +2 −1 src/plugins/enum/enum.c
  67. +5 −5 src/plugins/error/error.c
  68. +41 −27 src/plugins/fcrypt/fcrypt.c
  69. +6 −7 src/plugins/file/file.c
  70. +11 −7 src/plugins/filecheck/filecheck.c
  71. +11 −15 src/plugins/gitresolver/gitresolver.c
  72. +24 −25 src/plugins/gpgme/gpgme.c
  73. +12 −14 src/plugins/hexnumber/hexnumber.c
  74. +3 −3 src/plugins/hosts/README.md
  75. +1 −1 src/plugins/hosts/hosts-get.c
  76. +1 −1 src/plugins/hosts/hosts-set.c
  77. +14 −14 src/plugins/iconv/iconv.c
  78. +9 −8 src/plugins/ini/ini.c
  79. +2 −1 src/plugins/ini/testmod_ini.c
  80. +2 −2 src/plugins/ipaddr/README.md
  81. +3 −2 src/plugins/ipaddr/ipaddr.c
  82. +20 −20 src/plugins/jni/jni.c
  83. +1 −1 src/plugins/keytometa/keytometa.c
  84. +2 −2 src/plugins/line/line.c
  85. +3 −3 src/plugins/lineendings/lineendings.c
  86. +5 −5 src/plugins/lua/lua.cpp
  87. +6 −5 src/plugins/macaddr/macaddr.c
  88. +2 −2 src/plugins/mathcheck/README.md
  89. +9 −8 src/plugins/mathcheck/mathcheck.c
  90. +2 −2 src/plugins/mini/README.md
  91. +2 −3 src/plugins/mini/mini.c
  92. +3 −3 src/plugins/multifile/multifile.c
  93. +1 −1 src/plugins/network/README.md
  94. +14 −12 src/plugins/network/network.c
  95. +7 −5 src/plugins/passwd/passwd.c
  96. +2 −2 src/plugins/path/README.md
  97. +37 −33 src/plugins/path/path.c
  98. +6 −5 src/plugins/process/process.c
  99. +17 −15 src/plugins/python/python.cpp
  100. +20 −22 src/plugins/quickdump/quickdump.c
  101. +4 −4 src/plugins/quickdump/readv1.c
  102. +9 −10 src/plugins/quickdump/readv2.c
  103. +5 −7 src/plugins/range/range.c
  104. +14 −15 src/plugins/reference/reference.c
  105. +10 −10 src/plugins/reference/testmod_reference.c
  106. +10 −7 src/plugins/regexstore/regexstore.cpp
  107. +2 −2 src/plugins/required/required.c
  108. +35 −31 src/plugins/resolver/filename.c
  109. +76 −98 src/plugins/resolver/resolver.c
  110. +3 −2 src/plugins/rgbcolor/rgbcolor.c
  111. +8 −8 src/plugins/ruby/ruby.cpp
  112. +3 −3 src/plugins/ruby/testmod_ruby.c
  113. +12 −9 src/plugins/shell/shell.c
  114. +11 −8 src/plugins/simpleini/simpleini.c
  115. +2 −2 src/plugins/simplespeclang/simplespeclang.cpp
  116. +2 −2 src/plugins/spec/spec.c
  117. +20 −21 src/plugins/specload/specload.c
  118. +1 −1 src/plugins/struct/struct.cpp
  119. +2 −2 src/plugins/sync/sync.c
  120. +7 −7 src/plugins/tcl/tcl.cpp
  121. +3 −3 src/plugins/type/README.md
  122. +27 −26 src/plugins/type/type.c
  123. +7 −6 src/plugins/type/types.c
  124. +2 −2 src/plugins/typechecker/Elektra/Typechecker.hs.in
  125. +10 −8 src/plugins/unit/unit.c
  126. +3 −3 src/plugins/validation/validation.c
  127. +15 −14 src/plugins/wresolver/wresolver.c
  128. +10 −10 src/plugins/xerces/xerces.cpp
  129. +2 −2 src/plugins/yajl/yajl_gen.c
  130. +2 −2 src/plugins/yajl/yajl_parse.c
  131. +3 −3 src/plugins/yambi/convert.cpp
  132. +2 −2 src/plugins/yambi/yambi.cpp
  133. +3 −3 src/plugins/yamlcpp/README.md
  134. +11 −11 src/plugins/yamlcpp/yamlcpp.cpp
  135. +1 −2 src/plugins/yamlsmith/yamlsmith.cpp
  136. +2 −3 src/plugins/yanlr/yanlr.cpp
  137. +7 −7 src/plugins/yawn/convert.cpp
  138. +2 −2 src/plugins/yawn/yawn.cpp
  139. +2 −2 src/plugins/yaypeg/yaypeg.cpp
  140. +3 −3 src/plugins/zeromqrecv/CMakeLists.txt
  141. +2 −2 src/plugins/zeromqsend/testmod_zeromqsend.c
  142. +2 −3 src/plugins/zeromqsend/zeromqsend.c
  143. +28 −28 tests/ctest/test_opts.c
  144. +1 −1 tests/ctest/test_splitget.c
  145. +52 −2 tests/kdb/CMakeLists.txt
  146. +1 −1 tests/kdb/testkdb_ensure.cpp
  147. +23 −20 tests/kdb/testkdb_error.cpp
  148. +0 −1 tests/kdb/testkdb_highlevel.cpp
  149. +4 −4 tests/shell/check_error.sh
  150. +1 −1 tests/shell/shell_recorder/shell_recorder.sh
@@ -1,26 +1,52 @@
function (add_lib name)
cmake_parse_arguments (ARG
"CPP" # optional keywords
"" # one value keywords
"SOURCES;LINK_LIBRARIES;LINK_ELEKTRA" # multi value keywords
${ARGN})
function (set_additional_compile_definitions shortname)
if (NOT "${ARG_COMPILE_DEFINITIONS}" MATCHES "ELEKTRA_MODULE_NAME")
list (APPEND ADDITIONAL_COMPILE_DEFINITIONS_PARTS
"ELEKTRA_MODULE_NAME=${shortname}")
endif ()

set (ADDITIONAL_COMPILE_DEFINITIONS "${ADDITIONAL_COMPILE_DEFINITIONS_PARTS}" PARENT_SCOPE)
unset (ADDITIONAL_COMPILE_DEFINITIONS_PARTS)
endfunction (set_additional_compile_definitions)

function (add_lib name)
cmake_parse_arguments (
ARG
"CPP" # optional keywords
"" # one value keywords
"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)

add_library (elektra-${name}-objects OBJECT ${ARG_SOURCES})
add_dependencies (elektra-${name}-objects kdberrors_generated elektra_error_codes_generated)
target_include_directories (elektra-${name}-objects PUBLIC ${ARG_INCLUDE_DIRECTORIES})
target_include_directories (elektra-${name}-objects SYSTEM PUBLIC ${ARG_INCLUDE_SYSTEM_DIRECTORIES})

set_property (TARGET elektra-${name}-objects
PROPERTY POSITION_INDEPENDENT_CODE
ON)

set_additional_compile_definitions (${name})

set_property (TARGET elektra-${name}-objects
APPEND
PROPERTY COMPILE_DEFINITIONS
"${ARG_COMPILE_DEFINITIONS};${ADDITIONAL_COMPILE_DEFINITIONS}")

if (BUILD_SHARED)
add_library (elektra-${name} SHARED ${ARG_SOURCES})
add_dependencies (elektra-${name} kdberrors_generated elektra_error_codes_generated ${ARG_LINK_ELEKTRA})
add_library (elektra-${name} SHARED $<TARGET_OBJECTS:elektra-${name}-objects>)

target_link_libraries (elektra-${name} elektra-core ${ARG_LINK_ELEKTRA})
endif (BUILD_SHARED)

set_property (GLOBAL
APPEND
PROPERTY "elektra-full_SRCS"
${ARG_SOURCES})
"$<TARGET_OBJECTS:elektra-${name}-objects>")

set_property (GLOBAL
APPEND
@@ -214,9 +214,7 @@ macro (add_headers 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/errorcodes.h PROPERTIES GENERATED ON SKIP_AUTOMOC ON)
set_source_files_properties (${BINARY_INCLUDE_DIR}/elektra/errors.h PROPERTIES GENERATED ON SKIP_AUTOMOC ON)
set_source_files_properties (${BINARY_INCLUDE_DIR}/elektra/errorsprivate.h PROPERTIES GENERATED ON SKIP_AUTOMOC ON)
list (APPEND ${HDR_FILES}
"${BINARY_INCLUDE_DIR}/kdberrors.h")
endmacro (add_headers)
@@ -28,6 +28,11 @@ function (set_additional_compile_definitions shortname)
"ELEKTRA_PLUGIN_NAME_C=${shortname}")
endif ()

if (NOT "${ARG_COMPILE_DEFINITIONS}" MATCHES "ELEKTRA_MODULE_NAME")
list (APPEND ADDITIONAL_COMPILE_DEFINITIONS_PARTS
"ELEKTRA_MODULE_NAME=${shortname}")
endif ()

set (ADDITIONAL_COMPILE_DEFINITIONS "${ADDITIONAL_COMPILE_DEFINITIONS_PARTS}" PARENT_SCOPE)
unset (ADDITIONAL_COMPILE_DEFINITIONS_PARTS)
endfunction (set_additional_compile_definitions)
@@ -70,7 +70,11 @@ IMPORTANT: `kdbEnsure` only works, if the `list` plugin is mounted in all approp
Note: `kdbEnsure` right now ignores the `infos/recommends` and `infos/needs` metadata of plugins, so you have to explicitly take care of
dependencies. _(Klemens Böswirth)_

### <<HIGHLIGHT2>>
### Error Code Concept

With this release, we changed our messy error code system into a more structured and clean way. Similar to [SQLStates](https://www.ibm.com/support/knowledgecenter/en/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0809.htm) we changed to structure of our error codes and migrated them. Have a look into
the new [codes](../../src/error/specification). This allows us to easily extend the specification without breaking existing
codes and to avoid risking duplicated errors as we had before. _(Michael Zronek)_

## Plugins

@@ -340,7 +340,7 @@ Basically the implementation of `elektraLineSet` can be described with the follo
// open the file
if (error)
{
ELEKTRA_SET_ERROR(74, parentKey, keyString(parentKey));
ELEKTRA_SET_RESOURCE_ERROR(parentKey, keyString(parentKey));
}
for (/* each key */)
{
@@ -404,8 +404,8 @@ int elektraLineCheckConfig (Key * errorKey, KeySet * conf)
const char * value = keyString (cur);
if (strlen (value) > 3)
{
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALUE_LENGTH, errorKey,
"value %s is more than 3 characters long",
ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( errorKey,
"Value '%s' is more than 3 characters long",
value);
return -1; // The configuration was not OK and could not be fixed
}
@@ -45,8 +45,8 @@ The most direct way to validate keys is
sudo kdb mount validation.dump user/tests/together dump validation
kdb vset user/tests/together/test 123 "[1-9][0-9]*" "Not a number"
kdb set user/tests/together/test abc
# STDERR: Sorry, module validator issued the error.*
# ERROR: 42
# STDERR: Sorry, module validation issued the error.*
# ERROR:C03100
# RET:5
```

@@ -264,8 +264,8 @@ you can run into [this](https://github.com/ElektraInitiative/libelektra/issues/2
```sh
kdb set /tests/tutorial/links/url "invalid url"
# STDOUT-REGEX: Using name (user|system)/tests/tutorial/links/url
# STDERR: .*key value failed to validate.*not a valid URL.*
# ERROR: 42
# STDERR: .*Validation Syntactic.*not a valid URL.*
# ERROR: C03100
# RET: 5
```

@@ -298,13 +298,13 @@ There are many ways to do so directly supported by [the spec plugin](/src/plugin
Another way is to trigger errors with the [error plugin](/src/plugins/error):

```sh
kdb setmeta /tests/tutorial/spec/should_not_be_here trigger/error 10
kdb setmeta /tests/tutorial/spec/should_not_be_here trigger/error C03200
#> Using keyname spec/tests/tutorial/spec/should_not_be_here
kdb spec-mount /tests/tutorial
kdb set /tests/tutorial/spec/should_not_be_here abc
# STDOUT-REGEX: Using name (user|system)/tests/tutorial/spec/should_not_be_here
# RET: 5
# ERROR:10
# ERROR:C03200
kdb get /tests/tutorial/spec/should_not_be_here
# RET: 11
# STDERR: Did not find key '/tests/tutorial/spec/should_not_be_here'
@@ -57,7 +57,7 @@ if (FOUND_NAME GREATER -1)

target_link_elektra (${EXAMPLE} elektra-kdb elektra-notification)

# TODO resolve issues.libelektra.org/2007
# TODO resolve https://issues.libelektra.org/2007
check_binding_was_added ("io_uv" IS_INCLUDED)
if (IS_INCLUDED)

@@ -68,7 +68,7 @@ if (FOUND_NAME GREATER -1)
set (SOURCES ${SRC_FILES} ${HDR_FILES})
if (BUILD_FULL OR BUILD_STATIC)
list (APPEND SOURCES
$<TARGET_OBJECTS:OBJ_elektra-io-uv>) # add sources for elektra-io-uv for static and full builds
$<TARGET_OBJECTS:elektra-io-uv-objects>) # add sources for elektra-io-uv for static and full builds
endif ()

add_executable (${EXAMPLE} ${SOURCES})
@@ -85,6 +85,7 @@ if (FOUND_NAME GREATER -1)
else ()
target_compile_definitions (${EXAMPLE} PRIVATE "HAVE_LIBUV1")
endif ()
target_include_directories (${EXAMPLE} PRIVATE ${libuv_INCLUDE_DIRS})

endif ()

@@ -96,15 +97,14 @@ if (FOUND_NAME GREATER -1)

set (SRC_FILES notificationReload.c)
set (SOURCES ${SRC_FILES} ${HDR_FILES})
if (BUILD_FULL OR BUILD_STATIC)
# Work around missing header errors that occurs if only `BUILD_FULL`, but not `BUILD_SHARED` is enabled.
find_package (GLib QUIET)
find_package (libuv QUIET)
include_directories (${GLib_INCLUDE_DIRS} ${libuv_INCLUDE_DIRS})

list (APPEND SOURCES
$<TARGET_OBJECTS:OBJ_elektra-io-glib>) # add sources for elektra-io-uv for static and full builds
endif ()
# if (BUILD_FULL OR BUILD_STATIC) Work around missing header errors that occurs if only `BUILD_FULL`, but not `BUILD_SHARED`
# is enabled.
find_package (GLib QUIET)
find_package (libuv QUIET)
include_directories (${GLib_INCLUDE_DIRS} ${libuv_INCLUDE_DIRS})

list (APPEND SOURCES
$<TARGET_OBJECTS:elektra-io-glib-objects>) # add sources for elektra-io-uv for static and full builds endif ()

add_executable (${EXAMPLE} ${SOURCES})
add_dependencies (${EXAMPLE} kdberrors_generated elektra_error_codes_generated)
@@ -76,7 +76,7 @@ class Delegator
catch (const char * msg)
{
#ifdef KDBERRORS_H
ELEKTRA_ADD_WARNING (69, errorKey, msg);
ELEKTRA_ADD_PLUGIN_MISBEHAVIOR_WARNINGF (errorKey, "Could not create C++ plugin. Reason: %s", msg);
#endif
return -1;
}
@@ -15,5 +15,5 @@ module Elektra.Errors (

{#context lib="libelektra" #}

{#fun unsafe hsElektraTriggerError as triggerError {`Int', `Key', `String'} -> `()' #}
{#fun unsafe hsElektraTriggerWarnings as triggerWarnings {`Int', `Key', `String'} -> `()' #}
{#fun unsafe hsElektraTriggerError as triggerError {`String', `Key', `String'} -> `()' #}
{#fun unsafe hsElektraTriggerWarnings as triggerWarnings {`String', `Key', `String'} -> `()' #}
@@ -8,12 +8,12 @@
#include <hskdberrors.h>
#include <kdberrors.h>

void hsElektraTriggerError (int nr, Key * parentKey, const char * message)
void hsElektraTriggerError (const char * nr, Key * parentKey, const char * message)
{
elektraTriggerError (nr, parentKey, message);
}

void hsElektraTriggerWarnings (int nr, Key * parentKey, const char * message)
void hsElektraTriggerWarnings (const char * nr, Key * parentKey, const char * message)
{
elektraTriggerWarnings (nr, parentKey, message);
}
@@ -10,7 +10,7 @@

#include <kdb.h>

void hsElektraTriggerError (int nr, Key * parentKey, const char * message);
void hsElektraTriggerWarnings (int nr, Key * parentKey, const char * message);
void hsElektraTriggerError (const char * nr, Key * parentKey, const char * message);
void hsElektraTriggerWarnings (const char * nr, Key * parentKey, const char * message);

#endif
@@ -15,18 +15,15 @@ else () # Build library

set (IO_VARIANT_LIBRARY elektra-io-${BINDING_VARIANT})

# create object library so that executables can use $<TARGET_OBJECTS:OBJ_${IO_VARIANT_LIBRARY}>
add_library (OBJ_${IO_VARIANT_LIBRARY} OBJECT ${SOURCES})
target_include_directories (OBJ_${IO_VARIANT_LIBRARY} SYSTEM PUBLIC ${LIBEV_INCLUDE_DIRS})

add_lib (io-${BINDING_VARIANT} SOURCES ${SOURCES} LINK_ELEKTRA elektra-io LINK_LIBRARIES ${LIBEV_LIBRARIES})

if (BUILD_FULL OR BUILD_STATIC)
add_includes ("elektra-full" ${LIBEV_INCLUDE_DIRS})
endif ()
if (BUILD_SHARED)
target_include_directories (${IO_VARIANT_LIBRARY} SYSTEM PUBLIC ${LIBEV_INCLUDE_DIRS})
endif ()
add_lib (io-${BINDING_VARIANT}
SOURCES
${SOURCES}
LINK_ELEKTRA
elektra-io
LINK_LIBRARIES
${LIBEV_LIBRARIES}
INCLUDE_SYSTEM_DIRECTORIES
${LIBEV_INCLUDE_DIRS})

configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/${IO_VARIANT_LIBRARY}.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IO_VARIANT_LIBRARY}.pc"
@@ -48,7 +45,7 @@ else () # Build library

if (BUILD_FULL OR BUILD_STATIC) # add sources for elektra-io-ev for static and full builds
list (APPEND TEST_SOURCES
$<TARGET_OBJECTS:OBJ_${IO_VARIANT_LIBRARY}>)
$<TARGET_OBJECTS:${IO_VARIANT_LIBRARY}-objects>)
endif ()

add_executable (${testexename} ${TEST_SOURCES})
@@ -10,7 +10,7 @@ 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
list (APPEND SOURCES
$<TARGET_OBJECTS:OBJ_elektra-io-ev>)
$<TARGET_OBJECTS:elektra-io-ev-objects>)
endif ()

# Build test
@@ -20,18 +20,15 @@ else ()

set (IO_VARIANT_LIBRARY elektra-io-${BINDING_VARIANT})

# create object library so that executables can use $<TARGET_OBJECTS:OBJ_${IO_VARIANT_LIBRARY}>
add_library (OBJ_${IO_VARIANT_LIBRARY} OBJECT ${SOURCES})
target_include_directories (OBJ_${IO_VARIANT_LIBRARY} SYSTEM PUBLIC ${GLib_INCLUDE_DIRS})

add_lib (io-${BINDING_VARIANT} SOURCES ${SOURCES} LINK_ELEKTRA elektra-io LINK_LIBRARIES ${GLib_LIBRARY})

if (BUILD_FULL OR BUILD_STATIC)
add_includes ("elektra-full" ${GLib_INCLUDE_DIRS})
endif ()
if (BUILD_SHARED)
target_include_directories (${IO_VARIANT_LIBRARY} SYSTEM PUBLIC ${GLib_INCLUDE_DIRS})
endif ()
add_lib (io-${BINDING_VARIANT}
SOURCES
${SOURCES}
LINK_ELEKTRA
elektra-io
LINK_LIBRARIES
${GLib_LIBRARY}
INCLUDE_SYSTEM_DIRECTORIES
${GLib_INCLUDE_DIRS})

configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/${IO_VARIANT_LIBRARY}.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IO_VARIANT_LIBRARY}.pc"
@@ -53,7 +50,7 @@ else ()

if (BUILD_FULL OR BUILD_STATIC) # add sources for elektra-io-glib for static and full builds
list (APPEND TEST_SOURCES
$<TARGET_OBJECTS:OBJ_${IO_VARIANT_LIBRARY}>)
$<TARGET_OBJECTS:${IO_VARIANT_LIBRARY}-objects>)
endif ()

add_executable (${testexename} ${TEST_SOURCES})
@@ -10,7 +10,7 @@ set (SOURCES ${SRC_FILES} ${HDR_FILES} ${ELEKTRA_HEADERS})

if (BUILD_FULL OR BUILD_STATIC)
list (APPEND SOURCES
$<TARGET_OBJECTS:OBJ_elektra-io-glib>) # add sources for elektra-io-glib for static and full builds
$<TARGET_OBJECTS:elektra-io-glib-objects>) # add sources for elektra-io-glib for static and full builds
endif ()

# Build test
@@ -21,36 +21,23 @@ else ()

set (IO_UV_LIBRARY elektra-io-${BINDING_VARIANT})

# create object library so that executables can use $<TARGET_OBJECTS:OBJ_${IO_UV_LIBRARY}>
add_library (OBJ_${IO_UV_LIBRARY} OBJECT ${SOURCES})
target_include_directories (OBJ_${IO_UV_LIBRARY} SYSTEM PUBLIC ${libuv_INCLUDE_DIRS})

if (libuv_VERSION VERSION_LESS "1.0")
target_compile_definitions (OBJ_${IO_UV_LIBRARY} PRIVATE "HAVE_LIBUV0")
set (HAVE_LIBUV_VERSION "HAVE_LIBUV0")
else ()
target_compile_definitions (OBJ_${IO_UV_LIBRARY} PRIVATE "HAVE_LIBUV1")
set (HAVE_LIBUV_VERSION "HAVE_LIBUV1")
endif ()

add_lib (io-${BINDING_VARIANT} SOURCES ${SOURCES} LINK_ELEKTRA elektra-io LINK_LIBRARIES ${libuv_LIBRARIES})

if (BUILD_FULL OR BUILD_STATIC)
add_includes ("elektra-full" ${libuv_INCLUDE_DIRS})

if (libuv_VERSION VERSION_LESS "1.0")
add_definitions ("-DHAVE_LIBUV0")
else ()
add_definitions ("-DHAVE_LIBUV1")
endif ()
endif ()
if (BUILD_SHARED)
target_include_directories (${IO_UV_LIBRARY} SYSTEM PUBLIC ${libuv_INCLUDE_DIRS})

if (libuv_VERSION VERSION_LESS "1.0")
target_compile_definitions (${IO_UV_LIBRARY} PRIVATE "HAVE_LIBUV0")
else ()
target_compile_definitions (${IO_UV_LIBRARY} PRIVATE "HAVE_LIBUV1")
endif ()
endif ()
add_lib (io-${BINDING_VARIANT}
SOURCES
${SOURCES}
LINK_ELEKTRA
elektra-io
LINK_LIBRARIES
${libuv_LIBRARIES}
INCLUDE_SYSTEM_DIRECTORIES
${libuv_INCLUDE_DIRS}
COMPILE_DEFINITIONS
${HAVE_LIBUV_VERSION})

configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/${IO_UV_LIBRARY}.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${IO_UV_LIBRARY}.pc" @ONLY)

@@ -70,7 +57,7 @@ else ()

if (BUILD_FULL OR BUILD_STATIC)
list (APPEND TEST_SOURCES
$<TARGET_OBJECTS:OBJ_${IO_UV_LIBRARY}>) # add sources for elektra-io-uv for static and full builds
$<TARGET_OBJECTS:${IO_UV_LIBRARY}-objects>) # add sources for elektra-io-uv for static and full builds
endif ()

add_executable (${TESTEXENAME} ${TEST_SOURCES})

0 comments on commit 76f2b79

Please sign in to comment.
You can’t perform that action at this time.