Module: Rscons
- Defined in:
- lib/rscons.rb,
lib/rscons/cli.rb,
lib/rscons/ansi.rb,
lib/rscons/util.rb,
lib/rscons/cache.rb,
lib/rscons/varset.rb,
lib/rscons/builder.rb,
lib/rscons/job_set.rb,
lib/rscons/version.rb,
lib/rscons/environment.rb,
lib/rscons/build_target.rb,
lib/rscons/builders/cfile.rb,
lib/rscons/builders/object.rb,
lib/rscons/builders/command.rb,
lib/rscons/builders/install.rb,
lib/rscons/builders/library.rb,
lib/rscons/builders/program.rb,
lib/rscons/threaded_command.rb,
lib/rscons/builders/directory.rb,
lib/rscons/builders/preprocess.rb,
lib/rscons/builders/disassemble.rb,
lib/rscons/builders/shared_object.rb,
lib/rscons/builders/shared_library.rb,
lib/rscons/builders/simple_builder.rb
Overview
Namespace module for rscons classes
Defined Under Namespace
Modules: Ansi, Builders, Cli, Util Classes: BuildError, BuildTarget, Builder, Cache, Environment, JobSet, ThreadedCommand, VarSet
Constant Summary collapse
- DEFAULT_BUILDERS =
Names of the default builders which will be added to all newly created Environment objects.
[ :CFile, :Command, :Copy, :Directory, :Disassemble, :Install, :Library, :Object, :Preprocess, :Program, :SharedLibrary, :SharedObject, ]
- VERSION =
gem version
"1.19.1"
Class Attribute Summary collapse
-
.do_ansi_color ⇒ Boolean
Whether to output ANSI color escape sequences.
-
.n_threads ⇒ Integer
The number of threads to use when scheduling subprocesses.
-
.vars ⇒ VarSet
readonly
Access any variables set on the rscons command-line.
Class Method Summary collapse
-
.absolute_path?(path) ⇒ Boolean
Return whether the given path is an absolute filesystem path.
-
.clean ⇒ void
Remove all generated files.
-
.command_executer ⇒ Array<String>
Return an Array containing a command used to execute commands.
-
.command_executer=(val) ⇒ Array<String>
Set the command executer array.
-
.get_system_shell ⇒ Array<String>
Return the system shell and arguments for executing a shell command.
-
.glob(*patterns) ⇒ Array<String>
Return a list of paths matching the specified pattern(s).
-
.phony_target?(target) ⇒ Boolean
Return whether the given target is a phony target.
-
.set_suffix(path, suffix) ⇒ String
Return a new path by changing the suffix in path to suffix.
Class Attribute Details
.do_ansi_color ⇒ Boolean
Returns Whether to output ANSI color escape sequences.
57 58 59 |
# File 'lib/rscons.rb', line 57 def do_ansi_color @do_ansi_color end |
.n_threads ⇒ Integer
Returns The number of threads to use when scheduling subprocesses.
53 54 55 |
# File 'lib/rscons.rb', line 53 def n_threads @n_threads end |
.vars ⇒ VarSet (readonly)
Returns Access any variables set on the rscons command-line.
62 63 64 |
# File 'lib/rscons.rb', line 62 def vars @vars end |
Class Method Details
.absolute_path?(path) ⇒ Boolean
Return whether the given path is an absolute filesystem path.
88 89 90 91 92 93 94 |
# File 'lib/rscons.rb', line 88 def absolute_path?(path) if RUBY_PLATFORM =~ /mingw/ path =~ %r{^(?:\w:)?[\\/]} else path.start_with?("/") end end |
.clean ⇒ void
This method returns an undefined value.
Remove all generated files.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rscons.rb', line 67 def clean cache = Cache.instance # remove all built files cache.targets.each do |target| FileUtils.rm_f(target) end # remove all created directories if they are empty cache.directories.sort {|a, b| b.size <=> a.size}.each do |directory| next unless File.directory?(directory) if (Dir.entries(directory) - ['.', '..']).empty? Dir.rmdir(directory) rescue nil end end cache.clear end |
.command_executer ⇒ Array<String>
Return an Array containing a command used to execute commands.
This will normally be an empty Array, but on Windows if Rscons detects that it is running in MSYS then [“env”] will be returned.
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rscons.rb', line 151 def command_executer @command_executer ||= if Object.const_get("RUBY_PLATFORM") =~ /mingw/ if ENV.keys.find {|key| key =~ /MSYS/} begin if IO.popen(["env", "echo", "success"]) {|io| io.read.strip} == "success" ["env"] end rescue end end end || [] end |
.command_executer=(val) ⇒ Array<String>
Set the command executer array.
170 171 172 |
# File 'lib/rscons.rb', line 170 def command_executer=(val) @command_executer = val end |
.get_system_shell ⇒ Array<String>
Return the system shell and arguments for executing a shell command.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/rscons.rb', line 118 def get_system_shell @shell ||= begin test_shell = lambda do |*args| begin "success" == IO.popen([*args, "echo success"]) do |io| io.read.strip end rescue false end end if ENV["SHELL"] and ENV["SHELL"] != "" and test_shell[ENV["SHELL"], "-c"] [ENV["SHELL"], "-c"] elsif Object.const_get("RUBY_PLATFORM") =~ /mingw/ if test_shell["sh", "-c"] # Using Rscons from MSYS should use MSYS's shell. ["sh", "-c"] else ["cmd", "/c"] end else ["sh", "-c"] end end end |
.glob(*patterns) ⇒ Array<String>
Return a list of paths matching the specified pattern(s).
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.
191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rscons.rb', line 191 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 |
.phony_target?(target) ⇒ Boolean
Return whether the given target is a phony target.
101 102 103 |
# File 'lib/rscons.rb', line 101 def phony_target?(target) target.is_a?(Symbol) end |
.set_suffix(path, suffix) ⇒ String
Return a new path by changing the suffix in path to suffix.
111 112 113 |
# File 'lib/rscons.rb', line 111 def set_suffix(path, suffix) path.sub(/\.[^.]*$/, "") + suffix end |