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

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]
This commit is contained in:
Vladimir Prus
2002-11-10 15:41:53 +00:00
parent 279c8ef3f8
commit 7272ef9f42
8 changed files with 152 additions and 54 deletions

View File

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

View File

@@ -11,37 +11,18 @@ generators.register-c-compiler gcc.compile : C : OBJ : <toolset>gcc ;
rule compile ( target : sources * : property-set * )
{
local options ;
for local p in $(property-set)
{
if $(p) = <optimization>on
{
options += -O2 ;
}
else if $(p) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <define>
{
options += -D$(p:G=) ;
}
else if $(p:G) = <include>
{
options += -I$(p:G=) ;
}
else if $(p:G) = <cxxflags>
{
options += $(p:G=) ;
}
}
OPTIONS on $(target) = $(options) ;
{
}
toolset.flags gcc.compile OPTIONS <optimization>on : -O2 ;
toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
toolset.flags gcc.compile OPTIONS <cxxflags> ;
toolset.flags gcc.compile DEFINES <define> ;
toolset.flags gcc.compile INCLUDES <include> ;
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 * )

64
new/toolset.jam Normal file
View File

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

View File

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

64
v2/build/toolset.jam Normal file
View File

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

View File

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

View File

@@ -11,37 +11,18 @@ generators.register-c-compiler gcc.compile : C : OBJ : <toolset>gcc ;
rule compile ( target : sources * : property-set * )
{
local options ;
for local p in $(property-set)
{
if $(p) = <optimization>on
{
options += -O2 ;
}
else if $(p) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <define>
{
options += -D$(p:G=) ;
}
else if $(p:G) = <include>
{
options += -I$(p:G=) ;
}
else if $(p:G) = <cxxflags>
{
options += $(p:G=) ;
}
}
OPTIONS on $(target) = $(options) ;
{
}
toolset.flags gcc.compile OPTIONS <optimization>on : -O2 ;
toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
toolset.flags gcc.compile OPTIONS <cxxflags> ;
toolset.flags gcc.compile DEFINES <define> ;
toolset.flags gcc.compile INCLUDES <include> ;
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 * )

View File

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