celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-401: Creating docker dirs is now also based on a primairy exe target (as with celix container/deploy)
Date Mon, 11 Dec 2017 19:39:52 GMT
Repository: celix
Updated Branches:
  refs/heads/develop edefb3f4d -> 49e25fad3


CELIX-401: Creating docker dirs is now also based on a primairy exe target (as with celix
container/deploy)


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/49e25fad
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/49e25fad
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/49e25fad

Branch: refs/heads/develop
Commit: 49e25fad35f9c129e251c5bef2fd8bb0e3411101
Parents: edefb3f
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Mon Dec 11 20:39:41 2017 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Mon Dec 11 20:39:41 2017 +0100

----------------------------------------------------------------------
 cmake/cmake_celix/BundlePackaging.cmake |   4 +-
 cmake/cmake_celix/DeployPackaging.cmake |  35 ++---
 cmake/cmake_celix/DockerPackaging.cmake | 196 ++++++++++++---------------
 examples/dm_example/CMakeLists.txt      |  42 +++---
 4 files changed, 126 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/49e25fad/cmake/cmake_celix/BundlePackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake
index 7eb42fa..992e88e 100644
--- a/cmake/cmake_celix/BundlePackaging.cmake
+++ b/cmake/cmake_celix/BundlePackaging.cmake
@@ -123,7 +123,8 @@ function(add_bundle)
     if (NOT BUNDLE_SYMBOLIC_NAME)
         set(BUNDLE_SYMBOLIC_NAME ${BUNDLE_TARGET_NAME})
     endif()
-    set(BUNDLE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}.zip") 
+    set(BUNDLE_FILE_NAME "${BUNDLE_TARGET_NAME}.zip")
+    set(BUNDLE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_FILE_NAME}")
     set(BUNDLE_CONTENT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}_content")
     set(BUNDLE_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}_gen")
 
@@ -206,6 +207,7 @@ function(add_bundle)
     #bundle specific
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_CONTENT_DIR" ${BUNDLE_CONTENT_DIR})
#location where the content to be jar/zipped. 
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_FILE" ${BUNDLE_FILE})
#target bundle file (.zip)
+    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_FILE_NAME" ${BUNDLE_FILE_NAME})
#target bundle file (.zip)
 
     #name and version
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_NAME" ${BUNDLE_NAME})
#The bundle name default target name

http://git-wip-us.apache.org/repos/asf/celix/blob/49e25fad/cmake/cmake_celix/DeployPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake
index 781dacb..91200d8 100644
--- a/cmake/cmake_celix/DeployPackaging.cmake
+++ b/cmake/cmake_celix/DeployPackaging.cmake
@@ -68,7 +68,7 @@ function(add_celix_container)
     set(CONTAINER_ECLIPSE_LAUNCHER "${CONTAINER_LOC}/${CONTAINER_NAME}.launch")
 
     if (CONTAINER_LAUNCHER_SRC)
-        get_filename_component(SRC_FILENAME ${LAUNCHER_SRC} NAME)
+        get_filename_component(SRC_FILENAME ${CONTAINER_LAUNCHER_SRC} NAME)
         set(LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}-${SRC_FILENAME}")
         set(LAUNCHER_ORG "${CONTAINER_LAUNCHER_SRC}")
     elseif (CONTAINER_CXX)
@@ -88,15 +88,11 @@ function(add_celix_container)
         endif()
         add_custom_target(${CONTAINER_TARGET}
                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${LAUNCHER} ${CONTAINER_LOC}/${CONTAINER_TARGET}
-                DEPENDS  "$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_TARGET_DEPS>"
-                COMMENT "Deploying ${CONTAINER_PRINT_NAME} Celix container" VERBATIM
         )
     else ()
         add_custom_command(OUTPUT ${LAUNCHER_SRC}
                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/celix/gen
                 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAUNCHER_ORG} ${LAUNCHER_SRC}
