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

new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 55
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

are_we_in_a_build_directory?() click to toggle source
#

are_we_in_a_build_directory?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 135
def are_we_in_a_build_directory?
  @internal_hash[:are_we_in_a_build_directory]
end
assumed_prefix?( user_prefix = user_prefix? ) click to toggle source
#

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
assumed_version?() click to toggle source
#

assumed_version?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 585
def assumed_version?
  _ = dataset.program_version?
  if @internal_hash[:user_defined_program_version]
    _ = @internal_hash[:user_defined_program_version]
  end
  return _
end
build_type?( cookbook_dataset = cookbook_dataset? )
cookbook_dataset?() click to toggle source
#

cookbook_dataset?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 224
def cookbook_dataset?
  @internal_hash[:cookbook_dataset]
end
Also aliased as: dataset?, dataset, data?, data
cookbook_dataset_program_name?() click to toggle source
#

cookbook_dataset_program_name?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 448
def cookbook_dataset_program_name?
  cookbook_dataset.program_name?
end
data()
Alias for: cookbook_dataset?
data?()
Alias for: cookbook_dataset?
dataset()
Alias for: cookbook_dataset?
dataset?()
Alias for: cookbook_dataset?
dataset_prefix?() click to toggle source
#

dataset_prefix?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 243
def dataset_prefix?
  dataset.prefix?
end
determine_cookbook()
do_assume_that_the_user_wanted_to_work_with_the_current_working_directory() click to toggle source
#

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() click to toggle source
#

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
Also aliased as: show_help
find_cookbook_alias_for(i) click to toggle source
#

find_cookbook_alias_for

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 149
def find_cookbook_alias_for(i)
  ::RBT.find_cookbook_alias_for(i)
end
for_this_program?()
found?( cookbook_dataset = cookbook_dataset? ) click to toggle source
#

found?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 215
def found?(
    cookbook_dataset = cookbook_dataset?
  )
  cookbook_dataset and cookbook_dataset.found?
end
initialize_the_cookbook_dataset() click to toggle source
#

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
Also aliased as: determine_cookbook
input?()
insert_prefix_to_use( user_prefix = user_prefix? )
Alias for: assumed_prefix?
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
prefix?()
Alias for: user_prefix?
prefix_to_use?( user_prefix = user_prefix? )
Alias for: assumed_prefix?
program_name?()
program_version?()
report()
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method 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_insert_prefix_to_use( user_prefix = user_prefix? )
Alias for: assumed_prefix?
return_proper_configure_command( cookbook_dataset = cookbook_dataset? ) click to toggle source
#

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() click to toggle source
#

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_for_this_program(i)
set_new_xorg_buffer( i = data?.join(' ') ) click to toggle source
#

set_new_xorg_buffer

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 234
def set_new_xorg_buffer(
    i = data?.join(' ')
  ) 
  set_xorg_buffer(i) # Useful to set the xorg buffer.
end
set_prefix(i)
Alias for: set_user_prefix
set_program_version(i)
set_user_defined_program_version(i) click to toggle source
#

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
Also aliased as: set_program_version
set_user_prefix(i) click to toggle source
#

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
Also aliased as: set_prefix
set_work_on_this_program(i) click to toggle source
#

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
Also aliased as: set_for_this_program
show_configuration_options()
show_help()
show_the_configure_options() click to toggle source
#

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( i, into = RBT.store_the_last_configuration_options_in_this_file ) click to toggle source
#

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
this_program?()
use_this_build_system?( cookbook_dataset = cookbook_dataset? ) click to toggle source
#

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
Also aliased as: build_type?
use_xorg_buffer?() click to toggle source
#

use_xorg_buffer?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 110
def use_xorg_buffer?
  @internal_hash[:use_xorg_buffer]
end
user_defined_program_version?() click to toggle source
#

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
Also aliased as: program_version?
user_defined_use_this_build_system?() click to toggle source
#

user_defined_use_this_build_system?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 441
def user_defined_use_this_build_system?
  @internal_hash[:use_this_build_system]
end
user_prefix?() click to toggle source
#

user_prefix?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 250
def user_prefix?
  @internal_hash[:user_prefix]
end
Also aliased as: prefix?
uses_cmake?() click to toggle source
#

uses_cmake?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 468
def uses_cmake?
  use_this_build_system? == 'cmake'
end
uses_meson?() click to toggle source
#

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
we_are_in_a_build_directory() click to toggle source
#

we_are_in_a_build_directory

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 142
def we_are_in_a_build_directory
  @internal_hash[:are_we_in_a_build_directory] = true
end
work_on_this_program?() click to toggle source
#

work_on_this_program?

#
# File lib/rbt/cookbooks/show_configuration_options/show_configuration_options.rb, line 124
def work_on_this_program?
  @internal_hash[:work_on_this_program]
end
work_on_which_program?()