diff options
-rwxr-xr-x | config-cache-hook.tl | 24 |
1 files 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`))))))) |