Class: Cxx::EvalContext
- Inherits:
-
Object
- Object
- Cxx::EvalContext
- 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
- #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.
-
#source_lib(name, hash) ⇒ Object
specify a sourcelib hash supports: * :sources * :includes * :dependencies * :toolchain * :file_dependencies * :output_dir.
Instance Attribute Details
#all_blocks ⇒ Object
Returns the value of attribute all_blocks.
10 11 12 |
# File 'lib/cxx/eval_context.rb', line 10 def all_blocks @all_blocks end |
Instance Method Details
#bin_lib(name, hash = Hash.new) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/cxx/eval_context.rb', line 69 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) bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes) 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
81 82 83 84 85 86 87 |
# File 'lib/cxx/eval_context.rb', line 81 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
89 90 91 92 93 94 95 96 |
# File 'lib/cxx/eval_context.rb', line 89 def compile(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash,[:sources,:includes]) bblock = Cxxproject::SingleSource.new(name) bblock.set_sources(hash[:sources]) if hash.has_key?(:sources) bblock.set_includes(hash[:includes]) if hash.has_key?(:includes) all_blocks << bblock end |
#custom(name, hash) ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/cxx/eval_context.rb', line 98 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
13 14 15 16 |
# File 'lib/cxx/eval_context.rb', line 13 def cxx_configuration(&block) @all_blocks = [] block.call end |
#eval_project(project_text, project_file, pwd) ⇒ Object
18 19 20 21 22 |
# File 'lib/cxx/eval_context.rb', line 18 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
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cxx/eval_context.rb', line 30 def exe(name, hash) raise "not a hash" unless hash.is_a?(Hash) check_hash(hash,[:sources,:includes,:dependencies,:libpath,:output_dir]) bblock = Cxxproject::Executable.new(name) bblock.set_sources(hash[:sources]) if hash.has_key?(:sources) bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes) 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 end |
#source_lib(name, hash) ⇒ Object
specify a sourcelib hash supports:
-
:sources
-
:includes
-
:dependencies
-
:toolchain
-
:file_dependencies
-
:output_dir
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cxx/eval_context.rb', line 52 def source_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]) raise ":sources need to be defined" unless hash.has_key?(:sources) bblock = Cxxproject::SourceLibrary.new(name, hash[:whole_archive]) bblock.set_sources(hash[:sources]) bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes) 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 end |