$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79973 - in trunk/tools/build/v2: build tools
From: jurko.gospodnetic_at_[hidden]
Date: 2012-08-11 18:24:52
Author: jurko
Date: 2012-08-11 18:24:51 EDT (Sat, 11 Aug 2012)
New Revision: 79973
URL: http://svn.boost.org/trac/boost/changeset/79973
Log:
Boost Build cleanup - added two new rules to the project.jam module (is-config-module for checking whether a module is one of Boost Build's configuration file modules & get-jamroot-module returning a given non-standalone & non-configuration project's base parent Jamroot project) and used them to restore corrected boostbook.jam module functionality for storing its constructed xml-catalog targets in the same location independent of what folder the build got run from. Updated related rule comments.
Text files modified: 
   trunk/tools/build/v2/build/project.jam   |    27 +++++++++++++++++++++++++++             
   trunk/tools/build/v2/tools/boostbook.jam |    33 +++++++++++++++++++++++++++++++--       
   2 files changed, 58 insertions(+), 2 deletions(-)
Modified: trunk/tools/build/v2/build/project.jam
==============================================================================
--- trunk/tools/build/v2/build/project.jam	(original)
+++ trunk/tools/build/v2/build/project.jam	2012-08-11 18:24:51 EDT (Sat, 11 Aug 2012)
@@ -821,6 +821,19 @@
 }
 
 
+# Returns whether a project module is one of Boost Build's configuration
+# modules.
+#
+rule is-config-module ( project )
+{
+    local cfgs = project site test user ;
+    if $(project) in $(cfgs)-config
+    {
+        return true ;
+    }
+}
+
+
 # Returns whether a project module is a Jamroot project module.
 #
 rule is-jamroot-module ( project )
@@ -829,6 +842,20 @@
 }
 
 
+# Returns a project's parent jamroot module. Returns nothing if there is no such
+# module, i.e. if this is a standalone project or one of the internal Boost
+# Build configuration projects.
+#
+rule get-jamroot-module ( project )
+{
+    local jamroot-location = [ attribute $(project) project-root ] ;
+    if $(jamroot-location)
+    {
+        return [ module-name $(jamroot-location) ] ;
+    }
+}
+
+
 # Returns the project target corresponding to the 'project-module'.
 #
 rule target ( project-module )
Modified: trunk/tools/build/v2/tools/boostbook.jam
==============================================================================
--- trunk/tools/build/v2/tools/boostbook.jam	(original)
+++ trunk/tools/build/v2/tools/boostbook.jam	2012-08-11 18:24:51 EDT (Sat, 11 Aug 2012)
@@ -579,6 +579,15 @@
 # every project that requests it but instead only create it based on the first
 # project requesting it and then reuse it from there for any later requests.
 #
+# To get 'as close as possible' to having the global catalog stored in the same
+# location independent of which folder our build was run from, we assign its
+# target to the given project's base Jamroot project. This works correctly as
+# long as we know the passed project is not standalone or one of Boost Build's
+# configuration module projects, as those to not have a Jamroot project in their
+# parent chain. Note also that we can still get our targets generated in
+# different folders in case when one build project references a target from
+# another build project with its own separate Jamroot.
+#
 # FIXME: Ideally the catalog target should be created as part of the boostbook
 # project and stored in some central location for all used standalone pojects,
 # shared between all builds made on that system. This however would require much
@@ -588,8 +597,28 @@
 {
     if ! $(.xml-catalog)
     {
-        .xml-catalog = [ new file-target boostbook_catalog : XML : $(project) :
-            [ new action : boostbook.generate-xml-catalog ] ] ;
+        local project-module = [ $(project).project-module ] ;
+        local root-module = [ project.get-jamroot-module $(project-module) ] ;
+        if ! $(root-module)
+        {
+            import errors ;
+            if [ project.is-config-module $(project-module) ]
+            {
+                errors.user-error boostbook targets can not be declared in Boost
+                    Build's configuration modules. ;
+            }
+            else
+            {
+                errors.user-error boostbook targets can not be declared in
+                    standalone projects. : use a Jamfile/Jamroot project
+                    instead. ;
+            }
+        }
+        local root-project = [ project.target $(root-module) ] ;
+
+        .xml-catalog = [ new file-target boostbook_catalog : XML :
+            $(root-project) : [ new action : boostbook.generate-xml-catalog ] ]
+            ;
         .xml-catalog-file = [ $(.xml-catalog).path ] [ $(.xml-catalog).name ] ;
         .xml-catalog-file = $(.xml-catalog-file:J=/) ;
     }