class MxxRu::Cpp::Toolset

Base toolset class. Toolset is a compiler and tool set for compiling an application.

Constants

COMPILER_NAME_TAG

Tag name for a custom compiler name.

Must be used in cases where there isn't difference beetwen C and C++ compilers (VC++, Borland C++ for example). If the difference exists (GNU Compiler Collection with gcc and g++ for example) C_COMPILER_NAME_TAG and CPP_COMPILER_NAME_TAG must be used.

Since v.1.4.0

CPP_COMPILER_NAME_TAG

Tag name for a custom C++ compiler name.

Since v.1.4.0

C_COMPILER_NAME_TAG

Tag name for a custom C compiler name.

Since v.1.4.0

IMPORT_LIBRARIAN_NAME_TAG

Tag name for a custom import librarian name.

Since v.1.4.0

LIBRARIAN_NAME_TAG

Tag name for a custom librarian name.

Since v.1.4.0

LINKER_NAME_TAG

Tag name for a custom linker name.

Since v.1.4.0

NO_PREFIX

There isn't a prefix for target name

Since v.1.4.2

NO_SUFFIX

There isn't a suffix for target name

Since v.1.4.2

RC_NAME_TAG

Tag name for a custom resource compiler name.

Since v.1.4.0

Unknown_tag_ex

Exception, thrown in case of unknown toolset tag value.

Attributes

cpp_std[R]

Get the C++ standard version

Public Class Methods

has_linkable_dependecies?( target ) click to toggle source

Has a target any linkable libraries as dependecies?

Returns true if target is derived from MxxRu::BinaryTarget.

Since v.1.4.0

# File lib/mxx_ru/cpp/toolset.rb, line 369
def Toolset.has_linkable_dependecies?( target )
  target.kind_of?( MxxRu::BinaryTarget )
end
new( a_name ) click to toggle source

Constructor.

a_name

Toolset name.

# File lib/mxx_ru/cpp/toolset.rb, line 356
def initialize( a_name )
  @name = a_name
  @tags = Hash.new

  # C++ standard version
  @cpp_std = CPP_STD_DEFAULT
end

Public Instance Methods

clean_dll( target ) click to toggle source

Perform dynamic library cleanup. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

# File lib/mxx_ru/cpp/toolset.rb, line 669
def clean_dll( target )
  # Creating result file name.
  dll_info = make_dll_name( target.mxx_target_name, target )

  dll_file = dll_info.full_name

  MxxRu::Util::delete_file( dll_file )

  clean_dll_specific_files( dll_file, dll_info, target )
end
clean_dll_specific_files( a_dll_file, a_dll_info, a_target ) click to toggle source

Perform a cleanup of auxiliary files, specific for static library on given platform. Does nothing in a base class, but may be redefined by a child class if import library may be created on given platform.

a_dll_file

Full library file name.

a_dll_info

DllInfo, created for the file.

a_target

Target, the library is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 687
def clean_dll_specific_files(
  a_dll_file,
  a_dll_info,
  a_target )
end
clean_exe( target ) click to toggle source

Perform executable file cleanup. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

# File lib/mxx_ru/cpp/toolset.rb, line 738
def clean_exe( target )
  # Creating result file name.
  exe_info = make_exe_name( target.mxx_target_name, target )

  exe_file = exe_info.full_name

  MxxRu::Util::delete_file( exe_file )

  clean_exe_specific_files( exe_file, exe_info, target )
end
clean_exe_specific_files( a_exe_file, a_exe_info, a_target ) click to toggle source

Perform a cleanup of auxiliary files, specific for static library on given platform. Does nothing in a base class, but may be redefined by a child class.

a_exe_file

Full file name.

a_exe_info

ExeInfo, created for the file.

a_target

Target, the file is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 756
def clean_exe_specific_files(
  a_exe_file,
  a_exe_info,
  a_target )
end
clean_lib( target ) click to toggle source

Perform cleanup of static library. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

# File lib/mxx_ru/cpp/toolset.rb, line 593
def clean_lib( target )
  # Creating result file name. Also determining in which folder
  # lib should be.
  lib_info = make_lib_name( target.mxx_target_name, target )

  lib_file = lib_info.full_name

  MxxRu::Util::delete_file( lib_file )

  clean_lib_specific_files( lib_file, lib_info, target )
