add Rscons.clear() class method
This commit is contained in:
parent
983cb7cf21
commit
770a22250a
@ -22,4 +22,13 @@ module Rscons
|
||||
|
||||
class BuildError < Exception
|
||||
end
|
||||
|
||||
# Remove all generated files
|
||||
def self.clean
|
||||
cache = Cache.new
|
||||
cache.targets.each do |target|
|
||||
FileUtils.rm_f(target)
|
||||
end
|
||||
Cache.clear
|
||||
end
|
||||
end
|
||||
|
@ -132,6 +132,11 @@ module Rscons
|
||||
}
|
||||
end
|
||||
|
||||
# Return a list of targets that have been built
|
||||
def targets
|
||||
@cache[:targets].keys
|
||||
end
|
||||
|
||||
# Private Instance Methods
|
||||
private
|
||||
|
||||
|
@ -120,6 +120,17 @@ describe Rscons do
|
||||
File.exists?('build/two/two.o').should be_true
|
||||
end
|
||||
|
||||
it 'cleans built files' do
|
||||
lines = test_dir('build_dir')
|
||||
`./build_dir`.should == "Hello from two()\n"
|
||||
File.exists?('build/one/one.o').should be_true
|
||||
File.exists?('build/two/two.o').should be_true
|
||||
Rscons.clean
|
||||
File.exists?('build/one/one.o').should be_false
|
||||
File.exists?('build/two/two.o').should be_false
|
||||
File.exists?('src/one/one.c').should be_true
|
||||
end
|
||||
|
||||
it 'allows Ruby classes as custom builders to be used to construct files' do
|
||||
lines = test_dir('custom_builder')
|
||||
lines.should == ['CC program.o', 'LD program']
|
||||
|
Loading…
x
Reference in New Issue
Block a user