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 = {}) ⇒ Object
-
#bin_libs(*names) ⇒ Object
specify some binary libs returns all binary libs as array.
- #calc_lib_searchpath(hash) ⇒ Object
- #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 * :libpath * :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.
22 23 24 |
# File 'lib/cxx/eval_context.rb', line 22 def all_blocks @all_blocks end |
Instance Method Details
#bin_lib(name, hash = {}) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/cxx/eval_context.rb', line 95 def bin_lib(name, hash={}) 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) end |
#bin_libs(*names) ⇒ Object
specify some binary libs returns all binary libs as array
105 106 107 108 109 110 111 112 |
# File 'lib/cxx/eval_context.rb', line 105 def bin_libs(*names) res = [] mapped = names.map{|n|n.to_s} mapped.each do |name| res << Cxxproject::BinaryLibrary.new(name) end mapped end |
#calc_lib_searchpath(hash) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cxx/eval_context.rb', line 58 def calc_lib_searchpath(hash) if hash.has_key?(:libpath) hash[:libpath] else if Cxxproject::Utils::OS.linux? || Cxxproject::Utils::OS.mac? ["/usr/local/lib","/usr/lib"] elsif Cxxproject::Utils::OS.windows? ["C:/tool/cygwin/lib", "C:/Tool/cygwin/usr/local/lib"] end end end |
#compile(name, hash) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/cxx/eval_context.rb', line 114 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
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cxx/eval_context.rb', line 123 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
25 26 27 28 |
# File 'lib/cxx/eval_context.rb', line 25 def cxx_configuration(&block) @all_blocks = [] block.call end |
#eval_project(project_text, project_file, pwd) ⇒ Object
30 31 32 33 34 |
# File 'lib/cxx/eval_context.rb', line 30 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
-
:libpath
-
:output_dir
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cxx/eval_context.rb', line 43 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) calc_lib_searchpath(hash).each { |sp| bblock.add_lib_element(Cxxproject::HasLibraries::SEARCH_PATH, sp) } 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
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cxx/eval_context.rb', line 78 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 |