Class: MxxRu::Cpp::Toolset

Inherits:
Object
  • Object
show all
Defined in:
lib/mxx_ru/cpp/toolset.rb

Overview

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

Defined Under Namespace

Classes: UnknownTagEx

Constant Summary collapse

Unknown_tag_ex =

For compatibility with previous versions.

UnknownTagEx
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

'compiler_name'
C_COMPILER_NAME_TAG =

Tag name for a custom C compiler name.

Since v.1.4.0

'c_compiler_name'
CPP_COMPILER_NAME_TAG =

Tag name for a custom C++ compiler name.

Since v.1.4.0

'cpp_compiler_name'
LINKER_NAME_TAG =

Tag name for a custom linker name.

Since v.1.4.0

'linker_name'
LIBRARIAN_NAME_TAG =

Tag name for a custom librarian name.

Since v.1.4.0

'librarian_name'
IMPORT_LIBRARIAN_NAME_TAG =

Tag name for a custom import librarian name.

Since v.1.4.0

'import_librarian_name'
RC_NAME_TAG =

Tag name for a custom resource compiler name.

Since v.1.4.0

'rc_name'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a_name) ⇒ Toolset

Constructor.

a_name

Toolset name.



356
357
358
359
360
361
362
# 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

Instance Attribute Details

#cpp_stdObject (readonly)

Get the C++ standard version



1047
1048
1049
# File 'lib/mxx_ru/cpp/toolset.rb', line 1047

def cpp_std
  @cpp_std
end

Class Method Details

.has_linkable_dependecies?(target) ⇒ Boolean

Has a target any linkable libraries as dependecies?

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

Since v.1.4.0

Returns:

  • (Boolean)


369
370
371
# File 'lib/mxx_ru/cpp/toolset.rb', line 369

def Toolset.has_linkable_dependecies?( target )
  target.kind_of?( MxxRu::BinaryTarget )
end

Instance Method Details

#clean_dll(target) ⇒ Object

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



669
670
671
672
673
674
675
676
677
678
# 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) ⇒ Object

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.



687
688
689
690
691
# 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) ⇒ Object

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



738
739
740
741
742
743
744
745
746
747
# 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) ⇒ Object

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.



756
757
758
759
760
# 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) ⇒ Object

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



593
594
595
596
597
598
599
600
601
602
603
# 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) ⇒ Object

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.



612
613
614
615
616
# 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) ⇒ Object

Remove resource files compilation results.



513
514
515
516
517
518
519
520
521
522
523
# 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) ⇒ Object

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.



531
532
533
534
535
# 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) ⇒ Object

Remove object files.



471
472
473
474
475
476
477
478
# 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) ⇒ Object

Get shared library file name.

AbstractMethodEx exception is thrown in a base class.

Raises:



873
874
875
876
# 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) ⇒ Object

Get executable file name.

AbstractMethodEx exception is thrown in a base class.

Raises:



956
957
958
959
# 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_cpp03Object

Set C++03 standard version.

Since v.1.6.3.



1021
1022
1023
# File 'lib/mxx_ru/cpp/toolset.rb', line 1021

def force_cpp03
  set_cpp_std CPP_STD03
end

#force_cpp0x_stdObject

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

Kept for compatibility with previous versions.



1014
1015
1016
# File 'lib/mxx_ru/cpp/toolset.rb', line 1014

def force_cpp0x_std
  set_cpp_std CPP_STD11
end

#force_cpp11Object

Set C++11 standard version.

Since v.1.6.3



1028
1029
1030
# File 'lib/mxx_ru/cpp/toolset.rb', line 1028

def force_cpp11
  set_cpp_std CPP_STD11
end

#force_cpp14Object

Set C++14 standard version.

Since v.1.6.3



1035
1036
1037
# File 'lib/mxx_ru/cpp/toolset.rb', line 1035

def force_cpp14
  set_cpp_std CPP_STD14
