Skip to content

Commit

Permalink
Extend cmake warnings test and fix container package error
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Aug 3, 2023
1 parent 3bf73df commit a286732
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions cmake/celix_project/WarningTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ Including some constructions that will generate warnings.

if (ENABLE_CMAKE_WARNING_TESTS AND TARGET Celix::shell AND TARGET Celix::shell_tui)
add_celix_container(examples-with-duplicate-installed-bundles
BUNDLES Celix::shell Celix::shell_tui #add bundles with run level 3
INSTALL_BUNDLES Celix::shell
BUNDLES Celix::shell_tui #add bundles with run level 3
)

#Adding a bundle twice on the same run level is fine and the last entry should be ignored
celix_container_bundles(examples-with-duplicate-installed-bundles LEVEL 3 Celix::shell)
celix_container_bundles(examples-with-duplicate-installed-bundles INSTALL Celix::shell)
celix_container_bundles(examples-with-duplicate-installed-bundles LEVEL 3 Celix::shell_tui)

#Adding a bundle twice on different run levels should result in an warning
celix_container_bundles(examples-with-duplicate-installed-bundles LEVEL 4 Celix::shell_tui)
celix_container_bundles(examples-with-duplicate-installed-bundles LEVEL 4 Celix::shell)
celix_container_bundles(examples-with-duplicate-installed-bundles INSTALL Celix::shell_tui)
endif ()
18 changes: 9 additions & 9 deletions cmake/cmake_celix/ContainerPackaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function(celix_container_bundles)

if (BUNDLES_INSTALL)
get_target_property(BUNDLES ${CONTAINER_TARGET} "CONTAINER_BUNDLES_INSTALL")
set(BUNDLES_LEVEL "install")
set(BUNDLES_LEVEL "INSTALL")
else () #bundle level 0,1,2,3,4,5 or 6
get_target_property(BUNDLES ${CONTAINER_TARGET} "CONTAINER_BUNDLES_LEVEL_${BUNDLES_LEVEL}")
endif ()
Expand Down Expand Up @@ -599,7 +599,7 @@ function(celix_container_bundles)

list(FIND BUNDLES ${BUNDLE_TO_ADD} INDEX)
if (INDEX EQUAL -1) #Note this ignores the same bundle for the same level
_celix_container_check_duplicate_bundles(${CONTAINER_TARGET} ${BUNDLE_TO_ADD} ${TARGET_LEVEL})
_celix_container_check_duplicate_bundles(${CONTAINER_TARGET} ${BUNDLE_TO_ADD} ${BUNDLES_LEVEL})
list(APPEND BUNDLES ${BUNDLE_TO_ADD})
endif ()
endforeach()
Expand All @@ -617,27 +617,27 @@ endfunction()

#[[
Private function to check if there are duplicate bundles in the container and print a warning if so.
Arg CONTAINER_TARGET ADDED_BUNDLES_LIST BUNDLE_LEVEL
Arg CONTAINER_TARGET ADDED_BUNDLES_LIST TARGET_LEVEL
]]
function(_celix_container_check_duplicate_bundles)
list(GET ARGN 0 CONTAINER_TARGET)
list(GET ARGN 1 TO_ADD_BUNDLE)
list(GET ARGN 2 BUNDLE_LEVEL)
list(GET ARGN 2 TARGET_LEVEL)

set(MSG "Bundle `${TO_ADD_BUNDLE}` is added to the container multiple times. This can lead to errors during \
bundle installation. Bundle `${TO_ADD_BUNDLE}` already added to container '${CONTAINER_TARGET}` \
at level ${BUNDLE_LEVEL}.")
set(PARTIAL_MSG "Bundle `${TO_ADD_BUNDLE}` is added to the container multiple times. This can lead to errors \
during bundle installation. Bundle `${TO_ADD_BUNDLE}` for level ${TARGET_LEVEL} is already added to the \
container '${CONTAINER_TARGET}` at level ")

get_target_property(BUNDLES ${CONTAINER_TARGET} "CONTAINER_BUNDLES_INSTALL")
list(FIND BUNDLES ${TO_ADD_BUNDLE} INDEX)
if (INDEX GREATER -1)
message(WARNING "${MSG}")
message(WARNING "${PARTIAL_MSG} INSTALL.")
endif()
foreach(BUNDLE_LEVEL RANGE 0 6)
get_target_property(BUNDLES ${CONTAINER_TARGET} "CONTAINER_BUNDLES_LEVEL_${BUNDLE_LEVEL}")
list(FIND BUNDLES ${TO_ADD_BUNDLE} INDEX)
if (INDEX GREATER -1)
message(WARNING "${MSG}")
message(WARNING "${PARTIAL_MSG} ${BUNDLE_LEVEL}.")
endif()
endforeach()
endfunction()
Expand Down

0 comments on commit a286732

Please sign in to comment.