diff --git a/v2/build/generators.jam b/v2/build/generators.jam index 66588a715..c19651f8b 100644 --- a/v2/build/generators.jam +++ b/v2/build/generators.jam @@ -105,6 +105,7 @@ class generator import virtual-target ; import "class" : new ; import property ; + import path ; EXPORT class@generator : indent increase-indent decrease-indent generators.dout ; @@ -414,8 +415,20 @@ class generator } } - # Names of sources might include directory. We should strip it. - name = $(name:D=) ; + # See if we need to add directory to the target name. + local dir = [ $(sources[1]).name ] ; + dir = $(dir:D) ; + if $(dir) && + # Never append '..' to target path. + ! [ MATCH .*(\\.\\.).* : $(dir) ] + && + ! [ path.is-rooted $(dir) ] + { + # Relative path is always relative to the source + # directory. Retain it, so that users can have files + # with the same in two different subdirectories. + name = $(dir)/$(name) ; + } } # Assign an action for each target