1# Copyright (C) 2012-2019 Antony Polukhin 2# 3# Distributed under the Boost Software License, Version 1.0. (See accompanying 4# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5# 6 7import testing ; 8import feature ; 9import os ; 10 11# Variable that contains all the stuff required for linking together <rtti>on and <rtti>off 12compat = <define>BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY ; 13 14# Making own `nortti` that is link compatible. 15# We explicitly define BOOST_NO_RTTI because it sometimes can not be detected by build system. 16nortti = <toolset>gcc:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>clang:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>intel:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>darwin:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>msvc:<cxxflags>"/GR-" ; 17 18norttidefines = <toolset>gcc:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>clang:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>intel:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>darwin:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>msvc:<cxxflags>"-DBOOST_NO_RTTI" ; 19 20 21# Making libraries that CANNOT work between rtti-on/rtti-off modules 22obj test_lib_nortti-obj : test_lib.cpp : <link>shared <rtti>off $(norttidefines) ; 23obj test_lib_anonymous_nortti-obj : test_lib_anonymous.cpp : <link>shared <rtti>off $(norttidefines) ; 24lib test_lib_nortti : test_lib_nortti-obj : <link>shared <rtti>off $(norttidefines) ; 25lib test_lib_anonymous_nortti : test_lib_anonymous_nortti-obj : <link>shared <rtti>off $(norttidefines) ; 26 27obj test_lib_rtti-obj : test_lib.cpp : <link>shared ; 28obj test_lib_anonymous_rtti-obj : test_lib_anonymous.cpp : <link>shared ; 29lib test_lib_rtti : test_lib_rtti-obj : <link>shared ; 30lib test_lib_anonymous_rtti : test_lib_anonymous_rtti-obj : <link>shared ; 31 32# Making libraries that can work between rtti-on/rtti-off modules 33obj test_lib_nortti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ; 34obj test_lib_rtti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ; 35lib test_lib_nortti_compat : test_lib_nortti_compat-obj : <link>shared $(nortti) $(compat) ; 36lib test_lib_rtti_compat : test_lib_rtti_compat-obj : <link>shared $(nortti) $(compat) ; 37 38exe testing_crossmodule_anonymous_no_rtti : testing_crossmodule_anonymous.cpp test_lib_anonymous_nortti : <rtti>off $(norttidefines) ; 39 40test-suite type_index 41 : 42 [ run type_index_test.cpp ] 43 [ run type_index_runtime_cast_test.cpp ] 44 [ run type_index_constexpr_test.cpp ] 45 [ run type_index_test.cpp : : : <rtti>off $(norttidefines) : type_index_test_no_rtti ] 46 [ run ctti_print_name.cpp : : : <test-info>always_show_run_output ] 47 [ run testing_crossmodule.cpp test_lib_rtti ] 48 [ run testing_crossmodule.cpp test_lib_nortti : : : <rtti>off $(norttidefines) : testing_crossmodule_no_rtti ] 49 [ run testing_crossmodule_anonymous.cpp test_lib_anonymous_rtti : : : <test-info>always_show_run_output ] 50 [ run compare_ctti_stl.cpp ] 51 [ run track_13621.cpp ] 52 53 [ compile-fail type_index_test_ctti_copy_fail.cpp ] 54 [ compile-fail type_index_test_ctti_construct_fail.cpp ] 55 [ compile type_index_test_ctti_alignment.cpp ] 56 57 # Mixing RTTI on and off 58 59 # MSVC sometimes overrides the /GR-, without `detect_missmatch` this test may link. 60 # TODO: Disabled on MSVC. Enable again when there'll be an understanding of how to write this test correctly wor MSVC. 61 [ link-fail testing_crossmodule.cpp test_lib_rtti : $(nortti) <toolset>msvc:<build>no : link_fail_nortti_rtti ] 62 [ link-fail testing_crossmodule.cpp test_lib_nortti : <toolset>msvc:<build>no : link_fail_rtti_nortti ] 63 64 [ run testing_crossmodule.cpp test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ] 65 [ run testing_crossmodule.cpp test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ] 66 ; 67 68# Assuring that examples compile and run. Adding sources from `examples` directory to the `type_index` test suite. 69for local p in [ glob ../examples/*.cpp ] 70{ 71 # RTTI on 72 type_index += [ run $(p) ] ; 73 74 # RTTI off 75 local target_name = $(p[1]:B)_no_rtti ; 76 if $(target_name) != "table_of_names_no_rtti" 77 { 78 type_index += [ run $(p) : : : <rtti>off $(norttidefines) : $(target_name) ] ; 79 } 80} 81 82