Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e900e74342 | ||
|
|
62ae3f162d | ||
|
|
099d26f33c | ||
|
|
89562c584a | ||
|
|
a9aeaf2356 | ||
|
|
5409b3cb34 | ||
|
|
6d04500c13 | ||
|
|
45e30662d2 | ||
|
|
8f7e044bfd |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
rscons (1.12.0)
|
||||
rscons (1.13.0)
|
||||
json (~> 1.0)
|
||||
|
||||
GEM
|
||||
|
||||
@@ -564,6 +564,22 @@ http://www.rubydoc.info/github/holtrop/rscons/master.
|
||||
|
||||
## Release Notes
|
||||
|
||||
### v1.14.0
|
||||
|
||||
#### New Features
|
||||
|
||||
- #45 - Add Rscons::VarSet#values_at
|
||||
|
||||
#### Fixes
|
||||
|
||||
- #44 - Environment#print_builder_run_message should support string commands
|
||||
|
||||
### v1.13.0
|
||||
|
||||
#### New Features
|
||||
|
||||
- #43 - Add ability to record side-effect file production
|
||||
|
||||
### v1.12.0
|
||||
|
||||
#### New Features
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.echo = :command
|
||||
env.Install("inst.exe", "install.rb")
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class MyBuilder < Rscons::Builder
|
||||
def run(options)
|
||||
env, target = options.values_at(:env, :target)
|
||||
env.print_builder_run_message("MyBuilder #{target}", "MyBuilder #{target} command")
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.echo = :command
|
||||
env.add_builder(MyBuilder.new)
|
||||
env.MyBuilder("foo")
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["build_root"] = env.build_root
|
||||
env["inc_h"] = "inc.h"
|
||||
|
||||
env.Copy("copy_inc.h", "${inc_h}")
|
||||
env.depends("${build_root}/program.o", "${inc_h}")
|
||||
env.Program("program.exe", ["program.c", "inc.c"])
|
||||
|
||||
env.Command("inc.c",
|
||||
[],
|
||||
"CMD" => %w[ruby gen.rb ${_TARGET}],
|
||||
"CMD_DESC" => "Generating")
|
||||
env.produces("inc.c", "inc.h")
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
module Rscons
|
||||
# Module to contain logic to write ANSI color escape codes.
|
||||
module Ansi
|
||||
class << self
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ module Rscons
|
||||
# @param env [Environment] The Environment executing the builder.
|
||||
# @param cache [Cache] The Cache object.
|
||||
# @param options [Hash] Options.
|
||||
# @options options [String] :stdout
|
||||
# @option options [String] :stdout
|
||||
# File name to redirect standard output to.
|
||||
#
|
||||
# @return [String,ThreadedCommand]
|
||||
|
||||
@@ -20,8 +20,7 @@ module Rscons
|
||||
Ansi.write($stderr, :red, "Error: `#{target}' already exists and is not a directory", :reset, "\n")
|
||||
false
|
||||
else
|
||||
desc = "Directory #{target}"
|
||||
env.print_builder_run_message(desc, desc)
|
||||
env.print_builder_run_message("Directory #{target}", nil)
|
||||
cache.mkdir_p(target)
|
||||
target
|
||||
end
|
||||
|
||||
@@ -43,8 +43,7 @@ module Rscons
|
||||
# Check the cache and copy if necessary
|
||||
unless cache.up_to_date?(dest, :Copy, [src], env)
|
||||
unless printed_message
|
||||
desc = "#{name} #{target}"
|
||||
env.print_builder_run_message(desc, desc)
|
||||
env.print_builder_run_message("#{name} #{target}", nil)
|
||||
printed_message = true
|
||||
end
|
||||
cache.mkdir_p(File.dirname(dest))
|
||||
|
||||
@@ -45,8 +45,9 @@ module Rscons
|
||||
def initialize(options = {})
|
||||
@threaded_commands = Set.new
|
||||
@registered_build_dependencies = {}
|
||||
@side_effects = {}
|
||||
@varset = VarSet.new
|
||||
@job_set = JobSet.new(@registered_build_dependencies)
|
||||
@job_set = JobSet.new(@registered_build_dependencies, @side_effects)
|
||||
@user_deps = {}
|
||||
@builders = {}
|
||||
@build_dirs = []
|
||||
@@ -502,6 +503,26 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Manually record the given side effect file(s) as being produced when the
|
||||
# named target is produced.
|
||||
#
|
||||
# @since 1.13.0
|
||||
#
|
||||
# @param target [String]
|
||||
# Target of a build operation.
|
||||
# @param side_effects [Array<String>]
|
||||
# File(s) produced when the target file is produced.
|
||||
#
|
||||
# @return [void]
|
||||
def produces(target, *side_effects)
|
||||
target = expand_path(expand_varref(target))
|
||||
side_effects = Array(side_effects).map do |side_effect|
|
||||
expand_path(expand_varref(side_effect))
|
||||
end.flatten
|
||||
@side_effects[target] ||= []
|
||||
@side_effects[target] += side_effects
|
||||
end
|
||||
|
||||
# Return the list of user dependencies for a given target.
|
||||
#
|
||||
# @param target [String] Target file name.
|
||||
@@ -864,7 +885,13 @@ module Rscons
|
||||
def print_builder_run_message(short_description, command)
|
||||
case @echo
|
||||
when :command
|
||||
message = command_to_s(command) if command
|
||||
if command.is_a?(Array)
|
||||
message = command_to_s(command)
|
||||
elsif command.is_a?(String)
|
||||
message = command
|
||||
elsif short_description.is_a?(String)
|
||||
message = short_description
|
||||
end
|
||||
when :short
|
||||
message = short_description if short_description
|
||||
end
|
||||
|
||||
+13
-10
@@ -9,9 +9,14 @@ module Rscons
|
||||
# @param build_dependencies [Hash]
|
||||
# Hash mapping targets to a set of build dependencies. A job will not be
|
||||
# returned as ready to run if any of its dependencies are still building.
|
||||
def initialize(build_dependencies)
|
||||
# @param side_effects [Hash]
|
||||
# Hash mapping targets to a set of side-effect files. A job will not be
|
||||
# returned as ready to run if any of its dependencies is a side-effect
|
||||
# of another target that has not yet been built.
|
||||
def initialize(build_dependencies, side_effects)
|
||||
@jobs = {}
|
||||
@build_dependencies = build_dependencies
|
||||
@side_effects = side_effects
|
||||
end
|
||||
|
||||
# Add a job to the JobSet.
|
||||
@@ -47,18 +52,16 @@ module Rscons
|
||||
# @return [nil, Hash]
|
||||
# The next job to run.
|
||||
def get_next_job_to_run(targets_still_building)
|
||||
targets_not_built_yet = targets_still_building + @jobs.keys
|
||||
side_effects = targets_not_built_yet.map do |target|
|
||||
@side_effects[target] || []
|
||||
end.flatten
|
||||
targets_not_built_yet += side_effects
|
||||
|
||||
@jobs.keys.each do |target|
|
||||
skip = false
|
||||
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
||||
if @jobs.include?(src)
|
||||
# Skip this target because it depends on another target not yet
|
||||
# built.
|
||||
skip = true
|
||||
break
|
||||
end
|
||||
if targets_still_building.include?(src)
|
||||
# Skip this target because it depends on another target that is
|
||||
# currently being built.
|
||||
if targets_not_built_yet.include?(src)
|
||||
skip = true
|
||||
break
|
||||
end
|
||||
|
||||
@@ -143,6 +143,19 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Return an array containing the values associated with the given keys.
|
||||
#
|
||||
# @param keys [Array<String, Symbol>]
|
||||
# Keys to look up in the VarSet.
|
||||
#
|
||||
# @return [Array]
|
||||
# An array containing the values associated with the given keys.
|
||||
def values_at(*keys)
|
||||
keys.map do |key|
|
||||
self[key]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Move all VarSet variables into the copy-on-access list.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# gem version
|
||||
VERSION = "1.12.0"
|
||||
VERSION = "1.14.0"
|
||||
end
|
||||
@@ -769,6 +769,22 @@ EOF
|
||||
expect(lines(result.stdout)).to eq ["165"]
|
||||
end
|
||||
|
||||
it "prints a builder's short description with 'command' echo mode if there is no command" do
|
||||
test_dir("build_dir")
|
||||
|
||||
result = run_test(rsconsfile: "echo_command_ruby_builder.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(lines(result.stdout)).to eq ["Install inst.exe"]
|
||||
end
|
||||
|
||||
it "supports a string for a builder's echoed 'command' with Environment#print_builder_run_message" do
|
||||
test_dir("build_dir")
|
||||
|
||||
result = run_test(rsconsfile: "echo_command_string.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(lines(result.stdout)).to eq ["MyBuilder foo command"]
|
||||
end
|
||||
|
||||
context "colored output" do
|
||||
it "does not output in color with --color=off" do
|
||||
test_dir("simple")
|
||||
@@ -1306,6 +1322,13 @@ EOF
|
||||
result = run_test(rsconsfile: "build_after.rb", rscons_args: %w[-j 4])
|
||||
expect(result.stderr).to eq ""
|
||||
end
|
||||
|
||||
it "allows the user to specify side-effect files produced by another builder" do
|
||||
test_dir("custom_builder")
|
||||
result = run_test(rsconsfile: "produces.rb", rscons_args: %w[-j 4])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(File.exists?("copy_inc.h")).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "CLI" do
|
||||
|
||||
@@ -199,5 +199,14 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values_at" do
|
||||
it "returns an array of the values associated with the given keys" do
|
||||
v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
|
||||
"qax" => [3, 6], "qux" => {a: :b}})
|
||||
expect(v.values_at).to eq []
|
||||
expect(v.values_at(*%w[fuz qux qax])).to eq ["a string", {a: :b}, [3, 6]]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user