changeset 289: |
acaa2f3cfbd4 |
parent 288: |
50329ab8865a |
child 290: |
02f74f65976c |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 18 Jun 2024 16:10:23 -0400 |
files: |
autogen.lisp default.sxp skelfile |
description: |
autogen checks |
1.1--- a/autogen.lisp Tue Jun 18 14:45:11 2024 -0400
1.2+++ b/autogen.lisp Tue Jun 18 16:10:23 2024 -0400
1.3@@ -62,30 +62,77 @@
1.4 ,@(loop for (k v) on forms by #'cddr while v
1.5 collect `(setenv ,k (or ,v "")))))
1.6
1.7-(defmacro check-err (is-warn ctrl name)
1.8+(defmacro check-err (is-warn ctrl &rest args)
1.9 `(if ,is-warn
1.10 (warn 'simple-warning
1.11 :format-control ,ctrl
1.12- :format-arguments (list ,name))
1.13- (error 'simple-program-error
1.14- :format-control ,ctrl
1.15- :format-arguments (list ,name))))
1.16+ :format-arguments (list ,@args))
1.17+ (std:simple-program-error
1.18+ ,ctrl
1.19+ ,@args)))
1.20+
1.21+(defun setenv-exe (k v &optional warn)
1.22+ (if-let ((path (cli:find-exe v)))
1.23+ (setenv k (namestring path))
1.24+ (check-err warn "~A not found: ~A" k v)))
1.25+
1.26+(defun setenv-probe (k v &optional warn)
1.27+ (if-let ((path (probe-file v)))
1.28+ (setenv k (namestring path))
1.29+ (check-err warn "~A not found: ~A" k v)))
1.30
1.31 (defun check-shared-lib (name &optional warn)
1.32 "Check for a shared library by loading it in the current session with dlopen.
1.33 When WARN is non-nil, signal a warning instead of an error."
1.34 (let ((lib-name (format nil "lib~a.so" name)))
1.35 (if-let ((lib (ignore-errors (sb-alien:load-shared-object lib-name))))
1.36- (unwind-protect t
1.37+ (unwind-protect (format t "found shared lib: ~A~%" lib)
1.38 (sb-alien:unload-shared-object lib))
1.39 (check-err warn "shared library missing: ~x" name))))
1.40
1.41+(defun check-exe (name &optional warn)
1.42+ "Check for an executable in current $PATH by NAME. When WARN is non-nil, signal
1.43+a warning instead of an error."
1.44+ (if-let ((bin (cli:find-exe name)))
1.45+ (progn (format t "found executable: ~A~%" bin) t)
1.46+ (check-err warn "executable missing: ~x" name)))
1.47+
1.48+(defun check-default ()
1.49+ (check-shared-lib "rocksdb")
1.50+ (check-shared-lib "uring")
1.51+ (check-shared-lib "zstd")
1.52+ (check-shared-lib "tree-sitter")
1.53+ (check-shared-lib "xkbcommon"))
1.54+
1.55+(defun check-org ()
1.56+ (check-exe "emacs" t))
1.57+
1.58+(defun check-pod ()
1.59+ (check-exe "podman"))
1.60+
1.61+(defun check-box ()
1.62+ (check-exe "qemu"))
1.63+
1.64+(defun check-feature (name)
1.65+ "Dispatch a host check based on feature NAME."
1.66+ (case name
1.67+ (:default (check-default))
1.68+ (:org (check-org))
1.69+ (:pod (check-pod))
1.70+ (:box (check-box))
1.71+ (t (warn "unsupported feature: ~A" name))))
1.72+
1.73 (defun getpro-else (k else) (or (getprofile k) else))
1.74
1.75 ;;; Config
1.76 (defun init-profile ()
1.77 (info! "initializing profile...")
1.78- (let* ((cc (getpro-else :cc "clang"))
1.79+ (let* ((packy-url (uri:uri (getpro-else :packy-url "https://packy.compiler.company")))
1.80+ (vc-url (uri:uri (getpro-else :packy-url "https://vc.compiler.company")))
1.81+ (ar (getpro-else :ar "tar"))
1.82+ (git (getpro-else :git "git"))
1.83+ (hg (getpro-else :hg "hg"))
1.84+ (cc (getpro-else :cc "clang"))
1.85 (ld (getpro-else :ld "lld"))
1.86 (install-prefix (getpro-else :install-prefix "/usr/local"))
1.87 (stash (getpro-else :stash ".stash"))
1.88@@ -101,31 +148,42 @@
1.89 (rustup-home (getprofile :rustup-home))
1.90 (cargo-home (getprofile :cargo-home))
1.91 (features (getprofile :features)))
1.92- (if-let ((stash (probe-file stash)))
1.93- (setenv "STASH" (namestring stash))
1.94- (error "STASH not found: ~A" stash))
1.95- (if-let ((cc (cli:find-exe cc)))
1.96- (setenv "CC" (namestring cc))
1.97- (error "CC not found: ~A" cc))
1.98+ (setq *log-level* log-level)
1.99+ (when (log:trace-p)
1.100+ (trace! "env before update:")
1.101+ (loop for k being the hash-key
1.102+ using (hash-value v) of *host-env*
1.103+ do (format t " ~A = ~A~%" k (or v ""))
1.104+ finally (terpri)))
1.105+ (setenv-probe "STASH" stash t)
1.106+ (setenv-probe "STORE" store t)
1.107+ (setenv-probe "DIST" dist t)
1.108+ (setenv-probe "INSTALL_PREFIX" install-prefix)
1.109+ (setenv-exe "CC" cc)
1.110+ (setenv-exe "LD" ld)
1.111+ (setenv-exe "AR" ar)
1.112+ (setenv-exe "GIT" git)
1.113+ (setenv-exe "HG" hg)
1.114+ (setenv-exe "RUSTC" rustc t)
1.115+ (setenv-exe "LISP" lisp t)
1.116 (setenv*
1.117- "LD" ld
1.118- "LISP" lisp
1.119+ "PACKY_URL" (uri:uri-to-string packy-url)
1.120+ "VC_URL" (uri:uri-to-string vc-url)
1.121 "LISP_VERSION" lisp-version
1.122 "LISP_HOME" lisp-home
1.123 "QUICKLISP_HOME" quicklisp-home
1.124- "RUSTC" rustc
1.125 "RUST_HOME" rust-home
1.126 "RUSTUP_HOME" rustup-home
1.127 "CARGO_HOME" cargo-home
1.128 "INSTALL_PREFIX" install-prefix
1.129- "STORE" store
1.130- "DIST" dist
1.131 "LOG_LEVEL" (symbol-name log-level))
1.132- (setq *log-level* log-level)
1.133+ (terpri)
1.134 ;; process features
1.135 (loop for f in features
1.136 do (progn
1.137- (format t "checking host for feature dependencies: ~A~%" f)))))
1.138+ (format t "checking host for feature: ~A~%" f)
1.139+ (check-feature f)
1.140+ (terpri)))))
1.141
1.142 (defun init-host ()
1.143 )
1.144@@ -133,10 +191,15 @@
1.145 ;;; Build
1.146 (defun make-default ()
1.147 (std/thread:wait-for-threads
1.148- (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :repos)))))
1.149- (vc:run-hg-command "clone" (list ".stash/src/core.hg" ".stash/src/core"))
1.150- (vc:run-hg-command "clone" (list ".stash/src/home.hg" ".stash/src/home"))
1.151- (vc:run-hg-command "clone" (list ".stash/src/etc.hg" ".stash/src/etc")))
1.152+ (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :repos)) :name "repos")))
1.153+ (std/thread:wait-for-threads
1.154+ (list
1.155+ (sb-thread:make-thread (lambda () (vc:run-hg-command "clone" (list ".stash/src/core.hg" ".stash/src/core")))
1.156+ :name "core")
1.157+ (sb-thread:make-thread (lambda () (vc:run-hg-command "clone" (list ".stash/src/home.hg" ".stash/src/home")))
1.158+ :name "home")
1.159+ (sb-thread:make-thread (lambda () (vc:run-hg-command "clone" (list ".stash/src/etc.hg" ".stash/src/etc")))
1.160+ :name "etc"))))
1.161
1.162 (defun make-pods ()
1.163 (vc:run-hg-command "clone" (list ".stash/src/pod.hg" ".stash/src/pod"))
1.164@@ -167,26 +230,33 @@
1.165 (setq *skel-project* (find-skelfile *default-pathname-defaults* :load t))
1.166 (unless (probe-file #p".stash")
1.167 (sk-call* *skel-project* :bootstrap))
1.168+ (terpri)
1.169 ;; print post-init info
1.170- (format t "lisp: ~A ~A~%"(lisp-implementation-type) (lisp-implementation-version))
1.171- (format t "core: ~A~%" sb-ext:*core-pathname*)
1.172- (terpri)
1.173- (println "host:")
1.174- (loop for (k v) on *host* by 'cddr
1.175- do (format t " ~A = ~A~%" k v))
1.176- (println "profile:")
1.177- (loop for (k v) on *profile* by 'cddr
1.178- do (format t " ~A = ~A~%" k v))
1.179- (println "env:")
1.180- (loop for k being the hash-key
1.181- using (hash-value v) of *host-env*
1.182- do (format t " ~A = ~A~%" k (or v "")))
1.183+ (when (log:info-p)
1.184+ (log:info! "")
1.185+ (format t "lisp: ~A ~A~%"(lisp-implementation-type) (lisp-implementation-version))
1.186+ (terpri)
1.187+ (format t "core: ~A~%" sb-ext:*core-pathname*)
1.188+ (terpri)
1.189+ (println "host:")
1.190+ (loop for (k v) on *host* by 'cddr
1.191+ do (format t " ~A = ~A~%" k v))
1.192+ (terpri)
1.193+ (println "profile:")
1.194+ (loop for (k v) on *profile* by 'cddr
1.195+ do (format t " ~A = ~A~%" k v))
1.196+ (terpri)
1.197+ (println "env:")
1.198+ (loop for k being the hash-key
1.199+ using (hash-value v) of *host-env*
1.200+ do (format t " ~A = ~A~%" k (or v ""))))
1.201+ ;; process all features
1.202 (let ((features (getprofile :features)))
1.203+ (when (member :default features) (make-default))
1.204 (std/thread:wait-for-threads
1.205 (std:flatten
1.206 (list
1.207- (when (member :default features) (sb-thread:make-thread 'make-default :name "default"))
1.208- (when (member :pod features) (sb-thread:make-thread 'make-pods :name "pod"))
1.209- (when (member :box features) (sb-thread:make-thread 'make-boxes :name "box"))
1.210- (when (member :org features) (sb-thread:make-thread 'make-pods :name "org"))
1.211- (when (member :packy features) (sb-thread:make-thread 'make-packy :name "packy")))))))
1.212+ (when (member :org features) (sb-thread:make-thread #'make-org :name "org"))
1.213+ (when (member :pod features) (sb-thread:make-thread #'make-pods :name "pod"))
1.214+ (when (member :box features) (sb-thread:make-thread #'make-boxes :name "box"))
1.215+ (when (member :packy features) (sb-thread:make-thread #'make-packy :name "packy")))))))
2.1--- a/default.sxp Tue Jun 18 14:45:11 2024 -0400
2.2+++ b/default.sxp Tue Jun 18 16:10:23 2024 -0400
2.3@@ -1,10 +1,13 @@
2.4 ;; -*- mode:skel -*-
2.5+:packy-url "https://packy.compiler.company"
2.6+:vc-url "https://vc.compiler.company"
2.7+
2.8 :lisp "sbcl"
2.9 :lisp-version "2.4.5"
2.10 :lisp-home "/usr/local/share/lisp"
2.11 :quicklisp-home "/usr/local/share/lisp/quicklisp"
2.12
2.13-:rustc "/usr/bin/rustc"
2.14+:rustc "rustc"
2.15 :rust-home "/usr/local/share/rust"
2.16 :cargo-home "/usr/local/share/rust/cargo"
2.17 :rustup-home "/usr/local/share/rust/rustup"
2.18@@ -18,7 +21,7 @@
2.19
2.20 :install-prefix "/usr/local" ;; default install prefix
2.21
2.22-:log-level :debug ;; should usually be set to at least :DEBUG, set to
2.23+:log-level :trace ;; should usually be set to at least :DEBUG, set to
2.24 ;; :TRACE or T for verbose output
2.25
2.26 :features (:default :org) ;; :demo :rust :rust-docs :caddy :stumpwm :emacs
3.1--- a/skelfile Tue Jun 18 14:45:11 2024 -0400
3.2+++ b/skelfile Tue Jun 18 16:10:23 2024 -0400
3.3@@ -68,7 +68,7 @@
3.4 #$cd .stash/src/linux && make mrproper -j &&
3.5 zcat /proc/config.gz > .config && yes N | make localmodconfig$#)
3.6 (xcaddy () #$go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest$#)
3.7- (caddy (xcaddy) #$CGO_ENABLED=1 xcaddy build --output .stash/bin/caddy --with github.com/mholt/caddy-webdav$#)
3.8+ (caddy (xcaddy) #$xcaddy build --output .stash/bin/caddy --with github.com/mholt/caddy-webdav$#)
3.9 (rust () #$scripts/get-rust.sh$#)
3.10 (rust-docs (rust) #$cd .stash/src/rust && ./x doc$#)
3.11 (ublk () #$scripts/get-ublksrv.sh$#