aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build-otp
blob: 55023ba7d82820234d1367497f29f0daf267e933 (plain) (blame)
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
#!/bin/bash

set -e

function progress {
    local file=$1
    ls=$(ls -l $file)
    while [ true ]; do
	sleep 10
	new_ls=$(ls -l $file)
	if [ "$new_ls" != "$ls" ]; then
	    echo -n "."
	fi
        ls="$new_ls"
    done
}

function do_and_log {
    start_time=`date +%s`
    log="logs/latest-log.$$"
    echo "" >$log
    echo -n "$1..."
    (progress $log) &
    pid=$!
    disown
    shift
    if $* >$log 2>&1; then
	kill $pid >/dev/null 2>&1
        stop_time=`date +%s`
        diff_time=$((stop_time-start_time))
        echo " done, took $diff_time seconds"
    else
	kill $pid >/dev/null 2>&1
        echo " failed."
        tail -n 200 $log
        echo "*** Failed ***"
        exit 1
    fi
}

if [ ! -d "logs" ]; then
    mkdir logs
fi

do_and_log "Autoconfing" ./otp_build autoconf
do_and_log "Configuring" ./otp_build configure
echo Configure result:
tail -n 20 $log
do_and_log "Building OTP" ./otp_build boot -a

if [ "$1" = "release" ]; then
    do_and_log "Releasing OTP" ./otp_build release -a
fi

if [ "$1" = "docs" ]; then
    DOC_TARGET=${TRAVIS_BRANCH:-release/`erts/autoconf/config.guess`}
    DOC_TARGET=${TRAVIS_TAG:-$DOC_TARGET}
    TESTROOT=$PWD/$DOC_TARGET do_and_log "Building documentation" make release_docs
    do_and_log "Linting documentation" make xmllint
    # The code below prepares this build to be used as a deploy to
    # github pages for documentation.
    if [ "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_TAG" = "" -a "$TRAVIS_REPO_SLUG" = "erlang/otp" ]; then
        set -x
        rm -rf logs
        SHA=`git rev-parse --verify HEAD`
        DATE=`git show -s --format=%ci`
        git clean -xfdq -e $DOC_TARGET
        git fetch https://github.com/erlang/cd master
        git checkout -f FETCH_HEAD
        rm -rf _docs/$DOC_TARGET
        mv $DOC_TARGET _docs/$DOC_TARGET
        echo "---" > _docs/$DOC_TARGET.md
        echo "title: $DOC_TARGET" >> _docs/$DOC_TARGET.md
        echo "sha: $SHA" >> _docs/$DOC_TARGET.md
        echo "generated: $DATE" >> _docs/$DOC_TARGET.md
        echo "---" >> _docs/$DOC_TARGET.md
        set +x
    fi
fi

exit 0