]> Untitled Git - godot-builder.git/blob - entrypoint.sh
27c3ef5909811d19e686f817acca69c69be19edc
[godot-builder.git] / entrypoint.sh
1 #!/bin/bash
2
3 # builds a Godot project with all its native export config options
4 ################################################################################
5 # get project 
6
7 [[ -z "$URI_PROJECT_SNAPSHOT" ]] && echo No URI_PROJECT_SNAPSHOT, exiting && exit 1
8
9 echo Getting project - $URI_PROJECT_SNAPSHOT
10
11 DIR_BUILD=/build
12 DIR_PROJECT_ROOT=/project
13
14 wget $URI_PROJECT_SNAPSHOT && \
15     tar -xf *.tar.gz -C $DIR_PROJECT_ROOT && \
16     rm *.tar.gz
17
18 DIR_PROJECT=$(find $DIR_PROJECT_ROOT -type f -name project.godot | sed 's|/project.godot||')
19
20 echo Project directory - $DIR_PROJECT
21
22 ################################################################################
23 # execute project build
24
25 DIR_DEBUG=$DIR_BUILD/debug
26 DIR_RELEASE=$DIR_BUILD/release
27
28 GODOT="godot"
29 GODOT_OPTS="--headless --path $DIR_PROJECT"
30 EXPORT_PRESETS_CFG="$DIR_PROJECT/export_presets.cfg"
31
32 echo Godot version - $($GODOT --headless --version)
33
34 # iterate through all build types present in config file
35 # if arg is given, override automated export discovery
36 if [[ -n "$1" ]]
37 then
38     EXPORT_NAMES=$1
39 else
40     EXPORT_NAMES=$(awk -F= '$1=="name"{print $2}' $EXPORT_PRESETS_CFG | sed 's/"//g')
41 fi
42
43 for EXPORT_NAME in $EXPORT_NAMES
44 do
45     echo
46     echo Starting project build for export $EXPORT_NAME
47
48     # create build folders
49     [[ -d $DIR_RELEASE/$EXPORT_NAME ]] || mkdir -p $DIR_RELEASE/$EXPORT_NAME
50     [[ -d $DIR_DEBUG/$EXPORT_NAME ]] || mkdir -p $DIR_DEBUG/$EXPORT_NAME
51
52     # get export name from config file
53     EXPORT_FNAME=$(awk -vname=${EXPORT_NAME} -F= \
54         '$1=="name" && $2~name{f=1} f==1 && $1=="export_path"{print $2;exit}' \
55         $EXPORT_PRESETS_CFG | sed -e 's|^.*/||' -e 's/"//g')
56
57     # do build!
58     echo $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
59     $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
60     echo $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
61     $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
62 done