1# Boost serialization Library utility test Jamfile
2
3#  (C) Copyright Robert Ramey 2002-2004.
4#  Use, modification, and distribution are subject to the
5#  Boost Software License, Version 1.0. (See accompanying file
6#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7#
8
9# the file contains Jam rules which are used in both the normal
10# boost test, as well as the performance test and comprehensive
11# tests.
12
13# import rules for testing conditional on config file variables
14import ../../config/checks/config : requires ;
15
16BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
17
18# these are used to shorten testing while in development.  It permits
19# testing to be applied to just a particular type of archive
20if ! $(BOOST_ARCHIVE_LIST) {
21    BOOST_ARCHIVE_LIST =
22        "text_archive.hpp"
23        "text_warchive.hpp"
24        "binary_archive.hpp"
25        "xml_archive.hpp"
26        "xml_warchive.hpp"
27    ;
28    # enable the tests which don't depend on a particular archive
29    BOOST_SERIALIZATION_TEST = true ;
30}
31
32rule run-template ( test-name : sources * : files * : requirements * ) {
33    return [
34        run
35            $(sources)
36        : # command
37        : #input files
38            $(files)
39        : # requirements
40            # toolset warnings
41            <toolset>borland:<cxxflags>"-w-8080 -w-8071 -w-8057 -w-8062 -w-8008 -w-0018 -w-8066"
42            #<toolset>gcc:<warnings>all # ?
43            <toolset>gcc:<cxxflags>"-Wno-unused-variable -Wno-long-long"
44            # <toolset>gcc:<variant>debug><define>_STLP_DEBUG
45            # <toolset>gcc:<variant>debug><define>_GLIBCXX_DEBUG
46            <toolset>darwin:<cxxflags>"-Wno-unused-variable -Wno-long-long"
47            <toolset>msvc:<warnings>all # == /W4
48            <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
49            <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
50            <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
51            <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
52            <toolset>msvc:<cxxflags>"-wd4996"
53            <toolset>clang:<variant>debug:<cxxflags>"-fsanitize=memory"
54            # toolset optimizations
55            <toolset>gcc:<cxxflags>"-ftemplate-depth-255"
56            <toolset>clang:<cxxflags>"-ftemplate-depth-255"
57            <toolset>darwin:<cxxflags>"-ftemplate-depth-255"
58            <toolset>msvc:<cxxflags>"-Gy"
59            # linking
60            <link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
61            <link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
62            $(requirements)
63        : # test name
64            $(test-name)
65    ] ;
66}
67
68# Given a name of test, return the 'save' test that must be run
69# before the named test, or empty string if there's no such test.
70rule dependency-save-test ( test )
71{
72    local m = [ MATCH (.*)load(.*) : $(test) ] ;
73    if $(m)
74    {
75        return $(m[1])save$(m[2]) ;
76    }
77}
78
79# each of the following tests is run with each type of archive
80rule run-invoke ( test-name : sources * : files * : requirements * )
81{
82    local save-test = [ dependency-save-test $(test-name) ] ;
83
84    local tests ;
85    tests += [
86        run-template $(test-name)
87        : # sources
88            $(sources)
89            ../build//boost_serialization
90        : # input files
91        : # requirements
92            $(requirements)
93            <define>BOOST_LIB_DIAGNOSTIC=1
94            <dependency>$(save-test)
95    ] ;
96    return $(tests) ;
97}
98
99# each of the following tests is run with each type of archive
100rule run-winvoke ( test-name : sources * : files * : requirements * )
101{
102    local save-test = [ dependency-save-test $(test-name) ] ;
103
104    local tests ;
105    tests += [
106        run-template $(test-name)
107        : # sources
108            $(sources)
109            ../build//boost_serialization
110            ../build//boost_wserialization
111        : # input files
112        : # requirements
113            $(requirements)
114            <define>BOOST_LIB_DIAGNOSTIC=1
115            # both stlport and msvc6 define iswspace
116            <toolset>msvc,<stdlib>stlport:<linkflags>"-force:multiple"
117            <dependency>$(save-test)
118            [ requires std_wstreambuf ]
119    ] ;
120    return $(tests) ;
121}
122
123# for tests which don't use library code - usually just headers
124rule test-bsl-run-no-lib  ( test-name : sources * : requirements * )
125{
126    local tests ;
127    tests += [
128        run-template $(test-name)
129        : # sources
130            $(test-name).cpp $(sources).cpp
131        : # input files
132        : # requirements
133            $(requirements)
134    ] ;
135    return $(tests) ;
136}
137
138# for tests which are run just once rather than for every archive
139rule test-bsl-run ( test-name : sources * : libs * : requirements * )
140{
141    local tests ;
142    tests +=  [
143        run-invoke $(test-name)
144        : # sources
145            $(test-name).cpp $(sources).cpp $(libs)
146        : # input files
147        : # requirements
148            $(requirements)
149    ] ;
150    return $(tests) ;
151}
152
153rule test-bsl-run_archive ( test-name : archive-name : sources * : libs * : requirements * ) {
154    local tests ;
155    switch $(archive-name) {
156    case "*_warchive" :
157        tests +=  [
158            run-winvoke $(test-name)_$(archive-name)
159            : # sources
160                $(sources).cpp $(libs)
161            : # input files
162            : # requirements
163                <define>BOOST_ARCHIVE_TEST=$(archive-name).hpp
164                $(requirements)
165        ] ;
166    case "*" :
167        tests +=  [
168            run-invoke $(test-name)_$(archive-name)
169            : # sources
170                $(sources).cpp $(libs)
171            : # input files
172            : # requirements
173                <define>BOOST_ARCHIVE_TEST=$(archive-name).hpp
174                $(requirements)
175        ] ;
176    }
177    return $(tests) ;
178}
179
180rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) {
181    local tests ;
182    for local defn in $(BOOST_ARCHIVE_LIST) {
183        tests += [
184            test-bsl-run_archive $(test-name)
185            : $(defn:LB)
186            : $(test-name) $(sources)
187            : $(libs)
188            : $(requirements)
189        ] ;
190    }
191    return $(tests) ;
192}
193
194rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
195    local tests ;
196    for local defn in $(BOOST_ARCHIVE_LIST) {
197        ECHO polymorphic_$(defn:LB) ;
198        tests += [
199            test-bsl-run_archive $(test-name)
200            : polymorphic_$(defn:LB)
201            : $(test-name) $(sources)
202            : $(libs)
203            : $(requirements)
204        ] ;
205    }
206    return $(tests) ;
207}
208
209