Remove "nop" builders; Install* builders always install
This commit is contained in:
parent
dbd764749b
commit
fc17a14008
@ -41,8 +41,6 @@ module Rscons
|
||||
# List of task(s) to execute.
|
||||
# @param options [Hash]
|
||||
# Optional parameters.
|
||||
# @option sub_op [Boolean]
|
||||
# Whether this operation is not the top-level operation.
|
||||
#
|
||||
# @return [Integer]
|
||||
# Process exit code (0 on success).
|
||||
|
@ -87,14 +87,6 @@ module Rscons
|
||||
self.class.name
|
||||
end
|
||||
|
||||
# Return whether the builder is a no-op.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether the builder is a no-op.
|
||||
def nop?
|
||||
false
|
||||
end
|
||||
|
||||
# Manually record a given build target as depending on the specified files.
|
||||
#
|
||||
# @param user_deps [Array<String>]
|
||||
|
@ -37,7 +37,7 @@ module Rscons
|
||||
# The number of remaining build steps.
|
||||
def build_steps_remaining
|
||||
self.reduce(0) do |result, (target, builders)|
|
||||
result + builders.select {|b| not b.nop?}.size
|
||||
result + builders.size
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -9,61 +9,48 @@ module Rscons
|
||||
def initialize(*args)
|
||||
super
|
||||
@install_builder = self.class.name == "Install"
|
||||
@nop = @install_builder && !Rscons.application.operation("install")
|
||||
end
|
||||
|
||||
# Return whether the builder is a no-op.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether the builder is a no-op.
|
||||
def nop?
|
||||
@nop
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
def run(options)
|
||||
if @nop
|
||||
true
|
||||
target_is_dir = (@sources.length > 1) ||
|
||||
Dir.exists?(@sources.first) ||
|
||||
Dir.exists?(@target)
|
||||
outdir = target_is_dir ? @target : File.dirname(@target)
|
||||
# Collect the list of files to copy over.
|
||||
file_map = {}
|
||||
if target_is_dir
|
||||
@sources.each do |src|
|
||||
if Dir.exists? src
|
||||
Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).select do |f|
|
||||
File.file?(f)
|
||||
end.each do |subfile|
|
||||
subpath = Pathname.new(subfile).relative_path_from(Pathname.new(src)).to_s
|
||||
file_map[subfile] = "#{outdir}/#{subpath}"
|
||||
end
|
||||
else
|
||||
file_map[src] = "#{outdir}/#{File.basename(src)}"
|
||||
end
|
||||
end
|
||||
else
|
||||
target_is_dir = (@sources.length > 1) ||
|
||||
Dir.exists?(@sources.first) ||
|
||||
Dir.exists?(@target)
|
||||
outdir = target_is_dir ? @target : File.dirname(@target)
|
||||
# Collect the list of files to copy over.
|
||||
file_map = {}
|
||||
if target_is_dir
|
||||
@sources.each do |src|
|
||||
if Dir.exists? src
|
||||
Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).select do |f|
|
||||
File.file?(f)
|
||||
end.each do |subfile|
|
||||
subpath = Pathname.new(subfile).relative_path_from(Pathname.new(src)).to_s
|
||||
file_map[subfile] = "#{outdir}/#{subpath}"
|
||||
end
|
||||
else
|
||||
file_map[src] = "#{outdir}/#{File.basename(src)}"
|
||||
end
|
||||
end
|
||||
else
|
||||
file_map[sources.first] = target
|
||||
end
|
||||
printed_message = false
|
||||
file_map.each do |src, dest|
|
||||
# Check the cache and copy if necessary
|
||||
unless @cache.up_to_date?(dest, :Copy, [src], @env)
|
||||
unless printed_message
|
||||
message = "#{name} <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>"
|
||||
print_run_message(message, nil)
|
||||
printed_message = true
|
||||
end
|
||||
@cache.mkdir_p(File.dirname(dest), install: @install_builder)
|
||||
FileUtils.rm_f(dest)
|
||||
FileUtils.cp(src, dest, :preserve => true)
|
||||
end
|
||||
@cache.register_build(dest, :Copy, [src], @env, install: @install_builder)
|
||||
end
|
||||
(target_is_dir ? Dir.exists?(@target) : File.exists?(@target)) ? true : false
|
||||
file_map[sources.first] = target
|
||||
end
|
||||
printed_message = false
|
||||
file_map.each do |src, dest|
|
||||
# Check the cache and copy if necessary
|
||||
unless @cache.up_to_date?(dest, :Copy, [src], @env)
|
||||
unless printed_message
|
||||
message = "#{name} <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>"
|
||||
print_run_message(message, nil)
|
||||
printed_message = true
|
||||
end
|
||||
@cache.mkdir_p(File.dirname(dest), install: @install_builder)
|
||||
FileUtils.rm_f(dest)
|
||||
FileUtils.cp(src, dest, :preserve => true)
|
||||
end
|
||||
@cache.register_build(dest, :Copy, [src], @env, install: @install_builder)
|
||||
end
|
||||
(target_is_dir ? Dir.exists?(@target) : File.exists?(@target)) ? true : false
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -8,32 +8,19 @@ module Rscons
|
||||
def initialize(*args)
|
||||
super
|
||||
@install_builder = self.class.name == "InstallDirectory"
|
||||
@nop = @install_builder && !Rscons.application.operation("install")
|
||||
end
|
||||
|
||||
# Return whether the builder is a no-op.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether the builder is a no-op.
|
||||
def nop?
|
||||
@nop
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
def run(options)
|
||||
if @nop
|
||||
if File.directory?(@target)
|
||||
true
|
||||
elsif File.exists?(@target)
|
||||
Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n")
|
||||
false
|
||||
else
|
||||
if File.directory?(@target)
|
||||
true
|
||||
elsif File.exists?(@target)
|
||||
Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n")
|
||||
false
|
||||
else
|
||||
print_run_message("Creating directory <target>#{@target}<reset>", nil)
|
||||
@cache.mkdir_p(@target, install: @install_builder)
|
||||
true
|
||||
end
|
||||
print_run_message("Creating directory <target>#{@target}<reset>", nil)
|
||||
@cache.mkdir_p(@target, install: @install_builder)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -586,9 +586,7 @@ module Rscons
|
||||
#
|
||||
# @return [void]
|
||||
def run_builder(builder)
|
||||
unless builder.nop?
|
||||
builder.build_step ||= Rscons.application.get_next_build_step
|
||||
end
|
||||
builder.build_step ||= Rscons.application.get_next_build_step
|
||||
case result = builder.run({})
|
||||
when Array
|
||||
result.each do |waititem|
|
||||
|
Loading…
x
Reference in New Issue
Block a user