diff --git a/doc/history.qbk b/doc/history.qbk index f8c0b47..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) @@ -14,6 +14,8 @@ http://www.boost.org/LICENSE_1_0.txt) * 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] diff --git a/doc/html/index.html b/doc/html/index.html index fa8d249..8a4dde7 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -45,6 +45,7 @@
Version definition macros
+
Check Utilities
History
To Do
Acknoledgements
@@ -52,7 +53,7 @@ - +

Last revised: January 27, 2015 at 14:25:08 GMT

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


diff --git a/doc/html/predef/check_utility.html b/doc/html/predef/check_utility.html new file mode 100644 index 0000000..5302f24 --- /dev/null +++ b/doc/html/predef/check_utility.html @@ -0,0 +1,32 @@ + + + +Check Utility + + + + + + + + +
+PrevUpHomeNext +
+

+Check Utility +

+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/predef/history.html b/doc/html/predef/history.html index d7dc619..883817d 100644 --- a/doc/html/predef/history.html +++ b/doc/html/predef/history.html @@ -6,12 +6,12 @@ - +
-PrevUpHomeNext +PrevUpHomeNext

@@ -36,6 +36,10 @@ Add missing BOOST_PREDEF_MAKE_0X_VVRRPP macro (from Erik Lindahl). +
  • + Add predef_check program + and BBv2 integration for build configuration checks. +
  • @@ -88,7 +92,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/predef/reference/version_definition_macros.html b/doc/html/predef/reference/version_definition_macros.html index 84fed35..0451ca1 100644 --- a/doc/html/predef/reference/version_definition_macros.html +++ b/doc/html/predef/reference/version_definition_macros.html @@ -7,11 +7,11 @@ - +
    -PrevUpHomeNext +PrevUpHomeNext

    @@ -181,7 +181,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/predef.qbk b/doc/predef.qbk index 4626830..07807cd 100644 --- a/doc/predef.qbk +++ b/doc/predef.qbk @@ -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]