[Rake-devel] Rules in Rake
Jim Weirich
jim at weirichhouse.org
Thu Sep 2 18:59:04 EDT 2004
Link, Claudius said:
> Hello,
>
> to take more advantage of rake I was trying
> to use rules.
> But I simply don't manage :-(
>
> I use the simple rule from the documentation
> and put it into a rakefile
>
> simplerule.rb
> ----------
> require 'rake'
>
> task :default => [ "test1.o" ]
>
> rule '.o' => ['.c'] do |t|
> print "cc #{t.source} -c -o #{t.name}"
> end
> ----------
>
> Now neither
> rake -f simplerule.rb
> nor
> rake -f simplerule.rb test2.o
>
> work like I expected. I seam to miss something
> Does someone know what %-|?
The most obvious question is: Do you have a test2.c file available.
Here is a sample session on my machine, using your rakefile...
== BEGIN SAMPLE ==============================================
$ ls
simplerule.rb
test1.c
$
$ cat simplerule.rb
require 'rake'
task :default => [ "test1.o" ]
rule '.o' => ['.c'] do |t|
puts "cc #{t.source} -c -o #{t.name}"
end
$
$
$ rake -f simplerule.rb
(in c:/weirich/pgm/ruby/rakestuff/x)
cc test1.c -c -o test1.o
$
== END SAMPLE ========================================
BTW, the "require 'rake'" isn't strictly required in a rakefile. Since
the rake program runs it, the rake libarary is alread loaded.
--
-- Jim Weirich jim at 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)
More information about the Rake-devel
mailing list