release_cmake.cmake 3.6 KB

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