class CKick::Dependencies

Project dependency settings, such as include path, library path, and compiler flags

Public Class Methods

new(args={}) click to toggle source
  • args - Dependencies hash (directly the CKickfile :dependencies element parsed with keys as Symbol), must be a Hash

Input hash keys
  • :cflags - C language specific flags, for e.g. '-std=c89', '-Wall', etc., must be an Array of String

  • :cxxflags - C++ language specific flags, for e.g. '-std=c++11', '-fno-exceptions', etc., must be an Array of String

  • :include - Array of paths to append the include path (-I compiler option; include_directories() CMake command)

  • :lib - Array of paths to append the link path (-L compiler option; link_directories() CMake command)

# File lib/ckick/dependencies.rb, line 24
def initialize args={}
  raise IllegalInitializationError unless args.is_a?(Hash)

  cflags = args[:cflags] || []
  raise IllegalInitializationError, "cflags provided to dependencies is not an Array" unless cflags.is_a?(Array)
  @cflags = cflags.collect do |flag|
    CFlag.new(flag: flag)
  end

  cxxflags = args[:cxxflags] || []
  raise IllegalInitializationError, "cxxflags provided to dependencied is not an Array" unless cxxflags.is_a?(Array)
  @cxxflags = cxxflags.collect do |flag|
    CXXFlag.new(flag: flag)
  end

  includes = args[:include] || []
  raise IllegalInitializationError, "include provided to dependencies is not an Array" unless includes.is_a?(Array)
  @include = includes.collect do |include|
    IncludePath.new(path: include)
  end

  libs = args[:lib] || []
  raise IllegalInitializationError, "lib provided to dependencies is not an Array" unless libs.is_a?(Array)
  @lib = libs.collect do |lib|
    LibraryPath.new(path: lib)
  end
end

Public Instance Methods

add_include(path) click to toggle source

appends include path (-I) with path

path - include path, must be a CKick::IncludePath

# File lib/ckick/dependencies.rb, line 74
def add_include(path)
  raise BadIncludePathError, "path must be a CKick::IncludePath object" unless path.is_a?(IncludePath)
  @include << path unless @include.include?(path)
end
add_lib(path) click to toggle source

appends link path (-L) with path

path - link path, must be a CKick::LibraryPath

# File lib/ckick/dependencies.rb, line 82
def add_lib(path)
  raise BadLibraryPathError, "path must be a CKick::LibraryPath object" unless path.is_a?(LibraryPath)
  @lib << path unless @lib.include?(path)
end
cmake() click to toggle source

CMakeLists's section content

# File lib/ckick/dependencies.rb, line 58
def cmake
  [@cflags, @cxxflags, @include, @lib].flatten(1).collect do |unit|
      unit.cmake
  end.join("\n")
end
flags() click to toggle source

compiler flags in an Array

# File lib/ckick/dependencies.rb, line 65
def flags
  [@cflags, @cxxflags, @include, @lib].flatten(1).uniq.collect do |flag|
    flag.raw_flag
  end
end
to_hash() click to toggle source

converts to Hash (usable in CKickfile)

# File lib/ckick/dependencies.rb, line 53
def to_hash
  to_no_empty_value_hash
end