Mxx_ru 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/COPYING +26 -26
  2. data/NEWS +107 -107
  3. data/README +21 -21
  4. data/Rakefile +56 -56
  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 -420
  39. data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +64 -64
  40. data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +149 -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 -103
  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/o/dll.o +0 -0
  79. data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -18
  80. data/tests/cpp/mswin_res_exe/build.rb +23 -23
  81. data/tests/cpp/mswin_res_exe/h/res.h +3 -3
  82. data/tests/cpp/mswin_res_exe/main.cpp +17 -17
  83. data/tests/cpp/mswin_res_exe/main.rc +48 -48
  84. data/tests/cpp/mswin_res_exe/o/main.o +0 -0
  85. data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -18
  86. data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -32
  87. data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -7
  88. data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -14
  89. data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -10
  90. data/tests/cpp/rucodegen.embedded/prj.rb +16 -16
  91. data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -18
  92. data/tests/cpp/rucodegen/host_config.cpp +20 -20
  93. data/tests/cpp/rucodegen/host_config.rb +14 -14
  94. data/tests/cpp/rucodegen/impl/conn_params.cpp +7 -7
  95. data/tests/cpp/rucodegen/impl/conn_params.rb +14 -14
  96. data/tests/cpp/rucodegen/impl/h/conn_params.hpp +10 -10
  97. data/tests/cpp/rucodegen/prj.rb +16 -16
  98. data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -18
  99. data/tests/cpp/textfile_unittest/build.rb +8 -8
  100. data/tests/cpp/textfile_unittest/etalons/out_1.txt +1 -1
  101. data/tests/cpp/textfile_unittest/etalons/out_128.txt +128 -128
  102. data/tests/cpp/textfile_unittest/main.cpp +89 -89
  103. data/tests/cpp/textfile_unittest/prj.rb +8 -8
  104. data/tests/cpp/textfile_unittest/prj.ut.rb +18 -18
  105. data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -18
  106. data/tests/cpp/toolset_name.rb +6 -6
  107. data/tests/cpp/vc_cleanup/prj_dll_no_implib.rb +10 -10
  108. data/tests/cpp/vc_cleanup/prj_dll_no_implib_simple_target_root.rb +11 -11
  109. data/tests/cpp/vc_cleanup/prj_dll_with_implib.rb +11 -11
  110. data/tests/cpp/vc_cleanup/prj_dll_with_implib_simple_target_root.rb +14 -14
  111. data/tests/cpp/vc_cleanup/prj_exe_no_implib.rb +10 -10
  112. data/tests/cpp/vc_cleanup/prj_exe_no_implib_simple_target_root.rb +11 -11
  113. data/tests/cpp/vc_cleanup/prj_lib.rb +10 -10
  114. data/tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb +11 -11
  115. data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +23 -23
  116. data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -57
  117. data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -114
  118. data/tests/mxx_ru/change_default_value/ignoring_by_build_root/build.rb +8 -8
  119. data/tests/mxx_ru/change_default_value/ignoring_by_build_root/child_1.rb +5 -5
  120. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/build.rb +7 -7
  121. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_1.rb +5 -5
  122. data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_2.rb +5 -5
  123. data/tests/mxx_ru/change_default_value/ok/build.rb +8 -8
  124. data/tests/mxx_ru/change_default_value/ok/child_1.rb +8 -8
  125. data/tests/mxx_ru/lib_path/build.rb +8 -8
  126. data/tests/mxx_ru/lib_path/bye.rb +8 -8
  127. data/tests/mxx_ru/lib_path/hi.rb +8 -8
  128. data/tests/mxx_ru/lib_path/main.rb +12 -12
  129. data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -18
  130. data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -58
  131. data/tests/mxx_ru/opt_lib_ext/build.rb +7 -7
  132. data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -7
  133. data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -18
  134. data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -9
  135. data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -13
  136. data/tests/mxx_ru/plural_form_methods/tc.rb +72 -72
  137. data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -76
  138. data/tests/mxx_ru/target_ext/prj_dll.rb +8 -8
  139. data/tests/mxx_ru/target_ext/prj_exe.rb +8 -8
  140. data/tests/mxx_ru/target_ext/prj_lib.rb +8 -8
  141. data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -24
  142. data/tests/mxx_ru/tc_makestyle_generator.rb +117 -117
  143. data/tests/mxx_ru/vc8/tc_actual_manifest.rb +230 -230
  144. data/tests/mxx_ru/vc8/tc_append_mt_commands.rb +104 -104
  145. data/tests/mxx_ru/vc8/tc_default_manifest.rb +17 -17
  146. data/tests/mxx_ru/vc8/tc_define_manifest.rb +173 -173
  147. data/tests/mxx_ru/vc8/tc_drop_default_manifest.rb +16 -16
  148. data/tests/mxx_ru/vc8/tc_invalid_params.rb +81 -81
  149. data/tests/mxx_ru/vc8/ts_vc8.rb +10 -10
  150. data/tests/qt/aclock/aclock.cpp +148 -148
  151. data/tests/qt/aclock/aclock.h +45 -45
  152. data/tests/qt/aclock/main.cpp +28 -28
  153. data/tests/qt/aclock/prj.rb +21 -21
  154. data/tests/qt/iconview/main.cpp +76 -76
  155. data/tests/qt/iconview/prj.rb +21 -21
  156. data/tests/qt/toplevel/main.cpp +9 -9
  157. data/tests/qt/toplevel/options.ui +587 -587
  158. data/tests/qt/toplevel/prj.rb +22 -22
  159. data/tests/test_with_compilation.rb +110 -110
  160. data/tests/unix/lib_linking_mode/a_shared.rb +7 -7
  161. data/tests/unix/lib_linking_mode/a_static.rb +7 -7
  162. data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -2
  163. data/tests/unix/lib_linking_mode/etalon/static.txt +2 -2
  164. data/tests/unix/lib_linking_mode/main_conflict.rb +12 -12
  165. data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -11
  166. data/tests/unix/lib_linking_mode/main_shared.rb +9 -9
  167. data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -11
  168. data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -10
  169. data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -11
  170. data/tests/unix/lib_linking_mode/main_static.rb +9 -9
  171. data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -11
  172. data/tests/unix/lib_linking_mode/main_static_2.rb +10 -10
  173. data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -11
  174. data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -18
  175. data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -18
  176. data/tests/unix/lib_order/tc_normal_build.rb +16 -16
  177. metadata +216 -205
