Class: MxxRu::Cpp::Toolsets::VcFamily
- Inherits:
-
MxxRu::Cpp::Toolset
- Object
- MxxRu::Cpp::Toolset
- MxxRu::Cpp::Toolsets::VcFamily
- Defined in:
- lib/mxx_ru/cpp/toolsets/vc_family.rb
Overview
Toolset implemetation for Visual C++
Constant Summary
Constants inherited from MxxRu::Cpp::Toolset
MxxRu::Cpp::Toolset::COMPILER_NAME_TAG, MxxRu::Cpp::Toolset::CPP_COMPILER_NAME_TAG, MxxRu::Cpp::Toolset::C_COMPILER_NAME_TAG, MxxRu::Cpp::Toolset::IMPORT_LIBRARIAN_NAME_TAG, MxxRu::Cpp::Toolset::LIBRARIAN_NAME_TAG, MxxRu::Cpp::Toolset::LINKER_NAME_TAG, MxxRu::Cpp::Toolset::RC_NAME_TAG, MxxRu::Cpp::Toolset::Unknown_tag_ex
Instance Attribute Summary
Attributes inherited from MxxRu::Cpp::Toolset
Instance Method Summary collapse
-
#clean_dll_specific_files(a_dll_file, a_dll_info, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#clean_dll_specific_files.
-
#clean_exe_specific_files(a_exe_file, a_exe_info, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#clean_exe_specific_files.
-
#clean_lib_specific_files(a_lib_file, a_lib_info, a_target) ⇒ Object
Common description see MxxRu::Cpp::Toolset#clean_lib_specific_files.
-
#clean_vc_specific_garbage(full_name) ⇒ Object
Remove VC specific garbage.
-
#compiler_name ⇒ Object
Returns compiler name.
-
#dll_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#dll_file_name.
-
#exe_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#exe_file_name.
-
#implib_link_name(dll_real_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#implib_link_name.
-
#implib_link_path(dll_real_name, dll_real_path, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#implib_link_path.
-
#initialize(a_name) ⇒ VcFamily
constructor
A new instance of VcFamily.
-
#lib_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#lib_file_name.
-
#lib_link_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#lib_link_name.
-
#librarian_name ⇒ Object
Returns librarian name.
-
#linker_name ⇒ Object
Returns linker name.
-
#make_c_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
-
#make_cpp_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
-
#make_dll_command_lines(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_dll_command_lines.
-
#make_dll_requirements(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_dll_requirements.
-
#make_exe_command_lines(a_exe_name, a_exe_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
-
#make_lib_command_lines(lib_name, obj_files, librarian_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
-
#make_mswin_res_command_lines(res_name, rc_file, rc_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_mswin_res_command_lines.
-
#mswin_res_file_name(source_name) ⇒ Object
See description at MxxRu::Cpp::Toolset#mswin_res_file_name.
-
#obj_file_ext ⇒ Object
See description at MxxRu::Cpp::Toolset#obj_file_ext.
-
#rc_name ⇒ Object
Returns resource compiler name.
-
#setup_mandatory_options(target) ⇒ Object
See description at MxxRu::Cpp::Toolset#setup_mandatory_options.
-
#setup_vc_specific_debug_options(target) ⇒ Object
Setting up VC specific options for managing PDB files.
Methods inherited from MxxRu::Cpp::Toolset
#clean_dll, #clean_exe, #clean_lib, #clean_mswin_res, #clean_mswin_res_specific_files, #clean_objs, #force_cpp03, #force_cpp0x_std, #force_cpp11, #force_cpp14, #full_dll_name, #full_exe_name, #full_lib_name, has_linkable_dependecies?, #make_dll, #make_exe, #make_lib, #make_mswin_res, #make_objs, #name, #setup_tag, #tag
Constructor Details
#initialize(a_name) ⇒ VcFamily
Returns a new instance of VcFamily.
38 39 40 41 42 43 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 38 def initialize( a_name ) super( a_name ) setup_tag( "host_os", "mswin" ) setup_tag( "target_os", "mswin" ) end |
Instance Method Details
#clean_dll_specific_files(a_dll_file, a_dll_info, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#clean_dll_specific_files.
Removes import library if exists.
Removes *.ilk, *.pdb files.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 165 def clean_dll_specific_files( a_dll_file, a_dll_info, a_target ) # Remove import library if exists. if nil != a_dll_info.link_name implib_name = File.join( [ a_dll_info.link_path, a_dll_info.link_name ] ) MxxRu::Util::delete_file( implib_name ) # *.exp files are also created by Visual C++. explib_name = MxxRu::Util::change_file_ext( implib_name, ".exp" ) MxxRu::Util::delete_file( explib_name ) end clean_vc_specific_garbage( a_dll_file ) end |
#clean_exe_specific_files(a_exe_file, a_exe_info, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#clean_exe_specific_files.
Removing *.ilk, *.pdb files.
188 189 190 191 192 193 194 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 188 def clean_exe_specific_files( a_exe_file, a_exe_info, a_target ) clean_vc_specific_garbage( a_exe_file ) end |
#clean_lib_specific_files(a_lib_file, a_lib_info, a_target) ⇒ Object
Common description see MxxRu::Cpp::Toolset#clean_lib_specific_files.
Removes VC specific garbage files.
152 153 154 155 156 157 158 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 152 def clean_lib_specific_files( a_lib_file, a_lib_info, a_target ) clean_vc_specific_garbage( a_lib_file ) end |
#clean_vc_specific_garbage(full_name) ⇒ Object
Remove VC specific garbage.
In DEBUG mode: *.ilk, *.pdb files. If something exported from executable: *.exp, *.lib (only if *.exp file exists).
408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 408 def clean_vc_specific_garbage( full_name ) MxxRu::Util::delete_file( MxxRu::Util::change_file_ext( full_name, ".ilk" ) ) MxxRu::Util::delete_file( MxxRu::Util::change_file_ext( full_name, ".pdb" ) ) exp_file_name = MxxRu::Util::change_file_ext( full_name, ".exp" ) if File.exists?( exp_file_name ) MxxRu::Util::delete_file( exp_file_name ) # Import library for this export-file must be removed too. MxxRu::Util::delete_file( MxxRu::Util::change_file_ext( full_name, ".lib" ) ) end end |
#compiler_name ⇒ Object
Returns compiler name.
46 47 48 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 46 def compiler_name return tag( COMPILER_NAME_TAG, "cl" ) end |
#dll_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#dll_file_name.
271 272 273 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 271 def dll_file_name( source_name, target ) return construct_target_name( source_name, NO_PREFIX, ".dll", target ) end |
#exe_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#exe_file_name.
351 352 353 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 351 def exe_file_name( source_name, target ) return construct_target_name( source_name, NO_PREFIX, ".exe", target ) end |
#implib_link_name(dll_real_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#implib_link_name.
276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 276 def implib_link_name( dll_real_name, target ) # Import library should be defined explicitly for Visual C++. if nil != target.mxx_implib_path return lib_file_name( target.mxx_target_name, target ) end return nil end |
#implib_link_path(dll_real_name, dll_real_path, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#implib_link_path.
Returns a value, based on MxxRu::Cpp::Target#mxx_implib_path.
292 293 294 295 296 297 298 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 292 def implib_link_path( dll_real_name, dll_real_path, target ) return target.mxx_obj_placement.get_lib( target.mxx_implib_path, self, target ) end |
#lib_file_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#lib_file_name.
247 248 249 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 247 def lib_file_name( source_name, target ) return construct_target_name( source_name, NO_PREFIX, '.lib', target ) end |
#lib_link_name(source_name, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#lib_link_name.
252 253 254 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 252 def lib_link_name( source_name, target ) return lib_file_name( source_name, target ) end |
#librarian_name ⇒ Object
Returns librarian name.
56 57 58 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 56 def librarian_name return tag( LIBRARIAN_NAME_TAG, "lib" ) end |
#linker_name ⇒ Object
Returns linker name.
51 52 53 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 51 def linker_name return tag( LINKER_NAME_TAG, "link" ) end |
#make_c_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 202 def make_c_obj_command_lines( obj_name, source_name, , target ) tmpfile = MxxRu::Util::TmpFiles.instance.create( "-c -TC -Fo#{obj_name} " + "#{.join(' ')} #{source_name}" ) return [ "#{compiler_name} @#{tmpfile}" ] end |
#make_cpp_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_c_obj_command_lines.
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 216 def make_cpp_obj_command_lines( obj_name, source_name, , target ) tmpfile = MxxRu::Util::TmpFiles.instance.create( "-c -TP -Fo#{obj_name} " + "#{.join(' ')} #{source_name}" ) return [ "#{compiler_name} @#{tmpfile}" ] end |
#make_dll_command_lines(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_dll_command_lines.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 301 def make_dll_command_lines( a_dll_name, a_dll_info, a_linker_lists, a_target ) result = "/DLL " + "#{a_linker_lists..join(' ')} " + "/OUT:#{a_dll_name} " if a_linker_lists.resources.size result << "#{a_target..join(' ')} " end if nil != a_dll_info.link_name implib_name = File.join( [ a_dll_info.link_path, a_dll_info.link_name ] ) result << "/IMPLIB:#{implib_name} " end a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " } result << "#{a_linker_lists.objs.join(' ')} " result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} " result << "#{a_linker_lists.resources.join(' ')} " tmpfile = MxxRu::Util::TmpFiles.instance.create( result ) return [ "#{linker_name} @#{tmpfile}" ] end |
#make_dll_requirements(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_dll_requirements.
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 333 def make_dll_requirements( a_dll_name, a_dll_info, a_linker_lists, a_target ) result = DllRequirements.new # Dependencies are exists only if import library is present. if nil != a_dll_info.link_name result.add_libs( [ a_dll_info.link_name ] ) result.add_lib_paths( [ a_dll_info.link_path ] ) end return result end |
#make_exe_command_lines(a_exe_name, a_exe_info, a_linker_lists, a_target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 356 def make_exe_command_lines( a_exe_name, a_exe_info, a_linker_lists, a_target ) result = "#{a_linker_lists..join(' ')} " + "/OUT:#{a_exe_name} " if a_linker_lists.resources.size result << "#{a_target..join(' ')} " end a_linker_lists.lib_paths.each { |p| result << "/LIBPATH:#{p} " } result << "#{a_linker_lists.objs.join(' ')} " result << "#{make_libraries_list_for_linker(a_linker_lists.libs)} " result << "#{a_linker_lists.resources.join(' ')} " tmpfile = MxxRu::Util::TmpFiles.instance.create( result ) return [ "#{linker_name} @#{tmpfile}" ] end |
#make_lib_command_lines(lib_name, obj_files, librarian_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 257 def make_lib_command_lines( lib_name, obj_files, , target ) tmpfile = MxxRu::Util::TmpFiles.instance.create( "#{.join(' ')} " + "/OUT:#{lib_name} #{obj_files.join(' ')}" ) return [ "#{librarian_name} @#{tmpfile}" ] end |
#make_mswin_res_command_lines(res_name, rc_file, rc_options, target) ⇒ Object
See description at MxxRu::Cpp::Toolset#make_mswin_res_command_lines.
235 236 237 238 239 240 241 242 243 244 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 235 def make_mswin_res_command_lines( res_name, rc_file, , target ) return [ "#{rc_name} " + "#{.join(' ')} /r " + "/fo#{res_name} #{rc_file}" ] end |
#mswin_res_file_name(source_name) ⇒ Object
See description at MxxRu::Cpp::Toolset#mswin_res_file_name.
230 231 232 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 230 def mswin_res_file_name( source_name ) return source_name + ".res" end |
#obj_file_ext ⇒ Object
See description at MxxRu::Cpp::Toolset#obj_file_ext.
197 198 199 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 197 def obj_file_ext return ".obj" end |
#rc_name ⇒ Object
Returns resource compiler name.
61 62 63 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 61 def rc_name return tag( RC_NAME_TAG, "rc" ) end |
#setup_mandatory_options(target) ⇒ Object
See description at MxxRu::Cpp::Toolset#setup_mandatory_options.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 66 def ( target ) target.compiler_option( "-nologo" ) target.linker_option( "/NOLOGO" ) target.librarian_option( "/NOLOGO" ) target.cpp_compiler_option( "-EHsc" ) if RUNTIME_DEBUG == target.mxx_runtime_mode target.compiler_option( "-Zi" ) target.linker_option( "/DEBUG" ) ( target ) elsif RUNTIME_RELEASE == target.mxx_runtime_mode target.define( "NDEBUG" ) if OPTIM_SIZE == target.mxx_optimization target.compiler_option( "-O1" ) else target.compiler_option( "-O2" ) end end if RTTI_ENABLED == target.mxx_rtti_mode target.cpp_compiler_option( "-GR" ) end if RTL_SHARED == target.mxx_rtl_mode if THREADING_SINGLE == target.mxx_threading_mode raise MxxRu::UnsupportedModeEx.new( "Visual C++ not support single-threaded shared RTL" ) else if RUNTIME_DEBUG == target.mxx_runtime_mode target.compiler_option( "-MDd" ) else target.compiler_option( "-MD" ) end end else if THREADING_MULTI == target.mxx_threading_mode if RUNTIME_DEBUG == target.mxx_runtime_mode target.compiler_option( "-MTd" ) else target.compiler_option( "-MT" ) end else if RUNTIME_DEBUG == target.mxx_runtime_mode target.compiler_option( "-MLd" ) else target.compiler_option( "-ML" ) end end end if target.target_type.name == DllTargetType::TYPE target.compiler_option( "-LD" ) end if SCREEN_WINDOW == target.mxx_screen_mode target.linker_option( "/SUBSYSTEM:WINDOWS" ) else target.linker_option( "/SUBSYSTEM:CONSOLE" ) end # All defines and all include_path should be applied # to resource compiler too. target.mxx_all_defines.each { |d| target.compiler_option( "-D" + d ) target.mswin_rc_option( "/d" + d ) } target.mxx_all_include_paths.each { |p| target.compiler_option( "-I" + p ) target.mswin_rc_option( "/i" + p ) } # Resource compiler specific options. target.mxx_all_mswin_rc_defines.each { |d| target.mswin_rc_option( "/d" + d ) } target.mxx_all_mswin_rc_include_paths.each { |p| target.mswin_rc_option( "/i" + p ) } end |
#setup_vc_specific_debug_options(target) ⇒ Object
Setting up VC specific options for managing PDB files.
Adding ‘/Fd<full-target-name>.pdb’ option for compiler. Adding ‘/PDB:<full-target-name>.pdb’ option for linker (in case of EXE or DLL).
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/mxx_ru/cpp/toolsets/vc_family.rb', line 385 def ( target ) full_name = case target.target_type.name when ExeTargetType::TYPE make_exe_name( target.mxx_target_name, target ).full_name when DllTargetType::TYPE make_dll_name( target.mxx_target_name, target ).full_name when LibTargetType::TYPE make_lib_name( target.mxx_target_name, target ).full_name else nil end if full_name pdb_file = MxxRu::Util::change_file_ext( full_name, ".pdb" ) target.compiler_option( "/Fd#{pdb_file}" ) target.linker_option( "/PDB:#{pdb_file}" ) end end |