changelog shortlog graph tags branches files raw help

Mercurial > infra / changeset: updates, rm scripts/autogen.lisp

changeset 284: 71ac00213ae3
parent 283: 8b385a72c75f
child 285: e3f30a0836d1
author: Richard Westhaver <ellis@rwest.io>
date: Mon, 17 Jun 2024 20:17:45 -0400
files: autogen.lisp default.sxp scripts/autogen.lisp scripts/check.lisp
description: updates, rm scripts/autogen.lisp
     1.1--- a/autogen.lisp	Mon Jun 17 20:07:44 2024 +0000
     1.2+++ b/autogen.lisp	Mon Jun 17 20:17:45 2024 -0400
     1.3@@ -11,7 +11,7 @@
     1.4 
     1.5 # or run manually with local lisp runtime and core
     1.6 sbcl --core $LISP_HOME/user.core --script autogen.lisp \
     1.7-     --eval "(infra/autogen:autogen)"
     1.8+--eval "(infra/autogen:autogen)"
     1.9 |#
    1.10 
    1.11 ;;; Code:
    1.12@@ -30,9 +30,10 @@
    1.13 ;;; Vars
    1.14 (defparameter *profile* (uiop:read-file-forms
    1.15                          (if-let ((profile (sb-posix:getenv "INFRA_PROFILE")))
    1.16-                           profile
    1.17-                           #P"default.sxp")))
    1.18-(defparameter *core* sb-ext:*core-pathname*)
    1.19+                           (probe-file profile)
    1.20+                           (when-let ((default (probe-file "default.sxp")))
    1.21+                             (sb-posix:setenv "INFRA_PROFILE" (namestring default) 1)
    1.22+                             default))))
    1.23 (defparameter *host* (uiop:read-file-forms
    1.24                       (let ((hcfg (format nil "~a.sxp" (sb-unix:unix-gethostname))))
    1.25                         (unless (probe-file hcfg)
    1.26@@ -42,7 +43,7 @@
    1.27                                (keys (list "STASH" "STORE" "DIST" "PACKY_URL" "VC_URL" "INSTALL_PREFIX"
    1.28                                            "CC" "AR" "HG" "GIT" "LISP" "RUST" "LD" "SHELL" "DEV" "DEV_HOME"
    1.29                                            "DEV_ID" "WORKER" "WORKER_ID" "WORKER_HOME" "CARGO_HOME" "RUSTUP_HOME"
    1.30-                                           "LISP_HOME" "INFRA_PROFILE")))
    1.31+                                           "LISP_HOME" "INFRA_PROFILE" "LOG_LEVEL")))
    1.32                            (dolist (k keys table)
    1.33                              (setf (gethash k table) (sb-posix:getenv k)))))
    1.34 
    1.35@@ -56,16 +57,76 @@
    1.36   (sb-posix:setenv k v 1)
    1.37   (setf (gethash k *host-env*) v))
    1.38 
    1.39+(defmacro setenv* (&rest forms)
    1.40+  `(progn
    1.41+     ,@(loop for (k v) on forms by #'cddr while v
    1.42+             collect `(setenv ,k (or ,v "")))))
    1.43+
    1.44+(defmacro check-err (is-warn ctrl name)
    1.45+  `(if ,is-warn
    1.46+       (warn 'simple-warning 
    1.47+             :format-control ,ctrl
    1.48+             :format-arguments (list ,name))
    1.49+       (error 'simple-program-error 
    1.50+              :format-control ,ctrl
    1.51+              :format-arguments (list ,name))))
    1.52+
    1.53+(defun check-shared-lib (name &optional warn)
    1.54+  "Check for a shared library by loading it in the current session with dlopen.
    1.55+When WARN is non-nil, signal a warning instead of an error."
    1.56+  (let ((lib-name (format nil "lib~a.so" name)))
    1.57+    (if-let ((lib (ignore-errors (sb-alien:load-shared-object lib-name))))
    1.58+      (unwind-protect t
    1.59+        (sb-alien:unload-shared-object lib))
    1.60+      (check-err warn "shared library missing: ~x" name))))
    1.61+
    1.62+(defun getpro-else (k else) (or (getprofile k) else))
    1.63+
    1.64 ;;; Config
    1.65 (defun init-profile ()
    1.66-  (let ((stash (getprofile :stash))
    1.67-        (cc (getprofile :cc)))
    1.68+  (info! "initializing profile...")
    1.69+  (let* ((cc (getpro-else :cc "clang"))
    1.70+         (ld (getpro-else :ld "lld"))
    1.71+         (install-prefix (getpro-else :install-prefix "/usr/local"))
    1.72+         (stash (getpro-else :stash ".stash"))
    1.73+         (store (getpro-else :store (namestring (merge-pathnames "share/store" stash))))
    1.74+         (dist (getpro-else :dist (namestring (merge-pathnames "dist" store))))
    1.75+         (lisp (getpro-else :lisp (lisp-implementation-type)))
    1.76+         (lisp-version (getpro-else :lisp-version (lisp-implementation-version)))
    1.77+         (log-level (getprofile :log-level))
    1.78+         (lisp-home (getprofile :lisp-home))
    1.79+         (quicklisp-home (getprofile :quicklisp-home))
    1.80+         (rust-home (getprofile :rust-home))
    1.81+         (rustup-home (getprofile :rustup-home))
    1.82+         (cargo-home (getprofile :cargo-home))
    1.83+         (features (getprofile :features)))
    1.84     (if-let ((stash (probe-file stash)))
    1.85       (setenv "STASH" (namestring stash))
    1.86       (error "STASH not found: ~A" stash))
    1.87     (if-let ((cc (cli:find-exe cc)))
    1.88       (setenv "CC" (namestring cc))
    1.89-      (error "STASH not found: ~A" cc))))
    1.90+      (error "CC not found: ~A" cc))
    1.91+    (setenv*
    1.92+     "LD" ld
    1.93+     "LISP" lisp
    1.94+     "LISP_VERSION" lisp-version
    1.95+     "LISP_HOME" lisp-home
    1.96+     "QUICKLISP_HOME" quicklisp-home
    1.97+     "RUST_HOME" rust-home
    1.98+     "RUSTUP_HOME" rustup-home
    1.99+     "CARGO_HOME" cargo-home
   1.100+     "INSTALL_PREFIX" install-prefix
   1.101+     "STORE" store
   1.102+     "DIST" dist
   1.103+     "LOG_LEVEL" (symbol-name log-level))
   1.104+    (setq *log-level* log-level)
   1.105+    ;; process features
   1.106+    (loop for f in features
   1.107+          do (progn
   1.108+               (format t "checking host for feature dependencies: ~A~%" f)))))
   1.109+
   1.110+(defun init-host ()
   1.111+  )
   1.112 
   1.113 ;;; Build
   1.114 (defun make-default ()
   1.115@@ -84,38 +145,45 @@
   1.116 (defun make-boxes ()
   1.117   (vc:run-hg-command "clone" (list ".stash/src/box.hg" ".stash/src/box")))
   1.118 
   1.119+(defun make-packy ()
   1.120+  (sk-call* *skel-project* :packy-repos))
   1.121+
   1.122 (defun make-org ()
   1.123   (vc:run-hg-command "clone" (list ".stash/src/org.hg" ".stash/src/org")))
   1.124 
   1.125+(defun make-demo ()
   1.126+  (vc:run-hg-command "clone" (list ".stash/src/demo.hg" ".stash/src/demo")))
   1.127+
   1.128 (defun autogen ()
   1.129-  "Auto-generate the INFRA system."
   1.130-  (info! "starting autogen")
   1.131+  (info! (machine-version)
   1.132+         "starting autogen...")
   1.133   (in-readtable :shell)
   1.134   (terpri)
   1.135   (init-profile)
   1.136+  (init-host)
   1.137   (init-skel-vars)
   1.138   (setq *skel-project* (find-skelfile *default-pathname-defaults* :load t))
   1.139   (unless (probe-file #p".stash")
   1.140     (sk-call* *skel-project* :bootstrap))
   1.141-  ;; print host, env, profile
   1.142-  (format t "core: ~A~%" *core*)
   1.143+  ;; print post-init info
   1.144+  (format t "lisp: ~A ~A~%"(lisp-implementation-type) (lisp-implementation-version))
   1.145+  (format t "core: ~A~%" sb-ext:*core-pathname*)
   1.146   (terpri)
   1.147   (println "host:")
   1.148   (loop for (k v) on *host* by 'cddr
   1.149         do (format t "  ~A = ~A~%" k v))
   1.150+  (println "profile:")
   1.151+  (loop for (k v) on *profile* by 'cddr
   1.152+        do (format t "  ~A = ~A~%" k v))
   1.153   (println "env:")
   1.154   (loop for k being the hash-key
   1.155         using (hash-value v) of *host-env*
   1.156-        do (format t "  ~A = ~:A~%" k v))
   1.157-  (println "profile:")
   1.158-  (loop for (k v) on *profile* by 'cddr
   1.159-        do (format t "  ~A = ~A~%" k v))
   1.160-  (make-default))
   1.161-
   1.162-;;; *host*
   1.163-;; The host profile is generated automatically by 'check.sh'. After running
   1.164-;; the script you'll have a file HOST.sxp.
   1.165-
   1.166-;;; *profile*
   1.167-;; The default profile is defined in 'default.sxp'. You can use that as a base
   1.168-;; configuration and override it with INFRA_PROFILE
   1.169+        do (format t "  ~A = ~A~%" k (or v "")))
   1.170+  (let ((features (getprofile :features)))
   1.171+    (std/thread:wait-for-threads
   1.172+     (std:flatten
   1.173+      (list
   1.174+       (when (member :default features) (sb-thread:make-thread 'make-default :name "default"))
   1.175+       (when (member :pod features) (sb-thread:make-thread 'make-pods :name "pod"))
   1.176+       (when (member :box features) (sb-thread:make-thread 'make-boxes :name "box"))
   1.177+       (when (member :org features) (sb-thread:make-thread 'make-pods :name "org")))))))
     2.1--- a/default.sxp	Mon Jun 17 20:07:44 2024 +0000
     2.2+++ b/default.sxp	Mon Jun 17 20:17:45 2024 -0400
     2.3@@ -1,24 +1,16 @@
     2.4 ;; -*- mode:skel -*-
     2.5-:sbcl-version "2.4.5" ;; SBCL is always required for bootstrap
     2.6-
     2.7+:lisp "sbcl"
     2.8+:lisp-version "2.4.5"
     2.9 :cc "clang"
    2.10-
    2.11-:lisp "sbcl"
    2.12-
    2.13 :stash ".stash" ;; local build stash
    2.14-
    2.15 :dist nil ;; remote distribution directory, or nil to use the stash
    2.16           ;; instead
    2.17-
    2.18-:install-root "/usr/local" ;; default installation directory
    2.19-
    2.20+:install-prefix "/usr/local" ;; default install prefix
    2.21 :log-level :debug ;; should usually be set to at least :DEBUG, set to
    2.22                   ;; :TRACE or T for verbose output
    2.23-
    2.24 :lisp-home "/usr/local/share/lisp"
    2.25-
    2.26 :quicklisp-home "/usr/local/share/lisp/quicklisp"
    2.27-
    2.28 :rust-home "/usr/local/share/rust"
    2.29-
    2.30 :cargo-home "/usr/local/share/rust/cargo"
    2.31+:rustup-home "/usr/local/share/rust/rustup"
    2.32+:features (:default :pod :box :org) ;; :demo 
     3.1--- a/scripts/autogen.lisp	Mon Jun 17 20:07:44 2024 +0000
     3.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3@@ -1,25 +0,0 @@
     3.4-#!/usr/local/bin/sbcl --script
     3.5-;;; scripts/autogen.lisp --- prepare the local environment
     3.6-
     3.7-;;; Code:
     3.8-(require 'sb-posix)
     3.9-(require 'asdf)
    3.10-(in-package :cl-user)
    3.11-
    3.12-(format t "Starting comp/infra autogen...~%")
    3.13-
    3.14-(defvar *scripts* (directory-namestring (or *load-truename* #P"./scripts/")))
    3.15-(defvar *systems* (list #P"~/quicklisp/dists/quicklisp/software/cl-ppcre-20230618-git/" 
    3.16-                        #P"~/dev/comp/core/lisp/std/"))
    3.17-
    3.18-(mapc (lambda (p) (pushnew (sb-ext:native-pathname p) asdf:*central-registry*)) *systems*)
    3.19-
    3.20-(asdf:load-systems :cl-ppcre :std)
    3.21-(load (merge-pathnames *scripts* "check.lisp"))
    3.22-;; check system compatibility
    3.23-(check:check :warn)
    3.24-
    3.25-(std:println "DONE.")
    3.26-
    3.27-(std:println "saving lisp executable to './check'... Bye.")
    3.28-(sb-ext:save-lisp-and-die "check" :toplevel #'check:main :executable t :compression t)
     4.1--- a/scripts/check.lisp	Mon Jun 17 20:07:44 2024 +0000
     4.2+++ b/scripts/check.lisp	Mon Jun 17 20:17:45 2024 -0400
     4.3@@ -4,7 +4,7 @@
     4.4 ;; bootstrapping.
     4.5 
     4.6 ;;; Code:
     4.7-(defpackage :infra/scripts/check
     4.8+(defpackage :infra/check
     4.9   (:nicknames :check)
    4.10   (:use :cl :std :sb-alien :cli :log)
    4.11   (:export :main