knpwrs
knpwrs

Reputation: 16466

Rake -- Watch for Changes

Is there a way using Rake to watch depedencies for changes and execute tasks automatically?

For example, given the following Rakefile:

file 'main.o' => ["main.c", "greet.h"] do
  sh "cc -c -o main.o main.c"
end

file 'greet.o' => ['greet.c'] do
  sh "cc -c -o greet.o greet.c"
end

file "hello" => ["main.o", "greet.o"] do
  sh "cc -o hello main.o greet.o"
end

It would be great if when I changed greet.c or main.c then hello would automatically execute.

Upvotes: 2

Views: 2554

Answers (2)

Mohan Sandesh
Mohan Sandesh

Reputation: 46

There is also rerun https://github.com/alexch/rerun. You can do rerun rake to watch and run the default task.

Upvotes: 0

Antoine Toulme
Antoine Toulme

Reputation: 974

AFAIK rake doesn't support watching files and directories with a continuous compilation approach.

The buildr project implements a continuous compilation task for java which you can get inspired by to do the job for your project.

Also, it looks like guard might help there. See the guard github profile for implementations using guard. There's even a Rake extension to do what you want!

Upvotes: 2

Related Questions