如何指定其他文件作为导致 ASDF 重新编译程序的先决条件

Flu*_*lux 3 common-lisp asdf

我编写了一个程序,它使用读取时评估来读取文本文件中包含的字符串。在此示例中,文本文件是1.txt2.txt,两者都包含将在读取期间读取的文本。问题:当我编辑时1.txt,或者2.txt即使这些文件的内容影响程序的行为,ASDF 也不会重新编译程序。如何将这两个文件添加为附加“先决条件”,如果文件被修改,则会导致程序重新编译?

这是有问题的程序:

myprog.asd

(defpackage myprog-asd
  (:use :cl :asdf))
(in-package :myprog-asd)

(defsystem "myprog"
  :components ((:file "myprog")))
Run Code Online (Sandbox Code Playgroud)

myprog.lisp

(in-package :cl-user)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun read-file-string (path)
    "Returns the contents of the file as a string"
    (with-open-file (stream path :direction :input)
      (let ((str (make-string (file-length stream))))
        (read-sequence str stream)
        str))))

(defun run-main ()
  (princ #.(read-file-string "1.txt"))
  (princ #.(read-file-string "2.txt"))
  nil)
Run Code Online (Sandbox Code Playgroud)

创建1.txt2.txt

$ echo 'Hello' > 1.txt
$ echo 'World' > 2.txt
Run Code Online (Sandbox Code Playgroud)

编译并运行程序:

$ sbcl
* (require "asdf")
* (asdf:load-asd (merge-pathnames "myprog.asd" (uiop:getcwd)))
* (asdf:load-system :myprog)
* (run-main)
Hello
World
NIL
Run Code Online (Sandbox Code Playgroud)

如果我修改1.txtor 2.txt,程序将不会重新编译,导致 的输出错误(run-main)

$ echo 'Hi!' > 1.txt
$ echo 'Bye!' > 2.txt
$ sbcl
* (require "asdf")
* (asdf:load-asd (merge-pathnames "myprog.asd" (uiop:getcwd)))
* (asdf:load-system :myprog)
* (run-main)
Hello
World
NIL
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?(asdf:load-system :myprog :force t)可以解决问题,但即使没有任何更改,它也会重新编译程序。

(SBCL 2.2.2;ASDF 3.3.5;Ubuntu 20.04)

jla*_*ahd 6

只需使用以下指令将辅助文件作为附加依赖项包含进来:static-file

(defsystem "myprog"
  :components ((:static-file "1.txt")
               (:static-file "2.txt")
               (:file "myprog" :depends-on ("1.txt" "2.txt"))))
Run Code Online (Sandbox Code Playgroud)