diff --git a/check/build.jam b/check/build.jam new file mode 100644 index 0000000..1ce4f11 --- /dev/null +++ b/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 ; +exe predef_check_as_cpp : predef_check_as_cpp.cpp : ../include ; +exe predef_check_as_objc : predef_check_as_objc.m : ../include ; +exe predef_check_as_objcpp : predef_check_as_objcpp.mm : ../include ; diff --git a/check/predef.jam b/check/predef.jam new file mode 100644 index 0000000..0638703 --- /dev/null +++ b/check/predef.jam @@ -0,0 +1,106 @@ +# 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 ; + +# Create a project for our targets. +project.extension predef check ; + +# Feature to pass check expressions to check programs. +feature.feature predef-expression : : free ; + +# Check programs. Each needs to be compiled for different languages +# even though they are all the same source code. +local rule check_target ( language : ext ) +{ + # 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_as_$(language).$(ext) ; + local include_path + = $(predef_jam:D)/../include ; + _check_exe_($(language)) = [ + exe predef_check_as_$(language) + : $(source_path) + : $(include_path) ] ; + explicit predef_check_as_$(language) ; +} +check_target c : c ; +check_target cpp : cpp ; +check_target objc : m ; +check_target objcpp : mm ; + +# 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 result ; + for expression in $(expressions) + { + # The check program to use. + local exe_target = [ $(_check_exe_($(language))).name ] ; + exe_target = /check/predef//$(exe_target) ; + + # Create the check run if we don't have one yet. + local key = [ MD5 $(language)::$(expression) ] ; + if ! ( $(key) in $(_checks_) ) + { + _checks_ += $(key) ; + make + $(key).txt : + $(exe_target) : + @$(__name__).predef_check_action : + $(expression) ; + explicit + $(key).txt ; + } + + local check_target = [ check-target-builds + /check/predef//$(key).txt $(expression) + : $(true-properties) + : $(false-properties) ] ; + + result += $(check_target) ; + } + project.pop-current ; + return $(result) ; +} + +# Checks the expressions and when used evaluates to no +# if the expressions are all false. Otherwise evaluates to the +# nothing. +rule require ( expressions + : language ? ) +{ + return [ check $(expressions) : $(language) : : no ] ; +} + +rule predef_check_action ( targets + : sources + : props * ) +{ + PREDEF_CHECK_EXPRESSION on $(targets) + = [ feature.get-values : $(props) ] ; +} + +actions predef_check_action bind PREDEF_CHECK_EXPRESSION +{ + $(>) "$(PREDEF_CHECK_EXPRESSION)" > $(<) +} diff --git a/check/predef_check_as_c.c b/check/predef_check_as_c.c new file mode 100644 index 0000000..dcb7d6a --- /dev/null +++ b/check/predef_check_as_c.c @@ -0,0 +1,119 @@ +/* +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 +#include +#include + +#define BOOST_PREDEF_INTERNAL_GENERATE_TESTS + +typedef struct predef_info +{ + unsigned tag; + const char * name; + const char * description; + unsigned value; +} predef_info; + +predef_info first_predef_info = { 0x43210DEF , "-" , "-" , 0xFFFFFFFF }; + +#define BOOST_PREDEF_DECLARE_TEST(x,s) \ + predef_info x##_predef_info = { 0x67890DEF , #x , s , x }; +#include + +predef_info last_predef_info = { 0xFFFFFFFF , "-" , "-" , 0x43210DEF }; + +int predef_info_compare(const void * a, const void * b) +{ + const predef_info ** i = (const predef_info **)a; + const predef_info ** j = (const predef_info **)b; + return strcmp((*i)->name,(*j)->name); +} + +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; + predef_info ** predefs = 0; + unsigned predef_count = 0; + unsigned * i = &first_predef_info.tag; + unsigned * e = &last_predef_info.tag; + while (i < e) + { + i += 1; + if (*i == 0x67890DEF) + { + predef_count += 1; + predefs = (predef_info**)realloc(predefs,predef_count*sizeof(predef_info*)); + predefs[predef_count-1] = (predef_info*)i; + } + } + qsort(predefs,predef_count,sizeof(predef_info*),predef_info_compare); + 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 < predef_count; ++x) + { + if (*exp_op == 0 && + predefs[x]->value == 0 && + strcmp(exp_name, predefs[x]->name) == 0) + { + return argi; + } + else if (*exp_op != 0 && *exp_val != 0 && + strcmp(exp_name, predefs[x]->name) == 0) + { + if (0 == strcmp(">",exp_op) && !(predefs[x]->value > exp_version)) return argi; + if (0 == strcmp("<",exp_op) && !(predefs[x]->value < exp_version)) return argi; + if (0 == strcmp(">=",exp_op) && !(predefs[x]->value >= exp_version)) return argi; + if (0 == strcmp("<=",exp_op) && !(predefs[x]->value <= exp_version)) return argi; + if (0 == strcmp("==",exp_op) && !(predefs[x]->value == exp_version)) return argi; + if (0 == strcmp("!=",exp_op) && !(predefs[x]->value != exp_version)) return argi; + } + } + } + return 0; +} diff --git a/check/predef_check_as_cpp.cpp b/check/predef_check_as_cpp.cpp new file mode 100644 index 0000000..c58abe7 --- /dev/null +++ b/check/predef_check_as_cpp.cpp @@ -0,0 +1 @@ +#include "predef_check_as_c.c" diff --git a/check/predef_check_as_objc.m b/check/predef_check_as_objc.m new file mode 100644 index 0000000..c58abe7 --- /dev/null +++ b/check/predef_check_as_objc.m @@ -0,0 +1 @@ +#include "predef_check_as_c.c" diff --git a/check/predef_check_as_objcpp.mm b/check/predef_check_as_objcpp.mm new file mode 100644 index 0000000..c58abe7 --- /dev/null +++ b/check/predef_check_as_objcpp.mm @@ -0,0 +1 @@ +#include "predef_check_as_c.c" diff --git a/doc/history.qbk b/doc/history.qbk index b2fb81e..5df5bf1 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -1,5 +1,5 @@ [/ -Copyright 2014 Rene Rivera +Copyright 2014-2015 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) @@ -7,12 +7,22 @@ http://www.boost.org/LICENSE_1_0.txt) [section History] +[heading 1.2] + +* Account for skip in Visual Studio product version vs. compiler version. + This supports version of VS 2015 an onward. +* Add detection of Haiku OS (from Jessica Hamilton). +* Some fixes to endian detection for Android (from mstahl-at-redhat.com). +* Add missing `BOOST_PREDEF_MAKE_0X_VVRRPP` macro (from Erik Lindahl). +* Add `predef_check` program and BBv2 integration for build configuration + checks. + [heading 1.1] * Addition of `BOOST_PLAT_*` platform definitions for MinGW and Windows platform variants. * Detection of ARM architecture for Windows compilers to target - mobile devices of WIndows 8. + mobile devices of Windows 8. * Improved ARM detection for 64 bit ARM. * Added detection of iOS an an operating system. * Improved detection of endianess on some platforms. diff --git a/doc/html/index.html b/doc/html/index.html index 024453d..8a4dde7 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -1,10 +1,10 @@ -Predef 1.1 +Predef 1.2 - + @@ -13,7 +13,7 @@

