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,143 +1,143 @@
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/ex'
30
- require 'mxx_ru/abstract_target'
31
-
32
- module MxxRu
33
-
34
- # Class describing a target, which is unit-test binary application.
35
- #
36
- # The idea is, that there is project file, which controls the build process
37
- # of unit-test application. In that project file target object is created,
38
- # inherited from MxxRu::BinaryTarget.
39
- # To initialize unit-test it's required to create one more file, where
40
- # target object of MxxRu::BinaryUnittestTarget class is created.
41
- # For example:
42
- #
43
- # File to compile unit-test.
44
- # MxxRu::setup_target(
45
- # MxxRu::Cpp::ExeTarget.new( "test/pack/prj.rb" ) {
46
- # ...
47
- # }
48
- # )
49
- #
50
- # File to run unit-test.
51
- # MxxRu::setup_target(
52
- # MxxRu::BinaryUnittestTarget.new(
53
- # "test/pack/ut.rb",
54
- # "test/pack/prj.rb ) )
55
- #
56
- # File to use unit-test.
57
- # MxxRu::setup_target(
58
- # MxxRu::Cpp::CompositeTarget.new( MxxRu::BUILD_ROOT ) {
59
- # required_prj( "some/project/prj.rb" )
60
- # required_prj( "test/pack/ut.rb" )
61
- # }
62
- # )
63
- #
64
- class BinaryUnittestTarget < AbstractTarget
65
-
66
- # Exception, thrown if subordinated project created more then one result
67
- # name.
68
- class MustBeOneTargetNameEx < Ex
69
- # [_a_names_] Generated result names.
70
- def initialize( a_names )
71
- super( "Only one name expected in [#{a_names.join(';')}]" )
72
- end
73
- end
74
-
75
- # For compatibility with previous versions.
76
- Must_be_one_target_name_ex = MustBeOneTargetNameEx
77
-
78
- # Target, responsible for build of unit-test application.
79
- attr_reader :mxx_target_project
80
- # Attribute, showing that build method was already executed.
81
- attr_reader :mxx_build_state
82
-
83
- # Constructor.
84
- #
85
- # [_a_alias_] Self alias.
86
- # [_a_target_project_] Project, responsible for build of unit-test
87
- # application.
88
- def initialize( a_alias, a_target_project )
89
- super( a_alias )
90
-
91
- @mxx_build_state = nil
92
-
93
- @mxx_target_project = required_prj( a_target_project )
94
- end
95
-
96
- # Build subordinated project and run it.
97
- #
98
- # If unit-test application returns result, other then 0,
99
- # exception is thrown.
100
- def build
101
- if !@mxx_build_state
102
- @mxx_target_project.build
103
-
104
- # Determining application name.
105
- full_names = @mxx_target_project.mxx_full_targets_names
106
- if 1 != full_names.size
107
- raise MustBeOneTargetNameEx.new( full_names )
108
- end
109
-
110
- # In dry-run do not actually execute anything.
111
- if !MxxRu::Util::Mode.instance.is_dry_run
112
- puts "running unit test: #{full_names[0]}..."
113
- if !system( full_names[ 0 ] )
114
- puts "\n\nunit test '#{full_names[0]}' FAILED! #{$?}"
115
- raise BuildEx.new( full_names[ 0 ], $? )
116
- end
117
- end
118
-
119
- @mxx_build_state = TargetState.new( TargetState::REBUILT )
120
- end
121
-
122
- return @mxx_build_state
123
- end
124
-
125
- # Project cleanup.
126
- #
127
- # Just execute clean method from subordinated project.
128
- def clean
129
- @mxx_target_project.clean
130
- end
131
-
132
- # Reset build state.
133
- def reset
134
- @mxx_target_project.reset
135
- @mxx_build_state = nil
136
- end
137
-
138
- end
139
-
140
- # For compatibility with previous versions.
141
- Binary_unittest_target = BinaryUnittestTarget
142
-
143
- end
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/ex'
30
+ require 'mxx_ru/abstract_target'
31
+
32
+ module MxxRu
33
+
34
+ # Class describing a target, which is unit-test binary application.
35
+ #
36
+ # The idea is, that there is project file, which controls the build process
37
+ # of unit-test application. In that project file target object is created,
38
+ # inherited from MxxRu::BinaryTarget.
39
+ # To initialize unit-test it's required to create one more file, where
40
+ # target object of MxxRu::BinaryUnittestTarget class is created.
41
+ # For example:
42
+ #
43
+ # File to compile unit-test.
44
+ # MxxRu::setup_target(
45
+ # MxxRu::Cpp::ExeTarget.new( "test/pack/prj.rb" ) {
46
+ # ...
47
+ # }
48
+ # )
49
+ #
50
+ # File to run unit-test.
51
+ # MxxRu::setup_target(
52
+ # MxxRu::BinaryUnittestTarget.new(
53
+ # "test/pack/ut.rb",
54
+ # "test/pack/prj.rb ) )
55
+ #
56
+ # File to use unit-test.
57
+ # MxxRu::setup_target(
58
+ # MxxRu::Cpp::CompositeTarget.new( MxxRu::BUILD_ROOT ) {
59
+ # required_prj( "some/project/prj.rb" )
60
+ # required_prj( "test/pack/ut.rb" )
61
+ # }
62
+ # )
63
+ #
64
+ class BinaryUnittestTarget < AbstractTarget
65
+
66
+ # Exception, thrown if subordinated project created more then one result
67
+ # name.
68
+ class MustBeOneTargetNameEx < Ex
69
+ # [_a_names_] Generated result names.
70
+ def initialize( a_names )
71
+ super( "Only one name expected in [#{a_names.join(';')}]" )
72
+ end
73
+ end
74
+
75
+ # For compatibility with previous versions.
76
+ Must_be_one_target_name_ex = MustBeOneTargetNameEx
77
+
78
+ # Target, responsible for build of unit-test application.
79
+ attr_reader :mxx_target_project
80
+ # Attribute, showing that build method was already executed.
81
+ attr_reader :mxx_build_state
82
+
83
+ # Constructor.
84
+ #
85
+ # [_a_alias_] Self alias.
86
+ # [_a_target_project_] Project, responsible for build of unit-test
87
+ # application.
88
+ def initialize( a_alias, a_target_project )
89
+ super( a_alias )
90
+
91
+ @mxx_build_state = nil
92
+
93
+ @mxx_target_project = required_prj( a_target_project )
94
+ end
95
+
96
+ # Build subordinated project and run it.
97
+ #
98
+ # If unit-test application returns result, other then 0,
99
+ # exception is thrown.
100
+ def build
101
+ if !@mxx_build_state
102
+ @mxx_target_project.build
103
+
104
+ # Determining application name.
105
+ full_names = @mxx_target_project.mxx_full_targets_names
106
+ if 1 != full_names.size
107
+ raise MustBeOneTargetNameEx.new( full_names )
108
+ end
109
+
110
+ # In dry-run do not actually execute anything.
111
+ if !MxxRu::Util::Mode.instance.is_dry_run
112
+ puts "running unit test: #{full_names[0]}..."
113
+ if !system( full_names[ 0 ] )
114
+ puts "\n\nunit test '#{full_names[0]}' FAILED! #{$?}"
115
+ raise BuildEx.new( full_names[ 0 ], $? )
116
+ end
117
+ end
118
+
119
+ @mxx_build_state = TargetState.new( TargetState::REBUILT )
120
+ end
121
+
122
+ return @mxx_build_state
123
+ end
124
+
125
+ # Project cleanup.
126
+ #
127
+ # Just execute clean method from subordinated project.
128
+ def clean
129
+ @mxx_target_project.clean
130
+ end
131
+
132
+ # Reset build state.
133
+ def reset
134
+ @mxx_target_project.reset
135
+ @mxx_build_state = nil
136
+ end
137
+
138
+ end
139
+
140
+ # For compatibility with previous versions.
141
+ Binary_unittest_target = BinaryUnittestTarget
142
+
143
+ end
data/lib/mxx_ru/compat.rb CHANGED
@@ -1,33 +1,33 @@
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
- module MxxRu
30
- end
31
-
32
- # For compatibility with previous versions.
33
- Mxx_ru = MxxRu unless Module.constants.member?('Mxx_ru')
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
+ module MxxRu
30
+ end
31
+
32
+ # For compatibility with previous versions.
33
+ Mxx_ru = MxxRu unless Module.constants.member?('Mxx_ru')
data/lib/mxx_ru/cpp.rb CHANGED
@@ -1,38 +1,38 @@
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/abstract_target'
30
- require 'mxx_ru/binary_target'
31
- require 'mxx_ru/cpp/detect_toolset'
32
- require 'mxx_ru/cpp/target'
33
- require 'mxx_ru/cpp/composite'
34
-
35
- require 'mxx_ru/cpp/obj_placements/custom_subdir'
36
-
37
- # Determining which toolset should be used.
38
- MxxRu::Cpp::detect_toolset
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/abstract_target'
30
+ require 'mxx_ru/binary_target'
31
+ require 'mxx_ru/cpp/detect_toolset'
32
+ require 'mxx_ru/cpp/target'
33
+ require 'mxx_ru/cpp/composite'
34
+
35
+ require 'mxx_ru/cpp/obj_placements/custom_subdir'
36
+
37
+ # Determining which toolset should be used.
38
+ MxxRu::Cpp::detect_toolset
@@ -1,237 +1,237 @@
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 'singleton'
30
-
31
- module MxxRu
32
- module Cpp
33
-
34
- module Analyzer
35
- # Class, describing one source file.
36
- class SourceFile
37
- # Already processed file sign.
38
- attr_reader :is_processed
39
- # A set of files-dependecies.
40
- # Hash, key is a String, no value.
41
- attr_reader :depends
42
-
43
- def initialize
44
- @is_processed = false
45
- @depends = Hash.new
46
- end
47
-
48
- # Set processed file sign.
49
- def processed
50
- @is_processed = true
51
- end
52
-
53
- # Add a dependency.
54
- def <<( a_name )
55
- @depends[ a_name ]= nil
56
- end
57
-
58
- end # class SourceFile
59
-
60
- # For compatibility with previous versions.
61
- Source_file = SourceFile
62
-
63
- class CppAnalyzer
64
- include Singleton
65
-
66
- @@include_regex = Regexp.new(
67
- '^[ \t]*#[ \t]*include[ \t]*(<|")([^>"]+)(>|")' )
68
-
69
- def initialize
70
- # Key is a string, value - SourceFile.
71
- @sources = Hash.new
72
- # A list of folders to look header files in.
73
- @include_paths = Array.new
74
- end
75
-
76
- # Add files to view.
77
- # [_a_sources_] Should be Array of Strings.
78
- def add_sources( a_sources )
79
-
80
- a_sources.each { |s|
81
- if !@sources.key?( s )
82
- @sources[ s ] = SourceFile.new
83
- end
84
- }
85
- end
86
-
87
- # Add paths to header files.
88
- # [_a_paths_] Should be Array of Strings.
89
- def add_include_paths( a_paths )
90
-
91
- a_paths.each { |p|
92
- if !@include_paths.include?( p )
93
- @include_paths << p
94
- end
95
- }
96
- end
97
-
98
- # Perform file analisys.
99
- def analyze
100
- # Current list of keys should be taken to avoid
101
- # dynamic growth of file list.
102
- # Repeat iterations until source file list changes stop
103
- old_size = 0
104
- files = @sources.keys
105
- while old_size != files.size
106
- files.each { |file_name|
107
- current = @sources[ file_name ]
108
- if !current.is_processed
109
- process_file( file_name, current )
110
- end
111
- }
112
-
113
- old_size = files.size
114
- files = @sources.keys
115
- end
116
- end
117
-
118
- # Get full dependencies list for a file.
119
- # Returns Array of Strings.
120
- def get_depends_for( a_file_name )
121
- result_hash = Hash.new
122
- file_obj = @sources[ a_file_name ]
123
- if nil != file_obj
124
- to_review = file_obj.depends
125
- to_review_next = Hash.new
126
-
127
- while to_review.size != to_review_next.size
128
- to_review.each_key { |f|
129
- if !result_hash.key?( f )
130
- result_hash[ f ] = nil
131
- to_review_next_obj = @sources[ f ]
132
- to_review_next_obj.depends.each_key { |k|
133
- to_review_next[ k ] = nil }
134
- end
135
- }
136
-
137
- to_review = to_review_next
138
- to_review_next = Hash.new
139
- end
140
- end
141
-
142
- return result_hash.keys
143
- end
144
-
145
- protected
146
- # Process next file.
147
- # [_a_file_name_] File name.
148
- # [_a_file_obj_] Corresponding object.
149
- def process_file( a_file_name, a_file_obj )
150
-
151
- # Gather file names list from include directives.
152
- std_path_included = Array.new
153
- local_path_included = Array.new
154
- IO.foreach( a_file_name ) { |line|
155
- r = @@include_regex.match( line )
156
- if nil != r
157
- if "<" == r[ 1 ]
158
- std_path_included << r[ 2 ]
159
- else
160
- local_path_included << r[ 2 ]
161
- end
162
- end
163
- }
164
-
165
- # All files, loaded through include <>
166
- # should be searched in standard search paths only.
167
- std_path_included.each { |f|
168
- process_std_include_path_file( f, a_file_obj )
169
- }
170
-
171
- if local_path_included.size
172
- # Files loaded through include ""
173
- # should be searched in folder with the source file first.
174
- local_path = File.dirname( a_file_name )
175
- local_path_included.each { |f|
176
- process_local_include_path_file( f, local_path, a_file_obj )
177
- }
178
- end
179
-
180
- a_file_obj.processed
181
- end
182
-
183
- # Processing file loaded through include <>
184
- # [_a_file_name_] File name.
185
- # [_a_owner_obj_] File object contained include directive.
186
- def process_std_include_path_file( a_file_name, a_owner_obj )
187
-
188
- @include_paths.find { |path|
189
- test_name = File.join( [ path, a_file_name ] )
190
- if File.exists?( test_name )
191
- add_depend_to( a_owner_obj, test_name )
192
- true
193
- else
194
- false
195
- end
196
- }
197
- end
198
-
199
- # Processing file loaded through include ""
200
- # [_a_file_name_] File name.
201
- # [_a_local_path_] Folder with owner_obj.
202
- # [_a_owner_obj_] File object contained include directive.
203
- def process_local_include_path_file(
204
- a_file_name,
205
- a_local_path,
206
- a_owner_obj )
207
-
208
- test_name = File.join( [ a_local_path, a_file_name ] )
209
- if File.exists?( test_name )
210
- add_depend_to( a_owner_obj, test_name )
211
- else
212
- process_std_include_path_file( a_file_name, a_owner_obj )
213
- end
214
- end
215
-
216
- # Add dependency to a file.
217
- # [_a_owner_obj_] Dependency owner.
218
- # [_a_depend_name_] Dependency file name.
219
- def add_depend_to( a_owner_obj, a_depend_name )
220
-
221
- a_owner_obj << a_depend_name
222
-
223
- if !@sources.key?( a_depend_name )
224
- # This file wasn't viewed yet.
225
- @sources[ a_depend_name ] = SourceFile.new
226
- end
227
- end
228
- end # class CppAnalyzer
229
-
230
- # For compatibility with previous versions.
231
- Cpp_analyzer = CppAnalyzer
232
-
233
- end # module Analyzer
234
- end # module cpp
235
- end # module MxxRu
236
-
237
- load File.dirname( __FILE__ ) + '/../compat.rb'
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 'singleton'
30
+
31
+ module MxxRu
32
+ module Cpp
33
+
34
+ module Analyzer
35
+ # Class, describing one source file.
36
+ class SourceFile
37
+ # Already processed file sign.
38
+ attr_reader :is_processed
39
+ # A set of files-dependecies.
40
+ # Hash, key is a String, no value.
41
+ attr_reader :depends
42
+
43
+ def initialize
44
+ @is_processed = false
45
+ @depends = Hash.new
46
+ end
47
+
48
+ # Set processed file sign.
49
+ def processed
50
+ @is_processed = true
51
+ end
52
+
53
+ # Add a dependency.
54
+ def <<( a_name )
55
+ @depends[ a_name ]= nil
56
+ end
57
+
58
+ end # class SourceFile
59
+
60
+ # For compatibility with previous versions.
61
+ Source_file = SourceFile
62
+
63
+ class CppAnalyzer
64
+ include Singleton
65
+
66
+ @@include_regex = Regexp.new(
67
+ '^[ \t]*#[ \t]*include[ \t]*(<|")([^>"]+)(>|")' )
68
+
69
+ def initialize
70
+ # Key is a string, value - SourceFile.
71
+ @sources = Hash.new
72
+ # A list of folders to look header files in.
73
+ @include_paths = Array.new
74
+ end
75
+
76
+ # Add files to view.
77
+ # [_a_sources_] Should be Array of Strings.
78
+ def add_sources( a_sources )
79
+
80
+ a_sources.each { |s|
81
+ if !@sources.key?( s )
82
+ @sources[ s ] = SourceFile.new
83
+ end
84
+ }
85
+ end
86
+
87
+ # Add paths to header files.
88
+ # [_a_paths_] Should be Array of Strings.
89
+ def add_include_paths( a_paths )
90
+
91
+ a_paths.each { |p|
92
+ if !@include_paths.include?( p )
93
+ @include_paths << p
94
+ end
95
+ }
96
+ end
97
+
98
+ # Perform file analisys.
99
+ def analyze
100
+ # Current list of keys should be taken to avoid
101
+ # dynamic growth of file list.
102
+ # Repeat iterations until source file list changes stop
103
+ old_size = 0
104
+ files = @sources.keys
105
+ while old_size != files.size
106
+ files.each { |file_name|
107
+ current = @sources[ file_name ]
108
+ if !current.is_processed
109
+ process_file( file_name, current )
110
+ end
111
+ }
112
+
113
+ old_size = files.size
114
+ files = @sources.keys
115
+ end
116
+ end
117
+
118
+ # Get full dependencies list for a file.
119
+ # Returns Array of Strings.
120
+ def get_depends_for( a_file_name )
121
+ result_hash = Hash.new
122
+ file_obj = @sources[ a_file_name ]
123
+ if nil != file_obj
124
+ to_review = file_obj.depends
125
+ to_review_next = Hash.new
126
+
127
+ while to_review.size != to_review_next.size
128
+ to_review.each_key { |f|
129
+ if !result_hash.key?( f )
130
+ result_hash[ f ] = nil
131
+ to_review_next_obj = @sources[ f ]
132
+ to_review_next_obj.depends.each_key { |k|
133
+ to_review_next[ k ] = nil }
134
+ end
135
+ }
136
+
137
+ to_review = to_review_next
138
+ to_review_next = Hash.new
139
+ end
140
+ end
141
+
142
+ return result_hash.keys
143
+ end
144
+
145
+ protected
146
+ # Process next file.
147
+ # [_a_file_name_] File name.
148
+ # [_a_file_obj_] Corresponding object.
149
+ def process_file( a_file_name, a_file_obj )
150
+
151
+ # Gather file names list from include directives.
152
+ std_path_included = Array.new
153
+ local_path_included = Array.new
154
+ IO.foreach( a_file_name ) { |line|
155
+ r = @@include_regex.match( line )
156
+ if nil != r
157
+ if "<" == r[ 1 ]
158
+ std_path_included << r[ 2 ]
159
+ else
160
+ local_path_included << r[ 2 ]
161
+ end
162
+ end
163
+ }
164
+
165
+ # All files, loaded through include <>
166
+ # should be searched in standard search paths only.
167
+ std_path_included.each { |f|
168
+ process_std_include_path_file( f, a_file_obj )
169
+ }
170
+
171
+ if local_path_included.size
172
+ # Files loaded through include ""
173
+ # should be searched in folder with the source file first.
174
+ local_path = File.dirname( a_file_name )
175
+ local_path_included.each { |f|
176
+ process_local_include_path_file( f, local_path, a_file_obj )
177
+ }
178
+ end
179
+
180
+ a_file_obj.processed
181
+ end
182
+
183
+ # Processing file loaded through include <>
184
+ # [_a_file_name_] File name.
185
+ # [_a_owner_obj_] File object contained include directive.
186
+ def process_std_include_path_file( a_file_name, a_owner_obj )
187
+
188
+ @include_paths.find { |path|
189
+ test_name = File.join( [ path, a_file_name ] )
190
+ if File.exists?( test_name )
191
+ add_depend_to( a_owner_obj, test_name )
192
+ true
193
+ else
194
+ false
195
+ end
196
+ }
197
+ end
198
+
199
+ # Processing file loaded through include ""
200
+ # [_a_file_name_] File name.
201
+ # [_a_local_path_] Folder with owner_obj.
202
+ # [_a_owner_obj_] File object contained include directive.
203
+ def process_local_include_path_file(
204
+ a_file_name,
205
+ a_local_path,
206
+ a_owner_obj )
207
+
208
+ test_name = File.join( [ a_local_path, a_file_name ] )
209
+ if File.exists?( test_name )
210
+ add_depend_to( a_owner_obj, test_name )
211
+ else
212
+ process_std_include_path_file( a_file_name, a_owner_obj )
213
+ end
214
+ end
215
+
216
+ # Add dependency to a file.
217
+ # [_a_owner_obj_] Dependency owner.
218
+ # [_a_depend_name_] Dependency file name.
219
+ def add_depend_to( a_owner_obj, a_depend_name )
220
+
221
+ a_owner_obj << a_depend_name
222
+
223
+ if !@sources.key?( a_depend_name )
224
+ # This file wasn't viewed yet.
225
+ @sources[ a_depend_name ] = SourceFile.new
226
+ end
227
+ end
228
+ end # class CppAnalyzer
229
+
230
+ # For compatibility with previous versions.
231
+ Cpp_analyzer = CppAnalyzer
232
+
233
+ end # module Analyzer
234
+ end # module cpp
235
+ end # module MxxRu
236
+
237
+ load File.dirname( __FILE__ ) + '/../compat.rb'