Mxx_ru 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. data/COPYING +26 -26
  2. data/NEWS +107 -107
  3. data/README +21 -21
  4. data/Rakefile +56 -59
  5. data/examples/exe_and_lib/prj.rb +11 -11
  6. data/examples/exe_and_lib/say.rb +7 -7
  7. data/examples/exe_dll_lib/inout.rb +18 -18
  8. data/examples/exe_dll_lib/prj.rb +11 -11
  9. data/examples/exe_dll_lib/say.rb +9 -9
  10. data/examples/exe_dll_lib_2/build.rb +10 -10
  11. data/examples/exe_dll_lib_2/inout/prj.rb +16 -16
  12. data/examples/exe_dll_lib_2/main/prj.rb +9 -9
  13. data/examples/exe_dll_lib_2/say/prj.rb +8 -8
  14. data/examples/simple_exe/prj.rb +7 -7
  15. data/lib/mxx_ru/abstract_target.rb +335 -335
  16. data/lib/mxx_ru/binary_library.rb +106 -106
  17. data/lib/mxx_ru/binary_target.rb +173 -173
  18. data/lib/mxx_ru/binary_unittest.rb +143 -143
  19. data/lib/mxx_ru/compat.rb +33 -33
  20. data/lib/mxx_ru/cpp.rb +38 -38
  21. data/lib/mxx_ru/cpp/analyzer.rb +237 -237
  22. data/lib/mxx_ru/cpp/composite.rb +118 -118
  23. data/lib/mxx_ru/cpp/detect_toolset.rb +122 -122
  24. data/lib/mxx_ru/cpp/mode.rb +90 -90
  25. data/lib/mxx_ru/cpp/obj_placement.rb +330 -330
  26. data/lib/mxx_ru/cpp/obj_placements/custom_subdir.rb +155 -155
  27. data/lib/mxx_ru/cpp/qt.rb +366 -366
  28. data/lib/mxx_ru/cpp/rucodegen.rb +157 -157
  29. data/lib/mxx_ru/cpp/source_file.rb +79 -79
  30. data/lib/mxx_ru/cpp/target.rb +1523 -1523
  31. data/lib/mxx_ru/cpp/toolset.rb +1087 -1087
  32. data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +53 -53
  33. data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +460 -460
  34. data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +59 -59
  35. data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +59 -59
  36. data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +277 -277
  37. data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +58 -58
  38. data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +420 -424
  39. data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +64 -64
  40. data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +150 -150
  41. data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +91 -91
  42. data/lib/mxx_ru/cpp/toolsets/gcc_unix_family.rb +103 -84
  43. data/lib/mxx_ru/cpp/toolsets/vc7.rb +62 -62
  44. data/lib/mxx_ru/cpp/toolsets/vc8.rb +455 -455
  45. data/lib/mxx_ru/cpp/toolsets/vc_family.rb +448 -448
  46. data/lib/mxx_ru/ex.rb +165 -165
  47. data/lib/mxx_ru/makestyle_generator.rb +146 -146
  48. data/lib/mxx_ru/textfile_unittest.rb +303 -303
  49. data/lib/mxx_ru/util.rb +340 -340
  50. data/tests/c/pcre/chartables.c +183 -183
  51. data/tests/c/pcre/config.h +99 -99
  52. data/tests/c/pcre/dftables.c +167 -167
  53. data/tests/c/pcre/get.c +349 -349
  54. data/tests/c/pcre/internal.h +677 -677
  55. data/tests/c/pcre/maketables.c +140 -140
  56. data/tests/c/pcre/pcre.c +8304 -8304
  57. data/tests/c/pcre/pcre.h +193 -193
  58. data/tests/c/pcre/pcre.rb +14 -14
  59. data/tests/c/pcre/pcredemo.c +316 -316
  60. data/tests/c/pcre/pcregrep.c +642 -642
  61. data/tests/c/pcre/pcreposix.c +305 -305
  62. data/tests/c/pcre/pcreposix.h +88 -88
  63. data/tests/c/pcre/pcretest.c +1483 -1483
  64. data/tests/c/pcre/perltest +211 -211
  65. data/tests/c/pcre/printint.c +360 -360
  66. data/tests/c/pcre/study.c +472 -472
  67. data/tests/cpp/cpp_sources_glob/build.rb +7 -7
  68. data/tests/cpp/cpp_sources_glob/some/module/prj.rb +10 -10
  69. data/tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb +18 -18
  70. data/tests/cpp/mswin_res_dll/build.rb +14 -14
  71. data/tests/cpp/mswin_res_dll/dll.cpp +17 -17
  72. data/tests/cpp/mswin_res_dll/dll.rb +29 -29
  73. data/tests/cpp/mswin_res_dll/dll.rc +48 -48
  74. data/tests/cpp/mswin_res_dll/h/dll.hpp +8 -8
  75. data/tests/cpp/mswin_res_dll/h/res.h +3 -3
  76. data/tests/cpp/mswin_res_dll/main.cpp +13 -13
  77. data/tests/cpp/mswin_res_dll/main.rb +19 -19
  78. data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -18
  79. data/tests/cpp/mswin_res_exe/build.rb +23 -23
  80. data/tests/cpp/mswin_res_exe/h/res.h +3 -3
  81. data/tests/cpp/mswin_res_exe/main.cpp +17 -17
  82. data/tests/cpp/mswin_res_exe/main.rc +48 -48
  83. data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -18
  84. data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -32
  85. data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -7
  86. data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -14
  87. data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -10
  88. data/tests/cpp/rucodegen.embedded/prj.rb +16 -16
  89. data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -18
  90. data/tests/cpp/rucodegen/host_config.cpp +20 -20
  91. data/tests/cpp/rucodegen/host_config.rb +14 -14
  92. data/tests/cpp/rucodegen/impl/conn_params.cpp +7 -7
  93. data/tests/cpp/rucodegen/impl/conn_params.rb +14 -14
  94. data/tests/cpp/rucodegen/impl/h/conn_params.hpp +10 -10
  95. data/tests/cpp/rucodegen/prj.rb +16 -16
  96. data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -18
  97. data/tests/cpp/textfile_unittest/build.rb +8 -8
  98. data/tests/cpp/textfile_unittest/etalons/out_1.txt +1 -1
  99. data/tests/cpp/textfile_unittest/etalons/out_128.txt +128 -128
  100. data/tests/cpp/textfile_unittest/main.cpp +89 -89
  101. data/tests/cpp/textfile_unittest/prj.rb +8 -8
  102. data/tests/cpp/textfile_unittest/prj.ut.rb +18 -18
  103. data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -18
  104. data/tests/cpp/toolset_name.rb +6 -6
  105. data/tests/cpp/vc_cleanup/prj_dll_no_implib.rb +10 -10
  106. data/tests/cpp/vc_cleanup/prj_dll_no_implib_simple_target_root.rb +11 -11
  107. data/tests/cpp/vc_cleanup/prj_dll_with_implib.rb +11 -11
  108. data/tests/cpp/vc_cleanup/prj_dll_with_implib_simple_target_root.rb +14 -14
  109. data/tests/cpp/vc_cleanup/prj_exe_no_implib.rb +10 -10
  110. data/tests/cpp/vc_cleanup/prj_exe_no_implib_simple_target_root.rb +11 -11
  111. data/tests/cpp/vc_cleanup/prj_lib.rb +10 -10
  112. data/tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb +11 -11
  113. data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +23 -23
  114. data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -57
  115. data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -114
  116. data/tests/mxx_ru/change_default_value/ignoring_by_build_root/build.rb +8 -8
  117. data/tests/mxx_ru/change_default_value/ignoring_by_build_root/child_1.rb +5 -5
  118. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/build.rb +7 -7
  119. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_1.rb +5 -5
  120. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_2.rb +5 -5
  121. data/tests/mxx_ru/change_default_value/ok/build.rb +8 -8
  122. data/tests/mxx_ru/change_default_value/ok/child_1.rb +8 -8
  123. data/tests/mxx_ru/lib_path/build.rb +8 -8
  124. data/tests/mxx_ru/lib_path/bye.rb +8 -8
  125. data/tests/mxx_ru/lib_path/hi.rb +8 -8
  126. data/tests/mxx_ru/lib_path/main.rb +12 -12
  127. data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -18
  128. data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -58
  129. data/tests/mxx_ru/opt_lib_ext/build.rb +7 -7
  130. data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -7
  131. data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -18
  132. data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -9
  133. data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -13
  134. data/tests/mxx_ru/plural_form_methods/tc.rb +72 -72
  135. data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -76
  136. data/tests/mxx_ru/target_ext/prj_dll.rb +8 -8
  137. data/tests/mxx_ru/target_ext/prj_exe.rb +8 -8
  138. data/tests/mxx_ru/target_ext/prj_lib.rb +8 -8
  139. data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -24
  140. data/tests/mxx_ru/tc_makestyle_generator.rb +117 -117
  141. data/tests/mxx_ru/vc8/tc_actual_manifest.rb +230 -230
  142. data/tests/mxx_ru/vc8/tc_append_mt_commands.rb +104 -104
  143. data/tests/mxx_ru/vc8/tc_default_manifest.rb +17 -17
  144. data/tests/mxx_ru/vc8/tc_define_manifest.rb +173 -173
  145. data/tests/mxx_ru/vc8/tc_drop_default_manifest.rb +16 -16
  146. data/tests/mxx_ru/vc8/tc_invalid_params.rb +81 -81
  147. data/tests/mxx_ru/vc8/ts_vc8.rb +10 -10
  148. data/tests/qt/aclock/aclock.cpp +148 -148
  149. data/tests/qt/aclock/aclock.h +45 -45
  150. data/tests/qt/aclock/main.cpp +28 -28
  151. data/tests/qt/aclock/prj.rb +21 -21
  152. data/tests/qt/iconview/main.cpp +76 -76
  153. data/tests/qt/iconview/prj.rb +21 -21
  154. data/tests/qt/toplevel/main.cpp +9 -9
  155. data/tests/qt/toplevel/options.ui +587 -587
  156. data/tests/qt/toplevel/prj.rb +22 -22
  157. data/tests/test_with_compilation.rb +110 -110
  158. data/tests/unix/lib_linking_mode/a_shared.rb +7 -7
  159. data/tests/unix/lib_linking_mode/a_static.rb +7 -7
  160. data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -2
  161. data/tests/unix/lib_linking_mode/etalon/static.txt +2 -2
  162. data/tests/unix/lib_linking_mode/main_conflict.rb +12 -12
  163. data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -11
  164. data/tests/unix/lib_linking_mode/main_shared.rb +9 -9
  165. data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -11
  166. data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -10
  167. data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -11
  168. data/tests/unix/lib_linking_mode/main_static.rb +9 -9
  169. data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -11
  170. data/tests/unix/lib_linking_mode/main_static_2.rb +10 -10
  171. data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -11
  172. data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -18
  173. data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -18
  174. data/tests/unix/lib_order/a.cpp +4 -0
  175. data/tests/unix/lib_order/a.hpp +1 -0
  176. data/tests/unix/lib_order/a.rb +8 -0
  177. data/tests/unix/lib_order/b.cpp +10 -0
  178. data/tests/unix/lib_order/b.hpp +1 -0
  179. data/tests/unix/lib_order/b.rb +8 -0
  180. data/tests/unix/lib_order/build.rb +9 -0
  181. data/tests/unix/lib_order/c.cpp +12 -0
  182. data/tests/unix/lib_order/c.hpp +2 -0
  183. data/tests/unix/lib_order/c.rb +8 -0
  184. data/tests/unix/lib_order/d.cpp +7 -0
  185. data/tests/unix/lib_order/d.hpp +1 -0
  186. data/tests/unix/lib_order/d.rb +8 -0
  187. data/tests/unix/lib_order/main.cpp +7 -0
  188. data/tests/unix/lib_order/main.rb +14 -0
  189. data/tests/unix/lib_order/tc_normal_build.rb +16 -0
  190. metadata +342 -319