-Predef 1.1

+Predef 1.2

Rene Rivera

@@ -45,6 +45,7 @@
Version definition macros
+
Check Utilities
History
To Do
Acknoledgements
@@ -52,7 +53,7 @@
- +

Last revised: June 04, 2014 at 03:28:01 GMT

Last revised: January 29, 2015 at 21:39:36 GMT


diff --git a/doc/html/predef/acknoledgements.html b/doc/html/predef/acknoledgements.html index 7573714..9f73605 100644 --- a/doc/html/predef/acknoledgements.html +++ b/doc/html/predef/acknoledgements.html @@ -4,8 +4,8 @@ Acknoledgements - - + + diff --git a/doc/html/predef/adding_new_predefs.html b/doc/html/predef/adding_new_predefs.html index 091b7b7..37f49d4 100644 --- a/doc/html/predef/adding_new_predefs.html +++ b/doc/html/predef/adding_new_predefs.html @@ -4,8 +4,8 @@ Adding new predefs - - + + diff --git a/doc/html/predef/check_utilities.html b/doc/html/predef/check_utilities.html new file mode 100644 index 0000000..1664b19 --- /dev/null +++ b/doc/html/predef/check_utilities.html @@ -0,0 +1,148 @@ + + + +Check Utilities + + + + + + + + +
+PrevUpHomeNext +
+
+ +

