mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-11 05:07:58 +00:00
fix odr test for bundled boost and test this
This commit is contained in:
parent
830f238534
commit
b63d7e2b6f
@ -70,6 +70,9 @@ matrix:
|
|||||||
# prepare build
|
# prepare build
|
||||||
- ./bootstrap.sh
|
- ./bootstrap.sh
|
||||||
- ./b2 headers
|
- ./b2 headers
|
||||||
|
# simulate bundled boost by moving the headers instead of symlinking
|
||||||
|
- rm -rf boost/histogram.pp boost/histogram
|
||||||
|
- mv -f libs/histogram/include/boost/* boost
|
||||||
- cd libs/histogram
|
- cd libs/histogram
|
||||||
- B2="../../b2 -q -j2 warnings-as-errors=on"
|
- B2="../../b2 -q -j2 warnings-as-errors=on"
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
# (See accompanying file LICENSE_1_0.txt
|
# (See accompanying file LICENSE_1_0.txt
|
||||||
# or copy at http://www.boost.org/LICENSE_1_0.txt)
|
# or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
This test makes sure that all boost.histogram headers are included in the ODR test carried out in odr_main_test.cpp. See that file for details on why this test needed.
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@ -11,12 +15,20 @@ import re
|
|||||||
this_path = os.path.dirname(__file__)
|
this_path = os.path.dirname(__file__)
|
||||||
|
|
||||||
all_headers = set()
|
all_headers = set()
|
||||||
include_path = os.path.join(this_path, "..", "include")
|
# Includes are either in this_path/../include for the standalone version or ...
|
||||||
|
include_path = os.path.join(this_path, "..", "include", "boost", "histogram")
|
||||||
|
if not os.path.exists(include_path):
|
||||||
|
# ... in this_path/../../.. for the bundled boost release
|
||||||
|
include_path = os.path.join(this_path, "..", "..", "..", "boost", "histogram")
|
||||||
|
assert os.path.exists(include_path)
|
||||||
|
|
||||||
|
# this has to be rindex, because any leading path could also be called boost
|
||||||
|
root_include_path = include_path[: include_path.rindex("boost")]
|
||||||
|
|
||||||
for root, dirs, files in os.walk(include_path):
|
for root, dirs, files in os.walk(include_path):
|
||||||
for fn in files:
|
for fn in files:
|
||||||
fn = os.path.join(root, fn)
|
fn = os.path.join(root, fn)
|
||||||
assert fn.startswith(include_path)
|
fn = fn[len(root_include_path) :]
|
||||||
fn = fn[len(include_path) + 1 :]
|
|
||||||
all_headers.add(fn)
|
all_headers.add(fn)
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +49,7 @@ while unread_headers:
|
|||||||
included_headers.update(unread_headers)
|
included_headers.update(unread_headers)
|
||||||
for hdr in tuple(unread_headers): # copy needed because unread_headers is modified
|
for hdr in tuple(unread_headers): # copy needed because unread_headers is modified
|
||||||
unread_headers.remove(hdr)
|
unread_headers.remove(hdr)
|
||||||
for hdr2 in get_headers(os.path.join(include_path, hdr)):
|
for hdr2 in get_headers(os.path.join(root_include_path, hdr)):
|
||||||
if hdr2 not in included_headers:
|
if hdr2 not in included_headers:
|
||||||
unread_headers.add(hdr2)
|
unread_headers.add(hdr2)
|
||||||
|
|
||||||
|
@ -4,7 +4,18 @@
|
|||||||
// (See accompanying file LICENSE_1_0.txt
|
// (See accompanying file LICENSE_1_0.txt
|
||||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// include all headers again
|
/*
|
||||||
|
For a header-only library, it is important to not accidentally violate the
|
||||||
|
One-Definition-Rule (ODR), which causes linker errors. The ODR is violated
|
||||||
|
when a non-templated function declared in a header is not inlined, and that
|
||||||
|
header is then included in several translation units which are then linked
|
||||||
|
together.
|
||||||
|
|
||||||
|
We carry out this test by including all headers in two separate translation
|
||||||
|
units which are then linked together. There is an additional test called
|
||||||
|
check_odr_test.py which checks that "odr_test.cpp" includes all headers.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "odr_test.cpp"
|
#include "odr_test.cpp"
|
||||||
|
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
// (See accompanying file LICENSE_1_0.txt
|
// (See accompanying file LICENSE_1_0.txt
|
||||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// include all Boost.Histogram header here
|
// include all Boost.Histogram header here; see odr_main_test.cpp for details
|
||||||
#include <boost/histogram.hpp>
|
#include <boost/histogram.hpp>
|
||||||
#include <boost/histogram/accumulators.hpp>
|
|
||||||
#include <boost/histogram/axis/ostream.hpp>
|
|
||||||
#include <boost/histogram/ostream.hpp>
|
#include <boost/histogram/ostream.hpp>
|
||||||
#include <boost/histogram/serialization.hpp>
|
#include <boost/histogram/serialization.hpp>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user