class RBT::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
Public Instance Methods
#¶ ↑
assumed_prefix?¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 264 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
#¶ ↑
do_assume_that_the_user_wanted_to_work_with_the_current_working_directory
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 545 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 197 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-meson # specifically use meson and its configure options' eparse ' --usr # use the /usr/ prefix' e exit end
#¶ ↑
initialize_the_cookbook_dataset
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 405 def initialize_the_cookbook_dataset # ======================================================================= # # === :cookbook_dataset # ======================================================================= # @internal_hash[:cookbook_dataset] = RBT.cookbook_for(program_name?) # This uses :fast implicitely already. end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
RBT::Base#reset
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 69 def reset super() infer_the_namespace try_to_require_the_xorg_buffer # ======================================================================= # # === :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 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 481 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 524 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 opne "The given input `#{sfancy(input?)}` 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 end
#¶ ↑
set_user_defined_program_version
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 578 def set_user_defined_program_version(i) @internal_hash[:user_defined_program_version] = i end
#¶ ↑
set_user_prefix
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 117 def set_user_prefix(i) @internal_hash[:user_prefix] = i end
#¶ ↑
set_work_on_this_program
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 156 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)+ '` for the input `'+simp(i)+'` 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 601 def show_the_configure_options opnn { :no_trailing }; e; e e "These are the #{steelblue('raw')} configure options for "\ "#{sfancy(for_this_program?)}" e "(the xorg buffer will also be modified):#{N}" cmd = ' '+return_proper_configure_command.strip.squeeze(' ').dup # ======================================================================= # # Insert the prefix next: # ======================================================================= # cmd << " --prefix=#{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 # ======================================================================= # # 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) e "The above was assigned to the #{teal('xorg-buffer')} as "\ "well, so you" e 'can very easily copy-paste this.' 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 306 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 424 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/cookbooks/show_configuration_options/show_configuration_options.rb, line 257 def user_defined_program_version? @internal_hash[:user_defined_program_version] end
#¶ ↑
user_prefix?¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 250 def user_prefix? @internal_hash[:user_prefix] end
#¶ ↑
uses_meson?¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 455 def uses_meson? # ======================================================================= # # An alternative may be: # # if cookbook_dataset?.configure_command?.include? 'meson' # # ======================================================================= # use_this_build_system?.to_s == 'meson' end