+ The predef_check utility provides + a facility for building a program that will check a given set of expressions + against the definitions it detected when it was built. +

+

+ + predef_check + programs +

+

+ Even though there is only one predef_check + program, there are variations for each of the languages that are detected by + Predef to match the convention for sources files. For all of them one invokes + with a list of expression arguments. The expressions are evaluated within the + context of the particular predef_check program and if they + all are true zero (0) is returned. Otherwise the index of the first false expression + is returned. +

+

+ The expression syntax is simple: +

+
predef-definition [ relational-operator version-value ]
+
+

+ predef-definition can be any of the Predef definitions. + For example BOOST_COMP_GCC. +

+

+ relational-operator can be any of: >, + <, >=, <=, + == and !=. +

+

+ version-number can be a full or partial version + triplet value. If it's a partial version triple it is completed with zeros. + That is x.y is equivalent to x.y.0 and + x is equivalent to x.0.0. +

+

+ The relations-operator and version-number + can be ommited. In which case it is equivalent to: +

+
predef-definition > 0.0.0
+
+

+ + Using + with Boost.Build +

+

+ You can use the predef_check programs directly from Boost + Build to configure target requirements. This is useful for controlling what + gets built as part of your project based on the detailed version information + available in Predef. The basic use is simple: +

+
import path-to-predef-src/check/predef
+    : check require
+    : predef-check predef-require ;
+
+exe my_windows_program : windows_source.cpp
+    : [ predef-require "BOOST_OS_WINDOWS" ] ;
+
+

+ That simple use case will skip building the my_windows_program + unless one is building for Windows. Like the direct predef_check + you can pass mutiple expressions using relational comparisons. For example: +

+
import path-to-predef-src/check/predef
+    : check require
+    : predef-check predef-require ;
+
+lib my_special_lib : source.cpp
+    : [ predef-require "BOOST_OS_WINDOWS != 0" "BOOST_OS_VMS != 0"] ;
+
+

+ And in that case the my_special_lib is built only when the + OS is not Windows or VMS. The requires rule is a special + case of the check rule. And is defined in terms of it: +

+
rule require ( expressions + : language ? )
+{
+    return [ check $(expressions) : $(language) : : <build>no ] ;
+}
+
+

+ You can use the check rule for more control and to implement + something other than control of what gets built. The definition for the check + rule is: +

+
rule check ( expressions + : language ? : true-properties * : false-properties * )
+
+

+ When invoked as a reuirement of a Boost Build target this rule will add the + true-properties to the target if all the expressions + evaluate to true. Otherwise the false-properties get added + as requirements. For example you could use it to enable or disable features + in your programs: +

+
import path-to-predef-src/check/predef
+    : check require
+    : predef-check predef-require ;
+
+exe my_special_exe : source.cpp
+    : [ predef-check "BOOST_OS_WINDOWS == 0"
+        : <define>ENABLE_WMF=0
+        : <define>ENABLE_WMF=1 ] ;
+
+

