release_cmake.cmake 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. set(CVSROOT ":pserver:[email protected]:/cvsroot/CMake")
  2. get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
  3. if(NOT DEFINED INSTALLER_SUFFIX)
  4. set(INSTALLER_SUFFIX "*.sh")
  5. endif(NOT DEFINED INSTALLER_SUFFIX)
  6. if(NOT DEFINED PROCESSORS)
  7. set(PROCESSORS 1)
  8. endif(NOT DEFINED PROCESSORS)
  9. if(NOT DEFINED CMAKE_VERSION)
  10. message(FATAL_ERROR "CMAKE_VERSION not defined")
  11. endif(NOT DEFINED CMAKE_VERSION)
  12. if(NOT DEFINED CVS_COMMAND)
  13. set(CVS_COMMAND cvs)
  14. endif(NOT DEFINED CVS_COMMAND)
  15. if("${CMAKE_VERSION}" STREQUAL "CVS")
  16. set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -D now ")
  17. set( CMAKE_VERSION "CurrentCVS")
  18. else("${CMAKE_VERSION}" STREQUAL "CVS")
  19. set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -r ${CMAKE_VERSION} ")
  20. endif("${CMAKE_VERSION}" STREQUAL "CVS")
  21. if(NOT HOST)
  22. message(FATAL_ERROR "HOST must be specified with -DHOST=host")
  23. endif(NOT HOST)
  24. if(NOT DEFINED MAKE)
  25. message(FATAL_ERROR "MAKE must be specified with -DMAKE=\"make -j2\"")
  26. endif(NOT DEFINED MAKE)
  27. message("Creating CMake release ${CMAKE_VERSION} on ${HOST} with parallel = ${PROCESSORS}")
  28. # define a macro to run a remote command
  29. macro(remote_command comment command)
  30. message("${comment}")
  31. if(${ARGC} GREATER 2)
  32. execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
  33. else(${ARGC} GREATER 2)
  34. execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result)
  35. endif(${ARGC} GREATER 2)
  36. if(${result} GREATER 0)
  37. message(FATAL_ERROR "Error running command: ${command}, return value = ${result}")
  38. endif(${result} GREATER 0)
  39. endmacro(remote_command)
  40. # remove and create a directory to work with
  41. remote_command(
  42. "remove and create working directory ~/CMakeReleaseDirectory"
  43. "rm -rf ~/CMakeReleaseDirectory && mkdir ~/CMakeReleaseDirectory")
  44. # create user make rule file
  45. if(DEFINED USER_MAKE_RULE_FILE_CONTENTS)
  46. remote_command("Create ${USER_MAKE_RULE_FILE}"
  47. "echo ${USER_MAKE_RULE_FILE_CONTENTS} > ${USER_MAKE_RULE_FILE}" )
  48. endif(DEFINED USER_MAKE_RULE_FILE_CONTENTS)
  49. # create the build directory
  50. remote_command(
  51. "Create a directory to build in"
  52. "rm -rf ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && mkdir ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build")
  53. # set the initial cache
  54. if(DEFINED INITIAL_CACHE)
  55. remote_command("Create ${USER_MAKE_RULE_FILE}"
  56. "echo \"${INITIAL_CACHE}\" > ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build/CMakeCache.txt" )
  57. endif(DEFINED INITIAL_CACHE)
  58. # login to cvs
  59. remote_command(
  60. "Login into cvs."
  61. "cvs -d ${CVSROOT} login" "${SCRIPT_PATH}/cmake_login")
  62. # checkout the source
  63. remote_command(
  64. "Checkout the source for ${CMAKE_VERSION}"
  65. "cd ~/CMakeReleaseDirectory && ${CMAKE_CHECKOUT} -d ${CMAKE_VERSION} CMake")
  66. # now bootstrap cmake
  67. remote_command(
  68. "Run cmake bootstrap --parallel=${PROCESSORS}"
  69. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ../${CMAKE_VERSION}/bootstrap --parallel=${PROCESSORS}")
  70. # build cmake
  71. remote_command(
  72. "Build cmake with ${MAKE}"
  73. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ${MAKE}")
  74. # build cmake
  75. remote_command(
  76. "Build cmake with ${MAKE}"
  77. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ${MAKE}")
  78. # run the tests
  79. remote_command(
  80. "Run cmake tests"
  81. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ${MAKE} test")
  82. # package cmake with self-extracting shell script
  83. remote_command(
  84. "Package cmake"
  85. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ${MAKE} package")
  86. # package cmake with a tar gz file
  87. remote_command(
  88. "Package cmake"
  89. "cd ~/CMakeReleaseDirectory/${CMAKE_VERSION}-build && ./bin/cpack -G TGZ")
  90. message("copy the .gz file back from the machine")
  91. execute_process(COMMAND scp ${HOST}:CMakeReleaseDirectory/${CMAKE_VERSION}-build/*.gz .
  92. RESULT_VARIABLE result)
  93. message("copy the ${INSTALLER_SUFFIX} file back from the machine")
  94. execute_process(COMMAND scp ${HOST}:CMakeReleaseDirectory/${CMAKE_VERSION}-build/${INSTALLER_SUFFIX} .
  95. RESULT_VARIABLE result)