upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/linux-boot/configure-worktree.sh
blob: ef94973a93fa014e7f2f4c266c309c1a1f9c486f (plain)
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
#!/bin/bash
# usage: configure-worktree.sh <worktree>
# Configures a Windows build of the runtime on Linux with clang-cl and an xwin SDK (XWIN_DIR, default
# ~/.local/share/xwin-sdk). SDL3_SRC=<an SDL3 source tree> makes the configure work offline.
set -eu

usage() {
  echo "usage: configure-worktree.sh <worktree>"
}

die() {
  echo "ERROR: $*" >&2
  exit 2
}

if [ "$#" -ge 1 ] && { [ "$1" = "-h" ] || [ "$1" = "--help" ]; }; then
  usage
  exit 0
fi

[ "$#" -eq 1 ] || { usage >&2; exit 2; }
[ -n "$1" ] || die "worktree path must not be empty"
[ -d "$1" ] || die "worktree directory does not exist: $1"

W=$(realpath "$1")
[ -f "$W/runtime/CMakeLists.txt" ] || die "not a runtime worktree (missing runtime/CMakeLists.txt): $W"
[ -f "$W/runtime/cmake/clang-cl-xwin.cmake" ] || die "missing toolchain file: $W/runtime/cmake/clang-cl-xwin.cmake"

CMAKE=${CMAKE:-cmake}
command -v "$CMAKE" >/dev/null 2>&1 || die "cmake executable not found: $CMAKE"

if [ -n "${SDL3_SRC:-}" ] && [ ! -d "$SDL3_SRC" ]; then
  die "SDL3_SRC directory does not exist: $SDL3_SRC"
fi

cmake_args=(
  -S "$W/runtime"
  -B "$W/runtime/build/boot"
  -G Ninja
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_TOOLCHAIN_FILE="$W/runtime/cmake/clang-cl-xwin.cmake"
  -DXWIN_DIR="${XWIN_DIR:-$HOME/.local/share/xwin-sdk}"
  -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON
  -DLEONIDA_SDL3=ON
)
if [ -n "${SDL3_SRC:-}" ]; then
  cmake_args+=(-DFETCHCONTENT_SOURCE_DIR_SDL3="$SDL3_SRC")
fi

"$CMAKE" "${cmake_args[@]}"