Class: MxxRu::Cpp::Toolset
- Inherits:
-
Object
- Object
- MxxRu::Cpp::Toolset
- Defined in:
- lib/mxx_ru/cpp/toolset.rb
Overview
Base toolset class. Toolset is a compiler and tool set for compiling an application.
Direct Known Subclasses
MxxRu::Cpp::Toolsets::BccWin32Family, MxxRu::Cpp::Toolsets::C89NskFamily, MxxRu::Cpp::Toolsets::GccFamily, MxxRu::Cpp::Toolsets::VcFamily
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
-
#cpp_std ⇒ Object
readonly
Get the C++ standard version.
Class Method Summary collapse
-
.has_linkable_dependecies?(target) ⇒ Boolean
Has a target any linkable libraries as dependecies?.
Instance Method Summary collapse
-
#clean_dll(target) ⇒ Object
Perform dynamic library cleanup.
-
#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.
-
#clean_exe(target) ⇒ Object
Perform executable file cleanup.
-
#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.
-
#clean_lib(target) ⇒ Object
Perform cleanup of static library.
-
#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.
-
#clean_mswin_res(target) ⇒ Object
Remove resource files compilation results.
-
#clean_mswin_res_specific_files(a_res_file, a_res_info, a_target) ⇒ Object
Perform cleanup of files specific for mswin-res.
-
#clean_objs(target) ⇒ Object
Remove object files.
-
#dll_file_name(source_name, target) ⇒ Object
Get shared library file name.
-
#exe_file_name(source_name, target) ⇒ Object
Get executable file name.
-
#force_cpp03 ⇒ Object
Set C++03 standard version.
-
#force_cpp0x_std ⇒ Object
Sets a flag includes “-std=c++0x” compiler option.
-
#force_cpp11 ⇒ Object
Set C++11 standard version.
-
#force_cpp14 ⇒ Object
Set C++14 standard version.
-
#force_cpp17 ⇒ Object
Set C++17 standard version.
-
#force_cpp20 ⇒ Object
Set C++20 standard version.
-
#full_dll_name(target) ⇒ Object
Create full dll file name.
-
#full_exe_name(target) ⇒ Object
Create full exe file name.
-
#full_lib_name(target) ⇒ Object
Create full lib file name.
-
#implib_link_name(dll_real_name, target) ⇒ Object
Get shared library name, which should be passed to the linker.
-
#implib_link_path(dll_real_name, dll_real_path, target) ⇒ Object
Get folder name containing import library, which should be passed to the linker.
-
#initialize(a_name) ⇒ Toolset
constructor
Constructor.
-
#lib_file_name(source_name, target) ⇒ Object
Get static library file name.
-
#lib_link_name(source_name, target) ⇒ Object
Get static library name, which should be passed to the linker.
-
#make_c_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
Create command line for C file compilation.
-
#make_cpp_obj_command_lines(obj_name, source_name, compiler_options, target) ⇒ Object
Create command line for C++ file compilation.
-
#make_dll(target, force_rebuilding = false) ⇒ Object
Perform dynamic library build.
-
#make_dll_command_lines(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
Create command line for DLL build.
-
#make_dll_requirements(a_dll_name, a_dll_info, a_linker_lists, a_target) ⇒ Object
Create dependencies list from DLL given.
-
#make_exe(target, force_rebuilding = false) ⇒ Object
Perform executable file build.
-
#make_exe_command_lines(a_exe_name, a_exe_info, a_linker_lists, a_target) ⇒ Object
Create command line for EXE build.
-
#make_identification_string ⇒ Object
Make toolset identification string.
-
#make_lib(target, force_rebuilding = false) ⇒ Object
Perform static library build.
-
#make_lib_command_lines(lib_name, obj_files, librarian_options, target) ⇒ Object
Create command line for static library build.
-
#make_mswin_res(target) ⇒ Object
Perform resource files compilation.
-
#make_mswin_res_command_lines(res_name, rc_file, rc_options, target) ⇒ Object
Create command line for resource file compilation.
-
#make_objs(target) ⇒ Object
Perform C++ files compilation.
-
#name ⇒ Object
toolset name accessor.
-
#obj_file_ext ⇒ Object
Get file extension for an object file.
-
#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.
-
#setup_tag(a_name, a_value) ⇒ Object
Set tag value.
-
#tag(a_name, a_default = nil) ⇒ Object
Get tag value.
Constructor Details
#initialize(a_name) ⇒ Toolset
Constructor.
- a_name
-
Toolset name.
361 362 363 364 365 366 367 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 361 def initialize( a_name ) @name = a_name @tags = Hash.new # C++ standard version @cpp_std = CPP_STD_DEFAULT end |
Instance Attribute Details
#cpp_std ⇒ Object (readonly)
Get the C++ standard version
1059 1060 1061 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1059 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
374 375 376 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 374 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.
674 675 676 677 678 679 680 681 682 683 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 674 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.
692 693 694 695 696 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 692 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.
743 744 745 746 747 748 749 750 751 752 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 743 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.
761 762 763 764 765 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 761 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.
598 599 600 601 602 603 604 605 606 607 608 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 598 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.
617 618 619 620 621 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 617 def clean_lib_specific_files( a_lib_file, a_lib_info, a_target ) end |
#clean_mswin_res(target) ⇒ Object
Remove resource files compilation results.
518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 518 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.
536 537 538 539 540 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 536 def clean_mswin_res_specific_files( a_res_file, a_res_info, a_target ) end |
#clean_objs(target) ⇒ Object
Remove object files.
476 477 478 479 480 481 482 483 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 476 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.
878 879 880 881 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 878 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.
961 962 963 964 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 961 def exe_file_name( source_name, target ) raise AbstractMethodEx.new( "MxxRu::Cpp::Toolset::exe_file_name" ) end |
#force_cpp03 ⇒ Object
Set C++03 standard version.
Since v.1.6.3.
1026 1027 1028 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1026 def force_cpp03 set_cpp_std CPP_STD03 end |
#force_cpp0x_std ⇒ Object
Sets a flag includes “-std=c++0x” compiler option. Using at gnu-compilers.
Kept for compatibility with previous versions.
1019 1020 1021 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1019 def force_cpp0x_std set_cpp_std CPP_STD11 end |
#force_cpp11 ⇒ Object
Set C++11 standard version.
Since v.1.6.3
1033 1034 1035 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1033 def force_cpp11 set_cpp_std CPP_STD11 end |
#force_cpp14 ⇒ Object
Set C++14 standard version.
Since v.1.6.3
1040 1041 1042 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1040 def force_cpp14 set_cpp_std CPP_STD14 end |
#force_cpp17 ⇒ Object
Set C++17 standard version.
Since v.1.6.14.3
1047 1048 1049 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1047 def force_cpp17 set_cpp_std CPP_STD17 end |
#force_cpp20 ⇒ Object
Set C++20 standard version.
Since v.1.6.14.9
1054 1055 1056 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1054 def force_cpp20 set_cpp_std CPP_STD20 end |
#full_dll_name(target) ⇒ Object
Create full dll file name.
Since v.1.4.7
1003 1004 1005 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1003 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
995 996 997 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 995 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
1011 1012 1013 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1011 def full_lib_name( target ) make_lib_name( target.mxx_target_name, target ).full_name end |
#implib_link_name(dll_real_name, target) ⇒ Object
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.
891 892 893 894 895 896 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 891 def implib_link_name( dll_real_name, target ) raise AbstractMethodEx.new( "MxxRu::Cpp::Toolset::implib_link_name" ) end |
#implib_link_path(dll_real_name, dll_real_path, target) ⇒ Object
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.
910 911 912 913 914 915 916 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 910 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.
840 841 842 843 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 840 def lib_file_name( source_name, target ) raise AbstractMethodEx.new( "MxxRu::Cpp::Toolset::lib_file_name" ) end |
#lib_link_name(source_name, target) ⇒ Object
Get static library name, which should be passed to the linker.
AbstractMethodEx exception is thrown in a base class.
849 850 851 852 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 849 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.
786 787 788 789 790 791 792 793 794 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 786 def make_c_obj_command_lines( obj_name, source_name, , 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.
806 807 808 809 810 811 812 813 814 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 806 def make_cpp_obj_command_lines( obj_name, source_name, , 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.
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 665 666 667 668 669 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 630 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.
928 929 930 931 932 933 934 935 936 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 928 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.
947 948 949 950 951 952 953 954 955 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 947 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.
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 734 735 736 737 738 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 705 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.
976 977 978 979 980 981 982 983 984 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 976 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 ⇒ Object
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
1067 1068 1069 1070 1071 1072 1073 1074 1075 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 1067 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.
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 589 590 591 592 593 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 549 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., 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.
864 865 866 867 868 869 870 871 872 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 864 def make_lib_command_lines( lib_name, obj_files, , 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.
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 488 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., 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.
826 827 828 829 830 831 832 833 834 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 826 def make_mswin_res_command_lines( res_name, rc_file, , 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.
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 469 470 471 472 473 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 442 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., :make_c_obj_command_lines ) end if cpp_objs_to_build.size build_objs( cpp_objs_to_build, target, target., :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 ⇒ Object
toolset name accessor.
987 988 989 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 987 def name return @name end |
#obj_file_ext ⇒ Object
Get file extension for an object file. Should be redefined in a child class.
AbstractMethodEx exception is thrown in a base class.
772 773 774 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 772 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.
435 436 437 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 435 def ( 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.
383 384 385 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 383 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.
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/mxx_ru/cpp/toolset.rb', line 405 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 |