installOrBuild.sh 2.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/bash

if [[ "$OSTYPE" == "darwin"* ]]; then
    # Mac OSX
    echo "You are on macOS. Check if brew is installed..."
    if ! [ -x "$(command -v brew)" ]; then
        echo 'Error: you need brew to install boost. See https://brew.sh/.' >&2
        exit 1
    fi
    if [[ -z "$(brew ls --versions boost)" ]]; then
        echo "Installing boost..."
        brew install boost
    else
        echo "Updating boost..."
        brew upgrade boost
    fi
    if [[ -z "$(brew ls --versions boost-build)" ]]; then
        echo "Installing boost-build..."
        brew install boost-build
    else
        echo "Updating boost-build..."
        brew upgrade boost-build
    fi
    echo "Boost installation complete"
25 26
elif [[ "$OSTYPE" == "msys" ]] || ! [[ -z "$GITLAB_CI" ]]; then
    # windows or gitlab ci
27 28
    echo "You are on Windows"
    GIT_DIR="boost.git"
29
    if ! [ -d "$GIT_DIR" ]; then
30
        echo "We have to clone the repo, this will take approximately 6.5 minutes"
31
        git clone --depth 1 --shallow-submodules --recurse-submodules --jobs 32 https://github.com/boostorg/boost.git "$GIT_DIR"
32 33
        cd "$GIT_DIR"
        echo "Init the build"
34 35 36 37 38
        if ! [[ -z "$GITLAB_CI" ]]; then
            # in the ci we need the normal compiler to build the b2 tool
            OLD_CXX="$CXX"
            export CXX="/usr/bin/g++"
        fi
39
        ./bootstrap.sh
Leander Schulten's avatar
Leander Schulten committed
40 41 42 43 44
        # ls
        # TARGET="x86_64-w64-mingw32.shared.posix"
        # echo "using gcc : mxe : ${TARGET}-g++ : <rc>${TARGET}-windres <archiver>${TARGET}-ar <ranlib>${TARGET}-ranlib ;" > 'project-config.jam'
        
        # cat project-config.jam
45 46 47 48 49
        if ! [[ -z "$GITLAB_CI" ]]; then
            # set to old value, so that the cross compiling works
            export CXX="$OLD_CXX"
            echo "CXX: $CXX"
        fi
50 51 52 53
    else
        cd "$GIT_DIR"
        git pull
    fi
54 55 56
    if [[ -z "$GITLAB_CI" ]]; then
        EXE=".exe" # windows need the .exe postfix
    fi
57
    echo "Build boost, this will take approximately 3 minutes, if boost is not already build."
Leander Schulten's avatar
Leander Schulten committed
58
    ./b2$EXE --prefix=../ -q --layout=tagged --with-coroutine --with-context abi=ms architecture=x86 binary-format=pe threadapi=win32 target-os=windows toolset=gcc link=shared threading=multi runtime-link=shared address-model=64 install
59 60 61 62
    echo "Boost build is finished"
else
    # linux?
    echo "You are on Linux"
63
    echo "Linux is currently not supported (no mashine to test). You must install boost yourself. Maybe look at the windows version in this file."
64
fi