-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
126 lines (103 loc) · 3.66 KB
/
build.sh
File metadata and controls
126 lines (103 loc) · 3.66 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
source env.sh
########################################################################
echo "Building $PKG..."
# Modern installations of Unreal Tournament move the ucc and ut executables to System64. If there
# isn't a ucc-bin or ut-bin present in System, this is likely the case, so we need to symlink
# in order to build the project successfully
echo "Locating UCC and UT executables..."
if [ ! -f "$SYS/ucc-bin" ] && [ -f "$SYS64/ucc-bin" ]; then
echo "Symlinking ucc-bin to $SYS/ucc-bin"
ln -s "$(readlink -f "$SYS64/ucc-bin")" "$SYS/ucc-bin"
fi
if [ ! -f "$SYS/ut-bin" ] && [ -f "$SYS64/ut-bin" ]; then
echo "Symlinking ut-bin to $SYS/ut-bin"
ln -s "$(readlink -f "$SYS64/ut-bin")" "$SYS/ut-bin"
fi
if [ ! -f "$SYS/ucc-bin" ] || [ ! -f "$SYS/ut-bin" ]; then
echo "UCC or UT binary not found!"
exit 1
else
echo "Found executable files:"
echo "UCC: $(realpath "$SYS/ucc-bin")"
echo "UT: $(realpath "$SYS/ut-bin")"
printf "\n"
fi
if [ ! -f "$CONFIG" ]; then
echo "Makefile not found at $CONFIG!"
exit 1
fi
# Verifies the make file's structure. Note that this only checks if the package is specified at all
# rather than checking the dependency order. Be absolutely sure PKG is your last EditPackage!
if ! grep -F "EditPackages=$PKG" "$CONFIG" &> /dev/null; then
echo "EditPackages=$PKG not found in $CONFIG! Make sure the package is added after its dependencies."
exit 1
fi
# Make the build dir if it doesn't exist yet
mkdir -p "$BUILD_DIR"
# Delete previous build files
rm -vf "$SYS/$PKG.int"
rm -vf "$BUILD_DIR/*"
# Copy our project folder to UT's root folder
echo "Copying project folder to $UT_PATH..."
mkdir -p "$UT_PATH/$PKG"
for F in "../$PKG"/*; do
filename=$(basename "$F")
# Ignores hidden files and UT's root, things would get messy very quickly otherwise
if [ "$filename" != "$UT_PATH" ] && [ "$filename" != "." ] && [ "$filename" != ".." ]; then
printf "\033[0;37m"
cp -rv "$F" "$UT_PATH/$PKG"
printf "\033[0m"
fi
done
# UCC does not have a -nohomedir switch like the UT binary does. To avoid polluting the user's
# data folder, we have to temporarily rename it and copy the base system files there. In addition
# to this, we make a backup of the user's data folder in case anything goes wrong during the build
# process.
if [ -d ~/.utpg ]; then
printf "\033[0;33mFound existing UT data folder, renaming to ~/.utpg.user\033[0m\n"
printf "\033[0;37m"
mv ~/.utpg ~/.utpg.user
cp -r ~/.utpg.user ~/.utpg.bak
printf "\033[0m"
fi
echo "Creating temporary base profile at ~/.utpg"
mkdir -p ~/.utpg
cp -r "$SYS" ~/.utpg
# Build project
echo "Running UCC with makefile $(realpath "$CONFIG") and input files $INS"
printf "\033[0;37m"
echo "Command: ./ucc-bin make ini=\"../../$CONFIG\" \"$INS\""
printf "\033[0m\n"
OUTPUT=$(cd "$SYS" || exit 1; ./ucc-bin make ini="../../$CONFIG" "$INS")
STATUS=$?
cleanup() {
printf "Cleaning up...\n"
# Remove the project folder from UT's root folder
rm -rf "${UT_PATH:?}/${PKG:?}"
# Restore the user's UT data folders
if [ -d ~/.utpg.user ]; then
echo "Restoring user's UT data folder..."
printf "\033[0;37m"
rm -rf ~/.utpg
mv -v ~/.utpg.user ~/.utpg
printf "\033[0m"
fi
}
# Check UCC's status before continuing
echo "$OUTPUT"
if [ $STATUS -ne 0 ]; then
printf '\n\033[0;31mUCC exited with status %s\033[0m\n\n' "$STATUS"
cleanup; exit $STATUS
else
printf '\n\033[0;32mUCC exited with status 0\033[0m\n\n'
# Move the newly built files
printf "Moving build files to %s...\n" "$BUILD_DIR"
printf "\033[0;37m"
mv -v "${OUTS[@]}" "$BUILD_DIR"
cp -v "Classes/$PKG.int" "$BUILD_DIR"
printf "\033[0m\n"
fi
cleanup;
printf "\n\033[0;32mBuild complete!\033[0m\n"
exit 0