2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 13:02:11 +00:00

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]
This commit is contained in:
Vladimir Prus
2002-11-27 09:35:53 +00:00
parent b12a902687
commit 0afa3aa911
10 changed files with 122 additions and 122 deletions

View File

@@ -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 ;

View File

@@ -2,7 +2,10 @@
import property ;
import generators ;
import os ;
feature.extend toolset : gcc ;
# Declare generators
generators.register-composing gcc.link : LIB OBJ : EXE : <toolset>gcc ;
generators.register-composing gcc.archive : OBJ : STATIC_LIB : <toolset>gcc ;
generators.register-composing gcc.link-dll : OBJ : SHARED_LIB : <toolset>gcc ;
@@ -10,10 +13,7 @@ generators.register-c-compiler gcc.compile : CPP : OBJ : <toolset>gcc ;
generators.register-c-compiler gcc.compile : C : OBJ : <toolset>gcc ;
rule compile ( target : sources * : property-set * )
{
}
# Declare flags and action for compilation
toolset.flags gcc.compile OPTIONS <optimization>on : -O2 ;
toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
toolset.flags gcc.compile OPTIONS <cxxflags> ;
@@ -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) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <library-path>
{
options += -L$(p:G=) ;
}
else if $(p:G) = <find-library>
{
findlibs += -l$(p:G=) ;
}
else if $(p:G) = <library-file>
{
libs += $(p:G=) ;
}
else if $(p:G) = <library>
{
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 <debug-symbols>on : -g ;
toolset.flags gcc.link LINKPATH <library-path> ;
toolset.flags gcc.link FINDLIBS <find-library> ;
toolset.flags gcc.link LIBRARIES <library-file> ;
toolset.flags gcc.link LIBRARIES <library> ;
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 <debug-symbols>on : -g ;
toolset.flags gcc.link-dll LINKPATH <library-path> ;
toolset.flags gcc.link-dll FINDLIBS <find-library> ;
toolset.flags gcc.link-dll LIBRARIES <library-file> ;
toolset.flags gcc.link-dll LIBRARIES <library> ;
actions link-dll bind LIBS
{

View File

@@ -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) ;
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
import gcc ;
import property ;
rule yfc-compile ( target : sources * : property-set * )

View File

@@ -1,4 +1,5 @@
import gcc ;
import property ;
rule yfc-compile ( target : sources * : property-set * )

View File

@@ -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) ;
}
}
}
}
}

View File

@@ -2,7 +2,10 @@
import property ;
import generators ;
import os ;
feature.extend toolset : gcc ;
# Declare generators
generators.register-composing gcc.link : LIB OBJ : EXE : <toolset>gcc ;
generators.register-composing gcc.archive : OBJ : STATIC_LIB : <toolset>gcc ;
generators.register-composing gcc.link-dll : OBJ : SHARED_LIB : <toolset>gcc ;
@@ -10,10 +13,7 @@ generators.register-c-compiler gcc.compile : CPP : OBJ : <toolset>gcc ;
generators.register-c-compiler gcc.compile : C : OBJ : <toolset>gcc ;
rule compile ( target : sources * : property-set * )
{
}
# Declare flags and action for compilation
toolset.flags gcc.compile OPTIONS <optimization>on : -O2 ;
toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
toolset.flags gcc.compile OPTIONS <cxxflags> ;
@@ -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) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <library-path>
{
options += -L$(p:G=) ;
}
else if $(p:G) = <find-library>
{
findlibs += -l$(p:G=) ;
}
else if $(p:G) = <library-file>
{
libs += $(p:G=) ;
}
else if $(p:G) = <library>
{
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 <debug-symbols>on : -g ;
toolset.flags gcc.link LINKPATH <library-path> ;
toolset.flags gcc.link FINDLIBS <find-library> ;
toolset.flags gcc.link LIBRARIES <library-file> ;
toolset.flags gcc.link LIBRARIES <library> ;
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 <debug-symbols>on : -g ;
toolset.flags gcc.link-dll LINKPATH <library-path> ;
toolset.flags gcc.link-dll FINDLIBS <find-library> ;
toolset.flags gcc.link-dll LIBRARIES <library-file> ;
toolset.flags gcc.link-dll LIBRARIES <library> ;
actions link-dll bind LIBS
{

View File

@@ -1,4 +1,5 @@
import gcc ;
import property ;
rule yfc-compile ( target : sources * : property-set * )

View File

@@ -1,4 +1,5 @@
import gcc ;
import property ;
rule yfc-compile ( target : sources * : property-set * )

View File

@@ -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 ;