+ For both check and require the language + argument controls which variant of the predef_check program + is used to check the expressions. It defaults to "c++", but can be + any of: "c", "cpp", "objc", and "objcpp". +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/predef/history.html b/doc/html/predef/history.html index 9d9a2ef..883817d 100644 --- a/doc/html/predef/history.html +++ b/doc/html/predef/history.html @@ -4,14 +4,14 @@ History - - - + + +
-PrevUpHomeNext +PrevUpHomeNext

@@ -19,6 +19,30 @@

+ 1.2 +

+
    +
  • + Account for skip in Visual Studio product version vs. compiler version. + This supports version of VS 2015 an onward. +
  • +
  • + Add detection of Haiku OS (from Jessica Hamilton). +
  • +
  • + Some fixes to endian detection for Android (from mstahl-at-redhat.com). +
  • +
  • + Add missing BOOST_PREDEF_MAKE_0X_VVRRPP + macro (from Erik Lindahl). +
  • +
  • + Add predef_check program + and BBv2 integration for build configuration checks. +
  • +
+

+ 1.1

    @@ -28,7 +52,7 @@
  • Detection of ARM architecture for Windows compilers to target mobile devices - of WIndows 8. + of Windows 8.
  • Improved ARM detection for 64 bit ARM. @@ -68,7 +92,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/predef/introduction.html b/doc/html/predef/introduction.html index 66d3992..ef085b0 100644 --- a/doc/html/predef/introduction.html +++ b/doc/html/predef/introduction.html @@ -4,9 +4,9 @@ Introduction - - - + + + diff --git a/doc/html/predef/reference.html b/doc/html/predef/reference.html index c526fc5..9414b8f 100644 --- a/doc/html/predef/reference.html +++ b/doc/html/predef/reference.html @@ -4,8 +4,8 @@ Reference - - + + diff --git a/doc/html/predef/reference/boost_arch_architecture_macros.html b/doc/html/predef/reference/boost_arch_architecture_macros.html index c790a49..bd15aca 100644 --- a/doc/html/predef/reference/boost_arch_architecture_macros.html +++ b/doc/html/predef/reference/boost_arch_architecture_macros.html @@ -4,7 +4,7 @@ BOOST_ARCH architecture macros - + diff --git a/doc/html/predef/reference/boost_comp_compiler_macros.html b/doc/html/predef/reference/boost_comp_compiler_macros.html index ff59038..3376fd0 100644 --- a/doc/html/predef/reference/boost_comp_compiler_macros.html +++ b/doc/html/predef/reference/boost_comp_compiler_macros.html @@ -4,7 +4,7 @@ BOOST_COMP compiler macros - + diff --git a/doc/html/predef/reference/boost_lang_language_standards_ma.html b/doc/html/predef/reference/boost_lang_language_standards_ma.html index de69405..7623fc4 100644 --- a/doc/html/predef/reference/boost_lang_language_standards_ma.html +++ b/doc/html/predef/reference/boost_lang_language_standards_ma.html @@ -4,7 +4,7 @@ BOOST_LANG language standards macros - + diff --git a/doc/html/predef/reference/boost_lib_library_macros.html b/doc/html/predef/reference/boost_lib_library_macros.html index 7aecdd8..6e9a5ff 100644 --- a/doc/html/predef/reference/boost_lib_library_macros.html +++ b/doc/html/predef/reference/boost_lib_library_macros.html @@ -4,7 +4,7 @@ BOOST_LIB library macros - + diff --git a/doc/html/predef/reference/boost_os_operating_system_macros.html b/doc/html/predef/reference/boost_os_operating_system_macros.html index efb9400..ca12588 100644 --- a/doc/html/predef/reference/boost_os_operating_system_macros.html +++ b/doc/html/predef/reference/boost_os_operating_system_macros.html @@ -4,7 +4,7 @@ BOOST_OS operating system macros - + @@ -417,6 +417,44 @@
+ BOOST_OS_HAIKU +
+

+ Haiku + operating system. +

