From 24d4ae8eb2efcaae974b6c900ebf1c64020bb90e Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Tue, 17 Sep 2024 17:01:17 +0200 Subject: [PATCH] dynamically generate version info of jaspColumnEncoder --- .gitignore | 2 ++ configure | 17 +++++++++++++++++ configure.win | 17 +++++++++++++++++ inst/jaspColumnEncoderVersion.R.in | 4 ++++ 4 files changed, 40 insertions(+) create mode 100644 inst/jaspColumnEncoderVersion.R.in diff --git a/.gitignore b/.gitignore index e0b63c6..7578183 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,5 @@ src/Makevars.win !.github !.Rbuildignore _processedLockFile.lock + +R/jaspColumnEncoderVersion.R diff --git a/configure b/configure index f0edbdb..a23add8 100755 --- a/configure +++ b/configure @@ -21,6 +21,7 @@ if [ "$UNAME" = "SunOS" ]; then fi DOWNLOAD_SUCCESS=1 +EXTRA_INFO="Version info is only available when git is available!" if [ "${INCLUDE_DIR}" ]; then @@ -29,6 +30,16 @@ if [ "${INCLUDE_DIR}" ]; then PKG_CXXFLAGS="-I\"${INCLUDE_DIR}\"" JASPCOLUMNENCODER_DIR="${INCLUDE_DIR}" + if git --version 2>&1 >/dev/null; then + + if [ -d "${JASPCOLUMNENCODER_DIR}/.git" ]; then + EXTRA_INFO="include_dir, git_repo at: + $(git --git-dir="${JASPCOLUMNENCODER_DIR}/.git" --work-tree="${JASPCOLUMNENCODER_DIR}" log -1 --oneline)" + else + EXTRA_INFO='include_dir that is not a git repo.' + fi + + fi + else PKG_CXXFLAGS='-I"../inst/include/jaspColumnEncoder"' @@ -55,6 +66,8 @@ else fi + EXTRA_INFO="$(git --git-dir="${WORK_TREE}/.git" --work-tree="${WORK_TREE}" log -1 --oneline)" + fi if [ "${DOWNLOAD_SUCCESS}" -ne "0" ]; then @@ -69,6 +82,7 @@ else curl --silent --location https://api.github.com/repos/jasp-stats/jaspColumnEncoder/tarball | tar xz --strip=1 --directory inst/include/jaspColumnEncoder DOWNLOAD_SUCCESS=$? + EXTRA_INFO="curl was used to download jaspColumnEncoder, no version info is available." fi fi @@ -85,6 +99,7 @@ else wget --quiet --output-document=- https://api.github.com/repos/jasp-stats/jaspColumnEncoder/tarball | tar xz --strip=1 --directory inst/include/jaspColumnEncoder DOWNLOAD_SUCCESS=$? + EXTRA_INFO="wget was used to download jaspColumnEncoder, no version info is available." fi fi @@ -112,5 +127,7 @@ else fi sed -e "s|@cppflags@|${PKG_CXXFLAGS}|" -e "s|@src_sources@|${SRC_SOURCES}|" -e "s|@jaspColumnEncoder_sources@|${JASPCOLUMNENCODER_SOURCES}|" src/Makevars.in > src/Makevars +sed -e "s|@extrainfo@|${EXTRA_INFO}|" inst/jaspColumnEncoderVersion.R.in > R/jaspColumnEncoderVersion.R + exit 0 diff --git a/configure.win b/configure.win index 3482dff..ece3f25 100755 --- a/configure.win +++ b/configure.win @@ -5,6 +5,8 @@ # install.packages("jaspBase", ...) DOWNLOAD_SUCCESS=1 +EXTRA_INFO="Version info is only available when git is available!" + if [ "${INCLUDE_DIR}" ]; then @@ -13,6 +15,16 @@ if [ "${INCLUDE_DIR}" ]; then PKG_CXXFLAGS="-I\"${INCLUDE_DIR}\"" JASPCOLUMNENCODER_DIR="${INCLUDE_DIR}" + if git --version 2>&1 >/dev/null; then + + if [ -d "${JASPCOLUMNENCODER_DIR}/.git" ]; then + EXTRA_INFO="include_dir, git_repo at: + $(git --git-dir="${JASPCOLUMNENCODER_DIR}/.git" --work-tree="${JASPCOLUMNENCODER_DIR}" log -1 --oneline)" + else + EXTRA_INFO='include_dir that is not a git repo.' + fi + + fi + else PKG_CXXFLAGS='-I"../inst/include/jaspColumnEncoder"' @@ -39,6 +51,8 @@ else fi + EXTRA_INFO="$(git --git-dir="${WORK_TREE}/.git" --work-tree="${WORK_TREE}" log -1 --oneline)" + fi if [ "${DOWNLOAD_SUCCESS}" -ne "0" ]; then @@ -53,6 +67,7 @@ else curl --silent --location https://api.github.com/repos/jasp-stats/jaspColumnEncoder/tarball | tar xz --strip=1 --directory inst/include/jaspColumnEncoder DOWNLOAD_SUCCESS=$? + EXTRA_INFO="curl was used to download jaspColumnEncoder, no version info is available." fi fi @@ -69,6 +84,7 @@ else wget --quiet --output-document=- https://api.github.com/repos/jasp-stats/jaspColumnEncoder/tarball | tar xz --strip=1 --directory inst/include/jaspColumnEncoder DOWNLOAD_SUCCESS=$? + EXTRA_INFO="wget was used to download jaspColumnEncoder, no version info is available." fi fi @@ -97,5 +113,6 @@ else fi sed -e "s|@cppflags@|${PKG_CXXFLAGS}|" -e "s|@src_sources@|${SRC_SOURCES}|" -e "s|@jaspColumnEncoder_sources@|${JASPCOLUMNENCODER_SOURCES}|" src/Makevars.in > src/Makevars.win +sed -e "s|@extrainfo@|${EXTRA_INFO}|" inst/jaspColumnEncoderVersion.R.in > R/jaspColumnEncoderVersion.R exit 0 diff --git a/inst/jaspColumnEncoderVersion.R.in b/inst/jaspColumnEncoderVersion.R.in new file mode 100644 index 0000000..b5797af --- /dev/null +++ b/inst/jaspColumnEncoderVersion.R.in @@ -0,0 +1,4 @@ +jaspColumnEncoderInfo <- function() { + return(r"{@extrainfo@}") +} +