ASDF不会加载Common Lisp文件

时间:2018-03-27 03:54:09

标签: common-lisp asdf

我目前正在使用Common Lisp构建一个项目,并且正在使用ASDF。但是,我遇到了一些困难。也就是说,当我运行asdf:compile-system时,它似乎在编译。然后我可以成功asdf:load-system。但是,某些文件中的某些功能仍未定义。为了让它们为人所知,我必须手动导航到该文件并进行编译。

这是系统的声明。有人能告诉我我做错了什么吗?

(defsystem "xxx-xxxx"
  :version "0.1.0"
  :author ""
  :license ""
  :depends-on ("cl-mongo" "hunchentoot" "clack" "ningle" "cl-json" "hermetic" "lack-middleware-session" "cl-markup")
  :components ((:module "src"
                :components
                ((:file "packages")
         (:file "lisp-utils")
         (:file "xxx-xxxx" :depends-on ("packages"))
         (:file "database" :depends-on ("packages"))
         (:file "database-config" :depends-on ("packages"))
         (:file "server" :depends-on ("packages"))
         (:file "clack" :depends-on ("packages"))
         (:file "routes/activities" :depends-on ("packages"))
         (:file "route-processors" :depends-on ("packages")))))
  :description ""
  :long-description
  #.(read-file-string
     (subpathname *load-pathname* "README.markdown"))
  :in-order-to ((test-op (test-op "xxx-xxxx-test"))))

特别是,我遇到了文件routes/activities以及可能route-processors的问题。

1 个答案:

答案 0 :(得分:4)

根据我对asdf的经验,系统定义中唯一关闭的是“路由/活动”文件,因为子文件夹被定义为模块。此文件应该可以解决您的问题:

(defsystem "xxx-xxxx"
  :version "0.1.0"
  :author ""
  :license ""
  :depends-on ("cl-mongo" 
               "hunchentoot" 
               "clack" 
               "ningle" 
               "cl-json" 
               "hermetic" 
               "lack-middleware-session" 
               "cl-markup")
  :components ((:module "src"
                :components
                ((:file "packages")
                 (:file "lisp-utils")
                 (:file "xxx-xxxx" 
                        :depends-on ("packages"))
                 (:file "database" 
                        :depends-on ("packages"))
                 (:file "database-config" 
                        :depends-on ("packages"))
                 (:file "server" 
                        :depends-on ("packages"))
                 (:file "clack" 
                        :depends-on ("packages"))
                 (:module "routes"
                          :components ((:file "activities"))
                          :depends-on ("packages"))
                 (:file "route-processors" 
                        :depends-on ("packages")))))
  :description ""
  :long-description
  #.(read-file-string
     (subpathname *load-pathname* "README.markdown"))
  :in-order-to ((test-op (test-op "xxx-xxxx-test"))))

解决您的上一条评论。异常的原因是依赖关系在依赖关系的父级所在的列表中被解析。所以如果你说“活动”依赖于“包”但在模块中有“活动”asdf将搜索该模块中的包/子文件夹由于其不存在而找不到它。无论是冒昧与否都是无关紧要的,这就是它的运作方式。它也是有意义的,因为模块通常描述逻辑连贯单元,因此预期该单元的依赖性是相似的,否则您可能想重新考虑您的项目结构。