Skip to content

Commit

Permalink
dynamically generate version info of jaspColumnEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
vandenman authored and JorisGoosen committed Sep 19, 2024
1 parent f12f1ff commit 24d4ae8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ src/Makevars.win
!.github
!.Rbuildignore
_processedLockFile.lock

R/jaspColumnEncoderVersion.R
17 changes: 17 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions inst/jaspColumnEncoderVersion.R.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jaspColumnEncoderInfo <- function() {
return(r"{@extrainfo@}")
}

0 comments on commit 24d4ae8

Please sign in to comment.