-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_gitwork.sh
executable file
·97 lines (81 loc) · 2.66 KB
/
build_gitwork.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# This is a common script for all the other build_*.sh scripts. It does the
# droll, unexciting work of checking out the latest (good) git commit, cleaning
# out old compile artifacts, setting up logging, etc...
#
# It needs the following environment variables set in order to work:
# ORIG_DIR, OS, JULIA_GIT_BRANCH
# Die on errors. Very important. :P
set -e
# Set our build directory
BUILD_DIR=$(echo ~)/tmp/julia-packaging/${OS}
mkdir -p $BUILD_DIR
cd $BUILD_DIR
JULIA_GIT_URL="https://github.com/JuliaLang/julia.git"
# Checkout julia
if [[ ! -d "julia-${JULIA_GIT_BRANCH}" ]]; then
git clone ${JULIA_GIT_URL} julia-${JULIA_GIT_BRANCH}
fi
# Go into our checkout of JULIA_GIT_URL
cd julia-${JULIA_GIT_BRANCH}
# Setup some commonly-used variables
JULIA_VERSION=$(cat VERSION)
VERSDIR=$(cut -d. -f1-2 < VERSION)
BANNER="Official http://julialang.org/ release"
makevars=( VERBOSE=1 TAGGED_RELEASE_BANNER="${BANNER}" )
# These are the most common failure modes, so clear everything out that we can
rm -rf deps/libuv deps/Rmath
rm -f usr/bin/libuv*
rm -f usr/bin/libsupport*
rm -f bin/sys*.ji
git submodule update
git reset --hard
git checkout ${JULIA_GIT_BRANCH}
git fetch
git reset --hard origin/${JULIA_GIT_BRANCH}
make -C deps clean-openlibm
make -j1 cleanall
# Find the last commit that passed a Travis build
set +e
if [[ -z "$GIVEN_COMMIT" ]]; then
LAST_GOOD_COMMIT=$(${ORIG_DIR}/get_last_good_commit.py)
if [ -z "$LAST_GOOD_COMMIT" ]; then
echo "ERROR: No good commits detected, going with HEAD!"
LAST_GOOD_COMMIT="HEAD"
fi
else
LAST_GOOD_COMMIT="$GIVEN_COMMIT"
fi
git checkout -B ${JULIA_GIT_BRANCH} $LAST_GOOD_COMMIT
if [[ "$?" != 0 ]]; then
echo "Couldn't checkout last good commit, going with master/HEAD!"
git checkout master
fi
# Setup the target we're going to create/upload
JULIA_COMMIT=$(git rev-parse --short HEAD)
TARGET="julia-${JULIA_VERSION}-${JULIA_COMMIT}-${OS}.$BIN_EXT"
if [[ "$JULIA_GIT_BRANCH" != "master" ]]; then
TARGET="julia-${JULIA_VERSION}-$(basename $JULIA_GIT_BRANCH)-$(JULIA_COMMIT)-${OS}.$BIN_EXT"
fi
# Setup logging
LOG_FILE="$BUILD_DIR/${TARGET%.*}.log"
function upload_log {
echo "Uploading log file $LOG_FILE..."
${ORIG_DIR}/upload_binary.jl $LOG_FILE logs/$(basename $LOG_FILE)
}
# Make SURE that this gets called, even if we die out
trap upload_log EXIT
echo "" > "$LOG_FILE"
# The cool redirection seems to fail under wine, unfortunately
if [[ $OS == win* ]]; then
exec > "$LOG_FILE"
exec 2>"$LOG_FILE"
else
exec > >(tee -a "$LOG_FILE")
exec 2> >(tee -a "$LOG_FILE" >&2)
fi
set -x
# Show the date so that the log files make a little more sense
date
echo "Building $TARGET"
set -e