class CBuildGems::Config_Build

Attributes

build_str[R]

The string with the compiler options.

debug_mode[RW]

If true(default) then -g is passed into build_str to include debuging data. So it can be used with GDB for debugging.

Public Class Methods

new(config_yml) click to toggle source
Calls superclass method CBuildGems::Build::new
# File lib/config_build.rb, line 8
def initialize(config_yml)
  super(config_yml)

  @build_str = "gcc "
  @debug_mode = true
end

Public Instance Methods

if_include(key) { || ... } click to toggle source

If complier_opts includes the the passed in key than is yields what whatever is in the code block.

@param key [String] complier_opts key to test. @yield [] Actions to follow . @return [Nil]

# File lib/config_build.rb, line 21
def if_include(key)
  yield if @complier_opts.keys.include?(key)
end
set_c_flags() click to toggle source

Sets each C flag to build_str from c_flags.

@return [Nil] @see Build#c_flags @see build_str

# File lib/config_build.rb, line 30
def set_c_flags
  @c_flags.each do |i|
    build_str.concat("#{i}\s")
  end

  nil
end
set_include_paths() click to toggle source

Sets each include path to build_str from c_flags.

@return [Nil] @see Build#include @see build_str

# File lib/config_build.rb, line 43
def set_include_paths
  if_include("include") do
    inc = 0

    @include.each do |l|
      build_str.concat("-I"+@include[inc] + "\s")
      inc += 1
    end
  end

  nil
end
set_libs() click to toggle source

Sets each library to build_str from libs.

@return [Nil] @see Build#libs @see build_str

# File lib/config_build.rb, line 89
def set_libs
  if_include("libs") do
    inc = 0

    @libs.each do |l|
      if l.include?(".a") || l.include?(".so")
        build_str.concat(@libs[inc] + "\s")
      else
        build_str.concat("-l"+@libs[inc] + "\s")
      end
      inc += 1
    end
  end

  nil
end
set_output(bins_index) click to toggle source

Sets an output(executable/binary) to build_str from @bins.

@param bins_index [Fixnum] the binary in the bins array. @return [Nil] @see Build#bins @see build_str

# File lib/config_build.rb, line 78
def set_output(bins_index)
  build_str.concat("#{@bins[bins_index]}\s")

  nil
end
set_pkg_config() click to toggle source

Sets each package to build_str from pkgc.

@return [Nil] @see Build#pkgc @see build_str

# File lib/config_build.rb, line 111
def set_pkg_config
  if_include("pkg_config") do
    build_str.concat("`pkg-config --cflags --libs ")

    @pkgc.each do |p|
      build_str.concat("#{p}" + "\s")
    end

    build_str.concat "`"
  end

  nil
end
set_src_path(src_index) click to toggle source

Sets a source path to build_str from src.

@param src_index [Fixnum] the source in the src array. @return [Nil] @see Build#src @see build_str

# File lib/config_build.rb, line 62
def set_src_path(src_index)
  if debug_mode
    build_str.concat("-g #{@src[src_index]} -o\s")
  else
    build_str.concat("#{@src[src_index]} -o\s")
  end

  nil
end