aalavi
aalavi

Reputation: 63

Ruby ExtensionTask: How to make it dependent of another rake task?

I am writing a native C extension in Ruby 2.0 with Rake::ExtensionTask.new('NAME'). I need to make this dependent on another task that I define

task :myTask do |t|
....
end

My question is, how can I make this setup such that when I run rake compile, extension compilation/creation is dependent on completion of my defined task, ie, myTask?

I tried the following as well, but now I don't see 'compile' option when running rake -T:

task :myTask

task :extension_compile => [:myTask]
  Rake::ExtensionTask.new("NAME")
end

Upvotes: 1

Views: 1975

Answers (2)

Yossi
Yossi

Reputation: 12100

To add a dependency to an existing task you should use the hash notation as you did:

task :compile => [:myTask]

You don't see the :compile task when you run rake -T because rake only shows tasks that have a description:

desc "This is a compilation task"
task :compile

Now running rake -T will yield:

rake compile  # This is a compilation task

Upvotes: 5

megas
megas

Reputation: 21791

Your second snippet looks correct, just add the description to be able to see it in the rake list

desc "Here's your description"
task :extension_compile => [:myTask]
  Rake::ExtensionTask.new("NAME")
end

Upvotes: 1

Related Questions