class MxxRu::Cpp::RuCodeGen
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.add_embedded 'cfg.hpp'
Attributes
A list of code generation script names.
Target
, code generation is performed for.
Public Class Methods
Constructor.
- target
-
Target
, code generation is performed for.
# File lib/mxx_ru/cpp/rucodegen.rb, line 117 def initialize( target ) @target = target @scripts = [] end
Public Instance Methods
Adding a name of next code generation script.
# File lib/mxx_ru/cpp/rucodegen.rb, line 123 def <<( script ) @scripts << Standalone.new( @target.create_full_src_file_name( script ) ) end
Adding a name of next embeded code generation script.
# File lib/mxx_ru/cpp/rucodegen.rb, line 130 def add_embedded( script ) @scripts << Embedded.new( @target.create_full_src_file_name( script ) ) end
Perform code generation.
# 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
Perform cleanup of generated files.
# 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