3 # gets a Godot release, fetches export templates,
4 # and builds a project with its native export options
6 ################################################################################
8 DIR_DOWNLOAD=$PWD/download
9 DIR_TEMPLATES=$DIR_DOWNLOAD/templates
11 DIR_RELEASE=$PWD/release
12 DIR_PROJECT=$PWD/project
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
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
22 GODOT=$DIR_DOWNLOAD/$GODOT_EXE
24 ################################################################################
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
31 echo Godot version - $($GODOT --headless --version)
33 ################################################################################
34 # get export templates
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
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 ]]
43 mkdir -p $LOCAL_TEMPLATES
44 cp $DIR_TEMPLATES/* $LOCAL_TEMPLATES
45 # TODO: leaves extra copy of templates
48 echo Godot export template version - $GODOT_TEMPLATE_VERSION
49 echo Local templates - $LOCAL_TEMPLATES
51 ################################################################################
52 # execute project build
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"
59 for EXPORT_NAME in $EXPORT_NAMES
62 echo Starting project build for export $EXPORT_NAME
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
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')
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