class RBT::Action::Cookbooks::ShowConfigurationOptions
Constants
- DEFAULT_PROGRAM_NAME
#¶ ↑
DEFAULT_PROGRAM_NAME
¶ ↑This constant is no longer in use.
#¶ ↑
- VERSION_REGEX
#¶ ↑
VERSION_REGEX
¶ ↑This constant is also no longer in use, but it may be necessary in the future, so we’ll keep it here for the time being.
#¶ ↑
Public Class Methods
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 59 def initialize( i = ARGV, run_already = true, &block ) reset set_commandline_arguments(i) case run_already # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false end run if run_already end
Public Instance Methods
#¶ ↑
assumed_prefix?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 270 def assumed_prefix?( user_prefix = user_prefix? ) _ = dataset_prefix? # First get the default prefix as used by the cookbook-dataset. if user_prefix case user_prefix # ===================================================================== # # === :appdir_prefix # ===================================================================== # when :appdir_prefix # =================================================================== # # Next, we can either .split('-') on that directory name, or we # use ProgramInformation instead.' # =================================================================== # _ = return_appdir_prefix( work_on_which_program?+'-'+assumed_version?.to_s ) else _ = user_prefix unless user_prefix.nil? end elsif user_prefix.nil? and !user_defined_program_version?.nil? # ===================================================================== # # This entry point is valid for "scopwd" usage cases. # ===================================================================== # _ = return_appdir_prefix( work_on_which_program?+'-'+user_defined_program_version?.to_s ) end return _ end
#¶ ↑
assumed_version?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 619 def assumed_version? _ = dataset.program_version? if @internal_hash[:user_defined_program_version] _ = @internal_hash[:user_defined_program_version] end return _ end
#¶ ↑
do_assume_that_the_user_wanted_to_work_with_the_current_working_directory
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 579 def do_assume_that_the_user_wanted_to_work_with_the_current_working_directory pwd = return_pwd.dup if pwd.include? '-' # Must include at the least one '-'. # ===================================================================== # # We may be in a directory called BUILD/ here. # ===================================================================== # if pwd.include? 'BUILD' pwd.sub!(/BUILD_DIRECTORY/,'') pwd.sub!(/BUILD/,'') we_are_in_a_build_directory end _ = File.basename(pwd) if _.include? '-' set_work_on_this_program( ProgramInformation.return_program_name(_) ) set_program_version( ProgramInformation.return_program_version(_) ) else opne _+' can not be evaluated by ProgramInformation; '\ 'the input must include a '+tomato('-')+' token.' end else opne 'Can not work on '+pwd+' - the input must '\ 'contain at the least one - character.' set_work_on_this_program(nil) end end
#¶ ↑
feedback_help_then_exit
(help tag)¶ ↑
This will show some help options, then exit.
Invocation example:
sco --help
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 202 def feedback_help_then_exit opnn { :no_trailing} e e eparse ' XORG # Set the xorg buffer here as well, silently.' eparse ' PWD # Use the current working directory via PWD or --pwd.' eparse ' --ntrad # Make use of an AppDir prefix. Example: sco htop --ntrad' eparse ' --appdir # as ^^^ above' eparse ' --use-configure # specifically use the configure options' eparse ' --use-extended-configure # as ^^^ above, but also show the leading ./configure string' eparse ' --use-meson # specifically use meson and its configure options' eparse ' --usr # use the /usr/ prefix' e exit end
#¶ ↑
initialize_the_cookbook_dataset
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 736 def initialize_the_cookbook_dataset( i = work_on_which_program? ) # ======================================================================= # # === :cookbook_dataset # ======================================================================= # @internal_hash[:cookbook_dataset] = action(:cookbook_for, i) # This uses :fast implicitely already. end
#¶ ↑
notify_the_user_that_the_given_input_was_not_found
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 748 def notify_the_user_that_the_given_input_was_not_found(i = input?) opne "#{rev}The given input `#{sfancy(i)}#{rev}` was not found." opne 'This means that no program called that way could' opne 'be found to be registered.' opne 'Another reason why it failed may be a typo, so ' opne 'make sure to check the above input.' end
#¶ ↑
reset_the_internal_variables
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 89 def reset_the_internal_variables # ======================================================================= # # === :use_xorg_buffer # ======================================================================= # @internal_hash[:use_xorg_buffer] = true # ======================================================================= # # === :work_on_this_program # ======================================================================= # @internal_hash[:work_on_this_program] = nil # ======================================================================= # # === :user_prefix # # This will initially be nil. # ======================================================================= # @internal_hash[:user_prefix] = nil # ======================================================================= # # === :are_we_in_a_build_directory # # This variable will set to true if the current working directory # is a BUILD/ or BUILD_DIRECTORY subdirectory. # ======================================================================= # @internal_hash[:are_we_in_a_build_directory] = false # ======================================================================= # # === :user_defined_program_version # # This can be defined by the user and will override any guesses # from the cookbook-dataset. # ======================================================================= # @internal_hash[:user_defined_program_version] = nil # ======================================================================= # # === :use_this_build_system # ======================================================================= # @internal_hash[:use_this_build_system] = nil # ======================================================================= # # === :assume_build_directory # ======================================================================= # @internal_hash[:assume_build_directory] = false # ======================================================================= # # === :show_the_command # ======================================================================= # @internal_hash[:show_the_command] = false 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’.
Since as of December 2019, we will also check for the explicit option for “use_this_build_system”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 536 def return_proper_configure_command( cookbook_dataset = cookbook_dataset? ) result = ''.dup use_this_build_system = use_this_build_system? case use_this_build_system.to_s # ======================================================================= # # === cmake # # This entry point will specifically use cmake. # ======================================================================= # when 'cmake' result << use_this_build_system # ======================================================================= # # === meson # # Same as above, but for meson rather than cmake. # ======================================================================= # when 'meson' result << 'meson' # if @internal_hash[:use_this_build_system] = :meson # result << " #{cookbook_dataset.meson_configure_options?}" # end # ======================================================================= # # === configure # ======================================================================= # when 'configure' # result << "#{cookbook_dataset.configure_command?}" else # This else-clause covers :infer_automatically. # result << "#{cookbook_dataset.configure_command?}" # ← This usually adds the String 'configure'. end case result when 'configure' result.prepend './' # For "./configure" syntax. result.prepend '.' if are_we_in_a_build_directory? end result << ' ' unless result.end_with? ' ' return result end
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 759 def run menu initialize_the_cookbook_dataset # ======================================================================= # # Must check whether we have found the given input or whether we have # not. # ======================================================================= # if found? show_the_configure_options else notify_the_user_that_the_given_input_was_not_found(input?) end end
#¶ ↑
set_user_defined_program_version
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 612 def set_user_defined_program_version(i) @internal_hash[:user_defined_program_version] = i end
#¶ ↑
set_user_prefix
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 156 def set_user_prefix(i) @internal_hash[:user_prefix] = i end
#¶ ↑
set_work_on_this_program
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 436 def set_work_on_this_program(i) if i.is_a? Array i = i.first end i = i.dup if i if i and i.end_with?('.yml') i.delete_suffix!('.yml') 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 opne 'Using the alias name `'+sfancy(result)+ rev+'` for the input `'+simp(i)+rev+'` instead.' i = result end end @internal_hash[:work_on_this_program] = i end
#¶ ↑
show_the_configure_options
¶ ↑
Commandline
usage example:
sco gnutls
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 642 def show_the_configure_options cwd = return_pwd # ======================================================================= # # Obtain the assumed program-version from the name of the current working # directory next. In April 2023 the subsequent code had to be changed - # if no "-" is part of the current working directory then we will # short circuit. # ======================================================================= # cwd = File.basename(cwd) if cwd.include? '-' assumed_version_from_the_cwd = ProgramInformation.return_version(cwd) else assumed_version_from_the_cwd = program_version? end opnn { :no_trailing }; e; e e "#{rev}These are the #{steelblue('raw')} #{rev}configure options for "\ "#{sfancy(for_this_program?)}" e "#{rev}(the xorg buffer will also be modified):#{N}" cmd = ' '.dup if show_the_command? if assume_build_directory? cmd << '.' end cmd << './configure' end cmd << return_proper_configure_command.strip.squeeze(' ') # ======================================================================= # # Insert the prefix next: # ======================================================================= # cmd << " --prefix=" assumed_prefix = assumed_prefix?.dup if assumed_prefix.include? programs_dir? # We know that this must be an AppDir. # ===================================================================== # # The following regex is not perfect - we may have to change that one # day, but for now it suffices (April 2023). # ===================================================================== # use_this_regex = /(\d{1,4}\.?\d{0,4}\.?\d{0,4})/ # See: https://rubular.com/r/2hnUQZpcRYwNxD assumed_prefix.sub!(use_this_regex, assumed_version_from_the_cwd) end # ======================================================================= # # We may have to re-write the prefix here, e. g. to sanitize from # binutils-2.40.0 towards binutils-14.04.2023. # ======================================================================= # cmd << assumed_prefix if uses_cmake? # ===================================================================== # # Modify the prefix a little bit here - see # https://rubular.com/r/EtjMy1X87lz7mH # ===================================================================== # cmd.sub!(/-prefix/, 'DCMAKE_INSTALL_PREFIX') end # ======================================================================= # # And the configure-options will be added next: # ======================================================================= # assumed_configure_options = dataset?.meson_or_cmake_or_configure_options?(build_type?.to_sym) if assumed_configure_options.nil? assumed_configure_options = dataset?.meson_or_cmake_or_configure_options? end cmd << " #{assumed_configure_options}" if uses_meson? # ===================================================================== # # meson always requires a build-directory, so let's use one: # ===================================================================== # cmd << ' BUILD_DIRECTORY/' end if assume_build_directory? cmd << ' ..' end # ======================================================================= # # Next we output the full commandline. We will NOT show the name of # the class here though. # ======================================================================= # e e mediumpurple(cmd) e # ======================================================================= # # === Handle xorg-specific parts next # ======================================================================= # if use_xorg_buffer? set_new_xorg_buffer(cmd) store_last_configuration_options(cmd) shell_file = work_on_which_program?.to_s+'.sh' write_what_into(cmd.strip, shell_file) e "#{rev}The above was assigned to the #{teal('xorg-buffer')} "\ "#{rev}as well, so you can" e 'very easily copy-paste this. Additionally it was also stored' e 'into a shell file, at `'+sfile(shell_file)+rev+'`.' 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/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 312 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 # opne 'Storing into '+sfile(into)+'.' if be_verbose? write_what_into( i.strip, into ) else opnn; no_directory_exists_at(base_directory) end end
#¶ ↑
use_this_build_system?¶ ↑
This query method is a bit hackish. In theory we should rely on the code showing us the real value, but there is presently (April 2021) a bug, which explains the work around used here. At a later time we may have to re-evaluate the code here, but for now this has to suffice.
Since as of September 2022 the user can ignore this, via the –use-configure flag.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 479 def use_this_build_system?( cookbook_dataset = cookbook_dataset? ) _ = cookbook_dataset.use_this_build_system? case cookbook_dataset.raw_cookbook?.use_this_build_system? when 'meson' _ = 'meson' end if user_defined_use_this_build_system? _ = user_defined_use_this_build_system? end return _ end
#¶ ↑
user_defined_program_version?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 263 def user_defined_program_version? @internal_hash[:user_defined_program_version] end
#¶ ↑
user_prefix?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 256 def user_prefix? @internal_hash[:user_prefix] end
#¶ ↑
uses_meson?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/show_configuration_options/show_configuration_options.rb, line 510 def uses_meson? # ======================================================================= # # An alternative may be: # # if cookbook_dataset?.configure_command?.include? 'meson' # # ======================================================================= # use_this_build_system?.to_s == 'meson' end