0

I am currently building a project in Common Lisp and am using the ASDF. However, I am experiencing some difficulties. Namely, when I run asdf:compile-system, it seems to compile. I can then do asdf:load-system successfully. However, some functions located in some of the files remain undefined. To make them known, I have to manually navigate to that file and compile it.

Here is the declaration for the system. Could someone tell me what I am doing incorrectly?

(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"))))

In particular, I am having an issue with the file routes/activities and possibly route-processors.

MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
  • does routes/activities live in a subdirectory or do you have a file called "routes/activities/lisp" ? if the former , maybe use modules? – David Hodge Mar 27 '18 at 04:55
  • It is a subdirectory. How would it look using modules? I tried that earlier but kept getting an error. – MadPhysicist Mar 27 '18 at 11:06
  • The same as you did above with the `src`-module: `(:module "routes" :depends-on ("packages") :components ((:file "activities")))` – jkiiski Mar 27 '18 at 11:16
  • This entry would go in place of ‘(:file “routes/activities”)’? – MadPhysicist Mar 27 '18 at 11:41
  • Yep, that’s what it would look like. – David Hodge Mar 27 '18 at 17:53
  • Is there an infinite nesting allowed? – MadPhysicist Mar 27 '18 at 18:58
  • 1
    Infinite would take too long, but I think it can be arbitrarily deep. – Svante Mar 27 '18 at 20:35
  • @DavidHodge Why is it that I can do this: ``(:module "routes" :depends-on ("packages") :components ((:file "activities"))) but cannot do this: `(:module "routes" :components ((:file "activities" :depends-on ("packages"))))`? That is, the latter throws an error. Isn't it presumptuous to declare that the entire module depends on a certain file and not be able to specify on a file-by-file basis. – MadPhysicist Mar 28 '18 at 01:37
  • The answer below covers it I think. Also, why are you not using :serial T? I find it makes it much easier to reason about ASDF’S behavior using it. Sorry for the late reply, busy at work! – David Hodge Mar 29 '18 at 20:32
  • I am not sure what `:serial T` does. I am relatively new to ASDF. – MadPhysicist Mar 29 '18 at 21:44
  • https://common-lisp.net/project/asdf/asdf.html#Serial-dependencies. – David Hodge Mar 30 '18 at 02:26

1 Answers1

5

Given my experience with asdf the only off thing of your system definition is the "routes/activities" file as subfolders are defined as modules. This file should fix your problem:

(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"))))

Addressing your last comment. The reason for the exception is that dependencies are resolved within the list the parent of the dependency resides in. So if you say that "activities" depends on "packages" but have "activities" in a module asdf will search for packages in that module/subfolder and due to its non-existance not find it. Whether it is presumptuous or not is irrelevant, this is how it works. It also makes sense as a module usually describes a logical coherent unit and thus dependencies are expected to be similar for that unit, else you might want to rethink your project structure.

Sim
  • 4,199
  • 4
  • 39
  • 77