Class: MxxRu::Cpp::QtGen
- Inherits:
-
AbstractGenerator
- Object
- AbstractGenerator
- MxxRu::Cpp::QtGen
- Defined in:
- lib/mxx_ru/cpp/qt.rb
Overview
Files generator for Qt class.
Main features:
-
building of moc-files using moc tool. Generation from source and header files is supported.
-
building source files from ui-files using uic-compiler. For all files generated this way moc tool executed automatically.
Generated source files automatically added into cpp_source list of target.
Local list defines is supported.
If only pointer to the target passed into contructor, default list of defines is used. If it’s required to change default list, new list should be passed through a second argument:
generator( MxxRu::Cpp::QtGen.new( self, [ "QT_THREAD_SUPPORT" ] ) )
Defined Under Namespace
Classes: UiNames
Constant Summary collapse
- DEFAULT_DEFINES =
Default list of defines. QT_DLL, QT_THREAD_SUPPORT
[ "QT_DLL", "QT_THREAD_SUPPORT" ]
Instance Attribute Summary collapse
-
#cpp_ext ⇒ Object
File extension for source files generated.
-
#hpp_ext ⇒ Object
File extension for header files generated.
-
#moc_ext ⇒ Object
File extension for moc files generated.
-
#moc_name ⇒ Object
moc tool executable Default: moc.
-
#moc_result_subdir ⇒ Object
Subfolder name where moc generated files would be located.
-
#qt_cpp2moc_files ⇒ Object
readonly
Files list for generating moc files from source files.
-
#qt_h2moc_files ⇒ Object
readonly
Files list for generating moc files from header files.
-
#qt_ui_files ⇒ Object
readonly
Files list for generating hpp, cpp and moc files from ui files.
-
#target ⇒ Object
readonly
Target, generator is created for.
-
#uic_name ⇒ Object
uic tool executable Default: uic.
-
#uic_result_subdir ⇒ Object
Subfolder name where results of uic invokation must be placed.
Instance Method Summary collapse
-
#build(a_target) ⇒ Object
Perform files generation.
-
#clean(a_target) ⇒ Object
Perform generated files cleanup.
-
#cpp2moc(a_file) ⇒ Object
Add a file for cpp to moc generation.
-
#h2moc(a_file) ⇒ Object
Add a file for hpp to moc generation.
-
#initialize(a_target, a_defines = DEFAULT_DEFINES) ⇒ QtGen
constructor
Constructor.
-
#ui(a_file) ⇒ Object
Add a file for ui to hpp, cpp and moc generation.
Constructor Details
#initialize(a_target, a_defines = DEFAULT_DEFINES) ⇒ QtGen
Constructor.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/mxx_ru/cpp/qt.rb', line 118 def initialize( a_target, a_defines = DEFAULT_DEFINES ) @moc_name = "moc" @uic_name = "uic" @cpp_ext = ".cpp" @hpp_ext = ".hpp" @moc_ext = ".moc" @moc_result_subdir = nil @uic_result_subdir = nil # If uic_result_subdir not nil than we must add # uic_result_subdir into # target include_path. But must do this only one time. @uic_result_subdir_include_paths = Set.new @qt_h2moc_files = Array.new @qt_cpp2moc_files = Array.new @qt_ui_files = Array.new defines_to_set = a_defines.flatten defines_to_set.each { |d| a_target.define( d ) } @target = a_target end |
Instance Attribute Details
#cpp_ext ⇒ Object
File extension for source files generated. Used in both moc and uic tools. Default: .cpp
74 75 76 |
# File 'lib/mxx_ru/cpp/qt.rb', line 74 def cpp_ext @cpp_ext end |
#hpp_ext ⇒ Object
File extension for header files generated. Used in uic tool. Default: .hpp
79 80 81 |
# File 'lib/mxx_ru/cpp/qt.rb', line 79 def hpp_ext @hpp_ext end |
#moc_ext ⇒ Object
File extension for moc files generated. Used in moc tool. Default: .moc
84 85 86 |
# File 'lib/mxx_ru/cpp/qt.rb', line 84 def moc_ext @moc_ext end |
#moc_name ⇒ Object
moc tool executable Default: moc
65 66 67 |
# File 'lib/mxx_ru/cpp/qt.rb', line 65 def moc_name @moc_name end |
#moc_result_subdir ⇒ Object
Subfolder name where moc generated files would be located. If nil, generated files would be in the same folder where source files were. Default: nil
90 91 92 |
# File 'lib/mxx_ru/cpp/qt.rb', line 90 def moc_result_subdir @moc_result_subdir end |
#qt_cpp2moc_files ⇒ Object (readonly)
Files list for generating moc files from source files.
More exact: a.cpp -> a.moc.
106 107 108 |
# File 'lib/mxx_ru/cpp/qt.rb', line 106 def qt_cpp2moc_files @qt_cpp2moc_files end |
#qt_h2moc_files ⇒ Object (readonly)
Files list for generating moc files from header files.
More exact: a.hpp -> moc_a.cpp. moc_a.cpp file is added to cpp_source list of a target.
101 102 103 |
# File 'lib/mxx_ru/cpp/qt.rb', line 101 def qt_h2moc_files @qt_h2moc_files end |
#qt_ui_files ⇒ Object (readonly)
Files list for generating hpp, cpp and moc files from ui files.
More exact: a.ui -> a.hpp, a.cpp, moc_a.cpp. a.cpp, moc_a.cpp files are added to cpp_source of a target.
112 113 114 |
# File 'lib/mxx_ru/cpp/qt.rb', line 112 def qt_ui_files @qt_ui_files end |
#target ⇒ Object (readonly)
Target, generator is created for.
115 116 117 |
# File 'lib/mxx_ru/cpp/qt.rb', line 115 def target @target end |
#uic_name ⇒ Object
uic tool executable Default: uic.
69 70 71 |
# File 'lib/mxx_ru/cpp/qt.rb', line 69 def uic_name @uic_name end |
#uic_result_subdir ⇒ Object
Subfolder name where results of uic invokation must be placed. If nil, generated files would be in the same folder where source ui files were.
95 96 97 |
# File 'lib/mxx_ru/cpp/qt.rb', line 95 def uic_result_subdir @uic_result_subdir end |
Instance Method Details
#build(a_target) ⇒ Object
Perform files generation.
167 168 169 170 171 |
# File 'lib/mxx_ru/cpp/qt.rb', line 167 def build( a_target ) build_from_ui( a_target ) build_from_h( a_target ) build_from_cpp( a_target ) end |
#clean(a_target) ⇒ Object
Perform generated files cleanup.
174 175 176 177 178 |
# File 'lib/mxx_ru/cpp/qt.rb', line 174 def clean( a_target ) clean_from_ui( a_target ) clean_from_h( a_target ) clean_from_cpp( a_target ) end |
#cpp2moc(a_file) ⇒ Object
Add a file for cpp to moc generation.
148 149 150 |
# File 'lib/mxx_ru/cpp/qt.rb', line 148 def cpp2moc( a_file ) @qt_cpp2moc_files << @target.create_full_src_file_name( a_file ) end |
#h2moc(a_file) ⇒ Object
Add a file for hpp to moc generation.
143 144 145 |
# File 'lib/mxx_ru/cpp/qt.rb', line 143 def h2moc( a_file ) @qt_h2moc_files << @target.create_full_src_file_name( a_file ) end |
#ui(a_file) ⇒ Object
Add a file for ui to hpp, cpp and moc generation.
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/mxx_ru/cpp/qt.rb', line 153 def ui( a_file ) full_file_name = @target.create_full_src_file_name( a_file ) @qt_ui_files << full_file_name if @uic_result_subdir uic_result_path = make_uic_result_path_for( full_file_name ) if !@uic_result_subdir_include_paths.member?( uic_result_path ) @target.include_path( uic_result_path ) @uic_result_subdir_include_paths.add( uic_result_path ) end end end |