From f5ba4db1f7285769fd5630ee88fe3b692d9f4cc2 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 24 May 2005 08:57:52 +0000 Subject: [PATCH] Allow the 'source-location' attribute to list several directories. Patch from Alexander Kabaev and Craig Rodrigues. [SVN r29164] --- v2/build/project.jam | 10 +++++++--- v2/build/targets.jam | 38 +++++++++++++++++++++++++++---------- v2/build/virtual-target.jam | 33 +++++++++++++++----------------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/v2/build/project.jam b/v2/build/project.jam index 9c053839c..b39e7714b 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -614,9 +614,13 @@ class project-attributes self.default-build = [ property.make $(specification) ] ; } else if $(attribute) = "source-location" - { - self.source-location = [ path.root - [ path.make $(specification) ] $(self.location) ] ; + { + self.source-location = ; + for local src-path in $(specification) + { + self.source-location += [ path.root + [ path.make $(src-path) ] $(self.location) ] ; + } } else if $(attribute) = "build-dir" { diff --git a/v2/build/targets.jam b/v2/build/targets.jam index 9f53ed09c..9a5e8bcb9 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -365,7 +365,8 @@ class project-target : abstract-target else { # Interpret as filename - result = [ new file-reference [ path.make $(id) ] : $(project) ] ; + result = [ new file-reference [ path.make $(id) ] : $(project) ] ; + if ! [ $(result).exists ] { # File actually does not exist. @@ -789,23 +790,40 @@ class file-reference : abstract-target 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) ] ] ; - } - + location ; + return $(self.file-path) ; + } + # 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) ; + self.file-path = $(location) ; + } + } + } + } + return $(self.file-location) ; + } } diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index bd4b879a9..ba58096c6 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -500,10 +500,13 @@ class file-target : abstract-file-target : 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 @@ class file-target : abstract-file-target } 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 @@ class null-action : action # 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 @@ rule from-file ( file : project ) 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) ; }