]> Untitled Git - godot.git/blob - script.sh
f1c0c39f3241fd8b2a2e87966c8aa57d324b5f32
[godot.git] / script.sh
1 #!/bin/bash
2
3 # builds a Godot project with all its native export config options
4 ################################################################################
5
6 DIR_BUILD=`pwd`/build
7 DIR_DEBUG=$DIR_BUILD/debug
8 DIR_RELEASE=$DIR_BUILD/release
9 DIR_PROJECT=`pwd`/project
10
11 GODOT="docker run -v${DIR_PROJECT}:${DIR_PROJECT} -v${DIR_BUILD}:${DIR_BUILD} cjpalmer/godot:0.1.0"
12 GODOT_OPTS="--headless --path $DIR_PROJECT"
13 EXPORT_PRESETS_CFG="$DIR_PROJECT/export_presets.cfg"
14
15 echo Godot version - $($GODOT --headless --version)
16
17 ################################################################################
18 # execute project build
19
20 # iterate through all build types present in config file
21 # if arg is given, override automated export discovery
22 if [[ -n "$1" ]]
23 then
24     EXPORT_NAMES=$1
25 else
26     EXPORT_NAMES=$(awk -F= '$1=="name"{print $2}' $EXPORT_PRESETS_CFG | sed 's/"//g')
27 fi
28
29 for EXPORT_NAME in $EXPORT_NAMES
30 do
31     echo
32     echo Starting project build for export $EXPORT_NAME
33
34     # create build folders
35     [[ -d $DIR_RELEASE/$EXPORT_NAME ]] || mkdir -p $DIR_RELEASE/$EXPORT_NAME
36     [[ -d $DIR_DEBUG/$EXPORT_NAME ]] || mkdir -p $DIR_DEBUG/$EXPORT_NAME
37
38     # get export name from config file
39     EXPORT_FNAME=$(awk -vname=${EXPORT_NAME} -F= \
40         '$1=="name" && $2~name{f=1} f==1 && $1=="export_path"{print $2;exit}' \
41         $EXPORT_PRESETS_CFG | sed -e 's|^.*/||' -e 's/"//g')
42
43     # do build!
44     echo $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
45     $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
46     echo $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
47     $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
48 done