Class: MxxRu::Cpp::Toolsets::BccWin32Family

Inherits:
MxxRu::Cpp::Toolset show all
Defined in:
lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb

Overview

Toolset implemetation for Borland C++ on Win32 platform.

Direct Known Subclasses

Bcc5

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

#cpp_std

Instance Method Summary collapse

Methods inherited from MxxRu::Cpp::Toolset

#clean_dll, #clean_exe, #clean_lib, #clean_lib_specific_files, #clean_mswin_res, #clean_mswin_res_specific_files, #clean_objs, #force_cpp03, #force_cpp0x_std, #force_cpp11, #force_cpp14, #force_cpp17, #full_dll_name, #full_exe_name, #full_lib_name, has_linkable_dependecies?, #make_dll, #make_exe, #make_identification_string, #make_lib, #make_mswin_res, #make_objs, #name, #setup_tag, #tag

Constructor Details

#initialize(a_name = "bcc") ⇒ BccWin32Family

Returns a new instance of BccWin32Family.



38
39
40
41
42
43
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 38

def initialize( a_name = "bcc" )
  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.

If import library exists, delete it.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 171

def clean_dll_specific_files(
  a_dll_file,
  a_dll_info,
  a_target )

  # If import library exists, delete it.
  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 )
  end

  # TDS files also should be removed.
  MxxRu::Util::delete_file( tds_file_name( 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.



188
189
190
191
192
193
194
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 188

def clean_exe_specific_files(
  a_exe_file,
  a_exe_info,
  a_target )

  MxxRu::Util::delete_file( tds_file_name( a_exe_file ) )
end

#compiler_nameObject

Returns compiler name.



46
47
48
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 46

def compiler_name
  tag( COMPILER_NAME_TAG, "bcc32" )
end

#dll_file_name(source_name, target) ⇒ Object

See description at MxxRu::Cpp::Toolset#dll_file_name.



277
278
279
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 277

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.



354
355
356
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 354

def exe_file_name( source_name, target )
  return construct_target_name( source_name, NO_PREFIX, ".exe", target )
end

See description at MxxRu::Cpp::Toolset#implib_link_name.



282
283
284
285
286
287
288
289
290
291
292
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 282

def implib_link_name(
  dll_real_name,
  target )

  # Import library name 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

See description at MxxRu::Cpp::Toolset#implib_link_path.

Returns a value, based on MxxRu::Cpp::Target#mxx_implib_path.



298
299
300
301
302
303
304
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 298

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

#import_librarian_nameObject

Returns the name of import library creator.



66
67
68
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 66

def import_librarian_name
  tag( IMPORT_LIBRARIAN_NAME_TAG, "implib" )
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/bcc_win32_family.rb', line 247

def lib_file_name( source_name, target )
  return construct_target_name( source_name, NO_PREFIX, ".lib", target )
end

See description at MxxRu::Cpp::Toolset#lib_link_name.



252
253
254
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 252

def lib_link_name( source_name, target )
  return lib_file_name( source_name, target )
end

#librarian_nameObject

Returns librarian name.



56
57
58
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 56

def librarian_name
  tag( LIBRARIAN_NAME_TAG, "tlib" )
end

#linker_nameObject

Returns linker name.



51
52
53
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 51

def linker_name
  tag( LINKER_NAME_TAG, "ilink32" )
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/bcc_win32_family.rb', line 202

def make_c_obj_command_lines(
  obj_name,
  source_name,
  compiler_options,
  target )

  tmpfile = MxxRu::Util::TmpFiles.instance.create(
    "-c -P- -o#{obj_name} " +
    "#{compiler_options.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/bcc_win32_family.rb', line 216

def make_cpp_obj_command_lines(
  obj_name,
  source_name,
  compiler_options,
  target )

  tmpfile = MxxRu::Util::TmpFiles.instance.create(
    "-c -P -o#{obj_name} " +
    "#{compiler_options.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.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 307

def make_dll_command_lines(
  a_dll_name,
  a_dll_info,
  a_linker_lists,
  a_target )

  result = Array.new

  response_file = generate_linker_respfile(
    a_dll_name, "c0d32.obj", a_linker_lists )

  result << "#{linker_name} @#{response_file}"

  if nil != a_dll_info.link_name
    implib_name = File.join( [ a_dll_info.link_path,
      a_dll_info.link_name ] )
    result << "#{import_librarian_name} #{implib_name} " +
      "#{a_dll_name}"
  end

  if RUNTIME_DEBUG != a_target.mxx_runtime_mode
    result << "if exist #{a_dll_name} del " +
      "#{tds_file_name(a_dll_name)}"
  end

  return result
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.



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 336

def make_dll_requirements(
  a_dll_name,
  a_dll_info,
  a_linker_lists,
  a_target )

  result = DllRequirements.new

  # Dependency is 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.



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 359

def make_exe_command_lines(
  a_exe_name,
  a_exe_info,
  a_linker_lists,
  a_target )

  result = Array.new

  if SCREEN_WINDOW == a_target.mxx_screen_mode
    startup_obj = "c0w32.obj"
  else
    startup_obj = "c0x32.obj"
  end

  response_file = generate_linker_respfile(
    a_exe_name, startup_obj, a_linker_lists )

  result << "#{linker_name} @#{response_file}"

  if RUNTIME_DEBUG != a_target.mxx_runtime_mode
    result << "if exist #{unix2win(a_exe_name)} del " +
      "#{tds_file_name(a_exe_name)}"
  end

  return result
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
269
270
271
272
273
274
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 257

def make_lib_command_lines(
  lib_name,
  obj_files,
  librarian_options,
  target )

  obj_files_commands = String.new
  obj_files.each { |o|
    obj_files_commands += "-+\"#{unix2win(o)}\" "
  }

  tmpfile = MxxRu::Util::TmpFiles.instance.create(
    "#{librarian_options.join(' ')} " +
    "\"#{unix2win(lib_name)}\" " +
    "#{obj_files_commands}" )

  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/bcc_win32_family.rb', line 235

def make_mswin_res_command_lines(
  res_name,
  rc_file,
  rc_options,
  target )

  return [ "#{rc_name} " +
    "#{rc_options.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/bcc_win32_family.rb', line 230

def mswin_res_file_name( source_name )
  return source_name + ".res"
end

#obj_file_extObject

See description at MxxRu::Cpp::Toolset#obj_file_ext.



197
198
199
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 197

def obj_file_ext
  return ".obj"
end

#rc_nameObject

Returns resource compiler name.



61
62
63
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 61

def rc_name
  tag( RC_NAME_TAG, "brc32" )
end

#setup_mandatory_options(target) ⇒ Object

See description at MxxRu::Cpp::Toolset#setup_mandatory_options.



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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb', line 71

def setup_mandatory_options( target )

  # Disable warning: Parameter is never used.
  target.compiler_option( "-w-par" )
  # Disable warning: <ID> is assigned a value that is never used.
  target.compiler_option( "-w-aus" )

  # Turn all warnings on.
  target.linker_option( "/w" )
  # Don't generate state files (disable incremental linking).
  target.linker_option( "/Gn" )
  # Suppress creation of map file.
  target.linker_option( "/x" )
  # Suppress command line banner.
  target.linker_option( "/q" )

  if RUNTIME_DEBUG == target.mxx_runtime_mode
    target.compiler_option( "-v" )
    target.compiler_option( "-y" )
    target.linker_option( "/v" )
  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( "-RT" )
  elsif RTTI_DISABLED == target.mxx_rtti_mode
    target.cpp_compiler_option( "-RT-" )
  end

  if RTL_SHARED == target.mxx_rtl_mode
    target.compiler_option( "-WR" )
  end

  if THREADING_MULTI == target.mxx_threading_mode
    target.compiler_option( "-tWM" )
    if RTL_SHARED == target.mxx_rtl_mode
      target.lib( "cw32mti.lib" )
    else
      target.lib( "cw32mt.lib" )
    end
  else
    if RTL_SHARED == target.mxx_rtl_mode
      target.lib( "cw32i.lib" )
    else
      target.lib( "cw32.lib" )
    end
  end

  if target.target_type.name == DllTargetType::TYPE
    target.compiler_option( "-WD" )
    target.linker_option( "/Tpd" )
  elsif target.target_type.name == ExeTargetType::TYPE
    if SCREEN_WINDOW == target.mxx_screen_mode
      target.linker_option( "/aa" )
    else
      target.linker_option( "/ap" )
    end

    target.linker_option( "/Tpe" )
  end

  target.lib( "import32.lib" )

  if SCREEN_WINDOW == target.mxx_screen_mode
    target.compiler_option( "-tW" )
  else
    target.compiler_option( "-tWC" )
  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 requires it's own options, too.
  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