Compare commits

...
14 Commits
11 changed files with 88 additions and 28 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
rscons (1.10.0) rscons (1.11.1)
json (~> 1.0) json (~> 1.0)
GEM GEM
+24 -10
View File
@@ -230,14 +230,15 @@ An Environment consists of:
* a collection of user-defined build targets * a collection of user-defined build targets
* a collection of user-defined build hooks * a collection of user-defined build hooks
When cloning an environment, by default the construction variables and builders When cloning an environment, by default the construction variables, builders,
are cloned, but the new environment does not inherit any of the targets, build build hooks, build directories, and build root are cloned, but the new
hooks, build directories, or the build root from the source environment. environment does not inherit any of the registered build targets.
The set of environment attributes that are cloned is controllable via the The set of environment attributes that are cloned is controllable via the
`:clone` option to the `#clone` method. `:clone` option to the `#clone` method.
For example, `env.clone(clone: :all)` will include construction variables, For example, `env.clone(clone: [:variables, :builders])` will include
builders, build hooks, build directories, and the build root. construction variables, and builders but not build hooks, build directories, or
the build root.
The set of pending targets is never cloned. The set of pending targets is never cloned.
@@ -455,16 +456,14 @@ construction variables can be overridden by the user.
| LIBSUFFIX | String/Array | Default static library file suffix | ".a" | | LIBSUFFIX | String/Array | Default static library file suffix | ".a" |
| OBJDUMP | String | Objdump executable | "objdump" | | OBJDUMP | String | Objdump executable | "objdump" |
| OBJSUFFIX | String/Array | Default object file suffix | ".o" | | OBJSUFFIX | String/Array | Default object file suffix | ".o" |
| This name will include variant components. |
| The user should not change this construction variable. | Determined at runtime. |
| PROGSUFFIX | String | Default program suffix. | Windows: ".exe", POSIX: "" | | PROGSUFFIX | String | Default program suffix. | Windows: ".exe", POSIX: "" |
| SHCC | String | Shared object C compiler | "${CC}" | | SHCC | String | Shared object C compiler | "${CC}" |
| SHCCCMD | Array | Shared object C compiler command line | ["${SHCC}", "-c", "-o", "${_TARGET}", "${CCDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] | | SHCCCMD | Array | Shared object C compiler command line | ["${SHCC}", "-c", "-o", "${_TARGET}", "${CCDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] |
| SHCCFLAGS | Array | Shared object C and C++ compiler flags | Windows: ["${CCFLAGS}"], POSIX: ["${CCFLAGS}", -fPIC"] | | SHCCFLAGS | Array | Shared object C and C++ compiler flags | Windows: ["${CCFLAGS}"], POSIX: ["${CCFLAGS}", -fPIC"] |
| SHCFLAGS | Array | Shared object C compiler flags | [] | | SHCFLAGS | Array | Shared object C compiler flags | ["${CFLAGS}"] |
| SHCXX | String | Shared object C++ compiler | "${CXX}" | | SHCXX | String | Shared object C++ compiler | "${CXX}" |
| SHCXXCMD | Array | Shared object C++ compiler command line | ["${SHCXX}", "-c", "-o", "${_TARGET}", "${CXXDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCXXFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] | | SHCXXCMD | Array | Shared object C++ compiler command line | ["${SHCXX}", "-c", "-o", "${_TARGET}", "${CXXDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCXXFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] |
| SHCXXFLAGS | Array | Shared object C++ compiler flags | [] | | SHCXXFLAGS | Array | Shared object C++ compiler flags | ["${CXXFLAGS}"] |
| SHDC | String | Shared object D compiler | "gdc" | | SHDC | String | Shared object D compiler | "gdc" |
| SHDCCMD | Array | Shared object D compiler command line | ["${SHDC}", "-c", "-o", "${_TARGET}", "${INCPREFIX}${D_IMPORT_PATH}", "${SHDFLAGS}", "${_SOURCES}"] | | SHDCCMD | Array | Shared object D compiler command line | ["${SHDC}", "-c", "-o", "${_TARGET}", "${INCPREFIX}${D_IMPORT_PATH}", "${SHDFLAGS}", "${_SOURCES}"] |
| SHDFLAGS | Array | Shared object D compiler flags | Windows: ["${DFLAGS}"], POSIX: ["${DFLAGS}", "-fPIC"] | | SHDFLAGS | Array | Shared object D compiler flags | Windows: ["${DFLAGS}"], POSIX: ["${DFLAGS}", "-fPIC"] |
@@ -561,10 +560,24 @@ env.depends("my_app", "config/link.ld", "README.txt", *Dir.glob("assets/**/*"))
### API documentation ### API documentation
Documentation for the complete Rscons API can be found at Documentation for the complete Rscons API can be found at
http://rubydoc.info/github/holtrop/rscons/frames. http://www.rubydoc.info/github/holtrop/rscons/master.
## Release Notes ## Release Notes
### v1.11.0
#### New Features
- Change default Environment :clone option to :all to clone all attributes
- #38 - raise error when circular dependencies are found
- #34 - Allow overriding n_threads on a per-Environment level
#### Fixes
- #35 - env.build_after should expand paths
- #36 - SHCFLAGS and SHCXXFLAGS should inherit non-SH flags by default
- #37 - Fix non-blocking thread-wait if Rscons.n_threads is set to 0
### v1.10.0 ### v1.10.0
#### New Features #### New Features
@@ -581,6 +594,7 @@ http://rubydoc.info/github/holtrop/rscons/frames.
- expand target and source paths before calling Builder#create_build_target - expand target and source paths before calling Builder#create_build_target
- #29 - fix PROGSUFFIX handling - #29 - fix PROGSUFFIX handling
- #32 - Pre-build hooks do not respect modified key values
### v1.9.3 ### v1.9.3
+1 -1
View File
@@ -10,6 +10,6 @@ env1 = Rscons::Environment.new(echo: :command) do |env|
env.Program('program.exe', Dir['src/*.c']) env.Program('program.exe', Dir['src/*.c'])
end end
env2 = env1.clone(clone: :all) do |env| env2 = env1.clone do |env|
env.Program('program2.exe', Dir['src/*.c']) env.Program('program2.exe', Dir['src/*.c'])
end end
+3 -1
View File
@@ -3,6 +3,8 @@ Rscons::Environment.new do |env|
[], [],
"CMD" => %w[ruby gen.rb ${_TARGET}], "CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating") "CMD_DESC" => "Generating")
env.build_after("#{env.build_root}/program.o", "inc.c") env["build_root"] = env.build_root
env["inc_c"] = "inc.c"
env.build_after("${build_root}/program.o", "${inc_c}")
env.Program("program.exe", ["program.c", "inc.c"]) env.Program("program.exe", ["program.c", "inc.c"])
end end
@@ -0,0 +1,5 @@
Rscons::Environment.new do |env|
env.Command("foo", "bar")
env.Command("bar", "baz")
env.Command("baz", "foo")
end
@@ -0,0 +1,3 @@
Rscons::Environment.new do |env|
env.Command("foo", "foo")
end
+2 -2
View File
@@ -24,11 +24,11 @@ module Rscons
'SHCCFLAGS' => ['${CCFLAGS}'] + pic_flags, 'SHCCFLAGS' => ['${CCFLAGS}'] + pic_flags,
'SHCC' => '${CC}', 'SHCC' => '${CC}',
'SHCFLAGS' => [], 'SHCFLAGS' => ['${CFLAGS}'],
'SHCCCMD' => ['${SHCC}', '-c', '-o', '${_TARGET}', '${CCDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'], 'SHCCCMD' => ['${SHCC}', '-c', '-o', '${_TARGET}', '${CCDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'],
'SHCXX' => '${CXX}', 'SHCXX' => '${CXX}',
'SHCXXFLAGS' => [], 'SHCXXFLAGS' => ['${CXXFLAGS}'],
'SHCXXCMD' => ['${SHCXX}', '-c', '-o', '${_TARGET}', '${CXXDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCXXFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'], 'SHCXXCMD' => ['${SHCXX}', '-c', '-o', '${_TARGET}', '${CXXDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCXXFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'],
'SHDC' => 'gdc', 'SHDC' => 'gdc',
+24 -7
View File
@@ -17,6 +17,11 @@ module Rscons
# @return [String] The build root. # @return [String] The build root.
attr_reader :build_root attr_reader :build_root
# @return [Integer]
# The number of threads to use for this Environment. If nil (the
# default), the global Rscons.n_threads default value will be used.
attr_writer :n_threads
# Set the build root. # Set the build root.
# #
# @param build_root [String] The build root. # @param build_root [String] The build root.
@@ -73,9 +78,9 @@ module Rscons
# following: # following:
# - :variables to clone construction variables (on by default) # - :variables to clone construction variables (on by default)
# - :builders to clone the builders (on by default) # - :builders to clone the builders (on by default)
# - :build_root to clone the build root (off by default) # - :build_root to clone the build root (on by default)
# - :build_dirs to clone the build directories (off by default) # - :build_dirs to clone the build directories (on by default)
# - :build_hooks to clone the build hooks (off by default) # - :build_hooks to clone the build hooks (on by default)
# #
# If a block is given, the Environment object is yielded to the block and # If a block is given, the Environment object is yielded to the block and
# when the block returns, the {#process} method is automatically called. # when the block returns, the {#process} method is automatically called.
@@ -84,7 +89,7 @@ module Rscons
# #
# @return [Environment] The newly created {Environment} object. # @return [Environment] The newly created {Environment} object.
def clone(options = {}) def clone(options = {})
clone = options[:clone] || Set[:variables, :builders] clone = options[:clone] || :all
clone = Set[:variables, :builders, :build_root, :build_dirs, :build_hooks] if clone == :all clone = Set[:variables, :builders, :build_root, :build_dirs, :build_hooks] if clone == :all
clone = Set[] if clone == :none clone = Set[] if clone == :none
clone = Set.new(clone) if clone.is_a?(Array) clone = Set.new(clone) if clone.is_a?(Array)
@@ -101,7 +106,7 @@ module Rscons
env.append(@varset) if clone.include?(:variables) env.append(@varset) if clone.include?(:variables)
env.build_root = @build_root if clone.include?(:build_root) env.build_root = @build_root if clone.include?(:build_root)
if clone.include?(:build_dirs) if clone.include?(:build_dirs)
@build_dirs.each do |src_dir, obj_dir| @build_dirs.reverse.each do |src_dir, obj_dir|
env.build_dir(src_dir, obj_dir) env.build_dir(src_dir, obj_dir)
end end
end end
@@ -222,7 +227,7 @@ module Rscons
if src_dir.is_a?(String) if src_dir.is_a?(String)
src_dir = src_dir.gsub("\\", "/").sub(%r{/*$}, "") src_dir = src_dir.gsub("\\", "/").sub(%r{/*$}, "")
end end
@build_dirs << [src_dir, obj_dir] @build_dirs.unshift([src_dir, obj_dir])
end end
# Return the file name to be built from +source_fname+ with suffix # Return the file name to be built from +source_fname+ with suffix
@@ -330,7 +335,8 @@ module Rscons
end end
# If needed, do a blocking wait. # If needed, do a blocking wait.
if (completed_tcs.empty? and job.nil?) or @threaded_commands.size >= Rscons.n_threads if (@threaded_commands.size > 0) and
((completed_tcs.empty? and job.nil?) or (@threaded_commands.size >= n_threads))
completed_tcs << wait_for_threaded_commands completed_tcs << wait_for_threaded_commands
end end
@@ -476,8 +482,10 @@ module Rscons
targets = Array(targets) targets = Array(targets)
prerequisites = Array(prerequisites) prerequisites = Array(prerequisites)
targets.each do |target| targets.each do |target|
target = expand_path(expand_varref(target))
@registered_build_dependencies[target] ||= Set.new @registered_build_dependencies[target] ||= Set.new
prerequisites.each do |prerequisite| prerequisites.each do |prerequisite|
prerequisite = expand_path(expand_varref(prerequisite))
@registered_build_dependencies[target] << prerequisite @registered_build_dependencies[target] << prerequisite
end end
end end
@@ -825,6 +833,15 @@ module Rscons
end end
end end
# Get the number of threads to use for parallelized builds in this
# Environment.
#
# @return [Integer]
# Number of threads to use for parallelized builds in this Environment.
def n_threads
@n_threads || Rscons.n_threads
end
private private
# Add a build target. # Add a build target.
+9 -4
View File
@@ -51,14 +51,14 @@ module Rscons
skip = false skip = false
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src| (@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
if @jobs.include?(src) if @jobs.include?(src)
# Skip this target because it depends on another target later in # Skip this target because it depends on another target not yet
# the job set. # built.
skip = true skip = true
break break
end end
if targets_still_building.include?(src) if targets_still_building.include?(src)
# Skip this target because it depends on another target that is # Skip this target because it depends on another target that is
# still being built. # currently being built.
skip = true skip = true
break break
end end
@@ -73,7 +73,12 @@ module Rscons
return job return job
end end
nil # If there is a job to run, and nothing is still building, but we did
# not find a job to run above, then there might be a circular dependency
# introduced by the user.
if (@jobs.size > 0) and targets_still_building.empty?
raise "Could not find a runnable job. Possible circular dependency for #{@jobs.keys.first}"
end
end end
# Remove all jobs from the JobSet. # Remove all jobs from the JobSet.
+1 -1
View File
@@ -1,4 +1,4 @@
module Rscons module Rscons
# gem version # gem version
VERSION = "1.10.0" VERSION = "1.11.1"
end end
+15 -1
View File
@@ -336,7 +336,7 @@ EOF
] ]
end end
it 'allows cloning all attributes of an Environment object' do it 'clones all attributes of an Environment object by default' do
test_dir('clone_env') test_dir('clone_env')
result = run_test(rsconsfile: "clone_all.rb") result = run_test(rsconsfile: "clone_all.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
@@ -732,6 +732,20 @@ EOF
expect(`./test-static.exe`).to match /Hi from one/ expect(`./test-static.exe`).to match /Hi from one/
end end
it "raises an error for a circular dependency" do
test_dir("simple")
result = run_test(rsconsfile: "error_circular_dependency.rb")
expect(result.stderr).to match /Possible circular dependency for (foo|bar|baz)/
expect(result.status).to_not eq 0
end
it "raises an error for a circular dependency where a build target contains itself in its source list" do
test_dir("simple")
result = run_test(rsconsfile: "error_circular_dependency2.rb")
expect(result.stderr).to match /Possible circular dependency for foo/
expect(result.status).to_not eq 0
end
context "backward compatibility" do context "backward compatibility" do
it "allows a builder to call Environment#run_builder in a non-threaded manner" do it "allows a builder to call Environment#run_builder in a non-threaded manner" do
test_dir("simple") test_dir("simple")