lib/rscons.rb in rscons-1.15.0 vs lib/rscons.rb in rscons-1.16.0
- old
+ new
@@ -53,10 +53,15 @@
# @return [Boolean]
# Whether to output ANSI color escape sequences.
attr_accessor :do_ansi_color
+ # @since 1.16.0
+ # @return [VarSet]
+ # Access any variables set on the rscons command-line.
+ attr_reader :vars
+
# Remove all generated files.
#
# @return [void]
def clean
cache = Cache.instance
@@ -163,10 +168,39 @@
# @return [Array<String>] Command used to execute commands.
def command_executer=(val)
@command_executer = val
end
+ # Return a list of paths matching the specified pattern(s).
+ #
+ # @since 1.16.0
+ #
+ # A pattern can contain a "/**" component to recurse through directories.
+ # If the pattern ends with "/**" then only the recursive list of
+ # directories will be returned.
+ #
+ # Examples:
+ # - "src/**": return all directories under "src", recursively (including
+ # "src" itself).
+ # - "src/**/*": return all files and directories recursively under the src
+ # directory.
+ # - "src/**/*.c": return all .c files recursively under the src directory.
+ # - "dir/*/": return all directories in dir, but no files.
+ #
+ # @return [Array<String>] Paths matching the specified pattern(s).
+ def glob(*patterns)
+ require "pathname"
+ patterns.reduce([]) do |result, pattern|
+ if pattern.end_with?("/**")
+ pattern += "/"
+ end
+ result += Dir.glob(pattern).map do |path|
+ Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
+ end
+ end.sort
+ end
+
private
# Determine the number of threads to use by default.
#
# @return [Integer]
@@ -201,9 +235,10 @@
end
end
@n_threads = determine_n_threads
+ @vars = VarSet.new
end
# Unbuffer $stdout
$stdout.sync = true