]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
asdf-support: rework import again
authorAlejandro R Sedeño <asedeno@google.com>
Tue, 5 Mar 2013 22:18:35 +0000 (17:18 -0500)
committerAlejandro R Sedeño <asedeno@google.com>
Wed, 6 Mar 2013 04:19:00 +0000 (23:19 -0500)
* DO-PROCESS-IMPORT is now responsible for deciding whether or not to
  process an import. It does so by searching for the .proto to be
  imported, and upon finding it, checks to see if we alredy have a
  schema for that pathname. Additionally, it now returns the pathname.

* PROCESS-IMPORTS and PROCESS-IMPORTS-FROM-FILE now defer the work of
  figuring out whether or not an import has been done to
  DO-PROCESS-IMPORT. PROCESS-IMPORTS uses the return value of
  DO-PROCESS-IMPORT to update the PROTO-IMPORTED-SCHEMAS of the schema
  being processed.

asdf-support.lisp

index 334faebf6b2b964615a9740793730dc3e427551a..9e329d68fe1503d151a84eb3f1b8440c27741edc 100644 (file)
     (block import-one
       (let* ((import      (pathname import))
              (import-name (pathname-name import))
-             (imported    (find-schema (class-name->proto import-name))))
-        ;; If this schema has already been imported somewhere else,
-        ;; mark it as imported here and carry on
+             (proto-file  (do-process-import import import-name))
+             (imported    (find-schema proto-file)))
         (when imported
-          (appendf (proto-imported-schemas schema) (list imported))
-          (return-from import-one))
-        (do-process-import import import-name)
-        (let* ((imported (find-schema (class-name->proto import-name))))
-          (when imported
-            (appendf (proto-imported-schemas schema) (list imported)))
-          (return-from import-one))))))
+          (appendf (proto-imported-schemas schema) (list imported)))
+        (return-from import-one)))))
 
 (defun process-imports-from-file (imports-file)
   (when (probe-file imports-file)
       (dolist (import imports)
         (let* ((import      (pathname import))
                (import-name (pathname-name import)))
-          ;; If this schema has already been loaded, we're done.
-          (unless (find-schema (class-name->proto import-name))
-            (do-process-import import import-name)))))))
+          (do-process-import import import-name))))))
 
 (defun do-process-import (import import-name
                           &key (search-path *protobuf-search-path*)
            (fasl-date  (asdf::safe-file-write-date fasl-file))
            (imports-date  (asdf::safe-file-write-date imports-file)))
       (when (probe-file proto-file)
+        (when (find-schema proto-file)
+          (return proto-file))
         (let ((*protobuf-pathname* proto-file))
           (when (string= (pathname-type base-path) "proto")
             ;; The user asked to import a .proto file
                  (let ((*compile-file-pathname* nil)
                        (*load-pathname* fasl-file))
                    (load fasl-file)))))
-        (return (values))))))
+        (return proto-file)))))