Class: Rscons::Application
- Inherits:
-
Object
- Object
- Rscons::Application
- Defined in:
- lib/rscons/application.rb
Overview
Functionality for an instance of the rscons application invocation.
Instance 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.
-
#verbose ⇒ Boolean
Whether to run verbosely.
Instance Method Summary collapse
-
#get_next_build_step ⇒ Object
private
Get the next build step number.
-
#get_total_build_steps ⇒ Integer
Get the total number of build steps.
-
#initialize ⇒ Application
constructor
Create Application instance.
-
#operation(op) ⇒ Boolean
Check whether a requested operation is active.
-
#run(operation, script, operation_options, options = {}) ⇒ Integer
Run the specified operation.
Constructor Details
#initialize ⇒ Application
Create Application instance.
25 26 27 28 29 30 |
# File 'lib/rscons/application.rb', line 25 def initialize @n_threads = Util.determine_n_threads @vars = VarSet.new @operations = Set.new @build_step = 0 end |
Instance Attribute Details
#do_ansi_color ⇒ Boolean
Returns Whether to output ANSI color escape sequences.
10 11 12 |
# File 'lib/rscons/application.rb', line 10 def do_ansi_color @do_ansi_color end |
#n_threads ⇒ Integer
Returns The number of threads to use when scheduling subprocesses.
14 15 16 |
# File 'lib/rscons/application.rb', line 14 def n_threads @n_threads end |
#vars ⇒ VarSet (readonly)
Returns Access any variables set on the rscons command-line.
22 23 24 |
# File 'lib/rscons/application.rb', line 22 def vars @vars end |
#verbose ⇒ Boolean
Returns Whether to run verbosely.
18 19 20 |
# File 'lib/rscons/application.rb', line 18 def verbose @verbose end |
Instance Method Details
#get_next_build_step ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the next build step number.
This is used internally by the Environment class.
106 107 108 |
# File 'lib/rscons/application.rb', line 106 def get_next_build_step @build_step += 1 end |
#get_total_build_steps ⇒ Integer
Get the total number of build steps.
114 115 116 117 118 |
# File 'lib/rscons/application.rb', line 114 def get_total_build_steps Environment.environments.reduce(@build_step) do |result, env| result + env.build_steps_remaining end end |
#operation(op) ⇒ Boolean
Check whether a requested operation is active.
39 40 41 |
# File 'lib/rscons/application.rb', line 39 def operation(op) @operations.include?(op) end |
#run(operation, script, operation_options, options = {}) ⇒ Integer
Run the specified operation.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rscons/application.rb', line 58 def run(operation, script, , = {}) @start_time = Time.new @script = script @operations << operation puts "Starting '#{operation}' at #{Time.new}" if verbose rv = case operation when "build" rv = 0 unless Cache.instance["configuration_data"]["configured"] rv = if @script.autoconf run("configure", script, , sub_op: false) else $stderr.puts "Project must be configured first, and autoconf is disabled" 1 end end if rv == 0 build() end when "clean" clean when "configure" configure() when "distclean" distclean when "install" run("build", script, , sub_op: false) when "uninstall" uninstall else $stderr.puts "Unknown operation: #{operation}" 1 end if verbose and [:sub_op].nil? time = Time.new elapsed = time - @start_time puts "'#{operation}' complete at #{time} (#{Util.format_elapsed_time(elapsed)})" end rv end |