Begin on Program builder

monkey-patch String class for suffix checking/changing methods
This commit is contained in:
josh committed 2013-06-30 20:09:43 -04:00
1 parent 6cfba1c2fe
commit 12d94997dc
2 files changed
+25

No files matched your search

+15
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
+10
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