changelog shortlog graph tags branches files raw help

Mercurial > infra / changeset: rm infra.asd

changeset 271: cd797f4eb846
parent 270: 147c13d8a5b4
child 274: 7046a8e3e517
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 16 Jun 2024 19:15:28 -0400
files: autogen.lisp bootstrap.sh infra.asd readme.org
description: rm infra.asd
     1.1--- a/autogen.lisp	Sun Jun 16 15:02:42 2024 -0400
     1.2+++ b/autogen.lisp	Sun Jun 16 19:15:28 2024 -0400
     1.3@@ -1,6 +1,18 @@
     1.4-;;; autogen.lisp --- Setup the current directory for 
     1.5+;;; autogen.lisp --- Auto-generate CC Infrastructure
     1.6+
     1.7+;; This script must be ran with a compliant CC lisp core image from a complian
     1.8+;; CC lisp compiler. The easiest way to get started is by running the
     1.9+;; 'bootstrap.sh' script first which will download these for you into the
    1.10+;; local 'STASH' directory and run this script automatically.
    1.11 
    1.12-;; sbcl --core .stash/share/lisp/user.core --load autogen.lisp
    1.13+#|
    1.14+# download pre-compiled binaries and run autogen.lisp
    1.15+./bootstrap.sh 
    1.16+
    1.17+# or run manually with local lisp runtime and core
    1.18+sbcl --core $LISP_HOME/user.core --script autogen.lisp \
    1.19+     --eval "(infra/autogen:autogen)"
    1.20+|#
    1.21 
    1.22 ;;; Code:
    1.23 (in-package :std-user)
    1.24@@ -10,27 +22,22 @@
    1.25         :dat/json :dat/sxp :net/fetch :net/util
    1.26         :cli/progress :cli/ansi :cli/ed :cli/prompt
    1.27         :cli/shell :std/hash-table :std/alien :std/macs
    1.28-        :std/fmt))
    1.29+        :std/fmt)
    1.30+  (:export :autogen))
    1.31 
    1.32 (in-package :infra/autogen)
    1.33-
    1.34 (in-readtable :shell)
    1.35-
    1.36+;;; Vars
    1.37 (defparameter *profile* (uiop:read-file-forms
    1.38                          (if-let ((profile (sb-posix:getenv "INFRA_PROFILE")))
    1.39-                                 profile
    1.40-                                 #P"default.sxp")))
    1.41+                           profile
    1.42+                           #P"default.sxp")))
    1.43 (defparameter *core* sb-ext:*core-pathname*)
    1.44 (defparameter *host* (uiop:read-file-forms
    1.45                       (let ((hcfg (format nil "~a.sxp" (sb-unix:unix-gethostname))))
    1.46                         (unless (probe-file hcfg)
    1.47                           (print #0$./check.sh$#))
    1.48                         hcfg)))
    1.49-
    1.50-(defun gethost (k) (getf *host* k))
    1.51-(defun getprofile (k) (getf *profile* k))
    1.52-(init-skel-vars)
    1.53-(setq *skel-project* (find-skelfile *default-pathname-defaults* :load t))
    1.54 (defparameter *host-env* (let ((table (make-hash-table :test 'equal))
    1.55                                (keys (list "STASH" "STORE" "DIST" "PACKY_URL" "VC_URL" "INSTALL_PREFIX"
    1.56                                            "CC" "AR" "HG" "GIT" "LISP" "RUST" "LD" "SHELL" "DEV" "DEV_HOME"
    1.57@@ -38,20 +45,49 @@
    1.58                                            "LISP_HOME" "INFRA_PROFILE")))
    1.59                            (dolist (k keys table)
    1.60                              (setf (gethash k table) (sb-posix:getenv k)))))
    1.61+
    1.62+;;; Utils
    1.63+(defun gethost (k) (getf *host* k))
    1.64+(defun getprofile (k) (getf *profile* k))
    1.65+
    1.66 (defun getenv (k) (gethash *host-env* k))
    1.67 
    1.68-(defun build-default ()
    1.69-  (let ((comp-builder (sb-thread:make-thread (lambda () (sk-call* *skel-project* :repos))))
    1.70-        (packy-builder (sb-thread:make-thread (lambda () (sk-call* *skel-project* :packy-repos))))
    1.71-        (operator-builder (sb-thread:make-thread (lambda () (sk-call* *skel-project* :archlinux :box))))
    1.72-        (worker-builder (sb-thread:make-thread (lambda () (sk-call* *skel-project* :alpine :worker)))))
    1.73-    (std/thread:wait-for-threads
    1.74-     (list comp-builder packy-builder))))
    1.75+(defun setenv (k v)
    1.76+  (sb-posix:setenv k v 1)
    1.77+  (setf (gethash k *host-env*) v))
    1.78+
    1.79+;;; Config
    1.80+(defun init-profile ()
    1.81+  (let ((stash (getprofile :stash))
    1.82+        (cc (getprofile :cc)))
    1.83+    (if-let ((stash (probe-file stash)))
    1.84+      (setenv "STASH" (namestring stash))
    1.85+      (error "STASH not found: ~A" stash))
    1.86+    (if-let ((cc (cli:find-exe cc)))
    1.87+      (setenv "CC" (namestring cc))
    1.88+      (error "STASH not found: ~A" cc))))
    1.89+
    1.90+;;; Build
    1.91+(defun make-default ()
    1.92+  (std/thread:wait-for-threads
    1.93+   (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :repos)))
    1.94+         (sb-thread:make-thread (lambda () (sk-call* *skel-project* :packy-repos))))))
    1.95+
    1.96+(defun make-pods ()
    1.97+  (std/thread:wait-for-threads
    1.98+   (list (sb-thread:make-thread (lambda () (sk-call* *skel-project* :archlinux :box)))
    1.99+         (sb-thread:make-thread (lambda () (sk-call* *skel-project* :alpine :worker))))))
   1.100 
   1.101 (defun autogen ()
   1.102   "Auto-generate the INFRA system."
   1.103-  (info! "starting autogen.lisp" sb-ext:*core-pathname*)
   1.104+  (info! "starting autogen")
   1.105+  (in-readtable :shell)
   1.106   (terpri)
   1.107+  (init-profile)
   1.108+  (init-skel-vars)
   1.109+  (setq *skel-project* (find-skelfile *default-pathname-defaults* :load t))
   1.110+  (unless (probe-file #p".stash")
   1.111+    (sk-call* *skel-project* :bootstrap))
   1.112   ;; print host, env, profile
   1.113   (format t "core: ~A~%" *core*)
   1.114   (terpri)
   1.115@@ -65,8 +101,7 @@
   1.116   (println "profile:")
   1.117   (loop for (k v) on *profile* by 'cddr
   1.118         do (format t "  ~A = ~A~%" k v))
   1.119-
   1.120-  (build-default))
   1.121+  (make-default))
   1.122 
   1.123 ;;; *host*
   1.124 ;; The host profile is generated automatically by 'check.sh'. After running
   1.125@@ -75,12 +110,3 @@
   1.126 ;;; *profile*
   1.127 ;; The default profile is defined in 'default.sxp'. You can use that as a base
   1.128 ;; configuration and override it with INFRA_PROFILE
   1.129-
   1.130-;; (sb-ext:quit)
   1.131-
   1.132-(unless (probe-file #p".stash")
   1.133-  (sk-call* *skel-project* :bootstrap))
   1.134-
   1.135-;; (build-default)
   1.136-(autogen)
   1.137-
     2.1--- a/bootstrap.sh	Sun Jun 16 15:02:42 2024 -0400
     2.2+++ b/bootstrap.sh	Sun Jun 16 19:15:28 2024 -0400
     2.3@@ -55,7 +55,11 @@
     2.4   rm -rf *.tar
     2.5   say "successfully unpacked core"
     2.6   say "starting lisp..."
     2.7-  cd .. && .stash/bin/sbcl --core .stash/share/lisp/prelude.core --script autogen.lisp
     2.8+  cd .. && \
     2.9+    .stash/bin/sbcl --core .stash/share/lisp/user.core \
    2.10+                    --load autogen.lisp \
    2.11+                    --eval "(infra/autogen:autogen)" \
    2.12+                    --non-interactive
    2.13   say "OK"
    2.14 }
    2.15 
     3.1--- a/infra.asd	Sun Jun 16 15:02:42 2024 -0400
     3.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3@@ -1,5 +0,0 @@
     3.4-(defsystem :infra
     3.5-  :depends-on (:std :dat :cli :skel :log :net :packy :pod :box :organ)
     3.6-  :components ((:file "autogen")
     3.7-               (:file "deploy"))
     3.8-  :build-pathname ".stash/bin/infra")
     4.1--- a/readme.org	Sun Jun 16 15:02:42 2024 -0400
     4.2+++ b/readme.org	Sun Jun 16 19:15:28 2024 -0400
     4.3@@ -1,8 +1,9 @@
     4.4-{{{header(infra,
     4.5-Richard Westhaver,
     4.6-ellis@rwest.io,
     4.7-The Compiler Company Infrastructure)}}}
     4.8+#+title: infra
     4.9+#+author: Richard Westhaver
    4.10+#+email: richard.westhaver@gmail.com
    4.11+#+description: The Compiler Company Infrastructure
    4.12 #+EXPORT_FILE_NAME: index
    4.13+#+setupfile: https://cdn.compiler.company/org/clean.theme
    4.14 
    4.15 This project contains scripts, utils, and applications used to host
    4.16 and maintain The Compiler Company infrastructure.