summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-04-28 07:16:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-04-28 07:16:31 -0700
commit95d54abcf2f5e83efb7c25879c1c6b9f8d137462 (patch)
treeaa630a14b71bf5c7a0b10adbde21b4312273db19
parent1cbf1af6a626bda28dda3d5075a96bd8ebbc4213 (diff)
downloadtxr-95d54abcf2f5e83efb7c25879c1c6b9f8d137462.tar.gz
txr-95d54abcf2f5e83efb7c25879c1c6b9f8d137462.tar.bz2
txr-95d54abcf2f5e83efb7c25879c1c6b9f8d137462.zip
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.
-rwxr-xr-xconfig-cache-hook.tl24
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`)))))))