-                DEPENDS  "$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_TARGET_DEPS>"
-                COMMENT "Deploying ${CONTAINER_PRINT_NAME} Celix container" VERBATIM
         )
 
         include_directories(${CELIX_INCLUDE_DIRS})
@@ -133,6 +129,12 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>,
         get_filename_component(CELIX_BIN_DIR ${CELIX_LAUNCHER} DIRECTORY)
     endif()
 
+    if (CONTAINER_COPY)
+        add_custom_target(${CONTAINER_TARGET}-deps
+                DEPENDS $<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_DEPS>
+        )
+        add_dependencies(${CONTAINER_TARGET} ${CONTAINER_TARGET}-deps)
+    endif ()
 
     #generate release.sh and optional run.sh
     if(APPLE)
@@ -165,9 +167,9 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>,
 
     ##### Container Target Properties #####
     #internal use
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_TARGET_DEPS" "") #target
deps for the container.
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES" "") #bundles
to deploy fro the container.
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_COPY_BUNDLES" ${CONTAINER_COPY})
#copy bundles in bundle dir or link using abs paths. NOTE this cannot be changed after a add_deploy
command
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_DEPS" "") #target deps
for copy of bundles
 
     #deploy specific
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_NAME" "${CONTAINER_NAME}")
@@ -206,7 +208,7 @@ function(celix_container_bundles_dir)
     endif()
 
     get_target_property(CONTAINER_LOC ${CONTAINER_TARGET} "CONTAINER_LOC")
-    get_target_property(DEPS ${CONTAINER_TARGET} "CONTAINER_TARGET_DEPS")
+    get_target_property(DEPS ${CONTAINER_TARGET} "CONTAINER_DEPS")
 
     foreach(BUNDLE IN ITEMS ${BD_BUNDLES})
         if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
@@ -214,24 +216,22 @@ function(celix_container_bundles_dir)
             set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BUNDLE_FILENAME}")
             add_custom_command(OUTPUT ${OUT}
                 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE} ${OUT}
-		COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
+		        COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
                 DEPENDS ${BUNDLE}
             )
         else()
-            set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BUNDLE}.zip")
+            #assuming target
+            get_target_property(BFN ${BUNDLE} BUNDLE_FILE_NAME) #would prefer to used target
generator, but this is not supporte in a OUTPUT argument
+            set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BFN}")
             add_custom_command(OUTPUT ${OUT}
                 COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>"
${OUT}
-                COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
-                DEPENDS ${BUNDLE}
+                COMMENT "Copying bundle '${BFN}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
+                DEPENDS ${BUNDLE} ${BUNDLE}_bundle
             )
-            add_dependencies(${CONTAINER_TARGET} ${BUNDLE}_bundle) #ensure the the deploy
depends on the _bundle target, custom_command depends on add_library
-
         endif()
         list(APPEND DEPS "${OUT}")
-
     endforeach()
-
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_TARGET_DEPS" "${DEPS}")
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_DEPS" "${DEPS}")
 endfunction()
 
 function(deploy_bundles)
@@ -252,7 +252,8 @@ function(celix_container_bundles)
                     get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME) 
                     list(APPEND BUNDLES "bundles/${BUNDLE_FILENAME}")
                 else() #assuming target
-                    list(APPEND BUNDLES "bundles/${BUNDLE}.zip")
+                    get_target_property(BFN ${BUNDLE} BUNDLE_FILE_NAME)
+                    list(APPEND BUNDLES "bundles/${BFN}")
                 endif()
            else()
                 if(IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})

http://git-wip-us.apache.org/repos/asf/celix/blob/49e25fad/cmake/cmake_celix/DockerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake
index 7cce6dd..c792242 100644
--- a/cmake/cmake_celix/DockerPackaging.cmake
+++ b/cmake/cmake_celix/DockerPackaging.cmake
@@ -15,59 +15,27 @@
 # specific language governing permissions and limitations
 # under the License.
 
