forked from boostorg/predef
Initial docs for predef_check.
This commit is contained in:
@ -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]
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
<dt><span class="section"><a href="predef/reference/version_definition_macros.html">Version definition
|
||||
macros</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="predef/check_utilities.html">Check Utilities</a></span></dt>
|
||||
<dt><span class="section"><a href="predef/history.html">History</a></span></dt>
|
||||
<dt><span class="section"><a href="predef/to_do.html">To Do</a></span></dt>
|
||||
<dt><span class="section"><a href="predef/acknoledgements.html">Acknoledgements</a></span></dt>
|
||||
@ -52,7 +53,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: January 27, 2015 at 14:25:08 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: January 29, 2015 at 21:39:36 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
32
doc/html/predef/check_utility.html
Normal file
32
doc/html/predef/check_utility.html
Normal file
@ -0,0 +1,32 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Check Utility</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Predef 1.2">
|
||||
<link rel="up" href="../index.html" title="Predef 1.2">
|
||||
<link rel="prev" href="reference/version_definition_macros.html" title="Version definition macros">
|
||||
<link rel="next" href="history.html" title="History">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="reference/version_definition_macros.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="history.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="predef.check_utility"></a><a class="link" href="check_utility.html" title="Check Utility">Check Utility</a>
|
||||
</h2></div></div></div></div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2005, 2008-2014 Rene Rivera<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="reference/version_definition_macros.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="history.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -6,12 +6,12 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Predef 1.2">
|
||||
<link rel="up" href="../index.html" title="Predef 1.2">
|
||||
<link rel="prev" href="reference/version_definition_macros.html" title="Version definition macros">
|
||||
<link rel="prev" href="check_utilities.html" title="Check Utilities">
|
||||
<link rel="next" href="to_do.html" title="To Do">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="reference/version_definition_macros.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="to_do.html"><img src="../images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="check_utilities.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="to_do.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@ -36,6 +36,10 @@
|
||||
Add missing <code class="computeroutput"><span class="identifier">BOOST_PREDEF_MAKE_0X_VVRRPP</span></code>
|
||||
macro (from Erik Lindahl).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Add <code class="computeroutput"><span class="identifier">predef_check</span></code> program
|
||||
and BBv2 integration for build configuration checks.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="predef.history.h1"></a>
|
||||
@ -88,7 +92,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="reference/version_definition_macros.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="to_do.html"><img src="../images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="check_utilities.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="to_do.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -7,11 +7,11 @@
|
||||
<link rel="home" href="../../index.html" title="Predef 1.2">
|
||||
<link rel="up" href="../reference.html" title="Reference">
|
||||
<link rel="prev" href="other_macros.html" title="Other macros">
|
||||
<link rel="next" href="../history.html" title="History">
|
||||
<link rel="next" href="../check_utilities.html" title="Check Utilities">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="other_macros.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../history.html"><img src="../../images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="other_macros.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../check_utilities.html"><img src="../../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@ -181,7 +181,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="other_macros.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../history.html"><img src="../../images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="other_macros.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../check_utilities.html"><img src="../../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
127
doc/predef.qbk
127
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) : : <build>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"
|
||||
: <define>ENABLE_WMF=0
|
||||
: <define>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]
|
||||
|
||||
|
Reference in New Issue
Block a user