diff options
Diffstat (limited to 'src/boost/libs/predef')
36 files changed, 1606 insertions, 0 deletions
diff --git a/src/boost/libs/predef/CMakeLists.txt b/src/boost/libs/predef/CMakeLists.txt new file mode 100644 index 000000000..dc69fe5d7 --- /dev/null +++ b/src/boost/libs/predef/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright Mike Dev 2018 +# Copyright Rene Rivera 2018 +# 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 + +# NOTE: +# CMake support for Boost.Predef is currently experimental at best and the +# interface is likely to change in the future +# +# This file provides minimal cmake support (no unit-tests, +# no installation) for integration into a "host" cmake project +# via the "add_subdirectory( <path-to-boost-predef> )" command. +# +# Other cmake targets can then use the public target name +# "Boost::predef" in order to express their dependency +# on this library. I.e: +# +# target_link_libraries( <my-exe/lib> PUBLIC Boost::predef ) + +# Only need the basic minimum of project, add_library, and +# target_include_directories commands. +cmake_minimum_required( VERSION 3.0 ) + +# Don't set VERSION, as that's a pita to keep up to date with the version +# header. And don't set LANGUAGES as we are multi-language and header +# only, so it's irrelevant. +project( BoostPredef ) + +# Simple INTERFACE, and header only, library target. +add_library( boost_predef INTERFACE ) + +# The only usage requirement is include dir for consumers. +target_include_directories( boost_predef INTERFACE include ) + +# Add an alias to be compatible with consumers that may have used the +# FindBoost script. +add_library( Boost::predef ALIAS boost_predef ) diff --git a/src/boost/libs/predef/azure-pipelines.yml b/src/boost/libs/predef/azure-pipelines.yml new file mode 100644 index 000000000..3fed16598 --- /dev/null +++ b/src/boost/libs/predef/azure-pipelines.yml @@ -0,0 +1,333 @@ +# Use, modification, and distribution are +# subject to 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) +# +# Copyright Rene Rivera 2019-2020. + +trigger: + branches: + include: + - develop + - master + - feature/* +pr: + branches: + include: + - develop + +variables: + AZP: 1 + AZP_REPO_DIR: $(Build.Repository.LocalPath) + AZP_BRANCH: $(Build.SourceBranch) + AZP_BRANCH_NAME: $(Build.SourceBranchName) + AZP_COMMIT: $(Build.SourceVersion) + AZP_REPO: $(Build.Repository.Name) + AZP_PULL_REQUEST: $(System.PullRequest.PullRequestNumber) + +stages: + +- stage: Test + jobs: + + - job: 'Linux' + strategy: + matrix: + GCC 9 (GNU): + TOOLSET: gcc + CXX: g++-9 + PACKAGES: g++-9 + B2_ARGS: 'cxxstd=03,11,14,17,2a cxxstd-dialect=gnu' + VM_IMAGE: 'ubuntu-18.04' + GCC 9 (ISO): + TOOLSET: gcc + CXX: g++-9 + PACKAGES: g++-9 + B2_ARGS: 'cxxstd=03,11,14,17,2a cxxstd-dialect=iso' + VM_IMAGE: 'ubuntu-18.04' + GCC 9: + TOOLSET: gcc + CXX: g++-9 + PACKAGES: g++-9 + VM_IMAGE: 'ubuntu-18.04' + GCC 8: + TOOLSET: gcc + CXX: g++-8 + PACKAGES: g++-8 + VM_IMAGE: 'ubuntu-18.04' + GCC 7: + TOOLSET: gcc + CXX: g++-7 + PACKAGES: g++-7 + VM_IMAGE: 'ubuntu-18.04' + GCC 6: + TOOLSET: gcc + CXX: g++-6 + PACKAGES: g++-6 + VM_IMAGE: 'ubuntu-18.04' + GCC 5: + TOOLSET: gcc + CXX: g++-5 + PACKAGES: g++-5 + VM_IMAGE: 'ubuntu-18.04' + GCC 4.9: + TOOLSET: gcc + CXX: g++-4.9 + PACKAGES: g++-4.9 + VM_IMAGE: 'ubuntu-16.04' + GCC 4.8: + TOOLSET: gcc + CXX: g++-4.8 + PACKAGES: g++-4.8 + VM_IMAGE: 'ubuntu-16.04' + GCC 4.7: + TOOLSET: gcc + CXX: g++-4.7 + PACKAGES: g++-4.7 + VM_IMAGE: 'ubuntu-16.04' + Clang 9: + TOOLSET: clang + CXX: clang++-9 + PACKAGES: clang-9 + LLVM_REPO: llvm-toolchain-xenial-9 + VM_IMAGE: 'ubuntu-18.04' + Clang 8: + TOOLSET: clang + CXX: clang++-8 + PACKAGES: clang-8 + LLVM_REPO: llvm-toolchain-xenial-8 + VM_IMAGE: 'ubuntu-18.04' + Clang 7: + TOOLSET: clang + CXX: clang++-7 + PACKAGES: clang-7 + LLVM_REPO: llvm-toolchain-xenial-7 + VM_IMAGE: 'ubuntu-18.04' + Clang 6: + TOOLSET: clang + CXX: clang++-6.0 + PACKAGES: clang-6.0 + LLVM_REPO: llvm-toolchain-xenial-6.0 + VM_IMAGE: 'ubuntu-18.04' + Clang 5: + TOOLSET: clang + CXX: clang++-5.0 + PACKAGES: clang-5.0 + LLVM_REPO: llvm-toolchain-xenial-5.0 + VM_IMAGE: 'ubuntu-18.04' + Clang 4: + TOOLSET: clang + CXX: clang++-4.0 + PACKAGES: clang-4.0 + LLVM_REPO: llvm-toolchain-xenial-4.0 + VM_IMAGE: 'ubuntu-18.04' + Clang 3.9: + TOOLSET: clang + CXX: clang++-3.9 + PACKAGES: clang-3.9 + VM_IMAGE: 'ubuntu-18.04' + Clang 3.8: + TOOLSET: clang + CXX: clang++-3.8 + PACKAGES: clang-3.8 + VM_IMAGE: 'ubuntu-16.04' + Clang 3.7: + TOOLSET: clang + CXX: clang++-3.7 + PACKAGES: clang-3.7 + VM_IMAGE: 'ubuntu-16.04' + Clang 3.6: + TOOLSET: clang + CXX: clang++-3.6 + PACKAGES: clang-3.6 + VM_IMAGE: 'ubuntu-16.04' + Clang 3.5: + TOOLSET: clang + CXX: clang++-3.5 + PACKAGES: clang-3.5 + VM_IMAGE: 'ubuntu-16.04' + pool: + vmImage: $(VM_IMAGE) + steps: + - bash: | + set -e + uname -a + sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + if test -n "${LLVM_REPO}" ; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo -E apt-add-repository "deb http://apt.llvm.org/xenial/ ${LLVM_REPO} main" + fi + sudo -E apt-get update + sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ${PACKAGES} + displayName: 'Install CXX' + - bash: | + set -e + pushd ${HOME} + wget -nv https://github.com/boostorg/build/archive/master.tar.gz + tar -zxf master.tar.gz + cd build-master + CXX= ./bootstrap.sh + sudo ./b2 install + popd + displayName: 'Install B2' + - bash: | + set -e + CXX_PATH=`which ${CXX}` + echo "using ${TOOLSET} : : ${CXX_PATH} ;" > ${HOME}/user-config.jam + pushd test + b2 --debug-configuration -a toolset=${TOOLSET} ${B2_ARGS} + popd + displayName: Test + + - job: 'macOS' + strategy: + matrix: + Xcode 11.4: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.4_beta.app + VM_IMAGE: 'macOS-10.15' + Xcode 11.3.1: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.3.1.app + VM_IMAGE: 'macOS-10.15' + Xcode 11.3: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.3.app + VM_IMAGE: 'macOS-10.15' + Xcode 11.2: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.2.app + VM_IMAGE: 'macOS-10.15' + Xcode 11.1: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.1.app + VM_IMAGE: 'macOS-10.15' + Xcode 11.0: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_11.app + VM_IMAGE: 'macOS-10.15' + Xcode 10.2.1: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_10.2.1.app + VM_IMAGE: 'macOS-10.14' + Xcode 10.2: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_10.2.app + VM_IMAGE: 'macOS-10.14' + Xcode 10.1: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_10.1.app + VM_IMAGE: 'macOS-10.14' + Xcode 10.0: + TOOLSET: clang + CXX: clang++ + XCODE_APP: /Applications/Xcode_10.app + VM_IMAGE: 'macOS-10.14' + pool: + vmImage: $(VM_IMAGE) + steps: + - bash: | + set -e + uname -a + sudo xcode-select -switch ${XCODE_APP} + which clang++ + clang++ --version + displayName: 'Install CXX' + - bash: | + set -e + pushd ${HOME} + wget -nv https://github.com/boostorg/build/archive/master.tar.gz + tar -zxf master.tar.gz + cd build-master + CXX= ./bootstrap.sh + sudo ./b2 install + popd + displayName: 'Install B2' + - bash: | + set -e + CXX_PATH=`which ${CXX}` + echo "using ${TOOLSET} : : ${CXX_PATH} ;" > ${HOME}/user-config.jam + pushd test + b2 --debug-configuration -a toolset=${TOOLSET} ${B2_ARGS} + popd + displayName: Test + + - job: 'Windows' + strategy: + matrix: + VS 2019: + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=32,64 cxxstd=14,latest + VM_IMAGE: 'windows-2019' + VS 2019 (UWP DESKTOP): + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=64 define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP + VM_IMAGE: 'windows-2019' + VS 2019 (UWP PHONE): + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=64 define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP + VM_IMAGE: 'windows-2019' + VS 2019 (UWP STORE): + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=64 define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_PC_APP + VM_IMAGE: 'windows-2019' + VS 2019 (UWP SERVER): + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=64 define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_SERVER + VM_IMAGE: 'windows-2019' + VS 2019 (UWP SYSTEM): + TOOLSET: msvc + TOOLSET_VERSION: 14.2 + B2_ARGS: address-model=64 define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM + VM_IMAGE: 'windows-2019' + VS 2017: + TOOLSET: msvc + TOOLSET_VERSION: 14.1 + VM_IMAGE: 'vs2017-win2016' + MinGW 8.1.0: + TOOLSET: gcc + VM_IMAGE: 'windows-2019' + MinGW 8.1.0 (UWP DESKTOP): + TOOLSET: gcc + B2_ARGS: define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP + VM_IMAGE: 'windows-2019' + MinGW 8.1.0 (UWP STORE): + TOOLSET: gcc + B2_ARGS: define=_WIN32_WINNT=0x0A00 define=WINAPI_FAMILY=WINAPI_FAMILY_PC_APP + VM_IMAGE: 'windows-2019' + pool: + vmImage: $(VM_IMAGE) + steps: + - script: | + cd %BUILD_SOURCESDIRECTORY%/.. + curl "https://github.com/boostorg/build/archive/master.zip" -L -o b2.zip + displayName: Download B2 + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: $(Build.SourcesDirectory)/../b2.zip + destinationFolder: $(Build.SourcesDirectory)/.. + cleanDestinationFolder: false + displayName: Extract B2 + - script: | + echo using %TOOLSET% ^: %TOOLSET_VERSION% ^; > %HOMEDRIVE%%HOMEPATH%/user-config.jam + cd %BUILD_SOURCESDIRECTORY%/../build-master + cmd.exe /c bootstrap.bat + displayName: Install B2 + - script: | + set BOOST_BUILD_PATH=%BUILD_SOURCESDIRECTORY%/../build-master + cd %BUILD_SOURCESDIRECTORY%/test + %BUILD_SOURCESDIRECTORY%/../build-master/b2.exe --debug-configuration -a toolset=%TOOLSET% %B2_ARGS% + displayName: Test diff --git a/src/boost/libs/predef/build.jam b/src/boost/libs/predef/build.jam new file mode 100644 index 000000000..69be96944 --- /dev/null +++ b/src/boost/libs/predef/build.jam @@ -0,0 +1,43 @@ +# Copyright Rene Rivera 2014-2019 +# 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) + +#| +This B2 project provides support for using the Predef library externally as +a standalone project or by embedding in your B2 project tree. To use +externally you would need a `use-project` declaration and to use the +project as a dependency where needed: + +---- +use-project /hash-predef : /path/to/hash-predef/root ; + +exe my_thing : main.cpp : <dependency>/hash-predef ; +---- + +To use in your project tree you would only need to place the Predef tree +in a subdirectory and reference the project location as a dependency where +needed. + +---- +exe my_thin : main.cpp : <dependency>libs/hash-predef ; +---- +|# + +import project ; + +path-constant BOOST_PREDEF_ROOT : . ; +path-constant BOOST_PREDEF_INCLUDE : include ; +constant PREDEF_DIST : boost ; + +project /boost/predef + : usage-requirements + <include>$(BOOST_PREDEF_INCLUDE) ; + +if [ project.is-jamroot-module $(__name__) ] +{ + local attributes = [ project.attributes $(__name__) ] ; + $(attributes).set "build-dir" : .bin ; +} + +alias libs ; diff --git a/src/boost/libs/predef/check/predef.jam b/src/boost/libs/predef/check/predef.jam new file mode 100644 index 000000000..7042dc1d4 --- /dev/null +++ b/src/boost/libs/predef/check/predef.jam @@ -0,0 +1,17 @@ +# Copyright Rene Rivera 2016 +# 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) + +# Hack, to reload check/predef.jam at its new location. +import modules ; +local _loaded_ ; +for local _module_ in [ modules.peek modules : .loaded ] +{ + if $(_module_) != "predef" + { + _loaded_ += $(_module_) ; + } +} +modules.poke modules : .loaded : $(_loaded_) ; +import ../tools/check/predef ; diff --git a/src/boost/libs/predef/index.html b/src/boost/libs/predef/index.html new file mode 100644 index 000000000..af6032096 --- /dev/null +++ b/src/boost/libs/predef/index.html @@ -0,0 +1,19 @@ +<html> + +<head> + <meta http-equiv="refresh" content="0; URL=./doc/index.html"> +</head> + +<body> + Automatic redirection failed, please go to + <a href="./doc/index.html">./doc/index.html</a> + </p> +</body> + +</html> +<!-- +Copyright Rene Rivera 2013-2019 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt +or copy at www.boost.org/LICENSE_1_0.txt). +-->
\ No newline at end of file diff --git a/src/boost/libs/predef/meta/libraries.json b/src/boost/libs/predef/meta/libraries.json new file mode 100644 index 000000000..d7e326cdd --- /dev/null +++ b/src/boost/libs/predef/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "predef", + "name": "Predef", + "authors": [ + "Rene Rivera" + ], + "description": "This library defines a set of compiler, architecture, operating system, library, and other version numbers from the information it can gather of C, C++, Objective C, and Objective C++ predefined macros or those defined in generally available headers.", + "category": [ + "Miscellaneous" + ], + "maintainers": [ + "Rene Rivera <grafikrobot -at- gmail.com>" + ] +} diff --git a/src/boost/libs/predef/test/build.jam b/src/boost/libs/predef/test/build.jam new file mode 100644 index 000000000..e894a31e9 --- /dev/null +++ b/src/boost/libs/predef/test/build.jam @@ -0,0 +1,57 @@ +# Copyright Rene Rivera 2011-2019 +# 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 ../tools/check/predef : require check : predef-require predef-check ; +import path ; + +# 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. +local PREDEF_H = $(BOOST_PREDEF_INCLUDE)/boost/predef.h ; +if ! [ path.exists $(PREDEF_H) ] +{ + PREDEF_H = ; +} + +project + : requirements + <include>$(BOOST_PREDEF_INCLUDE) + # Add explicit dependency since we don't have header scanner for + # .m and .mm files. + <dependency>$(PREDEF_H) + ; + +using testing ; + +test-suite predef : + [ 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 ] + [ run version.cpp ] + [ run make.cpp ] + [ compile macos_endian.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ] + [ compile macos_vs_bsd.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ] + [ run check_value.cpp : : : <test-info>always_show_run_output + [ predef-check "BOOST_COMP_CLANG > 0.0.0" "BOOST_OS_LINUX == 0" : : <cxxflags>-DCHECK_VALUE=true ] ] + [ run workaround.cpp ] + [ compile workaround_strict_config.cpp ] + [ run tested_at.cpp ] + [ compile-fail tested_at_outdated.cpp : <test-info>always_show_run_output ] + [ compile platform_windows.cpp ] + ; + +# Minimal testing done for predef for CI. Since +# we don't have many we can just do all of them. +alias minimal : predef ; + +# Full testing target for regular regression tests. +alias full : predef ; + +# Extra's target. Nothing for Predef. +alias extra ; + +explicit minimal ; +explicit extra ; diff --git a/src/boost/libs/predef/test/check_value.cpp b/src/boost/libs/predef/test/check_value.cpp new file mode 100644 index 000000000..30ae806f5 --- /dev/null +++ b/src/boost/libs/predef/test/check_value.cpp @@ -0,0 +1,26 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ + +/* + * Simple program that just prints out the externally + * defined CHECK_VALUE def. It's used to test the check + * program and the related BB support. + */ + +#include <boost/predef.h> +#include <iostream> +#include <string> + +#ifndef CHECK_VALUE +#define CHECK_VALUE "undefined" +#endif + +int main() +{ + std::cout << "CHECK_VALUE == " << CHECK_VALUE << "\n" ; + return 0; +} diff --git a/src/boost/libs/predef/test/info_as_c.c b/src/boost/libs/predef/test/info_as_c.c new file mode 100644 index 000000000..44f7e8dcd --- /dev/null +++ b/src/boost/libs/predef/test/info_as_c.c @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_info.h" diff --git a/src/boost/libs/predef/test/info_as_cpp.cpp b/src/boost/libs/predef/test/info_as_cpp.cpp new file mode 100644 index 000000000..44f7e8dcd --- /dev/null +++ b/src/boost/libs/predef/test/info_as_cpp.cpp @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_info.h" diff --git a/src/boost/libs/predef/test/info_as_objc.m b/src/boost/libs/predef/test/info_as_objc.m new file mode 100644 index 000000000..44f7e8dcd --- /dev/null +++ b/src/boost/libs/predef/test/info_as_objc.m @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_info.h" diff --git a/src/boost/libs/predef/test/info_as_objcpp.mm b/src/boost/libs/predef/test/info_as_objcpp.mm new file mode 100644 index 000000000..44f7e8dcd --- /dev/null +++ b/src/boost/libs/predef/test/info_as_objcpp.mm @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_info.h" diff --git a/src/boost/libs/predef/test/macos_endian.c b/src/boost/libs/predef/test/macos_endian.c new file mode 100644 index 000000000..7f29f900f --- /dev/null +++ b/src/boost/libs/predef/test/macos_endian.c @@ -0,0 +1,21 @@ +/* +Copyright Rene Rivera 2013 +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) +*/ + +/* + * OSX can define the BSD symbols if sys/param.h is included + * before detection. This causes the endian detection to misfire + * as both MACOS and BSD are "detected" (currently). This just + * tests that the sys/param.h include can be included before + * endian detection and still have it work correctly. + */ + +#if defined(__APPLE__) +# include <sys/param.h> +# include <boost/predef/os/bsd.h> +# include <boost/predef/os/macos.h> +# include <boost/predef/other/endian.h> +#endif diff --git a/src/boost/libs/predef/test/macos_vs_bsd.c b/src/boost/libs/predef/test/macos_vs_bsd.c new file mode 100644 index 000000000..173b5a42a --- /dev/null +++ b/src/boost/libs/predef/test/macos_vs_bsd.c @@ -0,0 +1,19 @@ +/* +Copyright Rene Rivera 2013 +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) +*/ + +/* + * OSX can masquerade as BSD when sys/param.h is previously included. + * So we test that we only detect OSX in this combination. + */ +#if defined(__APPLE__) +# include <sys/param.h> +# include <boost/predef/os/bsd.h> +# include <boost/predef/os/macos.h> +# if !BOOST_OS_MACOS || BOOST_OS_BSD +# error "BOOST_OS_MACOS not detected and/or BOOST_OS_BSD mis-detected." +# endif +#endif diff --git a/src/boost/libs/predef/test/make.cpp b/src/boost/libs/predef/test/make.cpp new file mode 100644 index 000000000..6b8462466 --- /dev/null +++ b/src/boost/libs/predef/test/make.cpp @@ -0,0 +1,94 @@ +/* +Copyright Rene Rivera 2011-2013 +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) +*/ +#include <boost/predef/version_number.h> +#include <boost/predef/make.h> +#include <exception> +#include <vector> +#include <string> +#include <iostream> + +namespace +{ + struct test_info + { + std::string value; + bool passed; + + test_info(std::string const & v, bool p) : value(v), passed(p) {} + test_info(test_info const & o) : value(o.value), passed(o.passed) {} + }; + + std::vector<test_info> test_results; +} + +#define PREDEF_CHECK(X) test_results.push_back(test_info(#X,(X))) + +void test_BOOST_VERSION_NUMBER() +{ + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRP(0xFFF) == BOOST_VERSION_NUMBER(0xF,0xF,0xF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRP(0xFFFF) == BOOST_VERSION_NUMBER(0xFF,0xF,0xF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRPP(0xFFFF) == BOOST_VERSION_NUMBER(0xF,0xF,0xFF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRR(0xFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0x0)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRRPPPP(0xFFFFFFF) == BOOST_VERSION_NUMBER(0xF,0xFF,0xFFFF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRRP(0xFFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0xF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRRPP000(0xFFFFF000) == BOOST_VERSION_NUMBER(0xF,0xFF,0xFF)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRRPP(0xFFFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0xFF)); + + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VR0(980) == BOOST_VERSION_NUMBER(9,8,0)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRP(999) == BOOST_VERSION_NUMBER(9,9,9)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VPPP(9999) == BOOST_VERSION_NUMBER(9,0,999)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRRPP(999999) == BOOST_VERSION_NUMBER(99,99,99)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR(9999) == BOOST_VERSION_NUMBER(99,99,0)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRRP(98765) == BOOST_VERSION_NUMBER(98,76,5)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRPP(9999) == BOOST_VERSION_NUMBER(9,9,99)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRRPP(99999) == BOOST_VERSION_NUMBER(9,99,99)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRPPPP(460002) == BOOST_VERSION_NUMBER(4,6,2)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRPPPP(491000) == BOOST_VERSION_NUMBER(4,9,1000)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRP000(999000) == BOOST_VERSION_NUMBER(9,9,9)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRR000(999000) == BOOST_VERSION_NUMBER(9,99,0)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR00PP00(2199009900u) == BOOST_VERSION_NUMBER(21,99,99)); + /* PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR00PP00(9999009900ull) == BOOST_VERSION_NUMBER(99,99,99)); */ + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR0PP00(999909900) == BOOST_VERSION_NUMBER(99,99,99)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VV00(9900) == BOOST_VERSION_NUMBER(99,00,00)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR0PPPP(999909999) == BOOST_VERSION_NUMBER(99,99,9999)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRR(999) == BOOST_VERSION_NUMBER(9,99,00)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRRPPP(903122) == BOOST_VERSION_NUMBER(9,3,122)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRRPPP(1101002) == BOOST_VERSION_NUMBER(11,1,2)); + + PREDEF_CHECK(BOOST_PREDEF_MAKE_DATE(1971,1,1) == BOOST_VERSION_NUMBER(1,1,1)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(19700101) == BOOST_VERSION_NUMBER(0,1,1)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(19710101) == BOOST_VERSION_NUMBER(1,1,1)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(20691231) == BOOST_VERSION_NUMBER(99,12,31)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(197001) == BOOST_VERSION_NUMBER(0,1,1)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(197101) == BOOST_VERSION_NUMBER(1,1,1)); + PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(206912) == BOOST_VERSION_NUMBER(99,12,1)); +} + +int main() +{ + test_BOOST_VERSION_NUMBER(); + + unsigned fail_count = 0; + std::vector<test_info>::iterator i = test_results.begin(); + std::vector<test_info>::iterator e = test_results.end(); + for (; i != e; ++i) + { + std::cout + << (i->passed ? "[passed]" : "[failed]") + << " " << i->value + << std::endl; + fail_count += i->passed ? 0 : 1; + } + std::cout + << std::endl + << "TOTAL: " + << "passed " << (test_results.size()-fail_count) << ", " + << "failed " << (fail_count) << ", " + << "of " << (test_results.size()) + << std::endl; + return fail_count; +} diff --git a/src/boost/libs/predef/test/platform_windows.cpp b/src/boost/libs/predef/test/platform_windows.cpp new file mode 100644 index 000000000..53f3ecc52 --- /dev/null +++ b/src/boost/libs/predef/test/platform_windows.cpp @@ -0,0 +1,177 @@ +/* +Copyright James E. King, III - 2017 +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) +*/ + +#include <boost/predef/platform.h> + +// +// This file is used to verify the BOOST_PLAT_WINDOWS_* logic. +// +// To exercise all of the combinations the CI build needs many +// jobs where it defines all the different possible WINAPI_FAMILY +// values on all supported platforms. +// + +// +// UWP is available on Windows SDK 8.0 or later, or on MinGW-w64 major release 3 or later +// +#if (defined(__MINGW64__) && (__MINGW64_VERSION_MAJOR >= 3)) || (BOOST_PLAT_WINDOWS_SDK_VERSION >= 9200) +#if !BOOST_PLAT_WINDOWS_UWP +#error "BOOST_PLAT_WINDOWS_UWP should be available" +#endif +#else +#if BOOST_PLAT_WINDOWS_UWP +#error "BOOST_PLAT_WINDOWS_UWP should not be available" +#endif +#endif + +#if !BOOST_PLAT_WINDOWS_UWP + +// +// If BOOST_PLAT_WINDOWS_UWP is not available, none of the other BOOST_PLAT_WINDOWS_* are either +// except for BOOST_PLAT_WINDOWS_DESKTOP which is available for backwards compatibility. +// + +#if BOOST_OS_WINDOWS && !BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should be available" +#endif +#if BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should not be available" +#endif +#if BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should not be available" +#endif + +#else // !BOOST_PLAT_WINDOWS_UWP + +// +// If BOOST_PLAT_WINDOWS_UWP is available, and the SDK supports a particular family, +// and if WINAPI_FAMILY is set to it, then it and only it should be available. +// + +#if !defined(WINAPI_FAMILY) +#error "windows_uwp.h should have included <winapifamily.h> which should have defined supported families" +#endif + +#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP +#if !BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should be available" +#endif +#if BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should not be available" +#endif +#if BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should not be available" +#endif +#endif + +#if defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should not be available" +#endif +#if !BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should be available" +#endif +#if !BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should be available" +#endif +#if BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should not be available" +#endif +#if BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should not be available" +#endif +#endif + +#if defined(WINAPI_FAMILY_SERVER_APP) && WINAPI_FAMILY == WINAPI_FAMILY_SERVER_APP +#if BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should not be available" +#endif +#if BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should not be available" +#endif +#if !BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should be available" +#endif +#if BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should not be available" +#endif +#endif + +// Store is WINAPI_FAMILY_APP in MinGW-w64 and in Windows SDK 8.0 +// then in Windows SDK 8.1 it was deprecated in favor of WINAPI_FAMILY_PC_APP + +#if ((defined(WINAPI_FAMILY_PC_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) || \ + (defined(WINAPI_FAMILY_APP) && WINAPI_FAMILY == WINAPI_FAMILY_APP)) +#if BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should not be available" +#endif +#if BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should not be available" +#endif +#if !BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should be available" +#endif +#if BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should not be available" +#endif +#if !BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should be available" +#endif +#if BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should not be available" +#endif +#endif + +#if defined(WINAPI_FAMILY_SYSTEM_APP) && WINAPI_FAMILY == WINAPI_FAMILY_SYSTEM_APP +#if BOOST_PLAT_WINDOWS_DESKTOP +#error "BOOST_PLAT_WINDOWS_DESKTOP should not be available" +#endif +#if BOOST_PLAT_WINDOWS_PHONE +#error "BOOST_PLAT_WINDOWS_PHONE should not be available" +#endif +#if BOOST_PLAT_WINDOWS_RUNTIME /* deprecated */ +#error "BOOST_PLAT_WINDOWS_RUNTIME should not be available" +#endif +#if BOOST_PLAT_WINDOWS_SERVER +#error "BOOST_PLAT_WINDOWS_SERVER should not be available" +#endif +#if BOOST_PLAT_WINDOWS_STORE +#error "BOOST_PLAT_WINDOWS_STORE should not be available" +#endif +#if !BOOST_PLAT_WINDOWS_SYSTEM +#error "BOOST_PLAT_WINDOWS_SYSTEM should be available" +#endif +#endif + +#endif // !BOOST_PLAT_WINDOWS_UWP diff --git a/src/boost/libs/predef/test/predef_info.h b/src/boost/libs/predef/test/predef_info.h new file mode 100644 index 000000000..213d94b47 --- /dev/null +++ b/src/boost/libs/predef/test/predef_info.h @@ -0,0 +1,46 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include <boost/predef/detail/test_def.h> + +int main() +{ + unsigned x = 0; + create_predef_entries(); + qsort(generated_predef_info,generated_predef_info_count, + sizeof(predef_info),predef_info_compare); + /* + for (x = 0; x < generated_predef_info_count; ++x) + { + printf("%s: %d\n", generated_predef_info[x].name, generated_predef_info[x].value); + } + */ + puts("** Detected **"); + for (x = 0; x < generated_predef_info_count; ++x) + { + if (generated_predef_info[x].value > 0) + printf("%s = %u (%u,%u,%u) | %s\n", + generated_predef_info[x].name, + generated_predef_info[x].value, + (generated_predef_info[x].value/10000000)%100, + (generated_predef_info[x].value/100000)%100, + (generated_predef_info[x].value)%100000, + generated_predef_info[x].description); + } + puts("** Not Detected **"); + for (x = 0; x < generated_predef_info_count; ++x) + { + if (generated_predef_info[x].value == 0) + printf("%s = %u | %s\n", + generated_predef_info[x].name, + generated_predef_info[x].value, + generated_predef_info[x].description); + } + if (generated_predef_info_count > 0) + return 0; + else + return 1; +} diff --git a/src/boost/libs/predef/test/test_cmake/CMakeLists.txt b/src/boost/libs/predef/test/test_cmake/CMakeLists.txt new file mode 100644 index 000000000..9bdbd62d8 --- /dev/null +++ b/src/boost/libs/predef/test/test_cmake/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright Mike Dev 2018 +# Copyright Rene Rivera 2018 +# 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 + +# NOTE: +# This does NOT run the unit tests for Boost.Predef. +# It only tests, if the CMakeLists.txt file in predef's +# root directory works as expected (i.e. it provides the +# target Boost::predef which in turn provides the +# correct include directory ) + +# We have very simple cmake requirements we we still require the new style +# declarative targets. +cmake_minimum_required( VERSION 3.0 ) + +project( PredefCMakeSelfTest ) + +# Process cmake file at root of library and use +# ${CMAKE_CURRENT_BINARY_DIR}/libs/predef as workspace +add_subdirectory( ../.. ${CMAKE_CURRENT_BINARY_DIR}/libs/predef ) + +# The executable just includes a predef header to verify that it's used. +add_executable( predef_cmake_test_prj main.cpp ) + +# The executable needs to "use" the Predef "library" to get the usage +# requirements added to the executable build. +target_link_libraries( predef_cmake_test_prj Boost::predef ) diff --git a/src/boost/libs/predef/test/test_cmake/main.cpp b/src/boost/libs/predef/test/test_cmake/main.cpp new file mode 100644 index 000000000..c8005bc4a --- /dev/null +++ b/src/boost/libs/predef/test/test_cmake/main.cpp @@ -0,0 +1,19 @@ +/* +Copyright Mike Dev 2018 +Copyright 2018 Rene Rivera +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 +*/ + +/* +Dummy executable, just to make sure that we can find the Boost Predef header +files. +*/ + +#include <boost/predef.h> + +int main() +{ + return 0; +} diff --git a/src/boost/libs/predef/test/tested_at.cpp b/src/boost/libs/predef/test/tested_at.cpp new file mode 100644 index 000000000..2c4816eb5 --- /dev/null +++ b/src/boost/libs/predef/test/tested_at.cpp @@ -0,0 +1,62 @@ +/* +Copyright Rene Rivera 2011-2017 +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) +*/ +#include <boost/predef/version_number.h> +#include <boost/predef/other/workaround.h> +#include <exception> +#include <vector> +#include <string> +#include <iostream> + +namespace +{ + struct test_info + { + std::string value; + bool passed; + + test_info(std::string const & v, bool p) : value(v), passed(p) {} + test_info(test_info const & o) : value(o.value), passed(o.passed) {} + }; + + std::vector<test_info> test_results; +} + +#define PREDEF_CHECK(X) test_results.push_back(test_info(#X,(X))) + +void test_BOOST_PREDEF_TESTED_AT() +{ + PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(15,15,15),0xF,0xF,0xF)); + PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(1,0,0),1,0,0)); + PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(0,9,0),1,0,0)); + PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(2,0,0),1,0,0)); + PREDEF_CHECK(!BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER_NOT_AVAILABLE,1,0,0)); +} + +int main() +{ + test_BOOST_PREDEF_TESTED_AT(); + + unsigned fail_count = 0; + std::vector<test_info>::iterator i = test_results.begin(); + std::vector<test_info>::iterator e = test_results.end(); + for (; i != e; ++i) + { + std::cout + << (i->passed ? "[passed]" : "[failed]") + << " " << i->value + << std::endl; + fail_count += i->passed ? 0 : 1; + } + std::cout + << std::endl + << "TOTAL: " + << "passed " << (test_results.size()-fail_count) << ", " + << "failed " << (fail_count) << ", " + << "of " << (test_results.size()) + << std::endl; + return fail_count; +} diff --git a/src/boost/libs/predef/test/tested_at_outdated.cpp b/src/boost/libs/predef/test/tested_at_outdated.cpp new file mode 100644 index 000000000..534ebafe7 --- /dev/null +++ b/src/boost/libs/predef/test/tested_at_outdated.cpp @@ -0,0 +1,18 @@ +/* +Copyright Rene Rivera 2011-2017 +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) +*/ +#include <boost/predef/version_number.h> +#define BOOST_DETECT_OUTDATED_WORKAROUNDS +#include <boost/predef/other/workaround.h> + +int main() +{ +#if BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(2,0,0),1,0,0) + return 1; +#else + return 0; +#endif +} diff --git a/src/boost/libs/predef/test/version.cpp b/src/boost/libs/predef/test/version.cpp new file mode 100644 index 000000000..68e724fb2 --- /dev/null +++ b/src/boost/libs/predef/test/version.cpp @@ -0,0 +1,83 @@ +/* +Copyright Rene Rivera 2011-2012 +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) +*/ +#include <boost/predef/version_number.h> +#include <exception> +#include <vector> +#include <string> +#include <iostream> + +namespace +{ + struct test_info + { + std::string value; + bool passed; + + test_info(std::string const & v, bool p) : value(v), passed(p) {} + test_info(test_info const & o) : value(o.value), passed(o.passed) {} + }; + + std::vector<test_info> test_results; +} + +#define PREDEF_CHECK(X) test_results.push_back(test_info(#X,(X))) + +void test_BOOST_VERSION_NUMBER() +{ + PREDEF_CHECK(BOOST_VERSION_NUMBER(0,0,1) == 1L); + PREDEF_CHECK(BOOST_VERSION_NUMBER(99,99,99999) == 999999999L); + PREDEF_CHECK(BOOST_VERSION_NUMBER(299UL,99UL,99999UL) != 2999999999UL); + PREDEF_CHECK(BOOST_VERSION_NUMBER(100,99,99999) != 1009999999L); + PREDEF_CHECK(BOOST_VERSION_NUMBER(100,99,99999) == 9999999L); + PREDEF_CHECK(BOOST_VERSION_NUMBER(100,100,100000) == 0L); + + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MAJOR(BOOST_VERSION_NUMBER(0,0,0)) == 0); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MAJOR(BOOST_VERSION_NUMBER(3,3,3)) == 3); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MAJOR(BOOST_VERSION_NUMBER(99,99,99999)) == 99); + + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MINOR(BOOST_VERSION_NUMBER(0,0,0)) == 0); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MINOR(BOOST_VERSION_NUMBER(3,3,3)) == 3); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_MINOR(BOOST_VERSION_NUMBER(99,99,99999)) == 99); + + PREDEF_CHECK( + BOOST_VERSION_NUMBER_PATCH(BOOST_VERSION_NUMBER(0,0,0)) == 0); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_PATCH(BOOST_VERSION_NUMBER(3,3,3)) == 3); + PREDEF_CHECK( + BOOST_VERSION_NUMBER_PATCH(BOOST_VERSION_NUMBER(99,99,99999)) == 99999); +} + +int main() +{ + test_BOOST_VERSION_NUMBER(); + + unsigned fail_count = 0; + std::vector<test_info>::iterator i = test_results.begin(); + std::vector<test_info>::iterator e = test_results.end(); + for (; i != e; ++i) + { + std::cout + << (i->passed ? "[passed]" : "[failed]") + << " " << i->value + << std::endl; + fail_count += i->passed ? 0 : 1; + } + std::cout + << std::endl + << "TOTAL: " + << "passed " << (test_results.size()-fail_count) << ", " + << "failed " << (fail_count) << ", " + << "of " << (test_results.size()) + << std::endl; + return fail_count; +} diff --git a/src/boost/libs/predef/test/workaround.cpp b/src/boost/libs/predef/test/workaround.cpp new file mode 100644 index 000000000..368daea3a --- /dev/null +++ b/src/boost/libs/predef/test/workaround.cpp @@ -0,0 +1,62 @@ +/* +Copyright Rene Rivera 2011-2017 +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) +*/ +#include <boost/predef/version_number.h> +#include <boost/predef/other/workaround.h> +#include <exception> +#include <vector> +#include <string> +#include <iostream> + +namespace +{ + struct test_info + { + std::string value; + bool passed; + + test_info(std::string const & v, bool p) : value(v), passed(p) {} + test_info(test_info const & o) : value(o.value), passed(o.passed) {} + }; + + std::vector<test_info> test_results; +} + +#define PREDEF_CHECK(X) test_results.push_back(test_info(#X,(X))) + +void test_BOOST_PREDEF_WORKAROUND() +{ + PREDEF_CHECK(BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER(15,15,15),==,0xF,0xF,0xF)); + PREDEF_CHECK(BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER(0,9,0),<,1,0,0)); + PREDEF_CHECK(BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER(0,9,0),!=,1,0,0)); + PREDEF_CHECK(BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER_MIN,<,1,0,0)); + PREDEF_CHECK(BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER_MIN,>,0,0,0)); +} + +int main() +{ + test_BOOST_PREDEF_WORKAROUND(); + + unsigned fail_count = 0; + std::vector<test_info>::iterator i = test_results.begin(); + std::vector<test_info>::iterator e = test_results.end(); + for (; i != e; ++i) + { + std::cout + << (i->passed ? "[passed]" : "[failed]") + << " " << i->value + << std::endl; + fail_count += i->passed ? 0 : 1; + } + std::cout + << std::endl + << "TOTAL: " + << "passed " << (test_results.size()-fail_count) << ", " + << "failed " << (fail_count) << ", " + << "of " << (test_results.size()) + << std::endl; + return fail_count; +} diff --git a/src/boost/libs/predef/test/workaround_strict_config.cpp b/src/boost/libs/predef/test/workaround_strict_config.cpp new file mode 100644 index 000000000..df7b1764b --- /dev/null +++ b/src/boost/libs/predef/test/workaround_strict_config.cpp @@ -0,0 +1,17 @@ +/* +Copyright Rene Rivera 2011-2017 +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) +*/ +#include <boost/predef/version_number.h> +#define BOOST_STRICT_CONFIG +#include <boost/predef/other/workaround.h> + +int main() +{ +#if BOOST_PREDEF_WORKAROUND(BOOST_VERSION_NUMBER_AVAILABLE,==,0,0,1) + fail(); +#endif + return 0; +} diff --git a/src/boost/libs/predef/tools/check/build.jam b/src/boost/libs/predef/tools/check/build.jam new file mode 100644 index 000000000..1ce4f11e9 --- /dev/null +++ b/src/boost/libs/predef/tools/check/build.jam @@ -0,0 +1,9 @@ +# Copyright Rene Rivera 2015 +# 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) + +exe predef_check_as_c : predef_check_as_c.c : <include>../include ; +exe predef_check_as_cpp : predef_check_as_cpp.cpp : <include>../include ; +exe predef_check_as_objc : predef_check_as_objc.m : <include>../include ; +exe predef_check_as_objcpp : predef_check_as_objcpp.mm : <include>../include ; diff --git a/src/boost/libs/predef/tools/check/predef.jam b/src/boost/libs/predef/tools/check/predef.jam new file mode 100644 index 000000000..dd18bfb06 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef.jam @@ -0,0 +1,202 @@ +# Copyright Rene Rivera 2015 +# 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) + +# Defines rules that provide requirements based on checking +# conditions using Boost Predef definitions and version numbers. + +import modules ; +import project ; +import feature ; +import string ; +import toolset ; +import modules ; +import path ; +import "class" : new ; +import regex ; + +# Create a project for our targets. +project.extension predef check ; + +# Feature to pass check expressions to check programs. +feature.feature predef-expression : : free ; + +# Checks the expressions and when used evaluates to the true-properties +# if the expressions are all true. Otherwise evaluates to the +# false-properties. +rule check ( expressions + : language ? : true-properties * : false-properties * ) +{ + # Default to C++ on the check context. + language ?= cpp ; + + local project_target = [ project.target $(__name__) ] ; + project.push-current $(project_target) ; + local terms ; + local result ; + for expression in $(expressions) + { + if $(expression:L) in "and" "or" + { + terms += $(expression:L) ; + } + else + { + # Create the check run if we don't have one yet. + local key = [ MD5 "$(language)::$(expression)" ] ; + if ! ( $(key) in $(_checks_) ) + { + _checks_ += $(key) ; + _message_(/check/predef//predef_check_cc_$(key)) = $(expression) ; + check_target $(language) $(key) : [ change_term_to_def $(expression) ] ; + } + + terms += /check/predef//predef_check_cc_$(key) ; + } + } + local instance = [ new check-expression-evaluator + $(terms) : $(true-properties) : $(false-properties) ] ; + result = <conditional>@$(instance).check ; + project.pop-current ; + return $(result) ; +} + +# Checks the expressions and when used evaluates to <build>no +# if the expressions are all false. Otherwise evaluates to the +# nothing. +rule require ( expressions + : language ? ) +{ + return [ check $(expressions) : $(language) : : <build>no ] ; +} + +############################################################################# + +.c.ext = c ; +.cpp.ext = cpp ; +.objc.ext = m ; +.objcpp.ext = mm ; + +# Check targets. Each needs to be compiled for different languages +# even though they are all the same source code. +local rule check_target ( language key : requirements * ) +{ + # Need to use absolute paths because we don't know the + # context of the invocation which affects where the paths + # originate from. + local predef_jam + = [ modules.binding $(__name__) ] ; + local source_path + = $(predef_jam:D)/predef_check_cc_as_$(language).$(.$(language).ext) ; + local include_path + = $(predef_jam:D)/../../include $(BOOST_ROOT) ; + obj predef_check_cc_$(key) + : $(source_path) + : <include>$(include_path) $(requirements) ; + explicit predef_check_cc_$(key) ; + return predef_check_cc_$(key) ; +} + +local rule change_term_to_def ( term ) +{ + local parts = [ regex.split $(term) " " ] ; + if $(parts[3]) + { + local version_number = [ regex.split $(parts[3]) "[.]" ] ; + if ! $(version_number[2]) { version_number += "0" ; } + if ! $(version_number[3]) { version_number += "0" ; } + parts = $(parts[1-2]) BOOST_VERSION_NUMBER($(version_number:J=",")) ; + } + return <define>CHECK=\"$(parts:J=" ")\" ; +} + +class check-expression-evaluator +{ + import configure ; + + rule __init__ ( expression + : true-properties * : false-properties * ) + { + self.expression = $(expression) ; + self.true-properties = $(true-properties) ; + self.false-properties = $(false-properties) ; + } + + rule check ( properties * ) + { + local to-eval ; + local tokens = "and" "or" ; + # Go through the expression and: eval the target values, + # and normalize to a full expression. + for local term in $(self.expression) + { + if ! ( $(term:L) in $(tokens) ) + { + # A value is a target reference that will evan to "true" + # or "false". + if $(to-eval[-1]:L) && ! ( $(to-eval[-1]:L) in $(tokens) ) + { + # Default to "and" operation. + to-eval += "and" ; + } + local message = [ modules.peek predef : _message_($(term)) ] ; + if [ configure.builds $(term) : $(properties) : $(message) ] + { + to-eval += "true" ; + } + else + { + to-eval += "false" ; + } + } + else + { + to-eval += $(term) ; + } + } + # Eval full the expression. + local eval-result = [ eval $(to-eval) ] ; + # And resolve true/false properties. + if $(eval-result) = "true" + { + return $(self.true-properties) ; + } + else + { + return $(self.false-properties) ; + } + } + + rule eval ( e * ) + { + local r ; + if $(e[1]) && $(e[2]) && $(e[3]) + { + if $(e[2]) = "and" + { + if $(e[1]) = "true" && $(e[3]) = "true" + { + r = [ eval "true" $(e[4-]) ] ; + } + else + { + r = [ eval "false" $(e[4-]) ] ; + } + } + else if $(e[2]) = "or" + { + if $(e[1]) = "true" || $(e[3]) = "true" + { + r = [ eval "true" $(e[4-]) ] ; + } + else + { + r = [ eval "false" $(e[4-]) ] ; + } + } + } + else + { + r = $(e[1]) ; + } + return $(r) ; + } +} diff --git a/src/boost/libs/predef/tools/check/predef_check.h b/src/boost/libs/predef/tools/check/predef_check.h new file mode 100644 index 000000000..a6917c173 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check.h @@ -0,0 +1,98 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include <boost/predef/detail/test_def.h> + +const char * str_token(const char ** str, const char * space) +{ + unsigned span; + char * token; + for (; **str != 0; *str += 1) + { + if (0 == strchr(space, **str)) + { + break; + } + } + span = strcspn(*str, space); + token = (char *)malloc(span+1); + strncpy(token, *str, span); + token[span] = 0; + for (*str += span; **str != 0; *str += 1) + { + if (0 == strchr(space, **str)) + { + break; + } + } + return token; +} + +const char * whitespace = " "; +const char * dot = "."; + +int main(int argc, const char ** argv) +{ + unsigned x = 0; + int argi = 1; + create_predef_entries(); +#if 0 + qsort(generated_predef_info,generated_predef_info_count, + sizeof(predef_info),predef_info_compare); + for (x = 0; x < generated_predef_info_count; ++x) + { + printf("%s: %d\n", generated_predef_info[x].name, generated_predef_info[x].value); + } +#endif + int result = -1; + for (argi = 1; argi < argc; ++argi) + { + const char * exp = argv[argi]; + const char * exp_name = str_token(&exp, whitespace); + const char * exp_op = str_token(&exp, whitespace); + const char * exp_val = str_token(&exp, whitespace); + unsigned exp_version = 0; + if (*exp_val != 0) + { + exp = exp_val; + const char * exp_val_a = str_token(&exp, dot); + const char * exp_val_b = str_token(&exp, dot); + const char * exp_val_c = str_token(&exp, dot); + exp_version = BOOST_VERSION_NUMBER(atoi(exp_val_a), atoi(exp_val_b),atoi(exp_val_c)); + } + for (x = 0; x < generated_predef_info_count; ++x) + { + if (*exp_op == 0 && + generated_predef_info[x].value > 0 && + strcmp(exp_name, generated_predef_info[x].name) == 0) + { + /* Expression of the form "BOOST_x_yy" is true. */ + result = 0; + break; + } + else if (*exp_op == 0 && + generated_predef_info[x].value == 0 && + strcmp(exp_name, generated_predef_info[x].name) == 0) + { + /* Expression of the form "BOOST_x_yy" is false. */ + return argi; + } + else if (*exp_op != 0 && *exp_val != 0 && + strcmp(exp_name, generated_predef_info[x].name) == 0) + { + /* Expression of the form "BOOST_x_yy op val". */ + result = 0; + if (0 == strcmp(">",exp_op) && !(generated_predef_info[x].value > exp_version)) return argi; + if (0 == strcmp("<",exp_op) && !(generated_predef_info[x].value < exp_version)) return argi; + if (0 == strcmp(">=",exp_op) && !(generated_predef_info[x].value >= exp_version)) return argi; + if (0 == strcmp("<=",exp_op) && !(generated_predef_info[x].value <= exp_version)) return argi; + if (0 == strcmp("==",exp_op) && !(generated_predef_info[x].value == exp_version)) return argi; + if (0 == strcmp("!=",exp_op) && !(generated_predef_info[x].value != exp_version)) return argi; + } + } + } + return result; +} diff --git a/src/boost/libs/predef/tools/check/predef_check_as_c.c b/src/boost/libs/predef/tools/check/predef_check_as_c.c new file mode 100644 index 000000000..352c18ba9 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_as_c.c @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_check.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_as_cpp.cpp b/src/boost/libs/predef/tools/check/predef_check_as_cpp.cpp new file mode 100644 index 000000000..352c18ba9 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_as_cpp.cpp @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_check.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_as_objc.m b/src/boost/libs/predef/tools/check/predef_check_as_objc.m new file mode 100644 index 000000000..352c18ba9 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_as_objc.m @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_check.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_as_objcpp.mm b/src/boost/libs/predef/tools/check/predef_check_as_objcpp.mm new file mode 100644 index 000000000..352c18ba9 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_as_objcpp.mm @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2011-2015 +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) +*/ +#include "predef_check.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_cc.h b/src/boost/libs/predef/tools/check/predef_check_cc.h new file mode 100644 index 000000000..da7609ec4 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_cc.h @@ -0,0 +1,19 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ +#include <boost/predef.h> + +#ifdef CHECK +# if ((CHECK) == 0) +# error "FAILED" +# endif +#endif + +int dummy() +{ + static int d = 0; + return d++; +} diff --git a/src/boost/libs/predef/tools/check/predef_check_cc_as_c.c b/src/boost/libs/predef/tools/check/predef_check_cc_as_c.c new file mode 100644 index 000000000..24fab13e3 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_cc_as_c.c @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ +#include "predef_check_cc.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_cc_as_cpp.cpp b/src/boost/libs/predef/tools/check/predef_check_cc_as_cpp.cpp new file mode 100644 index 000000000..24fab13e3 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_cc_as_cpp.cpp @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ +#include "predef_check_cc.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_cc_as_objc.m b/src/boost/libs/predef/tools/check/predef_check_cc_as_objc.m new file mode 100644 index 000000000..24fab13e3 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_cc_as_objc.m @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ +#include "predef_check_cc.h" diff --git a/src/boost/libs/predef/tools/check/predef_check_cc_as_objcpp.mm b/src/boost/libs/predef/tools/check/predef_check_cc_as_objcpp.mm new file mode 100644 index 000000000..24fab13e3 --- /dev/null +++ b/src/boost/libs/predef/tools/check/predef_check_cc_as_objcpp.mm @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +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) +*/ +#include "predef_check_cc.h" |