Conform to latest library requirements.

This commit is contained in:
Rene Rivera
2016-01-07 12:50:26 -06:00
parent 0f70c3578a
commit 009367d6a1
19 changed files with 252 additions and 218 deletions

View File

@ -1,202 +1,17 @@
# Copyright Rene Rivera 2015 # Copyright Rene Rivera 2016
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
# Defines rules that provide requirements based on checking # Hack, to reload check/predef.jam at its new location.
# conditions using Boost Predef definitions and version numbers.
import modules ; import modules ;
import project ; local _loaded_ ;
import feature ; for local _module_ in [ modules.peek modules : .loaded ]
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. if $(_module_) != "predef"
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" _loaded_ += $(_module_) ;
{
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 ;
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[3]) { 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) ;
} }
} }
modules.poke modules : .loaded : $(_loaded_) ;
import ../tools/check/predef ;

View File

@ -1,4 +1,4 @@
# Copyright Rene Rivera 2011 # Copyright Rene Rivera 2011-2016
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
@ -23,6 +23,9 @@ else
local BOOST_PREDEF_HEADERS = [ path.glob-tree $(BOOST_PREDEF_INCLUDE_ROOT)/boost/predef : *.h ] ; local BOOST_PREDEF_HEADERS = [ path.glob-tree $(BOOST_PREDEF_INCLUDE_ROOT)/boost/predef : *.h ] ;
# Intermediate targets..
# Quickbok to boostbook target.
xml predef xml predef
: :
predef.qbk predef.qbk
@ -32,6 +35,15 @@ xml predef
; ;
explicit predef ; explicit predef ;
# HTML dependencies for standalone docs.
install images : [ glob $(BOOST_ROOT)/doc/src/images/*.png ] : <location>html/images ;
explicit images ;
install callouts : [ glob $(BOOST_ROOT)/doc/src/images/callouts/*.png ] : <location>html/images/callouts ;
explicit callouts ;
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ] : <location>html ;
explicit css ;
# Default target builds standalone docs.
boostbook standalone boostbook standalone
: :
predef predef
@ -46,9 +58,6 @@ boostbook standalone
<dependency>css <dependency>css
; ;
install images : [ glob $(BOOST_ROOT)/doc/src/images/*.png ] : <location>html/images ; # Target for Boost global documentation integration.
explicit images ; alias boostdoc : predef : : : <implcit-dependency>predef ;
install callouts : [ glob $(BOOST_ROOT)/doc/src/images/callouts/*.png ] : <location>html/images/callouts ; explicit boostdoc ;
explicit callouts ;
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ] : <location>html ;
explicit css ;

View File

@ -57,7 +57,7 @@
</div> </div>
</div> </div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: October 15, 2015 at 04:09:31 GMT</small></p></td> <td align="left"><p><small>Last revised: January 07, 2016 at 18:48:05 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td> <td align="right"><div class="copyright-footer"></div></td>
</tr></table> </tr></table>
<hr> <hr>

View File

@ -73,7 +73,7 @@
gets built as part of your project based on the detailed version information gets built as part of your project based on the detailed version information
available in Predef. The basic use is simple: available in Predef. The basic use is simple:
</p> </p>
<pre class="programlisting">import path-to-predef-src/check/predef <pre class="programlisting">import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -85,7 +85,7 @@ exe my_windows_program : windows_source.cpp
unless one is building for Windows. Like the direct <code class="literal">predef_check</code> unless one is building for Windows. Like the direct <code class="literal">predef_check</code>
you can pass mutiple expressions using relational comparisons. For example: you can pass mutiple expressions using relational comparisons. For example:
</p> </p>
<pre class="programlisting">import path-to-predef-src/check/predef <pre class="programlisting">import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -106,7 +106,7 @@ lib my_special_lib : source.cpp
The expression can also use explicit "and", "or" logical The expression can also use explicit "and", "or" logical
operators to for more complex checks: operators to for more complex checks:
</p> </p>
<pre class="programlisting">import path-to-predef-src/check/predef <pre class="programlisting">import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -127,7 +127,7 @@ lib my_special_lib : source.cpp
as requirements. For example you could use it to enable or disable features as requirements. For example you could use it to enable or disable features
in your programs: in your programs:
</p> </p>
<pre class="programlisting">import path-to-predef-src/check/predef <pre class="programlisting">import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;

View File

@ -584,7 +584,7 @@
</td> </td>
<td> <td>
<p> <p>
BOOST_HW_SIMD_x86_AVX2_VERSION BOOST_HW_SIMD_X86_AVX2_VERSION
</p> </p>
</td> </td>
</tr> </tr>
@ -692,7 +692,7 @@
</td> </td>
<td> <td>
<p> <p>
BOOST_HW_SIMD_x86_SSE4A_VERSION BOOST_HW_SIMD_X86_SSE4A_VERSION
</p> </p>
</td> </td>
</tr> </tr>
@ -704,7 +704,7 @@
</td> </td>
<td> <td>
<p> <p>
BOOST_HW_SIMD_x86_FMA4_VERSION BOOST_HW_SIMD_X86_FMA4_VERSION
</p> </p>
</td> </td>
</tr> </tr>
@ -716,7 +716,7 @@
</td> </td>
<td> <td>
<p> <p>
BOOST_HW_SIMD_x86_XOP_VERSION BOOST_HW_SIMD_X86_XOP_VERSION
</p> </p>
</td> </td>
</tr> </tr>
@ -728,7 +728,7 @@
</td> </td>
<td> <td>
<p> <p>
BOOST_HW_SIMD_x86 BOOST_HW_SIMD_X86
</p> </p>
</td> </td>
</tr> </tr>
@ -1180,10 +1180,10 @@
</p> </p>
<h6> <h6>
<a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.h1"></a> <a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.h1"></a>
<span class="phrase"><a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version"></a></span><a class="link" href="boost_hw_hardware_macros.html#predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version"><code class="computeroutput"><span class="identifier">BOOST_HW_SIMD_X86_XOP_VERSION</span></code></a> <span class="phrase"><a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_fma4_version"></a></span><a class="link" href="boost_hw_hardware_macros.html#predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_fma4_version"><code class="computeroutput"><span class="identifier">BOOST_HW_SIMD_X86_FMA4_VERSION</span></code></a>
</h6> </h6>
<p> <p>
<a href="https://en.wikipedia.org/wiki/XOP_instruction_set" target="_top">XOP</a> <a href="https://en.wikipedia.org/wiki/FMA_instruction_set#FMA4_instruction_set" target="_top">FMA4</a>
x86 extension (AMD specific). x86 extension (AMD specific).
</p> </p>
<p> <p>
@ -1191,7 +1191,7 @@
</p> </p>
<h6> <h6>
<a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.h2"></a> <a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.h2"></a>
<span class="phrase"><a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version0"></a></span><a class="link" href="boost_hw_hardware_macros.html#predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version0"><code class="computeroutput"><span class="identifier">BOOST_HW_SIMD_X86_XOP_VERSION</span></code></a> <span class="phrase"><a name="predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version"></a></span><a class="link" href="boost_hw_hardware_macros.html#predef.reference.boost_hw_hardware_macros.boost_hw_simd_x86_amd_version.boost_hw_simd_x86_xop_version"><code class="computeroutput"><span class="identifier">BOOST_HW_SIMD_X86_XOP_VERSION</span></code></a>
</h6> </h6>
<p> <p>
<a href="https://en.wikipedia.org/wiki/XOP_instruction_set" target="_top">XOP</a> <a href="https://en.wikipedia.org/wiki/XOP_instruction_set" target="_top">XOP</a>

View File

@ -619,7 +619,7 @@ version information available in Predef. The basic use is simple:
[teletype] [teletype]
`` ``
import path-to-predef-src/check/predef import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -635,7 +635,7 @@ For example:
[teletype] [teletype]
`` ``
import path-to-predef-src/check/predef import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -663,7 +663,7 @@ to for more complex checks:
[teletype] [teletype]
`` ``
import path-to-predef-src/check/predef import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;
@ -690,7 +690,7 @@ features in your programs:
[teletype] [teletype]
`` ``
import path-to-predef-src/check/predef import path-to-predef-src/tools/check/predef
: check require : check require
: predef-check predef-require ; : predef-check predef-require ;

View File

@ -1,5 +1,5 @@
#!/usr/bin/env b2 -a --verbose-test #!/usr/bin/env b2 -a --verbose-test
# Copyright Rene Rivera 2011-2013 # Copyright Rene Rivera 2011-2016
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
@ -64,4 +64,12 @@ test-suite predef :
# Minimal testing done for predef for CI. Since # Minimal testing done for predef for CI. Since
# we don't have many we can just do all of them. # we don't have many we can just do all of them.
alias minimal : predef ; alias minimal : predef ;
# Full testing target for regular regression tests.
alias full : predef ;
# Extra's target. Nothing for Predef.
alias extra ;
explicit minimal ; explicit minimal ;
explicit extra ;

202
tools/check/predef.jam Normal file
View File

@ -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 ;
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[3]) { 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) ;
}
}