Begin on Program builder

monkey-patch String class for suffix checking/changing methods
This commit is contained in:
Josh Holtrop 2013-06-30 20:09:43 -04:00
parent 6cfba1c2fe
commit 12d94997dc
2 changed files with 25 additions and 0 deletions

View File

@ -1,4 +1,19 @@
module Rscons
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

View 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