changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: removed skel project env/def, added to BIND

changeset 662: a53be64410c5
parent 661: 39170f311b8c
child 663: cc89b337384b
author: Richard Westhaver <ellis@rwest.io>
date: Sat, 21 Sep 2024 18:18:14 -0400
files: lisp/bin/skel.lisp lisp/lib/skel/core/obj.lisp lisp/lib/skel/core/proto.lisp skelfile
description: removed skel project env/def, added to BIND
     1.1--- a/lisp/bin/skel.lisp	Sat Sep 21 00:04:33 2024 -0400
     1.2+++ b/lisp/bin/skel.lisp	Sat Sep 21 18:18:14 2024 -0400
     1.3@@ -120,7 +120,7 @@
     1.4     ("scripts" (sk-scripts *skel-project*))
     1.5     ("rules" (sk-rules *skel-project*))
     1.6     ("phases" (hash-table-alist (sk-phases *skel-project*)))
     1.7-    ("env" (sk-env *skel-project*))
     1.8+    ;; ("env" (sk-env *skel-project*))
     1.9     ("bind" (sk-bind *skel-project*))
    1.10     ("include" (sk-include *skel-project*))
    1.11     ("stash" (sk-stash *skel-project*))
    1.12@@ -176,7 +176,7 @@
    1.13 (defcmd skc-commit
    1.14   (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t)))
    1.15     (:git (run-git-command "commit" (append '("-m") *args*) t))
    1.16-    (:hg (run-hg-command "commit" (when *opts* ) t))
    1.17+    (:hg (run-hg-command "commit" (when *args* (append '("-m") *args*)) t))
    1.18     (t (skel-simple-error "unknown VC type"))))
    1.19 
    1.20 (defcmd skc-make
     2.1--- a/lisp/lib/skel/core/obj.lisp	Sat Sep 21 00:04:33 2024 -0400
     2.2+++ b/lisp/lib/skel/core/obj.lisp	Sat Sep 21 18:18:14 2024 -0400
     2.3@@ -242,7 +242,7 @@
     2.4 
     2.5 ;;; Command
     2.6 (defclass sk-command (skel)
     2.7-  ((body :initform nil :initarg :body :type (or form function) :accessor sk-body)))
     2.8+  ((body :initform nil :initarg :body :accessor sk-body)))
     2.9 
    2.10 (defmethod sk-new ((self (eql :command)) &key body)
    2.11   (make-instance 'sk-command :body body))
    2.12@@ -254,7 +254,7 @@
    2.13   (with-output-to-string (s)
    2.14     (sk-write self s)))
    2.15 
    2.16-(defmethod sk-writeln ((self sk-command) stream) 
    2.17+(defmethod sk-writeln ((self sk-command) stream)
    2.18   (sk-write self stream)
    2.19   (format stream "~%"))
    2.20 
    2.21@@ -307,19 +307,21 @@
    2.22     (sk-write-string source)
    2.23     (sk-write-string recipe)))
    2.24 
    2.25+(defun sk-run-with-sources (obj rule)
    2.26+  (when-let ((sources (sk-rule-source rule)))
    2.27+    (mapcar
    2.28+     (lambda (src)
    2.29+       (if-let* ((sr (sk-find-rule src obj)))
    2.30+                ;; check if we need to rerun sources
    2.31+                (sk-make obj sr)
    2.32+                (warn! "unhandled source:" src "for rule:" rule)))
    2.33+     sources))
    2.34+  (sk-run rule))
    2.35+
    2.36 (defun sk-make (obj &rest rules)
    2.37   (if rules
    2.38       (mapc
    2.39-       (lambda (rule)
    2.40-         (when-let ((sources (sk-rule-source rule)))
    2.41-           (mapcar
    2.42-            (lambda (src)
    2.43-              (if-let* ((sr (sk-find-rule src obj)))
    2.44-                       ;; check if we need to rerun sources
    2.45-                       (sk-make obj sr)
    2.46-                       (warn! "unhandled source:" src "for rule:" rule)))
    2.47-            sources))
    2.48-         (sk-run rule))
    2.49+       (lambda (r) (sk-run-with-sources obj r))
    2.50        rules)
    2.51       (unless (sequence:emptyp (sk-rules obj))
    2.52         (let ((rule (aref (sk-rules obj) 0)))
    2.53@@ -356,6 +358,7 @@
    2.54     (format stream "~S" (sk-vc-meta-kind self))
    2.55     (when-let ((remotes (sk-vc-meta-remotes self)))
    2.56       (format stream " ~A" remotes))))
    2.57+
    2.58 ;;; Project
    2.59 (defclass sk-project (skel sxp sk-meta)
    2.60   ((name :initarg :name :initform "" :type string)
    2.61@@ -365,8 +368,7 @@
    2.62    (store :initarg :store :accessor sk-store :type pathname)
    2.63    (components :initform #() :initarg :components :accessor sk-components :type (vector sk-component))
    2.64    (bind :initarg :bind :initform nil :accessor sk-bind :type list)
    2.65-   (def :initarg :def :initform nil :accessor sk-def :type list)
    2.66-   (env :initarg :env :initform nil :accessor sk-env :type list)
    2.67+   ;; (env :initarg :env :initform nil :accessor sk-env :type list)
    2.68    (phases :initarg :phases
    2.69            :initform (make-hash-table)
    2.70            :accessor sk-phases
    2.71@@ -456,29 +458,66 @@
    2.72                        (warn! (format nil "ignoring missing scripts directory: ~A" (sk-scripts self)))))
    2.73           (when-let ((scripts (sk-scripts self)))
    2.74             (setf (sk-scripts self) (map 'vector #'make-sk-script scripts)))
    2.75-          ;; ENV
    2.76-          ;; TODO
    2.77-          (when-let ((env (sk-env self)))
    2.78-            (setf (sk-env self) (mapcar
    2.79-                                 (lambda (e)
    2.80-                                   (etypecase e
    2.81-                                     (symbol (cons
    2.82-                                              (sb-int:keywordicate e)
    2.83-                                              (sb-posix:getenv (format nil "~a" (symbol-name e)))))
    2.84-                                     (string (cons
    2.85-                                              (sb-int:keywordicate e)
    2.86-                                              (sb-posix:getenv (string-upcase e))))
    2.87-                                     (list
    2.88-                                      (cons (sb-int:keywordicate (car e)) (cadr e)))))
    2.89-                                 env)))
    2.90-          ;; BIND is always just a list evaluated only in the body of a WITH-SK-BINDINGS form.
    2.91-
    2.92-          ;; DEF is a list of function definitions which are compiled.
    2.93-          (when-let ((defs (sk-def self)))
    2.94-            (let ((ret))
    2.95-              (setf (sk-def self)
    2.96-                    (dolist (def defs ret)
    2.97-                      (push (compile (car def) `(lambda ,(cadr def) ,@(cddr def))) ret)))))
    2.98+          ;; ;; ENV
    2.99+          ;; ;; TODO
   2.100+          ;; (when-let ((env (sk-env self)))
   2.101+          ;;   (setf (sk-env self) (mapcar
   2.102+          ;;                        (lambda (e)
   2.103+          ;;                          (etypecase e
   2.104+          ;;                            (symbol (cons
   2.105+          ;;                                     (sb-int:keywordicate e)
   2.106+          ;;                                     (sb-posix:getenv (format nil "~a" (symbol-name e)))))
   2.107+          ;;                            (string (cons
   2.108+          ;;                                     (sb-int:keywordicate e)
   2.109+          ;;                                     (sb-posix:getenv (string-upcase e))))
   2.110+          ;;                            (list
   2.111+          ;;                             (cons (sb-int:keywordicate (car e)) (cadr e)))))
   2.112+          ;;                        env)))
   2.113+          ;; BIND contains a list of forms which are bound dynamically based
   2.114+          ;; on the contents of the cdr
   2.115+          (when-let ((bind (sk-bind self)))
   2.116+            (setf (sk-bind self)
   2.117+                  (let ((ret))
   2.118+                    ;; TODO 2024-09-21: 
   2.119+                    (dolist (b bind ret)
   2.120+                      ;; if this is a list of length > 2 we parse the form as (sym props val)
   2.121+                      (let ((sym (car b))
   2.122+                            (form (cddr b)))
   2.123+                        (cond 
   2.124+                          ((> (length form) 0)
   2.125+                           (let ((key? (cadr b)))
   2.126+                             (if (keywordp key?)
   2.127+                                 (case key?
   2.128+                                   (:hook
   2.129+                                    ;; process the remainder of the form as specializer+body
   2.130+                                    (destructuring-bind (spec &rest body) form
   2.131+                                      (declare (ignore spec body))
   2.132+                                      (nyi!)))
   2.133+                                   (:cmd
   2.134+                                    ;; process the remainder as spec+defcmd-args+body
   2.135+                                    )
   2.136+                                   (:opt
   2.137+                                    ;; process the remainder as spec+defcmd-args+body
   2.138+                                    )
   2.139+                                   (:env
   2.140+                                    ;; process the remainder as a regular value but
   2.141+                                    ;; associate the name with a shell environment which
   2.142+                                    ;; is set to the value. If the cdr is of length 3
   2.143+                                    ;; then we simply remember the value and set it during
   2.144+                                    ;; any calls out from Lisp to the shell. When the form
   2.145+                                    ;; length is > 3 we parse the next value as a shell
   2.146+                                    ;; specification with additional options for checking
   2.147+                                    ;; for pre-existing values and 'exporting' the
   2.148+                                    ;; environment.
   2.149+                                    (if (= (length form) 1)
   2.150+                                        ;; TODO 2024-09-21: setenv
   2.151+                                        (push (list sym (car form)) ret)
   2.152+                                        ;; process additional shell opts
   2.153+                                        (nyi!))))
   2.154+                                 ;; else we assume that a function is being defined
   2.155+                                 (push `(,sym ,(compile sym `(lambda ,(cadr b) ,@(cddr b)))) ret))))
   2.156+                          (t
   2.157+                           (push b ret))))))))
   2.158           ;; RULES
   2.159           (when-let ((rules (sk-rules self)))
   2.160             (setf (sk-rules self)
     3.1--- a/lisp/lib/skel/core/proto.lisp	Sat Sep 21 00:04:33 2024 -0400
     3.2+++ b/lisp/lib/skel/core/proto.lisp	Sat Sep 21 18:18:14 2024 -0400
     3.3@@ -23,7 +23,8 @@
     3.4   (:documentation "Load a component of type KIND from provided FORM, producing an SK-COMPONENT
     3.5 type. Usually calls SK-TRANSFORM or SK-CONVERT internally.
     3.6 
     3.7-PATH is an optional directory pathname which will be merged with a filename found in FORM. Defaults to *DEFAULT-PATHNAME-DEFAULTS*."))
     3.8+PATH is an optional directory pathname which will be merged with a filename
     3.9+found in FORM. Defaults to *DEFAULT-PATHNAME-DEFAULTS*."))
    3.10 (defgeneric sk-compile (self &key &allow-other-keys)
    3.11   (:documentation "Compile object SELF."))
    3.12 (defgeneric sk-build (self &key &allow-other-keys)
     4.1--- a/skelfile	Sat Sep 21 00:04:33 2024 -0400
     4.2+++ b/skelfile	Sat Sep 21 18:18:14 2024 -0400
     4.3@@ -9,9 +9,8 @@
     4.4 :tags ("core" "lisp" "rust" "emacs" "c")
     4.5 :include ("lisp.sk" "rust.sk" "emacs.sk")
     4.6 :vc (:hg "https://vc.compiler.company/core")
     4.7-:env ((cc "clang"))
     4.8-:def nil
     4.9-:bind nil
    4.10+:bind ((stash ".stash")
    4.11+       (cc :env "clang"))
    4.12 :components ((:dir-locals ".dir-locals")
    4.13              (:org "readme"))
    4.14 :rules