#
# Copyright (c) 2012-2016 Krzysztof Jusiak (krzysztof at jusiak dot net)
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
import testing ;
import feature : extend-feature compose ;

.argv = [ modules.peek : ARGV ] ;

project boost.di :
    requirements
        <include>../include
        <include>.
;

rule example ( src + : cxxflags * : property * ) {
    cxx_flags = "" ;
    if $(cxxflags) {
        cxx_flags = "$(cxxflags)" ;
    }

    toolset =
        <toolset>gcc:<cxxflags>"-std=c++1y -fno-exceptions -Wall -Wextra -Werror $(cxx_flags)"
        <toolset>gcc-6.0.0:<cxxflags>"-std=c++1z"
        <toolset>clang:<cxxflags>"-std=c++1y -Wno-dollar-in-identifier-extension -fno-exceptions -pedantic -pedantic-errors -Wall -Wextra -Werror $(cxx_flags)"
        <toolset>darwin:<cxxflags>"-std=c++1y -fno-exceptions -pedantic -pedantic-errors -Wall -Wextra -Werror $(cxx_flags)"
        <toolset>msvc:<cxxflags>"/W3 $(cxx_flags)"
    ;

    local memcheck = [ MATCH --memcheck=(.*) : $(.argv) ] ;

    if ${memcheck} {
        toolset += <testing.launcher>$(memcheck) ;
    }

    run $(src) : : : $(toolset) : $(property) ;
}

test-suite example :
    [ example modules/model.cpp
			  modules/module_model.cpp
			  modules/view.cpp
			  modules/module_view.cpp
			  modules/controller.cpp
			  modules/main.cpp
	  : -Imodules -DBOOST_DI_CFG_FWD="\"class config;\"" -DBOOST_DI_CFG=config
	]
    [ example annotations.cpp ]
    [ example automatic_injection.cpp ]
    [ example bind_non_owning_ptr.cpp ]
    [ example bindings.cpp ]
    [ example configuration.cpp ]
    [ example constructor_injection.cpp ]
    [ example constructor_signature.cpp ]
    [ example custom_policy.cpp ]
    [ example custom_provider.cpp ]
    [ example custom_scope.cpp ]
    [ example deduce_scope.cpp ]
    [ example dynamic_bindings.cpp ]
    [ example eager_singletons.cpp ]
    [ example fwd_bindings.cpp ]
    [ example hello_world.cpp ]
    [ example modules.cpp ]
    [ example motivation.cpp ]
    [ example multiple_bindings.cpp ]
    [ example multiple_interfaces.cpp ]
    [ example pool_provider.cpp ]
    [ example scopes.cpp ]
    [ example try_it.cpp ]
;

test-suite performance :
    [ example performance/create_bound_interface.cpp ]
    [ example performance/create_bound_interface_via_exposed_module.cpp ]
    [ example performance/create_bound_interface_via_module.cpp ]
    [ example performance/create_named_type.cpp ]
    [ example performance/create_type_with_bound_instance.cpp ]
    [ example performance/create_type_without_bindings.cpp ]
;

test-suite tutorial :
    [ example tutorial/basic_annotations_to_the_rescue.cpp ]
    [ example tutorial/basic_create_objects_tree.cpp ]
    [ example tutorial/basic_decide_the_life_times.cpp ]
    [ example tutorial/basic_first_steps_with_bindings.cpp ]
    [ example tutorial/basic_first_steps_with_bindings_override.cpp ]
    [ example tutorial/basic_first_steps_with_dynamic_bindings.cpp ]
    [ example tutorial/basic_first_steps_with_multiple_bindings.cpp ]
    [ example tutorial/basic_split_your_configuration.cpp ]
    [ example tutorial/basic_split_your_configuration_expose.cpp ]
;

test-suite user_guide :
    [ example user_guide/annotated_constructor_injection.cpp ]
    [ example user_guide/annotated_constructor_injection_with_constructor_definition.cpp ]
    [ example user_guide/annotated_constructor_injection_with_ctor_traits.cpp ]
    [ example user_guide/annotated_constructor_injection_with_the_same_names.cpp ]
    [ example user_guide/bind_cross_platform.cpp ]
    [ example user_guide/bind_deduce_type_to_value.cpp ]
    [ example user_guide/bind_dynamic_bindings.cpp ]
    [ example user_guide/bind_interface_to_implementation.cpp ]
    [ example user_guide/bind_multiple_bindings.cpp ]
    [ example user_guide/bind_multiple_bindings_initializer_list.cpp ]
    [ example user_guide/bind_multiple_interfaces.cpp ]
    [ example user_guide/bind_type_override.cpp ]
    [ example user_guide/bind_type_to_compile_time_value.cpp ]
    [ example user_guide/bind_type_to_value.cpp ]
    [ example user_guide/constructor_injection_aggregate.cpp ]
    [ example user_guide/constructor_injection_ambiguous_constructors_via_BOOST_DI_INJECT.cpp ]
    [ example user_guide/constructor_injection_ambiguous_constructors_via_BOOST_DI_INJECT_TRAITS.cpp ]
    [ example user_guide/constructor_injection_ambiguous_constructors_via_ctor_traits.cpp ]
    [ example user_guide/constructor_injection_ambiguous_constructors_via_inject.cpp ]
    [ example user_guide/constructor_injection_ambiguous_constructors_via_vaargs.cpp ]
    [ example user_guide/constructor_injection_default_values.cpp ]
    [ example user_guide/constructor_injection_direct.cpp ]
    [ example user_guide/constructor_injection_long_parameter_list.cpp ]
    [ example user_guide/constructor_injection_multiple_constructors.cpp ]
    [ example user_guide/injector_empty.cpp ]
    [ example user_guide/module.cpp ]
    [ example user_guide/module_exposed_annotated_type.cpp ]
    [ example user_guide/module_exposed_complex_types.cpp ]
    [ example user_guide/module_exposed_many_types.cpp ]
    [ example user_guide/module_exposed_type.cpp ]
    [ example user_guide/policies_constructible_global.cpp ]
    [ example user_guide/policies_constructible_local.cpp ]
    [ example user_guide/policies_print_type_extended.cpp ]
    [ example user_guide/policies_print_types.cpp ]
    [ example user_guide/providers_heap.cpp ]
    [ example user_guide/providers_heap_no_throw.cpp ]
    [ example user_guide/providers_stack_over_heap.cpp ]
    [ example user_guide/scopes_custom.cpp ]
    [ example user_guide/scopes_deduce_default.cpp ]
    [ example user_guide/scopes_instance.cpp ]
    [ example user_guide/scopes_singleton.cpp ]
    [ example user_guide/scopes_unique.cpp ]
;

