summaryrefslogtreecommitdiffstats
path: root/bootstrap-cpp.sh
blob: bc4c64665961df75491777346513637dd00c63b6 (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
#!/bin/bash -e
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

usage() {
    echo "Usage: $0 [-u] <source-dir> <build-dir>" >&2
}

UNPRIVILEGED=""
while getopts "uh" opt; do
    case "${opt}" in
        u)
            UNPRIVILEGED="-u"
            ;;
        h)
            usage
            exit 0
            ;;
        *)
            usage
            exit 1
            ;;
    esac
done
shift $((OPTIND-1))

# Parse arguments
if [ $# -eq 2 ]; then
    SOURCE_DIR="$1"
    BUILD_DIR="$2"
else
    echo "Wrong number of arguments: expected 2, was $#" >&2
    usage
    exit 1
fi

# Check the source directory
if [ ! -d "$SOURCE_DIR" ] ; then
    echo "Source dir $SOURCE_DIR not found" >&2
    exit 1
fi
SOURCE_DIR=$(realpath "${SOURCE_DIR}")

# Check (and possibly create) the build directory
mkdir -p "${BUILD_DIR}" || {
    echo "Failed to create build directory" >&2
    exit 1
}
BUILD_DIR=$(realpath "${BUILD_DIR}")

# Build it
source /opt/rh/devtoolset-7/enable || true
cd "${SOURCE_DIR}"
bash ./bootstrap.sh full
cd "${BUILD_DIR}"
bash ${SOURCE_DIR}/bootstrap-cmake.sh ${UNPRIVILEGED} "${SOURCE_DIR}"