git.fiddlerwoaroof.com
Edward Langley authored on 09/11/2023 21:54:58
Showing 6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
1
+*.fasl
2
+*~
0 3
new file mode 100644
... ...
@@ -0,0 +1,46 @@
1
+(defpackage :fwoar.file-string
2
+  (:use :cl )
3
+  (:shadow :string)
4
+  (:export string))
5
+(in-package :fwoar.file-string)
6
+
7
+(defclass asdf-user::file-string (asdf:cl-source-file)
8
+  ((package :initarg :package
9
+            :reader string-package
10
+            :initform (error "must have a package"))
11
+   (extension :initarg :extension
12
+              :reader string-extension
13
+              :initform (error "must have a extension"))))
14
+
15
+(defclass generate-lisp-op (asdf:downward-operation)
16
+  ())
17
+(defmethod asdf:component-depends-on ((o asdf:compile-op) (component asdf-user::file-string))
18
+  `((generate-lisp-op ,component) ,@(call-next-method)))
19
+
20
+(defvar *empty-package* (make-package (symbol-name (gensym)) :use ()))
21
+(defmethod asdf:perform ((op generate-lisp-op) (c asdf-user::file-string))
22
+  (let* ((lisp-file (car (asdf:input-files 'asdf:load-source-op
23
+                                           c)))
24
+         (file-string (merge-pathnames (make-pathname :type (string-extension c))
25
+                                       lisp-file))
26
+         (*package* *empty-package*)
27
+         (*print-pretty* t)
28
+         (*print-case* :upcase))
29
+    (alexandria:with-output-to-file (s lisp-file
30
+                                       :if-exists :supersede
31
+                                       :if-does-not-exist :create)
32
+      (pprint `(defpackage ,(string-package c) (:use) (:export :+data+))
33
+              s)
34
+      (fresh-line s)
35
+      (princ (serapeum:string-replace
36
+              "#:~A"
37
+              (with-output-to-string (str)
38
+                (let ((*print-readably* t))
39
+                  (pprint `(defparameter #:~a
40
+                             ,(alexandria:read-file-into-string file-string))
41
+                          str)))
42
+              (format nil "~a:~a"
43
+                      (string-package c)
44
+                      :+data+))
45
+             s))
46
+    (values)))
0 47
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+
2
+(COMMON-LISP:DEFPACKAGE ASDF/USER::FOO.DATA
3
+  (:USE)
4
+  (:EXPORT :+DATA+))
5
+
6
+(COMMON-LISP:DEFPARAMETER FOO.DATA:+DATA+
7
+  "This is the data
8
+")
0 9
\ No newline at end of file
1 10
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+This is the data
... ...
@@ -11,4 +11,5 @@
11 11
                #:yason)
12 12
   :serial t
13 13
   :components ((:file "json-file")
14
+               (:file "file-string")
14 15
                ))
15 16
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Package: ASDF-USER -*-
2
+(in-package :asdf-user)
3
+
4
+(defsystem :test-system
5
+  :description ""
6
+  :author "Ed L <edward@elangley.org>"
7
+  :license "MIT"
8
+  :depends-on (#:alexandria
9
+               #:uiop
10
+               #:serapeum
11
+               )
12
+  :serial t
13
+  :defsystem-depends-on (:fwoar-asdf-extensions)
14
+  :components ((fwoar.file-string:string "foo" :package foo.data)
15
+               ))