add an option to only include a subset of packages into a release

This commit is contained in:
Sébastien Loriot 2019-01-14 15:27:00 +01:00
parent 275786b0b4
commit 0cb112d941
1 changed files with 94 additions and 49 deletions

View File

@ -7,53 +7,14 @@
# Must be followed by -beta<beta_number> if the release is a beta.
# CGAL_VERSION_NR=release string used to update version.h. Must be something like 1041200033 , or 10412009<beta number>0
# TESTSUITE=indicate if the release is meant to be used by the testsuite, default if OFF
# GPL_PACKAGE_LIST=path to a file containing the list of GPL packages to include in the release. If not provided all of them are.
if (NOT GIT_REPO)
set(GIT_REPO ${CMAKE_BINARY_DIR})
if(POLICY CMP0009)
# http://www.cmake.org/cmake/help/v3.2/policy/CMP0009.html
cmake_policy(SET CMP0009 NEW)
endif()
if (NOT EXISTS ${GIT_REPO}/Installation/include/CGAL/version.h)
message(FATAL_ERROR "Cannot find Installation/include/CGAL/version.h. Make sure you are at the root of a CGAL branch")
endif()
file(READ "${GIT_REPO}/Installation/include/CGAL/version.h" version_file_content)
string(REGEX MATCH "define CGAL_VERSION (.*)\n#define CGAL_VERSION_NR" CGAL_VERSION_FOUND "${version_file_content}")
if (CGAL_VERSION_FOUND)
set(CGAL_VERSION_INPUT "${CMAKE_MATCH_1}")
if (NOT CGAL_VERSION)
set(CGAL_VERSION "${CGAL_VERSION_INPUT}")
endif()
set (GITHUB_PREFIX "https://github.com/CGAL/cgal/blob/releases/CGAL-${CGAL_VERSION}")
else()
message(FATAL_ERROR "Cannot extract CGAL version number.")
endif()
if (NOT DEFINED DESTINATION)
SET(DESTINATION "/tmp")
endif()
set(release_dir "${DESTINATION}/CGAL-${CGAL_VERSION}")
if(EXISTS ${release_dir})
file(REMOVE_RECURSE ${release_dir})
endif()
if (PUBLIC)
message(STATUS "Creating a public release ${CGAL_VERSION} in ${release_dir}")
else()
message(STATUS "Creating an internal release ${CGAL_VERSION} in ${release_dir}")
endif()
file(MAKE_DIRECTORY "${release_dir}")
file(GLOB files RELATIVE ${GIT_REPO} ${GIT_REPO}/*)
foreach(pkg ${files})
set(pkg_dir ${GIT_REPO}/${pkg}) # use absolute path
if(IS_DIRECTORY ${pkg_dir} AND (NOT "${pkg}" STREQUAL "Maintenance")
AND (EXISTS ${pkg_dir}/package_info
OR "${pkg}" STREQUAL "Documentation"
OR "${pkg}" STREQUAL "Miscellany" ) ) # only consider packages
function(process_package pkg)
if(VERBOSE)
message(STATUS "handling ${pkg}")
endif()
@ -105,6 +66,90 @@ foreach(pkg ${files})
file(REMOVE_RECURSE "${release_dir}/doc/${pkg}/fig_src")
endif()
endif()
endfunction()
if (NOT GIT_REPO)
set(GIT_REPO ${CMAKE_BINARY_DIR})
endif()
if (NOT EXISTS ${GIT_REPO}/Installation/include/CGAL/version.h)
message(FATAL_ERROR "Cannot find Installation/include/CGAL/version.h. Make sure you are at the root of a CGAL branch")
endif()
file(READ "${GIT_REPO}/Installation/include/CGAL/version.h" version_file_content)
string(REGEX MATCH "define CGAL_VERSION (.*)\n#define CGAL_VERSION_NR" CGAL_VERSION_FOUND "${version_file_content}")
if (CGAL_VERSION_FOUND)
set(CGAL_VERSION_INPUT "${CMAKE_MATCH_1}")
if (NOT CGAL_VERSION)
set(CGAL_VERSION "${CGAL_VERSION_INPUT}")
endif()
set (GITHUB_PREFIX "https://github.com/CGAL/cgal/blob/releases/CGAL-${CGAL_VERSION}")
else()
message(FATAL_ERROR "Cannot extract CGAL version number.")
endif()
set(FILTER_PACKAGES False)
if (DEFINED GPL_PACKAGE_LIST)
set(FILTER_GPL_PACKAGES True)
if(NOT EXISTS ${GPL_PACKAGE_LIST})
message(FATAL_ERROR "File ${GPL_PACKAGE_LIST} does not exist.")
endif()
endif()
if (NOT DEFINED DESTINATION)
SET(DESTINATION "/tmp")
endif()
set(release_dir "${DESTINATION}/CGAL-${CGAL_VERSION}")
if(EXISTS ${release_dir})
file(REMOVE_RECURSE ${release_dir})
endif()
if (PUBLIC)
message(STATUS "Creating a public release ${CGAL_VERSION} in ${release_dir}")
else()
message(STATUS "Creating an internal release ${CGAL_VERSION} in ${release_dir}")
endif()
if(FILTER_GPL_PACKAGES)
if (VERBOSE)
message("Copying only GPL packages from a provided list.")
endif()
file(READ ${GPL_PACKAGE_LIST} pkgs)
string(REPLACE " " ";" pkgs "${pkgs}")
string(REPLACE "\n" ";" pkgs "${pkgs}")
foreach(pkg ${pkgs})
set(pkg_dir ${GIT_REPO}/${pkg})
if(IS_DIRECTORY ${pkg_dir})
process_package(${pkg})
else()
message(FATAL_ERROR "${pkg} CGAL package cannot be found.")
endif()
endforeach()
if (VERBOSE)
message("Now handling non-GPL packages.")
endif()
endif()
file(MAKE_DIRECTORY "${release_dir}")
file(GLOB files RELATIVE ${GIT_REPO} ${GIT_REPO}/*)
foreach(pkg ${files})
set(pkg_dir ${GIT_REPO}/${pkg}) # use absolute path
if(IS_DIRECTORY ${pkg_dir} AND (NOT "${pkg}" STREQUAL "Maintenance")
AND (EXISTS ${pkg_dir}/package_info
OR "${pkg}" STREQUAL "Documentation"
OR "${pkg}" STREQUAL "Miscellany" ) ) # only consider packages
if(FILTER_GPL_PACKAGES AND EXISTS ${pkg_dir}/package_info/${pkg}/license.txt)
file(READ "${pkg_dir}/package_info/${pkg}/license.txt" license_file_content)
string(REGEX MATCH "^GPL" GPL_PACKAGE "${license_file_content}")
if (GPL_PACKAGE)
continue()
endif()
endif()
process_package(${pkg})
endif()
endforeach()