@@ -1,155 +1,155 @@
1
- #--
2
- # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
- # Copyright (c) 2004-2006, JSC Intervale
4
- # Copyright (c) 2006, The Mxx_ru Project
5
- # All rights reserved.
6
- #
7
- # Redistribution and use in source and binary forms, with or without modification,
8
- # are permitted provided that the following conditions are met:
9
- #
10
- # 1. Redistributions of source code must retain the above copyright notice,
11
- # this list of conditions and the following disclaimer.
12
- # 2. Redistributions in binary form must reproduce the above copyright notice,
13
- # this list of conditions and the following disclaimer in the documentation
14
- # and/or other materials provided with the distribution.
15
- # 3. The name of the author may not be used to endorse or promote products derived
16
- # from this software without specific prior written permission.
17
- #
18
- # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
- # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
- # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- #++
28
-
29
- require 'mxx_ru/util'
30
- require 'mxx_ru/cpp/obj_placement'
31
-
32
- module MxxRu
33
-
34
- module Cpp
35
-
36
- # Analog of RuntimeSubdirObjPlacement, but allow to specify
37
- # paths for final results (EXE, LIB, DLL) and intermediate files (OBJ, RES).
38
- # Unlike RuntimeSubdirObjPlacement these paths are independent of
39
- # runtime_mode.
40
- #
41
- # Example:
42
- # MxxRu::Cpp::composite_target {
43
- # global_obj_placement MxxRu::Cpp::CustomSubdirObjPlacement.new(
44
- # # Final resuls going here.
45
- # 'bin32',
46
- # # All intermediate files going here.
47
- # 'tmp/output32' )
48
- #
49
- # required_prj ...
50
- # }
51
- # If this composite project will be applied for project structure:
52
- # prj_1/
53
- # `- src/
54
- # prj_2/
55
- # `- module_1/
56
- # `- module_2/
57
- # Then after build project structructure will be:
58
- # prj_1/
59
- # `- src/
60
- # prj_2/
61
- # `- module_1/
62
- # `- module_2/
63
- # bin32/
64
- # tmp/
65
- # `- output32/
66
- # `- prj_1/
67
- # | `- src/
68
- # `- prj_2/
69
- # `- module_1/
70
- # `- module_2/
71
- #
72
- class CustomSubdirObjPlacement < ObjPlacement
73
- # Constructor
74
- #
75
- # [_final_results_path_] path for storing final results (EXE, LIB/A, DLL/SO).
76
- # [_intermediate_path_] path for storing intermediate files (OBJ/O, RES).
77
- def initialize( final_results_path, intermediate_path )
78
- @final_results_path = final_results_path
79
- @intermediate_path = intermediate_path
80
- end
81
-
82
- # Make name for obj file.
83
- def get_obj(
84
- source_path_name,
85
- toolset,
86
- target )
87
-
88
- if source_path_name &&
89
- "" != source_path_name &&
90
- "." != source_path_name
91
- result = File.join( @intermediate_path, source_path_name )
92
- else
93
- result = @intermediate_path
94
- end
95
-
96
- MxxRu::Util.ensure_path_exists( result )
97
-
98
- return result
99
- end
100
-
101
- # Returns result of get_obj method.
102
- def get_mswin_res(
103
- source_path_name,
104
- toolset,
105
- target )
106
-
107
- return get_obj( source_path_name, toolset, target )
108
- end
109
-
110
- # Returns final_results_path
111
- def get_lib(
112
- source_path_name,
113
- toolset,
114
- target )
115
-
116
- final_result_path_component( source_path_name )
117
- end
118
-
119
- # Returns final_results_path
120
- def get_dll(
121
- source_path_name,
122
- toolset,
123
- target )
124
-
125
- final_result_path_component( source_path_name )
126
- end
127
-
128
- # Returns final_results_path
129
- def get_exe(
130
- source_path_name,
131
- toolset,
132
- target )
133
-
134
- final_result_path_component( source_path_name )
135
- end
136
-
137
- protected
138
- # Make final_results_path if needed and return name of it
139
- def final_result_path_component( target_root )
140
- r = @final_results_path
141
- r = File.join( @final_results_path, target_root ) if
142
- target_root and target_root.size
143
- MxxRu::Util::ensure_path_exists( r )
144
- r
145
- end
146
-
147
- end # class CustomSubdirObjPlacement
148
-
149
- # For compatibility with old naming convention.
150
- Custom_subdir_obj_placement = CustomSubdirObjPlacement
151
-
152
- end # module Cpp
153
-
154
- end # module MxxRu
155
-
1
+ #--
2
+ # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
+ # Copyright (c) 2004-2006, JSC Intervale
4
+ # Copyright (c) 2006, The Mxx_ru Project
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without modification,
8
+ # are permitted provided that the following conditions are met:
9
+ #
10
+ # 1. Redistributions of source code must retain the above copyright notice,
11
+ # this list of conditions and the following disclaimer.
12
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ # 3. The name of the author may not be used to endorse or promote products derived
16
+ # from this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
+ # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ #++
28
+
29
+ require 'mxx_ru/util'
30
+ require 'mxx_ru/cpp/obj_placement'
31
+
32
+ module MxxRu
33
+
34
+ module Cpp
35
+
36
+ # Analog of RuntimeSubdirObjPlacement, but allow to specify
37
+ # paths for final results (EXE, LIB, DLL) and intermediate files (OBJ, RES).
38
+ # Unlike RuntimeSubdirObjPlacement these paths are independent of
39
+ # runtime_mode.
40
+ #
41
+ # Example:
42
+ # MxxRu::Cpp::composite_target {
43
+ # global_obj_placement MxxRu::Cpp::CustomSubdirObjPlacement.new(
44
+ # # Final resuls going here.
45
+ # 'bin32',
46
+ # # All intermediate files going here.
47
+ # 'tmp/output32' )
48
+ #
49
+ # required_prj ...
50
+ # }
51
+ # If this composite project will be applied for project structure:
52
+ # prj_1/
53
+ # `- src/
54
+ # prj_2/
55
+ # `- module_1/
56
+ # `- module_2/
57
+ # Then after build project structructure will be:
58
+ # prj_1/
59
+ # `- src/
60
+ # prj_2/
61
+ # `- module_1/
62
+ # `- module_2/
63
+ # bin32/
64
+ # tmp/
65
+ # `- output32/
66
+ # `- prj_1/
67
+ # | `- src/
68
+ # `- prj_2/
69
+ # `- module_1/
70
+ # `- module_2/
71
+ #
72
+ class CustomSubdirObjPlacement < ObjPlacement
73
+ # Constructor
74
+ #
75
+ # [_final_results_path_] path for storing final results (EXE, LIB/A, DLL/SO).
76
+ # [_intermediate_path_] path for storing intermediate files (OBJ/O, RES).
77
+ def initialize( final_results_path, intermediate_path )
78
+ @final_results_path = final_results_path
79
+ @intermediate_path = intermediate_path
80
+ end
81
+
82
+ # Make name for obj file.
83
+ def get_obj(
84
+ source_path_name,
85
+ toolset,
86
+ target )
87
+
88
+ if source_path_name &&
89
+ "" != source_path_name &&
90
+ "." != source_path_name
91
+ result = File.join( @intermediate_path, source_path_name )
92
+ else
93
+ result = @intermediate_path
94
+ end
95
+
96
+ MxxRu::Util.ensure_path_exists( result )
97
+
98
+ return result
99
+ end
100
+
101
+ # Returns result of get_obj method.
102
+ def get_mswin_res(
103
+ source_path_name,
104
+ toolset,
105
+ target )
106
+
107
+ return get_obj( source_path_name, toolset, target )
108
+ end
109
+
110
+ # Returns final_results_path
111
+ def get_lib(
112
+ source_path_name,
113
+ toolset,
114
+ target )
115
+
116
+ final_result_path_component( source_path_name )
117
+ end
118
+
119
+ # Returns final_results_path
120
+ def get_dll(
121
+ source_path_name,
122
+ toolset,
123
+ target )
124
+
125
+ final_result_path_component( source_path_name )
126
+ end
127
+
128
+ # Returns final_results_path
129
+ def get_exe(
130
+ source_path_name,
131
+ toolset,
132
+ target )
133
+
134
+ final_result_path_component( source_path_name )
135
+ end
136
+
137
+ protected
138
+ # Make final_results_path if needed and return name of it
139
+ def final_result_path_component( target_root )
140
+ r = @final_results_path
141
+ r = File.join( @final_results_path, target_root ) if
142
+ target_root and target_root.size
143
+ MxxRu::Util::ensure_path_exists( r )
144
+ r
145
+ end
146
+
147
+ end # class CustomSubdirObjPlacement
148
+
149
+ # For compatibility with old naming convention.
150
+ Custom_subdir_obj_placement = CustomSubdirObjPlacement
151
+
152
+ end # module Cpp
153
+
154
+ end # module MxxRu
155
+
data/lib/mxx_ru/cpp/qt.rb CHANGED
@@ -1,366 +1,366 @@
1
- #--
2
- # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
- # Copyright (c) 2004-2006, JSC Intervale
4
- # Copyright (c) 2006, The Mxx_ru Project
5
- # All rights reserved.
6
- #
7
- # Redistribution and use in source and binary forms, with or without modification,
8
- # are permitted provided that the following conditions are met:
9
- #
10
- # 1. Redistributions of source code must retain the above copyright notice,
11
- # this list of conditions and the following disclaimer.
12
- # 2. Redistributions in binary form must reproduce the above copyright notice,
13
- # this list of conditions and the following disclaimer in the documentation
14
- # and/or other materials provided with the distribution.
15
- # 3. The name of the author may not be used to endorse or promote products derived
16
- # from this software without specific prior written permission.
17
- #
18
- # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
- # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
- # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- #++
28
-
29
- require 'set'
30
-
31
- require 'mxx_ru/cpp'
32
-
33
- module MxxRu
34
- module Cpp
35
-
36
- # Files generator for Qt class.
37
- #
38
- # Main features:
39
- #
40
- # - building of moc-files using moc tool.
41
- # Generation from source and header files is supported.
42
- # - building source files from ui-files using uic-compiler.
43
- # For all files generated this way moc tool executed automatically.
44
- #
45
- # Generated source files automatically added into
46
- # cpp_source list of target.
47
- #
48
- # Local list defines is supported.
49
- #
50
- # If only pointer to the target passed into contructor,
51
- # default list of defines is used. If it's required to change
52
- # default list, new list should be passed through a second argument:
53
- #
54
- # generator( MxxRu::Cpp::QtGen.new( self, [ "QT_THREAD_SUPPORT" ] ) )
55
- #
56
- class QtGen < MxxRu::AbstractGenerator
57
- # Default list of defines.
58
- # QT_DLL, QT_THREAD_SUPPORT
59
- DEFAULT_DEFINES = [ "QT_DLL", "QT_THREAD_SUPPORT" ]
60
-
61
- UiNames = Struct.new( :header, :source )
62
-
63
- # moc tool executable
64
- # Default: moc
65
- attr_accessor :moc_name
66
-
67
- # uic tool executable
68
- # Default: uic.
69
- attr_accessor :uic_name
70
-
71
- # File extension for source files generated.
72
- # Used in both moc and uic tools.
73
- # Default: .cpp
74
- attr_accessor :cpp_ext
75
-
76
- # File extension for header files generated.
77
- # Used in uic tool.
78
- # Default: .hpp
79
- attr_accessor :hpp_ext
80
-
81
- # File extension for moc files generated.
82
- # Used in moc tool.
83
- # Default: .moc
84
- attr_accessor :moc_ext
85
-
86
- # Subfolder name where moc generated files would be located.
87
- # If nil, generated files would be in the same folder
88
- # where source files were.
89
- # Default: nil
90
- attr_accessor :moc_result_subdir
91
-
92
- # Subfolder name where results of uic invokation must be placed.
93
- # If nil, generated files would be in the same folder where
94
- # source ui files were.
95
- attr_accessor :uic_result_subdir
96
-
97
- # Files list for generating moc files from header files.
98
- #
99
- # More exact: a.hpp -> moc_a.cpp. moc_a.cpp file is added
100
- # to cpp_source list of a target.
101
- attr_reader :qt_h2moc_files
102
-
103
- # Files list for generating moc files from source files.
104
- #
105
- # More exact: a.cpp -> a.moc.
106
- attr_reader :qt_cpp2moc_files
107
-
108
- # Files list for generating hpp, cpp and moc files from ui files.
109
- #
110
- # More exact: a.ui -> a.hpp, a.cpp, moc_a.cpp.
111
- # a.cpp, moc_a.cpp files are added to cpp_source of a target.
112
- attr_reader :qt_ui_files
113
-
114
- # Target, generator is created for.
115
- attr :target
116
-
117
- # Constructor.
118
- def initialize( a_target, a_defines = DEFAULT_DEFINES )
119
- @moc_name = "moc"
120
- @uic_name = "uic"
121
- @cpp_ext = ".cpp"
122
- @hpp_ext = ".hpp"
123
- @moc_ext = ".moc"
124
- @moc_result_subdir = nil
125
- @uic_result_subdir = nil
126
-
127
- # If uic_result_subdir not nil than we must add
128
- # uic_result_subdir into
129
- # target include_path. But must do this only one time.
130
- @uic_result_subdir_include_paths = Set.new
131
-
132
- @qt_h2moc_files = Array.new
133
- @qt_cpp2moc_files = Array.new
134
- @qt_ui_files = Array.new
135
-
136
- defines_to_set = a_defines.flatten
137
- defines_to_set.each { |d| a_target.define( d ) }
138
-
139
- @target = a_target
140
- end
141
-
142
- # Add a file for hpp to moc generation.
143
- def h2moc( a_file )
144
- @qt_h2moc_files << @target.create_full_src_file_name( a_file )
145
- end
146
-
147
- # Add a file for cpp to moc generation.
148
- def cpp2moc( a_file )
149
- @qt_cpp2moc_files << @target.create_full_src_file_name( a_file )
150
- end
151
-
152
- # Add a file for ui to hpp, cpp and moc generation.
153
- def ui( a_file )
154
- full_file_name = @target.create_full_src_file_name( a_file )
155
- @qt_ui_files << full_file_name
156
- if @uic_result_subdir
157
- uic_result_path = make_uic_result_path_for( full_file_name )
158
-
159
- if !@uic_result_subdir_include_paths.member?( uic_result_path )
160
- @target.include_path( uic_result_path )
161
- @uic_result_subdir_include_paths.add( uic_result_path )
162
- end
163
- end
164
- end
165
-
166
- # Perform files generation.
167
- def build( a_target )
168
- build_from_ui( a_target )
169
- build_from_h( a_target )
170
- build_from_cpp( a_target )
171
- end
172
-
173
- # Perform generated files cleanup.
174
- def clean( a_target )
175
- clean_from_ui( a_target )
176
- clean_from_h( a_target )
177
- clean_from_cpp( a_target )
178
- end
179
-
180
- protected
181
-
182
- # Perform generation from ui-files.
183
- def build_from_ui( a_target )
184
- @qt_ui_files.each { |ui|
185
- files_from_ui = names_from_ui( ui, a_target )
186
- MxxRu::Util::ensure_path_exists(
187
- File.dirname( files_from_ui.header ) )
188
- MxxRu::Util::ensure_path_exists(
189
- File.dirname( files_from_ui.source ) )
190
-
191
- # Full file path detection.
192
- header_file = files_from_ui.header
193
- cpp_file = files_from_ui.source
194
-
195
- @qt_h2moc_files << header_file
196
- add_cpp_source( a_target, cpp_file )
197
-
198
- # Checking what files are changed and running generation
199
- # from them if necessary.
200
- if TargetState::EXISTS != TargetState.detect(
201
- header_file, [ ui ] ).state
202
- MxxRu::AbstractTarget::run(
203
- [ "#{@uic_name} -o #{header_file} #{ui}" ],
204
- [ header_file ],
205
- "building header file #{header_file}" )
206
- end
207
- if TargetState::EXISTS != TargetState.detect(
208
- cpp_file, [ ui, header_file ] ).state
209
- MxxRu::AbstractTarget::run(
210
- [ "#{@uic_name} -i #{File.basename(header_file)} " +
211
- "-o #{cpp_file} #{ui}" ],
212
- [ cpp_file ],
213
- "building source file #{cpp_file}" )
214
- end
215
- }
216
- end
217
-
218
- # Perform cleanup of files, generated from ui files.
219
- def clean_from_ui( a_target )
220
- @qt_ui_files.each { |ui|
221
- files_from_ui = names_from_ui( ui, a_target )
222
-
223
- MxxRu::Util::delete_file( files_from_ui.header )
224
- MxxRu::Util::delete_file( files_from_ui.source )
225
-
226
- # To remove object files.
227
- @qt_h2moc_files << files_from_ui.header
228
- add_cpp_source( a_target, files_from_ui.source )
229
- }
230
- end
231
-
232
- # Getting file names, generated by uic tool.
233
- #
234
- # Returns UiNames struct object.
235
- def names_from_ui( a_ui_file, a_target )
236
- if @uic_result_subdir then
237
- uic_result_path = make_uic_result_path_for( a_ui_file )
238
-
239
- short_ui_name = MxxRu::Util::remove_file_ext(
240
- File.basename( a_ui_file ) )
241
- result = UiNames.new(
242
- File.join( uic_result_path, short_ui_name + @hpp_ext ),
243
- File.join( uic_result_path, short_ui_name + @cpp_ext ) )
244
- else
245
- full_ui_name = MxxRu::Util::remove_file_ext( a_ui_file )
246
- result = UiNames.new(
247
- full_ui_name + @hpp_ext,
248
- full_ui_name + @cpp_ext )
249
- end
250
-
251
- return result
252
- end
253
-
254
- # Perform generation from hpp file using moc tool.
255
- def build_from_h( a_target )
256
- @qt_h2moc_files.each { |header_full|
257
- moc_full = moc_from_h( header_full, a_target )
258
-
259
- if TargetState::EXISTS != TargetState.detect(
260
- moc_full, [ header_full ] ).state
261
- MxxRu::AbstractTarget::run(
262
- [ "#{moc_name} -o #{moc_full} " +
263
- "#{header_full}" ],
264
- [ moc_full ],
265
- "building moc file #{moc_full}" )
266
- end
267
-
268
- add_cpp_source( a_target, moc_full )
269
- }
270
- end
271
-
272
- # Perform cleanup of files produced by generation from hpp file.
273
- def clean_from_h( a_target )
274
- @qt_h2moc_files.each { |h|
275
- moc = moc_from_h( h, a_target )
276
-
277
- MxxRu::Util::delete_file( moc )
278
-
279
- add_cpp_source( a_target, moc )
280
- }
281
- end
282
-
283
- # Formatting file name, which is generated from hpp file by moc tool
284
- def moc_from_h( a_h_file, a_target )
285
- path = File.dirname( a_h_file )
286
-
287
- # If path == ".", then Qt will generate wrong include directive
288
- path = "" if path == "./"
289
- path = make_moc_result_path_for( path )
290
-
291
- MxxRu::Util::ensure_path_exists( path )
292
-
293
- r = File.join( path, "moc_" + File.basename(
294
- MxxRu::Util::remove_file_ext( a_h_file ) ) + @cpp_ext )
295
- end
296
-
297
- # Perform generation from cpp file using moc tool.
298
- def build_from_cpp( a_target )
299
- @qt_cpp2moc_files.each { |cpp_full|
300
- moc_full = moc_from_cpp( cpp_full, a_target )
301
-
302
- if TargetState::EXISTS != TargetState.detect(
303
- moc_full, [ cpp_full ] ).state
304
- MxxRu::AbstractTarget::run(
305
- [ "#{moc_name} -o #{moc_full} " +
306
- "#{cpp_full}" ],
307
- [ moc_full ],
308
- "building moc file #{moc_full}" )
309
- end
310
- }
311
- end
312
-
313
- # Perform cleanup of files produced by generation from cpp file.
314
- def clean_from_cpp( a_target )
315
- @qt_cpp2moc_files.each { |cpp|
316
- moc = moc_from_cpp( cpp, a_target )
317
-
318
- MxxRu::Util::delete_file( moc )
319
- }
320
- end
321
-
322
- # Formatting file name, which is generated from cpp file by moc tool
323
- def moc_from_cpp( a_cpp_file, a_target )
324
- path = make_moc_result_path_for( File.dirname( a_cpp_file ) )
325
-
326
- MxxRu::Util::ensure_path_exists( path )
327
-
328
- r = File.join( path, File.basename(
329
- MxxRu::Util::remove_file_ext( a_cpp_file ) ) + @moc_ext )
330
-
331
- return r
332
- end
333
-
334
- # Setting C++ file name, ignoring current sources_root value.
335
- def add_cpp_source( a_target, a_file )
336
- old_root = a_target.sources_root( "" )
337
- a_target.cpp_source( a_file )
338
- a_target.sources_root( old_root )
339
- end
340
-
341
- # Calculating path for moc results.
342
- def make_moc_result_path_for( path )
343
- if @moc_result_subdir
344
- if path.length > 0
345
- File.join( path, @moc_result_subdir )
346
- else
347
- @moc_result_subdir
348
- end
349
- else
350
- path
351
- end
352
- end
353
-
354
- # Calculating path for uic results.
355
- def make_uic_result_path_for( file )
356
- File.join( File.dirname( file ), @uic_result_subdir )
357
- end
358
-
359
- end # class QtGen
360
-
361
- # For compatibility with previous versions
362
- Qt_gen = QtGen
363
-
364
- end
365
- end
366
-
1
+ #--
2
+ # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
+ # Copyright (c) 2004-2006, JSC Intervale
4
+ # Copyright (c) 2006, The Mxx_ru Project
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without modification,
8
+ # are permitted provided that the following conditions are met:
9
+ #
10
+ # 1. Redistributions of source code must retain the above copyright notice,
11
+ # this list of conditions and the following disclaimer.
12
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ # 3. The name of the author may not be used to endorse or promote products derived
16
+ # from this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
+ # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ #++
28
+
29
+ require 'set'
30
+
31
+ require 'mxx_ru/cpp'
32
+
33
+ module MxxRu
34
+ module Cpp
35
+
36
+ # Files generator for Qt class.
37
+ #
38
+ # Main features:
39
+ #
40
+ # - building of moc-files using moc tool.
41
+ # Generation from source and header files is supported.
42
+ # - building source files from ui-files using uic-compiler.
43
+ # For all files generated this way moc tool executed automatically.
44
+ #
45
+ # Generated source files automatically added into
46
+ # cpp_source list of target.
47
+ #
48
+ # Local list defines is supported.
49
+ #
50
+ # If only pointer to the target passed into contructor,
51
+ # default list of defines is used. If it's required to change
52
+ # default list, new list should be passed through a second argument:
53
+ #
54
+ # generator( MxxRu::Cpp::QtGen.new( self, [ "QT_THREAD_SUPPORT" ] ) )
55
+ #
56
+ class QtGen < MxxRu::AbstractGenerator
57
+ # Default list of defines.
58
+ # QT_DLL, QT_THREAD_SUPPORT
59
+ DEFAULT_DEFINES = [ "QT_DLL", "QT_THREAD_SUPPORT" ]
60
+
61
+ UiNames = Struct.new( :header, :source )
62
+
63
+ # moc tool executable
64
+ # Default: moc
65
+ attr_accessor :moc_name
66
+
67
+ # uic tool executable
68
+ # Default: uic.
69
+ attr_accessor :uic_name
70
+
71
+ # File extension for source files generated.
72
+ # Used in both moc and uic tools.
73
+ # Default: .cpp
74
+ attr_accessor :cpp_ext
75
+
76
+ # File extension for header files generated.
77
+ # Used in uic tool.
78
+ # Default: .hpp
79
+ attr_accessor :hpp_ext
80
+
81
+ # File extension for moc files generated.
82
+ # Used in moc tool.
83
+ # Default: .moc
84
+ attr_accessor :moc_ext
85
+
86
+ # Subfolder name where moc generated files would be located.
87
+ # If nil, generated files would be in the same folder
88
+ # where source files were.
89
+ # Default: nil
90
+ attr_accessor :moc_result_subdir
91
+
92
+ # Subfolder name where results of uic invokation must be placed.
93
+ # If nil, generated files would be in the same folder where
94
+ # source ui files were.
95
+ attr_accessor :uic_result_subdir
96
+
97
+ # Files list for generating moc files from header files.
98
+ #
99
+ # More exact: a.hpp -> moc_a.cpp. moc_a.cpp file is added
100
+ # to cpp_source list of a target.
101
+ attr_reader :qt_h2moc_files
102
+
103
+ # Files list for generating moc files from source files.
104
+ #
105
+ # More exact: a.cpp -> a.moc.
106
+ attr_reader :qt_cpp2moc_files
107
+
108
+ # Files list for generating hpp, cpp and moc files from ui files.
109
+ #
110
+ # More exact: a.ui -> a.hpp, a.cpp, moc_a.cpp.
111
+ # a.cpp, moc_a.cpp files are added to cpp_source of a target.
112
+ attr_reader :qt_ui_files
113
+
114
+ # Target, generator is created for.
115
+ attr :target
116
+
117
+ # Constructor.
118
+ def initialize( a_target, a_defines = DEFAULT_DEFINES )
119
+ @moc_name = "moc"
120
+ @uic_name = "uic"
121
+ @cpp_ext = ".cpp"
122
+ @hpp_ext = ".hpp"
123
+ @moc_ext = ".moc"
124
+ @moc_result_subdir = nil
125
+ @uic_result_subdir = nil
126
+
127
+ # If uic_result_subdir not nil than we must add
128
+ # uic_result_subdir into
129
+ # target include_path. But must do this only one time.
130
+ @uic_result_subdir_include_paths = Set.new
131
+
132
+ @qt_h2moc_files = Array.new
133
+ @qt_cpp2moc_files = Array.new
134
+ @qt_ui_files = Array.new
135
+
136
+ defines_to_set = a_defines.flatten
137
+ defines_to_set.each { |d| a_target.define( d ) }
138
+
139
+ @target = a_target
140
+ end
141
+
142
+ # Add a file for hpp to moc generation.
143
+ def h2moc( a_file )
144
+ @qt_h2moc_files << @target.create_full_src_file_name( a_file )
145
+ end
146
+
147
+ # Add a file for cpp to moc generation.
148
+ def cpp2moc( a_file )
149
+ @qt_cpp2moc_files << @target.create_full_src_file_name( a_file )
150
+ end
151
+
152
+ # Add a file for ui to hpp, cpp and moc generation.
153
+ def ui( a_file )
154
+ full_file_name = @target.create_full_src_file_name( a_file )
155
+ @qt_ui_files << full_file_name
156
+ if @uic_result_subdir
157
+ uic_result_path = make_uic_result_path_for( full_file_name )
158
+
159
+ if !@uic_result_subdir_include_paths.member?( uic_result_path )
160
+ @target.include_path( uic_result_path )
161
+ @uic_result_subdir_include_paths.add( uic_result_path )
162
+ end
163
+ end
164
+ end
165
+
166
+ # Perform files generation.
167
+ def build( a_target )
168
+ build_from_ui( a_target )
169
+ build_from_h( a_target )
170
+ build_from_cpp( a_target )
171
+ end
172
+
173
+ # Perform generated files cleanup.
174
+ def clean( a_target )
175
+ clean_from_ui( a_target )
176
+ clean_from_h( a_target )
177
+ clean_from_cpp( a_target )
178
+ end
179
+
180
+ protected
181
+
182
+ # Perform generation from ui-files.
183
+ def build_from_ui( a_target )
184
+ @qt_ui_files.each { |ui|
185
+ files_from_ui = names_from_ui( ui, a_target )
186
+ MxxRu::Util::ensure_path_exists(
187
+ File.dirname( files_from_ui.header ) )
188
+ MxxRu::Util::ensure_path_exists(
189
+ File.dirname( files_from_ui.source ) )
190
+
191
+ # Full file path detection.
192
+ header_file = files_from_ui.header
193
+ cpp_file = files_from_ui.source
194
+
195
+ @qt_h2moc_files << header_file
196
+ add_cpp_source( a_target, cpp_file )
197
+
198
+ # Checking what files are changed and running generation
199
+ # from them if necessary.
200
+ if TargetState::EXISTS != TargetState.detect(
201
+ header_file, [ ui ] ).state
202
+ MxxRu::AbstractTarget::run(
203
+ [ "#{@uic_name} -o #{header_file} #{ui}" ],
204
+ [ header_file ],
205
+ "building header file #{header_file}" )
206
+ end
207
+ if TargetState::EXISTS != TargetState.detect(
208
+ cpp_file, [ ui, header_file ] ).state
209
+ MxxRu::AbstractTarget::run(
210
+ [ "#{@uic_name} -i #{File.basename(header_file)} " +
211
+ "-o #{cpp_file} #{ui}" ],
212
+ [ cpp_file ],
213
+ "building source file #{cpp_file}" )
214
+ end
215
+ }
216
+ end
217
+
218
+ # Perform cleanup of files, generated from ui files.
219
+ def clean_from_ui( a_target )
220
+ @qt_ui_files.each { |ui|
221
+ files_from_ui = names_from_ui( ui, a_target )
222
+
223
+ MxxRu::Util::delete_file( files_from_ui.header )
224
+ MxxRu::Util::delete_file( files_from_ui.source )
225
+
226
+ # To remove object files.
227
+ @qt_h2moc_files << files_from_ui.header
228
+ add_cpp_source( a_target, files_from_ui.source )
229
+ }
230
+ end
231
+
232
+ # Getting file names, generated by uic tool.
233
+ #
234
+ # Returns UiNames struct object.
235
+ def names_from_ui( a_ui_file, a_target )
236
+ if @uic_result_subdir then
237
+ uic_result_path = make_uic_result_path_for( a_ui_file )
238
+
239
+ short_ui_name = MxxRu::Util::remove_file_ext(
240
+ File.basename( a_ui_file ) )
241
+ result = UiNames.new(
242
+ File.join( uic_result_path, short_ui_name + @hpp_ext ),
243
+ File.join( uic_result_path, short_ui_name + @cpp_ext ) )
244
+ else
245
+ full_ui_name = MxxRu::Util::remove_file_ext( a_ui_file )
246
+ result = UiNames.new(
247
+ full_ui_name + @hpp_ext,
248
+ full_ui_name + @cpp_ext )
249
+ end
250
+
251
+ return result
252
+ end
253
+
254
+ # Perform generation from hpp file using moc tool.
255
+ def build_from_h( a_target )
256
+ @qt_h2moc_files.each { |header_full|
257
+ moc_full = moc_from_h( header_full, a_target )
258
+
259
+ if TargetState::EXISTS != TargetState.detect(
260
+ moc_full, [ header_full ] ).state
261
+ MxxRu::AbstractTarget::run(
262
+ [ "#{moc_name} -o #{moc_full} " +
263
+ "#{header_full}" ],
264
+ [ moc_full ],
265
+ "building moc file #{moc_full}" )
266
+ end
267
+
268
+ add_cpp_source( a_target, moc_full )
269
+ }
270
+ end
271
+
272
+ # Perform cleanup of files produced by generation from hpp file.
273
+ def clean_from_h( a_target )
274
+ @qt_h2moc_files.each { |h|
275
+ moc = moc_from_h( h, a_target )
276
+
277
+ MxxRu::Util::delete_file( moc )
278
+
279
+ add_cpp_source( a_target, moc )
280
+ }
281
+ end
282
+
283
+ # Formatting file name, which is generated from hpp file by moc tool
284
+ def moc_from_h( a_h_file, a_target )
285
+ path = File.dirname( a_h_file )
286
+
287
+ # If path == ".", then Qt will generate wrong include directive
288
+ path = "" if path == "./"
289
+ path = make_moc_result_path_for( path )
290
+
291
+ MxxRu::Util::ensure_path_exists( path )
292
+
293
+ r = File.join( path, "moc_" + File.basename(
294
+ MxxRu::Util::remove_file_ext( a_h_file ) ) + @cpp_ext )
295
+ end
296
+
297
+ # Perform generation from cpp file using moc tool.
298
+ def build_from_cpp( a_target )
299
+ @qt_cpp2moc_files.each { |cpp_full|
300
+ moc_full = moc_from_cpp( cpp_full, a_target )
301
+
302
+ if TargetState::EXISTS != TargetState.detect(
303
+ moc_full, [ cpp_full ] ).state
304
+ MxxRu::AbstractTarget::run(
305
+ [ "#{moc_name} -o #{moc_full} " +
306
+ "#{cpp_full}" ],
307
+ [ moc_full ],
308
+ "building moc file #{moc_full}" )
309
+ end
310
+ }
311
+ end
312
+
313
+ # Perform cleanup of files produced by generation from cpp file.
314
+ def clean_from_cpp( a_target )
315
+ @qt_cpp2moc_files.each { |cpp|
316
+ moc = moc_from_cpp( cpp, a_target )
317
+
318
+ MxxRu::Util::delete_file( moc )
319
+ }
320
+ end
321
+
322
+ # Formatting file name, which is generated from cpp file by moc tool
323
+ def moc_from_cpp( a_cpp_file, a_target )
324
+ path = make_moc_result_path_for( File.dirname( a_cpp_file ) )
325
+
326
+ MxxRu::Util::ensure_path_exists( path )
327
+
328
+ r = File.join( path, File.basename(
329
+ MxxRu::Util::remove_file_ext( a_cpp_file ) ) + @moc_ext )
330
+
331
+ return r
332
+ end
333
+
334
+ # Setting C++ file name, ignoring current sources_root value.
335
+ def add_cpp_source( a_target, a_file )
336
+ old_root = a_target.sources_root( "" )
337
+ a_target.cpp_source( a_file )
338
+ a_target.sources_root( old_root )
339
+ end
340
+
341
+ # Calculating path for moc results.
342
+ def make_moc_result_path_for( path )
343
+ if @moc_result_subdir
344
+ if path.length > 0
345
+ File.join( path, @moc_result_subdir )
346
+ else
347
+ @moc_result_subdir
348
+ end
349
+ else
350
+ path
351
+ end
352
+ end
353
+
354
+ # Calculating path for uic results.
355
+ def make_uic_result_path_for( file )
356
+ File.join( File.dirname( file ), @uic_result_subdir )
357
+ end
358
+
359
+ end # class QtGen
360
+
361
+ # For compatibility with previous versions
362
+ Qt_gen = QtGen
363
+
364
+ end
365
+ end
366
+