Mercurial > core / lisp/lib/skel/comp/asd.lisp
changeset 468: |
121a0253aa3c |
parent: |
c40d2a41d7ce
|
child: |
7354623e5b54 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sat, 22 Jun 2024 00:51:41 -0400 |
permissions: |
-rw-r--r-- |
description: |
progress on asd comp |
1 ;;; lib/skel/comp/asd.lisp --- ASDF System Definition Compiler 3 ;; ASDF/PARSE-DEFSYSTEM may come in handy for testing. 5 ;; The problem with ASD files is that they're read-only afaik - eg there's no 6 ;; 'write' methods implemented on ASD:SYSTEM objects. This makes it a bit 7 ;; tedious because we obviously want to transform SK-LISP-SYSTEM objects 8 ;; directly to SYSTEM, but also need to be able to write them out as discrete 9 ;; files for portability. Probably will end up violating all that is DRY and 13 (in-package :skel/comp/asd) 15 (defclass sk-lisp-system (skel asdf:system) ()) 17 (defun read-system-definitions (system) 18 (with-open-file (file (asdf:system-source-file system)) 19 (loop for x = (read file nil) 23 (defun to-sk-system (system) 24 (let ((sys (change-class system 'sk-lisp-system))) 28 (defun find-sk-system (system) 29 (to-sk-system (asdf:find-system system))) 31 (defun parse-sk-system (name path &optional opts) 32 (to-sk-system (asdf::parse-component-form nil (list* :system name :pathname path opts)))) 34 (defmethod sk-load ((self sk-lisp-system) &key force force-not verbose version) 35 (asdf:load-system self :force force :force-not force-not :verbose verbose :version version)) 37 (defmethod sk-compile ((self sk-lisp-system) stream &key &allow-other-keys)) 39 (defun sk-write-asd-components (module) 42 (list (keywordicate (string-upcase (asdf:file-type module))) 43 (pathname-name (asdf:component-relative-pathname module)))) 46 (asdf:component-name module) 47 `(,@(when-let ((%c (asdf:module-components module))) 48 `((:components ,(mapcar #'sk-write-asd-components %c))))))))) 50 (defmethod sk-write-file ((self sk-lisp-system) &key path) 51 (let ((name (asdf:component-name self))) 52 (with-open-file (s path 54 :if-does-not-exist :create) 55 (format s ";;; ASDF definition for system ~A~%" name) 57 (format s ";;; Built for ~A ~A on a ~A/~A ~A~%" 58 (lisp-implementation-type) 59 (lisp-implementation-version) 63 (let ((*package* (find-package :asdf-user)) 64 (*print-case* :downcase)) 65 (pprint `(defsystem ,name 66 :class prebuilt-system 67 :version ,(asdf:component-version self) 68 :depends-on ,(asdf:system-depends-on self) 69 :components ,(mapcar #'sk-write-asd-components 70 (cdr (asdf:module-components self)))) 74 ;; (sk-write-file (find-sk-system :skel) :path "test") 76 (defmethod sk-read-file ((self sk-lisp-system) path) 77 (parse-sk-system (pathname-name path) (pathname-directory path)))