From 9d1b318b43f0bb7fe34c3aaf23d00272bc0650c8 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 24 Jan 2005 14:11:27 +0000 Subject: [PATCH] Implement symlinks support for installing shared libraries. Also fix top-level Boost Jamfile. Seems like V2 can now install Boost. [SVN r26835] --- v2/build/virtual-target.jam | 22 ++++++++--- v2/tools/stage.jam | 74 ++++++++++++++++++++++++++++++------- 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index cc92f099b..9152b344f 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -219,6 +219,7 @@ class abstract-file-target : virtual-target self.type = $(type) ; self.action = $(action) ; + self.exact-name = $(exact) ; if $(action) { $(action).add-targets $(__name__) ; @@ -234,7 +235,10 @@ class abstract-file-target : virtual-target rule set-type ( type ) { self.type = $(type) ; - _adjust-name [ utility.basename $(self.name) ] ; + if ! $(self.exact-name) + { + _adjust-name [ utility.basename $(self.name) ] ; + } } # Sets the path. When generating target name, it will override any path @@ -411,8 +415,17 @@ class abstract-file-target : virtual-target } rule _adjust-name ( specified-name ) - { - local ps = [ $(self.action).properties ] ; + { + local ps ; + if $(self.action) + { + ps = [ $(self.action).properties ] ; + } + else + { + ps = [ property-set.empty ] ; + } + local tag = [ $(ps).get ] ; if $(tag) @@ -443,8 +456,7 @@ class abstract-file-target : virtual-target if ! $(tag) || ! $(self.name) { self.name = [ virtual-target.add-suffix - $(specified-name) : $(self.type) - : [ $(self.action).properties ] ] ; + $(specified-name) : $(self.type) : $(ps) ] ; } } diff --git a/v2/tools/stage.jam b/v2/tools/stage.jam index aa3563eca..6b79f9cdf 100644 --- a/v2/tools/stage.jam +++ b/v2/tools/stage.jam @@ -111,10 +111,10 @@ class install-target-class : basic-target # See if something special should be done when staging this # type. It is indicated by presense of special "staged" type local t = [ $(i).type ] ; - if $(t) && [ type.registered STAGED_$(t) ] + if $(t) && [ type.registered INSTALLED_$(t) ] { local targets = [ generators.construct $(self.project) $(name) : - STAGED_$(t) : $(new-properties) : $(i) : * ] ; + INSTALLED_$(t) : $(new-properties) : $(i) : * ] ; staged-targets += $(targets[2-]) ; } else @@ -239,7 +239,7 @@ class install-target-class : basic-target rule copy-file ( project : source : properties ) { local name = [ $(source).name ] ; - + new-a = [ new action $(source) : common.copy : $(properties) ] ; targets = [ new file-target $(name:D=) exact : [ $(source).type ] : $(project) : $(new-a) ] ; @@ -247,16 +247,15 @@ rule copy-file ( project : source : properties ) return $(targets) ; } -#rule symlink-lib ( suffix : project : source : extra-properties ) -#{ -# local n = [ $(source).name ] ; -# local targets = [ -# new file-target $(n:D=) : [ $(source).type ] : $(project) ] ; -# local a = [ new action $(targets) : $(source) : symlink.ln : -# $(extra-properties) ] ; -# $(targets).action $(a) ; -# return $(targets) ; -#} +rule symlink ( name : project : source : properties ) +{ + local a = [ new action $(source) : symlink.ln : + $(properties) ] ; + local targets = [ + new file-target $(name) exact : [ $(source).type ] : $(project) : $(a) ] ; + + return $(targets) ; +} rule relink-file ( project : source : property-set ) { @@ -300,6 +299,53 @@ class installed-exe-generator : generator generators.register [ new installed-exe-generator ] ; +# Installing shared link on Unix might cause a creation of +# versioned symbolic links. +type.register INSTALLED_SHARED_LIB : : SHARED_LIB ; +class installed-shared-lib-generator : generator +{ + import type property-set modules stage ; + + rule __init__ ( ) + { + generator.__init__ install-shared-lib : SHARED_LIB + : INSTALLED_SHARED_LIB ; + } + + rule run ( project name ? : property-set : source : multiple ? ) + { + local copied = [ stage.copy-file $(project) + : $(source) : $(property-set) ] ; + + if [ $(property-set).get ] = NT + { + return $(copied) ; + } + else + { + local result = $(copied) ; + # If the name is in the form NNN.XXX.YYY.ZZZ, where all + # 'X', 'Y' and 'Z' are numbers, we need to create + # NNN.XXX and NNN.XXX.YYY symbolic links. + local m = [ MATCH (.*)\\.([0123456789]+)\\.([0123456789]+)\\.([0123456789]+)$ + : [ $(copied).name ] ] ; + if $(m) + { + result += [ stage.symlink $(m[1]).$(m[2]) : $(project) + : $(copied) : $(property-set) ] ; + result += [ stage.symlink $(m[1]).$(m[2]).$(m[3]) : $(project) + : $(copied) : $(property-set) ] ; + } + + return $(result) ; + } + } +} + +generators.register [ new installed-shared-lib-generator ] ; + + + # Main target rule for 'install' rule install ( name : sources * : requirements * : default-build * ) { @@ -335,7 +381,7 @@ rule install ( name : sources * : requirements * : default-build * ) IMPORT $(__name__) : install : : install ; IMPORT $(__name__) : install : : stage ; -rule add-variant-and-compiler ( name : property-set ) +rule add-variant-and-compiler ( name : type ? : property-set ) { return [ rename $(name) : $(type) : $(property-set) ] ; }