Commit 9bd6e875 authored by Tor Didriksen's avatar Tor Didriksen

Bug#19890133 MAKE DIST USING BZR EXPORT EVEN FOR SOURCE DIR NOT A BZR REPO

For 'make dist': only use 'bzr export' if bzr root == ${CMAKE_SOURCE_DIR}
Same thing for git.
parent a9b61b00
...@@ -37,6 +37,9 @@ ENDIF() ...@@ -37,6 +37,9 @@ ENDIF()
MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")
# Will set GIT_EXECUTABLE and GIT_FOUND
FIND_PACKAGE(Git)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
# First, decide about build type (debug or release) # First, decide about build type (debug or release)
......
...@@ -23,12 +23,12 @@ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@") ...@@ -23,12 +23,12 @@ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@")
SET(CMAKE_CPACK_COMMAND "@CMAKE_CPACK_COMMAND@") SET(CMAKE_CPACK_COMMAND "@CMAKE_CPACK_COMMAND@")
SET(CMAKE_COMMAND "@CMAKE_COMMAND@") SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@") SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@")
SET(GTAR_EXECUTABLE "@GTAR_EXECUTABLE@") SET(GTAR_EXECUTABLE "@GTAR_EXECUTABLE@")
SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@") SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@")
SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@") SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@")
SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
SET(PLUGIN_REPOS "@PLUGIN_REPOS@")
SET(VERSION "@VERSION@") SET(VERSION "@VERSION@")
...@@ -40,6 +40,23 @@ SET(PACKAGE_DIR ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}) ...@@ -40,6 +40,23 @@ SET(PACKAGE_DIR ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME})
FILE(REMOVE_RECURSE ${PACKAGE_DIR}) FILE(REMOVE_RECURSE ${PACKAGE_DIR})
FILE(REMOVE ${PACKAGE_DIR}.tar.gz ) FILE(REMOVE ${PACKAGE_DIR}.tar.gz )
# Only allow bzr if source dir itself is a bzr repository
IF(BZR_EXECUTABLE)
EXECUTE_PROCESS(
COMMAND "${BZR_EXECUTABLE}" root
OUTPUT_VARIABLE BZR_ROOT
ERROR_VARIABLE BZR_ROOT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
)
IF(NOT RESULT EQUAL 0 OR NOT BZR_ROOT STREQUAL ${CMAKE_SOURCE_DIR})
MESSAGE(STATUS "This is not a bzr repository")
SET(BZR_EXECUTABLE)
ENDIF()
ENDIF()
IF(BZR_EXECUTABLE) IF(BZR_EXECUTABLE)
MESSAGE(STATUS "Running bzr export") MESSAGE(STATUS "Running bzr export")
EXECUTE_PROCESS( EXECUTE_PROCESS(
...@@ -50,28 +67,57 @@ IF(BZR_EXECUTABLE) ...@@ -50,28 +67,57 @@ IF(BZR_EXECUTABLE)
) )
IF(NOT RESULT EQUAL 0) IF(NOT RESULT EQUAL 0)
SET(BZR_EXECUTABLE) SET(BZR_EXECUTABLE)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(BZR_EXECUTABLE) IF(GIT_EXECUTABLE AND NOT BZR_EXECUTABLE)
FOREACH(REPO ${PLUGIN_REPOS}) EXECUTE_PROCESS(
GET_FILENAME_COMPONENT(PLUGIN_NAME ${REPO} NAME) COMMAND "${GIT_EXECUTABLE}" rev-parse --show-toplevel
SET(DEST ${PACKAGE_DIR}/plugin/${PLUGIN_NAME}) OUTPUT_VARIABLE GIT_ROOT
MESSAGE(STATUS "Running bzr export for plugin/${PLUGIN_NAME}") ERROR_VARIABLE GIT_ROOT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
)
IF(NOT RESULT EQUAL 0 OR NOT GIT_ROOT STREQUAL ${CMAKE_SOURCE_DIR})
MESSAGE(STATUS "This is not a git repository")
SET(GIT_EXECUTABLE)
ENDIF()
ENDIF()
IF(GIT_EXECUTABLE AND NOT BZR_EXECUTABLE)
MESSAGE(STATUS "Running git archive -o ${PACKAGE_DIR}.tar")
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" archive --format=tar
--prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ -o ${PACKAGE_DIR}.tar HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
)
IF(NOT RESULT EQUAL 0)
SET(GIT_EXECUTABLE)
ELSE()
# Unpack tarball
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND "${BZR_EXECUTABLE}" export ${DEST} COMMAND ${CMAKE_COMMAND} -E tar xf ${PACKAGE_DIR}.tar
WORKING_DIRECTORY ${REPO} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE RESULT RESULT_VARIABLE TAR_RESULT
) )
IF(NOT RESULT EQUAL 0) IF(NOT TAR_RESULT EQUAL 0)
MESSAGE(STATUS "bzr export failed") SET(GIT_EXECUTABLE)
ELSE()
# Remove tarball after unpacking
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E remove ${PACKAGE_DIR}.tar
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
ENDIF() ENDIF()
ENDFOREACH() ENDIF()
ENDIF() ENDIF()
IF(NOT BZR_EXECUTABLE) IF(NOT BZR_EXECUTABLE AND NOT GIT_EXECUTABLE)
MESSAGE(STATUS "bzr not found or source dir is not a repo, use CPack") MESSAGE(STATUS "bzr/git not found or source dir is not a repo, use CPack")
IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
# In-source build is the worst option, we have to cleanup source tree. # In-source build is the worst option, we have to cleanup source tree.
......
...@@ -232,11 +232,4 @@ MACRO(CONFIGURE_PLUGINS) ...@@ -232,11 +232,4 @@ MACRO(CONFIGURE_PLUGINS)
ADD_SUBDIRECTORY(${dir}) ADD_SUBDIRECTORY(${dir})
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
FOREACH(dir ${dirs_plugin})
IF (EXISTS ${dir}/.bzr)
MESSAGE(STATUS "Found repo ${dir}/.bzr")
LIST(APPEND PLUGIN_BZR_REPOS "${dir}")
ENDIF()
ENDFOREACH()
SET(PLUGIN_REPOS "${PLUGIN_BZR_REPOS}" CACHE INTERNAL "")
ENDMACRO() ENDMACRO()
...@@ -252,7 +252,8 @@ FOREACH(tool glibtoolize libtoolize aclocal autoconf autoheader automake gtar ...@@ -252,7 +252,8 @@ FOREACH(tool glibtoolize libtoolize aclocal autoconf autoheader automake gtar
ENDFOREACH() ENDFOREACH()
CONFIGURE_FILE( CONFIGURE_FILE(
${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in ${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY) ${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in
${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY)
ADD_CUSTOM_TARGET(dist ADD_CUSTOM_TARGET(dist
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment