Fix redef of OS_BSD predef.

When a BSD sub-os header is included directly the general
OS_BSD predef is inidially defined as not-available. Which
warns as the sub-os header defines it. The fix is to unconditionally
un-def the OS_BSD predef.

fixes https://github.com/boostorg/predef/issues/111
This commit is contained in:
Rene Rivera
2021-01-04 14:37:33 -06:00
parent e697cafd12
commit d990549214
8 changed files with 79 additions and 6 deletions

View File

@ -10,6 +10,10 @@ http://www.boost.org/LICENSE_1_0.txt)
== 1.12
* Switch to using the endian.h header on OpenBSD. (Brad Smith)
* Fix not handling recent versions of stdcxx that go above version 9.
* Fix including sub-BSD OS headers directly causing redef warnings.
* Add CI testing of direct inclusion of all headers.
* Add CI testing on FreeBSD for clang and gcc.
== 1.11

View File

@ -6808,6 +6808,18 @@ expressions. It defaults to "c++", but can be any of: "c", "cpp",
<li>
<p>Switch to using the endian.h header on OpenBSD. (Brad Smith)</p>
</li>
<li>
<p>Fix not handling recent versions of stdcxx that go above version 9.</p>
</li>
<li>
<p>Fix including sub-BSD OS headers directly causing redef warnings.</p>
</li>
<li>
<p>Add CI testing of direct inclusion of all headers.</p>
</li>
<li>
<p>Add CI testing on FreeBSD for clang and gcc.</p>
</li>
</ul>
</div>
</div>

View File

@ -29,6 +29,7 @@ http://en.wikipedia.org/wiki/BSD/OS[BSDi BSD/OS] operating system.
defined(__bsdi__) \
)
# ifndef BOOST_OS_BSD_AVAILABLE
# undef BOOST_OS_BSD
# define BOOST_OS_BSD BOOST_VERSION_NUMBER_AVAILABLE
# define BOOST_OS_BSD_AVAILABLE
# endif

View File

@ -29,6 +29,7 @@ http://en.wikipedia.org/wiki/DragonFly_BSD[DragonFly BSD] operating system.
defined(__DragonFly__) \
)
# ifndef BOOST_OS_BSD_AVAILABLE
# undef BOOST_OS_BSD
# define BOOST_OS_BSD BOOST_VERSION_NUMBER_AVAILABLE
# define BOOST_OS_BSD_AVAILABLE
# endif

View File

@ -31,6 +31,7 @@ http://en.wikipedia.org/wiki/Freebsd[FreeBSD] operating system.
defined(__FreeBSD__) \
)
# ifndef BOOST_OS_BSD_AVAILABLE
# undef BOOST_OS_BSD
# define BOOST_OS_BSD BOOST_VERSION_NUMBER_AVAILABLE
# define BOOST_OS_BSD_AVAILABLE
# endif

View File

@ -36,6 +36,7 @@ http://en.wikipedia.org/wiki/Netbsd[NetBSD] operating system.
defined(__NETBSD__) || defined(__NetBSD__) \
)
# ifndef BOOST_OS_BSD_AVAILABLE
# undef BOOST_OS_BSD
# define BOOST_OS_BSD BOOST_VERSION_NUMBER_AVAILABLE
# define BOOST_OS_BSD_AVAILABLE
# endif

View File

@ -80,6 +80,7 @@ http://en.wikipedia.org/wiki/Openbsd[OpenBSD] operating system.
defined(__OpenBSD__) \
)
# ifndef BOOST_OS_BSD_AVAILABLE
# undef BOOST_OS_BSD
# define BOOST_OS_BSD BOOST_VERSION_NUMBER_AVAILABLE
# define BOOST_OS_BSD_AVAILABLE
# endif

View File

@ -4,11 +4,13 @@
# http://www.boost.org/LICENSE_1_0.txt)
import ../tools/check/predef : require check : predef-require predef-check ;
import common ;
import path ;
import regex ;
# This deals with the unfortunate aspect of a Boost monolithic release
# not having the modular include dirs. This is a kludge that just removes
# the direct depdndency to the header if it can't find it.
# the direct dependency to the header if it can't find it.
local PREDEF_H = $(BOOST_PREDEF_INCLUDE)/boost/predef.h ;
if ! [ path.exists $(PREDEF_H) ]
{
@ -25,11 +27,14 @@ project
using testing ;
test-suite predef :
test-suite predef-info :
[ run info_as_cpp.cpp : : : <test-info>always_show_run_output ]
[ run info_as_c.c : : : <test-info>always_show_run_output ]
[ run info_as_objcpp.mm : : : <test-info>always_show_run_output ]
[ run info_as_objc.m : : : <test-info>always_show_run_output ]
;
test-suite predef :
[ run version.cpp ]
[ run make.cpp ]
[ compile macos_endian.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ]
@ -43,15 +48,62 @@ test-suite predef :
[ compile platform_windows.cpp ]
;
local HEADERS = [ path.glob
$(BOOST_PREDEF_INCLUDE)/predef
$(BOOST_PREDEF_INCLUDE)/predef/architecture
$(BOOST_PREDEF_INCLUDE)/predef/architecture/x86
$(BOOST_PREDEF_INCLUDE)/predef/compiler
$(BOOST_PREDEF_INCLUDE)/predef/hardware
$(BOOST_PREDEF_INCLUDE)/predef/hardware/simd
$(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/arm
$(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/ppc
$(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/x86
$(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/x86_amd
$(BOOST_PREDEF_INCLUDE)/predef/language
$(BOOST_PREDEF_INCLUDE)/predef/library
$(BOOST_PREDEF_INCLUDE)/predef/library/c
$(BOOST_PREDEF_INCLUDE)/predef/library/std
$(BOOST_PREDEF_INCLUDE)/predef/os
$(BOOST_PREDEF_INCLUDE)/predef/os/bsd
$(BOOST_PREDEF_INCLUDE)/predef/other
$(BOOST_PREDEF_INCLUDE)/predef/platform
: *.h
] ;
local single_header_cpp ;
for local h in $(HEADERS)
{
local header_include = [ path.relative $(h) [ path.make $(BOOST_PREDEF_INCLUDE) ] ] ;
local header_cpp = [ regex.replace $(header_include:S=.cpp) "/" "_" ] ;
.HEADER($(header_cpp:B:S=)) = $(header_include) ;
make $(header_cpp) : : @gen_single_header_cpp ;
explicit $(header_cpp) ;
compile $(header_cpp) : <warnings-as-errors>on <warnings>all : $(header_cpp:B:S=) ;
explicit $(header_cpp:B:S=) ;
single_header_cpp += $(header_cpp:B:S=) ;
}
test-suite predef-headers : $(single_header_cpp) ;
.file_touch_cmd = [ common.file-touch-command ] ;
rule gen_single_header_cpp ( target * : source * : properties * )
{
HEADER on $(target) = $(.HEADER($(target[1]:B))) ;
}
actions gen_single_header_cpp
{
$(.file_touch_cmd) @($(<):<=":>=":O=F:E=#include <$(HEADER)>)
}
# Minimal testing done for predef for CI. Since
# we don't have many we can just do all of them.
alias minimal : predef ;
alias minimal : predef predef-info ;
# Full testing target for regular regression tests.
alias full : predef ;
alias full : predef predef-info ;
# Extra's target. Nothing for Predef.
alias extra ;
# Extra's target.
alias extra : predef-headers ;
explicit minimal ;
explicit extra ;