-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the R build script to the devcontainer
- Loading branch information
1 parent
3c7db97
commit b48e481
Showing
2 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/bash | ||
|
||
set -Eeuo pipefail | ||
|
||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) | ||
BASE_DIR=$(cd "$SCRIPT_DIR/.." && pwd) | ||
R_DIR="" | ||
|
||
if [ ! -d "$BASE_DIR" ]; then | ||
echo "Could not determine absolute dir of $0" | ||
echo "Maybe accessed with symlink" | ||
exit 1 | ||
fi | ||
|
||
function usage() { | ||
echo "$0 [-d] <R sources path>" | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-d | --debug) | ||
export CFLAGS="-ggdb3 -O0" | ||
export CXXFLAGS="-ggdb3 -O0" | ||
export CPPFLAGS="-ggdb3 -O0" | ||
echo "Building a debug version of R" | ||
shift | ||
;; | ||
-*) | ||
echo "Unknown option $1" | ||
exit 1 | ||
;; | ||
*) | ||
if [[ -z "$R_DIR" ]]; then | ||
R_DIR="$1" | ||
shift | ||
else | ||
echo "Unknown options $*" | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z "$R_DIR" ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
echo "Building in $R_DIR" | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
USING_OSX=1 | ||
else | ||
USING_OSX=0 | ||
fi | ||
|
||
if [[ ! -f ${R_DIR}/.git ]]; then | ||
echo "-> update submodules" | ||
git submodule update --init | ||
fi | ||
|
||
function build { | ||
cd "$R_DIR" | ||
|
||
if [[ $(git diff --shortstat 2>/dev/null | tail -n1) != "" ]]; then | ||
echo "** warning: $R_DIR repo is dirty" | ||
sleep 1 | ||
fi | ||
|
||
tools/rsync-recommended | ||
|
||
if [[ ! -f Makefile ]]; then | ||
echo "-> configure" | ||
if [ $USING_OSX -eq 1 ]; then | ||
./configure --enable-R-shlib --with-internal-tzcode --with-ICU=no --with-x=no || cat config.log | ||
else | ||
./configure | ||
fi | ||
fi | ||
|
||
if [ ! -f doc/FAQ ]; then | ||
touch doc/FAQ | ||
fi | ||
|
||
if [ ! -f "$R_DIR/SVN-REVISION" ]; then | ||
# R must either be built from a svn checkout, or from the tarball generated by make dist | ||
# this is a workaround to build it from a git mirror | ||
# see https://github.com/wch/r-source/wiki/Home/6d35777dcb772f86371bf221c194ca0aa7874016#building-r-from-source | ||
echo -n 'Revision: ' >SVN-REVISION | ||
# get the latest revision that is not a rir patch | ||
REV=$(git log --grep "git-svn-id" -1 --format=%B | grep "^git-svn-id" | sed -E 's/^git-svn-id: https:\/\/svn.r-project.org\/R\/[^@]*@([0-9]+).*$/\1/') | ||
# can fail on shallow checkouts, so let's put the last known there | ||
if [ "$REV" == "" ]; then | ||
REV='74948' | ||
fi | ||
echo "$REV" >>SVN-REVISION | ||
echo -n 'Last Changed Date: ' >>SVN-REVISION | ||
REV_DATE=$(git log --grep "git-svn-id" -1 --pretty=format:"%ad" --date=iso | cut -d' ' -f1) | ||
# can fail on shallow checkouts, so let's put the last known there | ||
if [ "$REV_DATE" == "" ]; then | ||
REV_DATE='2018-07-02' | ||
fi | ||
echo "$REV_DATE" >>SVN-REVISION | ||
|
||
rm -f non-tarball | ||
fi | ||
|
||
echo "-> make" | ||
make -j8 | ||
} | ||
|
||
build |