@@ -1,18 +1,18 @@
1
- require 'mxx_ru/cpp'
2
-
3
- Mxx_ru::Cpp::dll_target( "inout.rb" ) {
4
- target( "inout" )
5
- implib_path( "." )
6
-
7
- required_prj( "say.rb" )
8
-
9
- include_path( "." )
10
-
11
- define( "INOUT_PRJ" )
12
-
13
- if "mswin" == toolset.tag( "target_os" )
14
- define( "INOUT_MSWIN" )
15
- end
16
-
17
- cpp_source( "inout.cpp" )
18
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ Mxx_ru::Cpp::dll_target( "inout.rb" ) {
4
+ target( "inout" )
5
+ implib_path( "." )
6
+
7
+ required_prj( "say.rb" )
8
+
9
+ include_path( "." )
10
+
11
+ define( "INOUT_PRJ" )
12
+
13
+ if "mswin" == toolset.tag( "target_os" )
14
+ define( "INOUT_MSWIN" )
15
+ end
16
+
17
+ cpp_source( "inout.cpp" )
18
+ }
@@ -1,11 +1,11 @@
1
- require 'mxx_ru/cpp'
2
-
3
- Mxx_ru::Cpp::exe_target( "prj.rb" ) {
4
- target( "exe_dll_lib" )
5
-
6
- required_prj( "inout.rb" )
7
-
8
- include_path( "." )
9
-
10
- cpp_source( "main.cpp" )
11
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ Mxx_ru::Cpp::exe_target( "prj.rb" ) {
4
+ target( "exe_dll_lib" )
5
+
6
+ required_prj( "inout.rb" )
7
+
8
+ include_path( "." )
9
+
10
+ cpp_source( "main.cpp" )
11
+ }
@@ -1,9 +1,9 @@
1
- require 'mxx_ru/cpp'
2
-
3
- Mxx_ru::Cpp::lib_target( "say.rb" ) {
4
- target( "say" )
5
-
6
- include_path( "." )
7
-
8
- cpp_source( "say.cpp" )
9
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ Mxx_ru::Cpp::lib_target( "say.rb" ) {
4
+ target( "say" )
5
+
6
+ include_path( "." )
7
+
8
+ cpp_source( "say.cpp" )
9
+ }
@@ -1,10 +1,10 @@
1
- require 'mxx_ru/cpp'
2
-
3
- MxxRu::Cpp::composite_target( Mxx_ru::BUILD_ROOT ) {
4
- required_prj( "main/prj.rb" )
5
-
6
- global_include_path( "." )
7
-
8
- global_obj_placement(
9
- Mxx_ru::Cpp::CustomSubdirObjPlacement.new( 'bin', 'tmp/output' ) )
10
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::composite_target( Mxx_ru::BUILD_ROOT ) {
4
+ required_prj( "main/prj.rb" )
5
+
6
+ global_include_path( "." )
7
+
8
+ global_obj_placement(
9
+ Mxx_ru::Cpp::CustomSubdirObjPlacement.new( 'bin', 'tmp/output' ) )
10
+ }
@@ -1,16 +1,16 @@
1
- require 'mxx_ru/cpp'
2
-
3
- MxxRu::Cpp::dll_target {
4
- target( "inout" )
5
- implib_path( "lib" )
6
-
7
- required_prj( "say/prj.rb" )
8
-
9
- define( "INOUT_PRJ" )
10
-
11
- if "mswin" == toolset.tag( "target_os" )
12
- define( "INOUT_MSWIN" )
13
- end
14
-
15
- cpp_source( "inout.cpp" )
16
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::dll_target {
4
+ target( "inout" )
5
+ implib_path( "lib" )
6
+
7
+ required_prj( "say/prj.rb" )
8
+
9
+ define( "INOUT_PRJ" )
10
+
11
+ if "mswin" == toolset.tag( "target_os" )
12
+ define( "INOUT_MSWIN" )
13
+ end
14
+
15
+ cpp_source( "inout.cpp" )
16
+ }
@@ -1,9 +1,9 @@
1
- require 'mxx_ru/cpp'
2
-
3
- MxxRu::Cpp::exe_target {
4
- target( "exe_dll_lib" )
5
-
6
- required_prj( "inout/prj.rb" )
7
-
8
- cpp_source( "main.cpp" )
9
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::exe_target {
4
+ target( "exe_dll_lib" )
5
+
6
+ required_prj( "inout/prj.rb" )
7
+
8
+ cpp_source( "main.cpp" )
9
+ }
@@ -1,8 +1,8 @@
1
- require 'mxx_ru/cpp'
2
-
3
- Mxx_ru::Cpp::lib_target {
4
- target_root( "lib" )
5
- target( "say" )
6
-
7
- cpp_source( "say.cpp" )
8
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ Mxx_ru::Cpp::lib_target {
4
+ target_root( "lib" )
5
+ target( "say" )
6
+
7
+ cpp_source( "say.cpp" )
8
+ }
@@ -1,7 +1,7 @@
1
- require 'mxx_ru/cpp'
2
-
3
- Mxx_ru::Cpp::exe_target( "prj.rb" ) {
4
- target( "simple_exe" )
5
-
6
- cpp_source( "main.cpp" )
7
- }
1
+ require 'mxx_ru/cpp'
2
+
3
+ Mxx_ru::Cpp::exe_target( "prj.rb" ) {
4
+ target( "simple_exe" )
5
+
6
+ cpp_source( "main.cpp" )
7
+ }
@@ -1,335 +1,335 @@
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
-
31
- require 'mxx_ru/util'
32
-
33
- module MxxRu
34
-
35
- # File name of root project file.
36
- BUILD_ROOT = "build.rb"
37
-
38
- # Target status description.
39
- class TargetState
40
- # Target is absent or rebuild is required.
41
- ABSENT = 0
42
- # Target was rebuilt.
43
- REBUILT = 1
44
- # Target exists and up-to-date.
45
- EXISTS = 2
46
-
47
- attr_reader :state
48
-
49
- def initialize( a_state = ABSENT )
50
- @state = a_state
51
- end
52
-
53
- # Detect target status.
54
- # TargetState object returned.
55
- #
56
- # [_name_] Target name.
57
- # [_depends_] Dependencies list. Array of String.
58
- def TargetState.detect( name, depends )
59
-
60
- state = ABSENT
61
-
62
- # In dry-run mode we always return that target is absent.
63
- if !MxxRu::Util::Mode.instance.is_dry_run
64
- if FileTest.exists?( name )
65
- # It's necessary to detect time of target and it's dependencies.
66
- target_mtime = File.mtime( name )
67
- if nil != depends.find { |d|
68
- if !FileTest.exists?( d )
69
- raise MxxRu::MissingDependFileEx.new( d, name )
70
- end
71
- depend_mtime = File.mtime( d )
72
- target_mtime < depend_mtime
73
- }
74
- # More young dependency found.
75
- state = REBUILT
76
- else
77
- # Target is up-to-date.
78
- state = EXISTS
79
- end
80
- end
81
- end
82
-
83
- return TargetState.new( state )
84
- end
85
-
86
- end # Class TargetState
87
-
88
- # For compatibility with previous versions.
89
- Target_state = TargetState
90
-
91
- # Map of targets loaded.
92
- # Key is target alias -- file name with definition of a target.
93
- @@defined_targets = Hash.new
94
-
95
- # Root target alias.
96
- # This target will be used in setup_target function to start building process.
97
- @@first_target_alias = nil
98
-
99
- def MxxRu.try_set_first_target_alias( a_alias )
100
- if nil == @@first_target_alias
101
- @@first_target_alias = a_alias.clone
102
- end
103
- end
104
-
105
- def MxxRu.setup_target( target, build_enabled = true )
106
- begin
107
- if !( target_defined_for?( target.prj_alias ) )
108
- @@defined_targets[ target.prj_alias ] = target;
109
- end
110
-
111
- if build_enabled && nil != @@first_target_alias &&
112
- @@first_target_alias == target.prj_alias
113
- # It is a root project, required to build.
114
-
115
- # If this project is not root project file and root project file
116
- # exists, then we will load root project file and start build process
117
- # after that.
118
- if BUILD_ROOT != target.prj_alias
119
- if FileTest.exists?( BUILD_ROOT )
120
- require BUILD_ROOT
121
- end
122
- end
123
-
124
- target.clean if MxxRu::Util::Mode.instance.is_clean or
125
- MxxRu::Util::Mode.instance.is_rebuild
126
-
127
- target.reset if MxxRu::Util::Mode.instance.is_rebuild
128
-
129
- MxxRu::Util::build_call_wrapper( target ) if
130
- !MxxRu::Util::Mode.instance.is_clean
131
- end
132
-
133
- return target
134
- rescue MxxRu::Ex => ex
135
- $stderr.print "<<<[#{ex.class.name}]\t#{ex}>>>\n"
136
- exit( -2 )
137
- end
138
- end
139
-
140
- def MxxRu.query_target( prj_alias, mandatory )
141
- target = @@defined_targets[ prj_alias ]
142
-
143
- # If target was required, we already should found it.
144
- # Build should be stopper otherwise.
145
- if target.nil? && mandatory
146
- raise TargetUnknownEx.new( prj_alias )
147
- end
148
-
149
- return target
150
- end
151
-
152
- def MxxRu.target_defined_for?(prj_alias)
153
- return true if @@defined_targets.has_key?( prj_alias )
154
- return false
155
- end
156
-
157
- # Base class for all source code generators.
158
- class AbstractGenerator
159
- # This method is called to generate source code required.
160
- # Should be redefined in a child class.
161
- #
162
- # [_target_] Target, generator belongs to.
163
- def build( target )
164
- raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::build" )
165
- end
166
-
167
- # This method is called to cleanup of generated source code files.
168
- #
169
- # [_target_] Target, generator belongs to.
170
- def clean( target )
171
- raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::clean" )
172
- end
173
- end
174
-
175
- # For compatibility with previous versions.
176
- Abstract_generator = AbstractGenerator
177
-
178
- # Base class for all targets.
179
- class AbstractTarget
180
- # List of full file names, created during a build of the target.
181
- # It may be an empty array if target doesn't create any files.
182
- # For example, if target is a composite or unittest.
183
- attr_reader :mxx_full_targets_names
184
-
185
- # Vector of subordinated projects.
186
- attr_reader :mxx_required_prjs
187
-
188
- # Vector of source code generators.
189
- attr_reader :mxx_generators
190
-
191
- # Metacode for generating 'plural' version of singular method.
192
- # Plural version accept Enumerable-type argument and call
193
- # singular version for each member of Enumerable argument.
194
- #
195
- # For example:
196
- # define_plural_form_method :required_prj
197
- # define_plural_form_method :cpp_source
198
- # produces methods
199
- # required_prjs( items )
200
- # cpp_sources( items )
201
- #
202
- def AbstractTarget.define_plural_form_method( singular_method )
203
- class_eval %Q{
204
- def #{singular_method}s(a)
205
- a.each { |e| #{singular_method}( e ) }
206
- end
207
- }
208
- end
209
-
210
- def initialize( a_prj_alias )
211
- @mxx_full_targets_names = Array.new
212
- @mxx_prj_alias = a_prj_alias
213
- @mxx_required_prjs = Array.new
214
- @mxx_generators = Array.new
215
-
216
- MxxRu.try_set_first_target_alias( a_prj_alias )
217
- end
218
-
219
- # Add one more file, created during a target build.
220
- def mxx_add_full_target_name( a_full_name )
221
- @mxx_full_targets_names << a_full_name
222
- end
223
-
224
- def prj_alias
225
- return @mxx_prj_alias
226
- end
227
-
228
- # Add one more project in a list of subordinated projects.
229
- #
230
- # Returns target object, which is defined in subordinated project.
231
- def required_prj( a_prj )
232
- # If project is not loaded yet, loding it.
233
- # Then adding created target object to the list ofd subordinated projects.
234
- # If no target will be created, exception would be thrown.
235
- if !MxxRu::target_defined_for?( a_prj )
236
- require a_prj
237
- end
238
-
239
- target = MxxRu::query_target( a_prj, true )
240
- @mxx_required_prjs << target
241
-
242
- return target
243
- end
244
-
245
- # Plural form of required_prj.
246
- #
247
- # For example:
248
- # required_prjs [ 'module1/prj.rb', 'module2/prj.rb' ]
249
- # required_prjs Dir.glob( 'modules/**/prj.rb' )
250
- define_plural_form_method :required_prj
251
-
252
- # Add one more generator to the target.
253
- # Reference to the target is returned.
254
- def generator( a_generator )
255
- @mxx_generators << a_generator
256
- return a_generator
257
- end
258
-
259
- # Child classes should redefine this method.
260
- # TargetState object is returned.
261
- def build
262
- raise AbstractMethodEx.new( "AbstractTarget::build" )
263
- end
264
-
265
- # Child classes should redefine this method.
266
- def clean
267
- raise AbstractMethodEx.new( "AbstractTarget::clean" )
268
- end
269
-
270
- # Child classes should redefine this method.
271
- # Base class does not implement it.
272
- def reset
273
- end
274
-
275
- # Executing command line given.
276
- #
277
- # [a_cmd_lines] Array of String
278
- # [a_to_destroy_on_fail] Files required to be cleaned up if any of given
279
- # command fail.
280
- # [brief_desc] Brief description of command (will be shown if
281
- # --mxx-brief-show specified in command line)
282
- def AbstractTarget.run(
283
- a_cmd_lines, a_to_destroy_on_fail, brief_desc = nil )
284
-
285
- MxxRu.show_brief( brief_desc )
286
-
287
- a_cmd_lines.each { |c|
288
- puts "<<< #{c} >>>" \
289
- if MxxRu::Util::Mode.instance.is_show_cmd
290
-
291
- # Do not actually execute in dry-run mode.
292
- if !MxxRu::Util::Mode.instance.is_dry_run
293
- if !system( c )
294
- a_to_destroy_on_fail.each { |d|
295
- MxxRu::Util::delete_file( d ) }
296
- raise BuildEx.new( c, $? )
297
- end
298
- end
299
- }
300
- end
301
-
302
- protected
303
- # Build of all projects required for the target.
304
- # Returns MxxRu::TargetState.
305
- def build_required_projects
306
- state = MxxRu::TargetState::EXISTS
307
- @mxx_required_prjs.each { |p|
308
- prj_state = MxxRu::Util::build_call_wrapper( p )
309
- if MxxRu::TargetState::EXISTS != prj_state.state
310
- state = prj_state.state
311
- end
312
- }
313
-
314
- return MxxRu::TargetState.new( state )
315
- end
316
-
317
- # Cleanup of all projects required for the target.
318
- # Executed only if dry-run mode is disabled.
319
- def clean_required_prjs
320
- if !MxxRu::Util::Mode.instance.is_dry_run
321
- @mxx_required_prjs.each { |p| p.clean }
322
- end
323
- end
324
-
325
- # Reset build status for all projects required for the target.
326
- def reset_required_projects
327
- @mxx_required_prjs.each { |p| p.reset }
328
- end
329
-
330
- end
331
-
332
- # For compatibility with previous versions.
333
- Abstract_target = AbstractTarget
334
-
335
- 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
+
31
+ require 'mxx_ru/util'
32
+
33
+ module MxxRu
34
+
35
+ # File name of root project file.
36
+ BUILD_ROOT = "build.rb"
37
+
38
+ # Target status description.
39
+ class TargetState
40
+ # Target is absent or rebuild is required.
41
+ ABSENT = 0
42
+ # Target was rebuilt.
43
+ REBUILT = 1
44
+ # Target exists and up-to-date.
45
+ EXISTS = 2
46
+
47
+ attr_reader :state
48
+
49
+ def initialize( a_state = ABSENT )
50
+ @state = a_state
51
+ end
52
+
53
+ # Detect target status.
54
+ # TargetState object returned.
55
+ #
56
+ # [_name_] Target name.
57
+ # [_depends_] Dependencies list. Array of String.
58
+ def TargetState.detect( name, depends )
59
+
60
+ state = ABSENT
61
+
62
+ # In dry-run mode we always return that target is absent.
63
+ if !MxxRu::Util::Mode.instance.is_dry_run
64
+ if FileTest.exists?( name )
65
+ # It's necessary to detect time of target and it's dependencies.
66
+ target_mtime = File.mtime( name )
67
+ if nil != depends.find { |d|
68
+ if !FileTest.exists?( d )
69
+ raise MxxRu::MissingDependFileEx.new( d, name )
70
+ end
71
+ depend_mtime = File.mtime( d )
72
+ target_mtime < depend_mtime
73
+ }
74
+ # More young dependency found.
75
+ state = REBUILT
76
+ else
77
+ # Target is up-to-date.
78
+ state = EXISTS
79
+ end
80
+ end
81
+ end
82
+
83
+ return TargetState.new( state )
84
+ end
85
+
86
+ end # Class TargetState
87
+
88
+ # For compatibility with previous versions.
89
+ Target_state = TargetState
90
+
91
+ # Map of targets loaded.
92
+ # Key is target alias -- file name with definition of a target.
93
+ @@defined_targets = Hash.new
94
+
95
+ # Root target alias.
96
+ # This target will be used in setup_target function to start building process.
97
+ @@first_target_alias = nil
98
+
99
+ def MxxRu.try_set_first_target_alias( a_alias )
100
+ if nil == @@first_target_alias
101
+ @@first_target_alias = a_alias.clone
102
+ end
103
+ end
104
+
105
+ def MxxRu.setup_target( target, build_enabled = true )
106
+ begin
107
+ if !( target_defined_for?( target.prj_alias ) )
108
+ @@defined_targets[ target.prj_alias ] = target;
109
+ end
110
+
111
+ if build_enabled && nil != @@first_target_alias &&
112
+ @@first_target_alias == target.prj_alias
113
+ # It is a root project, required to build.
114
+
115
+ # If this project is not root project file and root project file
116
+ # exists, then we will load root project file and start build process
117
+ # after that.
118
+ if BUILD_ROOT != target.prj_alias
119
+ if FileTest.exists?( BUILD_ROOT )
120
+ require BUILD_ROOT
121
+ end
122
+ end
123
+
124
+ target.clean if MxxRu::Util::Mode.instance.is_clean or
125
+ MxxRu::Util::Mode.instance.is_rebuild
126
+
127
+ target.reset if MxxRu::Util::Mode.instance.is_rebuild
128
+
129
+ MxxRu::Util::build_call_wrapper( target ) if
130
+ !MxxRu::Util::Mode.instance.is_clean
131
+ end
132
+
133
+ return target
134
+ rescue MxxRu::Ex => ex
135
+ $stderr.print "<<<[#{ex.class.name}]\t#{ex}>>>\n"
136
+ exit( -2 )
137
+ end
138
+ end
139
+
140
+ def MxxRu.query_target( prj_alias, mandatory )
141
+ target = @@defined_targets[ prj_alias ]
142
+
143
+ # If target was required, we already should found it.
144
+ # Build should be stopper otherwise.
145
+ if target.nil? && mandatory
146
+ raise TargetUnknownEx.new( prj_alias )
147
+ end
148
+
149
+ return target
150
+ end
151
+
152
+ def MxxRu.target_defined_for?(prj_alias)
153
+ return true if @@defined_targets.has_key?( prj_alias )
154
+ return false
155
+ end
156
+
157
+ # Base class for all source code generators.
158
+ class AbstractGenerator
159
+ # This method is called to generate source code required.
160
+ # Should be redefined in a child class.
161
+ #
162
+ # [_target_] Target, generator belongs to.
163
+ def build( target )
164
+ raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::build" )
165
+ end
166
+
167
+ # This method is called to cleanup of generated source code files.
168
+ #
169
+ # [_target_] Target, generator belongs to.
170
+ def clean( target )
171
+ raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::clean" )
172
+ end
173
+ end
174
+
175
+ # For compatibility with previous versions.
176
+ Abstract_generator = AbstractGenerator
177
+
178
+ # Base class for all targets.
179
+ class AbstractTarget
180
+ # List of full file names, created during a build of the target.
181
+ # It may be an empty array if target doesn't create any files.
182
+ # For example, if target is a composite or unittest.
183
+ attr_reader :mxx_full_targets_names
184
+
185
+ # Vector of subordinated projects.
186
+ attr_reader :mxx_required_prjs
187
+
188
+ # Vector of source code generators.
189
+ attr_reader :mxx_generators
190
+
191
+ # Metacode for generating 'plural' version of singular method.
192
+ # Plural version accept Enumerable-type argument and call
193
+ # singular version for each member of Enumerable argument.
194
+ #
195
+ # For example:
196
+ # define_plural_form_method :required_prj
197
+ # define_plural_form_method :cpp_source
198
+ # produces methods
199
+ # required_prjs( items )
200
+ # cpp_sources( items )
201
+ #
202
+ def AbstractTarget.define_plural_form_method( singular_method )
203
+ class_eval %Q{
204
+ def #{singular_method}s(a)
205
+ a.each { |e| #{singular_method}( e ) }
206
+ end
207
+ }
208
+ end
209
+
210
+ def initialize( a_prj_alias )
211
+ @mxx_full_targets_names = Array.new
212
+ @mxx_prj_alias = a_prj_alias
213
+ @mxx_required_prjs = Array.new
214
+ @mxx_generators = Array.new
215
+
216
+ MxxRu.try_set_first_target_alias( a_prj_alias )
217
+ end
218
+
219
+ # Add one more file, created during a target build.
220
+ def mxx_add_full_target_name( a_full_name )
221
+ @mxx_full_targets_names << a_full_name
222
+ end
223
+
224
+ def prj_alias
225
+ return @mxx_prj_alias
226
+ end
227
+
228
+ # Add one more project in a list of subordinated projects.
229
+ #
230
+ # Returns target object, which is defined in subordinated project.
231
+ def required_prj( a_prj )
232
+ # If project is not loaded yet, loding it.
233
+ # Then adding created target object to the list ofd subordinated projects.
234
+ # If no target will be created, exception would be thrown.
235
+ if !MxxRu::target_defined_for?( a_prj )
236
+ require a_prj
237
+ end
238
+
239
+ target = MxxRu::query_target( a_prj, true )
240
+ @mxx_required_prjs << target
241
+
242
+ return target
243
+ end
244
+
245
+ # Plural form of required_prj.
246
+ #
247
+ # For example:
248
+ # required_prjs [ 'module1/prj.rb', 'module2/prj.rb' ]
249
+ # required_prjs Dir.glob( 'modules/**/prj.rb' )
250
+ define_plural_form_method :required_prj
251
+
252
+ # Add one more generator to the target.
253
+ # Reference to the target is returned.
254
+ def generator( a_generator )
255
+ @mxx_generators << a_generator
256
+ return a_generator
257
+ end
258
+
259
+ # Child classes should redefine this method.
260
+ # TargetState object is returned.
261
+ def build
262
+ raise AbstractMethodEx.new( "AbstractTarget::build" )
263
+ end
264
+
265
+ # Child classes should redefine this method.
266
+ def clean
267
+ raise AbstractMethodEx.new( "AbstractTarget::clean" )
268
+ end
269
+
270
+ # Child classes should redefine this method.
271
+ # Base class does not implement it.
272
+ def reset
273
+ end
274
+
275
+ # Executing command line given.
276
+ #
277
+ # [a_cmd_lines] Array of String
278
+ # [a_to_destroy_on_fail] Files required to be cleaned up if any of given
279
+ # command fail.
280
+ # [brief_desc] Brief description of command (will be shown if
281
+ # --mxx-brief-show specified in command line)
282
+ def AbstractTarget.run(
283
+ a_cmd_lines, a_to_destroy_on_fail, brief_desc = nil )
284
+
285
+ MxxRu.show_brief( brief_desc )
286
+
287
+ a_cmd_lines.each { |c|
288
+ puts "<<< #{c} >>>" \
289
+ if MxxRu::Util::Mode.instance.is_show_cmd
290
+
291
+ # Do not actually execute in dry-run mode.
292
+ if !MxxRu::Util::Mode.instance.is_dry_run
293
+ if !system( c )
294
+ a_to_destroy_on_fail.each { |d|
295
+ MxxRu::Util::delete_file( d ) }
296
+ raise BuildEx.new( c, $? )
297
+ end
298
+ end
299
+ }
300
+ end
301
+
302
+ protected
303
+ # Build of all projects required for the target.
304
+ # Returns MxxRu::TargetState.
305
+ def build_required_projects
306
+ state = MxxRu::TargetState::EXISTS
307
+ @mxx_required_prjs.each { |p|
308
+ prj_state = MxxRu::Util::build_call_wrapper( p )
309
+ if MxxRu::TargetState::EXISTS != prj_state.state
310
+ state = prj_state.state
311
+ end
312
+ }
313
+
314
+ return MxxRu::TargetState.new( state )
315
+ end
316
+
317
+ # Cleanup of all projects required for the target.
318
+ # Executed only if dry-run mode is disabled.
319
+ def clean_required_prjs
320
+ if !MxxRu::Util::Mode.instance.is_dry_run
321
+ @mxx_required_prjs.each { |p| p.clean }
322
+ end
323
+ end
324
+
325
+ # Reset build status for all projects required for the target.
326
+ def reset_required_projects
327
+ @mxx_required_prjs.each { |p| p.reset }
328
+ end
329
+
330
+ end
331
+
332
+ # For compatibility with previous versions.
333
+ Abstract_target = AbstractTarget
334
+
335
+ end