]> Untitled Git - godot.git/blob - script.sh
ce9cd20622d542e2f153a69053b5c6f668e6fd77
[godot.git] / script.sh
1 #!/bin/bash
2
3 # gets a Godot release, fetches export templates, 
4 # and builds a project with its native export options
5
6 ################################################################################
7 PWD=`pwd`
8 DIR_DOWNLOAD=$PWD/download
9 DIR_TEMPLATES=$DIR_DOWNLOAD/templates
10 DIR_DEBUG=$PWD/debug
11 DIR_RELEASE=$PWD/release
12 DIR_PROJECT=$PWD/project
13
14 GODOT_VERSION=4.4-stable
15 GODOT_ZIP=Godot_v${GODOT_VERSION}_linux.x86_64.zip
16 GODOT_EXE=Godot_v${GODOT_VERSION}_linux.x86_64
17 GODOT_URI=https://github.com/godotengine/godot/releases/download/$GODOT_VERSION/$GODOT_ZIP
18
19 GODOT_EXPORT_TEMPLATES=Godot_v${GODOT_VERSION}_export_templates.tpz
20 GODOT_TEMPLATE_URI=https://github.com/godotengine/godot/releases/download/$GODOT_VERSION/$GODOT_EXPORT_TEMPLATES
21
22 GODOT=$DIR_DOWNLOAD/$GODOT_EXE
23
24 ################################################################################
25 # get Godot
26
27 [[ -d $DIR_DOWNLOAD ]] || mkpath -p $DIR_DOWNLOAD 
28 [[ -f $DIR_DOWNLOAD/$GODOT_ZIP ]] || wget -P $DIR_DOWNLOAD $GODOT_URI
29 [[ -f $DIR_DOWNLOAD/$GODOT_EXE ]] || unzip $DIR_DOWNLOAD/$GODOT_ZIP -d $DIR_DOWNLOAD
30
31 echo Godot version - $($GODOT --headless --version)
32
33 ################################################################################
34 # get export templates
35
36 [[ -f $DIR_DOWNLOAD/$GODOT_EXPORT_TEMPLATES ]] || wget -P $DIR_DOWNLOAD $GODOT_TEMPLATE_URI
37 [[ -d $DIR_TEMPLATES ]] || unzip -d $DIR_DOWNLOAD $DIR_DOWNLOAD/$GODOT_EXPORT_TEMPLATES
38
39 GODOT_TEMPLATE_VERSION=$(cat $DIR_TEMPLATES/version.txt)
40 LOCAL_TEMPLATES=$HOME/.local/share/godot/export_templates/$GODOT_TEMPLATE_VERSION
41 if [[ ! -d $LOCAL_TEMPLATES ]]
42 then
43     mkdir -p $LOCAL_TEMPLATES
44     cp $DIR_TEMPLATES/* $LOCAL_TEMPLATES
45     # TODO: leaves extra copy of templates
46 fi
47
48 echo Godot export template version - $GODOT_TEMPLATE_VERSION
49 echo Local templates - $LOCAL_TEMPLATES
50
51 ################################################################################
52 # execute project build
53
54 # iterate through all build types present in config file
55 EXPORT_PRESETS_CFG=$DIR_PROJECT/export_presets.cfg
56 EXPORT_NAMES=$(awk -F= '$1=="name"{print $2}' $EXPORT_PRESETS_CFG | sed 's/"//g')
57 GODOT_OPTS="--headless --path $DIR_PROJECT"
58
59 for EXPORT_NAME in $EXPORT_NAMES
60 do
61     echo
62     echo Starting project build for export $EXPORT_NAME
63
64     # create build folders
65     [[ -d $DIR_RELEASE/$EXPORT_NAME ]] || mkdir -p $DIR_RELEASE/$EXPORT_NAME
66     [[ -d $DIR_DEBUG/$EXPORT_NAME ]] || mkdir -p $DIR_DEBUG/$EXPORT_NAME
67
68     # get export name from config file
69     EXPORT_FNAME=$(awk -vname=${EXPORT_NAME} -F= \
70         '$1=="name" && $2~name{f=1} f==1 && $1=="export_path"{print $2;exit}' \
71         $EXPORT_PRESETS_CFG | sed -e 's|^.*/||' -e 's/"//g')
72
73     # do build!
74     echo $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
75     $GODOT $GODOT_OPTS --export-debug "$EXPORT_NAME" $DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
76     echo $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
77     $GODOT $GODOT_OPTS --export-release "$EXPORT_NAME" $DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
78 done