changeset 271: |
cd797f4eb846 |
parent: |
2e100f53d0d7
|
child: |
8f6b1cd443fe |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 16 Jun 2024 19:15:28 -0400 |
permissions: |
-rw-r--r-- |
description: |
rm infra.asd |
1 ;;; autogen.lisp --- Auto-generate CC Infrastructure 3 ;; This script must be ran with a compliant CC lisp core image from a complian 4 ;; CC lisp compiler. The easiest way to get started is by running the 5 ;; 'bootstrap.sh' script first which will download these for you into the 6 ;; local 'STASH' directory and run this script automatically. 9 # download pre-compiled binaries and run autogen.lisp 12 # or run manually with local lisp runtime and core 13 sbcl --core $LISP_HOME/user.core --script autogen.lisp \ 14 --eval "(infra/autogen:autogen)" 18 (in-package :std-user) 20 (defpkg :infra/autogen 21 (:use :cl :skel :log :std/named-readtables 22 :dat/json :dat/sxp :net/fetch :net/util 23 :cli/progress :cli/ansi :cli/ed :cli/prompt 24 :cli/shell :std/hash-table :std/alien :std/macs 28 (in-package :infra/autogen) 31 (defparameter *profile* (uiop:read-file-forms 32 (if-let ((profile (sb-posix:getenv "INFRA_PROFILE"))) 35 (defparameter *core* sb-ext:*core-pathname*) 36 (defparameter *host* (uiop:read-file-forms 37 (let ((hcfg (format nil "~a.sxp" (sb-unix:unix-gethostname)))) 38 (unless (probe-file hcfg) 39 (print #0$./check.sh$#)) 41 (defparameter *host-env* (let ((table (make-hash-table :test 'equal)) 42 (keys (list "STASH" "STORE" "DIST" "PACKY_URL" "VC_URL" "INSTALL_PREFIX" 43 "CC" "AR" "HG" "GIT" "LISP" "RUST" "LD" "SHELL" "DEV" "DEV_HOME" 44 "DEV_ID" "WORKER" "WORKER_ID" "WORKER_HOME" "CARGO_HOME" "RUSTUP_HOME" 45 "LISP_HOME" "INFRA_PROFILE"))) 46 (dolist (k keys table) 47 (setf (gethash k table) (sb-posix:getenv k))))) 50 (defun gethost (k) (getf *host* k)) 51 (defun getprofile (k) (getf *profile* k)) 53 (defun getenv (k) (gethash *host-env* k)) 56 (sb-posix:setenv k v 1) 57 (setf (gethash k *host-env*) v)) 60 (defun init-profile () 61 (let ((stash (getprofile :stash)) 62 (cc (getprofile :cc))) 63 (if-let ((stash (probe-file stash))) 64 (setenv "STASH" (namestring stash)) 65 (error "STASH not found: ~A" stash)) 66 (if-let ((cc (cli:find-exe cc))) 67 (setenv "CC" (namestring cc)) 68 (error "STASH not found: ~A" cc)))) 71 (defun make-default () 72 (std/thread:wait-for-threads 73 (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :repos))) 74 (sb-thread:make-thread (lambda () (sk-call* *skel-project* :packy-repos)))))) 77 (std/thread:wait-for-threads 78 (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :archlinux :box))) 79 (sb-thread:make-thread (lambda () (sk-call* *skel-project* :alpine :worker)))))) 82 "Auto-generate the INFRA system." 83 (info! "starting autogen") 88 (setq *skel-project* (find-skelfile *default-pathname-defaults* :load t)) 89 (unless (probe-file #p".stash") 90 (sk-call* *skel-project* :bootstrap)) 91 ;; print host, env, profile 92 (format t "core: ~A~%" *core*) 95 (loop for (k v) on *host* by 'cddr 96 do (format t " ~A = ~A~%" k v)) 98 (loop for k being the hash-key 99 using (hash-value v) of *host-env* 100 do (format t " ~A = ~:A~%" k v)) 102 (loop for (k v) on *profile* by 'cddr 103 do (format t " ~A = ~A~%" k v)) 107 ;; The host profile is generated automatically by 'check.sh'. After running 108 ;; the script you'll have a file HOST.sxp. 111 ;; The default profile is defined in 'default.sxp'. You can use that as a base 112 ;; configuration and override it with INFRA_PROFILE