Help with Rake and FileList

Hi

Can someone tell me what is going wrong here:

    % rake -V
    rake, version 0.4.4
    % ls
    Rakefile
    % cat Rakefile
    X = FileList["*"]
    p X
    
    desc "test"
    task :default
    
    % rake
    (in /Users/jdf/tmp)
    []
    
Why is FileList empty?

···

--
Jim Freeze

jim@freeze.org wrote:

Hi

Can someone tell me what is going wrong here:

    % rake -V
    rake, version 0.4.4
    % ls
    Rakefile % cat Rakefile X = FileList["*"]
    p X
        desc "test"
    task :default
        % rake
    (in /Users/jdf/tmp)
    
    Why is FileList empty?

Hi Jim!

FileList use a "lazy load" technique where we don't calculate the exact list of files needed for a file list until the first time we need to know that information.

This allows us to do things like ...

   JUNK = FileList['**/*.bak']
   CFILES = FileList['**/*.c']
   OFILE = FileList['**/*.o']

   task :clobber do
     # Delete all the JUNK
   end

   task :compile do
     # compile all the CFILES
   end

If I invoke :clobber, I never need to know that CFILES resolves to. And if I invoke :compile, then I never need to resolve JUNK. Since searching the file system can be somewhat expensive, lazy load file lists cut down a little on the startup time of Rake.

So in your case, it seems that the inspect command (issued internally by "p") isn't causing the FileList to be resolved. You can force the resolution of any file list by trying to access the contents of X.

Try this ...

    X = FileList['*']
    p X
    X[0]
    p X

You can also request explicit resolution with "resolve", e.g.

   X = FileList['*']
   p X.resolve

I'm not sure why inspect (used by "p") is not triggering resolution. Perhaps it should (to_s does, for example).

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

* Jim Weirich <jim@weirichhouse.org> [2004-08-23 20:38:38 +0900]:

FileList use a "lazy load" technique where we don't calculate the exact
list of files needed for a file list until the first time we need to
know that information.

I think the problem is that it is 'too lazy' on OS X.

Here is the same rake file, two different OS's.

   cat Rakefile
   F = FileList["*"]
   p F
   task :default

Linux:
   ruby -v; rake -V; rake
   rake, version 0.4.4
   ruby 1.8.0 (2003-08-04) [i386-linux-gnu]
   (in /home/jfn/tmp)
   ["Rakefile"]
   
OS X:
   ruby -v; rake -V; rake
   rake, version 0.4.4
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]
   (in /home/jfn/tmp)
   
   
BTW, F.resolve and F.to_s works on OS X, but I don't understand why the
two different behaviours
Any ideas?

···

--
Jim Freeze

* Jim Weirich <jim@weirichhouse.org> [2004-08-23 20:38:38 +0900]:

FileList use a "lazy load" technique where we don't calculate the exact

jim@freeze.org said:

I think the problem is that it is 'too lazy' on OS X.

Here is the same rake file, two different OS's.

[...]

Linux:
   ruby -v; rake -V; rake
   rake, version 0.4.4
   ruby 1.8.0 (2003-08-04) [i386-linux-gnu]
   (in /home/jfn/tmp)
   ["Rakefile"]

OS X:
   ruby -v; rake -V; rake
   rake, version 0.4.4
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]
   (in /home/jfn/tmp)
   

Or the difference could be 1.8.0 vs 1.8.1. If the 1.8.0 version of
inspect invokes any array-specific methods (and the 1.8.1 version
doesn't), then that is enough to trigger resolution. (I don't have a copy
of 1.8.0 handy to test this).

I've tried your simple rakefile on Linux and windows and aways get the
same results as your OSX example.

BTW, I've looked at the FileList code. Any Array-specific method will
trigger resolution. I also add "to_s" to the list of trigger methods. I
will add "inspect" to this list as well.

My question is: are there any other methods in Kernel in addition to to_s
and inspect that should trigger resolution?

I'll try to get 0.4.5 out tonight with these changes.

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)