This is an automated email from the ASF dual-hosted git repository.

bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 3ee0c3b8094e746111af7ba3b883717d95c3efcf
Author: Benjamin Bannier <[email protected]>
AuthorDate: Mon Sep 9 09:19:51 2019 +0200

    Added a `dist` target to the cmake build.
    
    This patch adds a `dist` target to the cmake build, analogous to the
    target provided by the autotools build.
    
    While cmake already provides a `package_source` target to create a
    source archive it does not take care of only including relevant files,
    but instead adds all files to the archive, e.g., including build or
    backup files which should not be part of a release. For that reason this
    patch introduces a script which performs a temporary `git clone` from
    the checked out git repository and creates the archive from that clean
    tree.
    
    This patch also removes a hardcoded list of ignored files which was
    by design not exhaustive.
    
    Review: https://reviews.apache.org/r/71240/
---
 CMakeLists.txt | 28 +++-------------------------
 cmake/dist.sh  | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc50dd4..319ce99 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,31 +67,6 @@ endif ()
 
 # PACKAGING.
 ############
-# List of sources we will ignore when generating a source package.
-# We assume there are no artifacts from an autotools build.
-#
-# NOTE: An in-source build is not supported. The build directory
-# must be different than the source directory.
-set(CPACK_SOURCE_IGNORE_FILES
-  .clang-format;
-  .gitignore;
-  .reviewboardrc;
-  bootstrap.bat;
-  bootstrap;
-  configure.ac;
-  Doxyfile;
-  mesos.pc.in;
-  /.git/;
-  /docs/;
-  /m4/;
-  /mpi/;
-  /site/;
-  /support/;
-  ${CMAKE_BINARY_DIR};)
-
-# Convert the ignore list to a string (as required by CPack).
-set(CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
-
 # Set the basename of any packages to 'mesos-<version>'.
 set(CPACK_PACKAGE_FILE_NAME "mesos-${MESOS_PACKAGE_VERSION}")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
@@ -120,3 +95,6 @@ option(CPACK_SOURCE_TZ   "Enable to build TZ source 
packages"   OFF)
 option(CPACK_SOURCE_ZIP  "Enable to build ZIP source packages"  OFF)
 
 include(CPack)
+
+add_custom_target(dist
+  COMMAND ${CMAKE_SOURCE_DIR}/cmake/dist.sh ${MESOS_PACKAGE_VERSION})
diff --git a/cmake/dist.sh b/cmake/dist.sh
new file mode 100755
index 0000000..65dc04c
--- /dev/null
+++ b/cmake/dist.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -e
+set -o pipefail
+
+# Check for unstaged or uncommitted changes.
+if ! $(git diff-index --quiet HEAD --); then
+  echo 'Please commit or stash any changes before running `dist`.'
+  exit 1
+fi
+
+VERSION=$1
+if [ -z "${VERSION}" ]; then
+  echo "Specify a version number as first argument"
+  exit 1
+fi
+
+ORIGIN=$PWD
+MESOS_DIR=$(git rev-parse --show-toplevel)
+
+WORKDIR=$(mktemp -d)
+trap 'rm -rf ${WORKDIR}' EXIT
+
+pushd "${WORKDIR}" || exit 1
+
+git clone "${MESOS_DIR}"
+mkdir build
+pushd build
+
+cmake ../$(basename "${MESOS_DIR}")
+cmake --build . --target package_source -j "$(nproc)"
+cp mesos-"${VERSION}".tar.gz "${ORIGIN}"
+
+popd
+popd
+
+echo "Successfully created ${ORIGIN}/mesos-${VERSION}.tar.gz"

Reply via email to