|
List Info
Thread: Generating File Tasks
|
|
| Generating File Tasks |

|
2006-12-01 12:51:17 |
Hi
I'm quite new to both make (and very recently) to rake, but
I appear
to have a problem that is beyond make and I cannot figure
out how to
do it in rake either.
The situation is I have a series of drivers and a series of
models,
stored in the directories 'driver' and 'model',
respectively. The
driver code takes a model and performs some calculations
with it and
any model is valid for any driver.
What I would like to be able to do is have some generic code
whereby
if I add a driver or model, I can type "rake
driver_model" and compile
the code.
I have the code snippet:
file "driver_model" =>
calc_dep("driver_model") do |t|
sh "# # -o #{t.name}
#{t.prerequisites.join(" ")} #"
end
def calc_dep(file)
dep = file.split("_")
dep.collect! { |d| d + ".o" }
return dep
end
which will take driver_model, work out it depends on
driver.o and
model.o and proceed to build the code, which is just what I
want.
However, it does require me to have defined driver_model
combinations
for each executable I wish to create and since I have at
last count 5
drivers and 7 models, I would need to make 35 rules to cover
each
combination and more rules whenever I added another driver
or model.
So I would like to synthesise the possible driver/model
combinations
from the available source files at the time of running rake.
I think I should be able to do this via :
Task.new(task_name,app)
and
the .enhance(deps) method.
within a nested look of the available models and drivers.
However, I'm
not sure how to find the correct application name, since
DRIVERS.each do |d|
MODELS.each do |m|
Task.new("#_#",Rake.application())
end
end
puts Task.tasks()
will return only manually defined tasks, so I don't think
they're
being added to the correct application, and while I've
looked in the
rdoc documentation, I don't understand what I should add...
Any help would be appreciated
Regards
Jonathan
_______________________________________________
Rake-devel mailing list
Rake-devel rubyforge.org
http
://rubyforge.org/mailman/listinfo/rake-devel
|
|
| Generating File Tasks |

|
2006-12-02 22:58:04 |
Hi
I'm quite new to both make (and very recently) to rake, but
I appear
to have a problem that is beyond make and I cannot figure
out how to
do it in rake either.
The situation is I have a series of drivers and a series of
models,
stored in the directories 'driver' and 'model',
respectively. The
driver code takes a model and performs some calculations
with it and
any model is valid for any driver.
What I would like to be able to do is have some generic code
whereby
if I add a driver or model, I can type "rake
driver_model" and compile
the code.
I have the code snippet:
file "driver_model" =>
calc_dep("driver_model") do |t|
sh "# # -o #{t.name}
#{t.prerequisites.join(" ")} #"
end
def calc_dep(file)
dep = file.split("_")
dep.collect! { |d| d + ".o" }
return dep
end
which will take driver_model, work out it depends on
driver.o and
model.o and proceed to build the code, which is just what I
want.
However, it does require me to have defined driver_model
combinations
for each executable I wish to create and since I have at
last count 5
drivers and 7 models, I would need to make 35 rules to cover
each
combination and more rules whenever I added another driver
or model.
So I would like to synthesise the possible driver/model
combinations
from the available source files at the time of running rake.
I think I should be able to do this via :
Task.new(task_name,app)
and
the .enhance(deps) method.
within a nested look of the available models and drivers.
However, I'm
not sure how to find the correct application name, since
DRIVERS.each do |d|
MODELS.each do |m|
Task.new("#_#",Rake.application())
end
end
puts Task.tasks()
will return only manually defined tasks, so I don't think
they're
being added to the correct application, and while I've
looked in the
rdoc documentation, I don't understand what I should add...
Any help would be appreciated
Regards
Jonathan
PS Apologies if this ends up being double posted, but the
list seemed
to eat my first email with narry an indication it had been
sent 24
hours later ... not even getting my own mail back.
_______________________________________________
Rake-devel mailing list
Rake-devel rubyforge.org
http
://rubyforge.org/mailman/listinfo/rake-devel
|
|
| Generating File Tasks |

|
2006-12-03 00:32:50 |
Jonathan Stott wrote:
> Hi
>
> I'm quite new to both make (and very recently) to rake,
but I appear
> to have a problem that is beyond make and I cannot
figure out how to
> do it in rake either.
>
> The situation is I have a series of drivers and a
series of models,
> stored in the directories 'driver' and 'model',
respectively. The
> driver code takes a model and performs some
calculations with it and
> any model is valid for any driver.
>
> What I would like to be able to do is have some generic
code whereby
> if I add a driver or model, I can type "rake
driver_model" and compile
> the code.
> I have the code snippet:
>
> file "driver_model" =>
calc_dep("driver_model") do |t|
> sh "# # -o #{t.name}
#{t.prerequisites.join(" ")} #"
> end
>
> def calc_dep(file)
> dep = file.split("_")
> dep.collect! { |d| d + ".o" }
> return dep
> end
>
> which will take driver_model, work out it depends on
driver.o and
> model.o and proceed to build the code, which is just
what I want.
> However, it does require me to have defined
driver_model combinations
> for each executable I wish to create and since I have
at last count 5
> drivers and 7 models, I would need to make 35 rules to
cover each
> combination and more rules whenever I added another
driver or model.
>
> So I would like to synthesise the possible driver/model
combinations
> from the available source files at the time of running
rake.
>
> I think I should be able to do this via :
>
> Task.new(task_name,app)
> and
> the .enhance(deps) method.
>
> within a nested look of the available models and
drivers. However, I'm
> not sure how to find the correct application name,
since
>
> DRIVERS.each do |d|
> MODELS.each do |m|
>
Task.new("#_#",Rake.application())
> end
> end
>
> puts Task.tasks()
I haven't had a chance to look at this in detail, but I
always use the
standard task definition methods for my dynamically
generated tasks.
Try this:
DRIVERS.each do |d|
MODELS.each do |m|
task "#_#"
end
end
-- Jim Weirich
_______________________________________________
Rake-devel mailing list
Rake-devel rubyforge.org
http
://rubyforge.org/mailman/listinfo/rake-devel
|
|
| Generating File Tasks |

|
2006-12-03 01:00:29 |
...It really didn't occur to me I could have it as simply as
that.
*shakes his head*
That would have saved me so much exasperation on friday.
*blush*
It seems to work just perfectly though, so thank you!
Jonathan
_______________________________________________
Rake-devel mailing list
Rake-devel rubyforge.org
http
://rubyforge.org/mailman/listinfo/rake-devel
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|