os: ubuntu-20.04
CC: gcc
CXX: g++
- SPECIAL: build-and-verify-package-source
- apt_get: elfutils libzstd-dev ninja-build
+ SPECIAL: build-and-verify-source-package
+ apt_get: elfutils libzstd-dev ninja-build asciidoc xsltproc
- name: HTML documentation
os: ubuntu-18.04
- name: Collect testdir from failed tests
if: failure()
run: ci/collect-testdir
- # TODO: in case of build-and-verify-package* the BUILDDIR is set within those scripts.
+ # TODO: in case of build-and-verify-*package the BUILDDIR is set within those scripts.
- name: Upload testdir from failed tests
if: failure()
#!/bin/sh
+#
+# Test that it works to build from a source archive exported by "git archive"
+# outside a Git repository.
set -eu
# without resorting to setting base_dir.
export CMAKE_GENERATOR=Ninja
-rm -rf build_package_source_dir_test
-mkdir -p build_package_source_dir_test
-cd build_package_source_dir_test
-cmake ..
-ninja -v package_source
-
tmp_dir=$(mktemp -d)
trap "rm -rf $tmp_dir" EXIT
-tar -xf ccache-*.tar.xz -C $tmp_dir
-cd $tmp_dir/ccache-*
-
+git archive --prefix=ccache/ -o $tmp_dir/ccache.tar.gz HEAD
+cd $tmp_dir
+tar xf ccache.tar.gz
+cd ccache
mkdir build
cd build
cmake ..
set(CPACK_PACKAGE_DESCRIPTION "${CMAKE_PROJECT_DESCRIPTION}")
endif()
-# From GenerateVersionFile.cmake.
+# From CcacheVersion.cmake.
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_GENERATOR "TXZ")
endif()
-set(CPACK_SOURCE_GENERATOR "TGZ;TXZ")
-
-list(APPEND CPACK_SOURCE_IGNORE_FILES "^${CMAKE_SOURCE_DIR}/\\.git")
-list(APPEND CPACK_SOURCE_IGNORE_FILES "^${CMAKE_SOURCE_DIR}/build")
-list(APPEND CPACK_SOURCE_IGNORE_FILES "^${CMAKE_BINARY_DIR}")
-
set(
CPACK_PACKAGE_FILE_NAME
"ccache-${VERSION}-${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}"
)
-set(CPACK_SOURCE_PACKAGE_FILE_NAME "ccache-${VERSION}")
-
-configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/PreparePackage.cmake.in
- ${CMAKE_BINARY_DIR}/PreparePackage.cmake
- @ONLY
-)
-
-if(${CMAKE_VERSION} VERSION_LESS "3.16")
- set(CPACK_INSTALL_SCRIPT ${CMAKE_BINARY_DIR}/PreparePackage.cmake)
-else()
- set(CPACK_INSTALL_SCRIPTS ${CMAKE_BINARY_DIR}/PreparePackage.cmake)
-endif()
include(CPack)
-# There are four main scenarios:
+# There are three main scenarios:
#
-# 1. Building from an official source code release archive. In this case the
-# version is unconditionally read from the file VERSION in the top level
-# directory and the code below won't be executed.
-# 2. Building from an unofficial source code archive generated by "git
-# archive", e.g. from a GitHub "archive download"
-# (https://github.com/ccache/ccache/archive/$VERSION.tar.gz). In this case
-# the version_info info string below will be substituted because of
-# export-subst in the .gitattributes file. The version will then be correct
-# if $VERSION refers to a tagged commit. If the commit is not tagged the
-# version will be set to the commit hash instead.
-# 3. Building from an unofficial source code archive not generated by "git
-# archive" (i.e., version_info has not been substituted). In this case we
-# fail the configuration.
-# 4. Building from a Git repository. In this case the version will be a proper
+# 1. Building from a source code archive generated by "git archive", e.g. the
+# official source code archive or one downloaded directly from GitHub via
+# <https://github.com/ccache/ccache/archive/VERSION.tar.gz>. In this case the
+# version_info info string below will be substituted because of export-subst
+# in the .gitattributes file. The version will then be correct if VERSION
+# refers to a tagged commit. If the commit is not tagged the version will be
+# set to the commit hash instead.
+# 2. Building from a source code archive not generated by "git archive" (i.e.,
+# version_info has not been substituted). In this case we fail the
+# configuration.
+# 3. Building from a Git repository. In this case the version will be a proper
# version if building a tagged commit, otherwise "branch.hash(+dirty)".
set(version_info "$Format:%H %D$")
if(version_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])[0-9a-f]* (.*)")
- # Scenario 2.
+ # Scenario 1.
set(hash "${CMAKE_MATCH_1}")
set(ref_names "${CMAKE_MATCH_2}")
if(ref_names MATCHES "tag: v([^,]+)")
set(VERSION "${hash}")
endif()
elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
- # Scenario 4.
+ # Scenario 3.
find_package(Git QUIET)
if(NOT GIT_FOUND)
message(SEND_ERROR "Could not find git")
endif()
if(VERSION STREQUAL "")
- # Scenario 3 or unexpected error.
+ # Scenario 2 or unexpected error.
message(SEND_ERROR "Cannot determine Ccache version")
endif()