From 95d54abcf2f5e83efb7c25879c1c6b9f8d137462 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 28 Apr 2025 07:16:31 -0700 Subject: build: config cache: don't touch config when no change. * config-cache-hook.tl (try-save-curent-config, try-restore-new-config): These functions now take the cache key as the argument again. The caller has to obtain that. Diagnostics are not issued in these functions. (mainline): Convert git hashes to cache keys. If they are the same, indicate current config is valid. Also diagnose when a configuration has not been retrieved, recommending ./configure being run. --- config-cache-hook.tl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/config-cache-hook.tl b/config-cache-hook.tl index e092bac5..0de54d62 100755 --- a/config-cache-hook.tl +++ b/config-cache-hook.tl @@ -24,25 +24,31 @@ (sha256-hash s makefile-conftest-parts) (tostringp (sha256-end s)))) -(defun try-save-current-config (sha) +(defun try-save-current-config (key) (when [all %files% path-exists-p] - (let* ((key (hash-config-inputs sha)) - (dir (path-cat %cachedir% key))) + (let* ((dir (path-cat %cachedir% key))) (ensure-dir dir) (copy-files %files% dir t)))) -(defun try-restore-new-config (sha) - (let* ((key (hash-config-inputs sha)) - (dir (path-cat %cachedir% key)) +(defun try-restore-new-config (key) + (let* ((dir (path-cat %cachedir% key)) (files [map (op path-cat dir) %files%])) (when [all files path-exists-p] (copy-files files "." t) - (put-line `restored cached configuration for @sha`)))) + t))) (match-case *args* (("hash" @sha) (flow sha hash-config-inputs put-line)) (@(require (@prevsha @newsha @nil) (nequal prevsha newsha)) - (try-save-current-config prevsha) - (try-restore-new-config newsha))) + (let ((prevkey (hash-config-inputs prevsha)) + (newkey (hash-config-inputs newsha))) + (cond + ((equal prevkey newkey) + (put-line `current configuration valid for @newsha`)) + (t + (try-save-current-config prevkey) + (if (try-restore-new-config newkey) + (put-line `retrieved cached configuration for @newsha`) + (put-line `no cached configuration for @newsha - run ./configure`))))))) -- cgit v1.2.3