diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 0959479..10f5adb 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -11,7 +11,9 @@ import path ; import quickbook ; using boostbook ; using doxygen ; -import generate_base_units ; +import print ; +import regex ; +import sequence ; path-constant here : . ; @@ -32,7 +34,7 @@ doxygen $(target) \"BOOST_UNITS_TYPEOF(a)=typeof(a)\" \\ \"BOOST_PREVENT_MACRO_SUBSTITUTION=\" \\ \"BOOST_UNITS_HAS_TYPEOF=1\" \\ - \"BOOST_UNITS_NON_SI_UNIT(namespace_, name_, symbol_, factor, other_unit, id)= \\ + \"BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string, symbol_, factor, other_unit, id)= \\ namespace boost { namespace units { namespace namespace_ { \\ struct name_ ## _base_unit : boost::units::base_unit { \\ static const char* name(); \\ @@ -125,10 +127,47 @@ run_doxygen abstract_reference "Abstract System Reference" ; -generated-qbk base_units : [ path.glob-tree $(here)/../../../boost/units/base_units : *.hpp : detail conversions.hpp ] ; +rule less ( a b ) { + if [ path.basename $(a) ] < [ path.basename $(b) ] { + return true ; + } +} + +rule generate-qbk ( target : sources * : properties * ) { + print.output $(target) ; + local as-path = [ sequence.transform path.make : $(sources:G=) ] ; + local known = ; + local duplicated = ; + for local file in $(as-path) { + local base = [ path.basename $(file) ] ; + if $(base) in $(known) { + if ! $(base) in $(duplicated) { + duplicated += $(base) ; + } + } else { + known += $(base) ; + } + } + for local file in [ sequence.insertion-sort $(as-path) : less ] { + local output_filename = [ path.relative-to [ path.make $(here)/../../.. ] $(file) ] ; + local base_filename = [ path.basename $(file) ] ; + local base_unit = [ regex.replace $(base_filename) "\\.hpp" "" ] ; + if $(base_filename) in $(duplicated) { + # tack the directory name onto the end + local dir-name = [ path.basename [ path.parent $(file) ] ] ; + base_unit = "$(base_unit) ($(dir-name))" ; + } +# this looks better, but it won't work until my boostbook patch for +# annotation.xsl gets applied. +# print.text "[headerref $(output_filename) $(base_unit)]\\n" : overwrite ; + print.text "[headerref $(output_filename)]\\n" : overwrite ; + } +} + +make base_units.qbk : [ path.glob-tree $(here)/../../../boost/units/base_units : *.hpp : detail conversions.hpp ] : @generate-qbk ; explicit base_units ; -install base_units_install : base_units : . ; +install base_units_install : base_units.qbk : . ; xml units : diff --git a/doc/generate_base_units.jam b/doc/generate_base_units.jam deleted file mode 100644 index 393d441..0000000 --- a/doc/generate_base_units.jam +++ /dev/null @@ -1,56 +0,0 @@ -# generate_base_units.jam -# -# Copyright (c) 2008 -# Steven Watanabe -# -# 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 quickbook ; -import type ; -import generators ; -import print ; -import path ; -import regex ; -import sequence ; - -rule less ( a b ) { - if [ path.basename $(a) ] < [ path.basename $(b) ] { - return true ; - } -} - -rule generate_qbk ( target : sources * : properties * ) { - print.output $(target) ; - local as-path = [ sequence.transform path.make : $(sources:G=) ] ; - local known = ; - local duplicated = ; - for local file in $(as-path) { - local base = [ path.basename $(file) ] ; - if $(base) in $(known) { - if ! $(base) in $(duplicated) { - duplicated += $(base) ; - } - } else { - known += $(base) ; - } - } - for local file in [ sequence.insertion-sort $(as-path) : less ] { - local output_filename = [ regex.replace $(file) "\\.\\./" "" ] ; - local base_filename = [ path.basename $(file) ] ; - local base_unit = [ regex.replace $(base_filename) "\\.hpp" "" ] ; - if $(base_filename) in $(duplicated) { - # tack the directory name onto the end - local dir-name = [ path.basename [ path.parent $(file) ] ] ; - base_unit = "$(base_unit) ($(dir-name))" ; - } -# this looks better, but it won't work until my boostbook patch for -# annotation.xsl gets applied. -# print.text "[headerref $(output_filename) $(base_unit)]\\n" : overwrite ; - print.text "[headerref $(output_filename)]\\n" : overwrite ; - } -} - -type.register GENERATED_QBK : : QUICKBOOK ; -generators.register-composing generate_base_units.generate_qbk : HPP : GENERATED_QBK ; diff --git a/example/lambda.cpp b/example/lambda.cpp index 4801ae6..0fbac91 100644 --- a/example/lambda.cpp +++ b/example/lambda.cpp @@ -49,6 +49,8 @@ #include +static const double pi = 3.14159265358979323846; + //[lambda_snippet_1 int main(int argc, char **argv) { @@ -105,7 +107,7 @@ int main(int argc, char **argv) { boost::function (bu::quantity) > i = iamp * bl::bind(static_cast::type (*)(const bu::quantity&)>(bu::sin), - 2.0 * M_PI * si::radian * f * bl::_1) + 2.0 * pi * si::radian * f * bl::_1) + i0; cout << "Oscillating current:" << endl diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a1ad8c9..cbc0638 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,7 +8,7 @@ # http://www.boost.org/LICENSE_1_0.txt project units_test : - requirements $(BOOST_ROOT) ../../.. all msvc:on + requirements $(BOOST_ROOT) ../../.. msvc:on ; check-conversion-dependencies = [ path.glob-tree ../../../boost/units/systems/base_units : *.hpp ] ; diff --git a/test_headers/Jamfile.v2 b/test_headers/Jamfile.v2 index 7905c0a..1873a14 100644 --- a/test_headers/Jamfile.v2 +++ b/test_headers/Jamfile.v2 @@ -1,6 +1,6 @@ # Jamfile.v2 # -# Copyright (c) 2007 +# Copyright (c) 2007-2008 # Steven Watanabe # # Distributed under the Boost Software License, Version 1.0. (See @@ -11,19 +11,21 @@ import testing ; import path ; import regex ; import print ; -import generate_header ; project test_headers : requirements $(BOOST_ROOT) ../../.. ; -headers = ; +headers = [ path.glob-tree ../../../boost/units : *.hpp : detail ] ; rule setup ( ) { - for local file in [ path.glob-tree ../../../boost/units : *.hpp : cmath_*_impl*.hpp ] { + for local file in $(headers) { - headers += $(file) ; - result += [ compile test.cpp : BOOST_UNITS_HEADER_NAME=$(file) $(file) : [ regex.replace [ path.relative-to ../../.. $(file) ] "/" "_" ] ] ; + result += [ compile test.cpp : + BOOST_UNITS_HEADER_NAME=$(file) + $(file) + : + [ regex.replace [ path.relative-to ../../.. $(file) ] "/" "_" ] ] ; } return $(result) ; @@ -31,13 +33,24 @@ rule setup ( ) { tests = [ setup ] ; -generate-include-all-cpp include_all1 : $(headers) ; -generate-include-all-cpp include_all2 : $(headers) ; +rule generate-include-all ( target : sources * : properties * ) { + + print.output $(target) ; + + for local file in $(sources) { + print.text "#include <$(file:G=)> +" : overwrite ; + } + +} + +make include_all1.cpp : $(headers) : @generate-include-all ; +make include_all2.cpp : $(headers) : @generate-include-all ; import testing ; test-suite units_headers : $(tests) # this ought to catch non-inlined functions and other duplicate definitions - [ link include_all1 include_all2 main.cpp : . : include_all_headers ] + [ link include_all1.cpp include_all2.cpp main.cpp : . : include_all_headers ] ; diff --git a/test_headers/generate_header.jam b/test_headers/generate_header.jam deleted file mode 100644 index c521b48..0000000 --- a/test_headers/generate_header.jam +++ /dev/null @@ -1,28 +0,0 @@ -# generate_header.jam -# -# Copyright (c) 2008 -# Steven Watanabe -# -# 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 type ; -import generators ; -import print ; -import path ; - -rule generate_include_all ( target : sources * : properties * ) { - - print.output $(target) ; - - for local file in $(sources) { - print.text "#include <$(file:G=)> -" : overwrite ; - } - -} - -type.register GENERATE_INCLUDE_ALL_CPP : : CPP ; - -generators.register-composing generate_header.generate_include_all : HPP : GENERATE_INCLUDE_ALL_CPP ;