-### Setup Docker Option
-option(ENABLE_DOCKER "Enable the add_celix_docker function to create docker files")
+##### setup docker target
+add_custom_target(celix-build-docker-dirs ALL
+    DEPENDS $<TARGET_PROPERTY:celix-build-docker-dirs,DOCKER_DEPS>
+)
+set_target_properties(celix-build-docker-dirs PROPERTIES "DOCKER_DEPS" "") #initial empty
deps list
 
-if (ENABLE_DOCKER)
-    ##### setup docker target
-    add_custom_target(docker ALL
-        DEPENDS $<TARGET_PROPERTY:docker,DOCKER_DEPS>
-    )
-    add_custom_target(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.")
-
-    set_target_properties(docker PROPERTIES "DOCKER_DEPS" "") #initial empty deps list
-
-    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
-    list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/docker")
-    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
-    #####
+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.")
 
-
-    ##### Docker Dependencies Library
-    # This (dummy) dependencies library is used to link against required libraries for the
docker images.
-    # The create fs script will ensure that the minimal required directory / files is created
and this
-    # library will ensure that stdc++, m, jansson and libffi and ld-linux libaries are installed
-    #
-    # NOTE that this target can be used to extend the libraries added to the docker image
-    file(GENERATE
-            OUTPUT "${CMAKE_BINARY_DIR}/.celix_docker_depslib/docker_dummy.cc"
-            CONTENT "//intentionally emtpy source file")
-    add_library(celix_docker_depslib SHARED
-            ${CMAKE_BINARY_DIR}/.celix_docker_depslib/docker_dummy.cc
-    )
-    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
-    list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/.celix_docker_depslib")
-    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
-    set_target_properties(celix_docker_depslib PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/.celix_docker_depslib")
-    find_package(FFI REQUIRED)
-    find_package(Jansson REQUIRED)
-    target_link_libraries(celix_docker_depslib ${JANSSON_LIBRARIES} ${FFI_LIBRARIES})
-    target_link_libraries(celix_docker_depslib m)
-endif ()
+get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/docker")
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
+#####
 
 function(add_celix_docker)
     list(GET ARGN 0 DOCKER_TARGET)
     list(REMOVE_AT ARGN 0)
 
-    if (NOT ENABLE_DOCKER)
-        message(WARNING "Docker not enable, skipping target '${DOCKER_TARGET}'")
-        return()
-    endif()
-
-    set(OPTIONS )
-    set(ONE_VAL_ARGS GROUP NAME FROM BUNDLES_DIR WORKDIR IMAGE_NAME ENTRYPOINT DEPSLIB)
+    set(OPTIONS CXX)
+    set(ONE_VAL_ARGS GROUP NAME FROM BUNDLES_DIR WORKDIR IMAGE_NAME)
     set(MULTI_VAL_ARGS BUNDLES PROPERTIES INSTRUCTIONS)
     cmake_parse_arguments(DOCKER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN})
 
@@ -87,11 +55,6 @@ function(add_celix_docker)
     if (NOT DOCKER_WORKDIR)
         set(DOCKER_WORKDIR "/root")
     endif()
-    if (NOT DOCKER_ENTRYPOINT)
-        set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/celix\"]")
-    else ()
-        set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"${DOCKER_ENTRYPOINT}\"]")
-    endif ()
     if (NOT DOCKER_GROUP)
         set(DOCKER_LOC "${CMAKE_BINARY_DIR}/docker/${DOCKER_NAME}")
     else()
@@ -100,46 +63,69 @@ function(add_celix_docker)
     if (NOT DOCKER_BUNDLES_DIR)
         set(DOCKER_BUNDLES_DIR "/bundles")
     endif()
-    if (NOT DOCKER_DEPSLIB)
-        set(DOCKER_DEPSLIB "celix_docker_depslib")
-    endif ()
 
     #ensure the docker dir will be deleted during clean
     get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
     list(APPEND CLEANFILES "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>")
     set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
 