end
clean_lib_specific_files( a_lib_file, a_lib_info, a_target ) click to toggle source

Perform a cleanup of auxiliary files, specific for static library on given platform. Does nothing in a base class, but may be redefined by a child class.

a_lib_file

Full name of library file.

a_lib_info

LibInfo, created for the file.

a_target

Target, library is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 612
def clean_lib_specific_files(
  a_lib_file,
  a_lib_info,
  a_target )
end
clean_mswin_res( target ) click to toggle source

Remove resource files compilation results.

# File lib/mxx_ru/cpp/toolset.rb, line 513
def clean_mswin_res( target )
  # Creating the name of res file.
  res_info = make_mswin_res_name(
    target.mxx_mswin_rc_file.name, target )

  full_name = res_info.full_name

  MxxRu::Util::delete_file( full_name )

  clean_mswin_res_specific_files( full_name, res_info, target )
end
clean_mswin_res_specific_files( a_res_file, a_res_info, a_target ) click to toggle source

Perform cleanup of files specific for mswin-res. Does nothing in a base class.

a_res_file

Full name of mswin-res-file.

a_res_info

Formatted information for res-file.

a_target

Target, for which mswin-res-file is defined.

# File lib/mxx_ru/cpp/toolset.rb, line 531
def clean_mswin_res_specific_files(
  a_res_file,
  a_res_info,
  a_target )
end
clean_objs( target ) click to toggle source

Remove object files.

# File lib/mxx_ru/cpp/toolset.rb, line 471
def clean_objs( target )
  # Creating all object file names.
  c_objs = make_obj_names( target.mxx_c_files, target )
  cpp_objs = make_obj_names( target.mxx_cpp_files, target )

  c_objs.each { |o| MxxRu::Util::delete_file( o.name ) }
  cpp_objs.each { |o| MxxRu::Util::delete_file( o.name ) }
end
dll_file_name( source_name, target ) click to toggle source

Get shared library file name.

AbstractMethodEx exception is thrown in a base class.

