From 7272ef9f42abd7f3a965107e511fa24f670ee83c Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sun, 10 Nov 2002 15:41:53 +0000 Subject: [PATCH] Mimimal support for the 'flags' rule. * new/toolset.jam: New file. * new/virtual-target.jam (action.actualize): Call 'toolset.set-target-variables'. * new/gcc.jam: Use flags for compiling. [SVN r16189] --- new/builtin.jam | 1 + new/gcc.jam | 35 +++++--------------- new/toolset.jam | 64 +++++++++++++++++++++++++++++++++++++ new/virtual-target.jam | 3 ++ v2/build/toolset.jam | 64 +++++++++++++++++++++++++++++++++++++ v2/build/virtual-target.jam | 3 ++ v2/gcc.jam | 35 +++++--------------- v2/tools/builtin.jam | 1 + 8 files changed, 152 insertions(+), 54 deletions(-) create mode 100644 new/toolset.jam create mode 100644 v2/build/toolset.jam diff --git a/new/builtin.jam b/new/builtin.jam index 430ec40f7..a57970fd6 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -16,6 +16,7 @@ import virtual-target ; import os ; import stage ; import prebuilt ; +import toolset ; feature toolset : gcc : implicit propagated link-incompatible ; feature shared : false true : propagated ; diff --git a/new/gcc.jam b/new/gcc.jam index d9372fa0e..65d7d9064 100644 --- a/new/gcc.jam +++ b/new/gcc.jam @@ -11,37 +11,18 @@ generators.register-c-compiler gcc.compile : C : OBJ : gcc ; rule compile ( target : sources * : property-set * ) -{ - local options ; - for local p in $(property-set) - { - if $(p) = on - { - options += -O2 ; - } - else if $(p) = on - { - options += -g ; - } - else if $(p:G) = - { - options += -D$(p:G=) ; - } - else if $(p:G) = - { - options += -I$(p:G=) ; - } - else if $(p:G) = - { - options += $(p:G=) ; - } - } - OPTIONS on $(target) = $(options) ; +{ } +toolset.flags gcc.compile OPTIONS on : -O2 ; +toolset.flags gcc.compile OPTIONS on : -g ; +toolset.flags gcc.compile OPTIONS ; +toolset.flags gcc.compile DEFINES ; +toolset.flags gcc.compile INCLUDES ; + actions compile { - g++ -ftemplate-depth-100 $(OPTIONS) -c -o $(<) $(>) + g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } local rule link-options ( target : sources * : property-set * ) diff --git a/new/toolset.jam b/new/toolset.jam new file mode 100644 index 000000000..68d6339b0 --- /dev/null +++ b/new/toolset.jam @@ -0,0 +1,64 @@ +# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# Support for toolset definition. + +import feature ; +import numbers ; + +.flag-no = 1 ; + +rule flags ( rule-or-module variable-name condition * : values * ) +{ + .$(rule-or-module).flags += $(.flag-no) ; + + .$(rule-or-module).variable.$(.flag-no) += $(variable-name) ; + .$(rule-or-module).condition.$(.flag-no) += $(condition) ; + .$(rule-or-module).values.$(.flag-no) += $(values) ; + + .flag-no = [ numbers.increment $(.flag-no) ] ; +} + + +rule set-target-variables ( rule-or-module target : properties * ) +{ + for local f in $(.$(rule-or-module).flags) + { + local variable = $(.$(rule-or-module).variable.$(f)) ; + local condition = $(.$(rule-or-module).condition.$(f)) ; + local values = $(.$(rule-or-module).values.$(f)) ; + local result ; + local found ; + + for local c in $(condition) + { + local requirements = [ feature.split $(c) ] ; + + if $(requirements:G=) + { + + if ! $(found) && $(requirements) in $(properties) + { + result += $(values) ; + found = 1 ; + } + } + else + { + for local r in $(requirements) + { + result += [ feature.get-values $(r) : $(properties) ] ; + } + } + } + if ! $(condition) + { + result = $(values) ; + } + + $(variable) on $(target) += $(result) ; + } +} + diff --git a/new/virtual-target.jam b/new/virtual-target.jam index 204eac0c6..d150da8bd 100644 --- a/new/virtual-target.jam +++ b/new/virtual-target.jam @@ -393,6 +393,9 @@ rule action ( targets + : sources * : action-name : properties * ) DEPENDS $(actual-targets) : $(actual-sources) ; + toolset.set-target-variables $(self.action-name) $(actual-targets[0]) : + $(properties) ; + $(self.action-name) $(actual-targets) : $(actual-sources) : $(properties) ; } diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam new file mode 100644 index 000000000..68d6339b0 --- /dev/null +++ b/v2/build/toolset.jam @@ -0,0 +1,64 @@ +# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# Support for toolset definition. + +import feature ; +import numbers ; + +.flag-no = 1 ; + +rule flags ( rule-or-module variable-name condition * : values * ) +{ + .$(rule-or-module).flags += $(.flag-no) ; + + .$(rule-or-module).variable.$(.flag-no) += $(variable-name) ; + .$(rule-or-module).condition.$(.flag-no) += $(condition) ; + .$(rule-or-module).values.$(.flag-no) += $(values) ; + + .flag-no = [ numbers.increment $(.flag-no) ] ; +} + + +rule set-target-variables ( rule-or-module target : properties * ) +{ + for local f in $(.$(rule-or-module).flags) + { + local variable = $(.$(rule-or-module).variable.$(f)) ; + local condition = $(.$(rule-or-module).condition.$(f)) ; + local values = $(.$(rule-or-module).values.$(f)) ; + local result ; + local found ; + + for local c in $(condition) + { + local requirements = [ feature.split $(c) ] ; + + if $(requirements:G=) + { + + if ! $(found) && $(requirements) in $(properties) + { + result += $(values) ; + found = 1 ; + } + } + else + { + for local r in $(requirements) + { + result += [ feature.get-values $(r) : $(properties) ] ; + } + } + } + if ! $(condition) + { + result = $(values) ; + } + + $(variable) on $(target) += $(result) ; + } +} + diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index 204eac0c6..d150da8bd 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -393,6 +393,9 @@ rule action ( targets + : sources * : action-name : properties * ) DEPENDS $(actual-targets) : $(actual-sources) ; + toolset.set-target-variables $(self.action-name) $(actual-targets[0]) : + $(properties) ; + $(self.action-name) $(actual-targets) : $(actual-sources) : $(properties) ; } diff --git a/v2/gcc.jam b/v2/gcc.jam index d9372fa0e..65d7d9064 100644 --- a/v2/gcc.jam +++ b/v2/gcc.jam @@ -11,37 +11,18 @@ generators.register-c-compiler gcc.compile : C : OBJ : gcc ; rule compile ( target : sources * : property-set * ) -{ - local options ; - for local p in $(property-set) - { - if $(p) = on - { - options += -O2 ; - } - else if $(p) = on - { - options += -g ; - } - else if $(p:G) = - { - options += -D$(p:G=) ; - } - else if $(p:G) = - { - options += -I$(p:G=) ; - } - else if $(p:G) = - { - options += $(p:G=) ; - } - } - OPTIONS on $(target) = $(options) ; +{ } +toolset.flags gcc.compile OPTIONS on : -O2 ; +toolset.flags gcc.compile OPTIONS on : -g ; +toolset.flags gcc.compile OPTIONS ; +toolset.flags gcc.compile DEFINES ; +toolset.flags gcc.compile INCLUDES ; + actions compile { - g++ -ftemplate-depth-100 $(OPTIONS) -c -o $(<) $(>) + g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } local rule link-options ( target : sources * : property-set * ) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 430ec40f7..a57970fd6 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -16,6 +16,7 @@ import virtual-target ; import os ; import stage ; import prebuilt ; +import toolset ; feature toolset : gcc : implicit propagated link-incompatible ; feature shared : false true : propagated ;