Repository: celix Updated Branches: refs/heads/develop 1ba4184c4 -> b6ac4103c
CELIX-356: Adds support for import libraries with the add_bundle and bundle_import_libs command. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/b6ac4103 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/b6ac4103 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/b6ac4103 Branch: refs/heads/develop Commit: b6ac4103c88193c813e3c06722ffdb53cf7e4d20 Parents: 1ba4184 Author: Pepijn Noltes <[email protected]> Authored: Fri Apr 22 15:17:49 2016 +0200 Committer: Pepijn Noltes <[email protected]> Committed: Fri Apr 22 15:17:49 2016 +0200 ---------------------------------------------------------------------- cmake/cmake_celix/Packaging.cmake | 32 +++++++++++++++------ examples/hello_world/CMakeLists.txt | 22 +++++++++++---- examples/hello_world/private/src/activator.c | 2 ++ examples/hello_world/private/src/test2.c | 32 +++++++++++++++++++++ examples/hello_world/public/include/test2.h | 34 +++++++++++++++++++++++ 5 files changed, 109 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/b6ac4103/cmake/cmake_celix/Packaging.cmake ---------------------------------------------------------------------- diff --git a/cmake/cmake_celix/Packaging.cmake b/cmake/cmake_celix/Packaging.cmake index 3cb1b71..663ff1a 100644 --- a/cmake/cmake_celix/Packaging.cmake +++ b/cmake/cmake_celix/Packaging.cmake @@ -104,7 +104,7 @@ function(add_bundle) set(OPTIONS NO_ACTIVATOR) set(ONE_VAL_ARGS VERSION ACTIVATOR SYMBOLIC_NAME NAME DESCRIPTION) - set(MULTI_VAL_ARGS SOURCES PRIVATE_LIBRARIES EXPORT_LIBRARIES HEADERS) + set(MULTI_VAL_ARGS SOURCES PRIVATE_LIBRARIES EXPORT_LIBRARIES IMPORT_LIBRARIES HEADERS) cmake_parse_arguments(BUNDLE "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN}) ##check arguments @@ -179,6 +179,7 @@ function(add_bundle) ###### Packaging the bundle using using jar,zip or cpack and a content dir. Configuring dependencies ###### if(JAR_COMMAND) add_custom_command(OUTPUT ${BUNDLE_FILE} + COMMAND ${CMAKE_COMMAND} -E make_directory ${BUNDLE_CONTENT_DIR} COMMAND ${JAR_COMMAND} -cfm ${BUNDLE_FILE} ${BUNDLE_GEN_DIR}/MANIFEST.MF -C ${BUNDLE_CONTENT_DIR} . COMMENT "Packaging ${BUNDLE_TARGET_NAME}" DEPENDS ${BUNDLE_TARGET_NAME} "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_DEPEND_TARGETS>" ${BUNDLE_GEN_DIR}/MANIFEST.MF @@ -186,6 +187,7 @@ function(add_bundle) ) elseif(ZIP_COMMAND) add_custom_command(OUTPUT ${BUNDLE_FILE} + COMMAND ${CMAKE_COMMAND} -E make_directory ${BUNDLE_CONTENT_DIR} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE_GEN_DIR}/MANIFEST.MF META-INF/MANIFEST.MF COMMAND ${ZIP_COMMAND} -rq ${BUNDLE_FILE} * COMMENT "Packaging ${BUNDLE_TARGET_NAME}" @@ -255,6 +257,8 @@ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY \"0\") else() set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN") endif() + elseif(BUNDLE_NO_ACTIVATOR) + #do nothing else() #ACTIVATOR bundle_private_libs(${BUNDLE_TARGET_NAME} ${BUNDLE_ACTIVATOR}) get_filename_component(ACT_NAME ${BUNDLE_ACTIVATOR} NAME) @@ -263,6 +267,7 @@ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY \"0\") bundle_private_libs(${BUNDLE_TARGET_NAME} ${BUNDLE_PRIVATE_LIBRARIES}) bundle_export_libs(${BUNDLE_TARGET_NAME} ${BUNDLE_EXPORT_LIBRARIES}) + bundle_import_libs(${BUNDLE_TARGET_NAME} ${BUNDLE_IMPORT_LIBRARIES}) bundle_headers(${BUNDLE_TARGET_NAME} ${BUNDLE_HEADERS}) endfunction() @@ -338,19 +343,30 @@ function(bundle_libs) set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_DEPEND_TARGETS" "${DEPS}") endfunction() -#TODO -# -# bundle_import_libs(<target> LIB <lib> RANGE <version_range> ?) -# -# function(bundle_import_libs) #0 is bundle TARGET - #1..n is libs + #2..n is import libs list(GET ARGN 0 BUNDLE) list(REMOVE_AT ARGN 0) - message(WARNING "IMPORT BUNDLES STILL TODO") + #check if arg 0 is corrent + check_bundle(${BUNDLE}) + + get_target_property(LIBS ${BUNDLE} "BUNDLE_IMPORT_LIBS") + set(LIBS ) + + foreach(LIB IN ITEMS ${ARGN}) + if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB}) + list(APPEND LIBS ${LIB_NAME}) + else() + list(APPEND LIBS "$<TARGET_SONAME_FILE_NAME:${LIB}>") + endif() + + target_link_libraries(${BUNDLE} ${LIB}) + endforeach() + + set_target_properties(${BUNDLE} PROPERTIES "BUNDLE_IMPORT_LIBS" "${LIBS}") endfunction() function(bundle_files) http://git-wip-us.apache.org/repos/asf/celix/blob/b6ac4103/examples/hello_world/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index 57bbce4..04c79ed 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -18,17 +18,29 @@ include_directories("${PROJECT_SOURCE_DIR}/utils/public/include") include_directories("public/include") +add_library(hello_testlib SHARED + private/src/test +) +set_library_version(hello_testlib "4.3.2") # sets target propery VERSION to 4.3.2 and SOVERSION to 4 + + +add_library(hello_test2lib SHARED + private/src/test2 +) +set_library_version(hello_test2lib "3.3.3") add_bundle(hello VERSION "1.2" SOURCES private/src/activator.c + IMPORT_LIBRARIES hello_test2lib ) -add_library(hello_testlib SHARED - private/src/test +add_bundle(hello_import + VERSION "1.0" + NO_ACTIVATOR + EXPORT_LIBRARIES hello_test2lib ) -set_library_version(hello_testlib "4.3.2") # sets target propery VERSION to 4.3.2 and SOVERSION to 4 bundle_private_libs(hello hello_testlib @@ -36,11 +48,11 @@ bundle_private_libs(hello add_deploy(helloworld_byref GROUP hello - BUNDLES hello shell shell_tui + BUNDLES hello_import hello shell shell_tui ) add_deploy(helloworld_withcopy GROUP hello COPY #Ensures that bundles are copied in the deploy location - BUNDLES hello shell shell_tui + BUNDLES hello_import hello shell shell_tui ) http://git-wip-us.apache.org/repos/asf/celix/blob/b6ac4103/examples/hello_world/private/src/activator.c ---------------------------------------------------------------------- diff --git a/examples/hello_world/private/src/activator.c b/examples/hello_world/private/src/activator.c index 709d02b..37cf782 100644 --- a/examples/hello_world/private/src/activator.c +++ b/examples/hello_world/private/src/activator.c @@ -29,6 +29,7 @@ #include "bundle_activator.h" #include "test.h" +#include "test2.h" struct userData { char * word; @@ -50,6 +51,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) printf("Hello %s\n", data->word); doo(); + bar(); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/b6ac4103/examples/hello_world/private/src/test2.c ---------------------------------------------------------------------- diff --git a/examples/hello_world/private/src/test2.c b/examples/hello_world/private/src/test2.c new file mode 100644 index 0000000..9beb1bc --- /dev/null +++ b/examples/hello_world/private/src/test2.c @@ -0,0 +1,32 @@ +/** + *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. + */ +/* + * test.c + * + * \date 12 Feb 2014 + * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> + * \copyright Apache License, Version 2.0 + */ + +#include <stdio.h> + +void bar() +{ + printf("Hello from (imported) third lib\n"); +} http://git-wip-us.apache.org/repos/asf/celix/blob/b6ac4103/examples/hello_world/public/include/test2.h ---------------------------------------------------------------------- diff --git a/examples/hello_world/public/include/test2.h b/examples/hello_world/public/include/test2.h new file mode 100644 index 0000000..bff9048 --- /dev/null +++ b/examples/hello_world/public/include/test2.h @@ -0,0 +1,34 @@ +/** + *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. + */ +/* + * test.h + * + * \date 12 Feb 2014 + * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> + * \copyright Apache License, Version 2.0 + */ + +#ifndef TEST2_H_ +#define TEST2_H_ + + +void bar(void); + + +#endif /* TEST2_H_ */
