Provides useful extensions for Rake.
Methods
Public Instance methods
Allows one to define Rake rules in the context of the given subdirectory. For example,
subdir 'foo' do
file 'libfoo.so' => ['foo.c'] do
sh 'gcc foo.c -shared -fPIC -o libfoo.so'
end
end
subdir 'bar' do
file 'bar' => ['bar.c', '../foo/libfoo.so'] do
sh 'gcc bar.c -o bar -L../foo -lfoo'
end
end
is equivalent to:
file 'foo/libfoo.so' => ['foo/foo.c'] do
Dir.chdir('foo') do
sh 'gcc foo.c -shared -fPIC -o libfoo.so'
end
end
file 'bar/bar' => ['bar/bar.c', 'foo/libfoo.so'] do
Dir.chdir('bar') do
sh 'gcc bar.c -o bar -L../foo -lfoo'
end
end
String dependencies are assumed to be filenames
But be careful with string dependencies. They are assumed to be filenames, and will be automatically converted. For example:
subdir 'foo' do
task 'super_app' => ['super_app:compile', 'super_app:unit_test']
task 'super_app:compile' do
...
end
task 'super_app:unit_test' do
...
end
end
will be treated like:
subdir 'foo' do
# !!!!!!!
task 'super_app' => ['foo/super_app:compile', 'foo/super_app:unit_test']
task 'super_app:compile' do
...
end
task 'super_app:unit_test' do
...
end
end
To solve this, declare your dependencies as symbols:
task 'super_app' => [:'super_app:compile', :'super_app:unit_test']
(note the leading ’:’ character)
Supported Rake commands
Only the file and target Rake commands are supported.
[ show source ]
# File misc/rake/extensions.rb, line 99
99: def subdir(dir, &block)
100: subdir = Subdir.new(dir)
101: Dir.chdir(dir) do
102: subdir.instance_eval(&block)
103: end
104: end