+
++++ + + + + + + + + +
+

+ Symbol +

+
+

+ Version +

+
+

+ __HAIKU__ +

+
+

+ detection +

+
+
+ BOOST_OS_HPUX

@@ -479,7 +517,7 @@

- + BOOST_OS_IOS

@@ -554,7 +592,7 @@

- + BOOST_OS_IRIX

@@ -605,7 +643,7 @@

- + BOOST_OS_LINUX

@@ -656,7 +694,7 @@

- + BOOST_OS_MACOS

@@ -756,7 +794,7 @@

- + BOOST_OS_OS400

@@ -794,7 +832,7 @@

- + BOOST_OS_QNX

@@ -871,7 +909,7 @@

- + BOOST_OS_SOLARIS

@@ -923,7 +961,7 @@

- + BOOST_OS_UNIX

@@ -999,7 +1037,7 @@

- + BOOST_OS_SVR4

@@ -1075,7 +1113,7 @@

- + BOOST_OS_VMS

@@ -1138,7 +1176,7 @@

- + BOOST_OS_WINDOWS

@@ -1226,7 +1264,7 @@

- + BOOST_OS_BSD_BSDI

@@ -1264,7 +1302,7 @@

- + BOOST_OS_BSD_DRAGONFLY

@@ -1302,7 +1340,7 @@

- + BOOST_OS_BSD_FREE

@@ -1354,7 +1392,7 @@

- + BOOST_OS_BSD_NET

@@ -1466,7 +1504,7 @@

- + BOOST_OS_BSD_OPEN

diff --git a/doc/html/predef/reference/boost_plat_platform_macros.html b/doc/html/predef/reference/boost_plat_platform_macros.html index e554c77..9321e06 100644 --- a/doc/html/predef/reference/boost_plat_platform_macros.html +++ b/doc/html/predef/reference/boost_plat_platform_macros.html @@ -4,7 +4,7 @@ BOOST_PLAT platform macros - + diff --git a/doc/html/predef/reference/other_macros.html b/doc/html/predef/reference/other_macros.html index b1e3f6f..802f689 100644 --- a/doc/html/predef/reference/other_macros.html +++ b/doc/html/predef/reference/other_macros.html @@ -4,7 +4,7 @@ Other macros - + diff --git a/doc/html/predef/reference/version_definition_macros.html b/doc/html/predef/reference/version_definition_macros.html index c52ae47..0451ca1 100644 --- a/doc/html/predef/reference/version_definition_macros.html +++ b/doc/html/predef/reference/version_definition_macros.html @@ -4,14 +4,14 @@ Version definition macros - + - +

-PrevUpHomeNext +PrevUpHomeNext

@@ -105,6 +105,9 @@

BOOST_PREDEF_MAKE_0X_VRRPP000(V)

+

+ BOOST_PREDEF_MAKE_0X_VVRRPP(V) +

BOOST_PREDEF_MAKE_10_VPPP(V)

@@ -178,7 +181,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/predef/to_do.html b/doc/html/predef/to_do.html index 200e3ce..7c01101 100644 --- a/doc/html/predef/to_do.html +++ b/doc/html/predef/to_do.html @@ -4,8 +4,8 @@ To Do - - + + @@ -17,9 +17,14 @@ -
  • +
      +
    • Improve reference documentation. -
    +
  • +
  • + Provide BOOST_WORKAROUND style macros for public use. +
  • +

