changeset 570: |
d1c75054df03 |
parent 568: |
13a6c698a6dd |
child 571: |
35438b775bc4 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 30 Jul 2024 21:54:16 -0400 |
files: |
lisp/bin/skel.lisp lisp/lib/skel/core/obj.lisp lisp/lib/skel/core/pkg.lisp skelfile |
description: |
added phases |
1.1--- a/lisp/bin/skel.lisp Mon Jul 29 21:42:21 2024 -0400
1.2+++ b/lisp/bin/skel.lisp Tue Jul 30 21:54:16 2024 -0400
1.3@@ -76,37 +76,37 @@
1.4 (defcmd skc-id
1.5 (println (std:format-sxhash (obj/id:id (find-skelfile #P"." :load t)))))
1.6
1.7-(defun call-with-args (action)
1.8- (if (zerop *argc*)
1.9+(defun call-with-args (action args)
1.10+ (if (null args)
1.11 (sk-call *skel-project* action)
1.12- (mapcar (lambda (x)
1.13- (sk-call *skel-project* (print (keywordicate action '- (string-upcase x)))))
1.14- *args*)))
1.15+ (mapc (lambda (x)
1.16+ (sk-call *skel-project* (keywordicate action '- (string-upcase x))))
1.17+ args)))
1.18
1.19 (defcmd skc-compile
1.20- (call-with-args :compile))
1.21+ (call-with-args :compile *args*))
1.22 (defcmd skc-build
1.23- (call-with-args :build))
1.24+ (call-with-args :build *args*))
1.25 (defcmd skc-dist
1.26- (call-with-args :dist))
1.27+ (call-with-args :dist *args*))
1.28 (defcmd skc-install
1.29- (call-with-args :install))
1.30+ (call-with-args :install *args*))
1.31 (defcmd skc-pack
1.32- (call-with-args :pack))
1.33+ (call-with-args :pack *args*))
1.34 (defcmd skc-unpack
1.35- (call-with-args :unpack))
1.36+ (call-with-args :unpack *args*))
1.37 (defcmd skc-bundle
1.38- (call-with-args :bundle))
1.39+ (call-with-args :bundle *args*))
1.40 (defcmd skc-unbundle
1.41- (call-with-args :unbundle))
1.42+ (call-with-args :unbundle *args*))
1.43 (defcmd skc-clean
1.44- (call-with-args :clean))
1.45+ (call-with-args :clean *args*))
1.46 (defcmd skc-test
1.47- (call-with-args :test))
1.48+ (call-with-args :test *args*))
1.49 (defcmd skc-bench
1.50- (call-with-args :bench))
1.51+ (call-with-args :bench *args*))
1.52 (defcmd skc-save
1.53- (call-with-args :save))
1.54+ (call-with-args :save *args*))
1.55
1.56 (defun sk-slot-case (sel)
1.57 (std/string:string-case (sel :default (skel-simple-error "invalid slot"))
1.58@@ -121,6 +121,7 @@
1.59 (":components" (sk-components *skel-project*))
1.60 (":scripts" (sk-scripts *skel-project*))
1.61 (":rules" (sk-rules *skel-project*))
1.62+ (":phases" (hash-table-alist (sk-phases *skel-project*)))
1.63 (":env" (sk-env *skel-project*))
1.64 (":bind" (sk-bind *skel-project*))
1.65 (":include" (sk-include *skel-project*))
2.1--- a/lisp/lib/skel/core/obj.lisp Mon Jul 29 21:42:21 2024 -0400
2.2+++ b/lisp/lib/skel/core/obj.lisp Tue Jul 30 21:54:16 2024 -0400
2.3@@ -315,9 +315,9 @@
2.4 (mapcar
2.5 (lambda (src)
2.6 (if-let* ((sr (sk-find-rule src obj)))
2.7- ;; check if we need to rerun sources
2.8- (sk-make obj sr)
2.9- (warn! "unhandled source:" src "for rule:" rule)))
2.10+ ;; check if we need to rerun sources
2.11+ (sk-make obj sr)
2.12+ (warn! "unhandled source:" src "for rule:" rule)))
2.13 sources))
2.14 (sk-run rule))
2.15 rules)
2.16@@ -359,21 +359,25 @@
2.17 ;;; Project
2.18 (defclass sk-project (skel sxp sk-meta)
2.19 ((name :initarg :name :initform "" :type string)
2.20+ (vc :initarg :vc :initform (make-sk-vc-meta *default-skel-vc-kind*) :type sk-vc-meta :accessor sk-vc)
2.21 (src :initarg :src :type pathname :accessor sk-src)
2.22- (vc :initarg :vc :initform (make-sk-vc-meta *default-skel-vc-kind*) :type sk-vc-meta :accessor sk-vc)
2.23+ (stash :initarg :stash :accessor sk-stash :type pathname)
2.24+ (store :initarg :store :accessor sk-store :type pathname)
2.25+ (components :initform #() :initarg :components :accessor sk-components :type (vector sk-component))
2.26+ (bind :initarg :bind :initform nil :accessor sk-bind :type list)
2.27+ (env :initarg :env :initform nil :accessor sk-env :type list)
2.28+ (phases :initarg :phases
2.29+ :initform (make-hash-table)
2.30+ :accessor sk-phases
2.31+ :type hash-table)
2.32 (rules :initarg :rules
2.33 :initform (make-array 0 :element-type 'sk-rule :adjustable t)
2.34 :accessor sk-rules
2.35 :type (vector sk-rule))
2.36- (components :initform #() :initarg :components :accessor sk-components :type (vector (cons keyword pathname)))
2.37- (bind :initarg :bind :initform nil :accessor sk-bind :type list)
2.38- (env :initarg :env :initform nil :accessor sk-env :type list)
2.39 (scripts :initarg :scripts
2.40 :initform (make-array 0 :element-type 'sk-script :adjustable t)
2.41 :accessor sk-scripts
2.42 :type (vector sk-script))
2.43- (stash :initarg :stash :accessor sk-stash :type pathname)
2.44- (store :initarg :store :accessor sk-store :type pathname)
2.45 (include :initarg :include
2.46 :initform (make-array 0 :element-type 'pathname :adjustable t)
2.47 :accessor sk-include
2.48@@ -396,6 +400,15 @@
2.49 (defun find-sk-symbol (s)
2.50 (find-symbol* (symbol-name s) :skel/core/obj t))
2.51
2.52+(defun %recipe-phase-p (form)
2.53+ "Return non-nil if FORM looks like (:PHASE &BODY BODY)."
2.54+ (and (listp form) (>= (length form) 2) (keywordp (car form))))
2.55+
2.56+(defun sk-multi-recipe-p (recipe)
2.57+ "Return T if RECIPE looks like a list of (:PHASE &BODY BODY)."
2.58+ (when (consp recipe)
2.59+ (every '%recipe-phase-p recipe)))
2.60+
2.61 ;; ast -> obj
2.62 (defmethod load-ast ((self sk-project))
2.63 ;; internal ast is never tagged
2.64@@ -417,21 +430,21 @@
2.65 (let ((*default-pathname-defaults* (make-pathname :defaults (namestring *skel-path*))))
2.66 (when (bound-string-p self 'stash) (setf (sk-stash self) (pathname (the simple-string (sk-stash self)))))
2.67 (when (bound-string-p self 'store) (setf (sk-store self) (pathname (the simple-string (sk-store self)))))
2.68- ;; INCLUDE
2.69+ ;; INCLUDE
2.70 (when-let ((include (sk-include self)))
2.71- (setf (sk-include self) (map 'vector
2.72+ (setf (sk-include self) (map 'vector
2.73 ;; recursively load included projects
2.74 (lambda (i) (load-ast
2.75 (sk-read-file
2.76 (make-instance 'sk-project)
2.77 i)))
2.78- include)))
2.79- ;; COMPONENTS
2.80+ include)))
2.81+ ;; COMPONENTS
2.82 (when (slot-boundp self 'components)
2.83- (setf (sk-components self) (map 'vector
2.84- (lambda (c)
2.85- (sk-load-component (car c) (pathname (cadr c)) (namestring *default-pathname-defaults*)))
2.86- (sk-components self)))))
2.87+ (setf (sk-components self) (map 'vector
2.88+ (lambda (c)
2.89+ (sk-load-component (car c) (pathname (cadr c)) (namestring *default-pathname-defaults*)))
2.90+ (sk-components self)))))
2.91 ;; SCRIPTS
2.92 (if (bound-string-p self 'scripts)
2.93 (if-let* ((path (probe-file (pathname (the simple-string (sk-scripts self))))))
2.94@@ -457,13 +470,29 @@
2.95 (list
2.96 (cons (sb-int:keywordicate (car e)) (cadr e)))))
2.97 env)))
2.98+ ;; BIND
2.99 ;; RULES
2.100 (when-let ((rules (sk-rules self)))
2.101- (setf (sk-rules self) (map 'vector
2.102- (lambda (x)
2.103- (destructuring-bind (target source &rest recipe) x
2.104- (make-sk-rule target source recipe)))
2.105- rules)))
2.106+ (setf (sk-rules self)
2.107+ (coerce
2.108+ (flatten
2.109+ (mapcar
2.110+ (lambda (x)
2.111+ (destructuring-bind (target source &rest recipe) x
2.112+ ;; TODO 2024-07-30: check for phases
2.113+ (if (sk-multi-recipe-p recipe)
2.114+ (flatten
2.115+ (mapcar
2.116+ (lambda (y)
2.117+ (destructuring-bind (phase source &rest recipe) y
2.118+ (let ((%target (keywordicate phase '- (string-upcase target))))
2.119+ (let ((ph (gethash phase (sk-phases self))))
2.120+ (setf (gethash phase (sk-phases self))
2.121+ (push (make-sk-rule %target source recipe) ph))))))
2.122+ recipe))
2.123+ (make-sk-rule target source recipe))))
2.124+ (coerce rules 'list)))
2.125+ '(vector sk-rule))))
2.126 ;; VC
2.127 (when-let ((vc (sk-vc self)))
2.128 (etypecase vc
3.1--- a/lisp/lib/skel/core/pkg.lisp Mon Jul 29 21:42:21 2024 -0400
3.2+++ b/lisp/lib/skel/core/pkg.lisp Tue Jul 30 21:54:16 2024 -0400
3.3@@ -73,7 +73,8 @@
3.4 :sk-user-config :sk-system-config
3.5 :*skel-user-config* :*skel-system-config*
3.6 :sk-src :sk-component :sk-components :sk-module
3.7- :sk-parent))
3.8+ :sk-parent
3.9+ :sk-phases))
3.10
3.11 (defpackage :skel/core/util
3.12 (:use :cl :std :skel/core/obj :skel/core/vars :skel/core/proto :dat/sxp :skel/core/err)
4.1--- a/skelfile Mon Jul 29 21:42:21 2024 -0400
4.2+++ b/skelfile Tue Jul 30 21:54:16 2024 -0400
4.3@@ -28,7 +28,8 @@
4.4 (build-tree-sitter-alien () #$cd lisp/ffi/tree-sitter &&
4.5 clang -g -O2 -Wall -Wno-unused-value -ltree-sitter -shared \
4.6 alien.c -o ../../../.stash/libtree-sitter-alien.so$#)
4.7- (install-tree-sitter-alien () #$cp .stash/libtree-sitter-alien.so /usr/local/lib/$#)
4.8+ (tree-sitter-alien ()
4.9+ (:install #$cp .stash/libtree-sitter-alien.so /usr/local/lib/$#))
4.10 (psl.dat (%stash)
4.11 (download "https://publicsuffix.org/list/public_suffix_list.dat" :output ".stash/psl.dat"))
4.12 (parquet.thrift (%stash)
4.13@@ -43,45 +44,58 @@
4.14 :output ".stash/alltypes_plain.parquet"))
4.15 ;; lisp
4.16 (%stash () #$mkdir -pv .stash$#)
4.17- (build-rdb (%stash) (with-sbcl (:noinform t :quit t)
4.18- (ql:quickload :bin/rdb)
4.19- (asdf:make :bin/rdb))
4.20- #$mv lisp/bin/rdb .stash/rdb$#)
4.21- (build-skel (%stash) (with-sbcl (:noinform t :quit t)
4.22- (ql:quickload :bin/skel)
4.23- (asdf:make :bin/skel))
4.24- #$mv lisp/bin/skel .stash/skel$#)
4.25- (build-skel-gui (%stash) (with-sbcl (:noinform t :quit t)
4.26- (push :tools *features*)
4.27- (ql:quickload :bin/skel)
4.28- (asdf:make :bin/skel))
4.29- #$mv lisp/bin/skel .stash/skel$#)
4.30- (build-organ (%stash) (with-sbcl (:noinform t :quit t)
4.31+ (rdb (%stash)
4.32+ (:build ()
4.33+ (with-sbcl (:noinform t :quit t)
4.34+ (ql:quickload :bin/rdb)
4.35+ (asdf:make :bin/rdb))
4.36+ #$mv lisp/bin/rdb .stash/rdb$#))
4.37+ (skel (%stash)
4.38+ (:build ()
4.39+ (with-sbcl (:noinform t :quit t)
4.40+ (ql:quickload :bin/skel)
4.41+ (asdf:make :bin/skel))
4.42+ #$mv lisp/bin/skel .stash/skel$#)
4.43+ (:build-gui ()
4.44+ (with-sbcl (:noinform t :quit t)
4.45+ (push :tools *features*)
4.46+ (ql:quickload :bin/skel)
4.47+ (asdf:make :bin/skel))
4.48+ #$mv lisp/bin/skel .stash/skel$#)
4.49+ (:install () #$install -C -m 755 .stash/skel /usr/local/bin/skel$#))
4.50+ (organ (%stash)
4.51+ (:build () (with-sbcl (:noinform t :quit t)
4.52 (ql:quickload :bin/organ)
4.53 (asdf:make :bin/organ))
4.54- #$mv lisp/bin/organ .stash/organ$#)
4.55- (build-homer (%stash) (with-sbcl (:noinform t :quit t)
4.56- (ql:quickload :bin/homer)
4.57- (asdf:make :bin/homer))
4.58- #$mv lisp/bin/homer .stash/homer$#)
4.59- (build-packy (%stash) (with-sbcl (:noinform t :quit t)
4.60- (ql:quickload :bin/packy)
4.61- (asdf:make :bin/packy))
4.62- #$mv lisp/bin/packy .stash/packy$#)
4.63+ #$mv lisp/bin/organ .stash/organ$#))
4.64+ (homer (%stash)
4.65+ (:build () (with-sbcl (:noinform t :quit t)
4.66+ (ql:quickload :bin/homer)
4.67+ (asdf:make :bin/homer))
4.68+ #$mv lisp/bin/homer .stash/homer$#))
4.69+ (packy (%stash)
4.70+ (:build () (with-sbcl (:noinform t :quit t)
4.71+ (ql:quickload :bin/packy)
4.72+ (asdf:make :bin/packy))
4.73+ #$mv lisp/bin/packy .stash/packy$#))
4.74 (build (build-rdb build-skel build-organ build-homer build-packy))
4.75 (compile () #$./x.lisp compile$#)
4.76- (save-std () #$./x.lisp save std$#)
4.77- (save-prelude () #$./x.lisp save prelude$#)
4.78- (save-user () #$./x.lisp save user$#)
4.79- (save-infra () #$./x.lisp save infra$#)
4.80- (save-core () #$./x.lisp save core$#)
4.81- (save-tests () #$./x.lisp save tests$#)
4.82- (prelude-fasl () #$./x.lisp make prelude$#)
4.83- (user-fasl () #$./x.lisp make user$#)
4.84- (core-fasl () #$./x.lisp make core$#)
4.85- (tests-fasl () #$./x.lisp make core/tests$#)
4.86- (bench-fasl () #$./x.lisp make core/bench$#)
4.87- (fasl (core-fasl tests-fasl bench-fasl user-fasl prelude-fasl))
4.88+ (std () (:save () #$./x.lisp save std$#))
4.89+ (prelude ()
4.90+ (:save () #$./x.lisp save prelude$#)
4.91+ (:compile () #$./x.lisp make prelude$#))
4.92+ (user ()
4.93+ (:save () #$./x.lisp save user$#)
4.94+ (:compile () #$./x.lisp make user$#))
4.95+ (infra () (:save () #$./x.lisp save infra$#))
4.96+ (core ()
4.97+ (:save () #$./x.lisp save core$#)
4.98+ (:compile () #$./x.lisp make core$#))
4.99+ (tests ()
4.100+ (:save () #$./x.lisp save tests$#)
4.101+ (:compile () #$./x.lisp make core/tests$#))
4.102+ (bench () (:compile () #$./x.lisp make core/bench$#))
4.103+ (fasl (compile-core compile-tests compile-bench compile-user compile-prelude))
4.104 ;; rust
4.105 (mailman () #$cd rust && cargo build -Z unstable-options --bin mailman --artifact-dir ../.stash/$#)
4.106 (alik () #$cd rust && cargo build -Z unstable-options --bin alik --artifact-dir ../.stash/$#)