class RBT::BuildDetector

Public Class Methods

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

[]

#
# File lib/rbt/utility_scripts/build_detector.rb, line 207
def self.[](i = '')
  self.new(i)
end
do_guess_build_type() click to toggle source
#

RBT::BuildDetector.do_guess_build_type

This method can be used to guess the build type of a target archive. Prefer to use the method RBT.build_type? instead, though, since it is more convenient.

#
# File lib/rbt/utility_scripts/build_detector.rb, line 218
def self.do_guess_build_type
  self.new.build_type?
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/build_detector.rb, line 35
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

base_dir?()
build_type?() click to toggle source
#

build_type?

#
# File lib/rbt/utility_scripts/build_detector.rb, line 173
def build_type?
  @build_type
end
determine_build_type() click to toggle source
#

determine_build_type

#
# File lib/rbt/utility_scripts/build_detector.rb, line 136
def determine_build_type
  files_from_pwd = Dir[base_dir?+'*']
  files_from_pwd_but_only_their_filenames = files_from_pwd.map { |entry|
    File.basename(entry)
  }
  # ======================================================================= #
  # Check for cmake build types first
  # ======================================================================= #
  if files_from_pwd_but_only_their_filenames.include? 'CMakeLists.txt'
    is_cmake_build_type
  # ======================================================================= #
  # Next, check for meson build types
  # ======================================================================= #
  elsif files_from_pwd_but_only_their_filenames.include? 'meson.build'
    is_meson_build_type
  # ======================================================================= #
  # Next, check for waf-based build types
  # ======================================================================= #
  elsif files_from_pwd_but_only_their_filenames.include? 'waf'
    is_waf_build_type
  # ======================================================================= #
  # Next, scheck for "scons"-based build types
  # ======================================================================= #
  elsif files_from_pwd_but_only_their_filenames.include?('SConscript') and
        files_from_pwd_but_only_their_filenames.include?('SConstruct')
    is_scons_build_type
  # ======================================================================= #
  # Next, GNU configure-based scripts
  # ======================================================================= #
  else # This is the default value.
    set_build_type
  end
end
determine_whether_the_input_is_an_existing_directory() click to toggle source
#

determine_whether_the_input_is_an_existing_directory

By default, this class will use the current directory as the input directory that is to be checked.

#
# File lib/rbt/utility_scripts/build_detector.rb, line 59
def determine_whether_the_input_is_an_existing_directory
  if File.exist? @input and File.directory? @input
    # ===================================================================== #
    # In this case, use that input as directory.
    # ===================================================================== #
    set_main_dir(@input)
  end
end
input?() click to toggle source
#

input?

#
# File lib/rbt/utility_scripts/build_detector.rb, line 81
def input?
  @input
end
is_cmake_build_type() click to toggle source
#

is_cmake_build_type

#
# File lib/rbt/utility_scripts/build_detector.rb, line 108
def is_cmake_build_type
  set_build_type :cmake
end
is_meson_build_type() click to toggle source
#

is_meson_build_type

#
# File lib/rbt/utility_scripts/build_detector.rb, line 115
def is_meson_build_type
  set_build_type :meson
end
is_scons_build_type() click to toggle source
#

is_scons_build_type

#
# File lib/rbt/utility_scripts/build_detector.rb, line 129
def is_scons_build_type
  set_build_type :scons
end
is_waf_build_type() click to toggle source
#

is_waf_build_type

#
# File lib/rbt/utility_scripts/build_detector.rb, line 122
def is_waf_build_type
  set_build_type :waf
end
report() click to toggle source
#

report (report tag)

#
# File lib/rbt/utility_scripts/build_detector.rb, line 180
def report
  # ======================================================================= #
  # The build type is stored in the variable called @build_type.
  # ======================================================================= #
  e "The guessed build type is `#{sfancy(@build_type)}`."
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/build_detector.rb, line 47
def reset
  super()
  @build_type = :configure
  set_use_this_base_directory
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/build_detector.rb, line 199
def run
  determine_whether_the_input_is_an_existing_directory
  determine_build_type
end
set_build_type(i = :configure) click to toggle source
#

set_build_type

The @build_type variable will always be a Symbol.

#
# File lib/rbt/utility_scripts/build_detector.rb, line 192
def set_build_type(i = :configure)
  @build_type = i
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/rbt/utility_scripts/build_detector.rb, line 71
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = return_pwd if i.nil?
  i = i.to_s.dup
  @input = i
end
set_main_dir( i = return_pwd )
set_use_this_base_directory( i = return_pwd ) click to toggle source
#

set_use_this_base_directory

#
# File lib/rbt/utility_scripts/build_detector.rb, line 88
def set_use_this_base_directory(
    i = return_pwd
  )
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  @use_this_base_directory = i
end
Also aliased as: set_main_dir
use_this_base_directory?() click to toggle source
#

use_this_base_directory?

#
# File lib/rbt/utility_scripts/build_detector.rb, line 101
def use_this_base_directory?
  @use_this_base_directory
end
Also aliased as: base_dir?