42 lines
1.2 KiB
Shell
Executable file
42 lines
1.2 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
unity_editor="${UNITY_EDITOR:-/opt/unity/2018.1.6f1/Editor/Unity}"
|
|
output_dir="$repo_dir/Builds/linux"
|
|
log_file="$output_dir/build.log"
|
|
|
|
if [[ ! -x "$unity_editor" ]]; then
|
|
echo "Set UNITY_EDITOR to the Unity 2018.1.6f1 Editor/Unity executable." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$output_dir"
|
|
echo "Building Linux x86_64 player; log: $log_file"
|
|
|
|
# Unity 2018 on Linux still needs an X server in batch mode.
|
|
runner=()
|
|
if [[ -z "${DISPLAY:-}" ]]; then
|
|
if ! command -v xvfb-run >/dev/null; then
|
|
echo "Install xvfb and xauth for builds without a display." >&2
|
|
exit 1
|
|
fi
|
|
runner=(xvfb-run -a)
|
|
fi
|
|
|
|
if "${runner[@]}" "$unity_editor" \
|
|
-batchmode -nographics -quit \
|
|
-projectPath "$repo_dir/UnityProject" \
|
|
-buildTarget Linux64 \
|
|
-buildLinux64Player "$output_dir/Simulation.x86_64" \
|
|
-logFile "$log_file"; then
|
|
if [[ ! -x "$output_dir/Simulation.x86_64" ]]; then
|
|
echo "Unity exited without producing a Linux player. See $log_file." >&2
|
|
exit 1
|
|
fi
|
|
echo "Built $output_dir/Simulation.x86_64"
|
|
else
|
|
result=$?
|
|
[[ ! -f "$log_file" ]] || tail -n 60 "$log_file" >&2
|
|
exit "$result"
|
|
fi
|