From 0ff664ff6327f5deb3d87a13cf83a0ea5ef158ff Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 16 Feb 2004 09:12:27 +0000 Subject: [PATCH] Move the logic for library ordering to a separate module. Add library ordering to 'sun' toolset. [SVN r22284] --- v2/tools/gcc.jam | 142 +-------------------------------------- v2/tools/sun.jam | 5 +- v2/tools/unix.jam | 165 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+), 143 deletions(-) create mode 100644 v2/tools/unix.jam diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index df49f9ba1..e4f691216 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -16,7 +16,9 @@ import "class" : new ; import order ; import set ; -feature.extend toolset : gcc ; +#feature.extend toolset : gcc ; + +toolset.inherit gcc : unix ; feature.subfeature toolset gcc : version : : optional propagated link-incompatible ; # Make the "o" suffix used for gcc toolset on all @@ -54,96 +56,6 @@ if [ os.name ] = NT JAMSHELL = % ; } -# Special linking generator for gcc which handles order requirements on -# the command line. -class gcc-linking-generator : linking-generator -{ - import property-set ; - import type ; - import gcc ; - - rule __init__ ( id - composing ? : # Specify if generator is composing. The generator will be - # composing if non-empty string is passed, or parameter is - # not given. To make generator non-composing, pass empty - # string ("") - source-types + : target-types + : - requirements * ) - { - composing ?= true ; - generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : - $(requirements) ; - } - - rule run ( project name ? : property-set : sources + : multiple ? ) - { - local result = [ linking-generator.run $(project) $(name) : $(property-set) - : $(sources) : $(multiple) ] ; - - gcc.set-library-order $(sources) : $(property-set) : $(result) ; - - return $(result) ; - } - - rule generated-targets ( sources + : property-set : project name ? ) - { - local sources2 ; - local libraries ; - for local l in $(sources) - { - if [ type.is-derived [ $(l).type ] LIB ] - { - libraries += $(l) ; - } - else - { - sources2 += $(l) ; - } - } - - sources = $(sources2) [ gcc.order-libraries $(libraries) ] ; - - return [ linking-generator.generated-targets $(sources) : $(property-set) - : $(project) $(name) ] ; - } - -} - -class gcc-archive-generator : generator -{ - import gcc ; - - rule __init__ ( id composing ? : source-types + : target-types + : - requirements * ) - { - composing ?= true ; - generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : - $(requirements) ; - } - - rule run ( project name ? : property-set : sources + : multiple ? ) - { - local result = [ generator.run $(project) $(name) : $(property-set) - : $(sources) : $(multiple) ] ; - - gcc.set-library-order $(sources) : $(property-set) : $(result) ; - - return $(result) ; - - } -} - - -# Declare generators -generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE - : gcc ] ; - -generators.register [ new gcc-archive-generator gcc.archive : OBJ : STATIC_LIB - : gcc ] ; - -generators.register [ new gcc-linking-generator gcc.link.dll : LIB OBJ : SHARED_LIB - : gcc ] ; - generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : gcc ; generators.register-c-compiler gcc.compile.c : C : OBJ : gcc ; @@ -281,51 +193,3 @@ else if [ modules.peek : UNIX ] } } -.order = [ new order ] ; - -rule set-library-order-aux ( from * : to * ) -{ - for local f in $(from) - { - for local t in $(to) - { - if $(f) != $(t) - { - $(.order).add-pair $(f) $(t) ; - } - } - } -} - -rule set-library-order ( sources * : property-set : result * ) -{ - local used-libraries ; - local deps = [ $(property-set).dependency ] ; - for local l in $(sources) $(deps:G=) - { - if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] - { - used-libraries += $(l) ; - } - } - - local created-libraries ; - for local l in $(result) - { - if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] - { - created-libraries += $(l) ; - } - } - - created-libraries = [ set.difference $(created-libraries) : $(used-libraries) ] ; - set-library-order-aux $(created-libraries) : $(used-libraries) ; -} - - - - -rule order-libraries ( libraries * ) -{ - return [ $(.order).order $(libraries) ] ; -} diff --git a/v2/tools/sun.jam b/v2/tools/sun.jam index 264145418..e4cfe3cf8 100644 --- a/v2/tools/sun.jam +++ b/v2/tools/sun.jam @@ -11,7 +11,7 @@ import toolset : flags ; import feature ; import type ; -toolset.register sun ; +toolset.inherit sun : unix ; feature.subfeature toolset sun : version ; # Installation root to use for versionless toolset @@ -53,9 +53,6 @@ rule init ( version ? : root ? ) # Declare generators generators.register-c-compiler sun.compile.c : C : OBJ : sun ; generators.register-c-compiler sun.compile.c++ : CPP : OBJ : sun ; -generators.register-composing sun.archive : OBJ : STATIC_LIB : sun ; -generators.register-linker sun.link.dll : LIB OBJ : SHARED_LIB : sun ; -generators.register-linker sun.link : LIB OBJ : EXE : sun ; # Declare flags and actions for compilation flags sun.compile OPTIONS on : -g ; diff --git a/v2/tools/unix.jam b/v2/tools/unix.jam new file mode 100644 index 000000000..0cf09387f --- /dev/null +++ b/v2/tools/unix.jam @@ -0,0 +1,165 @@ +# Copyright (c) 2004 Vladimir Prus. +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +# This file implements linking semantic common to all unixes. On unix, static +# libraries must be specified in a fixed order on the linker command line. Generators +# declared there store information about the order and use it property. + +import feature ; +import "class" : new ; +import generators ; +import type ; +import set ; + + +feature.extend toolset : gcc ; + +class unix-linking-generator : linking-generator +{ + import property-set ; + import type ; + import unix ; + + rule __init__ ( id + composing ? : # Specify if generator is composing. The generator will be + # composing if non-empty string is passed, or parameter is + # not given. To make generator non-composing, pass empty + # string ("") + source-types + : target-types + : + requirements * ) + { + composing ?= true ; + generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : + $(requirements) ; + } + + rule run ( project name ? : property-set : sources + : multiple ? ) + { + local result = [ linking-generator.run $(project) $(name) : $(property-set) + : $(sources) : $(multiple) ] ; + + unix.set-library-order $(sources) : $(property-set) : $(result) ; + + return $(result) ; + } + + rule generated-targets ( sources + : property-set : project name ? ) + { + local sources2 ; + local libraries ; + for local l in $(sources) + { + if [ type.is-derived [ $(l).type ] LIB ] + { + libraries += $(l) ; + } + else + { + sources2 += $(l) ; + } + } + + sources = $(sources2) [ unix.order-libraries $(libraries) ] ; + + return [ linking-generator.generated-targets $(sources) : $(property-set) + : $(project) $(name) ] ; + } + +} + +class unix-archive-generator : generator +{ + import unix ; + + rule __init__ ( id composing ? : source-types + : target-types + : + requirements * ) + { + composing ?= true ; + generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : + $(requirements) ; + } + + rule run ( project name ? : property-set : sources + : multiple ? ) + { + local result = [ generator.run $(project) $(name) : $(property-set) + : $(sources) : $(multiple) ] ; + + unix.set-library-order $(sources) : $(property-set) : $(result) ; + + return $(result) ; + + } +} + + +# Declare generators +generators.register [ new unix-linking-generator unix.link : LIB OBJ : EXE + : unix ] ; + +generators.register [ new unix-archive-generator unix.archive : OBJ : STATIC_LIB + : unix ] ; + +generators.register [ new unix-linking-generator unix.link.dll : LIB OBJ : SHARED_LIB + : unix ] ; + + +# The derived toolset must specify their own actions. +actions link { +} + +actions link.dll { +} + +actions archive { +} + + +.order = [ new order ] ; + +rule set-library-order-aux ( from * : to * ) +{ + for local f in $(from) + { + for local t in $(to) + { + if $(f) != $(t) + { + $(.order).add-pair $(f) $(t) ; + } + } + } +} + +rule set-library-order ( sources * : property-set : result * ) +{ + local used-libraries ; + local deps = [ $(property-set).dependency ] ; + for local l in $(sources) $(deps:G=) + { + if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] + { + used-libraries += $(l) ; + } + } + + local created-libraries ; + for local l in $(result) + { + if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] + { + created-libraries += $(l) ; + } + } + + created-libraries = [ set.difference $(created-libraries) : $(used-libraries) ] ; + set-library-order-aux $(created-libraries) : $(used-libraries) ; +} + +rule order-libraries ( libraries * ) +{ + return [ $(.order).order $(libraries) ] ; +} + \ No newline at end of file