#!/usr/bin/env bash # Native libraries needed to compile Makepad's Linux platform backend. # This helper is intentionally opt-in: it never changes the host by default. set -Eeuo pipefail PACKAGES=( pkg-config libwayland-dev libxkbcommon-dev libx11-dev libxi-dev libxcursor-dev libxrandr-dev libgl1-mesa-dev # robius-sms enables its Linux backend through polkit/gio. libpolkit-gobject-1-dev # Needed to *link* a test binary, not merely to `cargo check`. Makepad's # audio backend pulls in ALSA and PulseAudio, and reqwest/rustls pulls in # OpenSSL. Omitting these gives a confusing "unable to find library # -lasound" at link time long after the compile appears to succeed. libasound2-dev libpulse-dev libssl-dev ) check() { if ! command -v pkg-config >/dev/null 2>&1; then echo "missing: pkg-config" >&2 return 1 fi local missing=0 for pc in wayland-client xkbcommon x11 xi xcursor xrandr polkit-gobject-1 \ alsa libpulse openssl; do if ! pkg-config --exists "$pc"; then echo "missing native library: $pc" >&2 missing=1 fi done return "$missing" } install() { if ! command -v apt-get >/dev/null 2>&1; then echo "error: apt-get is required for automatic installation" >&2 return 2 fi if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then apt-get update apt-get install -y --no-install-recommends "${PACKAGES[@]}" elif command -v sudo >/dev/null 2>&1; then sudo apt-get update sudo apt-get install -y --no-install-recommends "${PACKAGES[@]}" else echo "error: run as root or install sudo" >&2 return 2 fi } case "${1:---check}" in --check) check ;; --install) install && check ;; *) echo "usage: $0 [--check|--install]" >&2; exit 2 ;; esac