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,448 +1,448 @@
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/toolset'
30
-
31
- module MxxRu
32
- module Cpp
33
- module Toolsets
34
-
35
- # Toolset implemetation for Visual C++
36
- class VcFamily < MxxRu::Cpp::Toolset
37
- public
38
- def initialize( a_name )
39
- super( a_name )
40
-
41
- setup_tag( "host_os", "mswin" )
42
- setup_tag( "target_os", "mswin" )
43
- end
44
-
45
- # Returns compiler name.
46
- def compiler_name
47
- return "cl"
48
- end
49
-
50
- # Returns linker name.
51
- def linker_name
52
- return "link"
53
- end
54
-
55
- # Returns librarian name.
56
- def librarian_name
57
- return "lib"
58
- end
59
-
60
- # Returns resource compiler name.
61
- def rc_name
62
- return "rc"
63
- end
64
-
65
- # See description at MxxRu::Cpp::Toolset#setup_mandatory_options.
66
- def setup_mandatory_options( target )
67
-
68
- target.compiler_option( "-nologo" )
69
- target.linker_option( "/NOLOGO" )
70
- target.librarian_option( "/NOLOGO" )
71
- target.cpp_compiler_option( "-EHsc" )
72
-
73
- if RUNTIME_DEBUG == target.mxx_runtime_mode
74
- target.compiler_option( "-Zi" )
75
- target.linker_option( "/DEBUG" )
76
- setup_vc_specific_debug_options( target )
77
- elsif RUNTIME_RELEASE == target.mxx_runtime_mode
78
- target.define( "NDEBUG" )
79
- if OPTIM_SIZE == target.mxx_optimization
80
- target.compiler_option( "-O1" )
81
- else
82
- target.compiler_option( "-O2" )
83
- end
84
- end
85
-
86
- if RTTI_ENABLED == target.mxx_rtti_mode
87
- target.cpp_compiler_option( "-GR" )
88
- end
89
-
90
- if RTL_SHARED == target.mxx_rtl_mode
91
- if THREADING_SINGLE == target.mxx_threading_mode
92
- raise MxxRu::UnsupportedModeEx.new(
93
- "Visual C++ not support single-threaded shared RTL" )
94
- else
95
- if RUNTIME_DEBUG == target.mxx_runtime_mode
96
- target.compiler_option( "-MDd" )
97
- else
98
- target.compiler_option( "-MD" )
99
- end
100
- end
101
- else
102
- if THREADING_MULTI == target.mxx_threading_mode
103
- if RUNTIME_DEBUG == target.mxx_runtime_mode
104
- target.compiler_option( "-MTd" )
105
- else
106
- target.compiler_option( "-MT" )
107
- end
108
- else
109
- if RUNTIME_DEBUG == target.mxx_runtime_mode
110
- target.compiler_option( "-MLd" )
111
- else
112
- target.compiler_option( "-ML" )
113
- end
114
- end
115
- end
116
-
117
- if target.target_type.name == DllTargetType::TYPE
118
- target.compiler_option( "-LD" )
119
- end
120
-
121
- if SCREEN_WINDOW == target.mxx_screen_mode
122
- target.linker_option( "/SUBSYSTEM:WINDOWS" )
123
- else
124
- target.linker_option( "/SUBSYSTEM:CONSOLE" )
125
- end
126
-
127
- # All defines and all include_path should be applied
128
- # to resource compiler too.
129
- target.mxx_all_defines.each { |d|
130
- target.compiler_option( "-D" + d )
131
- target.mswin_rc_option( "/d" + d )
132
- }
133
-
134
- target.mxx_all_include_paths.each { |p|
135
- target.compiler_option( "-I" + p )
136
- target.mswin_rc_option( "/i" + p )
137
- }
138
-
139
- # Resource compiler specific options.
140
- target.mxx_all_mswin_rc_defines.each { |d|
141
- target.mswin_rc_option( "/d" + d )
142
- }
143
- target.mxx_all_mswin_rc_include_paths.each { |p|
144
- target.mswin_rc_option( "/i" + p )
145
- }
146
-
147
- end
148
-
149
- # Common description see MxxRu::Cpp::Toolset#clean_lib_specific_files.
150
- #
151
- # Removes VC specific garbage files.
152
- def clean_lib_specific_files(
153
- a_lib_file,
154
- a_lib_info,
155
- a_target )
156
-
157
- clean_vc_specific_garbage( a_lib_file )
158
- end
159
-
160
- # See description at MxxRu::Cpp::Toolset#clean_dll_specific_files.
161
- #
162
- # Removes import library if exists.
163
- #
164
- # Removes *.ilk, *.pdb files.
165
- def clean_dll_specific_files(
166
- a_dll_file,
167
- a_dll_info,
168
- a_target )
169
-
170
- # Remove import library if exists.
171
- if nil != a_dll_info.link_name
172
- implib_name = File.join(
173
- [ a_dll_info.link_path, a_dll_info.link_name ] )
174
- MxxRu::Util::delete_file( implib_name )
175
-
176
- # *.exp files are also created by Visual C++.
177
- explib_name =
178
- MxxRu::Util::change_file_ext( implib_name, ".exp" )
179
- MxxRu::Util::delete_file( explib_name )
180
- end
181
-
182
- clean_vc_specific_garbage( a_dll_file )
183
- end
184
-
185
- # See description at MxxRu::Cpp::Toolset#clean_exe_specific_files.
186
- #
187
- # Removing *.ilk, *.pdb files.
188
- def clean_exe_specific_files(
189
- a_exe_file,
190
- a_exe_info,
191
- a_target )
192
-
193
- clean_vc_specific_garbage( a_exe_file )
194
- end
195
-
196
- # See description at MxxRu::Cpp::Toolset#obj_file_ext.
197
- def obj_file_ext
198
- return ".obj"
199
- end
200
-
201
- # See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
202
- def make_c_obj_command_lines(
203
- obj_name,
204
- source_name,
205
- compiler_options,
206
- target )
207
-
208
- tmpfile = MxxRu::Util::TmpFiles.instance.create(
209
- "-c -TC -Fo#{obj_name} " +
210
- "#{compiler_options.join(' ')} #{source_name}" )
211
-
212
- return [ "#{compiler_name} @#{tmpfile}" ]
213
- end
214
-
215
- # See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
216
- def make_cpp_obj_command_lines(
217
- obj_name,
218
- source_name,
219
- compiler_options,
220
- target )
221
-
222
- tmpfile = MxxRu::Util::TmpFiles.instance.create(
223
- "-c -TP -Fo#{obj_name} " +
224
- "#{compiler_options.join(' ')} #{source_name}" )
225
-
226
- return [ "#{compiler_name} @#{tmpfile}" ]
227
- end
228
-
229
- # See description at MxxRu::Cpp::Toolset#mswin_res_file_name.
230
- def mswin_res_file_name( source_name )
231
- return source_name + ".res"
232
- end
233
-
234
- # See description at MxxRu::Cpp::Toolset#make_mswin_res_command_lines.
235
- def make_mswin_res_command_lines(
236
- res_name,
237
- rc_file,
238
- rc_options,
239
- target )
240
-
241
- return [ "#{rc_name} " +
242
- "#{rc_options.join(' ')} /r " +
243
- "/fo#{res_name} #{rc_file}" ]
244
- end
245
-
246
- # See description at MxxRu::Cpp::Toolset#lib_file_name.
247
- def lib_file_name( source_name )
248
- return source_name + ".lib"
249
- end
250
-
251
- # See description at MxxRu::Cpp::Toolset#lib_link_name.
252
- def lib_link_name( source_name )
253
- return lib_file_name( source_name )
254
- end
255
-
256
- # See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
257
- def make_lib_command_lines(
258
- lib_name,
259
- obj_files,
260
- librarian_options,
261
- target )
262
-
263
- tmpfile = MxxRu::Util::TmpFiles.instance.create(
264
- "#{librarian_options.join(' ')} " +
265
- "/OUT:#{lib_name} #{obj_files.join(' ')}" )
266
-
267
- return [ "#{librarian_name} @#{tmpfile}" ]
268
- end
269
-
270
- # See description at MxxRu::Cpp::Toolset#dll_file_name.
271
- def dll_file_name( source_name )
272
- return source_name + ".dll"
273
- end
274
-
275
- # See description at MxxRu::Cpp::Toolset#implib_link_name.
276
- def implib_link_name(
277
- dll_real_name,
278
- target )
279
-
280
- # Import library should be defined explicitly for Visual C++.
281
- if nil != target.mxx_implib_path
282
- return lib_file_name( target.mxx_target_name )
283
- end
284
-
285
- return nil
286
- end
287
-
288
- # See description at MxxRu::Cpp::Toolset#implib_link_path.
289
- #
290
- # Returns a value, based on
291
- # MxxRu::Cpp::Target#mxx_implib_path.
292
- def implib_link_path(
293
- dll_real_name,
294
- dll_real_path,
295
- target )
296
- return target.mxx_obj_placement.get_lib(
297
- target.mxx_implib_path, self, target )
298
- end
299
-
300
- # See description at MxxRu::Cpp::Toolset#make_dll_command_lines.
301
- def make_dll_command_lines(
302
- a_dll_name,
303
- a_dll_info,
304
- a_linker_lists,
305
- a_target )
306
-
307
- result = "/DLL " +
308
- "#{a_linker_lists.linker_options.join(' ')} " +
309
- "/OUT:#{a_dll_name} "
310
-
311
- if a_linker_lists.resources.size
312
- result << "#{a_target.mxx_all_mswin_rlink_options.join(' ')} "
313
- end
314
-
315
- if nil != a_dll_info.link_name
316
- implib_name = File.join( [ a_dll_info.link_path,
317
- a_dll_info.link_name ] )
318
- result << "/IMPLIB:#{implib_name} "
319
- end
320
-
321
- a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " }
322
-
323
- result << "#{a_linker_lists.objs.join(' ')} "
324
- result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} "
325
- result << "#{a_linker_lists.resources.join(' ')} "
326
-
327
- tmpfile = MxxRu::Util::TmpFiles.instance.create( result )
328
-
329
- return [ "#{linker_name} @#{tmpfile}" ]
330
- end
331
-
332
- # See description at MxxRu::Cpp::Toolset#make_dll_requirements.
333
- def make_dll_requirements(
334
- a_dll_name,
335
- a_dll_info,
336
- a_linker_lists,
337
- a_target )
338
-
339
- result = DllRequirements.new
340
-
341
- # Dependencies are exists only if import library is present.
342
- if nil != a_dll_info.link_name
343
- result.add_libs( [ a_dll_info.link_name ] )
344
- result.add_lib_paths( [ a_dll_info.link_path ] )
345
- end
346
-
347
- return result
348
- end
349
-
350
- # See description at MxxRu::Cpp::Toolset#exe_file_name.
351
- def exe_file_name( source_name )
352
- return source_name + ".exe"
353
- end
354
-
355
- # See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
356
- def make_exe_command_lines(
357
- a_exe_name,
358
- a_exe_info,
359
- a_linker_lists,
360
- a_target )
361
-
362
- result = "#{a_linker_lists.linker_options.join(' ')} " +
363
- "/OUT:#{a_exe_name} "
364
-
365
- if a_linker_lists.resources.size
366
- result << "#{a_target.mxx_all_mswin_rlink_options.join(' ')} "
367
- end
368
-
369
- a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " }
370
-
371
- result << "#{a_linker_lists.objs.join(' ')} "
372
- result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} "
373
- result << "#{a_linker_lists.resources.join(' ')} "
374
-
375
- tmpfile = MxxRu::Util::TmpFiles.instance.create( result )
376
-
377
- return [ "#{linker_name} @#{tmpfile}" ]
378
- end
379
-
380
- # Setting up VC specific options for managing PDB files.
381
- #
382
- # Adding '/Fd<full-target-name>.pdb' option for compiler.
383
- # Adding '/PDB:<full-target-name>.pdb' option for linker (in case
384
- # of EXE or DLL).
385
- def setup_vc_specific_debug_options( target )
386
- full_name =
387
- case target.target_type.name
388
- when ExeTargetType::TYPE:
389
- make_exe_name( target.mxx_target_name, target ).full_name
390
- when DllTargetType::TYPE:
391
- make_dll_name( target.mxx_target_name, target ).full_name
392
- when LibTargetType::TYPE:
393
- make_lib_name( target.mxx_target_name, target ).full_name
394
- else nil
395
- end
396
- if full_name
397
- pdb_file = MxxRu::Util::change_file_ext( full_name, ".pdb" )
398
- target.compiler_option( "/Fd#{pdb_file}" )
399
- target.linker_option( "/PDB:#{pdb_file}" )
400
- end
401
- end
402
-
403
- # Remove VC specific garbage.
404
- #
405
- # In DEBUG mode: *.ilk, *.pdb files.
406
- # If something exported from executable: *.exp, *.lib (only if
407
- # *.exp file exists).
408
- def clean_vc_specific_garbage( full_name )
409
- MxxRu::Util::delete_file(
410
- MxxRu::Util::change_file_ext( full_name, ".ilk" ) )
411
- MxxRu::Util::delete_file(
412
- MxxRu::Util::change_file_ext( full_name, ".pdb" ) )
413
-
414
- exp_file_name = MxxRu::Util::change_file_ext( full_name, ".exp" )
415
- if File.exists?( exp_file_name )
416
- MxxRu::Util::delete_file( exp_file_name )
417
- # Import library for this export-file must be removed too.
418
- MxxRu::Util::delete_file(
419
- MxxRu::Util::change_file_ext( full_name, ".lib" ) )
420
- end
421
- end
422
-
423
- protected
424
- # Checks and correct name of library. For Visual C++ library
425
- # name must always contain extension '.lib'. If this extension
426
- # is ommitted in project files than extension must be added.
427
- def check_library_name( name )
428
- return name if /.lib$/i =~ name
429
- return name + '.lib'
430
- end
431
-
432
- # Checks, correct and concatenate names of libraries for linker.
433
- def make_libraries_list_for_linker( libraries )
434
- libraries.inject( '' ) { |r, l|
435
- r << check_library_name( l.name ) << ' '
436
- }
437
- end
438
-
439
- end # class VcFamily
440
-
441
- # For compatibility with previous versions.
442
- Vc_family = VcFamily
443
- end # module Toolsets
444
-
445
- end # module Cpp
446
-
447
- end # module MxxRu
448
-
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/toolset'
30
+
31
+ module MxxRu
32
+ module Cpp
33
+ module Toolsets
34
+
35
+ # Toolset implemetation for Visual C++
36
+ class VcFamily < MxxRu::Cpp::Toolset
37
+ public
38
+ def initialize( a_name )
39
+ super( a_name )
40
+
41
+ setup_tag( "host_os", "mswin" )
42
+ setup_tag( "target_os", "mswin" )
43
+ end
44
+
45
+ # Returns compiler name.
46
+ def compiler_name
47
+ return "cl"
48
+ end
49
+
50
+ # Returns linker name.
51
+ def linker_name
52
+ return "link"
53
+ end
54
+
55
+ # Returns librarian name.
56
+ def librarian_name
57
+ return "lib"
58
+ end
59
+
60
+ # Returns resource compiler name.
61
+ def rc_name
62
+ return "rc"
63
+ end
64
+
65
+ # See description at MxxRu::Cpp::Toolset#setup_mandatory_options.
66
+ def setup_mandatory_options( target )
67
+
68
+ target.compiler_option( "-nologo" )
69
+ target.linker_option( "/NOLOGO" )
70
+ target.librarian_option( "/NOLOGO" )
71
+ target.cpp_compiler_option( "-EHsc" )
72
+
73
+ if RUNTIME_DEBUG == target.mxx_runtime_mode
74
+ target.compiler_option( "-Zi" )
75
+ target.linker_option( "/DEBUG" )
76
+ setup_vc_specific_debug_options( target )
77
+ elsif RUNTIME_RELEASE == target.mxx_runtime_mode
78
+ target.define( "NDEBUG" )
79
+ if OPTIM_SIZE == target.mxx_optimization
80
+ target.compiler_option( "-O1" )
81
+ else
82
+ target.compiler_option( "-O2" )
83
+ end
84
+ end
85
+
86
+ if RTTI_ENABLED == target.mxx_rtti_mode
87
+ target.cpp_compiler_option( "-GR" )
88
+ end
89
+
90
+ if RTL_SHARED == target.mxx_rtl_mode
91
+ if THREADING_SINGLE == target.mxx_threading_mode
92
+ raise MxxRu::UnsupportedModeEx.new(
93
+ "Visual C++ not support single-threaded shared RTL" )
94
+ else
95
+ if RUNTIME_DEBUG == target.mxx_runtime_mode
96
+ target.compiler_option( "-MDd" )
97
+ else
98
+ target.compiler_option( "-MD" )
99
+ end
100
+ end
101
+ else
102
+ if THREADING_MULTI == target.mxx_threading_mode
103
+ if RUNTIME_DEBUG == target.mxx_runtime_mode
104
+ target.compiler_option( "-MTd" )
105
+ else
106
+ target.compiler_option( "-MT" )
107
+ end
108
+ else
109
+ if RUNTIME_DEBUG == target.mxx_runtime_mode
110
+ target.compiler_option( "-MLd" )
111
+ else
112
+ target.compiler_option( "-ML" )
113
+ end
114
+ end
115
+ end
116
+
117
+ if target.target_type.name == DllTargetType::TYPE
118
+ target.compiler_option( "-LD" )
119
+ end
120
+
121
+ if SCREEN_WINDOW == target.mxx_screen_mode
122
+ target.linker_option( "/SUBSYSTEM:WINDOWS" )
123
+ else
124
+ target.linker_option( "/SUBSYSTEM:CONSOLE" )
125
+ end
126
+
127
+ # All defines and all include_path should be applied
128
+ # to resource compiler too.
129
+ target.mxx_all_defines.each { |d|
130
+ target.compiler_option( "-D" + d )
131
+ target.mswin_rc_option( "/d" + d )
132
+ }
133
+
134
+ target.mxx_all_include_paths.each { |p|
135
+ target.compiler_option( "-I" + p )
136
+ target.mswin_rc_option( "/i" + p )
137
+ }
138
+
139
+ # Resource compiler specific options.
140
+ target.mxx_all_mswin_rc_defines.each { |d|
141
+ target.mswin_rc_option( "/d" + d )
142
+ }
143
+ target.mxx_all_mswin_rc_include_paths.each { |p|
144
+ target.mswin_rc_option( "/i" + p )
145
+ }
146
+
147
+ end
148
+
149
+ # Common description see MxxRu::Cpp::Toolset#clean_lib_specific_files.
150
+ #
151
+ # Removes VC specific garbage files.
152
+ def clean_lib_specific_files(
153
+ a_lib_file,
154
+ a_lib_info,
155
+ a_target )
156
+
157
+ clean_vc_specific_garbage( a_lib_file )
158
+ end
159
+
160
+ # See description at MxxRu::Cpp::Toolset#clean_dll_specific_files.
161
+ #
162
+ # Removes import library if exists.
163
+ #
164
+ # Removes *.ilk, *.pdb files.
165
+ def clean_dll_specific_files(
166
+ a_dll_file,
167
+ a_dll_info,
168
+ a_target )
169
+
170
+ # Remove import library if exists.
171
+ if nil != a_dll_info.link_name
172
+ implib_name = File.join(
173
+ [ a_dll_info.link_path, a_dll_info.link_name ] )
174
+ MxxRu::Util::delete_file( implib_name )
175
+
176
+ # *.exp files are also created by Visual C++.
177
+ explib_name =
178
+ MxxRu::Util::change_file_ext( implib_name, ".exp" )
179
+ MxxRu::Util::delete_file( explib_name )
180
+ end
181
+
182
+ clean_vc_specific_garbage( a_dll_file )
183
+ end
184
+
185
+ # See description at MxxRu::Cpp::Toolset#clean_exe_specific_files.
186
+ #
187
+ # Removing *.ilk, *.pdb files.
188
+ def clean_exe_specific_files(
189
+ a_exe_file,
190
+ a_exe_info,
191
+ a_target )
192
+
193
+ clean_vc_specific_garbage( a_exe_file )
194
+ end
195
+
196
+ # See description at MxxRu::Cpp::Toolset#obj_file_ext.
197
+ def obj_file_ext
198
+ return ".obj"
199
+ end
200
+
201
+ # See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
202
+ def make_c_obj_command_lines(
203
+ obj_name,
204
+ source_name,
205
+ compiler_options,
206
+ target )
207
+
208
+ tmpfile = MxxRu::Util::TmpFiles.instance.create(
209
+ "-c -TC -Fo#{obj_name} " +
210
+ "#{compiler_options.join(' ')} #{source_name}" )
211
+
212
+ return [ "#{compiler_name} @#{tmpfile}" ]
213
+ end
214
+
215
+ # See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
216
+ def make_cpp_obj_command_lines(
217
+ obj_name,
218
+ source_name,
219
+ compiler_options,
220
+ target )
221
+
222
+ tmpfile = MxxRu::Util::TmpFiles.instance.create(
223
+ "-c -TP -Fo#{obj_name} " +
224
+ "#{compiler_options.join(' ')} #{source_name}" )
225
+
226
+ return [ "#{compiler_name} @#{tmpfile}" ]
227
+ end
228
+
229
+ # See description at MxxRu::Cpp::Toolset#mswin_res_file_name.
230
+ def mswin_res_file_name( source_name )
231
+ return source_name + ".res"
232
+ end
233
+
234
+ # See description at MxxRu::Cpp::Toolset#make_mswin_res_command_lines.
235
+ def make_mswin_res_command_lines(
236
+ res_name,
237
+ rc_file,
238
+ rc_options,
239
+ target )
240
+
241
+ return [ "#{rc_name} " +
242
+ "#{rc_options.join(' ')} /r " +
243
+ "/fo#{res_name} #{rc_file}" ]
244
+ end
245
+
246
+ # See description at MxxRu::Cpp::Toolset#lib_file_name.
247
+ def lib_file_name( source_name )
248
+ return source_name + ".lib"
249
+ end
250
+
251
+ # See description at MxxRu::Cpp::Toolset#lib_link_name.
252
+ def lib_link_name( source_name )
253
+ return lib_file_name( source_name )
254
+ end
255
+
256
+ # See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
257
+ def make_lib_command_lines(
258
+ lib_name,
259
+ obj_files,
260
+ librarian_options,
261
+ target )
262
+
263
+ tmpfile = MxxRu::Util::TmpFiles.instance.create(
264
+ "#{librarian_options.join(' ')} " +
265
+ "/OUT:#{lib_name} #{obj_files.join(' ')}" )
266
+
267
+ return [ "#{librarian_name} @#{tmpfile}" ]
268
+ end
269
+
270
+ # See description at MxxRu::Cpp::Toolset#dll_file_name.
271
+ def dll_file_name( source_name )
272
+ return source_name + ".dll"
273
+ end
274
+
275
+ # See description at MxxRu::Cpp::Toolset#implib_link_name.
276
+ def implib_link_name(
277
+ dll_real_name,
278
+ target )
279
+
280
+ # Import library should be defined explicitly for Visual C++.
281
+ if nil != target.mxx_implib_path
282
+ return lib_file_name( target.mxx_target_name )
283
+ end
284
+
285
+ return nil
286
+ end
287
+
288
+ # See description at MxxRu::Cpp::Toolset#implib_link_path.
289
+ #
290
+ # Returns a value, based on
291
+ # MxxRu::Cpp::Target#mxx_implib_path.
292
+ def implib_link_path(
293
+ dll_real_name,
294
+ dll_real_path,
295
+ target )
296
+ return target.mxx_obj_placement.get_lib(
297
+ target.mxx_implib_path, self, target )
298
+ end
299
+
300
+ # See description at MxxRu::Cpp::Toolset#make_dll_command_lines.
301
+ def make_dll_command_lines(
302
+ a_dll_name,
303
+ a_dll_info,
304
+ a_linker_lists,
305
+ a_target )
306
+
307
+ result = "/DLL " +
308
+ "#{a_linker_lists.linker_options.join(' ')} " +
309
+ "/OUT:#{a_dll_name} "
310
+
311
+ if a_linker_lists.resources.size
312
+ result << "#{a_target.mxx_all_mswin_rlink_options.join(' ')} "
313
+ end
314
+
315
+ if nil != a_dll_info.link_name
316
+ implib_name = File.join( [ a_dll_info.link_path,
317
+ a_dll_info.link_name ] )
318
+ result << "/IMPLIB:#{implib_name} "
319
+ end
320
+
321
+ a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " }
322
+
323
+ result << "#{a_linker_lists.objs.join(' ')} "
324
+ result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} "
325
+ result << "#{a_linker_lists.resources.join(' ')} "
326
+
327
+ tmpfile = MxxRu::Util::TmpFiles.instance.create( result )
328
+
329
+ return [ "#{linker_name} @#{tmpfile}" ]
330
+ end
331
+
332
+ # See description at MxxRu::Cpp::Toolset#make_dll_requirements.
333
+ def make_dll_requirements(
334
+ a_dll_name,
335
+ a_dll_info,
336
+ a_linker_lists,
337
+ a_target )
338
+
339
+ result = DllRequirements.new
340
+
341
+ # Dependencies are exists only if import library is present.
342
+ if nil != a_dll_info.link_name
343
+ result.add_libs( [ a_dll_info.link_name ] )
344
+ result.add_lib_paths( [ a_dll_info.link_path ] )
345
+ end
346
+
347
+ return result
348
+ end
349
+
350
+ # See description at MxxRu::Cpp::Toolset#exe_file_name.
351
+ def exe_file_name( source_name )
352
+ return source_name + ".exe"
353
+ end
354
+
355
+ # See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
356
+ def make_exe_command_lines(
357
+ a_exe_name,
358
+ a_exe_info,
359
+ a_linker_lists,
360
+ a_target )
361
+
362
+ result = "#{a_linker_lists.linker_options.join(' ')} " +
363
+ "/OUT:#{a_exe_name} "
364
+
365
+ if a_linker_lists.resources.size
366
+ result << "#{a_target.mxx_all_mswin_rlink_options.join(' ')} "
367
+ end
368
+
369
+ a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " }
370
+
371
+ result << "#{a_linker_lists.objs.join(' ')} "
372
+ result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} "
373
+ result << "#{a_linker_lists.resources.join(' ')} "
374
+
375
+ tmpfile = MxxRu::Util::TmpFiles.instance.create( result )
376
+
377
+ return [ "#{linker_name} @#{tmpfile}" ]
378
+ end
379
+
380
+ # Setting up VC specific options for managing PDB files.
381
+ #
382
+ # Adding '/Fd<full-target-name>.pdb' option for compiler.
383
+ # Adding '/PDB:<full-target-name>.pdb' option for linker (in case
384
+ # of EXE or DLL).
385
+ def setup_vc_specific_debug_options( target )
386
+ full_name =
387
+ case target.target_type.name
388
+ when ExeTargetType::TYPE:
389
+ make_exe_name( target.mxx_target_name, target ).full_name
390
+ when DllTargetType::TYPE:
391
+ make_dll_name( target.mxx_target_name, target ).full_name
392
+ when LibTargetType::TYPE:
393
+ make_lib_name( target.mxx_target_name, target ).full_name
394
+ else nil
395
+ end
396
+ if full_name
397
+ pdb_file = MxxRu::Util::change_file_ext( full_name, ".pdb" )
398
+ target.compiler_option( "/Fd#{pdb_file}" )
399
+ target.linker_option( "/PDB:#{pdb_file}" )
400
+ end
401
+ end
402
+
403
+ # Remove VC specific garbage.
404
+ #
405
+ # In DEBUG mode: *.ilk, *.pdb files.
406
+ # If something exported from executable: *.exp, *.lib (only if
407
+ # *.exp file exists).
408
+ def clean_vc_specific_garbage( full_name )
409
+ MxxRu::Util::delete_file(
410
+ MxxRu::Util::change_file_ext( full_name, ".ilk" ) )
411
+ MxxRu::Util::delete_file(
412
+ MxxRu::Util::change_file_ext( full_name, ".pdb" ) )
413
+
414
+ exp_file_name = MxxRu::Util::change_file_ext( full_name, ".exp" )
415
+ if File.exists?( exp_file_name )
416
+ MxxRu::Util::delete_file( exp_file_name )
417
+ # Import library for this export-file must be removed too.
418
+ MxxRu::Util::delete_file(
419
+ MxxRu::Util::change_file_ext( full_name, ".lib" ) )
420
+ end
421
+ end
422
+
423
+ protected
424
+ # Checks and correct name of library. For Visual C++ library
425
+ # name must always contain extension '.lib'. If this extension
426
+ # is ommitted in project files than extension must be added.
427
+ def check_library_name( name )
428
+ return name if /\.lib$/i =~ name
429
+ return name + '.lib'
430
+ end
431
+
432
+ # Checks, correct and concatenate names of libraries for linker.
433
+ def make_libraries_list_for_linker( libraries )
434
+ libraries.inject( '' ) { |r, l|
435
+ r << check_library_name( l.name ) << ' '
436
+ }
437
+ end
438
+
439
+ end # class VcFamily
440
+
441
+ # For compatibility with previous versions.
442
+ Vc_family = VcFamily
443
+ end # module Toolsets
444
+
445
+ end # module Cpp
446
+
447
+ end # module MxxRu
448
+