# File lib/mxx_ru/cpp/toolset.rb, line 873
def dll_file_name( source_name, target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::dll_file_name" )
end
exe_file_name( source_name, target ) click to toggle source

Get executable file name.

AbstractMethodEx exception is thrown in a base class.

# File lib/mxx_ru/cpp/toolset.rb, line 956
def exe_file_name( source_name, target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::exe_file_name" )
end
force_cpp03() click to toggle source

Set C++03 standard version.

Since v.1.6.3.

# File lib/mxx_ru/cpp/toolset.rb, line 1021
def force_cpp03
  set_cpp_std CPP_STD03
end
force_cpp0x_std() click to toggle source

Sets a flag includes “-std=c++0x” compiler option. Using at gnu-compilers.

Kept for compatibility with previous versions.

# File lib/mxx_ru/cpp/toolset.rb, line 1014
def force_cpp0x_std
  set_cpp_std CPP_STD11
end
force_cpp11() click to toggle source

Set C++11 standard version.

Since v.1.6.3

# File lib/mxx_ru/cpp/toolset.rb, line 1028
def force_cpp11
  set_cpp_std CPP_STD11
end
force_cpp14() click to toggle source

Set C++14 standard version.

Since v.1.6.3

# File lib/mxx_ru/cpp/toolset.rb, line 1035
def force_cpp14
  set_cpp_std CPP_STD14
end
force_cpp17() click to toggle source

Set C++17 standard version.

Since v.1.6.14.3

# File lib/mxx_ru/cpp/toolset.rb, line 1042
def force_cpp17
  set_cpp_std CPP_STD17
end
full_dll_name( target ) click to toggle source

Create full dll file name.

Since v.1.4.7

# File lib/mxx_ru/cpp/toolset.rb, line 998
def full_dll_name( target )
  make_dll_name( target.mxx_target_name, target ).full_name
end
full_exe_name( target ) click to toggle source

Create full exe file name.

Since v.1.4.7

# File lib/mxx_ru/cpp/toolset.rb, line 990
def full_exe_name( target )
  make_exe_name( target.mxx_target_name, target ).full_name
end
full_lib_name( target ) click to toggle source

Create full lib file name

Since v.1.4.7

# File lib/mxx_ru/cpp/toolset.rb, line 1006
def full_lib_name( target )
  make_lib_name( target.mxx_target_name, target ).full_name
end
lib_file_name( source_name, target ) click to toggle source

Get static library file name.

AbstractMethodEx exception is thrown in a base class.

# File lib/mxx_ru/cpp/toolset.rb, line 835
def lib_file_name( source_name, target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::lib_file_name" )
end
make_c_obj_command_lines( obj_name, source_name, compiler_options, target ) click to toggle source

Create command line for C file compilation. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

obj_name

Object file name.

source_name

Source file name.

compiler_options

Compiler options list. Array of String.

target

Target, which contains object file given.

# File lib/mxx_ru/cpp/toolset.rb, line 781
def make_c_obj_command_lines(
  obj_name,
  source_name,
  compiler_options,
  target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_c_obj_command_lines" )
end
make_cpp_obj_command_lines( obj_name, source_name, compiler_options, target ) click to toggle source

Create command line for C++ file compilation. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

obj_name

Object file name.

source_name

Source file name.

compiler_options

Compiler options list. Array of String.

target

Target, which contains object file given.

# File lib/mxx_ru/cpp/toolset.rb, line 801
def make_cpp_obj_command_lines(
  obj_name,
  source_name,
  compiler_options,
  target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_c_obj_command_lines" )
end
make_dll( target, force_rebuilding = false ) click to toggle source

Perform dynamic library build. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

If force_rebuilding is true then DLL will be rebuilt whitout checking its dependecies.

# File lib/mxx_ru/cpp/toolset.rb, line 625
def make_dll( target, force_rebuilding = false )
  # Creating result file name.
  dll_info = make_dll_name( target.mxx_target_name, target )
  dll_file = dll_info.full_name

  dll_state = if force_rebuilding
      MxxRu::TargetState.make_absent
    else
      MxxRu::TargetState::detect(
          dll_file,
          create_executable_depend_list( target ) )
    end

  if MxxRu::TargetState::EXISTS != dll_state.state
    # Target should be rebuilt.
    link_lists = prepare_linker_lists( target )
    cmd_lines = make_dll_command_lines(
      dll_file, dll_info, link_lists, target )

    MxxRu::AbstractTarget::run(
        cmd_lines,
        [ dll_file ],
        "building #{dll_file}" )

    dll_state = MxxRu::TargetState.new( MxxRu::TargetState::REBUILT )
  end

  # Full library file name should be included in files list, created by
  # given target.
  target.mxx_add_full_target_name( dll_file )

  # Determining dependencies list for all who will link this DLL.
  dll_requirements = make_dll_requirements(
    dll_file, dll_info, link_lists, target )

  target.mxx_add_required_libs( dll_requirements.libs )
  target.mxx_add_required_lib_paths( dll_requirements.lib_paths )

  return dll_state
end
make_dll_command_lines( a_dll_name, a_dll_info, a_linker_lists, a_target ) click to toggle source

Create command line for DLL build. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

a_dll_name

DLL result file name.

a_dll_info

DLL description.

a_linker_lists

Lists required for linker.

a_target

Target, the library is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 923
def make_dll_command_lines(
  a_dll_name,
  a_dll_info,
  a_linker_lists,
  a_target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_dll_command_lines" )
end
make_dll_requirements( a_dll_name, a_dll_info, a_linker_lists, a_target ) click to toggle source

Create dependencies list from DLL given. Returns DllRequirements object.

AbstractMethodEx exception is thrown in a base class.

a_dll_name

DLL result file name.

a_dll_info

DLL description.

a_linker_lists

Lists required for linker.

a_target

Target, the library is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 942
def make_dll_requirements(
  a_dll_name,
  a_dll_info,
  a_linker_lists,
  a_target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_dll_requirements" )
end
make_exe( target, force_rebuilding = false ) click to toggle source

Perform executable file build. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

If force_rebuilding is true then EXE will be rebuilt whitout checking its dependecies.

# File lib/mxx_ru/cpp/toolset.rb, line 700
def make_exe( target, force_rebuilding = false )
  # Creating result file name.
  exe_info = make_exe_name( target.mxx_target_name, target )
  exe_file = exe_info.full_name

  exe_state = if force_rebuilding
      MxxRu::TargetState.make_absent
    else
      MxxRu::TargetState::detect(
        exe_file,
        create_executable_depend_list( target ) )
    end

  if MxxRu::TargetState::EXISTS != exe_state.state
    # Target should be rebuilt.

    link_lists = prepare_linker_lists( target )
    cmd_lines = make_exe_command_lines(
      exe_file, exe_info, link_lists, target )

    MxxRu::AbstractTarget::run(
        cmd_lines,
        [ exe_file ],
        "building #{exe_file}" )

    exe_state = MxxRu::TargetState.new( MxxRu::TargetState::REBUILT )
  end

  # Full library file name should be included in files list, created by
  # given target.
  target.mxx_add_full_target_name( exe_file )

  return exe_state
end
make_exe_command_lines( a_exe_name, a_exe_info, a_linker_lists, a_target ) click to toggle source

Create command line for EXE build. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

a_exe_name

EXE result file name.

a_exe_info

EXE description.

a_linker_lists

Lists required for linker.

a_target

Target, the executable is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 971
def make_exe_command_lines(
  a_exe_name,
  a_exe_info,
  a_linker_lists,
  a_target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_exe_command_lines" )
end
make_identification_string() click to toggle source

Make toolset identification string.

This string can be used for creation of toolset-specific file or directory names and so on.

Since v.1.6.11

# File lib/mxx_ru/cpp/toolset.rb, line 1055
def make_identification_string
  if @id_string.nil?
    raw_id = make_toolset_id_string
    # Normalize ID alphabet.
    @id_string = raw_id.gsub( /[^A-Za-z0-9_]/, '_' )
  end

  @id_string
end
make_lib( target, force_rebuilding = false ) click to toggle source

Perform static library build. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

If force_rebuilding is true then library will be rebuilt whitout checking its dependecies.

# File lib/mxx_ru/cpp/toolset.rb, line 544
def make_lib( target, force_rebuilding = false )
  # Creating result file name. Also determining in which folder
  # lib should be. The name of that folder should be included in
  # libraries search paths of given target.
  lib_info = make_lib_name( target.mxx_target_name, target )

  # Determining target status.
  lib_file = lib_info.full_name

  lib_state = force_rebuilding ? MxxRu::TargetState.make_absent :
      MxxRu::TargetState::detect( lib_file, target.mxx_obj_files )
  if MxxRu::TargetState::EXISTS != lib_state.state
    # File should be rebuilt.
    cmd_lines = make_lib_command_lines(
      lib_file, target.mxx_obj_files,
      target.mxx_all_librarian_options, target )

    MxxRu::AbstractTarget::run(
        cmd_lines,
        [ lib_file ],
        "building #{lib_file}" )

    lib_state = MxxRu::TargetState.new( MxxRu::TargetState::REBUILT )
  end

  # Full library file name should be included in files list, created by
  # given target.
  target.mxx_add_full_target_name( lib_file )

  # For a library, in a dependency list the library itself may be
  # included.
  target.mxx_add_required_lib(
      BinaryLibrary.new( lib_info.link_name, BinaryLibrary::STATIC ) )
  target.mxx_add_required_lib_path( lib_info.path )

  # And all libraries and folders from all subordinated projects.
  target.mxx_required_prjs.each { |d|
    if Toolset::has_linkable_dependecies?( d )
      target.mxx_add_required_libs( d.mxx_required_libs )
      target.mxx_add_required_lib_paths( d.mxx_required_lib_paths )
    end
  }

  return lib_state
end
make_lib_command_lines( lib_name, obj_files, librarian_options, target ) click to toggle source

Create command line for static library build. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

lib_name

Result library file name.

obj_files

Object file names, which should be included in the library.

librarian_options

Archiver options list. Array of String.

target

Target, the library is created for.

# File lib/mxx_ru/cpp/toolset.rb, line 859
def make_lib_command_lines(
  lib_name,
  obj_files,
  librarian_options,
  target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_lib_command_lines" )
end
make_mswin_res( target ) click to toggle source

Perform resource files compilation. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

# File lib/mxx_ru/cpp/toolset.rb, line 483
def make_mswin_res( target )
  # Creating the name of res file and storing it in the target.
  res_info = make_mswin_res_name(
    target.mxx_mswin_rc_file.name, target )

  full_name = res_info.full_name

  target.mswin_res_file( full_name )

  # Determining it's status.
  state = TargetState::detect( full_name,
    [ target.mxx_mswin_rc_file.name ] +
    target.mxx_mswin_rc_file.depends )
  if state.state != TargetState::EXISTS
    cmd_lines = make_mswin_res_command_lines(
      full_name, target.mxx_mswin_rc_file.name,
      target.mxx_all_mswin_rc_options, target )

    MxxRu::AbstractTarget::run(
        cmd_lines,
        [ full_name ],
        "compilling #{full_name}" )

    state = MxxRu::TargetState.new( MxxRu::TargetState::REBUILT )
  end

  return state
end
make_mswin_res_command_lines( res_name, rc_file, rc_options, target ) click to toggle source

Create command line for resource file compilation. Returns Array of String with command lines. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

res_name

Full file name of resulting res file.

rc_file

Source resource file.

rc_options

Resource compiler options.

target

Target, resources are required for.

# File lib/mxx_ru/cpp/toolset.rb, line 821
def make_mswin_res_command_lines(
  res_name,
  rc_file,
  rc_options,
  target )

  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::make_mswin_res_command_lines" )
end
make_objs( target ) click to toggle source

Perform C++ files compilation. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

# File lib/mxx_ru/cpp/toolset.rb, line 437
def make_objs( target )
  # Creating all object file names.
  c_objs = make_obj_names( target.mxx_c_files, target )
  cpp_objs = make_obj_names( target.mxx_cpp_files, target )

  # Defining object files, which is necessary to build or rebuild.
  c_objs_to_build = detect_objs_to_rebuild( c_objs )
  cpp_objs_to_build = detect_objs_to_rebuild( cpp_objs )

  # Performing a compilation, if it's required.
  if c_objs_to_build.size
    build_objs( c_objs_to_build, target,
      target.mxx_all_c_compiler_options,
      :make_c_obj_command_lines )
  end
  if cpp_objs_to_build.size
    build_objs( cpp_objs_to_build, target,
      target.mxx_all_cpp_compiler_options,
      :make_cpp_obj_command_lines )
  end

  # It's required to store all object file names back to the target,
  # because they are required for linking.
  c_objs.each { |o| target.obj_file( o.name ) }
  cpp_objs.each { |o| target.obj_file( o.name ) }

  # Also informing if some object files were rebuilt.
  state = (c_objs_to_build.empty? && cpp_objs_to_build.empty?) ?
      TargetState::EXISTS : TargetState::REBUILT

  return TargetState.new( state )
end
name() click to toggle source

toolset name accessor.

# File lib/mxx_ru/cpp/toolset.rb, line 982
def name
  return @name
end
obj_file_ext() click to toggle source

Get file extension for an object file. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

# File lib/mxx_ru/cpp/toolset.rb, line 767
def obj_file_ext()
  raise AbstractMethodEx.new( "MxxRu::Cpp::Toolset::obj_file_ext" )
end
setup_mandatory_options( target ) click to toggle source

Set all compiler, linker, archiver, etc options required, taking all current modes, such as runtime_mode, rtl_mode, rtti_mode, threading_mode etc into account. Target parameter should be an object of a class, inherited from MxxRu::Cpp::Target.

Throws AbstractMethodEx exception in a base class.

# File lib/mxx_ru/cpp/toolset.rb, line 430
def setup_mandatory_options( target )
  raise AbstractMethodEx.new( "MxxRu::Cpp::Toolset::setup_mandatory_options" )
end
setup_tag( a_name, a_value ) click to toggle source

Set tag value. Previous value is changed to the new one.

a_name

Tag name.

a_value

Value. Should be a string.

# File lib/mxx_ru/cpp/toolset.rb, line 378
def setup_tag( a_name, a_value )
  @tags[ a_name ] = a_value
end
tag( a_name, a_default = nil ) click to toggle source

Get tag value. If tag wasn't found in a tag map, a_default value is returned. If a_default == nil, then exception is thrown in a case of missing tag.

Since v.1.4.0

a_name can be Enumerable. In this case each value from a_name searched in defined tag names. The first occurence (if found) returned. For example:

tag( [ CPP_COMPILER_NAME_TAG, COMPILER_NAME_TAG ], 'g++' )

returns:

# File lib/mxx_ru/cpp/toolset.rb, line 400
def tag( a_name, a_default = nil )
  r = if a_name.kind_of?( String )
        @tags.key?( a_name ) ? @tags[ a_name ] : nil
      elsif a_name.respond_to?( :each )
        catch( :found ) do
          a_name.each do |name|
            throw( :found, @tags[ name ] ) if @tags.key?( name )
          end
          nil
        end
      else
        raise InvalidValueEx.new(
          'String or object with :each expected, received: ' +
          a_name.class.name )
      end

  raise UnknownTagEx.new( a_name ) if ( nil == r && nil == a_default )
  r = a_default unless r

  r
end

Protected Instance Methods

build_objs( objs_to_build, target, lang_specific_options, a_method_name ) click to toggle source

Compilation of object files given.

objs_to_build

Array of ObjInfo.

target

Target object, contatining these object files.

lang_specific_options

C or C++ specific compiler options. Array of String.

a_method_name

Method name, which should be executed for command line build of source file compilation.

# File lib/mxx_ru/cpp/toolset.rb, line 1118
def build_objs(
  objs_to_build,
  target,
  lang_specific_options,
  a_method_name )

  all_files_options = target.mxx_all_compiler_options +
    lang_specific_options;
  all_files_options.flatten!
  all_files_options.uniq!

  objs_to_build.each { |o|
      # Creating command line to execute compiler.
      compiler_options =  all_files_options + o.options;
      compiler_options.flatten!
      compiler_options.uniq!

      cmd_lines = self.send( a_method_name,
        o.name, o.source.name,
        compiler_options,
        target )

      # Executing.
      MxxRu::AbstractTarget::run(
          cmd_lines,
          [ o.name ],
          "compiling #{o.source.name}" )
    }

end
construct_target_name( source_name, default_prefix, default_suffix, target ) click to toggle source

Helper method for creating name of target with consideration of target's custom prefix and/or suffix.

Should be used in derived classes. Example of usage:

# For GCC family on Unix.
def lib_file_name( source_name, target )
  construct_target_name( source_name, 'lib', '.a', target )
end
# For Visual C++ family on Windows.
def lib_file_name( source_name, target )
  construct_target_name( source_name, NO_PREFIX, '.lib', target )
end

Since v.1.4.2

# File lib/mxx_ru/cpp/toolset.rb, line 1285
def construct_target_name(
    # Base name for target name construction.
    source_name,
    # Default prefix for target. nil if there isn't such prefix.
    default_prefix,
    # Default suffix for target. nil if there isn't such suffix.
    default_suffix,
    # Target for which resulting name is being constructed.
    target )
  p = target.mxx_target_prefix
  p = ( default_prefix.nil? ? '' : default_prefix ) unless p
  s = target.mxx_target_ext
  s = ( default_suffix.nil? ? '' : default_suffix ) unless s
  p + source_name + s
end
create_executable_depend_list( target ) click to toggle source

Creating full dependencies file list for resulting EXE or DLL file.

# File lib/mxx_ru/cpp/toolset.rb, line 1214
def create_executable_depend_list( target )
  all_depend_files = Array.new
  target.mxx_required_prjs.each { |d|
      depends = d.mxx_full_targets_names
      if nil != depends
        all_depend_files << depends
      end
    }
  all_depend_files << target.mxx_obj_files

  if target.mxx_mswin_res_file
    all_depend_files << target.mxx_mswin_res_file
  end

  all_depend_files.flatten!

  return all_depend_files
end
detect_objs_to_rebuild( objs ) click to toggle source

Definition of object files, required to build (if absent) or rebuild (if outdated). Returns array of ObjInfo objects.

objs

Array of ObjInfo

# File lib/mxx_ru/cpp/toolset.rb, line 1095
def detect_objs_to_rebuild( objs )

  obj_names = Array.new
  objs.each { |o|
      obj_state = MxxRu::TargetState::detect(
        o.name, [ o.source.name ] + o.source.depends )
      if MxxRu::TargetState::EXISTS != obj_state.state
        # File should be rebuilt.
        obj_names << o
      end
    }

  return obj_names
end
make_dll_name( dll_name, target ) click to toggle source

Creating shared library file name. Returns DllInfo object.

# File lib/mxx_ru/cpp/toolset.rb, line 1180
def make_dll_name( dll_name, target )
  source_name = File::basename( dll_name )
  source_path = File::dirname( dll_name )

  dll_real_name = dll_file_name( source_name, target )
  dll_dest_path = target.mxx_obj_placement.get_dll(
    source_path, self, target )

  link_name = implib_link_name( dll_real_name, target )
  link_path = nil
  if nil != link_name
    link_path = implib_link_path(
      dll_real_name, dll_dest_path, target )
  end

  return DllInfo.new(
    dll_real_name, dll_dest_path, link_name, link_path )
end
make_exe_name( exe_name, target ) click to toggle source

Creating executable file name. Returns ExeInfo object.

# File lib/mxx_ru/cpp/toolset.rb, line 1201
def make_exe_name( exe_name, target )
  source_name = File::basename( exe_name )
  source_path = File::dirname( exe_name )

  real_name = exe_file_name( source_name, target )
  dest_path = target.mxx_obj_placement.get_exe(
    source_path, self, target )

  return ExeInfo.new(
    real_name, dest_path )
end
make_lib_name( lib_name, target ) click to toggle source

Creating static library file name. Returns LibInfo object.

# File lib/mxx_ru/cpp/toolset.rb, line 1165
def make_lib_name( lib_name, target )
  source_name = File::basename( lib_name )
  source_path = File::dirname( lib_name )

  real_name = lib_file_name( source_name, target )
  link_name = lib_link_name( source_name, target )
  dest_path = target.mxx_obj_placement.get_lib(
    source_path, self, target )

  return LibInfo.new(
    real_name, dest_path, link_name )
end
make_mswin_res_name( rc_file, target ) click to toggle source

Creating file name for compiled resources. Returns MswinResInfo object.

# File lib/mxx_ru/cpp/toolset.rb, line 1151
def make_mswin_res_name( rc_file, target )
  source_name = MxxRu::Util::remove_file_ext(
    File::basename( rc_file ) )
  source_path = File::dirname( rc_file )

  real_name = mswin_res_file_name( source_name )
  dest_path = target.mxx_obj_placement.get_mswin_res(
    source_path, self, target )

  return MswinResInfo.new( real_name, dest_path )
end
make_obj_names( sources, target ) click to toggle source

Creating object file names. Returns array of ObjInfo objects.

# File lib/mxx_ru/cpp/toolset.rb, line 1068
def make_obj_names( sources, target )
  obj_names = Array.new
  sources.each { |s|
      # Get file name with extension.
      only_name = File::basename( s.name )
      # Get file name without extension.
      only_name = MxxRu::Util::remove_file_ext( only_name )

      # Get source folder name.
      source_path = File::dirname( s.name )
      # Get target folder name for object file.
      dest_path = target.mxx_obj_placement.get_obj(
        source_path, self, target )
      # Object file name creation.
      obj_names.push( ObjInfo.new(
        File::join( dest_path, only_name + obj_file_ext() ),
        s,
        s.compiler_options ) )
    }
  return obj_names
end
make_toolset_id_string() click to toggle source

Real implementation of make_identification_string.

Must be reimplemented the proper way in derived classes.

Since v.1.6.11

# File lib/mxx_ru/cpp/toolset.rb, line 1318
def make_toolset_id_string
  "#{name}_generic"
end
prepare_linker_lists( target ) click to toggle source

Creating all lists required for linker. Returns LinkerLists object.

# File lib/mxx_ru/cpp/toolset.rb, line 1235
def prepare_linker_lists( target )
  result = LinkerLists.new

  result.add_objs( target.mxx_obj_files )
  result.add_resources( target.mxx_mswin_res_file )
  result.add_libs( target.mxx_required_libs )
  result.add_lib_paths( target.mxx_required_lib_paths )

  target.mxx_required_prjs.each { |d|
    if Toolset::has_linkable_dependecies?( d )
      result.add_libs( d.mxx_required_libs )
      result.add_lib_paths( d.mxx_required_lib_paths )
    end
  }

  # At now libraries conflicts must be checked.
  BinaryTarget.check_libraries_types( target.prj_alias, result.libs )

  result.add_linker_options( target.mxx_all_linker_options )

  return result
end
set_cpp_std( version ) click to toggle source

Set C++ standard version.

Sets new value only if it is greater than old value. It means that call to force_cpp03 after the previous call to force_cpp11 will not change C++ standard version from CPP_STD11 to CPP_STD03.

Since v.1.6.3.

# File lib/mxx_ru/cpp/toolset.rb, line 1309
def set_cpp_std( version )
  @cpp_std = version if @cpp_std < version
end