summaryrefslogtreecommitdiffstats
path: root/godot-update
blob: 06b9003cc1842577c1265bec290ffd8f081ef008 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/sh

RED="\033[0;31m"
RESET="\033[0m"

TEMPLATE_DIR=$HOME/.local/share/godot/templates/3.x

DIR=godot
FORCE=0
CLEAN=0
ANDROID=0
OPTIMIZED=0

for I in  "$@"
do
    case $I in
        f)
        FORCE=1
        ;;
        a)
        ANDROID=1
        ;;
        c)
        CLEAN=1
        ;;
        o)
        OPTIMIZED=1
				;;
				*)
				DIR=$I
    esac
done

function build()
{

    J=$(nproc)

    export CXX=/usr/lib/ccache/bin/clang++
    export CC=/usr/lib/ccache/bin/clang

    rm ./bin/*
    platform=linuxbsd
    platform=x11
    [ $CLEAN -eq 1 ] && scons platform=$platform --clean

    [ $OPTIMIZED -eq 1 ] && opt_flags="use_static_ccp=yes use_lto=yes debug_symbols=no"

    # https://docs.godotengine.org/en/3.2/development/compiling/compiling_for_x11.html
    target=release_debug
    echo -e "build : ${RED}$platform$RESET target=$RED$target$RESET"
    time scons -j$J platform=$platform target=$target tools=yes pulseaudio=no bits=64 $opt_flags warnings=no #custom_modules=../modules

    if [ $ANDROID -eq 1 ]
    then
        cp ../custom.py .
        export ANDROID_HOME=/opt/android-sdk
        export ANDROID_NDK_ROOT=/opt/android-ndk
        [ ! -d $TEMPLATE_DIR ] && mkdir $TEMPLATE_DIR

        [ $CLEAN -eq 1 ] && scons platform=android --clean
        # https://docs.godotengine.org/en/3.2/development/compiling/compiling_for_android.html
        echo -e "${RED}gradlew clean$RESET"
        pushd platform/android/java && ./gradlew --no-daemon cleanGodotTemplates && popd
        ndk_platform=android-22
        for target in release debug;
        do
            for arch in arm64v8 armv7; #x86_6
            do
                echo -e "build : ${RED}android$RESET android_arch=$RED$arch$RESET target=$RED$target$RESET ndk_platform=$RED$ndk_platform$RESET"
                time scons -j$J platform=android target=$target android_arch=$arch ndk_platform=$ndk_platform tools=no disable_3d=true
            done
        done
        echo -e "${RED}gradlew build$RESET"
        pushd platform/android/java && ./gradlew --no-daemon generateGodotTemplates && popd

        cp bin/android* $TEMPLATE_DIR/
        rm custom.py
    fi
}

pushd $DIR

    if [ $CLEAN -eq 1 ]
    then
        find -name \*.o -delete
        find -name \*.gen.h -delete
        find -name \*.gen.cpp -delete
    fi

    HEAD_PREV=$(git log HEAD~1.. --pretty=format:'%H' | head -n1)
    echo -e "current HEAD : $RED$HEAD_PREV$RESET"
    git pull
    HEAD_NOW=$(git log HEAD~1.. --pretty=format:'%H' | head -n1)
    echo -e "updated HEAD : $RED$HEAD_NOW$RESET"

    if [ $FORCE = 1 -o "$HEAD_PREV" != "$HEAD_NOW" ]
    then
        build
        git log $HEAD_PREV..
    fi

popd

strip $DIR/bin/godo.*
ls -lh $DIR/bin/

# https://godot-build-options-generator.github.io
# scons -j4 platform=linuxbsd target=release_debug tools=yes pulseaudio=no bits=64 warnings=no #custom_modules=../modules
# scons -j4 platform=android target=debug android_arch=arm64v8 ndk_platform=android-22 tools=no disable_3d=true