class RBT::SimpleAppdirConfigure

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::SimpleAppdirConfigure[]

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 249
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 27
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
padded_esystem(cmd) click to toggle source
#

padded_esystem

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 91
def padded_esystem(cmd)
  e
  e slateblue(cmd)
  e
  system cmd
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 41
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @cmd
  # ======================================================================= #
  @cmd = './configure'.dup
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 101
def run
  menu
  # ======================================================================= #
  # Establish the cmd to use early on.
  # ======================================================================= #
  cmd = @cmd # ← This is the command that will be used.
  from = return_pwd # Default.
  _ = first_non_hyphen_argument?
  case _
  # ======================================================================= #
  # === :pwd
  # ======================================================================= #
  when :pwd
    _ = return_pwd
  end
  _ = _.to_s.dup # Work on a copy here, anyway.
  unless _.empty?
    from = _.dup
  end
  from = File.basename(from)
  if File.exist?(from) and File.file?(from)
    # ===================================================================== #
    # Extract the archive in this case.
    #
    # Usage example:
    #
    #
    #
    # ===================================================================== #
    e "#{rev}Extracting the archive #{sdir(from)} next."
    RBT.extract_what_to(from)
    from = remove_archive_from_the_end( # Re-define from here.
      File.basename(from)
    )
    opne "Entering the directory #{sdir(File.absolute_path(from))} next."
    cd from
  end
  if File.exist?(from) and !File.directory?(from)
    opne swarn('Currently this code only works on already '\
         'extracted directories.')
    exit
  end
  append_these_configure_options = ''.dup
  commandline_arguments = commandline_arguments?
  commandline_arguments.reject! {|entry| entry == _ }
  these_arguments = hyphen_arguments(
    commandline_arguments
  ).join(' ')
  unless these_arguments.rstrip.empty?
    append_these_configure_options << these_arguments.rstrip
  end
  # ======================================================================= #
  # Obtain the program-name and program-version next:
  # ======================================================================= #
  program_name    = ProgramInformation.return_short_name(from).delete('-')
  program_version = ProgramInformation.return_version(from)
  # ======================================================================= #
  # === Determine the correct prefix next
  #
  # Next we must determine the proper prefix-target for PROGRAMS.
  # ======================================================================= #
  use_this_as_the_target_prefix = programs_directory?+
                                  program_name.capitalize+'/'+
                                  program_version+'/'
  # ======================================================================= #
  # We will pass this into RBT::CreateAppDirSkeleton next:
  # ======================================================================= #
  require 'rbt/create_app_dir_skeleton/create_app_dir_skeleton.rb'
  RBT.create_appdir_skeleton(use_this_as_the_target_prefix)
  if File.exist?('CMakeLists.txt') and !File.exist?('configure') and
    cmd.include?('configure')
    # ===================================================================== #
    # In this case there is no GNU configure script; only a cmake file
    # available, so use that.
    # ===================================================================== #
    cmd = 'cmake'
  # ======================================================================= #
  # Run the three sys-commands next, starting with "./configure". If
  # the working directory does NOT include a file called "configure",
  # but it DOES contain a file called 'autogen.sh' then we will first
  # invoke autogen before continuing.
  # ======================================================================= #
  elsif File.exist?('autogen.sh') and
       !File.exist?('configure') and
        cmd.include?('configure')
    e
    e 'No '+sfile('configure')+' file was found, but a file called'
    e sfile('autogen.sh')+' was found. Thus, invoking autogen next.'
    e
    padded_esystem 'sh autogen.sh'
  end
  cmd = cmd.dup if cmd.frozen?
  if cmd.include? 'cmake'
    # ===================================================================== #
    # Add the proper prefix.
    # ===================================================================== #
    cmd << ' -DCMAKE_INSTALL_PREFIX='+use_this_as_the_target_prefix
  else
    # ===================================================================== #
    # This part is valid for both GNU configure as well as meson.
    # ===================================================================== #
    cmd << ' --prefix='+use_this_as_the_target_prefix
  end
  unless cmd.include? append_these_configure_options
    cmd << " #{append_these_configure_options}" unless append_these_configure_options.empty?
  end
  if File.exist?('meson.build') and !File.exist?('configure')
    _ = "meson --prefix=#{use_this_as_the_target_prefix}".dup
    if append_these_configure_options and !append_these_configure_options.empty?
      _ << " #{append_these_configure_options}"
    end
    _ << " BUILD_DIRECTORY/"
    padded_esystem _
    cd 'BUILD_DIRECTORY'
    run_ninja_command
    run_ninja_install_command
    return
  else
    padded_esystem cmd
    if cmd.start_with? 'meson'
      run_ninja_command
      run_ninja_install_command
    else # This clause is valid for GNU configure and cmake.
      cmd = 'make'
      padded_esystem(cmd)
      cmd = 'make install'
      padded_esystem(cmd)
    end
  end
end
run_ninja_command() click to toggle source
#

run_ninja_command

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 235
def run_ninja_command
  padded_esystem 'ninja'
end
run_ninja_install_command() click to toggle source
#

run_ninja_install_command

#
# File lib/rbt/utility_scripts/simple_appdir_configure/simple_appdir_configure.rb, line 242
def run_ninja_install_command
  padded_esystem 'ninja install'
end