Compare commits

...
24 Commits
Author SHA1 Message Date
josh a2f72c6b87 v2.3.0 2021-12-04 09:43:03 -05:00
josh 7055cad73c Add v2.3.0 release notes 2021-12-04 09:27:24 -05:00
josh 4548f4e3c9 Document phony targets - close #141 2021-12-01 23:00:12 -05:00
josh 19dbab3426 Run subsidiary rscons binary from rscons() method if found - close #129 2021-11-28 22:36:24 -05:00
josh 69f5bea2b2 Fix specs for dependency file moving - #135 2021-11-28 15:10:25 -05:00
josh 2ee9dda49d Write dependency file to build directory when user invokes Object builder directly - close #135 2021-11-18 20:18:19 -05:00
josh f011b23499 Add PATH manipulation methods - close #126 2021-11-17 21:39:58 -05:00
josh 80d52f25b8 Document CMD_STDOUT variable for Command builder - close #134 2021-11-15 21:52:11 -05:00
josh 0face546e3 Clarify failed command error message indicating to run -F - close #133 2021-11-15 21:45:18 -05:00
josh ca747232cd Support passing a directory to rscons() method - close #128 2021-11-13 11:36:25 -05:00
josh a7b46093e9 Document -f command line option - close #130 2021-11-13 11:07:15 -05:00
josh 09892eed63 Add DEVELOPING.md 2021-11-07 21:09:42 -05:00
josh 117df43f64 Document rscons() build script method for subsidiary build scripts 2021-10-27 23:02:04 -04:00
josh acc12822b6 Add description for user_guide task 2021-10-27 22:42:31 -04:00
josh 8c7b43f60c Show a message when entering/leaving a subsidiary script directory 2021-10-22 16:48:44 -04:00
josh 7c8becc3f9 env.depends() does not work with build-root-relative "^/" paths - close #121 2021-10-22 16:03:10 -04:00
josh d1a35501ef Support subsidiary Rsconscript files - close #125 2021-10-22 13:58:38 -04:00
josh 28a245f0ab build_dist: Remove lines marked just for specs 2021-10-22 13:58:38 -04:00
josh 87a6d9f04f Do not run simplecov on dspec specs 2021-10-22 13:58:38 -04:00
josh 556c821cc6 Commonize error handling across all operations 2021-10-21 18:35:58 -04:00
josh 441fc9bc65 bundle update 2021-09-02 15:37:33 -04:00
josh 1861874f5c bundle update 2021-01-11 15:15:42 -05:00
dependabot[bot] 6d51c5cbde Bump redcarpet from 3.5.0 to 3.5.1
Bumps [redcarpet](https://github.com/vmg/redcarpet) from 3.5.0 to 3.5.1.
- [Release notes](https://github.com/vmg/redcarpet/releases)
- [Changelog](https://github.com/vmg/redcarpet/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vmg/redcarpet/compare/v3.5.0...v3.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 19:21:14 +00:00
josh 73af83803a add v2.2.0 release notes 2020-10-13 19:04:29 -04:00
30 changed files with 569 additions and 87 deletions

No files matched your search

+24
View File
@@ -1,3 +1,27 @@
## v2.3.0
### New Features
- #125 - Support subsidiary Rsconscript files
- #126 - Add PATH manipulation methods
### Fixes
- #121 - env.depends() does not work with built-root-relative "^/" paths
- #130 - Document -f command line option
- #133 - Clarify failed command error message indicating to run -F
- #134 - Document CMD_STDOUT variable for Command builder
- #135 - Write dependency file to build directory when user invokes Object builder directly
- #141 - Document phony targets
## v2.2.0
### New Features
- #120 - improve support for MSYS2
- #119 - add failure messages for failed configuration checks
- #118 - compiler checks should support cross-compilers and freestanding compilers
## v2.1.0
### New Features
+14
View File
@@ -0,0 +1,14 @@
# Developing
# Specs
To run the rscons specs, the following commands must be available:
* gcc
* clang
* g++
* clang++
* gdc
* ldc
* flex
* bison
+17 -17
View File
@@ -1,32 +1,32 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
diff-lcs (1.4.4)
docile (1.1.5)
json (2.3.0)
rake (13.0.1)
rdoc (6.2.1)
redcarpet (3.5.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.1)
json (2.5.1)
rake (13.0.6)
rdoc (6.3.2)
redcarpet (3.5.1)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
simplecov (0.15.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
syntax (1.2.2)
yard (0.9.24)
yard (0.9.26)
PLATFORMS
ruby
+7 -1
View File
@@ -17,12 +17,16 @@ task :build_dist do
end
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
ENV["specs"] = "1"
if args.example_string
ENV["partial_specs"] = "1"
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
end
end
task :spec => :build_dist
task :spec do
ENV.delete("specs")
end
# dspec task is useful to test the distributable release script, but is not
# useful for coverage information.
@@ -31,7 +35,7 @@ task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.mkdir_p("test")
FileUtils.cp("dist/rscons", "test/rscons.rb")
ENV["dist_specs"] = "1"
Rake::Task["spec"].invoke(args.example_string)
Rake::Task["spec"].execute(args.example_string)
ENV.delete("dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*"))
end
@@ -89,6 +93,7 @@ unless RbConfig::CONFIG["host"]["msys"]
yard.options = ["-ogen/yard"]
end
desc "Build user guide"
task :user_guide do
system("ruby", "-Ilib", "rb/gen_user_guide.rb")
end
@@ -99,6 +104,7 @@ task :default => :spec
task :all => [
:build_dist,
:spec,
:dspec,
:yard,
:user_guide,
]
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "foobar!"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
exit 42
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "flex!"
+10
View File
@@ -0,0 +1,10 @@
path_prepend "path_prepend"
path_append "path_append"
build do
Environment.new do |env|
system("flex")
system("foobar")
env.Object("simple.o", "simple.c")
end
end
@@ -0,0 +1,18 @@
class FileBuilder < Builder
def self.name
"File"
end
def run(options)
FileUtils.mkdir_p(File.dirname(@target))
File.binwrite(@target, ENV["file_contents"])
true
end
end
build do
Environment.new do |env|
env.add_builder(FileBuilder)
env.File("^/file.txt")
program = env.Program("^/simple.exe", Dir["*.c"])
env.depends("^/simple.exe", "^/file.txt")
end
end
+10
View File
@@ -0,0 +1,10 @@
configure do
rscons "sub/Rsconscript"
rscons "sub/Rsconscript2", "configure"
puts "top configure"
end
build do
rscons "sub/Rsconscript2", "build"
puts "top build"
end
+10
View File
@@ -0,0 +1,10 @@
configure do
rscons "sub"
rscons "sub", "-f", "Rsconscript2", "configure"
puts "top configure"
end
build do
rscons "sub", "-f", "Rsconscript2", "build"
puts "top build"
end
+9
View File
@@ -0,0 +1,9 @@
configure do
rscons "sub/Rsconscript_fail"
puts "top configure"
end
build do
rscons "sub/Rsconscript2", "build"
puts "top build"
end
@@ -0,0 +1,4 @@
build do
rscons "second", "build"
puts "top build"
end
+3
View File
@@ -0,0 +1,3 @@
build do
puts "second build"
end
+7
View File
@@ -0,0 +1,7 @@
configure do
puts "sub Rsconscript configure"
end
build do
puts "sub Rsconscript build"
end
+7
View File
@@ -0,0 +1,7 @@
configure do
puts "sub Rsconscript2 configure"
end
build do
puts "sub Rsconscript2 build"
end
@@ -0,0 +1,8 @@
configure do
puts "sub Rsconscript configure"
check_program "foobarfailure"
end
build do
puts "sub Rsconscript build"
end
+94 -2
View File
@@ -612,14 +612,26 @@ There are several default builders that are built-in to Rscons:
```ruby
env.Command(target, sources, "CMD" => command)
# Example
env.Command("docs.html", "docs.md",
env.Command("user_guide.html", "user_guide.md",
"CMD" => ["pandoc", "-fmarkdown", "-thtml", "-o${_TARGET}", "${_SOURCES}"],
"CMD_DESC" => "PANDOC")
"CMD_DESC" => "Generating user guide:")
```
The `Command` builder executes a user-defined command in order to produce the
desired target file based on the provided source files.
The `Command` builder supports the following construction variables:
* `CMD` (required) specifies the command to execute (an array of strings).
`CMD` is expanded for variable references, so the tokens `${_TARGET}` and
`${_SOURCES}` can be used, for example.
* `CMD_DESC` (optional) specifies the short text description to print when
the builder executes. The given description is followed by the target file
name.
* `CMD_STDOUT` (optional) specifies a file to redirect standard output to.
`CMD_STDOUT` is expanded for variable references, so the token `${_TARGET}`
can be used, for example.
####> The CFile Builder
```ruby
@@ -809,6 +821,22 @@ allows it to be used to create a shared library are added.
Although it can be called explicitly, it is more commonly implicitly called by
the `SharedLibrary` builder.
###> Phony Targets
rscons supports phony build targets.
Normally, a builder produces an output file, and executes whenever the input
files or command have changed.
A phony build target can be used to register a builder that does not produce
an output file.
A custom builder can take some action when the input files change even if it
does not produce an output file.
Such a builder could perform verification or run a test on its source files,
possibly failing if some conditions are not met.
It could also simply output something to the console, such as an analysis of
the source file, whenever it changes.
A phony target is signified by passing a Symbol instead of a String as the
first parameter (target) to a builder method.
###> Explicit Dependencies
A target can be marked as depending on another file that Rscons would not
@@ -872,6 +900,70 @@ In other words, build targets are not parallelized across a barrier.
env.barrier
```
##> Global Build Script Functionality
###> Using Subsidiary Build Scripts
The `rscons` build script method can be used to invoke an rscons subprocess to
perform an operation using a subsidiary rscons build script.
This can be used, for example, when a subproject is imported and a top-level
`configure` or `build` operation should also perform the same operation in the
subproject directory.
The first argument to the `rscons` method specifies either a directory name, or
the path to the subsidiary Rsconscript file to execute.
Any additional arguments are passed to `rscons` when it executes the subsidiary
script.
`rscons` will change working directories to the directory containing the
subsidiary script when executing it.
For example:
```ruby
configure do
rscons "subproject", "configure"
end
build do
rscons "subproject/Rsconscript", "build"
end
```
It is also perfectly valid to perform a different operation in the subsidiary
script from the one being performed in the top-level script.
For example, in a project that requires a particular cross compiler, the
top-level `configure` script could build the necessary cross compiler using a
subsidiary build script.
This could look something like:
```ruby
configure do
rscons "cross/Rsconscript"
check_c_compiler "i686-elf-gcc"
end
```
This would build, and if necessary first configure, using the cross/Rsconscript
subsidiary build script.
Subsidiary build scripts are executed from within the directory containing the
build script.
###> PATH Management
`rscons` provides methods for management of the `PATH` environment variable.
The `path_append` and `path_prepend` methods can be used to append or prepend
a path to the `PATH` environment variable.
```ruby
path_prepend "i686-elf-gcc/bin"
```
The `path_set` method sets the `PATH` environment variable to the given
Array or String.
The `path_components` method returns an Array of the components in the `PATH`
environment variable.
##> Extending Rscons
### Adding New Languages
+2 -2
View File
@@ -35,8 +35,8 @@ module Rscons
:SharedObject,
]
# Class to represent a fatal error while building a target.
class BuildError < RuntimeError; end
# Class to represent a fatal error during an Rscons operation.
class RsconsError < RuntimeError; end
class << self
+6 -3
View File
@@ -136,8 +136,8 @@ module Rscons
env.process
end
0
rescue BuildError => be
Ansi.write($stderr, :red, be.message, :reset, "\n")
rescue RsconsError => e
Ansi.write($stderr, :red, e.message, :reset, "\n")
1
end
end
@@ -193,7 +193,10 @@ module Rscons
co = ConfigureOp.new(options)
begin
@script.configure(co)
rescue ConfigureOp::ConfigureFailure
rescue RsconsError => e
if e.message and e.message != ""
$stderr.puts e.message
end
Ansi.write($stderr, :red, "Configuration failed", :reset, "\n")
rv = 1
end
+3 -3
View File
@@ -75,10 +75,10 @@ module Rscons
@vars["_SOURCES"] = @sources
depfilesuffix = @env.expand_varref("${DEPFILESUFFIX}", vars)
@vars["_DEPFILE"] =
if @vars[:direct]
@env.get_build_fname(target, depfilesuffix, self.class)
if @vars[:direct] || !@target.start_with?("#{@env.build_root}/")
@env.get_build_fname(@target, depfilesuffix, self.class)
else
"#{target}#{depfilesuffix}"
"#{@target}#{depfilesuffix}"
end
@cache.mkdir_p(File.dirname(@vars["_DEPFILE"]))
command = @env.build_command(@command_template, @vars)
+3 -5
View File
@@ -6,11 +6,13 @@ USAGE = <<EOF
Usage: #{$0} [global options] [operation] [operation options]
Global options:
-f FILE Use FILE as Rsconscript
-F, --show-failure Show failed command log from previous build and exit
--version Show rscons version and exit
-h, --help Show rscons help and exit
-j N, --nthreads=N Set number of threads (local default: #{Rscons.application.n_threads})
-r COLOR, --color=COLOR Set color mode (off, auto, force)
-v, --verbose Run verbosely
--version Show rscons version and exit
Operations:
configure Configure the project
@@ -23,10 +25,6 @@ Operations:
Configure options:
-b BUILD, --build=BUILD Set build directory (default: build)
--prefix=PREFIX Set installation prefix (default: /usr/local)
Build options:
-j N, --nthreads=N Set number of threads (local default: #{Rscons.application.n_threads})
EOF
module Rscons
+1 -4
View File
@@ -5,9 +5,6 @@ module Rscons
# Class to manage a configure operation.
class ConfigureOp
# Exception raised when a configuration error occurs.
class ConfigureFailure < Exception; end
# Create a ConfigureOp.
#
# @param options [Hash]
@@ -407,7 +404,7 @@ module Rscons
options[:on_fail].call
end
if should_fail
raise ConfigureFailure.new
raise RsconsError.new
end
end
end
+4 -4
View File
@@ -286,9 +286,9 @@ module Rscons
unless @process_failures.empty?
msg = @process_failures.join("\n")
if Cache.instance["failed_commands"].size > 0
msg += "\nUse -F to view the failed command log from the previous build operation"
msg += "\nUse `#{Util.command_to_execute_me} -F` to view the failed command log from the previous build operation"
end
raise BuildError.new(msg)
raise RsconsError.new(msg)
end
end
@@ -346,12 +346,12 @@ module Rscons
if target.is_a?(Builder)
target = target.target
end
target = expand_varref(target.to_s)
target = expand_path(expand_varref(target.to_s))
user_deps = user_deps.map do |ud|
if ud.is_a?(Builder)
ud = ud.target
end
expand_varref(ud)
expand_path(expand_varref(ud))
end
@user_deps[target] ||= []
@user_deps[target] = (@user_deps[target] + user_deps).uniq
+82 -3
View File
@@ -3,8 +3,87 @@ module Rscons
# The Script class encapsulates the state of a build script.
class Script
# DSL available to the Rsconscript.
class Dsl
# Global DSL methods.
class GlobalDsl
# Return path components from the PATH variable.
#
# @return [Array<String>]
# Path components from the PATH variable.
def path_components
ENV["PATH"].split(File::PATH_SEPARATOR)
end
# Prepend a path component to the PATH variable.
#
# @param path [String]
# Path to prepend.
#
# @return [void]
def path_prepend(path)
path_set([File.expand_path(path)] + path_components)
end
# Append a path component to the PATH variable.
#
# @param path [String]
# Path to append.
#
# @return [void]
def path_append(path)
path_set(path_components + [File.expand_path(path)])
end
# Set the PATH variable.
#
# @param new_path [String, Array<String>]
# New PATH variable value as an array or string.
#
# @return [void]
def path_set(new_path)
if new_path.is_a?(Array)
new_path = new_path.join(File::PATH_SEPARATOR)
end
ENV["PATH"] = new_path
end
# Invoke rscons in a subprocess for a subsidiary Rsconscript file.
#
# @param path [String]
# Path to subsidiary Rsconscript to execute, or path to subsidiary
# directory to run rscons in.
# @param args[Array<String>]
# Arguments to pass to rscons subprocess.
def rscons(path, *args)
rscons_path = File.expand_path($0)
path = File.expand_path(path)
if File.directory?(path)
command = [*args]
dir = path
else
command = ["-f", path, *args]
dir = File.dirname(path)
end
if File.exist?("#{dir}/rscons")
rscons_path = "#{dir}/rscons"
end
command = [rscons_path] + command
print_dir = dir != "." && dir != File.expand_path(Dir.pwd)
if ENV["specs"] and not ENV["dist_specs"] # specs
command = ["ruby", $LOAD_PATH.map {|p| ["-I", p]}, command].flatten # specs
end # specs
puts "rscons: Entering directory '#{dir}'" if print_dir
result = system(*command, chdir: dir)
puts "rscons: Leaving directory '#{dir}'" if print_dir
unless result
raise RsconsError.new("Failed command: " + command.join(" "))
end
end
end
# Top-level DSL available to the Rsconscript.
class Dsl < GlobalDsl
# Create a Dsl.
def initialize(script)
@script = script
@@ -59,7 +138,7 @@ module Rscons
end
# DSL available to the 'configure' block.
class ConfigureDsl
class ConfigureDsl < GlobalDsl
# Create a ConfigureDsl.
#
# @param configure_op [ConfigureOp]
+8
View File
@@ -217,6 +217,14 @@ module Rscons
queue.pop
end
# Command that can be run to execute this instance of rscons from the
# current working directory.
def command_to_execute_me
command = Pathname.new(File.expand_path($0)).relative_path_from(Dir.pwd).to_s
command = "./#{command}" unless command["/"]
command
end
private
# Check if a directory contains a certain executable.
+1 -1
View File
@@ -1,4 +1,4 @@
module Rscons
# Project version.
VERSION = "2.2.0"
VERSION = "2.3.0"
end
+6 -4
View File
@@ -44,7 +44,7 @@ combine_files[START_FILE]
# Strip Ruby comment lines and empty lines to save some space, but do not
# remove lines that are in heredoc sections. This isn't terribly robust to be
# used in the wild, but works for the heredoc instances for this project.
stripped_comments = []
stripped = []
heredoc_end = nil
combined_file.each do |line|
if line =~ /<<-?([A-Z]+)/
@@ -53,14 +53,16 @@ combined_file.each do |line|
if heredoc_end and line =~ /^\s*#{heredoc_end}/
heredoc_end = nil
end
if heredoc_end or not (line =~ /^\s*(#[^!].*)?$/)
stripped_comments << line
if line !~ /#\sspecs/
if heredoc_end or line !~ /^\s*(#[^!].*)?$/
stripped << line
end
end
end
require "zlib"
require "base64"
compressed_script = Zlib::Deflate.deflate(stripped_comments.join)
compressed_script = Zlib::Deflate.deflate(stripped.join)
encoded_compressed_script = Base64.encode64(compressed_script).gsub("\n", "")
hash = Digest::MD5.hexdigest(encoded_compressed_script)
+182 -18
View File
@@ -55,6 +55,8 @@ describe Rscons do
end
end
let(:passenv) {{}}
def test_dir(build_test_directory)
Dir.chdir(@owd)
rm_rf(@build_test_run_dir)
@@ -118,21 +120,23 @@ describe Rscons do
command_name = "#{command_prefix}#{@statics[:build_test_id]}"
File.open("_simplecov_setup.rb", "w") do |fh|
fh.puts <<EOF
require "bundler"
Bundler.setup
require "simplecov"
class MyFormatter
def format(*args)
unless ENV["dist_specs"]
require "bundler"
Bundler.setup
require "simplecov"
class MyFormatter
def format(*args)
end
end
end
SimpleCov.start do
root(#{@owd.inspect})
command_name(#{command_name.inspect})
filters.clear
add_filter do |src|
!(src.filename[SimpleCov.root])
SimpleCov.start do
root(#{@owd.inspect})
command_name(#{command_name.inspect})
filters.clear
add_filter do |src|
!(src.filename[SimpleCov.root])
end
formatter(MyFormatter)
end
formatter(MyFormatter)
end
# force color off
ENV["TERM"] = nil
@@ -145,6 +149,7 @@ EOF
stdout, stderr, status = nil, nil, nil
Bundler.with_unbundled_env do
env = ENV.to_h
env.merge!(passenv)
path = ["#{@build_test_run_dir}/_bin", "#{env["PATH"]}"]
if options[:path]
path = Array(options[:path]) + path
@@ -524,7 +529,7 @@ EOF
result = run_rscons
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{gcc -c -o one.o -MMD -MF one.o.mf -DONE one.c},
%r{gcc -c -o one.o -MMD -MF build/e.1/one.o.mf -DONE one.c},
%r{gcc -c -o build/e.1/two.c.o -MMD -MF build/e.1/two.c.o.mf two.c},
%r{gcc -o two_sources.exe one.o build/e.1/two.c.o},
])
@@ -564,8 +569,8 @@ EOF
result = run_rscons(rsconscript: "build_hooks_override_vars.rb")
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{gcc -c -o one.o -MMD -MF one.o.mf -Isrc -Isrc/one -Isrc/two -O1 src/two/two.c},
%r{gcc -c -o two.o -MMD -MF two.o.mf -Isrc -Isrc/one -Isrc/two -O2 src/two/two.c},
%r{gcc -c -o one.o -MMD -MF build/e.1/one.o.mf -Isrc -Isrc/one -Isrc/two -O1 src/two/two.c},
%r{gcc -c -o two.o -MMD -MF build/e.1/two.o.mf -Isrc -Isrc/one -Isrc/two -O2 src/two/two.c},
])
expect(File.exists?('one.o')).to be_truthy
expect(File.exists?('two.o')).to be_truthy
@@ -599,6 +604,27 @@ EOF
expect(result.stdout).to eq ""
end
it "rebuilds when user-specified dependencies using ^ change" do
test_dir("simple")
passenv["file_contents"] = "1"
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{Compiling simple.c},
%r{Linking .*simple.exe},
])
passenv["file_contents"] = "2"
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [%r{Linking .*simple.exe}])
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to eq ""
end
unless RUBY_PLATFORM =~ /mingw|msys/
it "supports building D sources with gdc" do
test_dir("d")
@@ -1040,7 +1066,7 @@ EOF
result = run_rscons
expect(result.stderr).to match /Failed to build/
expect(result.stderr).to match /^Use.*-F.*to view the failed command log/
expect(result.stderr).to match %r{^Use .*/rscons(\.rb)? -F.*to view the failed command log}
expect(result.status).to_not eq 0
result = run_rscons(rscons_args: %w[-F])
@@ -1449,6 +1475,25 @@ EOF
expect(result.status).to eq 0
end
it "allows prepending and appending to PATH" do
test_dir "simple"
result = run_rscons(rsconscript: "pathing.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to match /flex!/
expect(result.stdout).to match /foobar!/
expect(File.exist?("simple.o")).to be_truthy
end
it "writes the dependency file to the build root" do
test_dir "simple"
result = run_rscons(rsconscript: "distclean.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to match /Compiling simple\.c/
expect(File.exist?("simple.o")).to be_truthy
expect(File.exist?("simple.o.mf")).to be_falsey
expect(File.exist?("build/e.1/simple.o.mf")).to be_truthy
end
context "debugging" do
it "prints a message when the target does not exist" do
test_dir("simple")
@@ -1542,7 +1587,7 @@ EOF
result = run_rscons(rsconscript: "override_depfilesuffix.rb")
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{gcc -c -o simple.o -MMD -MF simple.o.deppy simple.c},
%r{gcc -c -o simple.o -MMD -MF build/e.1/simple.o.deppy simple.c},
])
end
@@ -2580,4 +2625,123 @@ EOF
end
end
context "with subsidiary scripts" do
context "with a script specified" do
it "executes the subsidiary script from configure block" do
test_dir "subsidiary"
result = run_rscons(op: %W[configure])
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{Entering directory '.*/sub'},
%r{sub Rsconscript configure},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub Rsconscript build},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub Rsconscript2 configure},
%r{Leaving directory '.*/sub'},
%r{top configure},
])
end
it "executes the subsidiary script from build block" do
test_dir "subsidiary"
result = run_rscons(op: %W[configure])
expect(result.stderr).to eq ""
result = run_rscons(op: %W[build])
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{sub Rsconscript2 build},
%r{top build},
])
end
end
context "with a directory specified" do
it "executes the subsidiary script from configure block" do
test_dir "subsidiary"
result = run_rscons(rsconscript: "Rsconscript_dir", op: %W[configure])
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{Entering directory '.*/sub'},
%r{sub Rsconscript configure},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub Rsconscript build},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub Rsconscript2 configure},
%r{Leaving directory '.*/sub'},
%r{top configure},
])
end
it "executes the subsidiary script from build block" do
test_dir "subsidiary"
result = run_rscons(rsconscript: "Rsconscript_dir", op: %W[configure])
expect(result.stderr).to eq ""
result = run_rscons(rsconscript: "Rsconscript_dir", op: %W[build])
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{sub Rsconscript2 build},
%r{top build},
])
end
end
context "with a rscons binary in the subsidiary script directory" do
it "executes rscons from the subsidiary script directory" do
test_dir "subsidiary"
File.binwrite("sub/rscons", <<EOF)
#!/usr/bin/env ruby
puts "sub rscons"
EOF
FileUtils.chmod(0755, "sub/rscons")
result = run_rscons(op: %W[configure])
expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [
%r{Entering directory '.*/sub'},
%r{sub rscons},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub rscons},
%r{Leaving directory '.*/sub'},
%r{Entering directory '.*/sub'},
%r{sub rscons},
%r{Leaving directory '.*/sub'},
%r{top configure},
])
end
end
it "does not print entering/leaving directory messages when the subsidiary script is in the same directory" do
test_dir "subsidiary"
result = run_rscons(rsconscript: "Rsconscript_samedir", op: %W[configure])
expect(result.stderr).to eq ""
result = run_rscons(rsconscript: "Rsconscript_samedir", op: %W[build])
expect(result.stderr).to eq ""
expect(result.stdout).to_not match(%{(Entering|Leaving) directory})
verify_lines(lines(result.stdout), [
%r{second build},
%r{top build},
])
end
it "terminates execution when a subsidiary script fails" do
test_dir "subsidiary"
result = run_rscons(rsconscript: "Rsconscript_fail", op: %W[configure])
expect(result.stderr).to_not eq ""
expect(result.status).to_not eq 0
expect(result.stdout).to_not match /top configure/
end
end
end
+20 -20
View File
@@ -1,25 +1,25 @@
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
add_filter "/.bundle/"
if ENV["partial_specs"]
command_name "RSpec-partial"
else
command_name "RSpec"
end
if ENV["dist_specs"]
add_filter "/bin/"
add_filter "/lib/"
else
add_filter "test/rscons.rb"
end
project_name "Rscons"
merge_timeout 3600
end
if ENV["dist_specs"]
require_relative "../test/rscons"
else
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
add_filter "/.bundle/"
if ENV["partial_specs"]
command_name "RSpec-partial"
else
command_name "RSpec"
end
if ENV["dist_specs"]
add_filter "/bin/"
add_filter "/lib/"
else
add_filter "test/rscons.rb"
end
project_name "Rscons"
merge_timeout 3600
end
require "rscons"
end