Help with Rake and FileList

J

jim

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?
 
J

Jim Weirich

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).
 
J

jim

* Jim Weirich said:
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?
 
J

Jim Weirich

(e-mail address removed) 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top