Skip to content

Commit

Permalink
CELIX-408: Adds some needed linking setup for OSX. Refactors runtime …
Browse files Browse the repository at this point in the history
…scripts to use indexed bash array instead of associative bash arrays.

- Associative bash array are support from bash v4, OSX Sierra still default uses bash v3
  • Loading branch information
pnoltes committed Apr 13, 2017
1 parent 4b723e4 commit ac4babf
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
16 changes: 11 additions & 5 deletions cmake/cmake_celix/Runtimes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function(add_runtime)
set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_LOCATION" "${RUNTIME_LOCATION}") #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_DEPLOYMENT_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_DEPLOYMENT" "")
Expand Down Expand Up @@ -123,8 +124,12 @@ function(runtime_deployments)

get_target_property(DEPLOYMENTS ${RUNTIME_NAME} "RUNTIME_DEPLOYMENTS")
foreach(DEPLOYMENT IN ITEMS ${ARGN})
list(APPEND DEPLOYMENTS "DEPLOYMENTS[$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_NAME>]=\"$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>\"")
#list(APPEND DEPLOYMENTS "$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>")
get_target_property(DEP_ID ${RUNTIME_NAME} "RUNTIME_NEXT_DEPLOYMENT_ID")
math(EXPR DEP_ID "${DEP_ID}+1")
set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_DEPLOYMENT_${DEPLOYMENT}_ID" "${DEP_ID}")
list(APPEND DEPLOYMENTS "DEPLOYMENT_NAMES[${DEP_ID}]=\"$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_NAME>\"")
list(APPEND DEPLOYMENTS "DEPLOYMENT_DIRS[${DEP_ID}]=\"$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>\"")
set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_NEXT_DEPLOYMENT_ID" "${DEP_ID}")
endforeach()

set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_DEPLOYMENTS" "${DEPLOYMENTS}")
Expand Down Expand Up @@ -174,9 +179,10 @@ function(runtime_arguments)
if (${ARG_LENGTH} GREATER 1)
foreach(I RANGE 1 ${ARG_LENGTH} 2)
math(EXPR IMINUS "${I}-1")
list(GET ARGN ${IMINUS} ARG_NAME)
list(GET ARGN ${I} ARG_VAL)
list(APPEND ARGUMENTS "ARGUMENTS[$<TARGET_PROPERTY:${ARG_NAME},DEPLOY_NAME>]=\"${ARG_VAL}\"")
list(GET ARGN ${IMINUS} DEPLOY_NAME)
list(GET ARGN ${I} DEPLOY_ARGS)
get_target_property(TEST ${RUNTIME_NAME} "RUNTIME_DEPLOYMENT_${DEPLOY_NAME}_ID")
list(APPEND ARGUMENTS "DEPLOYMENT_ARGUMENTS[$<TARGET_PROPERTY:${RUNTIME_NAME},RUNTIME_DEPLOYMENT_${DEPLOY_NAME}_ID>]=\"${DEPLOY_ARGS}\"")
endforeach()
endif ()
set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_ARGUMENTS" "${ARGUMENTS}")
Expand Down
21 changes: 11 additions & 10 deletions cmake/cmake_celix/runtime_common.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

#Locations
BUILD_DIR="${BUILD_DIR:-@PROJECT_BINARY_DIR@}"
Expand All @@ -9,14 +9,14 @@ DEPLOY_DIR="${DEPLOY_DIR:-${BUILD_DIR}/deploy}"
RUNTIME_NAME="${RUNTIME_NAME:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_NAME>}"
RUNTIME_GROUP="${RUNTIME_NAME:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_GROUP>}"

#deployments & commands
#commands
COMMANDS=${COMMANDS:-"$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_COMMANDS>, >"}

declare -A DEPLOYMENTS
#deployments
$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_DEPLOYMENTS>,
>

declare -A ARGUMENTS
#deployment arguments
$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_ARGUMENTS>,
>

Expand Down Expand Up @@ -50,9 +50,9 @@ function rt_start_all() {
echo ""
echo ""
echo "********** Starting runtime ${RUNTIME_NAME} **********"
for DEPLOYMENT in "${!DEPLOYMENTS[@]}"
for DEPLOYMENT_INDEX in "${!DEPLOYMENT_NAMES[@]}"
do
rt_run_deployment ${DEPLOYMENT}
rt_run_deployment ${DEPLOYMENT_INDEX}
done

for CMD in ${COMMANDS}; do
Expand All @@ -75,9 +75,10 @@ function rt_stop() {
}

function rt_run_deployment() {
DEPLOYMENT=$1
DEPLOYMENT_DIR=${DEPLOYMENTS[${DEPLOYMENT}]}
ARGS=${ARGUMENTS[${DEPLOYMENT}]}
INDEX=$1
DEPLOYMENT=${DEPLOYMENT_NAMES[${INDEX}]}
DEPLOYMENT_DIR=${DEPLOYMENT_DIRS[${INDEX}]}
ARGS=${DEPLOYMENT_ARGUMENTS[${INDEX}]}
LOG_FILE="${RUNTIME_DIR}/logs/${DEPLOYMENT}.log"
echo ""
echo "Starting deployment ${DEPLOYMENT}"
Expand Down Expand Up @@ -204,4 +205,4 @@ 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
fi
3 changes: 2 additions & 1 deletion cmake/cmake_celix/runtime_start.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/bin/bash

source $<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_LOCATION>/common.sh

rt_init
Expand Down
2 changes: 1 addition & 1 deletion cmake/cmake_celix/runtime_stop.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source $<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_LOCATION>/common.sh

Expand Down
2 changes: 1 addition & 1 deletion pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (PUBSUB)


if (ENABLE_TESTING)
option(BUILD_PUBSUB_TESTS "Enable Tests for PUBSUB" ON)
option(BUILD_PUBSUB_TESTS "Enable Tests for PUBSUB" OFF)
endif()
if (ENABLE_TESTING AND BUILD_PUBSUB_TESTS)
add_subdirectory(test)
Expand Down
8 changes: 8 additions & 0 deletions pubsub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_bundle(pubsub_sut
test/sut_activator.c
VERSION 1.0.0
)
target_link_libraries(pubsub_sut celix_framework celix_utils)
bundle_files(pubsub_sut
msg_descriptors/msg.descriptor
msg_descriptors/sync.descriptor
Expand Down Expand Up @@ -63,6 +64,13 @@ add_bundle(pubsub_tst
test/tst_activator.cpp
VERSION 1.0.0
)
if (APPLE)
#Note that the launcher celix_test_runner is linked with CppuTest, not the bundle libs. Default libCppUTest.a is not compiled for relocation
target_link_libraries(pubsub_tst celix_framework celix_utils -Wl,-undefined -Wl,dynamic_lookup)
else ()
target_link_libraries(pubsub_tst celix_framework celix_utils)
endif ()

bundle_files(pubsub_tst
msg_descriptors/msg.descriptor
msg_descriptors/sync.descriptor
Expand Down

0 comments on commit ac4babf

Please sign in to comment.