diff --git a/doc/html/predef/using_the_predefs.html b/doc/html/predef/using_the_predefs.html index 7ce9d04..c659ce6 100644 --- a/doc/html/predef/using_the_predefs.html +++ b/doc/html/predef/using_the_predefs.html @@ -4,8 +4,8 @@ Using the predefs - - + + diff --git a/doc/predef.qbk b/doc/predef.qbk index 75ec39d..07807cd 100644 --- a/doc/predef.qbk +++ b/doc/predef.qbk @@ -1,6 +1,6 @@ [article Predef [quickbook 1.7] - [version 1.1] + [version 1.2] [authors [Rivera, Rene]] [copyright 2005, 2008-2014 Rene Rivera] [purpose Identification and specification of predefined macros.] @@ -558,6 +558,133 @@ and "Y", "M", "D" for dates. [endsect] +[section Check Utilities] + +The `predef_check` utility provides a facility for building a +program that will check a given set of expressions against +the definitions it detected when it was built. + +[heading [^predef_check] programs] + +Even though there is only one `predef_check` program, there +are variations for each of the languages that are detected +by Predef to match the convention for sources files. For all +of them one invokes with a list of expression arguments. The +expressions are evaluated within the context of the particular +[^predef_check] program and if they all are true zero (0) is returned. +Otherwise the index of the first false expression is returned. + +The expression syntax is simple: + +[teletype] +`` +predef-definition [ relational-operator version-value ] +`` +[c++] + +[~predef-definition] can be any of the Predef definitions. For +example `BOOST_COMP_GCC`. + +[~relational-operator] can be any of: [^>], [^<], [^>=], [^<=], +[^==] and [^!=]. + +[~version-number] can be a full or partial version triplet value. +If it's a partial version triple it is completed with zeros. That +is [^x.y] is equivalent to [^x.y.0] and [^x] is equivalent to +[^x.0.0]. + +The [~relations-operator] and [~version-number] can be ommited. In +which case it is equivalent to: + +[teletype] +`` +predef-definition > 0.0.0 +`` +[c++] + +[heading Using with Boost.Build] + +You can use the [^predef_check] programs directly from Boost Build +to configure target requirements. This is useful for controlling +what gets built as part of your project based on the detailed +version information available in Predef. The basic use is simple: + +[teletype] +`` +import path-to-predef-src/check/predef + : check require + : predef-check predef-require ; + +exe my_windows_program : windows_source.cpp + : [ predef-require "BOOST_OS_WINDOWS" ] ; +`` +[c++] + +That simple use case will skip building the [^my_windows_program] +unless one is building for Windows. Like the direct [^predef_check] +you can pass mutiple expressions using relational comparisons. +For example: + +[teletype] +`` +import path-to-predef-src/check/predef + : check require + : predef-check predef-require ; + +lib my_special_lib : source.cpp + : [ predef-require "BOOST_OS_WINDOWS != 0" "BOOST_OS_VMS != 0"] ; +`` +[c++] + +And in that case the [^my_special_lib] is built only when the OS is +not Windows or VMS. The [^requires] rule is a special case of the +[^check] rule. And is defined in terms of it: + +[teletype] +`` +rule require ( expressions + : language ? ) +{ + return [ check $(expressions) : $(language) : : no ] ; +} +`` +[c++] + +You can use the [^check] rule for more control and to implement +something other than control of what gets built. The definition +for the [^check] rule is: + +[teletype] +`` +rule check ( expressions + : language ? : true-properties * : false-properties * ) +`` +[c++] + +When invoked as a reuirement of a Boost Build target this rule +will add the [^true-properties] to the target if all the [^expressions] +evaluate to true. Otherwise the [^false-properties] get added as +requirements. For example you could use it to enable or disable +features in your programs: + +[teletype] +`` +import path-to-predef-src/check/predef + : check require + : predef-check predef-require ; + +exe my_special_exe : source.cpp + : [ predef-check "BOOST_OS_WINDOWS == 0" + : ENABLE_WMF=0 + : ENABLE_WMF=1 ] ; +`` +[c++] + +For both [^check] and [^require] the [^language] argument controls +which variant of the [^predef_check] program is used to check the +expressions. It defaults to "c++", but can be any of: "c", "cpp", +"objc", and "objcpp". + +[endsect] + [include history.qbk] [include todo.qbk] diff --git a/doc/todo.qbk b/doc/todo.qbk index 12f7db5..aa1c845 100644 --- a/doc/todo.qbk +++ b/doc/todo.qbk @@ -8,5 +8,6 @@ http://www.boost.org/LICENSE_1_0.txt) [section To Do] * Improve reference documentation. +* Provide BOOST_WORKAROUND style macros for public use. [endsect] diff --git a/include/boost/predef/make.h b/include/boost/predef/make.h index d327906..f8c28d1 100644 --- a/include/boost/predef/make.h +++ b/include/boost/predef/make.h @@ -42,6 +42,8 @@ Macros are: #define BOOST_PREDEF_MAKE_0X_VVRRP(V) BOOST_VERSION_NUMBER((V&0xFF000)>>12,(V&0xFF0)>>4,(V&0xF)) /*` `BOOST_PREDEF_MAKE_0X_VRRPP000(V)` */ #define BOOST_PREDEF_MAKE_0X_VRRPP000(V) BOOST_VERSION_NUMBER((V&0xF0000000)>>28,(V&0xFF00000)>>20,(V&0xFF000)>>12) +/*` `BOOST_PREDEF_MAKE_0X_VVRRPP(V)` */ +#define BOOST_PREDEF_MAKE_0X_VVRRPP(V) BOOST_VERSION_NUMBER((V&0xFF0000)>>16,(V&0xFF00)>>8,(V&0xFF)) /*` `BOOST_PREDEF_MAKE_10_VPPP(V)` */ #define BOOST_PREDEF_MAKE_10_VPPP(V) BOOST_VERSION_NUMBER(((V)/1000)%10,0,(V)%1000) /*` `BOOST_PREDEF_MAKE_10_VRP(V)` */ diff --git a/include/boost/predef/os.h b/include/boost/predef/os.h index 628eb4f..abd6666 100644 --- a/include/boost/predef/os.h +++ b/include/boost/predef/os.h @@ -15,6 +15,7 @@ http://www.boost.org/LICENSE_1_0.txt) #include #include #include +#include #include #include #include diff --git a/include/boost/predef/os/haiku.h b/include/boost/predef/os/haiku.h new file mode 100644 index 0000000..4d741cf --- /dev/null +++ b/include/boost/predef/os/haiku.h @@ -0,0 +1,47 @@ +/* +Copyright Jessica Hamilton 2014 +Copyright Rene Rivera 2014 +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) +*/ + +#ifndef BOOST_PREDEF_OS_HAIKU_H +#define BOOST_PREDEF_OS_HAIKU_H + +#include +#include + +/*` +[heading `BOOST_OS_HAIKU`] + +[@http://en.wikipedia.org/wiki/Haiku_(operating_system) Haiku] operating system. + +[table + [[__predef_symbol__] [__predef_version__]] + + [[`__HAIKU__`] [__predef_detection__]] + ] + */ + +#define BOOST_OS_HAIKU BOOST_VERSION_NUMBER_NOT_AVAILABLE + +#if !defined(BOOST_PREDEF_DETAIL_OS_DETECTED) && ( \ + defined(__HAIKU__) \ + ) +# undef BOOST_OS_HAIKU +# define BOOST_OS_HAIKU BOOST_VERSION_NUMBER_AVAILABLE +#endif + +#if BOOST_OS_HAIKU +# define BOOST_OS_HAIKU_AVAILABLE +# include +#endif + +#define BOOST_OS_HAIKU_NAME "Haiku" + +#include +BOOST_PREDEF_DECLARE_TEST(BOOST_OS_HAIKU,BOOST_OS_HAIKU_NAME) + + +#endif diff --git a/include/boost/predef/other/endian.h b/include/boost/predef/other/endian.h index fd73364..85a028d 100644 --- a/include/boost/predef/other/endian.h +++ b/include/boost/predef/other/endian.h @@ -13,6 +13,7 @@ http://www.boost.org/LICENSE_1_0.txt) #include #include #include +#include /*` [heading `BOOST_ENDIAN_*`] @@ -53,7 +54,7 @@ information and acquired knowledge: */ #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \ !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD -# if BOOST_LIB_C_GNU +# if BOOST_LIB_C_GNU || BOOST_OS_ANDROID # include # else # if BOOST_OS_MACOS @@ -69,29 +70,29 @@ information and acquired knowledge: # endif # endif # if defined(__BYTE_ORDER) -# if (__BYTE_ORDER == __BIG_ENDIAN) +# if defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) # undef BOOST_ENDIAN_BIG_BYTE # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE # endif -# if (__BYTE_ORDER == __LITTLE_ENDIAN) +# if defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) # undef BOOST_ENDIAN_LITTLE_BYTE # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE # endif -# if (__BYTE_ORDER == __PDP_ENDIAN) +# if defined(__PDP_ENDIAN) && (__BYTE_ORDER == __PDP_ENDIAN) # undef BOOST_ENDIAN_LITTLE_WORD # define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE # endif # endif # if !defined(__BYTE_ORDER) && defined(_BYTE_ORDER) -# if (_BYTE_ORDER == _BIG_ENDIAN) +# if defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) # undef BOOST_ENDIAN_BIG_BYTE # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE # endif -# if (_BYTE_ORDER == _LITTLE_ENDIAN) +# if defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) # undef BOOST_ENDIAN_LITTLE_BYTE # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE # endif -# if (_BYTE_ORDER == _PDP_ENDIAN) +# if defined(_PDP_ENDIAN) && (_BYTE_ORDER == _PDP_ENDIAN) # undef BOOST_ENDIAN_LITTLE_WORD # define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE # endif diff --git a/include/boost/predef/version.h b/include/boost/predef/version.h index 1e85df7..0439b2c 100644 --- a/include/boost/predef/version.h +++ b/include/boost/predef/version.h @@ -10,6 +10,6 @@ http://www.boost.org/LICENSE_1_0.txt) #include -#define BOOST_PREDEF_VERSION BOOST_VERSION_NUMBER(1,1,0) +#define BOOST_PREDEF_VERSION BOOST_VERSION_NUMBER(1,2,0) #endif diff --git a/test/build.jam b/test/build.jam index 10ba4f8..28e1473 100755 --- a/test/build.jam +++ b/test/build.jam @@ -4,6 +4,8 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +import ../check/predef : require : predef-require ; + local predef-include-root ; local predef-dependency ; @@ -53,6 +55,6 @@ test-suite predef : [ run info_as_objc.m : : : always_show_run_output ] [ run version.cpp ] [ run make.cpp ] - [ compile macos_endian.c ] - [ compile macos_vs_bsd.c ] + [ compile macos_endian.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ] + [ compile macos_vs_bsd.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ] ; diff --git a/test/info_as_c.c b/test/info_as_c.c index fe26e84..ba84947 100644 --- a/test/info_as_c.c +++ b/test/info_as_c.c @@ -13,8 +13,8 @@ http://www.boost.org/LICENSE_1_0.txt) typedef struct predef_info { unsigned tag; - char * name; - char * description; + const char * name; + const char * description; unsigned value; } predef_info; @@ -46,7 +46,7 @@ int main() if (*i == 0x67890DEF) { predef_count += 1; - predefs = realloc(predefs,predef_count*sizeof(predef_info*)); + predefs = (predef_info**)realloc(predefs,predef_count*sizeof(predef_info*)); predefs[predef_count-1] = (predef_info*)i; } } diff --git a/test/make.cpp b/test/make.cpp index 9dbd4a8..3ae8192 100644 --- a/test/make.cpp +++ b/test/make.cpp @@ -36,6 +36,7 @@ void test_BOOST_VERSION_NUMBER() 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_VRP(999) == BOOST_VERSION_NUMBER(9,9,9)); PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VPPP(9999) == BOOST_VERSION_NUMBER(9,0,999));