class RBT::ConfigureString
Public Class Methods
Public Instance Methods
#¶ ↑
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 114 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
#¶ ↑
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 268 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
?¶ ↑
Contains the configure string object.
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 51 def configure_string? @configure_string end
#¶ ↑
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 303 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?¶ ↑
for @prefix? Dont set this to an attr_*writer!
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 291 def prefix? @prefix end
#¶ ↑
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 82 def sanitize_configure_string @configure_string.chomp! @configure_string.strip! @configure_string.squeeze!(' ') @configure_string.gsub!(/\n/, '') @configure_string.gsub!(/\.\/\.\//, './') # replace ././ with ./ end
#¶ ↑
set_build
¶ ↑
set_build
:mac (build tag)
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 197 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
¶ ↑
Use this method when setting @configure_string.
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 60 def set_configure_string(i) i = '' if i.nil? i = i.strip @configure_string = i end
#¶ ↑
set_host
¶ ↑
This sets the host type. It relies on symbols for special constructs.
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 131 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 tag)¶ ↑
Remember that if march=arch is set then -mcpu=arch is also honored.
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 229 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_target
(target tag)¶ ↑
#¶ ↑
# File lib/rbt/misc/configure_string.rb, line 166 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