From ccb28e2feb49350596daa9617dc1c26bf1423dfa Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 10 Dec 2003 08:10:13 +0000 Subject: [PATCH] Minor refactorings. [SVN r21200] --- src/build/targets.jam | 11 +++++------ src/util/path.jam | 10 ++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/build/targets.jam b/src/build/targets.jam index 453afb514..2981c9c7d 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -545,13 +545,12 @@ class file-reference : abstract-target [ virtual-target.from-file $(self.name) : $(self.project) ] ; } - rule location ( ) + # Returns true if the referred file really exists; + rule exists ( ) { - # FIXME: use of glob seems like a horribly inefficient way - # to lookup a file. local location = [ path.root $(self.name) - [ project.attribute $(self.project) source-location ] ] ; - return [ path.glob $(location:D) : $(location:D=) ] ; + [ project.attribute $(self.project) source-location ] ] ; + return [ path.exists $(location) ] ; } } @@ -615,7 +614,7 @@ rule find ( id : current-location ) if ! $(target) && ! $(have-project-reference) && $(base-project) { target = [ new file-reference $(target-part) : $(base-project) ] ; - if ! [ $(target).location ] + if ! [ $(target).exists ] { # File actually does not exist. # Reset 'target' so that an error is issued. diff --git a/src/util/path.jam b/src/util/path.jam index dedb30d5e..305a8d777 100644 --- a/src/util/path.jam +++ b/src/util/path.jam @@ -195,6 +195,16 @@ rule glob ( dir : patterns + ) return [ sequence.transform make : [ GLOB [ native $(dir) ] : $(patterns) ] ] ; } +# +# Returns true is the specified file exists. +# +rule exists ( file ) +{ + return [ path.glob $(file:D) : $(file:D=) ] ; +} + + + # # Find out the absolute name of path and returns the list of all the parents, # starting with the immediate one. Parents are returned as relative names.