class CKick::Dependencies
Project
dependency settings, such as include path, library path, and compiler flags
Public Class Methods
-
args
-Dependencies
hash (directly the CKickfile :dependencies element parsed with keys as Symbol), must be aHash
Input hash keys¶ ↑
-
:cflags
- C language specific flags, for e.g. '-std=c89', '-Wall', etc., must be anArray
ofString
-
:cxxflags
- C++ language specific flags, for e.g. '-std=c++11', '-fno-exceptions', etc., must be anArray
ofString
-
: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
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
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
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
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
converts to Hash
(usable in CKickfile)
# File lib/ckick/dependencies.rb, line 53 def to_hash to_no_empty_value_hash end