Boost logo

Boost-Build :

From: Craig Rodrigues (rodrigc_at_[hidden])
Date: 2005-05-06 14:30:09


On Fri, May 06, 2005 at 05:03:28PM +0400, Vladimir Prus wrote:
> Another detail. I'd be happy to commit the patch, but if you'd like it to work
> despite all the refactorings I make in future ;-), here's a simple recipe:
>
> 1. Take the test project you've sent and copy it to the "test" directory.
> 2. Run
>
> python load_dir.py $the_project_dir > vpath.py
>
> 3. Edit vpath.py and modify the list of binaries that are expected to be
> created (at the end of the file)
> 4. Modify the copyright message.
>
> That done, vpath functionality will be always tested.

Volodya,

Here is an updated patch from Alexander, incorporating your suggestions.

Index: v2/build/targets.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/build/targets.jam,v
retrieving revision 1.179
diff -u -r1.179 targets.jam
--- v2/build/targets.jam 4 May 2005 06:06:34 -0000 1.179
+++ v2/build/targets.jam 6 May 2005 19:26:34 -0000
@@ -789,23 +789,38 @@
rule generate ( properties )
{
return [ property-set.empty ]
- [ virtual-target.from-file $(self.name) : $(self.project) ] ;
+ [ virtual-target.from-file $(self.name)
+ : [ location ]
+ : $(self.project) ] ;
}

# Returns true if the referred file really exists;
rule exists ( )
{
- local location = [ path.root $(self.name)
- [ $(self.project).get source-location ] ] ;
- return [ CHECK_IF_FILE [ path.native $(location) ] ] ;
- }
-
+ return [ location ] ;
+ }
+
# Returns the location of target. Needed by 'testing.jam'
rule location ( )
{
- return [ path.root $(self.name)
- [ $(self.project).get source-location ] ] ;
- }
+ if ! $(self.file-location)
+ {
+ local source-location = [ $(self.project).get source-location ] ;
+
+ for local src-dir in $(source-location)
+ {
+ if ! $(self.file-location)
+ {
+ local location = [ path.root $(self.name) $(src-dir) ] ;
+ if [ CHECK_IF_FILE [ path.native $(location) ] ]
+ {
+ self.file-location = $(src-dir) ;
+ }
+ }
+ }
+ }
+ return $(self.file-location) ;
+ }
}

Index: v2/build/virtual-target.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/build/virtual-target.jam,v
retrieving revision 1.102
diff -u -r1.102 virtual-target.jam
--- v2/build/virtual-target.jam 4 May 2005 06:06:34 -0000 1.102
+++ v2/build/virtual-target.jam 6 May 2005 19:26:35 -0000
@@ -500,10 +500,13 @@
: type ? # Optional type for this target
: project
: action ?
+ : path ?
)
{
abstract-file-target.__init__ $(name) $(exact) : $(type) : $(project)
: $(action) ;
+
+ self.path = $(path) ;
}

rule actualize-location ( target )
@@ -540,9 +543,7 @@
}
else
{
- # This is a source file.
- SEARCH on $(target) =
- [ path.native [ $(self.project).get source-location ] ] ;
+ SEARCH on $(target) = [ path.native $(self.path) ] ;
}
}

@@ -764,15 +765,14 @@
# FIXME: more correct way would be to compute path to the file, based on name and source location
# for the project, and use that path to determine if the target was already created.
# TODO: passing project with all virtual targets starts to be annoying.
-rule from-file ( file : project )
+rule from-file ( file : file-loc : project )
{
import type ; # had to do this here to break a circular dependency

# Check if we've created a target corresponding to this file.
- local source-location = [ $(project).get source-location ] ;
- local path = [ path.root [ path.root [ path.make $(file) ] $(source-location) ]
- [ path.pwd ] ] ;
-
+ local path = [ path.root [ path.root $(file) $(file-loc) ]
+ [ path.pwd ] ] ;
+
if $(.files.$(path))
{
return $(.files.$(path)) ;
@@ -782,16 +782,13 @@
local name = [ path.make $(file) ] ;
local type = [ type.type $(file) ] ;
local result ;
- if ! $(type)
- {
- # warning "cannot determine type for file $(file)" ;
- result = [ new file-target $(file) : : $(project) ] ;
- }
- else
- {
- local v = [ new file-target $(name) : $(type) : $(project) ] ;
- result = $(v) ;
- }
+
+ result = [ new file-target $(file)
+ : $(type)
+ : $(project)
+ : #action
+ : $(file-loc) ] ;
+
.files.$(path) = $(result) ;
return $(result) ;
}

--
Craig Rodrigues 
rodrigc_at_[hidden]
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk