class MxxRu::Cpp::Toolsets::BccWin32Family

Toolset implemetation for Borland C++ on Win32 platform.

Public Class Methods

new( a_name = "bcc" ) click to toggle source
Calls superclass method MxxRu::Cpp::Toolset::new
# 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

Public Instance Methods

clean_dll_specific_files( a_dll_file, a_dll_info, a_target ) click to toggle source

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

If import library exists, delete it.

# 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 ) click to toggle source

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

# 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_name() click to toggle source

Returns compiler name.

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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
import_librarian_name() click to toggle source

Returns the name of import library creator.

# 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 ) click to toggle source

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

# 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
librarian_name() click to toggle source

Returns librarian name.

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 56
def librarian_name
  tag( LIBRARIAN_NAME_TAG, "tlib" )
end
linker_name() click to toggle source

Returns linker name.

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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 ) click to toggle source

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

# 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_ext() click to toggle source

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

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 197
def obj_file_ext
  return ".obj"
end
rc_name() click to toggle source

Returns resource compiler name.

# 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 ) click to toggle source

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

# 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

Protected Instance Methods

generate_linker_respfile( a_output_name, a_startup_objfile, a_linker_lists ) click to toggle source

Response-file generation for linker startup.

a_output_name

Result file name.

a_startup_objfile

Object file name with startup code.

a_linker_list

List of object file names, libraries, compiled resource files, e.t.c.

Returns response file name.

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 422
def generate_linker_respfile(
  a_output_name,
  a_startup_objfile,
  a_linker_lists )

  result = "#{a_linker_lists.linker_options.join(' ')} "

  if 0 != a_linker_lists.lib_paths.size
    result << "/L;"
    unix2win_mass( a_linker_lists.lib_paths ).each { |p|
      result << "#{p};"
    }
    result << " "
  end

  result << "#{a_startup_objfile} "

  result << "#{unix2win_mass(a_linker_lists.objs).join(' ')} "
  result << ", #{unix2win(a_output_name)}, , "
  a_linker_lists.libs.each { |l|
    result << unix2win( l.name ) << ' '
  }
  result << ', , '
  result << "#{unix2win_mass(a_linker_lists.resources).join(' ')} "

  return MxxRu::Util::TmpFiles.instance.create( result )
end
tds_file_name( a_source_name ) click to toggle source

Creates TDS file name based on DLL or EXE name.

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 388
def tds_file_name( a_source_name )
  return unix2win(
    MxxRu::Util::change_file_ext( a_source_name, ".tds" ) )
end
unix2win( a_name ) click to toggle source

File name normalization.

Replaces unix slashes with windows revers slashes and concludes it into a double quotes.

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 397
def unix2win( a_name )
  return "\"" + a_name.gsub( "/", "\\" ) + "\""
end
unix2win_mass( a_names ) click to toggle source

Normalization of array of the file names.

Replaces unix slashes with windows revers slashes

Returns a vector with normalized names.

# File lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb, line 406
def unix2win_mass( a_names )
  return a_names.collect { |d|
    if d
      unix2win( d )
    end
  }
end