From: charlie
Subject: ASDF Question - How to specify an image (picture) file.
Date: 
Message-ID: <402d6196-df4b-44ff-a4d8-2284f5d84f4a@d45g2000hsc.googlegroups.com>
I'm trying to run through the NeHe openGL examples with cl-opengl and
need to specify an image file for a texture but when I come to load
the texture file I get the following message:

error opening #P"/var/cache/common-lisp-controller/1000/sbcl/local/
home/charlieb/src/cl-opengl/examples/nehe/paint64x64.ras":
  No such file or directory
   [Condition of type SB-POSIX::FILE-ENOENT]

which makes sense because it is still in the source directory. I'd
like to specify the texture file in the asdf definition so that (I
guess) it'd gt copied to the above directory.
I tried to use the source-file directive:

(defsystem cl-opengl-nehe
    :name "CL-OPENGL-NEHE"
    :version "0.1"
    :author "Charlie Burrows"
    :description "Nehe Tutorials using cl-opengl"
    :long-description "Nehe Tutorials 1-6 implemented using cl-opengl"
    :components
		((:module "examples"
				:components
				((:file "examples")
				 (:module "nehe"
						:depends-on ("examples")
						:components ((:file "nehe1")
						 (:file "nehe2" :depends-on ("nehe1"))
						 (:file "nehe3" :depends-on ("nehe1"))
						 (:file "nehe4" :depends-on ("nehe1"))
						 (:file "nehe5" :depends-on ("nehe1"))
						 (:file "sunras")
						 (:file "nehe6" :depends-on
								("nehe1" "sunras"))))))
		 (:source-file "paint64x64.ras")
		 )
		:depends-on (cl-opengl cl-glu cl-glut))

but then I get:

There is no applicable method for the generic function
  #<STANDARD-GENERIC-FUNCTION ASDF:SOURCE-FILE-TYPE (5)>
when called with arguments
  (#<ASDF:SOURCE-FILE "paint64x64.ras" {B9018F9}>
   #<ASDF:SYSTEM "cl-opengl-nehe" {ACFB4B1}>).
   [Condition of type SIMPLE-ERROR]

Can anyone suggest a solution to this problem?

Thanks
charlieb
From: Robert Brown
Subject: Re: ASDF Question - How to specify an image (picture) file.
Date: 
Message-ID: <m2tzgkoow3.fsf@roger-vivier.bibliotech.com>
charlie <···············@gmail.com> writes:
> I'd like to specify the texture file in the asdf definition so that (I
> guess) it'd get copied to the above directory.  I tried to use the
> source-file directive:

There may be an easier way to solve your ASDF problem, given its specifics.
However, I faced something similar and you should be able to adapt what I
did.

You have a new kind of SOURCE-FILE, your RAS texture file.  It's not Lisp,
so ASDF doesn't know how to process it.  Similarly, I have a new kind of
source.  Let's call it a FOOBAR file.  I need to have ASDF translate the
FOOBAR file into Lisp and then load the Lisp file.  From what you've said,
you just need to make ASDF copy the RAS file somewhere and then load it, so
the solution to your problem should be simpler.

First, I define the new kind of SOURCE-FILE:

(defclass foobar-file (source-file)
  ()
  (:documentation "Foobar source code"))

Next, I tell ASDF what the file extension is for FOOBAR files, what files
need to be up to date in order to compile it, what output files are produced
when the file is compiled, and how exactly to compile it.  I also tell ASDF
how to load foobar files, by doing nothing.

(defmethod source-file-type ((component foobar-file) (module module))
  "foobar")

(defmethod input-files ((operation compile-op) (component foobar-file))
  (append (list *foobar-compiler*) (call-next-method)))

(defmethod output-files ((operation compile-op) (component component))
  (list (merge-pathnames (make-pathname
                          :name (pathname-name (component-pathname component))
                          :type "lisp")
                         (asdf::component-parent-pathname component))))

(defmethod perform ((operation compile-op) (component foobar-file))
  (let* ((source-file (component-pathname component))
         (output-file (car (output-files operation component))))
    (zerop (run-shell-command "~S ~S -o ~S"
                              (namestring *foobar-compiler*)
                              (namestring source-file)
                              (namestring output-file)))))

(defmethod perform ((operation load-op) (component foobar-file))
  nil)

I believe you can solve your problem by doing something similar.  Instead of
compiling the RAS file, copy it to the output file.  Similarly, you'll have
to tell ASDF how to load the RAS file, but the default behavior for
COMPONENT may just work.

Good luck.

> (defsystem cl-opengl-nehe
>     :name "CL-OPENGL-NEHE"
>     :version "0.1"
>     :author "Charlie Burrows"
>     :description "Nehe Tutorials using cl-opengl"
>     :long-description "Nehe Tutorials 1-6 implemented using cl-opengl"
>     :components
> 		((:module "examples"
> 				:components
> 				((:file "examples")
> 				 (:module "nehe"
> 						:depends-on ("examples")
> 						:components ((:file "nehe1")
> 						 (:file "nehe2" :depends-on ("nehe1"))
> 						 (:file "nehe3" :depends-on ("nehe1"))
> 						 (:file "nehe4" :depends-on ("nehe1"))
> 						 (:file "nehe5" :depends-on ("nehe1"))
> 						 (:file "sunras")
> 						 (:file "nehe6" :depends-on
> 								("nehe1" "sunras"))))))
> 		 (:source-file "paint64x64.ras")
> 		 )
> 		:depends-on (cl-opengl cl-glu cl-glut))
>
> but then I get:
>
> There is no applicable method for the generic function
>   #<STANDARD-GENERIC-FUNCTION ASDF:SOURCE-FILE-TYPE (5)>
> when called with arguments
>   (#<ASDF:SOURCE-FILE "paint64x64.ras" {B9018F9}>
>    #<ASDF:SYSTEM "cl-opengl-nehe" {ACFB4B1}>).
>    [Condition of type SIMPLE-ERROR]
>
> Can anyone suggest a solution to this problem?