create requisite output directories for build targets; refactor common buile functionality into Builder#standard_build()
This commit is contained in:
parent
17c7bf1d31
commit
f13664331f
@ -1,3 +1,5 @@
|
|||||||
|
require "fileutils"
|
||||||
|
|
||||||
module Rscons
|
module Rscons
|
||||||
# Class to hold an object that knows how to build a certain type of file.
|
# Class to hold an object that knows how to build a certain type of file.
|
||||||
class Builder
|
class Builder
|
||||||
@ -16,5 +18,18 @@ module Rscons
|
|||||||
def produces?(target, source, env)
|
def produces?(target, source, env)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check if the cache is up to date for the target and if not execute the
|
||||||
|
# build command.
|
||||||
|
# Return the name of the target or false on failure.
|
||||||
|
def standard_build(short_cmd_string, target, command, sources, env, cache)
|
||||||
|
unless cache.up_to_date?(target, command, sources)
|
||||||
|
FileUtils.mkdir_p(File.dirname(target))
|
||||||
|
FileUtils.rm_f(target)
|
||||||
|
return false unless env.execute(short_cmd_string, command)
|
||||||
|
cache.register_build(target, command, sources)
|
||||||
|
end
|
||||||
|
target
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,12 +21,7 @@ module Rscons
|
|||||||
'SOURCES' => objects,
|
'SOURCES' => objects,
|
||||||
})
|
})
|
||||||
command = env.build_command(env['ARCOM'], vars)
|
command = env.build_command(env['ARCOM'], vars)
|
||||||
unless cache.up_to_date?(target, command, objects)
|
standard_build("AR #{target}", target, command, objects, env, cache)
|
||||||
FileUtils.rm_f(target)
|
|
||||||
return false unless env.execute("AR #{target}", command)
|
|
||||||
cache.register_build(target, command, objects)
|
|
||||||
end
|
|
||||||
target
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -55,6 +55,8 @@ module Rscons
|
|||||||
end
|
end
|
||||||
command = env.build_command(env["#{com_prefix}COM"], vars)
|
command = env.build_command(env["#{com_prefix}COM"], vars)
|
||||||
unless cache.up_to_date?(target, command, sources)
|
unless cache.up_to_date?(target, command, sources)
|
||||||
|
FileUtils.mkdir_p(File.dirname(target))
|
||||||
|
FileUtils.rm_f(target)
|
||||||
return false unless env.execute("#{com_prefix} #{target}", command)
|
return false unless env.execute("#{com_prefix} #{target}", command)
|
||||||
deps = sources
|
deps = sources
|
||||||
if File.exists?(vars['DEPFILE'])
|
if File.exists?(vars['DEPFILE'])
|
||||||
|
@ -28,11 +28,7 @@ module Rscons
|
|||||||
'LD' => env['LD'] || ld_alt,
|
'LD' => env['LD'] || ld_alt,
|
||||||
})
|
})
|
||||||
command = env.build_command(env['LDCOM'], vars)
|
command = env.build_command(env['LDCOM'], vars)
|
||||||
unless cache.up_to_date?(target, command, objects)
|
standard_build("LD #{target}", target, command, objects, env, cache)
|
||||||
return false unless env.execute("LD #{target}", command)
|
|
||||||
cache.register_build(target, command, objects)
|
|
||||||
end
|
|
||||||
target
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user