diff --git a/CHANGES.md b/CHANGES.md index 3880cd00d..31bdfdfa1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,8 @@ limitations under the License. - pubsub_serializer.h is removed and no longer supported. Use pubsub_message_serialization_service.h instead. - C++11 support for dm is removed. C++14 is now the minimum required version. - C++17 string_view support is removed from the utils and framework lib. +- Apache Celix CMake bundle functions without a celix_ prefix or infix are removed. +- Apache Celix CMake support for creating docker images and creating runtimes dirs is removed. - Support and usage of "service.lang" service property is removed. # Noteworthy Changes for 2.4.0 (2023-09-27) diff --git a/cmake/celix_project/ApacheRat.cmake b/cmake/celix_project/ApacheRat.cmake index c18f0dd32..c2b748b1c 100644 --- a/cmake/celix_project/ApacheRat.cmake +++ b/cmake/celix_project/ApacheRat.cmake @@ -41,4 +41,4 @@ if (ENABLE_APACHE_RAT) else(Java_Runtime_FOUND) MESSAGE(STATUS "Java not found, cannot execute Apache RAT checks") endif(Java_Runtime_FOUND) -endif () \ No newline at end of file +endif () diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake index f006c1c66..112d942f4 100644 --- a/cmake/cmake_celix/BundlePackaging.cmake +++ b/cmake/cmake_celix/BundlePackaging.cmake @@ -101,12 +101,6 @@ function(check_bundle BUNDLE) endif () endfunction() - -function(add_bundle) - message(DEPRECATION "add_bundle is deprecated, use add_celix_bundle instead.") - add_celix_bundle(${ARGN}) -endfunction() - #[[ Add a Celix bundle to the project. @@ -391,11 +385,6 @@ function(add_celix_bundle) celix_bundle_headers(${BUNDLE_TARGET_NAME} ${BUNDLE_HEADERS}) endfunction() -function(bundle_export_libs) - message(DEPRECATION "bundle_export_libs is deprecated, use celix_bundle_export_libs instead.") - celix_bundle_export_libs(${ARGN}) -endfunction() - #[[ Adds a export lib to the Celix bundle. @@ -407,11 +396,6 @@ function(celix_bundle_export_libs) celix_bundle_libs(${BUNDLE} "EXPORT" TRUE ${ARGN}) endfunction() -function(bundle_private_libs) - message(DEPRECATION "bundle_private_libs is deprecated, use celix_bundle_private_libs instead.") - celix_bundle_private_libs(${ARGN}) -endfunction() - #[[ Add libraries to a bundle. @@ -452,10 +436,6 @@ function(celix_bundle_private_libs) celix_bundle_libs(${BUNDLE} "PRIVATE" FALSE ${ARGN}) endfunction() -function(bundle_libs) - message(DEPRECATION "bundle_libs is deprecated, use celix_bundle_libs instead.") - celix_bundle_libs(${ARGN}) -endfunction() function(celix_bundle_libs) #0 is bundle TARGET #1 is TYPE, e.g PRIVATE,EXPORT or IMPORT @@ -544,11 +524,6 @@ function(celix_bundle_libs) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_LIB_TARGETS" "${LIB_TARGETS}") endfunction() -function(bundle_import_libs) - message(DEPRECATION "bundle_import_libs is deprecated, use celix_bundle_import_libs instead.") - celix_bundle_import_libs(${ARGN}) -endfunction() - #[[ Adds a import lib to the Celix bundle. @@ -580,11 +555,6 @@ function(celix_bundle_import_libs) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_IMPORT_LIBS" "${LIBS}") endfunction() -function(bundle_files) - message(DEPRECATION "bundle_files is deprecated, use celix_bundle_files instead.") - celix_bundle_files(${ARGN}) -endfunction() - #[[ Add files to the target bundle. @@ -767,11 +737,6 @@ function(celix_bundle_add_files) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_DEPEND_TARGETS" "${DEPS}") endfunction() -function(bundle_headers) - message(DEPRECATION "bundle_headers is deprecated, use celix_bundle_headers instead.") - celix_bundle_headers(${ARGN}) -endfunction() - #[[ Append the provided headers to the target bundle manifest. @@ -798,11 +763,6 @@ function(celix_bundle_headers) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_HEADERS" "${HEADERS}") endfunction() -function(bundle_symbolic_name) - message(DEPRECATION "bundle_symbolic_name is deprecated, use celix_bundle_symbolic_name instead.") - celix_bundle_symbolic_name(${ARGN}) -endfunction() - #[[ Set bundle symbolic name @@ -845,11 +805,6 @@ function(celix_get_bundle_symbolic_name) endif () endfunction() -function(bundle_name) - message(DEPRECATION "bundle_name is deprecated, use celix_bundle_name instead.") - celix_bundle_name(${ARGN}) -endfunction() - #[[ Set bundle name @@ -861,11 +816,6 @@ function(celix_bundle_name BUNDLE NAME) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_NAME" ${NAME}) endfunction() -function(bundle_version) - message(DEPRECATION "bundle_version is deprecated, use celix_bundle_version instead.") - celix_bundle_version(${ARGN}) -endfunction() - #[[ Set bundle version @@ -877,11 +827,6 @@ function(celix_bundle_version BUNDLE VERSION) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_VERSION" ${VERSION}) endfunction() -function(bundle_description) - message(DEPRECATION "bundle_description is deprecated, use celix_bundle_description instead.") - celix_bundle_description(${ARGN}) -endfunction() - #[[ Set bundle description @@ -967,11 +912,6 @@ function(celix_get_bundle_file) endif () endfunction() -function(install_bundle) - message(DEPRECATION "install_bundle is deprecated, use install_celix_bundle instead.") - install_celix_bundle(${ARGN}) -endfunction() - #[[ Install bundle when 'make install' is executed. diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake deleted file mode 100644 index 9e8095a7e..000000000 --- a/cmake/cmake_celix/DockerPackaging.cmake +++ /dev/null @@ -1,597 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -set(CELIX_DEFAULT_CONTAINER_CXX_OPTION ON CACHE BOOL "Whether the default docker options is CXX. If OFF this will be C") - - -##### setup docker target -option(CELIX_BUILD_DOCKER_USE_DOCKER "Use docker to build docker images" ON) -option(CELIX_BUILD_DOCKER_USE_DOCKER_DIR_TAR "Use docker directory tar packages packing" OFF) -if (NOT TARGET celix-build-docker-dirs) - if (APPLE) #create filesystem script is not working on mac os, exclude target from ALL - add_custom_target(celix-build-docker-dirs - DEPENDS $ - ) - else () - add_custom_target(celix-build-docker-dirs ALL - DEPENDS $ - ) - endif () - set_target_properties(celix-build-docker-dirs PROPERTIES "DOCKER_DEPS" "") #initial empty deps list -endif () - -if (CELIX_BUILD_DOCKER_USE_DOCKER) - if (NOT TARGET celix-build-docker-images) - add_custom_target(celix-build-docker-images) - set(DOCKER_USE_SUDO ON CACHE BOOL "Wether the use of sudo is needed to run docker") - set(DOCKER_CMD "docker" CACHE STRING "Docker command to use.") - - get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES) - list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/docker") - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") - endif () -endif() - -##### - -#[[ -Adds a docker target dir, containing a all the required executables, -libraries, filesystem files and selected bundles needed to run a Apache Celix framework in a docker container. - -The 'add_celix_docker' target is a executable target and can be used to link libraries which are needed in the docker image. - -The docker dir can be found in `/docker[/]/`. - -The docker directories are build with the target `celix-build-docker-dirs`, this does not create the -docker images and can also be executed on systems without docker. The `celix-build-docker-dirs` is trigger -with `make all`. - -The docker images are build with the target `celix-build-docker-images`. For this to work docker needs te installed -and the user executing the `celix-build-docker-images` should have right to create docker images. -The `celix-build-docker-images` is not triggered with `make all` - -There are three variants of 'add_celix_docker': -- If no launcher is specified a custom Celix launcher will be generated. This launcher also contains the configured properties. -- If a LAUNCHER_SRC is provided a Celix launcher will be build using the provided sources. Additional sources can be added with the - CMake 'target_sources' command. -- If a LAUNCHER (absolute path to a executable of CMake `add_executable` target) is provided that will be used as Celix launcher. - -Optional arguments: -- CXX: With this option the generated Celix launcher (if used) will be a C++ source. - This ensures that the Celix launcher is linked against stdlibc++. -- C: With this option the generated Celix launcher (if used) will be a C source. -- GROUP: If configured the build location will be prefixed the GROUP. Default is empty. -- NAME: The name of the executable. Default is . Only useful for generated/LAUNCHER_SRC Celix launchers. -- FROM: Configured the docker image base. Default is scratch. - If configured a minimal filesystem will not be created! -- BUNDLES_DIR: Configures the directory where are all the bundles are copied. Default is /bundles. -- WORKDIR: Configures the workdir of the docker image. Default is /root. -- IMAGE_NAME: Configure the image name. Default is NAME. -- BUNDLES: Configures the used bundles. These bundles are configured for run level 3. see 'celix_docker_bundles' for more info. -- PROPERTIES: Configure configuration properties. -- INSTRUCTIONS: Additional dockker instruction to add the the generated Dockerfile. - -```CMake -add_celix_docker( - [CXX] - [C] - [GROUP group_name] - [NAME deploy_name] - [FROM docker_from_image] - [BUNDLES_DIR bundle_dir_in_docker_image] - [WORKDIR workdir_in_docker_image] - [IMAGE_NAME docker_image_name] - [BUNDLES ...] - [PROPERTIES "prop1=val1" "prop2=val2" ...] - [INSTRUCTIONS "instr1" "instr2" ...] -) -``` - -```CMake -add_celix_docker( - LAUNCHER_SRC launcher_src - [CXX] - [C] - [GROUP group_name] - [NAME deploy_name] - [FROM docker_from_image] - [BUNDLES_DIR bundle_dir_in_docker_image] - [WORKDIR workdir_in_docker_image] - [IMAGE_NAME docker_image_name] - [BUNDLES ...] - [PROPERTIES "prop1=val1" "prop2=val2" ...] - [INSTRUCTIONS "instr1" "instr2" ...] -) -``` - -```CMake -add_celix_docker( - LAUNCHER launcher - [CXX] - [C] - [GROUP group_name] - [NAME deploy_name] - [FROM docker_from_image] - [BUNDLES_DIR bundle_dir_in_docker_image] - [WORKDIR workdir_in_docker_image] - [IMAGE_NAME docker_image_name] - [BUNDLES ...] - [PROPERTIES "prop1=val1" "prop2=val2" ...] - [INSTRUCTIONS "instr1" "instr2" ...] -) -``` -]] -function(add_celix_docker) - message(DEPRECATION "Support for docker creation with Celix CMake commands is deprecated and will be removed in future Celix releases.") - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - set(OPTIONS C CXX) - set(ONE_VAL_ARGS GROUP NAME FROM BUNDLES_DIR FILES_DIR WORKDIR IMAGE_NAME LAUNCHER LAUNCHER_SRC TAR_LOCATION) - set(MULTI_VAL_ARGS BUNDLES PROPERTIES INSTRUCTIONS FILES) - cmake_parse_arguments(DOCKER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) - - #set defaults - if (NOT DEFINED DOCKER_FROM) - set(DOCKER_FROM "scratch") - set(DOCKER_CREATE_FS true) - else () - set(DOCKER_CREATE_FS false) - endif () - if (NOT DEFINED DOCKER_NAME) - set(DOCKER_NAME "${DOCKER_TARGET}") - endif () - if (NOT DEFINED DOCKER_IMAGE_NAME) - set(DOCKER_IMAGE_NAME "${DOCKER_NAME}") - endif () - if (NOT DEFINED DOCKER_WORKDIR) - set(DOCKER_WORKDIR "/root") - endif () - if (NOT DEFINED DOCKER_GROUP) - set(DOCKER_LOC "${CMAKE_BINARY_DIR}/docker/${DOCKER_NAME}") - else () - set(DOCKER_LOC "${CMAKE_BINARY_DIR}/docker/${DOCKER_GROUP}/${DOCKER_NAME}") - endif () - if (NOT DEFINED DOCKER_BUNDLES_DIR) - set(DOCKER_BUNDLES_DIR "/bundles") - endif () - - #ensure the docker dir will be deleted during clean - get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES) - list(APPEND CLEANFILES "$") - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") - - if (DOCKER_LAUNCHER) - add_custom_target(${DOCKER_TARGET}) - if (IS_ABSOLUTE "${DOCKER_LAUNCHER}") - set(LAUNCHER "${DOCKER_LAUNCHER}") - get_filename_component(EXE_FILENAME ${DOCKER_LAUNCHER} NAME) - set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/${EXE_FILENAME}\"]") - else () - #assuming target - set(LAUNCHER "$") - set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/$\"]") - endif () - elseif (DOCKER_LAUNCHER_SRC) - add_executable(${DOCKER_TARGET} EXCLUDE_FROM_ALL ${DOCKER_LAUNCHER_SRC}) - target_link_libraries(${DOCKER_TARGET} PRIVATE Celix::framework) - set(LAUNCHER "$") - set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/$\"]") - else () - if (DOCKER_CXX) - set(LAUNCHER_SRC "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-main.cc") - elseif (DOCKER_C) - set(LAUNCHER_SRC "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-main.c") - else() - if (CELIX_DEFAULT_CONTAINER_CXX_OPTION) - set(LAUNCHER_SRC "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-main.cc") - else() - set(LAUNCHER_SRC "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-main.c") - endif() - endif () - - file(GENERATE - OUTPUT ${LAUNCHER_SRC} - CONTENT "#include - -int main(int argc, char *argv[]) { - const char * config = \"\\ -$,\\n\\ ->\"; - - celix_properties_t *packedConfig = celix_properties_loadFromString(config); - return celixLauncher_launchAndWaitForShutdown(argc, argv, packedConfig); -} -" - ) - - add_executable(${DOCKER_TARGET} EXCLUDE_FROM_ALL ${LAUNCHER_SRC}) - target_link_libraries(${DOCKER_TARGET} PRIVATE Celix::framework) - if(NOT APPLE) - #Add --no-as-needed options, to ensure that libraries are always linked. - #This is needed because most libraries are not used by the executable, but by the bundle libraries instead. - set_target_properties(${DOCKER_TARGET} PROPERTIES LINK_FLAGS -Wl,--no-as-needed) - endif() - set(LAUNCHER "$") - set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/$\"]") - endif () - - - ###### Setup docker custom target timestamp - add_custom_target(${DOCKER_TARGET}-deps - DEPENDS ${FS_TIMESTAMP_FILE} $ - ) - add_dependencies(${DOCKER_TARGET} ${DOCKER_TARGET}-deps) - - #setup dependencies based on timestamp - if (DOCKER_CREATE_FS) - add_custom_command(TARGET ${DOCKER_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory $ - COMMAND cd $ && /bin/bash ${CELIX_CMAKE_DIRECTORY}/create_target_filesystem.sh -e ${LAUNCHER} > /dev/null - WORKING_DIRECTORY "${DOCKER_LOC}" - COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM - ) - else () - add_custom_command(TARGET ${DOCKER_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory $/bin - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAUNCHER} $/bin/ - WORKING_DIRECTORY "${DOCKER_LOC}" - COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM - ) - endif () - - ##### Deploy Target Properties for Dockerfile ##### - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_LOC" "${DOCKER_LOC}") - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_FROM" "${DOCKER_FROM}") #name of docker base, default celix-base - set_target_properties(${DOCKER_TARGET} PROPERTIES "CONTAINER_NAME" "${DOCKER_NAME}") #name of docker celix container - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_IMAGE_NAME" "${DOCKER_IMAGE_NAME}") #name of docker images, default deploy target name - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_DIR" "${DOCKER_BUNDLES_DIR}") #bundles directory in docker image - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_0" "") #bundles for runtime level 0 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_1" "") #bundles for runtime level 1 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_2" "") #bundles for runtime level 2 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_3" "") #bundles for runtime level 3 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_4" "") #bundles for runtime level 4 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_5" "") #bundles for runtime level 5 - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_WORKDIR" "${DOCKER_WORKDIR}") #workdir in docker image, should also contain the config.properties - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_ENTRYPOINT" "${DOCKER_ENTRYPOINT}") - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_CREATE_FS" "${DOCKER_CREATE_FS}") #wether to create a fs with the minimal needed libraries / etc files - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_INSTRUCTIONS" "") #list of additional instructions - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "") - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_EMBEDDED_PROPERTIES" "") - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_DEPS" "") - - set(DOCKERFILE_STAGE1 ${CMAKE_BINARY_DIR}/celix/gen/docker/${DOCKER_TARGET}/Dockerfile.in) - set(DOCKERFILE "$/Dockerfile") - - file(GENERATE - OUTPUT "${DOCKERFILE_STAGE1}" - CONTENT "# Dockerfile for celix based image -FROM $ -ENV IMAGE_NAME $ -COPY . / -WORKDIR $ -$ -$, -> -") - file(GENERATE - OUTPUT ${DOCKERFILE} - INPUT ${DOCKERFILE_STAGE1} - ) - - #generate config.properties - set(DOCKER_PROPERTIES_FILE "${DOCKER_LOC}/${DOCKER_WORKDIR}/config.properties") - set(STAGE1_PROPERTIES_FILE "${CMAKE_BINARY_DIR}/celix/gen/docker/${DOCKER_TARGET}/docker-config-stage1.properties") - file(GENERATE - OUTPUT "${STAGE1_PROPERTIES_FILE}" - CONTENT "CELIX_AUTO_START_0=$, > -CELIX_AUTO_START_1=$, > -CELIX_AUTO_START_2=$, > -CELIX_AUTO_START_3=$, > -CELIX_AUTO_START_4=$, > -CELIX_AUTO_START_5=$, > -CELIX_CONTAINER_NAME=$ -org.osgi.framework.storage=.cache -$, -> -" - ) - file(GENERATE - OUTPUT "${DOCKER_PROPERTIES_FILE}" - INPUT "${STAGE1_PROPERTIES_FILE}" - ) - - if (DOCKER_BUNDLES) - celix_docker_bundles(${DOCKER_TARGET} LEVEL 3 ${DOCKER_BUNDLES}) - endif () - if (DOCKER_PROPERTIES) - celix_docker_properties(${DOCKER_TARGET} ${DOCKER_PROPERTIES}) - endif () - if (DOCKER_INSTRUCTIONS) - celix_docker_instructions(${DOCKER_TARGET} ${DOCKER_INSTRUCTIONS}) - endif () - if (DOCKER_FILES) - cmake_docker_add_files(${DOCKER_TARGET} FILES ${DOCKER_FILES} DESTINATION ${DOCKER_FILES_DIR}) - endif () - - get_target_property(DEPS celix-build-docker-dirs "DOCKER_DEPS") - list(APPEND DEPS ${DOCKER_TARGET}) - set_target_properties(celix-build-docker-dirs PROPERTIES "DOCKER_DEPS" "${DEPS}") - - if (CELIX_BUILD_DOCKER_USE_DOCKER) - add_custom_target(celix-build-${DOCKER_TARGET}-docker-image - COMMAND cd $ && ${DOCKER_CMD} build -t "$" . - DEPENDS ${DOCKERFILE} ${DOCKER_TARGET} - COMMENT "Creating docker image for target '${DOCKER_TARGET}'" VERBATIM - ) - add_dependencies(celix-build-docker-images celix-build-${DOCKER_TARGET}-docker-image) - endif() -endfunction() - -#[[ -Add the selected bundles to the Celix docker image. These bundles are copied to the docker build dir and -are added to the configuration properties so that they are installed and started when the Celix docker container is created and started. - -The Celix framework support 7 (0 - 6) run levels. Run levels can be used to control the start and stop order of bundles. -Bundles in run level 0 are started first and bundles in run level 6 are started last. -When stopping bundles in run level 6 are stopped first and bundles in run level 0 are stopped last. -Within a run level the order of configured decides the start order; bundles added earlier are started first. - - -Optional Arguments: -- LEVEL: The run level for the added bundles. Default is 3. - -```CMake -celix_docker_bundles( - [LEVEL (0..5)] - bundle1 - bundle2 - ... -) -``` -]] -function(celix_docker_bundles) - #0 is docker TARGET - #1..n is bundles - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - set(OPTIONS) - set(ONE_VAL_ARGS LEVEL) - set(MULTI_VAL_ARGS) - cmake_parse_arguments(BUNDLES "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) - set(BUNDLES_LIST ${BUNDLES_UNPARSED_ARGUMENTS}) - - if (NOT DEFINED BUNDLES_LEVEL) - set(BUNDLES_LEVEL 3) - endif () - - get_target_property(BUNDLES ${DOCKER_TARGET} "DOCKER_BUNDLES_LEVEL_${BUNDLES_LEVEL}") - get_target_property(BUNDLES_DIR ${DOCKER_TARGET} "DOCKER_BUNDLES_DIR") - get_target_property(LOC ${DOCKER_TARGET} "DOCKER_LOC") - get_target_property(DEPS ${DOCKER_TARGET} "DOCKER_DEPS") - - foreach (BUNDLE IN ITEMS ${BUNDLES_LIST}) - set(HANDLED FALSE) - if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE}) - get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME) - set(OUT "${LOC}/${BUNDLES_DIR}/${BUNDLE_FILENAME}") - add_custom_command(OUTPUT ${OUT} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE} ${OUT} - COMMENT "Copying (file) bundle '${BUNDLE}' to '${LOC}/${BUNDLES_DIR}'" - DEPENDS ${BUNDLE} - ) - list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE_FILENAME}") - set(HANDLED TRUE) - elseif (TARGET ${BUNDLE}) - get_target_property(TARGET_TYPE ${BUNDLE} TYPE) - if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") - #ignore - set(HANDLED TRUE) - else () - get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED) - if (IMP) #An imported bundle target -> handle target without DEPENDS - string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell) - _celix_extract_imported_bundle_info(${BUNDLE}) #extracts BUNDLE_FILE and BUNDLE_FILENAME - set(OUT "${CMAKE_BINARY_DIR}/celix/gen/docker/${DOCKER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp") - set(DEST "${LOC}/${BUNDLES_DIR}/${BUNDLE_FILENAME}") - add_custom_command(OUTPUT ${OUT} - COMMAND ${CMAKE_COMMAND} -E touch ${OUT} - COMMAND ${CMAKE_COMMAND} -E make_directory ${LOC}/${BUNDLES_DIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BUNDLE_FILE}" ${DEST} - COMMENT "Copying (imported) bundle '${BUNDLE}' to '${LOC}/${BUNDLES_DIR}'" - ) - list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE_FILENAME}") - set(HANDLED TRUE) - endif () - endif () - endif () - - if (NOT HANDLED) #assuming (future) bundle target) - string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell) - set(OUT "${CMAKE_BINARY_DIR}/celix/gen/docker/${DOCKER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp") - set(DEST "${LOC}/${BUNDLES_DIR}/$") - add_custom_command(OUTPUT ${OUT} - COMMAND ${CMAKE_COMMAND} -E touch ${OUT} - COMMAND ${CMAKE_COMMAND} -E make_directory ${LOC}/${BUNDLES_DIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" ${DEST} - COMMENT "Copying (target) bundle '${BUNDLE}' to '${LOC}/${BUNDLES_DIR}'" - DEPENDS ${BUNDLE} $ - ) - list(APPEND BUNDLES "${BUNDLES_DIR}/$") - endif () - list(APPEND DEPS "${OUT}") - endforeach () - - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_LEVEL_${BUNDLES_LEVEL}" "${BUNDLES}") - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_DEPS" "${DEPS}") -endfunction() - -#[[ -Same as `celix_container_properties`, but then for the celix container -in the docker image. - -```CMake -celix_docker_properties( - "prop1=val1" - "prop2=val2" - ... -) -``` -]] -function(celix_docker_properties) - #0 is docker TARGET - #1..n is properties - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - get_target_property(PROPS ${DOCKER_TARGET} "DOCKER_PROPERTIES") - - foreach (PROP IN ITEMS ${ARGN}) - list(APPEND PROPS ${PROP}) - endforeach () - - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "${PROPS}") -endfunction() - -#[[ -Same as `celix_container_embedded_properties`, but then for the celix container -in the docker image. - -```CMake -celix_docker_embedded_properties( - "prop1=val1" - "prop2=val2" - ... -) -``` -]] -function(celix_docker_embedded_properties) - #0 is docker TARGET - #1..n is properties - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - get_target_property(PROPS ${DOCKER_TARGET} "DOCKER_EMBEDDED_PROPERTIES") - - foreach (PROP IN ITEMS ${ARGN}) - list(APPEND PROPS ${PROP}) - endforeach () - - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_EMBEDDED_PROPERTIES" "${PROPS}") -endfunction() - -#[[ -Add the provided docker instruction to the end of the generated -Dockerfile. - -```CMake -celix_docker_instructions( - "instruction1" - "instruction2" - ... -) -``` -]] -function(celix_docker_instructions) - #0 is docker TARGET - #1..n is instructions - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - get_target_property(INSTRUCTIONS ${DOCKER_TARGET} "DOCKER_INSTRUCTIONS") - - foreach (INSTR IN ITEMS ${ARGN}) - list(APPEND INSTRUCTIONS ${INSTR}) - endforeach () - - set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_INSTRUCTIONS" "${INSTRUCTIONS}") -endfunction() - -function(cmake_docker_add_files) - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - set(OPTIONS) - set(ONE_VAL_ARGS DESTINATION) - set(MULTI_VAL_ARGS FILES) - cmake_parse_arguments(DOCKER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) - if (NOT DEFINED DOCKER_DESTINATION) - set(DOCKER_DESTINATION) - endif () - get_target_property(DOCKER_DIR_LOCATION ${DOCKER_TARGET} "DOCKER_LOC") - foreach(DOCKER_FILE IN ITEMS ${DOCKER_FILES}) - add_custom_command(TARGET ${DOCKER_TARGET} - POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${DOCKER_DIR_LOCATION}/${DOCKER_DESTINATION} - POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DOCKER_FILE}" ${DOCKER_DIR_LOCATION}/${DOCKER_DESTINATION} - COMMENT "Copying file '${DOCKER_FILE}' to '${DOCKER_DIR_LOCATION}/${DOCKER_DESTINATION}'" - ) - endforeach() -endfunction() - - -#[[ -Install docker container when 'make install' is executed and CELIX_BUILD_DOCKER_USE_DOCKER_DIR_TAR is defined. -Docker containers are installed at `/shared//containers`. - -CELIX_BUILD_DOCKER_TAR_LOCATION can be defined to override the default install-prefix. - -Optional arguments: -- PROJECT_NAME: The project name for installing. Default is the cmake project name. -- IMAGE_NAME: Configure the image name. Default is NAME. - -install_celix_docker( - [PROJECT_NAME] project_name - [IMAGE_NAME docker_image_name] -) -]] -function(install_celix_docker) - list(GET ARGN 0 DOCKER_TARGET) - list(REMOVE_AT ARGN 0) - - set(OPTIONS ) - set(ONE_VAL_ARGS PROJECT_NAME) - set(MULTI_VAL_ARGS ) - cmake_parse_arguments(DOCKER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) - - if (NOT DEFINED DOCKER_PROJECT_NAME) - string(TOLOWER ${PROJECT_NAME} DOCKER_PROJECT_NAME) - endif() - if (NOT DEFINED DOCKER_NAME) - set(DOCKER_NAME "${DOCKER_TARGET}") - endif () - if (NOT DEFINED DOCKER_IMAGE_NAME) - set(DOCKER_IMAGE_NAME "${DOCKER_NAME}") - endif () - - if(CELIX_BUILD_DOCKER_USE_DOCKER_DIR_TAR) - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${DOCKER_PROJECT_NAME}/${DOCKER_IMAGE_NAME}.tar.gz - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${DOCKER_PROJECT_NAME} - COMMAND tar czf ${CMAKE_BINARY_DIR}/${DOCKER_PROJECT_NAME}/${DOCKER_IMAGE_NAME}.tar.gz --directory=$ . - DEPENDS ${DOCKERFILE} ${DOCKER_TARGET} - COMMENT "Generating '${DOCKER_IMAGE_NAME}.tar.gz'" VERBATIM - ) - add_custom_target(${DOCKER_IMAGE_NAME}-dirs-tars ALL DEPENDS ${CMAKE_BINARY_DIR}/${DOCKER_PROJECT_NAME}/${DOCKER_IMAGE_NAME}.tar.gz) - - if (DEFINED CELIX_BUILD_DOCKER_TAR_LOCATION) - set(DOCKER_TAR_LOCATION ${CELIX_BUILD_DOCKER_TAR_LOCATION}) - endif() - if (NOT DEFINED DOCKER_TAR_LOCATION) - set(DOCKER_TAR_LOCATION shared) - endif() - install(FILES ${CMAKE_BINARY_DIR}/${DOCKER_PROJECT_NAME}/${DOCKER_IMAGE_NAME}.tar.gz DESTINATION ${DOCKER_TAR_LOCATION}/${DOCKER_PROJECT_NAME}/containers) - endif() -endfunction() \ No newline at end of file diff --git a/cmake/cmake_celix/Runtimes.cmake b/cmake/cmake_celix/Runtimes.cmake deleted file mode 100644 index 925d5772a..000000000 --- a/cmake/cmake_celix/Runtimes.cmake +++ /dev/null @@ -1,253 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -if (NOT TARGET celix-runtimes) - add_custom_target(celix-runtimes ALL - DEPENDS "$" - ) - set_target_properties(celix-runtimes PROPERTIES "DEPS" "") - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/runtimes") -endif () - -function(add_runtime) - message(DEPRECATION "add_celix_runtime is deprecated, and will be removed in future Celix releases.") - add_celix_runtime(${ARGN}) -endfunction() -function(add_celix_runtime) - message(DEPRECATION "add_celix_runtime is deprecated, and will be removed in future Celix releases.") - list(GET ARGN 0 RUNTIME_TARGET_NAME) - list(REMOVE_AT ARGN 0) - - set(OPTIONS USE_TERM LOG_TO_FILES) - set(ONE_VAL_ARGS WAIT_FOR NAME GROUP) - set(MULTI_VAL_ARGS DEPLOYMENTS CONTAINERS COMMANDS ARGUMENTS RELEASE_FILES) - cmake_parse_arguments(RUNTIME "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) - - if (NOT DEFINED RUNTIME_NAME) - set(RUNTIME_NAME ${RUNTIME_TARGET_NAME}) - endif () - if (NOT DEFINED RUNTIME_GROUP) - set(RUNTIME_LOC "${CMAKE_BINARY_DIR}/runtimes/${RUNTIME_NAME}") - else () - set(RUNTIME_LOC "${CMAKE_BINARY_DIR}/runtimes/${RUNTIME_GROUP}/${RUNTIME_NAME}") - endif () - set(TIMESTAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${RUNTIME_TARGET_NAME}-runtime-timestamp") - - set(START_SCRIPT "$/start.sh") - set(STOP_SCRIPT "$/stop.sh") - set(COMMON_SCRIPT "$/common.sh") - - add_custom_command(OUTPUT "${TIMESTAMP_FILE}" - COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE} - COMMAND ${CMAKE_COMMAND} -E make_directory $ - COMMAND chmod +x $/start.sh - COMMAND chmod +x $/stop.sh - DEPENDS ${START_SCRIPT} ${STOP_SCRIPT} ${SETUP_SCRIPT} - WORKING_DIRECTORY "${RUNTIME_LOC}" - COMMENT "Creating runtime ${RUNTIME_TARGET_NAME}" VERBATIM - ) - add_custom_target(${RUNTIME_TARGET_NAME} - DEPENDS "${TIMESTAMP_FILE}" - ) - - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_CONTAINERS" "") #containers that should be runned - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_COMMANDS" "") #command that should be executed - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_ARGUMENTS" "") #potential arguments to use for deployments - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RELEASE_FILES" "") #release files which needs to be released before starting the containers/commands - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_NAME" "${RUNTIME_NAME}") #The runtime workdir - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_GROUP" "${RUNTIME_GROUP}") #The runtime workdir - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_LOC" "${RUNTIME_LOC}") #The runtime workdir - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_USE_TERM" "${RUNTIME_USE_TERM}") #Wether or not the use terminal - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_LOG_TO_FILES" "${RUNTIME_LOG_TO_FILES}") #log to files or std out/err - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_NEXT_CONTAINER_ID" "0") #used for indexes int he bash scripts - - #wait for deployment, e.g. the one that control the lifecycle of the runtime. - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_WAIT_FOR_CONTAINER" "") - - #wait for command, e.g. the one that control the lifecycle of the runtime. - set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_WAIT_FOR_COMMAND" "") - - - #replaces @RUNTIME_TARGET_NAME@ - configure_file("${CELIX_CMAKE_DIRECTORY}/runtime_start.sh.in" "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/start.sh.in.1" @ONLY) - configure_file("${CELIX_CMAKE_DIRECTORY}/runtime_stop.sh.in" "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/stop.sh.in.1" @ONLY) - configure_file("${CELIX_CMAKE_DIRECTORY}/runtime_common.sh.in" "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/common.sh.in.1" @ONLY) - - - file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/common.sh.in.2" - INPUT "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/common.sh.in.1" - ) - file(GENERATE - OUTPUT "${START_SCRIPT}" - INPUT "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/start.sh.in.1" - ) - file(GENERATE - OUTPUT "${STOP_SCRIPT}" - INPUT "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/stop.sh.in.1" - ) - - - file(GENERATE - OUTPUT "${COMMON_SCRIPT}" - INPUT "${CMAKE_BINARY_DIR}/celix/gen/runtimes/${RUNTIME_TARGET_NAME}/common.sh.in.2" - ) - - get_target_property(DEPS celix-runtimes "DEPS") - list(APPEND DEPS "${RUNTIME_TARGET_NAME}") - set_target_properties(celix-runtimes PROPERTIES "DEPS" "${DEPS}") - - celix_runtime_containers(${RUNTIME_TARGET_NAME} ${RUNTIME_DEPLOYMENTS}) - celix_runtime_containers(${RUNTIME_TARGET_NAME} ${RUNTIME_CONTAINERS}) - celix_runtime_commands(${RUNTIME_TARGET_NAME} ${RUNTIME_COMMANDS}) - celix_runtime_arguments(${RUNTIME_TARGET_NAME} ${RUNTIME_ARGUMENTS}) - celix_runtime_release_files(${RUNTIME_TARGET_NAME} ${RUNTIME_RELEASE_FILES}) - - if (RUNTIME_WAIT_FOR) - celix_runtime_container_wait_for(${RUNTIME_TARGET_NAME} ${RUNTIME_WAIT_FOR}) - endif () - -endfunction() - -function(runtime_use_term) - message(DEPRECATION "runtime_use_term is depecrated, use celix_runtime_use_term instead.") - celix_runtime_use_term(${ARGN}) -endfunction() -function(celix_runtime_use_term) - #0 is runtime TARGET - #1 is BOOL (use xterm) - list(GET ARGN 0 RUNTIME_NAME) - list(GET ARGN 1 USE_TERM) - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_USE_TERM" "${USE_TERM}") -endfunction() - -function(runtime_log_to_files) - message(DEPRECATION "runtime_log_to_files is depecrated, use celix_runtime_log_to_files instead.") - celix_runtime_log_to_files(${ARGN}) -endfunction() -function(celix_runtime_log_to_files) - #0 is runtime TARGET - #1 is BOOL (log to files) - list(GET ARGN 0 RUNTIME_NAME) - list(GET ARGN 1 LOG_TO_FILES) - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_LOG_TO_FILES" "${LOG_TO_FILES}") -endfunction() - -function(runtime_deployments) - message(DEPRECATION "runtime_deployments is depecrated, use celix_runtime_containers instead.") - celix_runtime_containers(${ARGN}) -endfunction() -function(celix_runtime_containers) - #0 is runtime TARGET - #1..n is deployments - list(GET ARGN 0 RUNTIME_NAME) - list(REMOVE_AT ARGN 0) - - get_target_property(CONTAINERS ${RUNTIME_NAME} "RUNTIME_CONTAINERS") - foreach(CONTAINER IN ITEMS ${ARGN}) - get_target_property(DEP_ID ${RUNTIME_NAME} "RUNTIME_NEXT_CONTAINER_ID") - math(EXPR DEP_ID "${DEP_ID}+1") - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_DEPLOYMENT_${CONTAINER}_ID" "${DEP_ID}") - list(APPEND CONTAINERS "CONTAINERS_NAMES[${DEP_ID}]=\"$\"") - list(APPEND CONTAINERS "CONTAINERS_DIRS[${DEP_ID}]=\"$\"") - list(APPEND CONTAINERS "CONTAINERS_DEBUG_OPTS[${DEP_ID}]=\"\${${CONTAINER}_DEBUG_OPTS:-}\"") - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_NEXT_CONTAINER_ID" "${DEP_ID}") - endforeach() - - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_CONTAINERS" "${CONTAINERS}") -endfunction() - -function(runtime_deployment_wait_for) - message(DEPRECATION "runtime_deployment_wait_for is depecrated, use celix_runtime_container_wait_for instead.") - celix_runtime_container_wait_for(${ARGN}) -endfunction() -function(celix_runtime_container_wait_for) - #0 is runtime TARGET - #1 is deployment TARGET - list(GET ARGN 0 RUNTIME_NAME) - list(GET ARGN 1 CONTAINER) - - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_CONTAINER" "$") - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_COMMAND" "") -endfunction() - -function(runtime_commands) - message(DEPRECATION "runtime_commands is depecrated, use celix_runtime_commands instead.") - celix_runtime_commands(${ARGN}) -endfunction() -function(celix_runtime_commands) - #0 is runtime TARGET - #1..n is commands - list(GET ARGN 0 RUNTIME_NAME) - list(REMOVE_AT ARGN 0) - - get_target_property(COMMANDS ${RUNTIME_NAME} "RUNTIME_COMMANDS") - foreach(CMD IN ITEMS ${ARGN}) - list(APPEND COMMANDS ${CMD}) - endforeach() - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_COMMANDS" "${COMMANDS}") -endfunction() - -function(runtime_command_wait_for) - message(DEPRECATION "runtime_command_wait_for is depecrated, use celix_runtime_command_wait_for instead.") - celix_runtime_command_wait_for(${ARGN}) -endfunction() -function(celix_runtime_command_wait_for) - #0 is runtime TARGET - #1 is COMMAND STR - list(GET ARGN 0 RUNTIME_NAME) - list(GET ARGN 1 COMMAND) - - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_COMMAND" "${COMMAND}") - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_CONTAINER" "") -endfunction() - -function(runtime_arguments) - message(DEPRECATION "runtime_arguments is depecrated, use celix_runtime_arguments instead.") - celix_runtime_arguments(${ARGN}) -endfunction() -function(celix_runtime_arguments) - #0 is runtime TARGET - #1..n is commands - list(GET ARGN 0 RUNTIME_NAME) - list(REMOVE_AT ARGN 0) - - get_target_property(ARGUMENTS ${RUNTIME_NAME} "RUNTIME_ARGUMENTS") - list(LENGTH ARGN ARG_LENGTH) - if (${ARG_LENGTH} GREATER 1) - foreach(I RANGE 1 ${ARG_LENGTH} 2) - math(EXPR IMINUS "${I}-1") - list(GET ARGN ${IMINUS} DEPLOY_NAME) - list(GET ARGN ${I} DEPLOY_ARGS) - list(APPEND ARGUMENTS "CONTAIMER_ARGUMENTS[$]=\"${DEPLOY_ARGS}\"") - endforeach() - endif () - set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_ARGUMENTS" "${ARGUMENTS}") -endfunction() - -function(celix_runtime_release_files) - #0 is runtime TARGET - #1..n is release files - list(GET ARGN 0 RUNTIME_NAME) - list(REMOVE_AT ARGN 0) - - get_target_property(RELEASE_FILES ${RUNTIME_NAME} "RELEASE_FILES") - foreach(RELEASE_FILE IN ITEMS ${ARGN}) - list(APPEND RELEASE_FILES "source ${RELEASE_FILE}") - endforeach() - set_target_properties(${RUNTIME_NAME} PROPERTIES "RELEASE_FILES" "${RELEASE_FILES}") -endfunction() diff --git a/cmake/cmake_celix/UseCelix.cmake b/cmake/cmake_celix/UseCelix.cmake index 507715937..26d94619b 100644 --- a/cmake/cmake_celix/UseCelix.cmake +++ b/cmake/cmake_celix/UseCelix.cmake @@ -21,10 +21,7 @@ include(CMakeParseArguments) set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CELIX_CMAKE_DIRECTORY}/../Modules") - #Celix CMake function include(${CELIX_CMAKE_DIRECTORY}/BundlePackaging.cmake) include(${CELIX_CMAKE_DIRECTORY}/ContainerPackaging.cmake) -include(${CELIX_CMAKE_DIRECTORY}/DockerPackaging.cmake) -include(${CELIX_CMAKE_DIRECTORY}/Runtimes.cmake) include(${CELIX_CMAKE_DIRECTORY}/Generic.cmake) diff --git a/cmake/cmake_celix/create_target_filesystem.sh b/cmake/cmake_celix/create_target_filesystem.sh deleted file mode 100644 index 96964f327..000000000 --- a/cmake/cmake_celix/create_target_filesystem.sh +++ /dev/null @@ -1,215 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/bin/bash - -declare -A EXE_ARGUMENTS -EXE_INDEX=0 -declare -A LIB_ARGUMENTS -LIB_INDEX=0 -declare -A BUNDLE_ARGUMENTS -BUNDLE_INDEX=0 - -while [ -n "${1}" ] -do - ARG="${1}" - case $ARG in - -h|--help) - echo "Usage ${0} [-e executable].. [-l library].. [-b bundle].." - exit 0 - ;; - -e|--executable) - EXE_ARGUMENTS[${EXE_INDEX}]="${2}" - EXE_INDEX=$((EXE_INDEX+1)) - shift - ;; - -l|--lib) - LIB_ARGUMENTS[${LIB_INDEX}]="${2}" - LIB_INDEX=$((LIB_INDEX+1)) - shift - ;; - -b|--bundle) - BUNDLE_ARGUMENTS[${BUNDLE_INDEX}]="${2}" - BUNDLE_INDEX=$((BUNDLE_INDEX+1)) - shift - ;; - *) - echo "unknown option '${ARG}'" - ;; - esac - shift -done - -celix_add_file() { - FILE=$1 - TO_DIR=$2 - if [ -f ${FILE} ] - then #is regular file and not symlink - if [ -n "${TO_DIR}" ]; then - DIR=${TO_DIR} - elif [[ "${FILE}" =~ ^/.* ]]; then #absolute path - DIR=.$(dirname ${FILE}) - else - DIR=$(dirname ${FILE}) - fi - - mkdir -p ${DIR} 2> /dev/null - cp -vu ${FILE} ${DIR}/ - else - echo "Skipping file ${FILE}" - fi -} - -celix_add_bundle() { - BUNDLE=$1 - if [ -e ${BUNDLE} ] - then - BUNDLE_DIR=bundles - mkdir -p ${BUNDLES_DIR} 2> /dev/null - cp -vu ${BUNDLE} ${BUNDLES_DIR}/ - else - echo "Bundle '${BUNDLE}' does not exists!" - fi -} - -celix_add_lib() { - LIB=$1 - for DEP in $(ldd ${LIB} | grep lib | awk '{print $3}') - do - celix_add_file ${DEP} lib64 - done - - #the ld-linux library is handled separately - LDLIB=$(ldd ${EXE} | grep ld-linux | awk '{print $1}') - if [ -n ${LDLIB} ] - then - celix_add_file ${LDLIB} lib64 - fi -} - -celix_add_libs_for_exe() { - EXE=$1 - for LIB in $(ldd ${EXE} | grep lib | awk '{print $3}') - do - celix_add_file ${LIB} lib64 - done - - #the ld-linux library is handled separately - LDLIB=$(ldd ${EXE} | grep ld-linux | awk '{print $1}') - if [ -n ${LDLIB} ] - then - celix_add_file ${LDLIB} lib64 - fi -} - -celix_add_exe() { - EXE=$1 - celix_add_libs_for_exe ${EXE} - - #if [[ "${EXE}" =~ ^/.* ]]; then - # DIR=.$(dirname ${EXE}) - #else - # #for relative paths use usr/bin - # DIR=usr/bin - #fi - - #Always put executables in /bin - DIR=bin - - mkdir -p ${DIR} 2> /dev/null - cp -vu ${EXE} ${DIR}/ -} - -celix_add_required_libs() { - if [ ! -d /lib64 ] - then - echo "ERROR: Assuming 64 bit architecture for docker creating. Created filesystem will not be valid" - fi - #LIBS=$(ls -1 /lib64/ld-linux* /lib64/libnss_dns* /lib64/libnss_files*) - LIBS=$(ls -1 /lib64/ld-linux* /lib64/libnss_dns* /lib64/libnss_files* /lib/x86_64-linux-gnu/libnss_dns* /lib/x86_64-linux-gnu/libnss_files* 2> /dev/null) - for LIB in ${LIBS} - do - celix_add_file ${LIB} - done -} - -for INDEX in "${!EXE_ARGUMENTS[@]}" -do - EXE=${EXE_ARGUMENTS[${INDEX}]} - echo "Adding exe ${EXE}" - celix_add_exe ${EXE} -done - -for INDEX in "${!LIB_ARGUMENTS[@]}" -do - LIB=${LIB_ARGUMENTS[${INDEX}]} - echo "Adding lib ${LIB}" - celix_add_lib ${LIB} -done - -for INDEX in "${!BUNDLE_ARGUMENTS[@]}" -do - BUNDLE=${BUNDLE_ARGUMENTS[${INDEX}]} - echo "Adding bundle ${BUNDLE}" - celix_add_bundle ${BUNDLE} -done - - -mkdir root 2> /dev/null - -echo "Creating minimal etc dir" - -mkdir etc 2> /dev/null -if [ ! -f etc/group ] -then - echo """root:x:0: -bin:x:1: -daemon:x:2: -adm:x:4: -lp:x:7: -mail:x:12: -games:x:20: -ftp:x:50: -nobody:x:99: -users:x:100: -nfsnobody:x:65534:""" > etc/group -fi - -if [ ! -f etc/nsswitch.conf ] -then - echo """passwd: files -shadow: files -group: files -hosts: files dns""" > etc/nsswitch.conf -fi - -if [ ! -f etc/passwd ] -then - echo """root:x:0:0:root:/root:/bin/bash -bin:x:1:1:bin:/bin:/sbin/nologin -daemon:x:2:2:daemon:/sbin:/sbin/nologin -adm:x:3:4:adm:/var/adm:/sbin/nologin -lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin -sync:x:5:0:sync:/sbin:/bin/sync -shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown -halt:x:7:0:halt:/sbin:/sbin/halt -mail:x:8:12:mail:/var/spool/mail:/sbin/nologin -operator:x:11:0:operator:/root:/sbin/nologin -games:x:12:100:games:/usr/games:/sbin/nologin -ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin -nobody:x:99:99:Nobody:/:/sbin/nologin""" > etc/passwd -fi - -celix_add_required_libs diff --git a/cmake/cmake_celix/runtime_common.sh.in b/cmake/cmake_celix/runtime_common.sh.in deleted file mode 100644 index 2a438529c..000000000 --- a/cmake/cmake_celix/runtime_common.sh.in +++ /dev/null @@ -1,230 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/bin/bash - -#Locations -BUILD_DIR="${BUILD_DIR:-@PROJECT_BINARY_DIR@}" -RUNTIME_DIR="${RUNTIME_DIR:-$}" -DEPLOY_DIR="${DEPLOY_DIR:-${BUILD_DIR}/deploy}" - -#Name & Group -RUNTIME_NAME="${RUNTIME_NAME:-$}" -RUNTIME_GROUP="${RUNTIME_GROUP:-$}" - -#commands -COMMANDS=${COMMANDS:-"$, >"} - -#containers -$, -> - -#container arguments -$, -> - -#release files -$, -> - -#Options -TERM_CMD="${TERM_CMD:-xterm}" -TERM_OPTS="${TERM_OPTS:-}" -USE_TERM="${USE_TERM:-$}" -RELEASE_SH="${RELEASE_SH:-}" -WAIT_FOR_CONTAINER="${WAIT_FOR_CONTAINER:-$}" -WAIT_FOR_CMD="${WAIT_FOR_CMD:-$}" -LOG_TO_FILES="${LOG_TO_FILES:-$}" -KILL_OPTS="${KILL_OPTS:--2}" #default is -2, e.g. SIGINT -PATIENCE="${PATIENCE:-5}" #in seconds - -PIDS="" -RUNTIME_STARTTIME=$(date +"%s") -trap stop_all INT - -##functions -function rt_init() { - rm -fr ${RUNTIME_DIR}/run #contains pids, etc - rm -fr ${RUNTIME_DIR}/logs - mkdir ${RUNTIME_DIR}/run - mkdir ${RUNTIME_DIR}/logs - echo "Name: ${RUNTIME_NAME}" > ${RUNTIME_DIR}/logs/init.log - echo "Start time: ${RUNTIME_STARTTIME}" >> ${RUNTIME_DIR}/logs/init.log -} - -function rt_start_all() { - echo "" - echo "" - echo "********** Starting runtime ${RUNTIME_NAME} **********" - for CONTAINERS_INDEX in "${!CONTAINERS_NAMES[@]}" - do - rt_run_deployment ${CONTAINERS_INDEX} - done - - for CMD in ${COMMANDS}; do - rt_run_cmd "${CMD}" - done -} - -function rt_stop_all() { - echo "********** Stopping runtime ${RUNTIME_NAME} **********" - for PID in ${PIDS}; do - echo "Sending signal to ${PID}" - kill ${KILL_OPTS} ${PID} 2> /dev/null; true - done -} - -function rt_stop() { - PIDS=$@ - echo "Stopping pids ${PIDS}" - kill ${KILL_OPTS} ${PIDS} 2> /dev/null; true -} - -function rt_run_deployment() { - INDEX=$1 - DEPLOYMENT=${CONTAINERS_NAMES[${INDEX}]} - CONTAINERS_DIR=${CONTAINERS_DIRS[${INDEX}]} - ARGS=${CONTAINERS_ARGUMENTS[${INDEX}]} - LOG_FILE="${RUNTIME_DIR}/logs/${DEPLOYMENT}.log" - DEBUG_OPTS=${CONTAINERS_DEBUG_OPTS[${INDEX}]} - - echo "" - echo "Starting deployment ${DEPLOYMENT}" - cd ${CONTAINERS_DIR} - if [ -d .cache ] ; then - echo " Clearing cache" - rm -fr .cache - fi - if [ -e release.sh ] ; then - . ./release.sh #run deployment release - fi - echo " Workdir: ${CONTAINERS_DIR}" - echo " Cmd used: '${DEBUG_OPTS} ./${DEPLOYMENT} ${ARGS}'" - if [ "${USE_TERM}" = "TRUE" ] ; then - if [ "${LOG_TO_FILES}" = "TRUE" ] ; then - echo " Using log file ${LOG_FILE}" - ${TERM_CMD} ${TERM_OPTS} -e "${DEBUG_OPTS} ./${DEPLOYMENT} ${ARGS} &> ${LOG_FILE}" &> /dev/null & - else - ${TERM_CMD} ${TERM_OPTS} -e "${DEBUG_OPTS} ./${DEPLOYMENT} ${ARGS}" &> /dev/null & - fi - else #run in this shell - if [ "${LOG_TO_FILES}" = "TRUE" ] ; then - echo " Using log file ${LOG_FILE}" - ${DEBUG_OPTS} ./${DEPLOYMENT} ${ARGS} &> ${LOG_FILE} & - else - ${DEBUG_OPTS} ./${DEPLOYMENT} ${ARGS} & - fi - fi - PID=$! - echo " Pid of deployment '${DEPLOYMENT}' is ${PID}" - if [ ! -z "${WAIT_FOR_CONTAINER}" -a "${CONTAINERS_DIR}" = "${WAIT_FOR_CONTAINER}" ] ; then - WAIT_FOR_PID=${PID} - echo "${PID}" > ${RUNTIME_DIR}/run/wait_for_pid - else - PIDS="${PID} ${PIDS}" - echo "${PIDS}" > ${RUNTIME_DIR}/run/pids - fi - cd - > /dev/null -} - -function rt_run_cmd() { - CMD="$1" - echo "" - echo "Starting command '${CMD}'" - read CMD_NAME _ <<< ${CMD} - LOG_FILE="${RUNTIME_DIR}/logs/${CMD_NAME}.log" - WD="${RUNTIME_DIR}/${CMD_NAME}" - if [ -d {WD} ] ; then - echo " Clearing previous workdir for command '${CMD}'" - rm -fr ${WD} - fi - echo " Workdir: ${WD}" - mkdir -p ${WD} - cd ${WD} - if [ "${USE_TERM}" = "TRUE" ] ; then - if [ "${LOG_TO_FILES}" = "TRUE" ] ; then - echo " Using log file ${LOG_FILE}" - ${TERM_CMD} ${TERM_OPTS} -e "${CMD} &> ${LOG_FILE}" &> /dev/null & - else - ${TERM_CMD} ${TERM_OPTS} -e "${CMD}" &> /dev/null & - fi - else - if [ "${LOG_TO_FILES}" = "TRUE" ] ; then - echo " Using log file ${LOG_FILE}" - ${CMD} &> ${LOG_FILE} & - else - ${CMD} & - fi - fi - PID=$! - echo " Pid of command '${CMD}' is ${PID}" - if [ ! -z "${WAIT_FOR_CMD}" -a "${CMD}" = "${MWAIT_FOR_CMD}" ] ; then - WAIT_FOR_PID=${PID} - echo "${PID}" > ${RUNTIME_DIR}/run/wait_for_pid - else - PIDS="${PID} ${PIDS}" - echo "${PIDS}" > ${RUNTIME_DIR}/run/pids - fi - cd - > /dev/null -} - -function rt_wait_for() { - RESULT=0 - echo "" - echo "Waiting for pid ${WAIT_FOR_PID}" - if wait ${WAIT_FOR_PID}; then - echo "${WAIT_FOR_PID} exited normal" - else - echo "${WAIT_FOR_PID} exited with error" - RESULT=1 - fi - - echo "Signalling pids '${PIDS}' with '${KILL_OPTS}'" - kill ${KILL_OPTS} ${PIDS} - echo -n "Waiting " - TIMES=${PATIENCE} - for (( I=1; I<=TIMES; I++ )) - do - echo -n "." - kill -0 ${PIDS} &> /dev/null - if [ $? -eq 1 ] ; then #e.g. no such process result - #all process stopped - break - else - sleep 1 - fi - done - echo "" - - for PID in ${PIDS}; do - kill -0 ${PID} &> /dev/null - if [ $? -eq 0 ] ; then - NAME=$(ps -p ${PID} -o comm | tail -n 1) - echo "Out of patience, killing process '${NAME}' (${PID}), with kill -9" - kill -9 ${PID} - fi - done -} - - -if [ -z "${RELEASE_SH}" ] ; then - true #pass -elif [ -e "${RELEASE_SH}" ]; then #absolute release file - source ${RELEASE_SH} -elif [ -e "${RUNTIME_DIR}/${RELEASE_SH}" ] ; then #release file in runtime dir - source ${RUNTIME_DIR}/${RELEASE_SH} -elif [ -e "${BUILD_DIR}/${RELEASE_SH}" ] ; then #release file in build dir - source ${BUILD_DIR}/${RELEASE_SH} -fi diff --git a/cmake/cmake_celix/runtime_start.sh.in b/cmake/cmake_celix/runtime_start.sh.in deleted file mode 100644 index ea1668968..000000000 --- a/cmake/cmake_celix/runtime_start.sh.in +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/bin/bash - -source $/common.sh - -rt_init -rt_start_all - -if [ ! -z "${WAIT_FOR_PID}" ] ; then - rt_wait_for #sets RESULT - echo "********** Runtime ${RUNTIME_NAME} result is ${RESULT} **********" - exit ${RESULT} -fi - - - - diff --git a/cmake/cmake_celix/runtime_stop.sh.in b/cmake/cmake_celix/runtime_stop.sh.in deleted file mode 100644 index 4c4c7fc66..000000000 --- a/cmake/cmake_celix/runtime_stop.sh.in +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/bin/bash - -source $/common.sh - -#Options -USE_SIGNAL=${USE_SIGNAL:-} - -#TODO parse option to easily select kill -9 - -if [ -e ${RUNTIME_DIR}/run/main_pid ] ; then - MAIN_PID=$(cat ${RUNTIME_DIR}/run/wait_for_pid) - rt_stop ${MAIN_PID} -fi - -if [ -e ${RUNTIME_DIR}/run/pids ] ; then - PIDS=$(cat ${RUNTIME_DIR}/run/pids) - rt_stop ${PIDS} -fi -