2023-01-15 21:34:52 -07:00
|
|
|
#!/bin/bash
|
2023-01-14 23:14:06 -07:00
|
|
|
|
2023-01-15 21:34:52 -07:00
|
|
|
set -e
|
2023-01-14 23:14:06 -07:00
|
|
|
# Number of jobs == core count
|
|
|
|
jobs=$(grep -c ^processor /proc/cpuinfo)
|
|
|
|
|
|
|
|
# Calculate absolute paths for docker to do mounts
|
|
|
|
srcdir=$(realpath "$(dirname "$(readlink -f "$0")")"/..)
|
|
|
|
|
|
|
|
cd "$srcdir"/build
|
|
|
|
|
2023-01-15 21:34:52 -07:00
|
|
|
builder_uid=$(id -u)
|
|
|
|
|
2023-01-14 23:14:06 -07:00
|
|
|
mkdir -p win64-cross
|
|
|
|
mkdir -p win64-cross/output
|
2023-01-24 20:27:12 -07:00
|
|
|
mkdir -p win64-cross/ccache
|
2023-01-14 23:14:06 -07:00
|
|
|
|
2023-01-15 21:34:52 -07:00
|
|
|
# Check for sudo; we want to use the real user
|
|
|
|
if [[ $(id -u) -eq 0 ]]; then
|
|
|
|
if [[ -z "$SUDO_UID" || "$SUDO_UID" -eq 0 ]]; then
|
|
|
|
echo "Please don't run this script directly as root, use sudo instead:"
|
|
|
|
echo
|
|
|
|
echo " sudo $0"
|
|
|
|
# This is because we can't change the buildmaster UID in the container to 0 --
|
|
|
|
# that's already taken by root.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If this was run using sudo, let's make sure the directories are owned by the
|
|
|
|
# real user (and set the BUILDER_UID to it)
|
|
|
|
builder_uid=$SUDO_UID
|
2023-01-27 16:12:02 -07:00
|
|
|
chown -R $builder_uid win64-cross
|
2023-01-15 21:34:52 -07:00
|
|
|
fi
|
|
|
|
|
2023-01-14 23:14:06 -07:00
|
|
|
# Assumes you built a container image called dfhack-build-msvc from
|
|
|
|
# https://github.com/BenLubar/build-env/tree/master/msvc, see
|
|
|
|
# docs/dev/compile/Compile.rst.
|
|
|
|
#
|
|
|
|
# NOTE: win64-cross is mounted in /src/build due to the hardcoded `cmake ..` in
|
|
|
|
# the Dockerfile
|
2023-01-24 17:17:49 -07:00
|
|
|
if ! docker run --rm -i -v "$srcdir":/src -v "$srcdir/build/win64-cross/":/src/build \
|
2023-01-15 21:34:52 -07:00
|
|
|
-e BUILDER_UID=$builder_uid \
|
2023-01-24 20:27:12 -07:00
|
|
|
-e CCACHE_DIR=/src/build/ccache \
|
2023-04-18 18:33:02 -06:00
|
|
|
-e steam_username \
|
|
|
|
-e steam_password \
|
2023-01-14 23:14:06 -07:00
|
|
|
--name dfhack-win \
|
2023-01-24 17:17:49 -07:00
|
|
|
ghcr.io/dfhack/build-env:msvc \
|
2023-01-31 18:13:39 -07:00
|
|
|
bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output cmake .. -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install" \
|
2023-01-14 23:14:06 -07:00
|
|
|
; then
|
|
|
|
echo
|
|
|
|
echo "Build failed"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "Windows artifacts are at win64-cross/output. Copy or symlink them to"
|
|
|
|
echo "your steam DF directory to install dfhack (and optionally delete the"
|
|
|
|
echo "hack/ directory already present)"
|
|
|
|
echo
|
|
|
|
echo "Typically this can be done like this:"
|
2023-01-20 18:21:33 -07:00
|
|
|
echo " cp -r win64-cross/output/* ~/.local/share/Steam/steamapps/common/\"Dwarf Fortress\""
|
2023-01-14 23:14:06 -07:00
|
|
|
fi
|