Class: MxxRu::Cpp::RuCodeGen
- Inherits:
-
AbstractGenerator
- Object
- AbstractGenerator
- MxxRu::Cpp::RuCodeGen
- Defined in:
- lib/mxx_ru/cpp/rucodegen.rb
Overview
Generator intended to use generators based on RuCodeGen in C++ projects.
The attachment of the given generator to the C++ projects consists in that it allows sources_root value be taken into account during a work with names of code generation scripts.
For example, for my_prj/pub.rb and my_prj/impl/details.rb code generation scripts:
require 'mxx_ru/cpp'
require 'mxx_ru/cpp/rucodegen'
MxxRu::setup_target( MxxRu::Cpp::ExeTarget.new( "my_prj/prj.rb" ) {
...
rucodegen = generator( MxxRu::Cpp::RuCodeGen.new( self ) )
...
rucodegen << "pub.rb"
...
sources_root( "impl" ) {
rucodegen << "details.rb"
...
}
...
})
NOTE. RuCodeGen#add method may be used instead of shift operator for adding next code generation script
rucodegen.add "details.rb"
Since RuCodeGen 0.2.0 embeded scripts supported by RuCodeGen#add_embedded method:
rucodegen. 'cfg.hpp'
Defined Under Namespace
Classes: Embedded, Script, Standalone
Instance Attribute Summary collapse
-
#scripts ⇒ Object
readonly
A list of code generation script names.
-
#target ⇒ Object
readonly
Target, code generation is performed for.
Instance Method Summary collapse
-
#<<(script) ⇒ Object
(also: #add)
Adding a name of next code generation script.
-
#add_embedded(script) ⇒ Object
(also: #add_embeded)
Adding a name of next embeded code generation script.
-
#build(target) ⇒ Object
Perform code generation.
-
#clean(target) ⇒ Object
Perform cleanup of generated files.
-
#initialize(target) ⇒ RuCodeGen
constructor
Constructor.
Constructor Details
#initialize(target) ⇒ RuCodeGen
Constructor.
- target
-
Target, code generation is performed for.
117 118 119 120 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 117 def initialize( target ) @target = target @scripts = [] end |
Instance Attribute Details
#scripts ⇒ Object (readonly)
A list of code generation script names.
111 112 113 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 111 def scripts @scripts end |
#target ⇒ Object (readonly)
Target, code generation is performed for.
108 109 110 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 108 def target @target end |
Instance Method Details
#<<(script) ⇒ Object Also known as: add
Adding a name of next code generation script.
123 124 125 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 123 def <<( script ) @scripts << Standalone.new( @target.create_full_src_file_name( script ) ) end |
#add_embedded(script) ⇒ Object Also known as: add_embeded
Adding a name of next embeded code generation script.
130 131 132 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 130 def ( script ) @scripts << Embedded.new( @target.create_full_src_file_name( script ) ) end |
#build(target) ⇒ Object
Perform code generation.
137 138 139 140 141 142 143 144 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 137 def build( target ) @scripts.each do |s| AbstractTarget.run( [ s.build_cmd( :build ) ], [], "running code generation script #{s} (build mode)" ) end end |
#clean(target) ⇒ Object
Perform cleanup of generated files.
147 148 149 150 151 152 153 154 |
# File 'lib/mxx_ru/cpp/rucodegen.rb', line 147 def clean( target ) @scripts.each do |s| AbstractTarget.run( [ s.build_cmd( :clean ) ], [], "running code generation script #{s} (clean mode)" ) end end |