-    ###### Setup docker custom target timestamp
-    set(TIMESTAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-timestamp")
-
-    add_custom_target(${DOCKER_TARGET}
-        DEPENDS ${TIMESTAMP_FILE}
-    )
-
-    #Setting CELIX_LIB_DIRS, CELIX_BIN_DIR and CELIX_LAUNCHER 
-    if (EXISTS ${CELIX_FRAMEWORK_LIBRARY}) 
-        #CELIX_FRAMEWORK_LIBRARY set by FindCelix.cmake -> Celix Based Project
-        #CELIX_LAUNCHER is set by FindCelix.cmake
+    if (DOCKER_LAUNCHER_SRC)
+        get_filename_component(SRC_FILENAME ${DOCKER_LAUNCHER_SRC} NAME)
+        set(LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/${DOCKER_TARGET}-${SRC_FILENAME}")
+        set(LAUNCHER_ORG "${DOCKER_LAUNCHER_SRC}")
+    elseif (DOCKER_CXX)
+        set(LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/${DOCKER_TARGET}-main.cc")
+        set(LAUNCHER_ORG "${CELIX_CMAKE_DIRECTORY}/cmake_celix/main.c.in")
     else()
-        set(CELIX_LAUNCHER "$<TARGET_FILE:celix>")
+        set(LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/${DOCKER_TARGET}-main.c")
+        set(LAUNCHER_ORG "${CELIX_CMAKE_DIRECTORY}/cmake_celix/main.c.in")
     endif()
 
+    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 "$<TARGET_FILE:${DOCKER_LAUNCHER}>")
+            set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/$<TARGET_FILE_NAME:${DOCKER_TARGET}>\"]")
+        endif()
+    else ()
+        add_custom_command(OUTPUT ${LAUNCHER_SRC}
+                COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/celix/gen
+                COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAUNCHER_ORG} ${LAUNCHER_SRC}
+        )
+
+        add_executable(${DOCKER_TARGET} ${LAUNCHER_SRC})
+        #   set_target_properties(${DOCKER_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${DOCKER_LOC})
+        target_include_directories(${DOCKER_TARGET} PRIVATE ${CELIX_INCLUDE_DIRS})
+        target_link_libraries(${DOCKER_TARGET} PRIVATE ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY})
+        set(LAUNCHER "$<TARGET_FILE:${DOCKER_TARGET}>")
+        set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/$<TARGET_FILE_NAME:${DOCKER_TARGET}>\"]")
+    endif ()
+
+
+    ###### Setup docker custom target timestamp
+    add_custom_target(${DOCKER_TARGET}-deps
+        DEPENDS ${FS_TIMESTAMP_FILE} $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_DEPS>
+    )
+    add_dependencies(${DOCKER_TARGET} ${DOCKER_TARGET}-deps)
+
     #setup dependencies based on timestamp
     if (DOCKER_CREATE_FS)
-        add_custom_command(OUTPUT "${TIMESTAMP_FILE}"
-            COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE}
-	    COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>
-	    COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC> && /bin/bash
${CELIX_CMAKE_DIRECTORY}/cmake_celix/create_target_filesystem.sh -e ${CELIX_LAUNCHER} -l $<TARGET_FILE:${DOCKER_DEPSLIB}>
> /dev/null
-            DEPENDS  "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_DEPS>" ${DOCKERFILE}
${DOCKER_DEPSLIB}
-	    WORKING_DIRECTORY "${DOCKER_LOC}"
+        add_custom_command(TARGET ${DOCKER_TARGET} POST_BUILD
+	        COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>
+	        COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC> && /bin/bash
${CELIX_CMAKE_DIRECTORY}/cmake_celix/create_target_filesystem.sh -e ${LAUNCHER} > /dev/null
+    	    WORKING_DIRECTORY "${DOCKER_LOC}"
             COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM
         )
     else ()
