class RBT::ConfigureString

Public Class Methods

new( string = './configure', run_already = false ) click to toggle source
#

initialize

#
# File lib/rbt/misc/configure_string.rb, line 25
def initialize(
    string      = './configure',
    run_already = false
  )
  reset
  set_configure_string(
    string
  )
  run if run_already
end

Public Instance Methods

<<(this)
Alias for: append
_()
Alias for: string?
append(this) click to toggle source
#

append

This method will simply append data onto the @configure_string, after appending a ' '. It does check whether the string already exists, before adding it.

#
# File lib/rbt/misc/configure_string.rb, line 112
def append(this)
  # Ensure string format if input is an Array
  this = this.flatten.join(' ') if this.is_a? Array
  if this.include? ' '
    this.split(' ').each {|_| append(_)}
  else
    # Only add if our string does not already have this:
    @configure_string << ' '+this if ! @configure_string.include? this
    @configure_string.lstrip! if string?.start_with? ' ' # Get rid of leading ' '
  end
end
Also aliased as: <<
check_then_append(this_string) click to toggle source
#

check_then_append

This first checkes the prefix and if the prefix does not contain something special, then we add the argument to it.

For example:

--with-os-vendor="HiveOS"
#
# File lib/rbt/misc/configure_string.rb, line 258
def check_then_append(this_string)
  if this_string.include? '--' and this_string.include? '='
    this_string =~ /--(.*)=/
    target = $1.dup
    append(this_string) unless this_string.include?(target)
  end
end
configure_string()
Alias for: configure_string?
configure_string?() click to toggle source
#

configure_string?

Contains the configure string object.

#
# File lib/rbt/misc/configure_string.rb, line 49
def configure_string?
  @configure_string
end
Also aliased as: configure_string
do_not_use_a_prefix() click to toggle source
#

do_not_use_a_prefix

Do not use a prefix at all.

#
# File lib/rbt/misc/configure_string.rb, line 150
def do_not_use_a_prefix
  @do_not_use_a_prefix = true
end
do_use_a_prefix() click to toggle source
#

do_use_a_prefix

#
# File lib/rbt/misc/configure_string.rb, line 157
def do_use_a_prefix
  @do_not_use_a_prefix = false
end
leading_part=(i) click to toggle source
#

leading_part

A setter method to set the leading part.

#
# File lib/rbt/misc/configure_string.rb, line 70
def leading_part=(i)
  @configure_string.prepend(i) # prepend here.
end
modify_prefix(new_prefix) click to toggle source
#

modify_prefix

This method modifies the –prefix= directive by replacing the old directive (if found). Invoke this method ONLY if you are sure that you want to modify the prefix PERMANENTLY.

x = ' --prefix=/Programs/Xosd/2.11.122 '; x.gsub!(/--prefix=\/\S*/,'')
#
# File lib/rbt/misc/configure_string.rb, line 293
def modify_prefix(new_prefix)
  unless @do_not_use_a_prefix # Only do it when we need to modify the prefix.
    # ===================================================================== #
    # prefix braucht wirklich nur einmal dabei zu sein.
    # ===================================================================== #
    @configure_string.sub!(/--prefix=\/\S*/,' ')
    # ===================================================================== #
    # Since as of October 2011, we will remove '-' if the string contains
    # this character.
    # ===================================================================== #
    if new_prefix.include? '-'
      new_prefix.delete!('-')
    end
    sanitize_configure_string
    # If it includes a |
    if @configure_string.include? '|'
      splitted = @configure_string.split '|'
      splitted[1] = splitted[1]+' --prefix='+new_prefix+' '
      set_configure_string splitted.join('|')
    else # Else, we insert right after ./configure or ./config
      if @configure_string.include? 'configure'
        pos = @configure_string =~ /configure/
        @configure_string[pos+'configure'.size, 0] = ' --prefix='+new_prefix+' '
      else
        pos = @configure_string =~ /config/
        @configure_string[pos+'config'.size,0] = ' --prefix='+new_prefix+' '
      end
      # @configure_string = @configure_string.insert_after_nth_word(1,'--prefix='+new_prefix+' ')
    end
    set_prefix(new_prefix) # Finally call set_prefix() here.
  end
end
prefix()
Alias for: prefix?
prefix?() click to toggle source
#

prefix?

for @prefix? Dont set this to an attr_*writer!

#
# File lib/rbt/misc/configure_string.rb, line 281
def prefix?
  @prefix
end
Also aliased as: prefix
prepend(this_string) click to toggle source
#

prepend

This method will simply prepend data onto the @configure_string. It does NO sanity-checking whatsoever.

#
# File lib/rbt/misc/configure_string.rb, line 101
def prepend(this_string)
  @configure_string.prepend(this_string)
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/misc/configure_string.rb, line 39
def reset # reset tag.
  super()
  do_use_a_prefix
