# HG changeset patch # User Richard Westhaver # Date 1726957094 14400 # Node ID a53be64410c54da426e28df303819c7efdc2c98d # Parent 39170f311b8c9682ec40103125c1c6532da4ded6 removed skel project env/def, added to BIND diff -r 39170f311b8c -r a53be64410c5 lisp/bin/skel.lisp --- a/lisp/bin/skel.lisp Sat Sep 21 00:04:33 2024 -0400 +++ b/lisp/bin/skel.lisp Sat Sep 21 18:18:14 2024 -0400 @@ -120,7 +120,7 @@ ("scripts" (sk-scripts *skel-project*)) ("rules" (sk-rules *skel-project*)) ("phases" (hash-table-alist (sk-phases *skel-project*))) - ("env" (sk-env *skel-project*)) + ;; ("env" (sk-env *skel-project*)) ("bind" (sk-bind *skel-project*)) ("include" (sk-include *skel-project*)) ("stash" (sk-stash *skel-project*)) @@ -176,7 +176,7 @@ (defcmd skc-commit (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t))) (:git (run-git-command "commit" (append '("-m") *args*) t)) - (:hg (run-hg-command "commit" (when *opts* ) t)) + (:hg (run-hg-command "commit" (when *args* (append '("-m") *args*)) t)) (t (skel-simple-error "unknown VC type")))) (defcmd skc-make diff -r 39170f311b8c -r a53be64410c5 lisp/lib/skel/core/obj.lisp --- a/lisp/lib/skel/core/obj.lisp Sat Sep 21 00:04:33 2024 -0400 +++ b/lisp/lib/skel/core/obj.lisp Sat Sep 21 18:18:14 2024 -0400 @@ -242,7 +242,7 @@ ;;; Command (defclass sk-command (skel) - ((body :initform nil :initarg :body :type (or form function) :accessor sk-body))) + ((body :initform nil :initarg :body :accessor sk-body))) (defmethod sk-new ((self (eql :command)) &key body) (make-instance 'sk-command :body body)) @@ -254,7 +254,7 @@ (with-output-to-string (s) (sk-write self s))) -(defmethod sk-writeln ((self sk-command) stream) +(defmethod sk-writeln ((self sk-command) stream) (sk-write self stream) (format stream "~%")) @@ -307,19 +307,21 @@ (sk-write-string source) (sk-write-string recipe))) +(defun sk-run-with-sources (obj rule) + (when-let ((sources (sk-rule-source rule))) + (mapcar + (lambda (src) + (if-let* ((sr (sk-find-rule src obj))) + ;; check if we need to rerun sources + (sk-make obj sr) + (warn! "unhandled source:" src "for rule:" rule))) + sources)) + (sk-run rule)) + (defun sk-make (obj &rest rules) (if rules (mapc - (lambda (rule) - (when-let ((sources (sk-rule-source rule))) - (mapcar - (lambda (src) - (if-let* ((sr (sk-find-rule src obj))) - ;; check if we need to rerun sources - (sk-make obj sr) - (warn! "unhandled source:" src "for rule:" rule))) - sources)) - (sk-run rule)) + (lambda (r) (sk-run-with-sources obj r)) rules) (unless (sequence:emptyp (sk-rules obj)) (let ((rule (aref (sk-rules obj) 0))) @@ -356,6 +358,7 @@ (format stream "~S" (sk-vc-meta-kind self)) (when-let ((remotes (sk-vc-meta-remotes self))) (format stream " ~A" remotes)))) + ;;; Project (defclass sk-project (skel sxp sk-meta) ((name :initarg :name :initform "" :type string) @@ -365,8 +368,7 @@ (store :initarg :store :accessor sk-store :type pathname) (components :initform #() :initarg :components :accessor sk-components :type (vector sk-component)) (bind :initarg :bind :initform nil :accessor sk-bind :type list) - (def :initarg :def :initform nil :accessor sk-def :type list) - (env :initarg :env :initform nil :accessor sk-env :type list) + ;; (env :initarg :env :initform nil :accessor sk-env :type list) (phases :initarg :phases :initform (make-hash-table) :accessor sk-phases @@ -456,29 +458,66 @@ (warn! (format nil "ignoring missing scripts directory: ~A" (sk-scripts self))))) (when-let ((scripts (sk-scripts self))) (setf (sk-scripts self) (map 'vector #'make-sk-script scripts))) - ;; ENV - ;; TODO - (when-let ((env (sk-env self))) - (setf (sk-env self) (mapcar - (lambda (e) - (etypecase e - (symbol (cons - (sb-int:keywordicate e) - (sb-posix:getenv (format nil "~a" (symbol-name e))))) - (string (cons - (sb-int:keywordicate e) - (sb-posix:getenv (string-upcase e)))) - (list - (cons (sb-int:keywordicate (car e)) (cadr e))))) - env))) - ;; BIND is always just a list evaluated only in the body of a WITH-SK-BINDINGS form. - - ;; DEF is a list of function definitions which are compiled. - (when-let ((defs (sk-def self))) - (let ((ret)) - (setf (sk-def self) - (dolist (def defs ret) - (push (compile (car def) `(lambda ,(cadr def) ,@(cddr def))) ret))))) + ;; ;; ENV + ;; ;; TODO + ;; (when-let ((env (sk-env self))) + ;; (setf (sk-env self) (mapcar + ;; (lambda (e) + ;; (etypecase e + ;; (symbol (cons + ;; (sb-int:keywordicate e) + ;; (sb-posix:getenv (format nil "~a" (symbol-name e))))) + ;; (string (cons + ;; (sb-int:keywordicate e) + ;; (sb-posix:getenv (string-upcase e)))) + ;; (list + ;; (cons (sb-int:keywordicate (car e)) (cadr e))))) + ;; env))) + ;; BIND contains a list of forms which are bound dynamically based + ;; on the contents of the cdr + (when-let ((bind (sk-bind self))) + (setf (sk-bind self) + (let ((ret)) + ;; TODO 2024-09-21: + (dolist (b bind ret) + ;; if this is a list of length > 2 we parse the form as (sym props val) + (let ((sym (car b)) + (form (cddr b))) + (cond + ((> (length form) 0) + (let ((key? (cadr b))) + (if (keywordp key?) + (case key? + (:hook + ;; process the remainder of the form as specializer+body + (destructuring-bind (spec &rest body) form + (declare (ignore spec body)) + (nyi!))) + (:cmd + ;; process the remainder as spec+defcmd-args+body + ) + (:opt + ;; process the remainder as spec+defcmd-args+body + ) + (:env + ;; process the remainder as a regular value but + ;; associate the name with a shell environment which + ;; is set to the value. If the cdr is of length 3 + ;; then we simply remember the value and set it during + ;; any calls out from Lisp to the shell. When the form + ;; length is > 3 we parse the next value as a shell + ;; specification with additional options for checking + ;; for pre-existing values and 'exporting' the + ;; environment. + (if (= (length form) 1) + ;; TODO 2024-09-21: setenv + (push (list sym (car form)) ret) + ;; process additional shell opts + (nyi!)))) + ;; else we assume that a function is being defined + (push `(,sym ,(compile sym `(lambda ,(cadr b) ,@(cddr b)))) ret)))) + (t + (push b ret)))))))) ;; RULES (when-let ((rules (sk-rules self))) (setf (sk-rules self) diff -r 39170f311b8c -r a53be64410c5 lisp/lib/skel/core/proto.lisp --- a/lisp/lib/skel/core/proto.lisp Sat Sep 21 00:04:33 2024 -0400 +++ b/lisp/lib/skel/core/proto.lisp Sat Sep 21 18:18:14 2024 -0400 @@ -23,7 +23,8 @@ (:documentation "Load a component of type KIND from provided FORM, producing an SK-COMPONENT type. Usually calls SK-TRANSFORM or SK-CONVERT internally. -PATH is an optional directory pathname which will be merged with a filename found in FORM. Defaults to *DEFAULT-PATHNAME-DEFAULTS*.")) +PATH is an optional directory pathname which will be merged with a filename +found in FORM. Defaults to *DEFAULT-PATHNAME-DEFAULTS*.")) (defgeneric sk-compile (self &key &allow-other-keys) (:documentation "Compile object SELF.")) (defgeneric sk-build (self &key &allow-other-keys) diff -r 39170f311b8c -r a53be64410c5 skelfile --- a/skelfile Sat Sep 21 00:04:33 2024 -0400 +++ b/skelfile Sat Sep 21 18:18:14 2024 -0400 @@ -9,9 +9,8 @@ :tags ("core" "lisp" "rust" "emacs" "c") :include ("lisp.sk" "rust.sk" "emacs.sk") :vc (:hg "https://vc.compiler.company/core") -:env ((cc "clang")) -:def nil -:bind nil +:bind ((stash ".stash") + (cc :env "clang")) :components ((:dir-locals ".dir-locals") (:org "readme")) :rules