-        add_custom_command(OUTPUT "${TIMESTAMP_FILE}"
-            COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE}
-	    COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>
-            DEPENDS  "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_DEPS>" ${DOCKERFILE}
-	    WORKING_DIRECTORY "${DOCKER_LOC}"
+        add_custom_command(TARGET ${DOCKER_TARGET} POST_BUILD
+	        COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>/bin
+            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAUNCHER} $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>/bin/
+	        WORKING_DIRECTORY "${DOCKER_LOC}"
             COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM
         )
     endif ()
@@ -157,36 +143,40 @@ function(add_celix_docker)
     set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "")
     set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_DEPS" "")
 
+    set(DOCKERFILE_STAGE1 ${CMAKE_BINARY_DIR}/celix/gen/${DOCKER_TARGET}-Dockerfile.in)
     set(DOCKERFILE "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC>/Dockerfile")
 
     file(GENERATE
-            OUTPUT "${DOCKERFILE}"
+            OUTPUT "${DOCKERFILE_STAGE1}"
             CONTENT "# Dockerfile for celix based image
 FROM $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_FROM>
 ENV IMAGE_NAME $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_IMAGE_NAME>
-ADD . /
+COPY . /
 WORKDIR $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_WORKDIR>
 $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_ENTRYPOINT>
 $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_INSTRUCTIONS>,
 >
 ")
+    file(GENERATE
+            OUTPUT ${DOCKERFILE}
+            INPUT ${DOCKERFILE_STAGE1}
+    )
 
     #generate config.properties
-    set(DOCKER_PROPS "${DOCKER_LOC}/${DOCKER_WORKDIR}/config.properties")
-    set(STAGE1_PROPERTIES "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-config-stage1.properties")
+    set(DOCKER_PROPERTIES_FILE "${DOCKER_LOC}/${DOCKER_WORKDIR}/config.properties")
+    set(STAGE1_PROPERTIES_FILE "${CMAKE_BINARY_DIR}/celix/gen/${DOCKER_TARGET}-docker-config-stage1.properties")
     file(GENERATE
-            OUTPUT "${STAGE1_PROPERTIES}"
+            OUTPUT "${STAGE1_PROPERTIES_FILE}"
             CONTENT "cosgi.auto.start.1=$<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_BUNDLES>,
>
 $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_PROPERTIES>,
 >
 "
     )
     file(GENERATE
-            OUTPUT "${DOCKER_PROPS}"
-            INPUT "${STAGE1_PROPERTIES}"
+            OUTPUT "${DOCKER_PROPERTIES_FILE}"
+            INPUT "${STAGE1_PROPERTIES_FILE}"
     )
 
-
     if (DOCKER_BUNDLES)
         celix_docker_bundles(${DOCKER_TARGET} ${DOCKER_BUNDLES})
     endif()
@@ -197,29 +187,20 @@ $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_PROPERTIES>,
         celix_docker_instructions(${DOCKER_TARGET} ${DOCKER_INSTRUCTIONS})
     endif ()
 
-    get_target_property(DEPS docker "DOCKER_DEPS")
+    get_target_property(DEPS celix-build-docker-dirs "DOCKER_DEPS")
     list(APPEND DEPS ${DOCKER_TARGET})
-    set_target_properties(docker PROPERTIES "DOCKER_DEPS" "${DEPS}")
+    set_target_properties(celix-build-docker-dirs PROPERTIES "DOCKER_DEPS" "${DEPS}")
 
-    #Note assuming sudo is needed for the docker command
-    set(SUDO_CMD "")
-    if (DOCKER_USE_SUDO)
-        set(SUDO_CMD "sudo")
-    endif ()
-    add_custom_target(build-${DOCKER_TARGET}-docker-image
-	    COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC> && ${SUDO_CMD}
${DOCKER_CMD} build -t "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_IMAGE_NAME>" .
+    add_custom_target(celix-build-${DOCKER_TARGET}-docker-image
+	    COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOC> && ${DOCKER_CMD}
build -t "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_IMAGE_NAME>" .
         DEPENDS ${DOCKERFILE} ${DOCKER_TARGET}
         COMMENT "Creating docker image for target '${DOCKER_TARGET}'" VERBATIM
     )
-    add_dependencies(build-docker-images build-${DOCKER_TARGET}-docker-image)
+    add_dependencies(celix-build-docker-images celix-build-${DOCKER_TARGET}-docker-image)
 
 endfunction()
 
 function(celix_docker_bundles)
-    if (NOT ENABLE_DOCKER)
-        return()
-    endif()
-
     #0 is docker TARGET
     #1..n is bundles
     list(GET ARGN 0 DOCKER_TARGET)
@@ -240,15 +221,16 @@ function(celix_docker_bundles)
                 COMMENT "Copying bundle '${BUNDLE}' to '${OUT}'"
                 DEPENDS ${BUNDLE}
             )
+            add_dependencies(${DOCKER_TARGET} ${OUT})
         else() #assuming target
-            list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE}.zip")
-            set(OUT ${LOC}/${BUNDLES_DIR}/${BUNDLE}.zip)
+            get_target_property(BFN ${BUNDLE} BUNDLE_FILE_NAME)
+            list(APPEND BUNDLES "${BUNDLES_DIR}/${BFN}")
+            set(OUT ${LOC}/${BUNDLES_DIR}/${BFN})
             add_custom_command(OUTPUT ${OUT}
                     COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>"
"${OUT}"
                     COMMENT "Copying bundle '${BUNDLE}' to '${OUT}'"
-                    DEPENDS ${BUNDLE}
+                    DEPENDS ${BUNDLE} ${BUNDLE}_bundle
             )
