]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
asdf-support: more filename mangling
authorAlejandro R Sedeño <asedeno@google.com>
Tue, 5 Mar 2013 19:50:29 +0000 (14:50 -0500)
committerAlejandro R Sedeño <asedeno@google.com>
Wed, 6 Mar 2013 04:18:57 +0000 (23:18 -0500)
New functions:

* ASDF::PROTOBUF-MANGLE-NAME: Takes a pathname, returns a string to be
  used as a filename that represents the original path.
  e.g., #P"/foo/bar/baz.quux" becomes "foo-bar-baz-quux"

* ASDF::PROTOBUF-LISPIZE-PATHNAME: Takes a pathname, returns a new
  pathname with the name mangled as described above, and with a lisp
  type.

asdf-support.lisp

index 1e3311fa1be90a29619e00ed0cc6ed5a85321d55..334faebf6b2b964615a9740793730dc3e427551a 100644 (file)
   (pathname-directory-pathname
    (merge-pathnames* path parent-path)))
 
+(defun protobuf-mangle-name (input-file)
+  (let ((directory (pathname-directory input-file)))
+    (format nil "~{~A-~}~A-~A"
+            (if (eq (first directory) :absolute)
+              (rest directory)
+              directory)
+            (pathname-name input-file)
+            (pathname-type input-file))))
+
+(defun protobuf-lispize-pathname (input-file)
+  (make-pathname
+   :name (protobuf-mangle-name input-file)
+   :type "lisp"
+   :defaults input-file))
+
 (defmethod input-files ((op proto-to-lisp) (component protobuf-file))
   "The input file is just the .proto file."
   (declare (ignorable op))
    stored where .fasl files are stored"
   (declare (ignorable op))
   (let* ((base-pathname (component-pathname component))
-         (lisp-file (make-pathname
-                     :name (format nil "~A.proto" (pathname-name base-pathname))
-                     :type "lisp"
-                     :defaults base-pathname)))
+         (lisp-file (protobuf-lispize-pathname base-pathname)))
     (values (list lisp-file
                   (make-pathname :type "proto-imports"
                                  :defaults lisp-file))
     (let* ((base-path  (asdf::merge-pathnames* import path))
            (proto-file (make-pathname :name import-name :type "proto"
                                       :defaults base-path))
-           (lisp-file  (asdf::lispize-pathname
-                        (if output-path
-                            (make-pathname :name import-name
-                                           :directory (pathname-directory output-path))
-                            base-path)))
+           (lisp-file (if output-path
+                        (asdf::lispize-pathname
+                         (make-pathname :name (asdf::protobuf-mangle-name base-path)
+                                        :directory (pathname-directory output-path)))
+                        (asdf::protobuf-lispize-pathname base-path)))
            (imports-file (make-pathname :type "proto-imports"
                                         :defaults lisp-file))
            (fasl-file  (compile-file-pathname lisp-file))