From 0afa3aa911ef7a3d7a10bafa433d272a08ea7e81 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 27 Nov 2002 09:35:53 +0000 Subject: [PATCH] Improve 'flags' and the gcc toolset. * gcc.jam: Extend the 'toolset' feature with gcc here. Use flags for linking too and eliminate 'link-options' rule. Remove empty compile/archive/link/link-dll rules. * toolset.jam (flags): Document somehow. (set-target-variables): Call 'actualize' on values of dependency features. [SVN r16440] --- new/builtin.jam | 2 +- new/gcc.jam | 77 +++++++------------------- new/toolset.jam | 41 ++++++++++++-- test/project-test3/project-root.jam | 1 + test/project-test4/project-root.jam | 1 + v2/build/toolset.jam | 41 ++++++++++++-- v2/gcc.jam | 77 +++++++------------------- v2/test/project-test3/project-root.jam | 1 + v2/test/project-test4/project-root.jam | 1 + v2/tools/builtin.jam | 2 +- 10 files changed, 122 insertions(+), 122 deletions(-) diff --git a/new/builtin.jam b/new/builtin.jam index 78384c163..6be1abd88 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -20,7 +20,7 @@ import toolset ; import errors : error ; import symlink ; -feature toolset : gcc : implicit propagated link-incompatible symmetric ; +feature toolset : : implicit propagated link-incompatible symmetric ; feature shared : false true : propagated ; feature optimization : off on : propagated ; feature threading : single multi : link-incompatible propagated ; diff --git a/new/gcc.jam b/new/gcc.jam index 5c4e8a261..26b57939c 100644 --- a/new/gcc.jam +++ b/new/gcc.jam @@ -2,7 +2,10 @@ import property ; import generators ; import os ; - + +feature.extend toolset : gcc ; + +# Declare generators generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; generators.register-composing gcc.archive : OBJ : STATIC_LIB : gcc ; generators.register-composing gcc.link-dll : OBJ : SHARED_LIB : gcc ; @@ -10,10 +13,7 @@ generators.register-c-compiler gcc.compile : CPP : OBJ : gcc ; generators.register-c-compiler gcc.compile : C : OBJ : gcc ; -rule compile ( target : sources * : property-set * ) -{ -} - +# Declare flags and action for compilation toolset.flags gcc.compile OPTIONS on : -O2 ; toolset.flags gcc.compile OPTIONS on : -g ; toolset.flags gcc.compile OPTIONS ; @@ -25,65 +25,30 @@ actions compile g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } -local rule link-options ( target : sources * : property-set * ) -{ - local options ; - local libs ; - local findlibs ; - for local p in $(property-set) - { - if $(p) = on - { - options += -g ; - } - else if $(p:G) = - { - options += -L$(p:G=) ; - } - else if $(p:G) = - { - findlibs += -l$(p:G=) ; - } - else if $(p:G) = - { - libs += $(p:G=) ; - } - else if $(p:G) = - { - libs += [ $(p:G=).actualize ] ; - } - } - - DEPENDS $(target) : $(LIBS) ; - - OPTIONS on $(target) = $(options) ; - LIBS on $(target) = $(libs) ; - FINDLIBS on $(target) = $(findlibs) ; -} - -rule link ( target : sources * : property-set * ) -{ - link-options $(target) : $(sources) : $(property-set) ; -} - -actions link bind LIBS -{ - g++ $(OPTIONS) -o $(<) $(>) $(LIBS) $(FINDLIBS) -} - -rule archive ( target : sources * : property-set * ) +# Declare flags and action for linking +toolset.flags gcc.link OPTIONS on : -g ; +toolset.flags gcc.link LINKPATH ; +toolset.flags gcc.link FINDLIBS ; +toolset.flags gcc.link LIBRARIES ; +toolset.flags gcc.link LIBRARIES ; + +actions link bind LIBRARIES { + g++ $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) } +# Declare action for creating static libraries actions archive { ar ur $(<) $(>) } -rule link-dll ( target : sources * : property-set * ) -{ - link-options $(target) : $(sources) : $(property-set) ; -} +# Declare flags and action for linking shared libraries +toolset.flags gcc.link-dll OPTIONS on : -g ; +toolset.flags gcc.link-dll LINKPATH ; +toolset.flags gcc.link-dll FINDLIBS ; +toolset.flags gcc.link-dll LIBRARIES ; +toolset.flags gcc.link-dll LIBRARIES ; actions link-dll bind LIBS { diff --git a/new/toolset.jam b/new/toolset.jam index 68d6339b0..f0c8fb754 100644 --- a/new/toolset.jam +++ b/new/toolset.jam @@ -10,7 +10,29 @@ import numbers ; .flag-no = 1 ; -rule flags ( rule-or-module variable-name condition * : values * ) +# Specifies the flags (variables) that must be set on targets under certain +# conditions, described by arguments. +rule flags ( rule-or-module # If contains dot, should be a rule name. + # The flags will be applied when that rule is + # used to set up build actions. + # + # If does not contain dot, should be a module name. + # The flags will be applied for all rules in that + # module. THIS PART IS NOT IMPLEMENTED YET. + + variable-name # Variable that should be set on target + condition * : # Can specify either + # + # - a set of feature names. Values of all mentioned + # feature that are present in build property set + # will be appended to the variable. The 'actualize' + # method will be called on values of all dependency + # features. The next argument will be unused. + # + # - a set of property sets. If one of those property + # sets is contained in build properties, 'values' + # will be added to the variable. + values * ) { .$(rule-or-module).flags += $(.flag-no) ; @@ -38,7 +60,7 @@ rule set-target-variables ( rule-or-module target : properties * ) if $(requirements:G=) { - + # This is a property set if ! $(found) && $(requirements) in $(properties) { result += $(values) ; @@ -48,8 +70,19 @@ rule set-target-variables ( rule-or-module target : properties * ) else { for local r in $(requirements) - { - result += [ feature.get-values $(r) : $(properties) ] ; + { + local item = [ feature.get-values $(r) : $(properties) ] ; + if $(item) + { + if dependency in [ feature.attributes $(r:G) ] + { + result += [ $(item).actualize ] ; + } + else + { + result += $(item) ; + } + } } } } diff --git a/test/project-test3/project-root.jam b/test/project-test3/project-root.jam index a6f85e166..3826e8fe4 100644 --- a/test/project-test3/project-root.jam +++ b/test/project-test3/project-root.jam @@ -1,4 +1,5 @@ +import gcc ; import property ; rule yfc-compile ( target : sources * : property-set * ) diff --git a/test/project-test4/project-root.jam b/test/project-test4/project-root.jam index a6f85e166..3826e8fe4 100644 --- a/test/project-test4/project-root.jam +++ b/test/project-test4/project-root.jam @@ -1,4 +1,5 @@ +import gcc ; import property ; rule yfc-compile ( target : sources * : property-set * ) diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam index 68d6339b0..f0c8fb754 100644 --- a/v2/build/toolset.jam +++ b/v2/build/toolset.jam @@ -10,7 +10,29 @@ import numbers ; .flag-no = 1 ; -rule flags ( rule-or-module variable-name condition * : values * ) +# Specifies the flags (variables) that must be set on targets under certain +# conditions, described by arguments. +rule flags ( rule-or-module # If contains dot, should be a rule name. + # The flags will be applied when that rule is + # used to set up build actions. + # + # If does not contain dot, should be a module name. + # The flags will be applied for all rules in that + # module. THIS PART IS NOT IMPLEMENTED YET. + + variable-name # Variable that should be set on target + condition * : # Can specify either + # + # - a set of feature names. Values of all mentioned + # feature that are present in build property set + # will be appended to the variable. The 'actualize' + # method will be called on values of all dependency + # features. The next argument will be unused. + # + # - a set of property sets. If one of those property + # sets is contained in build properties, 'values' + # will be added to the variable. + values * ) { .$(rule-or-module).flags += $(.flag-no) ; @@ -38,7 +60,7 @@ rule set-target-variables ( rule-or-module target : properties * ) if $(requirements:G=) { - + # This is a property set if ! $(found) && $(requirements) in $(properties) { result += $(values) ; @@ -48,8 +70,19 @@ rule set-target-variables ( rule-or-module target : properties * ) else { for local r in $(requirements) - { - result += [ feature.get-values $(r) : $(properties) ] ; + { + local item = [ feature.get-values $(r) : $(properties) ] ; + if $(item) + { + if dependency in [ feature.attributes $(r:G) ] + { + result += [ $(item).actualize ] ; + } + else + { + result += $(item) ; + } + } } } } diff --git a/v2/gcc.jam b/v2/gcc.jam index 5c4e8a261..26b57939c 100644 --- a/v2/gcc.jam +++ b/v2/gcc.jam @@ -2,7 +2,10 @@ import property ; import generators ; import os ; - + +feature.extend toolset : gcc ; + +# Declare generators generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; generators.register-composing gcc.archive : OBJ : STATIC_LIB : gcc ; generators.register-composing gcc.link-dll : OBJ : SHARED_LIB : gcc ; @@ -10,10 +13,7 @@ generators.register-c-compiler gcc.compile : CPP : OBJ : gcc ; generators.register-c-compiler gcc.compile : C : OBJ : gcc ; -rule compile ( target : sources * : property-set * ) -{ -} - +# Declare flags and action for compilation toolset.flags gcc.compile OPTIONS on : -O2 ; toolset.flags gcc.compile OPTIONS on : -g ; toolset.flags gcc.compile OPTIONS ; @@ -25,65 +25,30 @@ actions compile g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } -local rule link-options ( target : sources * : property-set * ) -{ - local options ; - local libs ; - local findlibs ; - for local p in $(property-set) - { - if $(p) = on - { - options += -g ; - } - else if $(p:G) = - { - options += -L$(p:G=) ; - } - else if $(p:G) = - { - findlibs += -l$(p:G=) ; - } - else if $(p:G) = - { - libs += $(p:G=) ; - } - else if $(p:G) = - { - libs += [ $(p:G=).actualize ] ; - } - } - - DEPENDS $(target) : $(LIBS) ; - - OPTIONS on $(target) = $(options) ; - LIBS on $(target) = $(libs) ; - FINDLIBS on $(target) = $(findlibs) ; -} - -rule link ( target : sources * : property-set * ) -{ - link-options $(target) : $(sources) : $(property-set) ; -} - -actions link bind LIBS -{ - g++ $(OPTIONS) -o $(<) $(>) $(LIBS) $(FINDLIBS) -} - -rule archive ( target : sources * : property-set * ) +# Declare flags and action for linking +toolset.flags gcc.link OPTIONS on : -g ; +toolset.flags gcc.link LINKPATH ; +toolset.flags gcc.link FINDLIBS ; +toolset.flags gcc.link LIBRARIES ; +toolset.flags gcc.link LIBRARIES ; + +actions link bind LIBRARIES { + g++ $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) } +# Declare action for creating static libraries actions archive { ar ur $(<) $(>) } -rule link-dll ( target : sources * : property-set * ) -{ - link-options $(target) : $(sources) : $(property-set) ; -} +# Declare flags and action for linking shared libraries +toolset.flags gcc.link-dll OPTIONS on : -g ; +toolset.flags gcc.link-dll LINKPATH ; +toolset.flags gcc.link-dll FINDLIBS ; +toolset.flags gcc.link-dll LIBRARIES ; +toolset.flags gcc.link-dll LIBRARIES ; actions link-dll bind LIBS { diff --git a/v2/test/project-test3/project-root.jam b/v2/test/project-test3/project-root.jam index a6f85e166..3826e8fe4 100644 --- a/v2/test/project-test3/project-root.jam +++ b/v2/test/project-test3/project-root.jam @@ -1,4 +1,5 @@ +import gcc ; import property ; rule yfc-compile ( target : sources * : property-set * ) diff --git a/v2/test/project-test4/project-root.jam b/v2/test/project-test4/project-root.jam index a6f85e166..3826e8fe4 100644 --- a/v2/test/project-test4/project-root.jam +++ b/v2/test/project-test4/project-root.jam @@ -1,4 +1,5 @@ +import gcc ; import property ; rule yfc-compile ( target : sources * : property-set * ) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 78384c163..6be1abd88 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -20,7 +20,7 @@ import toolset ; import errors : error ; import symlink ; -feature toolset : gcc : implicit propagated link-incompatible symmetric ; +feature toolset : : implicit propagated link-incompatible symmetric ; feature shared : false true : propagated ; feature optimization : off on : propagated ; feature threading : single multi : link-incompatible propagated ;