#!/usr/bin/env jolt ;; Generate offsets.edn: the wlroots struct layout facts wayland-bar-compositor ;; reads at startup. Rerun after a wlroots update. (require '[babashka.process :as p] '[babashka.fs :as fs] '[clojure.string :as str]) (def here (str (fs/parent (fs/canonicalize *file*)))) (def out (str here "/build-out")) (fs/create-dirs out) (defn run [& cmd] (apply p/shell {:out :inherit :err :inherit} cmd)) ;; wlroots' public layer-shell header includes a protocol header it doesn't install. (run "wayland-scanner" "server-header" (str here "/protocol/wlr-layer-shell-unstable-v1.xml") (str out "/wlr-layer-shell-unstable-v1-protocol.h")) (def cflags (-> (p/sh "pkg-config" "--cflags" "wlroots-0.20" "wayland-server" "pixman-1" "xkbcommon") :out str/trim)) (apply run (concat ["cc" "-o" (str out "/gen-offsets") (str here "/gen-offsets.c") (str "-I" out)] (str/split cflags #"\s+"))) (spit (str here "/offsets.edn") (:out (p/sh (str out "/gen-offsets")))) (println "wrote" (str here "/offsets.edn"))