| 1 | #!/usr/bin/env bash |
| 2 | # What the desktop app's Windows cross build needs on g1t's Linux machines, |
| 3 | # besides cargo-xwin: Debian's packages (scripts/apt-install.sh, from the |
| 4 | # job's cache when it has them), the names cargo-xwin runs LLVM's tools by, |
| 5 | # and an NSIS header Debian lacks. desktop-release.yml's Windows build and |
| 6 | # caches.yml, which keeps its cache warm on main, both run it. |
| 7 | set -euo pipefail |
| 8 | |
| 9 | bash "$(dirname "$0")/apt-install.sh" tauri-windows |
| 10 | # cargo-xwin compiles C (ring's, among others) with clang-cl and |
| 11 | # links with lld-link and llvm-lib. Each is a mode of a tool |
| 12 | # Debian does install, chosen by the name it is run as: clang-cl |
| 13 | # is clang, lld-link is lld, and llvm-lib is llvm-ar. Debian ships |
| 14 | # none of the three names, so each is linked to its tool. |
| 15 | for pair in clang-cl:clang lld-link:lld llvm-lib:llvm-ar; do |
| 16 | name="${pair%%:*}" tool="${pair##*:}" |
| 17 | command -v "$name" >/dev/null && continue |
| 18 | found="$(command -v "$tool" || ls /usr/lib/llvm-*/bin/"$tool" 2>/dev/null | sort -V | tail -1)" |
| 19 | [ -n "$found" ] || { echo "::error::$tool is not installed, so there is no $name"; exit 1; } |
| 20 | sudo ln -sf "$(readlink -f "$found")" "/usr/local/bin/$name" |
| 21 | echo "$name: $(readlink -f "$found")" |
| 22 | done |
| 23 | # Tauri's installer script includes Win\RestartManager.nsh, which |
| 24 | # NSIS ships from 3.10 on; Debian's is 3.08. The header stands |
| 25 | # alone (defines and System calls), so it is added from NSIS 3.11's |
| 26 | # source, checked against its SHA-256. |
| 27 | rm_nsh=/usr/share/nsis/Include/Win/RestartManager.nsh |
| 28 | if [ ! -f "$rm_nsh" ]; then |
| 29 | curl -fsSL --retry 3 -o /tmp/RestartManager.nsh https://raw.githubusercontent.com/kichik/nsis/v311/Include/Win/RestartManager.nsh |
| 30 | echo "67149978412da9b283e2e1abe48a360093df9caf6363373e2cabe463978b7c0e /tmp/RestartManager.nsh" | sha256sum -c - |
| 31 | sudo install -m 0644 /tmp/RestartManager.nsh "$rm_nsh" |
| 32 | fi |