end
run() click to toggle source
#

run

#
# File lib/rbt/misc/configure_string.rb, line 329
def run
  set_target :default
  set_build
  set_host
  set_march
end
sanitize_again()
sanitize_configure_string() click to toggle source
#

sanitize_configure_string

This methods attempts to ensure that our string is correct. For this, it removes newlines and some other things that may crop up.

#
# File lib/rbt/misc/configure_string.rb, line 80
def sanitize_configure_string
  @configure_string.chomp!
  @configure_string.strip!
  @configure_string.squeeze!(' ')
  @configure_string.gsub!(/\n/, '')
  @configure_string.gsub!(/\.\/\.\//, './') # replace ././ with ./
end
Also aliased as: sanitize_again
set_build(build_type = :linux) click to toggle source
#

set_build

set_build :mac (build tag)

#
# File lib/rbt/misc/configure_string.rb, line 193
def set_build(build_type = :linux)
  case build_type
  when :x64, :cross_linux, :cross, :dualcore
    build_type = 'x86_64-pc-linux-gnu'
  when :linux
    build_type = 'i686-pc-linux-gnu'
  when :mac
    build_type = 'powerpc-apple'
  end
  append '--build="'+build_type+'"'
end
set_configure_string(i) click to toggle source
#

set_configure_string

Use this method when setting @configure_string.

#
# File lib/rbt/misc/configure_string.rb, line 58
def set_configure_string(i)
  i = '' if i.nil?
  i = i.strip
  @configure_string = i
end
Also aliased as: set_string, string=
set_host( host_type = :mingw ) click to toggle source
#

set_host

This sets the host type. It relies on symbols for special constructs.

#
# File lib/rbt/misc/configure_string.rb, line 129
def set_host(
    host_type = :mingw
  )
  case host_type
  when :mac
    host_type = 'powerpc-apple-darwin7.7.0'
  when :windows, :win, :mingw
    host_type = 'i686-pc-mingw32' # i586-mingw32msvc'
  when :linux
    host_type = 'i586-pc-linux-gnu'
  when :old_linux
    host_type = 'i386-linux'
  end
  append '--host="'+host_type+'"'
end
set_march(march_type = 'athlon-xp') click to toggle source
#

set_march (march tag)

Remember that if march=arch is set then -mcpu=arch is also honored.

#
# File lib/rbt/misc/configure_string.rb, line 223
def set_march(march_type = 'athlon-xp')
  case march_type.to_sym
  when :pentium # aktuellster. should always point to the most-recent pentium
    march_type = 'pentium4' # 7. x86 Generation
  when :middle_pentium
    march_type = 'pentium3'
  when :old_pentium # really old
    march_type = 'pentium2'
  when :Intel_Celeron_M
    march_type = 'pentium-m'
  when :amd
    march_type = 'athlon-xp'
  when :mp
    march_type = 'athlon-mp'
  when :athlon64
    march_type = 'athlon64'
  when :old
    march_type = 'i486'
  when :k6
    march_type = 'k6'
  when :default, :native
    march_type = 'native' # special march type
  end
  append '--march="'+march_type+'"'
end
set_prefix(i) click to toggle source
#

set_prefix

#
# File lib/rbt/misc/configure_string.rb, line 91
def set_prefix(i)
  @prefix = i
end
set_string(i)
set_target(target_type = 'i686-pc-linux-gnu') click to toggle source
#

set_target (target tag)

#
# File lib/rbt/misc/configure_string.rb, line 164
def set_target(target_type = 'i686-pc-linux-gnu')
  case target_type
  when :default, :linux
    target_type = 'i686-pc-linux-gnu'
  when :windows
    target_type = 'i686-pc-mingw32'
  when :currentwindows, :current_windows
    target_type = 'i586-mingw32'
  when :oldwindows, :old_windows
    target_type = 'i386-mingw32'
  when :sparc
    target_type = 'sparc-linux'
  when :ppc, :powerpc
    target_type = 'powerpc-linux'
  else
    if target_type.to_s.empty?
      target_type = 'i686-pc-linux-gnu'
    else # else, the user has a clear idea what he wants
      # so we pass through here simply
    end
  end
  append '--target="'+target_type.to_s+'"'
end
set_tune(tune_type = 'i686') click to toggle source
#

set_tune

No idea yet …

#
# File lib/rbt/misc/configure_string.rb, line 210
def set_tune(tune_type = 'i686')
  case tune_type
  when :default
    tune_type = 'i686'
  end
  append '--tune="'+tune_type+'"'
end
string()
Alias for: string?
string=(i)
string?() click to toggle source
#

string?

_() is an easier wrapper towards the @configure_string variable.

#
# File lib/rbt/misc/configure_string.rb, line 271
def string?
  @configure_string
end
Also aliased as: string, _