fully parallelize the Disassemble builder

This commit is contained in:
Josh Holtrop 2017-05-25 14:59:51 -04:00
parent a11fab43cb
commit 145d51c825
3 changed files with 25 additions and 21 deletions

View File

@ -2,6 +2,7 @@ module Rscons
module Builders
# The Disassemble builder produces a disassembly listing of a source file.
class Disassemble < Builder
# Return default construction variables for the builder.
#
# @param env [Environment] The Environment using the builder.
@ -28,13 +29,28 @@ module Rscons
def run(target, sources, cache, env, vars)
vars = vars.merge("_SOURCES" => sources)
command = env.build_command("${DISASM_CMD}", vars)
unless cache.up_to_date?(target, command, sources, env)
if cache.up_to_date?(target, command, sources, env)
target
else
cache.mkdir_p(File.dirname(target))
return false unless env.execute("Disassemble #{target}", command, options: {out: target})
cache.register_build(target, command, sources, env)
ThreadedCommand.new(
command,
short_description: "Disassemble #{target}",
system_options: {out: target})
end
target
end
# Finalize a build.
#
# @param options [Hash]
# Finalize options.
#
# @return [String, nil]
# The target name on success or nil on failure.
def finalize(options)
standard_finalize(options)
end
end
end
end

View File

@ -439,10 +439,15 @@ EOF
it "supports disassembling object files" do
test_dir("simple")
result = run_test(rsconsfile: "disassemble.rb")
expect(result.stderr).to eq ""
expect(File.exists?("simple.txt")).to be_truthy
expect(File.read("simple.txt")).to match /Disassembly of section .text:/
result = run_test(rsconsfile: "disassemble.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to eq ""
end
it "supports preprocessing C sources" do

View File

@ -1,17 +0,0 @@
module Rscons
module Builders
describe Disassemble do
let(:env) {Environment.new}
subject {Disassemble.new}
it "supports overriding DISASM_CMD construction variable" do
cache = "cache"
allow(cache).to receive(:up_to_date?) { false }
allow(cache).to receive(:mkdir_p) { }
allow(cache).to receive(:register_build) { }
expect(env).to receive(:execute).with("Disassemble a_file.txt", ["my_disasm", "a_file.exe"], anything).and_return(true)
subject.run("a_file.txt", ["a_file.exe"], cache, env, "DISASM_CMD" => ["my_disasm", "${_SOURCES}"])
end
end
end
end