-            add_dependencies(${DOCKER_TARGET} ${BUNDLE}_bundle) #ensure the the deploy depends
on the _bundle target, custom_command depends on add_library
         endif()
         list(APPEND DEPS "${OUT}")
     endforeach()
@@ -258,10 +240,6 @@ function(celix_docker_bundles)
 endfunction()
 
 function(celix_docker_properties)
-    if (NOT ENABLE_DOCKER)
-        return()
-    endif()
-
     #0 is docker TARGET
     #1..n is properties
     list(GET ARGN 0 DOCKER_TARGET)
@@ -277,10 +255,6 @@ function(celix_docker_properties)
 endfunction()
 
 function(celix_docker_instructions)
-    if (NOT ENABLE_DOCKER)
-        return()
-    endif()
-
     #0 is docker TARGET
     #1..n is instructions
     list(GET ARGN 0 DOCKER_TARGET)

http://git-wip-us.apache.org/repos/asf/celix/blob/49e25fad/examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt
index 8e07825..f10ef26 100644
--- a/examples/dm_example/CMakeLists.txt
+++ b/examples/dm_example/CMakeLists.txt
@@ -41,28 +41,26 @@ if (BUILD_DEPENDENCY_MANAGER)
             LOGHELPER_ENABLE_STDOUT_FALLBACK=true
     )
 
-    if (ENABLE_DOCKER)
-        add_celix_docker(dm_exmpl_base
-                NAME dmbase
-                IMAGE_NAME dmbase
-                GROUP examples
-                INSTRUCTIONS
-                    "LABEL exmpl=value"
-        )
-        add_celix_docker(dm_exmpl
-            FROM dmbase
+    add_celix_docker(dm_exmpl_base
+            NAME dmbase
+            IMAGE_NAME dmbase
             GROUP examples
-            BUNDLES
-                shell
-                shell_tui
-                dm_shell
-                phase1
-                phase2a
-                phase2b
-                phase3
-            PROPERTIES
-                LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-        )
-    endif ()
+            INSTRUCTIONS
+                "LABEL exmpl=value"
+    )
+    add_celix_docker(dm_exmpl
+        FROM dmbase
+        GROUP examples
+        BUNDLES
+            shell
+            shell_tui
+            dm_shell
+            phase1
+            phase2a
+            phase2b
+            phase3
+        PROPERTIES
+            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+    )
 
 endif ()


Mime
View raw message