class RBT::Cookbooks::ShowConfigurationOptions
Constants
- DEFAULT_PROGRAM_NAME
#¶ ↑
DEFAULT_PROGRAM_NAME
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 47 def initialize( for_this_program = nil, run_already = true ) reset set_commandline_arguments( for_this_program ) # This is also a backup-copy. set_for_this_program( for_this_program ) run if run_already end
Public Instance Methods
#¶ ↑
consider_cleaning_up_the_cookbook_dataset
¶ ↑
This method currently only checks for the build type in use, in particular configure versus meson.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 292 def consider_cleaning_up_the_cookbook_dataset if @dataset.has_a_dependency_on_meson? @dataset.set_configure_command('meson') end end
#¶ ↑
data?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 130 def data? @data end
#¶ ↑
determine_cookbook
¶ ↑
We will obtain a new instance of class RBT::Cookbooks::Cookbook
so that we can also query the build system in use.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 282 def determine_cookbook @dataset = RBT::Cookbooks::Cookbook.new(this_program?) { :bypass_menu_check } end
#¶ ↑
feedback_help_then_exit
¶ ↑
This will show some help options, then exit.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 121 def feedback_help_then_exit opnn; e 'You can use the current working directory via PWD.' opnn; Colours.eparse 'XORG # Set the xorg buffer here as well, silently.' exit end
#¶ ↑
insert_prefix_to_use
¶ ↑
This will insert the prefix that we will use. The prefix is usually /usr but it can also be an AppDir prefix such as /Programs/Htop/2.0.2.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 243 def insert_prefix_to_use _ = ' --prefix=' use_this_prefix = prefix_to_use?.to_s # Better as String. if use_this_prefix.include?(programs_dir?) and @commandline_arguments.is_a?(Array) and @commandline_arguments.empty? # ===================================================================== # # This means that the user provided no arguments, thus we will use # the current working directory as our assumed input. # ===================================================================== # splitted = use_this_prefix.split('/') # program_version = splitted.last # This is usually the program version. # ===================================================================== # # Now we will simply use the current working directory as version, # if it matches a specific regex. # ===================================================================== # assumed_version_of_the_working_directory = File.basename(Dir.pwd) new_version = ::ProgramInformation.return_program_version(assumed_version_of_the_working_directory) splitted[-1] = new_version use_this_prefix = splitted.join('/') end _ = _.dup if _.frozen? _ << use_this_prefix _ << ' ' end
#¶ ↑
return_appdir_prefix
¶ ↑
We may have to use another version when we run from certain directories.
An example for this may be a directory called gobject-introspection-1.52.0 but the latest version in the cookbook files is 1.53.0.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 227 def return_appdir_prefix(i = '') if i.include? '-' program_name, program_version = ProgramInformation.return_real_short_name_and_version(i) end _ = programs_directory?+ program_name.capitalize+'/'+ program_version return _ end
#¶ ↑
return_proper_configure_command
¶ ↑
This method will honour the entry configure_command: in the respective .yml file. We can return 'configure' or 'cmake' or 'scons'.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 365 def return_proper_configure_command result = ''.dup result << @dataset.configure_command? # <- This usually adds the String 'configure'. if result == 'configure' result.prepend './' # For "./configure" syntax. end result.prepend '.' if @are_we_in_a_build_directory result << ' ' unless result.end_with? ' ' return result end
#¶ ↑
set_for_this_program
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 137 def set_for_this_program(i = DEFAULT_PROGRAM_NAME) if i.is_a? Array if i.size > 1 # This is the case for e. g.: "sco gcc XORG" case i[1] # Second argument. when 'XORG','BUFFER' @use_xorg_buffer = true end end i = i.first end if i.nil? # ===================================================================== # # In this case, use the current working directory. # ===================================================================== # _ = Dir.pwd if _.include?('-') && _.include?('.') i = ProgramInformation.return_name(File.basename(_)).delete('-').delete('_') else i = DEFAULT_PROGRAM_NAME end end i = i.to_s.dup i.downcase! # Since as of 20.09.2014. # ======================================================================= # # Keep in mind that the following check checks against the # downcased variant. # ======================================================================= # case i # case tag # ======================================================================= # # === appdir # ======================================================================= # when /-?-?appdir/,/-?-?appconf/,/^app/ i = File.basename(Dir.pwd) # ===================================================================== # # Next, we can either .split('-') on that directory name, or we # use ProgramInformation instead.' # ===================================================================== # i = ProgramInformation.return_name(i).delete('-').delete('_') @dataset.prefix_to_use = return_appdir_prefix(File.basename(Dir.pwd)) # ======================================================================= # # === sco --build # ======================================================================= # when /-?-?build/ # We may be in a directory called BUILD. if Dir.pwd.include? 'BUILD' i = File.basename(Dir.pwd.gsub(/BUILD$/,'')) i = ProgramInformation.return_name(i) @are_we_in_a_build_directory = true end # ======================================================================= # # === --help # ======================================================================= # when /-?-?help/,'HELP' feedback_help_then_exit # ======================================================================= # # === --pwd # ======================================================================= # when /-?-?pwd/,'PWD' i = File.basename(Dir.pwd).split('-').first end # ======================================================================= # # Last but not least, we query whether there is an alias program name # but ONLY if the Cookbooks project does NOT include the given input. # ======================================================================= # if RBT.is_included? i, :do_not_check_for_aliases result = i else # else pass it through our alias-filter there. result = find_cookbook_alias_for(i) end if result.nil? and # Try again in this case. RBT.include_this_program?('lib'+i) result = 'lib'+i end if result unless result == i opnn; e 'Using the alias name `'+sfancy(result)+ '` for the input `'+simp(i)+'` instead.' i = result end end @for_this_program = i end
#¶ ↑
show_configuration_options
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 301 def show_configuration_options # ======================================================================= # # Must check whether we have found the given input or whether we have not. # ======================================================================= # if found? condensed_configuration_options = ''.dup opnn; e "These are the configuration options for #{sfancy(@for_this_program)}"\ " (we will also modify the xorg buffer):"+N+N @data = @dataset.configuration_options?.split(' ') # ===================================================================== # # Next, append the condensed configuration options. # ===================================================================== # @data.each {|entry| condensed_configuration_options << entry+' ' entry.gsub!(/--/,'') # Get rid of '--' options. e ' --'+simp(entry) } e condensed_configuration_options.delete!(N) opnn; e 'Also showing the '+slateblue('condensed format')+' of these options next:'+N+N full_commandline = ''.dup full_commandline << return_proper_configure_command # ========================================================================= # # Append the prefix next. We will, however had, NOT insert the # prefix if the condensed_configuration_options already include '-prefix' # ========================================================================= # unless condensed_configuration_options.include? '-prefix' full_commandline << insert_prefix_to_use end full_commandline << condensed_configuration_options if @dataset.configure_command?.include? 'meson' # ======================================================================= # # This always requires a build-directory, so let's use one: # ======================================================================= # full_commandline << ' BUILD_DIRECTORY/' end full_commandline.squeeze!(' ') # ========================================================================= # # Next we output the full commandline. We will NOT show the name of # the class here though. # ========================================================================= # e " #{simp(full_commandline)}" e if @use_xorg_buffer set_new_xorg_buffer(full_commandline) store_last_configuration_options(full_commandline) opnn; e "The above was assigned to the #{teal('xorg-buffer')} as well, so you" opnn; e 'can very easily copy-paste this.' end else opnn; e "The given input `#{sfancy(input?)}` was not found." opnn; e 'This means that no program called that way could be '\ 'found to be registered.' opnn; e 'Another reason why it failed may be a typo, so make '\ 'sure to check the above input.' end end
#¶ ↑
store_last_configuration_options
¶ ↑
Use this method to store the last configure options used in a specific file, so that it can be read lateron.
Note that the target directory must exist, for this method to properly work.
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 385 def store_last_configuration_options(i) into = RBT.store_the_last_configuration_options_in_this_file base_directory = File.dirname(into) if File.directory? base_directory write_what_into( i, into ) else opnn; no_directory_exists_at(base_directory) end end