J
Joe Van Dyk
rule '.o' =3D> ['.c'] do |t|
sh "cc #{t.source} -c -o #{t.name}"
end
But, when I change the .c source file, it doesn't get compiled again.=20
Why is that?
Example:
PowerBook:~/that_stuff/test1 joe$ ls
Rakefile another_test.h test.cpp
another_test.cpp main.cpp test.h
PowerBook:~/that_stuff/test1 joe$ cat Rakefile=20
require 'rake/clean'
CLEAN.include '*.o', 'test'
CPP_SOURCE =3D FileList['*.cpp']
OBJS =3D CPP_SOURCE.ext 'o'
task :default =3D> :run
task :run =3D> "test" do
sh "./test"
end
file "test" =3D> OBJS do
sh "g++ -o test #{OBJS}"
end
rule '.o' =3D> '.cpp' do |t|
sh "g++ -c -o #{t.name} #{t.source}"
end
CPP_SOURCE.each do |cpp|
headers =3D File.read(cpp).scan(/^#include "(.+)"/)
task cpp =3D> headers
end
PowerBook:~/that_stuff/test1 joe$ rake
(in /Users/joe/that_stuff/test1)
g++ -c -o another_test.o another_test.cpp
g++ -c -o main.o main.cpp
g++ -c -o test.o test.cpp
g++ -o test another_test.o main.o test.o
/test
Whassup
what's up!
PowerBook:~/that_stuff/test1 joe$ touch main.cpp
PowerBook:~/that_stuff/test1 joe$ rake
(in /Users/joe/that_stuff/test1)
/test
Whassup
what's up!
It should've recompiled main.cpp and relinked everything, right?
sh "cc #{t.source} -c -o #{t.name}"
end
But, when I change the .c source file, it doesn't get compiled again.=20
Why is that?
Example:
PowerBook:~/that_stuff/test1 joe$ ls
Rakefile another_test.h test.cpp
another_test.cpp main.cpp test.h
PowerBook:~/that_stuff/test1 joe$ cat Rakefile=20
require 'rake/clean'
CLEAN.include '*.o', 'test'
CPP_SOURCE =3D FileList['*.cpp']
OBJS =3D CPP_SOURCE.ext 'o'
task :default =3D> :run
task :run =3D> "test" do
sh "./test"
end
file "test" =3D> OBJS do
sh "g++ -o test #{OBJS}"
end
rule '.o' =3D> '.cpp' do |t|
sh "g++ -c -o #{t.name} #{t.source}"
end
CPP_SOURCE.each do |cpp|
headers =3D File.read(cpp).scan(/^#include "(.+)"/)
task cpp =3D> headers
end
PowerBook:~/that_stuff/test1 joe$ rake
(in /Users/joe/that_stuff/test1)
g++ -c -o another_test.o another_test.cpp
g++ -c -o main.o main.cpp
g++ -c -o test.o test.cpp
g++ -o test another_test.o main.o test.o
/test
Whassup
what's up!
PowerBook:~/that_stuff/test1 joe$ touch main.cpp
PowerBook:~/that_stuff/test1 joe$ rake
(in /Users/joe/that_stuff/test1)
/test
Whassup
what's up!
It should've recompiled main.cpp and relinked everything, right?