end

#force_cpp17Object

Set C++17 standard version.

Since v.1.6.14.3



1042
1043
1044
# File 'lib/mxx_ru/cpp/toolset.rb', line 1042

def force_cpp17
  set_cpp_std CPP_STD17
end

#full_dll_name(target) ⇒ Object

Create full dll file name.

Since v.1.4.7



998
999
1000
# 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) ⇒ Object

Create full exe file name.

Since v.1.4.7



990
991
992
# 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) ⇒ Object

Create full lib file name

Since v.1.4.7



1006
1007
1008
# 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

Get shared library name, which should be passed to the linker. May return nil if no import library defined.

AbstractMethodEx exception is thrown in a base class.

dll_real_name

The name, returned on previous reference to dll_file_name.

target

Target, the library is created for.

Raises:



886
887
888
889
890
891
# File 'lib/mxx_ru/cpp/toolset.rb', line 886

def implib_link_name(
  dll_real_name,
  target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::implib_link_name" )
end

Get folder name containing import library, which should be passed to the linker. Executed only if previous implib_link_name returned other then nil value. May return nil, if no import library defined. Should be redefined in a child class.

AbstractMethodEx exception is thrown in a base class.

dll_real_name

The name, returned on previous reference to dll_file_name.

dll_real_path

Folder name, DLL will be in.

target

Target, the library is created for.

Raises:



905
906
907
908
909
910
911
# File 'lib/mxx_ru/cpp/toolset.rb', line 905

def implib_link_path(
  dll_real_name,
  dll_real_path,
  target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::implib_link_path" )
end

#lib_file_name(source_name, target) ⇒ Object

Get static library file name.

AbstractMethodEx exception is thrown in a base class.

Raises:



835
836
837
838
# 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

Get static library name, which should be passed to the linker.

AbstractMethodEx exception is thrown in a base class.

Raises:



844
845
846
847
# File 'lib/mxx_ru/cpp/toolset.rb', line 844

def lib_link_name( source_name, target )
  raise AbstractMethodEx.new(
    "MxxRu::Cpp::Toolset::lib_link_name" )
end

#make_c_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object

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.

Raises:



781
782
783
784
785
786
787
788
789
# 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) ⇒ Object

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.

Raises:



801
802
803
804
805
806
807
808
809
# 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) ⇒ Object

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.



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# 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) ⇒ Object

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.

Raises:



923
924
925
926
927
928
929
930
931
# 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) ⇒ Object

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.

Raises:



942
943
944
945
946
947
948
949
950
# 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) ⇒ Object

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.



700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
# 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) ⇒ Object

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.

Raises:



971
972
973
974
975
976
977
978
979
# 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_stringObject

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



1055
1056
1057
1058
1059
1060
1061
1062
1063
# 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) ⇒ Object

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.



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# 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) ⇒ Object

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.

Raises:



859
860
861
862
863
864
865
866
867
# 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) ⇒ Object

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



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# 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) ⇒ Object

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.

Raises:



821
822
823
824
825
826
827
828
829
# 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) ⇒ Object

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



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# 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

#nameObject

toolset name accessor.



982
983
984
# File 'lib/mxx_ru/cpp/toolset.rb', line 982

def name
  return @name
end

#obj_file_extObject

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

AbstractMethodEx exception is thrown in a base class.

Raises:



767
768
769
# 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) ⇒ Object

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.

Raises:



430
431
432
# 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) ⇒ Object

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

a_name

Tag name.

a_value

Value. Should be a string.



378
379
380
# 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) ⇒ Object

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:

  • value of CPP_COMPILER_NAME_TAG if defined,

  • value of COMPILER_NAME_TAG if CPP_COMPILER_NAME_TAG not defined, but COMPILER_NAME_TAG defined,

  • ‘g++’ if neither CPP_COMPILER_NAME_TAG nor COMPILER_NAME_TAG is defined.

Raises:



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# 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