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,103 +1,103 @@
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/binary_library'
30
- require 'mxx_ru/cpp/toolsets/gcc_family'
31
-
32
- module MxxRu
33
- module Cpp
34
- module Toolsets
35
-
36
- # Base class for Unix GCC ports.
37
- #
38
- # Under Unix library name in '-l' linker option can be either static or shared.
39
- # Therefore on Unix MxxRu must do special action to handle Target#lib_static
40
- # and Target#lib_shared descriptions. This action implemented in this class.
41
- class GccUnixFamily < GccFamily
42
- def initialize( name )
43
- super( name )
44
- end
45
-
46
- # Special implementation for support explicit library type linker option.
47
- def make_linker_include_lib_options( target, libs )
48
- current_lib_type = nil
49
- all_libs = libs.inject( '' ) { |r, l|
50
- # Insert new lib mode switch only if next library has different
51
- # type than current type.
52
- if nil == current_lib_type || current_lib_type != l.type
53
- r << switch_to_default_lib_mode_if_needed( current_lib_type )
54
- current_lib_type = l.type
55
- if BinaryLibrary::ANY != l.type &&
56
- default_lib_linking_mode != l.type
57
- r << lib_linking_mode_switch( l.type )
58
- end
59
- end
60
-
61
- r << '-l' << port_specific_lib_name_checker( l.name ) << ' '
62
- }
63
- all_libs << switch_to_default_lib_mode_if_needed( current_lib_type )
64
- "-Wl,--start-group #{all_libs} -Wl,--end-group "
65
- end
66
-
67
- # Return default library linking mode for current platform.
68
- #
69
- # Default mode BinaryLibrary::SHARED for Unix with GCC assumed.
70
- # But default mode can be specified in toolset tag 'lib_linking_mode'.
71
- def default_lib_linking_mode
72
- t = tag( 'lib_linking_mode', 'unknown' )
73
- if 'unknown' != t
74
- 'static' == t ? BinaryLibrary::STATIC : BinaryLibrary::SHARED
75
- else
76
- BinaryLibrary::SHARED
77
- end
78
- end
79
-
80
- # Return command line switch for forcing specified library type.
81
- def lib_linking_mode_switch( linking_mode )
82
- "-Wl,#{linking_mode == BinaryLibrary::SHARED ? '-Bdynamic' : '-Bstatic'} "
83
- end
84
-
85
- # Return command line switch for closing group of libraries with same type.
86
- # Empty string returned if current_lib_type is nil of is current_lib_type
87
- # is default lib linking mode on this platform.
88
- def switch_to_default_lib_mode_if_needed( current_lib_type )
89
- if nil != current_lib_type &&
90
- BinaryLibrary::ANY != current_lib_type &&
91
- default_lib_linking_mode != current_lib_type
92
- lib_linking_mode_switch( default_lib_linking_mode )
93
- else
94
- ''
95
- end
96
- end
97
-
98
- end
99
-
100
- end # module Toolsets
101
- end # module Cpp
102
- end # module MxxRu
103
-
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/binary_library'
30
+ require 'mxx_ru/cpp/toolsets/gcc_family'
31
+
32
+ module MxxRu
33
+ module Cpp
34
+ module Toolsets
35
+
36
+ # Base class for Unix GCC ports.
37
+ #
38
+ # Under Unix library name in '-l' linker option can be either static or shared.
39
+ # Therefore on Unix MxxRu must do special action to handle Target#lib_static
40
+ # and Target#lib_shared descriptions. This action implemented in this class.
41
+ class GccUnixFamily < GccFamily
42
+ def initialize( name )
43
+ super( name )
44
+ end
45
+
46
+ # Special implementation for support explicit library type linker option.
47
+ def make_linker_include_lib_options( target, libs )
48
+ current_lib_type = nil
49
+ all_libs = libs.inject( '' ) { |r, l|
50
+ # Insert new lib mode switch only if next library has different
51
+ # type than current type.
52
+ if nil == current_lib_type || current_lib_type != l.type
53
+ r << switch_to_default_lib_mode_if_needed( current_lib_type )
54
+ current_lib_type = l.type
55
+ if BinaryLibrary::ANY != l.type &&
56
+ default_lib_linking_mode != l.type
57
+ r << lib_linking_mode_switch( l.type )
58
+ end
59
+ end
60
+
61
+ r << '-l' << port_specific_lib_name_checker( l.name ) << ' '
62
+ }
63
+ all_libs << switch_to_default_lib_mode_if_needed( current_lib_type )
64
+ "-Wl,--start-group #{all_libs} -Wl,--end-group "
65
+ end
66
+
67
+ # Return default library linking mode for current platform.
68
+ #
69
+ # Default mode BinaryLibrary::SHARED for Unix with GCC assumed.
70
+ # But default mode can be specified in toolset tag 'lib_linking_mode'.
71
+ def default_lib_linking_mode
72
+ t = tag( 'lib_linking_mode', 'unknown' )
73
+ if 'unknown' != t
74
+ 'static' == t ? BinaryLibrary::STATIC : BinaryLibrary::SHARED
75
+ else
76
+ BinaryLibrary::SHARED
77
+ end
78
+ end
79
+
80
+ # Return command line switch for forcing specified library type.
81
+ def lib_linking_mode_switch( linking_mode )
82
+ "-Wl,#{linking_mode == BinaryLibrary::SHARED ? '-Bdynamic' : '-Bstatic'} "
83
+ end
84
+
85
+ # Return command line switch for closing group of libraries with same type.
86
+ # Empty string returned if current_lib_type is nil of is current_lib_type
87
+ # is default lib linking mode on this platform.
88
+ def switch_to_default_lib_mode_if_needed( current_lib_type )
89
+ if nil != current_lib_type &&
90
+ BinaryLibrary::ANY != current_lib_type &&
91
+ default_lib_linking_mode != current_lib_type
92
+ lib_linking_mode_switch( default_lib_linking_mode )
93
+ else
94
+ ''
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end # module Toolsets
101
+ end # module Cpp
102
+ end # module MxxRu
103
+
@@ -1,62 +1,62 @@
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/cpp/toolsets/vc_family'
30
-
31
- module MxxRu
32
- module Cpp
33
- module Toolsets
34
-
35
- # Toolset implemetation for Visual C++ 7.*
36
- class Vc7 < MxxRu::Cpp::Toolsets::VcFamily
37
- public
38
- def initialize( a_name = "vc" )
39
- super( a_name )
40
-
41
- setup_tag( "ver_hi", "7" )
42
- setup_tag( "ver_lo", "1" )
43
- end
44
-
45
- def setup_mandatory_options( target )
46
- if RUNTIME_DEBUG == target.mxx_runtime_mode
47
- target.compiler_option( "-Yd" )
48
- end
49
-
50
- super( target )
51
- end
52
-
53
- end # class Vc7
54
-
55
- end # module Toolsets
56
-
57
- end # module Cpp
58
-
59
- end # module MxxRu
60
-
61
- MxxRu::Cpp::setup_toolset( MxxRu::Cpp::Toolsets::Vc7.new )
62
-
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/cpp/toolsets/vc_family'
30
+
31
+ module MxxRu
32
+ module Cpp
33
+ module Toolsets
34
+
35
+ # Toolset implemetation for Visual C++ 7.*
36
+ class Vc7 < MxxRu::Cpp::Toolsets::VcFamily
37
+ public
38
+ def initialize( a_name = "vc" )
39
+ super( a_name )
40
+
41
+ setup_tag( "ver_hi", "7" )
42
+ setup_tag( "ver_lo", "1" )
43
+ end
44
+
45
+ def setup_mandatory_options( target )
46
+ if RUNTIME_DEBUG == target.mxx_runtime_mode
47
+ target.compiler_option( "-Yd" )
48
+ end
49
+
50
+ super( target )
51
+ end
52
+
53
+ end # class Vc7
54
+
55
+ end # module Toolsets
56
+
57
+ end # module Cpp
58
+
59
+ end # module MxxRu
60
+
61
+ MxxRu::Cpp::setup_toolset( MxxRu::Cpp::Toolsets::Vc7.new )
62
+
@@ -1,455 +1,455 @@
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 'ostruct'
30
- require 'set'
31
-
32
- require 'mxx_ru/cpp/target'
33
- require 'mxx_ru/cpp/toolsets/vc_family'
34
-
35
- module MxxRu
36
- module Cpp
37
-
38
- # Expand class Target to store source and actual manifest descriptions.
39
- class Target < MxxRu::BinaryTarget
40
- # Get source manifest description. If target has no manifest
41
- # then default manifest will be returned.
42
- def vc8_source_manifest
43
- if nil != @vc8_source_manifest
44
- @vc8_source_manifest
45
- else
46
- MxxRu::Cpp::Toolsets::Vc8::default_manifest
47
- end
48
- end
49
-
50
- # Setter for source manifest description.
51
- def vc8_source_manifest=( manifest )
52
- @vc8_source_manifest = manifest
53
- end
54
-
55
- attr_accessor :vc8_actual_manifest
56
-
57
- end
58
-
59
- module Toolsets
60
-
61
- # Toolset implementation for Visual C++ 2005 (8.0)
62
- #
63
- # Setups following tags:
64
- # [_ver_hi_] high version number. Value: 8.
65
- # [_ver_lo_] low version number. Value: 0.
66
- class Vc8 < MxxRu::Cpp::Toolsets::VcFamily
67
-
68
- # Actual manifest description.
69
- class ActualManifest
70
- attr_reader :manifest_file
71
- attr_reader :digital_resource_id
72
-
73
- def initialize(
74
- source_manifest,
75
- manifest_file,
76
- digital_resource_id )
77
- @source_manifest = source_manifest
78
- @manifest_file = manifest_file
79
- @digital_resource_id = digital_resource_id
80
- end
81
-
82
- # Is autogeneration of manifest must be used?
83
- def autogen?
84
- @source_manifest.autogen
85
- end
86
-
87
- # Is manifest tool (mt.exe) must be used?
88
- def mt?
89
- @source_manifest.mt
90
- end
91
-
92
- # Is autogenerated manifest file should be kept after
93
- # embeding into executable?
94
- # By default autogenerated manifest file will be deleted.
95
- def keep_manifest_file?
96
- ( mt? and autogen? ) ? @source_manifest.keep_manifest_file : true
97
- end
98
- end # class ActualManifest
99
-
100
- # For compatibility with previous versions.
101
- Actual_manifest = ActualManifest
102
-
103
- @@default_manifest = OpenStruct.new(
104
- :autogen => true,
105
- :mt => true,
106
- :manifest_file => :default,
107
- :resource_id => :default,
108
- :keep_manifest_file => false )
109
-
110
- # Set of avaliable values for :resource_id key-value pair
111
- # in manifest description.
112
- @@resource_id_names = Set.new( [
113
- :default,
114
- :process_manifest,
115
- :isolationaware_manifest,
116
- :isolationaware_nostaticimport_manifest ] )
117
-
118
- public
119
- def initialize( a_name = "vc" )
120
- super( a_name )
121
-
122
- setup_tag( "ver_hi", "8" )
123
- setup_tag( "ver_lo", "0" )
124
- end
125
-
126
- # Check some VC8.0 constraints before calling superclass
127
- # implementation
128
- #
129
- # VC8.0 does not support Single-Thread Run-Time.
130
- def setup_mandatory_options( target )
131
- if THREADING_SINGLE == target.mxx_threading_mode
132
- raise MxxRu::UnsupportedModeEx.new(
133
- "Visual C++ 2005 not supports " +
134
- "single-threaded static RTL" )
135
- elsif THREADING_DEFAULT == target.mxx_threading_mode
136
- # Because VC8.0 not support Single Thread Run-Time then
137
- # by default we must use Mutli-Threading Run-Time.
138
- target.threading_mode( THREADING_MULTI )
139
- end
140
-
141
- super( target )
142
-
143
- setup_manifest( target )
144
- setup_manifest_params( target )
145
- end
146
-
147
- # Remove autogenerated manifest file if any.
148
- def clean_dll_specific_files( dll_file, dll_info, target )
149
- super( dll_file, dll_info, target )
150
- clean_autogenerated_manifest( target )
151
- end
152
-
153
- # Remove autogenerated manifest file if any.
154
- def clean_exe_specific_files( exe_file, exe_info, target )
155
- super( exe_file, exe_info, target )
156
- clean_autogenerated_manifest( target )
157
- end
158
-
159
- # Append command line for embeding manifest file to result
160
- # of super class implementation.
161
- def make_dll_command_lines(
162
- dll_name,
163
- dll_info,
164
- linker_lists,
165
- target )
166
-
167
- append_mt_command_lines(
168
- super( dll_name, dll_info, linker_lists, target ),
169
- dll_name,
170
- target )
171
- end
172
-
173
- # Append command line for embeding manifest file to result
174
- # of super class implementation.
175
- def make_exe_command_lines(
176
- exe_name,
177
- exe_info,
178
- linker_lists,
179
- target )
180
- append_mt_command_lines(
181
- super( exe_name, exe_info, linker_lists, target ),
182
- exe_name,
183
- target )
184
- end
185
-
186
- # Make manifest description.
187
- #
188
- # Examples:
189
- # # Autogenerate manifest for target. Do not embed into executable.
190
- # # Manifest stored in <target>.manifest file.
191
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
192
- # :target => self,
193
- # :autogen => :to_default_file )
194
- #
195
- # # Autogenerate manifest for target. Embed into executable.
196
- # # Autogenerated manifest will be deleted after embeding.
197
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
198
- # :target => self,
199
- # :autogen => :to_default_file,
200
- # :mt => {} )
201
- #
202
- # # Autogenerate manifest for target. Embed into executable.
203
- # # Autogenerated manifest will be kept after embeding.
204
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
205
- # :target => self,
206
- # :autogen => :to_default_file,
207
- # :mt => { :keep_manifest_file => true } )
208
- #
209
- # # Autogenerate manifest for target. Embed into executable as
210
- # # resource with id CREATEPROCESS_MANIFEST_RESOURCE_ID id.
211
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
212
- # :target => self,
213
- # :autogen => :to_default_file,
214
- # :mt => { :resource_id => :process_manifest } )
215
- #
216
- # # Autogenerate manifest for target. Store manifest into
217
- # # file 'hello_world.exe.manifest'. Embed info executable.
218
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
219
- # :target => self,
220
- # :autogen => 'hello_world.exe.manifest',
221
- # :mt => {} )
222
- #
223
- # # Embed manifest from file 'hello_world.exe.manifest' into
224
- # # target executable.
225
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
226
- # :target => self,
227
- # :mt => { :manifest => 'hello_world.exe.manifest' } )
228
- # # Embed manifest from file 'hello_world.dll.manifest' into
229
- # # target executable as resource with
230
- # # ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID id.
231
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
232
- # :target => self,
233
- # :mt => { :manifest => 'hello_world.exe.manifest',
234
- # :resource_id => :isolationaware_nonstaticimport } )
235
- #
236
- # # Autogenerate manifest for all targets in build. Store manifest
237
- # # in default files. Do not embed manifest into executable.
238
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
239
- # :autogen => :to_default_file )
240
- #
241
- # # Autogenerate manifest for all targets in build. Store manifest
242
- # # in default files. Embed manifest into executable.
243
- # MxxRu::Cpp::Toolsets::Vc8::manifest(
244
- # :autogen => :to_default_file,
245
- # :mt => {} )
246
- #
247
- # # Drop default manifest for build. Only explicitly specified
248
- # # manifest will be generated.
249
- # MxxRu::Cpp::Toolsets::Vc8::manifest( nil )
250
- #
251
- def self.manifest( params )
252
- if nil == params
253
- # No default manifest.
254
- @@default_manifest = nil
255
- else
256
- check_manifest_params( params )
257
-
258
- d = OpenStruct.new( :keep_manifest_file => true )
259
-
260
- if params.key?( :autogen )
261
- d.autogen = true
262
- d.manifest_file = ( params[ :autogen ] == :to_default_file ?
263
- :default : params[ :autogen ] )
264
- d.keep_manifest_file = false
265
- else
266
- d.autogen = false
267
- end
268
-
269
- if params.key?( :mt ) && nil != params[ :mt ]
270
- d.mt = true
271
- mt_params = params[ :mt ]
272
- d.manifest_file = mt_params[ :manifest ] if
273
- mt_params.key?( :manifest )
274
- d.resource_id = ( mt_params.key?( :resource_id ) ?
275
- mt_params[ :resource_id ] : :default )
276
-
277
- if mt_params.key?( :keep_manifest_file ) and
278
- params.key?( :autogen )
279
- d.keep_manifest_file = mt_params[ :keep_manifest_file ]
280
- end
281
- else
282
- d.mt = false
283
- end
284
-
285
- if params.key?( :target )
286
- # Source manifest must be set for specified target.
287
- params[ :target ].vc8_source_manifest = d
288
- else
289
- # This is new default manifest.
290
- @@default_manifest = d
291
- end
292
- end
293
- end
294
-
295
- # Get default manifest.
296
- def self.default_manifest
297
- @@default_manifest
298
- end
299
-
300
- protected
301
- # Set actual manifest for target if source manifest defined
302
- # (or default manifest exists).
303
- def setup_manifest( target )
304
- # Manifest can be set only for EXE or DLL.
305
- if ExeTargetType::TYPE == target.target_type.name or
306
- DllTargetType::TYPE == target.target_type.name
307
- desc = target.vc8_source_manifest
308
-
309
- if nil != desc
310
- # Actual manifest must be created for target.
311
- manifest_file =
312
- if :default == desc.manifest_file
313
- # We must create name for manifest.
314
- if ExeTargetType::TYPE == target.target_type.name
315
- make_exe_name(
316
- target.mxx_target_name,
317
- target ).full_name
318
- else
319
- make_dll_name(
320
- target.mxx_target_name,
321
- target ).full_name
322
- end + ".manifest"
323
- else
324
- # Manifest filename already specified.
325
- desc.manifest_file
326
- end
327
-
328
- # If mt.exe will be used then we must determine
329
- # digital resource_id for manifest resource.
330
- digital_resource_id =
331
- if desc.mt
332
- case desc.resource_id
333
- when :default:
334
- # Resource ID must be caclulated based on
335
- # target type.
336
- ExeTargetType::TYPE == target.target_type.name ? 1 : 2
337
- when :process_manifest: 1
338
- when :isolationaware_manifest: 2
339
- else
340
- # :isolationaware_nostaticimport_manifest
341
- 3
342
- end
343
- else
344
- nil
345
- end
346
-
347
- target.vc8_actual_manifest = ActualManifest.new(
348
- desc,
349
- manifest_file,
350
- digital_resource_id )
351
- end
352
- end
353
- end
354
-
355
- # Setup linker params for processing target manifest.
356
- def setup_manifest_params( target )
357
- m = target.vc8_actual_manifest
358
- if nil != m and m.autogen?
359
- # Linker must generate manifest.
360
- target.linker_option( '/MANIFEST' )
361
- target.linker_option( '/MANIFESTFILE:' + m.manifest_file )
362
- else
363
- # Linker should not generate manifest.
364
- target.linker_option( '/MANIFEST:NO' )
365
- end
366
- end
367
-
368
- # Remove autogenerated manifest file if any.
369
- def clean_autogenerated_manifest( target )
370
- m = target.vc8_actual_manifest
371
- MxxRu::Util::delete_file( m.manifest_file ) if
372
- m != nil and m.autogen?
373
- end
374
-
375
- # Append command line for embeding manifest file to end of
376
- # specified command line list.
377
- def append_mt_command_lines(
378
- cmd_lines,
379
- target_name,
380
- target )
381
-
382
- m = target.vc8_actual_manifest
383
- if nil != m and m.mt?
384
- cmd_lines << "#{mt_name} /nologo " +
385
- "/outputresource:\"#{target_name};\#" +
386
- "#{m.digital_resource_id}\" " +
387
- "/manifest \"#{m.manifest_file}\""
388
-
389
- if !m.keep_manifest_file?
390
- # del utility doesn't work with unix slashes
391
- cmd_lines << "del \"#{MxxRu::Util::native_pathname(m.manifest_file)}\""
392
- end
393
- end
394
-
395
- cmd_lines
396
- end
397
-
398
- # Name of manifest tool executable
399
- def mt_name
400
- "mt"
401
- end
402
-
403
- # Checking manifest params validity.
404
- def self.check_manifest_params( params )
405
- if nil != params
406
- if params.key?( :mt )
407
- mt_hash = params[ :mt ]
408
-
409
- # :resource_id must have one of avaliable values.
410
- if mt_hash.key?( :resource_id ) and
411
- !@@resource_id_names.member?( mt_hash[ :resource_id ] )
412
- raise InvalidValueEx.new(
413
- "invalid value for :resource_id key: " +
414
- "'#{mt_hash[:resource_id]}'" )
415
- end
416
-
417
- if !mt_hash.key?( :manifest ) and
418
- !params.key?( :autogen )
419
-
420
- raise InvalidValueEx.new(
421
- "no manifest file name specified" )
422
- end
423
-
424
- # :keep_manifest_file should be Bool.
425
- if mt_hash.key?( :keep_manifest_file ) and
426
- true != mt_hash[ :keep_manifest_file ] and
427
- false != mt_hash[ :keep_manifest_file ]
428
- raise InvalidValueEx.new(
429
- "value for :keep_manifest_file should be 'true' " +
430
- "or 'false'" )
431
- end
432
- end
433
-
434
- if params.key?( :autogen )
435
- v = params[ :autogen ]
436
- if !( v == :to_default_file or
437
- v.kind_of?( String ) )
438
- raise InvalidValueEx.new(
439
- "invalid value for :autogen (must be " +
440
- ":to_default_file or String instance)" )
441
- end
442
- end
443
- end
444
- end
445
-
446
- end # class Vc8
447
-
448
- end # module Toolsets
449
-
450
- end # module Cpp
451
-
452
- end # module MxxRu
453
-
454
- MxxRu::Cpp::setup_toolset( MxxRu::Cpp::Toolsets::Vc8.new )
455
-
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 'ostruct'
30
+ require 'set'
31
+
32
+ require 'mxx_ru/cpp/target'
33
+ require 'mxx_ru/cpp/toolsets/vc_family'
34
+
35
+ module MxxRu
36
+ module Cpp
37
+
38
+ # Expand class Target to store source and actual manifest descriptions.
39
+ class Target < MxxRu::BinaryTarget
40
+ # Get source manifest description. If target has no manifest
41
+ # then default manifest will be returned.
42
+ def vc8_source_manifest
43
+ if nil != @vc8_source_manifest
44
+ @vc8_source_manifest
45
+ else
46
+ MxxRu::Cpp::Toolsets::Vc8::default_manifest
47
+ end
48
+ end
49
+
50
+ # Setter for source manifest description.
51
+ def vc8_source_manifest=( manifest )
52
+ @vc8_source_manifest = manifest
53
+ end
54
+
55
+ attr_accessor :vc8_actual_manifest
56
+
57
+ end
58
+
59
+ module Toolsets
60
+
61
+ # Toolset implementation for Visual C++ 2005 (8.0)
62
+ #
63
+ # Setups following tags:
64
+ # [_ver_hi_] high version number. Value: 8.
65
+ # [_ver_lo_] low version number. Value: 0.
66
+ class Vc8 < MxxRu::Cpp::Toolsets::VcFamily
67
+
68
+ # Actual manifest description.
69
+ class ActualManifest
70
+ attr_reader :manifest_file
71
+ attr_reader :digital_resource_id
72
+
73
+ def initialize(
74
+ source_manifest,
75
+ manifest_file,
76
+ digital_resource_id )
77
+ @source_manifest = source_manifest
78
+ @manifest_file = manifest_file
79
+ @digital_resource_id = digital_resource_id
80
+ end
81
+
82
+ # Is autogeneration of manifest must be used?
83
+ def autogen?
84
+ @source_manifest.autogen
85
+ end
86
+
87
+ # Is manifest tool (mt.exe) must be used?
88
+ def mt?
89
+ @source_manifest.mt
90
+ end
91
+
92
+ # Is autogenerated manifest file should be kept after
93
+ # embeding into executable?
94
+ # By default autogenerated manifest file will be deleted.
95
+ def keep_manifest_file?
96
+ ( mt? and autogen? ) ? @source_manifest.keep_manifest_file : true
97
+ end
98
+ end # class ActualManifest
99
+
100
+ # For compatibility with previous versions.
101
+ Actual_manifest = ActualManifest
102
+
103
+ @@default_manifest = OpenStruct.new(
104
+ :autogen => true,
105
+ :mt => true,
106
+ :manifest_file => :default,
107
+ :resource_id => :default,
108
+ :keep_manifest_file => false )
109
+
110
+ # Set of avaliable values for :resource_id key-value pair
111
+ # in manifest description.
112
+ @@resource_id_names = Set.new( [
113
+ :default,
114
+ :process_manifest,
115
+ :isolationaware_manifest,
116
+ :isolationaware_nostaticimport_manifest ] )
117
+
118
+ public
119
+ def initialize( a_name = "vc" )
120
+ super( a_name )
121
+
122
+ setup_tag( "ver_hi", "8" )
123
+ setup_tag( "ver_lo", "0" )
124
+ end
125
+
126
+ # Check some VC8.0 constraints before calling superclass
127
+ # implementation
128
+ #
129
+ # VC8.0 does not support Single-Thread Run-Time.
130
+ def setup_mandatory_options( target )
131
+ if THREADING_SINGLE == target.mxx_threading_mode
132
+ raise MxxRu::UnsupportedModeEx.new(
133
+ "Visual C++ 2005 not supports " +
134
+ "single-threaded static RTL" )
135
+ elsif THREADING_DEFAULT == target.mxx_threading_mode
136
+ # Because VC8.0 not support Single Thread Run-Time then
137
+ # by default we must use Mutli-Threading Run-Time.
138
+ target.threading_mode( THREADING_MULTI )
139
+ end
140
+
141
+ super( target )
142
+
143
+ setup_manifest( target )
144
+ setup_manifest_params( target )
145
+ end
146
+
147
+ # Remove autogenerated manifest file if any.
148
+ def clean_dll_specific_files( dll_file, dll_info, target )
149
+ super( dll_file, dll_info, target )
150
+ clean_autogenerated_manifest( target )
151
+ end
152
+
153
+ # Remove autogenerated manifest file if any.
154
+ def clean_exe_specific_files( exe_file, exe_info, target )
155
+ super( exe_file, exe_info, target )
156
+ clean_autogenerated_manifest( target )
157
+ end
158
+
159
+ # Append command line for embeding manifest file to result
160
+ # of super class implementation.
161
+ def make_dll_command_lines(
162
+ dll_name,
163
+ dll_info,
164
+ linker_lists,
165
+ target )
166
+
167
+ append_mt_command_lines(
168
+ super( dll_name, dll_info, linker_lists, target ),
169
+ dll_name,
170
+ target )
171
+ end
172
+
173
+ # Append command line for embeding manifest file to result
174
+ # of super class implementation.
175
+ def make_exe_command_lines(
176
+ exe_name,
177
+ exe_info,
178
+ linker_lists,
179
+ target )
180
+ append_mt_command_lines(
181
+ super( exe_name, exe_info, linker_lists, target ),
182
+ exe_name,
183
+ target )
184
+ end
185
+
186
+ # Make manifest description.
187
+ #
188
+ # Examples:
189
+ # # Autogenerate manifest for target. Do not embed into executable.
190
+ # # Manifest stored in <target>.manifest file.
191
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
192
+ # :target => self,
193
+ # :autogen => :to_default_file )
194
+ #
195
+ # # Autogenerate manifest for target. Embed into executable.
196
+ # # Autogenerated manifest will be deleted after embeding.
197
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
198
+ # :target => self,
199
+ # :autogen => :to_default_file,
200
+ # :mt => {} )
201
+ #
202
+ # # Autogenerate manifest for target. Embed into executable.
203
+ # # Autogenerated manifest will be kept after embeding.
204
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
205
+ # :target => self,
206
+ # :autogen => :to_default_file,
207
+ # :mt => { :keep_manifest_file => true } )
208
+ #
209
+ # # Autogenerate manifest for target. Embed into executable as
210
+ # # resource with id CREATEPROCESS_MANIFEST_RESOURCE_ID id.
211
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
212
+ # :target => self,
213
+ # :autogen => :to_default_file,
214
+ # :mt => { :resource_id => :process_manifest } )
215
+ #
216
+ # # Autogenerate manifest for target. Store manifest into
217
+ # # file 'hello_world.exe.manifest'. Embed info executable.
218
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
219
+ # :target => self,
220
+ # :autogen => 'hello_world.exe.manifest',
221
+ # :mt => {} )
222
+ #
223
+ # # Embed manifest from file 'hello_world.exe.manifest' into
224
+ # # target executable.
225
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
226
+ # :target => self,
227
+ # :mt => { :manifest => 'hello_world.exe.manifest' } )
228
+ # # Embed manifest from file 'hello_world.dll.manifest' into
229
+ # # target executable as resource with
230
+ # # ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID id.
231
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
232
+ # :target => self,
233
+ # :mt => { :manifest => 'hello_world.exe.manifest',
234
+ # :resource_id => :isolationaware_nonstaticimport } )
235
+ #
236
+ # # Autogenerate manifest for all targets in build. Store manifest
237
+ # # in default files. Do not embed manifest into executable.
238
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
239
+ # :autogen => :to_default_file )
240
+ #
241
+ # # Autogenerate manifest for all targets in build. Store manifest
242
+ # # in default files. Embed manifest into executable.
243
+ # MxxRu::Cpp::Toolsets::Vc8::manifest(
244
+ # :autogen => :to_default_file,
245
+ # :mt => {} )
246
+ #
247
+ # # Drop default manifest for build. Only explicitly specified
248
+ # # manifest will be generated.
249
+ # MxxRu::Cpp::Toolsets::Vc8::manifest( nil )
250
+ #
251
+ def self.manifest( params )
252
+ if nil == params
253
+ # No default manifest.
254
+ @@default_manifest = nil
255
+ else
256
+ check_manifest_params( params )
257
+
258
+ d = OpenStruct.new( :keep_manifest_file => true )
259
+
260
+ if params.key?( :autogen )
261
+ d.autogen = true
262
+ d.manifest_file = ( params[ :autogen ] == :to_default_file ?
263
+ :default : params[ :autogen ] )
264
+ d.keep_manifest_file = false
265
+ else
266
+ d.autogen = false
267
+ end
268
+
269
+ if params.key?( :mt ) && nil != params[ :mt ]
270
+ d.mt = true
271
+ mt_params = params[ :mt ]
272
+ d.manifest_file = mt_params[ :manifest ] if
273
+ mt_params.key?( :manifest )
274
+ d.resource_id = ( mt_params.key?( :resource_id ) ?
275
+ mt_params[ :resource_id ] : :default )
276
+
277
+ if mt_params.key?( :keep_manifest_file ) and
278
+ params.key?( :autogen )
279
+ d.keep_manifest_file = mt_params[ :keep_manifest_file ]
280
+ end
281
+ else
282
+ d.mt = false
283
+ end
284
+
285
+ if params.key?( :target )
286
+ # Source manifest must be set for specified target.
287
+ params[ :target ].vc8_source_manifest = d
288
+ else
289
+ # This is new default manifest.
290
+ @@default_manifest = d
291
+ end
292
+ end
293
+ end
294
+
295
+ # Get default manifest.
296
+ def self.default_manifest
297
+ @@default_manifest
298
+ end
299
+
300
+ protected
301
+ # Set actual manifest for target if source manifest defined
302
+ # (or default manifest exists).
303
+ def setup_manifest( target )
304
+ # Manifest can be set only for EXE or DLL.
305
+ if ExeTargetType::TYPE == target.target_type.name or
306
+ DllTargetType::TYPE == target.target_type.name
307
+ desc = target.vc8_source_manifest
308
+
309
+ if nil != desc
310
+ # Actual manifest must be created for target.
311
+ manifest_file =
312
+ if :default == desc.manifest_file
313
+ # We must create name for manifest.
314
+ if ExeTargetType::TYPE == target.target_type.name
315
+ make_exe_name(
316
+ target.mxx_target_name,
317
+ target ).full_name
318
+ else
319
+ make_dll_name(
320
+ target.mxx_target_name,
321
+ target ).full_name
322
+ end + ".manifest"
323
+ else
324
+ # Manifest filename already specified.
325
+ desc.manifest_file
326
+ end
327
+
328
+ # If mt.exe will be used then we must determine
329
+ # digital resource_id for manifest resource.
330
+ digital_resource_id =
331
+ if desc.mt
332
+ case desc.resource_id
333
+ when :default:
334
+ # Resource ID must be caclulated based on
335
+ # target type.
336
+ ExeTargetType::TYPE == target.target_type.name ? 1 : 2
337
+ when :process_manifest: 1
338
+ when :isolationaware_manifest: 2
339
+ else
340
+ # :isolationaware_nostaticimport_manifest
341
+ 3
342
+ end
343
+ else
344
+ nil
345
+ end
346
+
347
+ target.vc8_actual_manifest = ActualManifest.new(
348
+ desc,
349
+ manifest_file,
350
+ digital_resource_id )
351
+ end
352
+ end
353
+ end
354
+
355
+ # Setup linker params for processing target manifest.
356
+ def setup_manifest_params( target )
357
+ m = target.vc8_actual_manifest
358
+ if nil != m and m.autogen?
359
+ # Linker must generate manifest.
360
+ target.linker_option( '/MANIFEST' )
361
+ target.linker_option( '/MANIFESTFILE:' + m.manifest_file )
362
+ else
363
+ # Linker should not generate manifest.
364
+ target.linker_option( '/MANIFEST:NO' )
365
+ end
366
+ end
367
+
368
+ # Remove autogenerated manifest file if any.
369
+ def clean_autogenerated_manifest( target )
370
+ m = target.vc8_actual_manifest
371
+ MxxRu::Util::delete_file( m.manifest_file ) if
372
+ m != nil and m.autogen?
373
+ end
374
+
375
+ # Append command line for embeding manifest file to end of
376
+ # specified command line list.
377
+ def append_mt_command_lines(
378
+ cmd_lines,
379
+ target_name,
380
+ target )
381
+
382
+ m = target.vc8_actual_manifest
383
+ if nil != m and m.mt?
384
+ cmd_lines << "#{mt_name} /nologo " +
385
+ "/outputresource:\"#{target_name};\#" +
386
+ "#{m.digital_resource_id}\" " +
387
+ "/manifest \"#{m.manifest_file}\""
388
+
389
+ if !m.keep_manifest_file?
390
+ # del utility doesn't work with unix slashes
391
+ cmd_lines << "del \"#{MxxRu::Util::native_pathname(m.manifest_file)}\""
392
+ end
393
+ end
394
+
395
+ cmd_lines
396
+ end
397
+
398
+ # Name of manifest tool executable
399
+ def mt_name
400
+ "mt"
401
+ end
402
+
403
+ # Checking manifest params validity.
404
+ def self.check_manifest_params( params )
405
+ if nil != params
406
+ if params.key?( :mt )
407
+ mt_hash = params[ :mt ]
408
+
409
+ # :resource_id must have one of avaliable values.
410
+ if mt_hash.key?( :resource_id ) and
411
+ !@@resource_id_names.member?( mt_hash[ :resource_id ] )
412
+ raise InvalidValueEx.new(
413
+ "invalid value for :resource_id key: " +
414
+ "'#{mt_hash[:resource_id]}'" )
415
+ end
416
+
417
+ if !mt_hash.key?( :manifest ) and
418
+ !params.key?( :autogen )
419
+
420
+ raise InvalidValueEx.new(
421
+ "no manifest file name specified" )
422
+ end
423
+
424
+ # :keep_manifest_file should be Bool.
425
+ if mt_hash.key?( :keep_manifest_file ) and
426
+ true != mt_hash[ :keep_manifest_file ] and
427
+ false != mt_hash[ :keep_manifest_file ]
428
+ raise InvalidValueEx.new(
429
+ "value for :keep_manifest_file should be 'true' " +
430
+ "or 'false'" )
431
+ end
432
+ end
433
+
434
+ if params.key?( :autogen )
435
+ v = params[ :autogen ]
436
+ if !( v == :to_default_file or
437
+ v.kind_of?( String ) )
438
+ raise InvalidValueEx.new(
439
+ "invalid value for :autogen (must be " +
440
+ ":to_default_file or String instance)" )
441
+ end
442
+ end
443
+ end
444
+ end
445
+
446
+ end # class Vc8
447
+
448
+ end # module Toolsets
449
+
450
+ end # module Cpp
451
+
452
+ end # module MxxRu
453
+
454
+ MxxRu::Cpp::setup_toolset( MxxRu::Cpp::Toolsets::Vc8.new )
455
+