Class: Cxx::EvalContext
- Inherits:
-
Object
- Object
- Cxx::EvalContext
- Extended by:
- Deprecated
- Includes:
- Cxxproject, Cxxproject::Context
- Defined in:
- lib/cxx/eval_context.rb
Instance Attribute Summary collapse
-
#all_blocks ⇒ Object
Returns the value of attribute all_blocks.
Instance Method Summary collapse
- #attach_includes(hash, bblock) ⇒ Object
- #attach_sources(hash, bblock) ⇒ Object
- #attach_tags(hash, bblock) ⇒ Object
- #bin_lib(name, hash = Hash.new) ⇒ Object
-
#bin_libs(names, hash = Hash.new) ⇒ Object
specify some binary libs returns all binary libs as array.
- #compile(name, hash) ⇒ Object
- #custom(name, hash) ⇒ Object
-
#cxx_configuration(&block) ⇒ Object
must be called to add building blocks.
- #eval_project(project_text, project_file, pwd) ⇒ Object
-
#exe(name, hash) ⇒ Object
specify an executable hash supports: * :sources * :includes * :dependencies * :output_dir.
-
#shared_lib(name, hash) ⇒ Object
specify an executable hash supports: * :sources * :includes * :dependencies * :output_dir * :tags * :major * :minor * :compatibility.
-
#static_lib(name, hash) ⇒ Object
specify a static library hash supports: * :sources * :includes * :dependencies * :toolchain * :file_dependencies * :output_dir * :whole_archive * :tags.
Instance Attribute Details
#all_blocks ⇒ Object
Returns the value of attribute all_blocks.
12 13 14 |
# File 'lib/cxx/eval_context.rb', line 12 def all_blocks @all_blocks end |
Instance Method Details
#attach_includes(hash, bblock) ⇒ Object
37 38 39 |
# File 'lib/cxx/eval_context.rb', line 37 def attach_includes(hash,bblock) bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes) end |
#attach_sources(hash, bblock) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cxx/eval_context.rb', line 26 def attach_sources(hash,bblock) if hash.has_key?(:sources) ss = hash[:sources] if ss.class == Array || ss.class == Rake::FileList bblock.set_sources(ss) else raise "sources need to be given in an Array or FileList, not a #{ss.class}" end end end |
#attach_tags(hash, bblock) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/cxx/eval_context.rb', line 41 def (hash, bblock) bblock. = Set.new if hash.has_key?(:tags) bblock. = hash[:tags].to_set end end |
#bin_lib(name, hash = Hash.new) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/cxx/eval_context.rb', line 137 def bin_lib(name, hash=Hash.new) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash, [:includes, :lib_path]) bblock = Cxxproject::BinaryLibrary.new(name) attach_includes(hash,bblock) bblock.add_lib_element(Cxxproject::HasLibraries::SEARCH_PATH, hash[:lib_path], true) if hash.has_key?(:lib_path) return bblock end |
#bin_libs(names, hash = Hash.new) ⇒ Object
specify some binary libs returns all binary libs as array
149 150 151 152 153 154 155 |
# File 'lib/cxx/eval_context.rb', line 149 def bin_libs(names, hash=Hash.new) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash, [:includes, :lib_path]) mapped = names.map{|n|n.to_s} return mapped.map{|name|bin_lib(name, hash)} end |
#compile(name, hash) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/cxx/eval_context.rb', line 157 def compile(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash,[:sources,:includes]) bblock = Cxxproject::SingleSource.new(name) attach_sources(hash,bblock) attach_includes(hash,bblock) all_blocks << bblock end |
#custom(name, hash) ⇒ Object
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/cxx/eval_context.rb', line 166 def custom(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash,[:execute, :dependencies]) bblock = Cxxproject::CustomBuildingBlock.new(name) bblock.set_actions(hash[:execute]) if hash.has_key?(:execute) if hash.has_key?(:dependencies) bblock.set_dependencies(hash[:dependencies]) end all_blocks << bblock end |
#cxx_configuration(&block) ⇒ Object
must be called to add building blocks
15 16 17 18 |
# File 'lib/cxx/eval_context.rb', line 15 def cxx_configuration(&block) @all_blocks = [] block.call end |
#eval_project(project_text, project_file, pwd) ⇒ Object
20 21 22 23 24 |
# File 'lib/cxx/eval_context.rb', line 20 def eval_project(project_text, project_file, pwd) @current_project_file = project_file @current_working_dir = pwd instance_eval(project_text) end |
#exe(name, hash) ⇒ Object
specify an executable hash supports:
-
:sources
-
:includes
-
:dependencies
-
:output_dir
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cxx/eval_context.rb', line 54 def exe(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash,[:sources,:includes,:dependencies,:libpath,:output_dir, :tags]) bblock = Cxxproject::Executable.new(name) attach_sources(hash,bblock) attach_includes(hash,bblock) (hash, bblock) if hash.has_key?(:dependencies) bblock.set_dependencies(hash[:dependencies]) hash[:dependencies].each { |d| bblock.add_lib_element(Cxxproject::HasLibraries::DEPENDENCY, d) } end bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir) all_blocks << bblock bblock end |
#shared_lib(name, hash) ⇒ Object
specify an executable hash supports:
-
:sources
-
:includes
-
:dependencies
-
:output_dir
-
:tags
-
:major
-
:minor
-
:compatibility
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cxx/eval_context.rb', line 80 def shared_lib(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash, [:sources, :includes, :dependencies, :output_dir, :tags, :major, :minor, :compatibility]) raise "add the :major version to shared library #{name}" unless not hash.has_key?(:minor) or hash.has_key?(:major) bblock = Cxxproject::SharedLibrary.new(name) attach_sources(hash,bblock) attach_includes(hash,bblock) (hash, bblock) if hash.has_key?(:dependencies) bblock.set_dependencies(hash[:dependencies]) hash[:dependencies].each { |d| bblock.add_lib_element(Cxxproject::HasLibraries::DEPENDENCY, d) } end if hash.has_key?(:minor) bblock.minor = hash[:minor] end if hash.has_key?(:major) bblock.major = hash[:major] end if hash.has_key?(:compatibility) bblock.compatibility = hash[:compatibility] end bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir) all_blocks << bblock bblock end |
#static_lib(name, hash) ⇒ Object
specify a static library hash supports:
-
:sources
-
:includes
-
:dependencies
-
:toolchain
-
:file_dependencies
-
:output_dir
-
:whole_archive
-
:tags
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/cxx/eval_context.rb', line 116 def static_lib(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash, [:sources, :includes, :dependencies, :toolchain, :file_dependencies, :output_dir, :whole_archive, :tags]) raise ":sources need to be defined" unless hash.has_key?(:sources) bblock = Cxxproject::StaticLibrary.new(name, hash[:whole_archive]) attach_sources(hash,bblock) attach_includes(hash,bblock) (hash, bblock) bblock.set_tcs(hash[:toolchain]) if hash.has_key?(:toolchain) if hash.has_key?(:dependencies) bblock.set_dependencies(hash[:dependencies]) hash[:dependencies].each { |d| bblock.add_lib_element(Cxxproject::HasLibraries::DEPENDENCY, d) } end bblock.file_dependencies = hash[:file_dependencies] if hash.has_key?(:file_dependencies) bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir) all_blocks << bblock bblock end |