class RBT::Make
Constants
- DEFAULT_RUN_ALREADY
#¶ ↑
DEFAULT_RUN_ALREADY
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( optional_commandline_arguments = ARGV, run_already = DEFAULT_RUN_ALREADY ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
By default run_already will be false, as we wish to let the user more easily decide at which point to .run() on this class.
Do note that this class can also be invoked via the following way:
Make.new { :run }
#¶ ↑
# File lib/rbt/make/make.rb, line 47 def initialize( optional_commandline_arguments = ARGV, run_already = DEFAULT_RUN_ALREADY ) register_sigint reset @run_already = run_already set_commandline_arguments( optional_commandline_arguments ) if block_given? yielded = yield handle_this_block(yielded) end run if @run_already end
Public Instance Methods
append_make_options(i)
click to toggle source
#¶ ↑
append_make_options
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 190 def append_make_options(i) # ======================================================================= # # Handle String input such as 'foo,bar' or 'foo;bar' next: # ======================================================================= # if i.is_a? String if i.include?(',') i = i.split(',') elsif i.include?(';') i = i.split(';') end end @make_options << i @make_options.flatten! end
Also aliased as: parameters_to_make, append_these_options, append_this_option_to_make, append_these_make_options
append_these_options?()
click to toggle source
#¶ ↑
append_these_options
?¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 222 def append_these_options? @make_options end
Also aliased as: make_options?
colourize_parser?()
click to toggle source
#¶ ↑
colourize_parser?¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 154 def colourize_parser? @colourize_parser end
Also aliased as: cparser?
commandline_arguments?()
click to toggle source
#¶ ↑
commandline_arguments?¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 161 def commandline_arguments? @commandline_arguments end
Also aliased as: input?
determine_which_commands_to_run()
click to toggle source
do_run_make_install()
click to toggle source
do_run_the_commands( i = @array_run_these_commands )
click to toggle source
#¶ ↑
do_run_the_commands
¶ ↑
This is the main powerhorse method of this class, aka the most important one.
#¶ ↑
# File lib/rbt/make/make.rb, line 257 def do_run_the_commands( i = @array_run_these_commands ) if @run_make i.each {|entry| unless @make_options.empty? # ===================================================================== # # Append the make-options to "make" next: # ===================================================================== # entry = entry.dup if entry.frozen? entry << ' '+joined_make_options? end entry = entry.dup if entry.frozen? entry.squeeze!(' ') entry << SILENT_REDIRECTION if silent_redirection? e "Now running `#{mediumturquoise(entry)}` from #{sdir_return_pwd}." run_this_command_via_io_popen(entry) } end # ======================================================================= # # Next, run "make install" or the equivalent if the user decided # that this should be run. # ======================================================================= # if run_make_install? if @use_porg entry = "porg -lp #{@program_name_and_program_version} \"#{make_command?} install\"" e "Now running `#{mediumturquoise(entry)}` from #{sdir_return_pwd}." run_this_command_via_io_popen(entry) else esystem "#{make_command?} install" end end end
do_run_the_make_install_step_as_well()
click to toggle source
do_use_ninja()
click to toggle source
#¶ ↑
do_use_ninja
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 485 def do_use_ninja set_use_this_command :ninja end
Also aliased as: use_ninja
do_use_porg()
click to toggle source
handle_hash_or_symbol(i)
click to toggle source
handle_symbols(i = nil)
click to toggle source
#¶ ↑
handle_symbols
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 443 def handle_symbols(i = nil) return unless i case i when :run @run_already = true when :and_run_make_install_as_well, :yup @run_make_install = true end end
Also aliased as: determine_whether_to_run_make_install, handle_this_symbol
handle_this_hash(yielded)
click to toggle source
#¶ ↑
handle_this_hash
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 380 def handle_this_hash(yielded) if yielded.is_a? Hash # ===================================================================== # # === append_these_options # ===================================================================== # if yielded.has_key? :append_these_options _ = yielded[:append_these_options] _ = _.join(' ').strip if _.is_a? Array append_these_options(_.to_s) # ===================================================================== # # === use_stow # ===================================================================== # elsif yielded.has_key?(:append) append_these_options(yielded[:append].to_s) end # ===================================================================== # # === run_make # ===================================================================== # if yielded.has_key? :run_make @run_make = yielded.delete(:run_make) end # ===================================================================== # # === :use_this_make_command # ===================================================================== # if yielded.has_key? :use_this_make_command use_this_command = yielded.delete(:use_this_make_command) set_use_this_make_command( use_this_command ) end # ===================================================================== # # === :use_porg # ===================================================================== # if yielded.has_key? :use_porg use_porg = yielded.delete(:use_porg) set_use_porg( use_porg ) end # ===================================================================== # # === :program_name_and_program_version # ===================================================================== # if yielded.has_key? :program_name_and_program_version set_program_name_and_program_version( yielded.delete(:program_name_and_program_version) ) end # ===================================================================== # # === :run_make_install # ===================================================================== # if yielded.has_key? :run_make_install set_run_make_install( yielded.delete(:run_make_install) ) end elsif yielded.is_a? Symbol handle_symbols(yielded) end end
Also aliased as: handle_this_block
history_of_commands_run?()
click to toggle source
joined_make_options?()
click to toggle source
#¶ ↑
joined_make_options?¶ ↑
This method will return a String variant of the content found in @make_options.
We have to apply only .rstrip here because there may be valid padding on the left hand side, such as ' install', which may become 'make install' subsequently.
#¶ ↑
# File lib/rbt/make/make.rb, line 183 def joined_make_options? @make_options.join(' ').rstrip end
make()
click to toggle source
reset()
click to toggle source
reset_internal_dataset()
click to toggle source
#¶ ↑
reset_internal_dataset
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 84 def reset_internal_dataset # ======================================================================= # # The next Array will keep track as to which commands were run. # ======================================================================= # @array_history_of_commands_run = [] @make_options = [] @use_this_make_command = 'make' # ======================================================================= # # The following Array can be modified by the user. # ======================================================================= # @array_run_these_commands = [] # ======================================================================= # # We will delegate towards class RBT::ColourizeParser, in order # to colourize the output. This could, in principle, be disabled, # but I like colours, so the default is to make use of it. # ======================================================================= # @colourize_parser = RBT::ColourizeParser.new # ======================================================================= # # The next variable determines whether we will make use of porg # during the "make install" step. This is optional, so it will # be disabled by default. # ======================================================================= # @use_porg = false # ======================================================================= # # The next variable can be used specifically for when we will make use # of porg. When set then it should be a String such as "htop-2.2.1". # ======================================================================= # @program_name_and_program_version = nil end
run() { || ... }
click to toggle source
run_make_install?()
click to toggle source
run_this_command_via_io_popen(entry)
click to toggle source
#¶ ↑
run_this_command_via_io_popen
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 301 def run_this_command_via_io_popen(entry) cparser = cparser? io_object = IO.popen(entry, :err => [:child, :out]).each { |line| cparser.grab_this_line(line) # ===================================================================== # # Delegate towards module RBT::Errors::MapLineToASpecificError to # register any possible error. # ===================================================================== # RBT::Errors::MapLineToASpecificError.parse_this_line(line) line = cparser.line? # ===================================================================== # # Store the line in our history: # ===================================================================== # @array_history_of_commands_run << line e line # Output here. } io_object.close # Close it up again. end
Also aliased as: esystem, run_this_sys_command
set_commandline_arguments( i = nil )
click to toggle source
#¶ ↑
set_commandline_arguments
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 338 def set_commandline_arguments( i = nil ) if i.is_a? Hash # ===================================================================== # # First pass into a special method: # ===================================================================== # handle_hash_or_symbol(i) # ===================================================================== # # === :use_this_make_command # ===================================================================== # if i.has_key? :use_this_make_command set_use_this_make_command( i.delete(:use_this_make_command) ) end # ===================================================================== # # === :run_make_install # ===================================================================== # if i.has_key? :run_make_install if i.delete(:run_make_install) # Then this must be true. try_to_append_this_option_to_make(' install') end end end @commandline_arguments = [i].flatten.compact end
set_program_name_and_program_version(i)
click to toggle source
set_run_make_install(i)
click to toggle source
set_use_porg( i = false )
click to toggle source
set_use_this_make_command( i = :default )
click to toggle source
#¶ ↑
set_use_this_make_command
¶ ↑
We need this setter-method so that we can toggle between, e. g. “make” or “ninja” or any other similar build system.
#¶ ↑
# File lib/rbt/make/make.rb, line 461 def set_use_this_make_command( i = :default ) case i when :make_install # ===================================================================== # # This one is a bit different - we will only run "make install" # here, not both "make" and "make install" combined. # ===================================================================== # i = 'make' # Handle "make install" instruction here. append_this_option_to_make('install') when :ninja i = 'ninja' when :rake i = 'rake' when :default, nil, :make i = 'make' # <- We need to use a sane default value, aka "make". end @use_this_make_command = i end
Also aliased as: set_use_this_command
show_help()
click to toggle source
try_to_append_this( i = ' install' )
click to toggle source
#¶ ↑
try_to_append_this
¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 211 def try_to_append_this( i = ' install' ) unless use_which_command?.end_with? i append_these_make_options(i) end end
Also aliased as: try_to_append_this_option_to_make
use_which_make_command?()
click to toggle source
#¶ ↑
use_which_make_command?¶ ↑
#¶ ↑
# File lib/rbt/make/make.rb, line 168 def use_which_make_command? @use_this_make_command end
Also aliased as: use_which_command?, make_command?