class MxxRu::Cpp::Toolsets::ClangFamily
Toolset
implemetation for Clang compiler.
Public Class Methods
new( name )
click to toggle source
Calls superclass method
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 39 def initialize( name ) super( name ) end
Public Instance Methods
c_compiler_name()
click to toggle source
Returns C compiler name.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 96 def c_compiler_name tag( [ C_COMPILER_NAME_TAG, COMPILER_NAME_TAG ], "clang" ) end
cpp_compiler_name()
click to toggle source
Returns C++ compiler name.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 101 def cpp_compiler_name tag( [ CPP_COMPILER_NAME_TAG, COMPILER_NAME_TAG ], "clang++" ) end
default_lib_linking_mode()
click to toggle source
Return default library linking mode for current platform.
Default mode BinaryLibrary::SHARED for Unix with GCC assumed. But default mode can be specified in toolset tag 'lib_linking_mode'.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 141 def default_lib_linking_mode t = tag( 'lib_linking_mode', 'unknown' ) if 'unknown' != t 'static' == t ? BinaryLibrary::STATIC : BinaryLibrary::SHARED else BinaryLibrary::SHARED end end
lib_linking_mode_switch( linking_mode )
click to toggle source
Return command line switch for forcing specified library type.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 151 def lib_linking_mode_switch( linking_mode ) "-Wl,#{linking_mode == BinaryLibrary::SHARED ? '-Bdynamic' : '-Bstatic'} " end
librarian_name()
click to toggle source
Returns librarian name.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 111 def librarian_name tag( LIBRARIAN_NAME_TAG, "ar" ) end
linker_name()
click to toggle source
Returns linker name.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 106 def linker_name tag( LINKER_NAME_TAG, "clang++" ) end
make_linker_include_lib_options( target, libs )
click to toggle source
Special implementation for support explicit library type linker option.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 116 def make_linker_include_lib_options( target, libs ) current_lib_type = nil all_libs = libs.inject( '' ) { |r, l| # Insert new lib mode switch only if next library has different # type than current type. if nil == current_lib_type || current_lib_type != l.type r << switch_to_default_lib_mode_if_needed( current_lib_type ) current_lib_type = l.type if BinaryLibrary::ANY != l.type && default_lib_linking_mode != l.type r << lib_linking_mode_switch( l.type ) end end r << '-l' << port_specific_lib_name_checker( l.name ) << ' ' } all_libs << switch_to_default_lib_mode_if_needed( current_lib_type ) enclose_linker_include_lib_options_into_brackes( all_libs ) end
setup_mandatory_options( target )
click to toggle source
See description at MxxRu::Cpp::Toolset#setup_mandatory_options
.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 44 def setup_mandatory_options( target ) if RUNTIME_DEBUG == target.mxx_runtime_mode target.compiler_option( "-g" ) target.linker_option( "-g" ) elsif RUNTIME_RELEASE == target.mxx_runtime_mode target.define( "NDEBUG" ) # -s switch is non-supported on clang+msvc. if 'mswin' != tag( 'host_os' ) target.linker_option( "-s" ) end if OPTIM_SIZE == target.mxx_optimization target.compiler_option( "-Os" ) else target.compiler_option( "-O2" ) end end if RTTI_DISABLED == target.mxx_rtti_mode target.cpp_compiler_option( "-fno-rtti" ) end # -fPIC switch is not supported on clang+msvc since clang-4.0.0 if 'mswin' != tag( 'host_os' ) target.compiler_option( "-fPIC" ) end target.mxx_all_defines.each { |d| target.compiler_option( "-D" + d ) } target.mxx_all_include_paths.each { |p| target.compiler_option( "-I" + p ) } if CPP_STD17 == cpp_std target.cpp_compiler_option( '-std=c++17' ) elsif CPP_STD14 == cpp_std target.cpp_compiler_option( '-std=c++14' ) elsif CPP_STD11 == cpp_std target.cpp_compiler_option( "-std=c++11" ) end if CPP_STD11 <= cpp_std and THREADING_MULTI == target.mxx_threading_mode target.linker_option( '-pthread' ) end end
switch_to_default_lib_mode_if_needed( current_lib_type )
click to toggle source
Return command line switch for closing group of libraries with same type. Empty string returned if current_lib_type is nil of is current_lib_type is default lib linking mode on this platform.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 158 def switch_to_default_lib_mode_if_needed( current_lib_type ) if nil != current_lib_type && BinaryLibrary::ANY != current_lib_type && default_lib_linking_mode != current_lib_type lib_linking_mode_switch( default_lib_linking_mode ) else '' end end
Private Instance Methods
make_toolset_id_string()
click to toggle source
Create toolset identification string.
# File lib/mxx_ru/cpp/toolsets/clang_family.rb, line 170 def make_toolset_id_string result = IO.popen( "#{c_compiler_name} -v 2>&1", :err => [:child, :out] ) do |io| target = 'generic' version = 'unknown' io.each_line do |line| if /^Target:\s*(?<trgt>\S+)/ =~ line target = trgt elsif /clang version (?<v>\S+)/ =~ line version = v end end version + '--' + target end "clang_#{result}" end