forked from unknown-horizons/godot-port
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·72 lines (59 loc) · 2.08 KB
/
build.sh
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
#!/bin/sh
# Change to the project's name.
PROJECTNAME="UnknownHorizons"
# Godot version or path.
GODOT="3.1"
# Note: This script expects the export presets to be called "windows" and "linux".
# Look for the Godot binary.
if [ -f "$GODOT" ]; then
: # Do nothing. It's already a valid path.
elif [ -f "$HOME/.local/share/Godot/$GODOT/Godot" ]; then
GODOT="$HOME/.local/share/Godot/$GODOT/Godot"
elif [ -f "$HOME/.local/bin/Godot/$GODOT/Godot" ]; then
GODOT="$HOME/.local/bin/Godot/$GODOT/Godot"
elif [ -f "$HOME/Documents/Godot/$GODOT/Godot" ]; then
GODOT="$HOME/Documents/Godot/$GODOT/Godot"
# Godot snaps use the "binary-v1-v2" name form
elif [ -f "/snap/bin/godot-${GODOT%%.*}-${GODOT##*.}" ]; then
GODOT="/snap/bin/godot-${GODOT%%.*}-${GODOT##*.}"
# Godot on macos
elif [ -f "/Applications/Godot.app/Contents/MacOS/Godot" ]; then
GODOT="/Applications/Godot.app/Contents/MacOS/Godot"
else
echo "Error: Can't find the Godot editor. Can't build. "
exit 1
fi
# Is this a Godot project?
if [ ! -f "project.godot" ]; then
echo "Error: This isn't the directory of a Godot project. Can't build. "
exit 2
fi
if [ ! -f "export_presets.cfg" ]; then
echo "Error: There isn't an export presets file. Can't build. "
exit 3
fi
# Ensure folder structure exists.
mkdir -p "Builds/Desktop"
# Builds.
echo "Exporting Linux binary... "
$GODOT --path . --export linux "Builds/Desktop/$PROJECTNAME.x86_64"
echo "Exporting Windows binary... "
$GODOT --path . --export windows "Builds/Desktop/$PROJECTNAME.exe"
if [ "$(uname -s)" == "Darwin" ]; then
echo "Exporting macOS binary... "
$GODOT --path . --export mac "Builds/Desktop/$PROJECTNAME.dmg"
else
echo "Not building on macOS, export of dmg file skipped. "
fi
# Make everything executable.
chmod -R +x Builds/*
# Check if the files exist, if not, throw an error.
if [ ! -f "Builds/Desktop/$PROJECTNAME.x86_64" ] || [ ! -f "Builds/Desktop/$PROJECTNAME.exe" ]; then
echo
echo "Error: Building failed! Please see the Godot log for more information. "
echo
exit 4
fi
echo
echo "SUCCESS building the project! "
echo