add Environment.execute(); implement first version of Program builder

This commit is contained in:
Josh Holtrop 2013-06-16 22:41:47 -04:00
parent 3b8763a424
commit 62e9bfa5d3
3 changed files with 22 additions and 3 deletions

View File

@ -7,7 +7,7 @@ module Rscons
'OBJSUFFIX' => '.o', 'OBJSUFFIX' => '.o',
} }
def run(env, sources) def run(env, target, sources)
end end
end end
end end

View File

@ -5,10 +5,20 @@ module Rscons
'OBJSUFFIX' => '.o', 'OBJSUFFIX' => '.o',
'LIBSUFFIX' => '.a', 'LIBSUFFIX' => '.a',
'LDFLAGS' => [], 'LDFLAGS' => [],
'LIBPATHS' => [],
'LIBS' => [], 'LIBS' => [],
} }
def run(env, sources) def run(env, target, sources)
command = [
env['LD'] || env['CC'],
'-o', target,
*env['LDFLAGS'],
*sources,
*env['LIBPATHS'].map {|lp| "-L#{lp}"},
*env['LIBS'].map {|lib| "-l#{lib}"}
]
env.execute("LINK #{target}", command)
end end
end end
end end

View File

@ -44,11 +44,20 @@ module Rscons
@build_dirs[src_dir] = build_dir @build_dirs[src_dir] = build_dir
end end
def execute(short_desc, command)
if @echo == :command
puts command.join(' ')
elsif @echo == :short
puts short_desc
end
system(*command)
end
def method_missing(method, *args) def method_missing(method, *args)
if @builders.has_key?(method.to_s) if @builders.has_key?(method.to_s)
# TODO: build sources if necessary # TODO: build sources if necessary
builder = @builders[method.to_s].new builder = @builders[method.to_s].new
builder.run(self, args.first) builder.run(self, *args)
end end
end end
end end