Begin on Program builder
monkey-patch String class for suffix checking/changing methods
This commit is contained in:
parent
6cfba1c2fe
commit
12d94997dc
@ -1,4 +1,19 @@
|
|||||||
module Rscons
|
module Rscons
|
||||||
class Program < Builder
|
class Program < Builder
|
||||||
|
def default_variables
|
||||||
|
{
|
||||||
|
'CC' => 'gcc',
|
||||||
|
'CFLAGS' => [],
|
||||||
|
'CPPFLAGS' => [],
|
||||||
|
'OBJSUFFIX' => '.o',
|
||||||
|
'CSUFFIX' => '.c',
|
||||||
|
'CCDEPGEN' => ['-MMD', '-MF', '$DEPFILE'],
|
||||||
|
'CCCOM' => ['$CC', '-c', '-o', '$TARGET', '$CCDEPGEN', '$CPPFLAGS', '$CFLAGS', '$SOURCES']
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def produces?(target, source)
|
||||||
|
target.has_suffix?(@env['OBJSUFFIX']) and source.has_suffix?(@env['CSUFFIX'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
10
lib/rscons/monkey/string.rb
Normal file
10
lib/rscons/monkey/string.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class String
|
||||||
|
def has_suffix?(suffix)
|
||||||
|
suffix = [suffix] if suffix.is_a?(String)
|
||||||
|
suffix.find {|s| self =~ /#{s}$/}
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_suffix(suffix = '')
|
||||||
|
sub(/\.[^.]*$/, suffix)
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user