📄 toolset.jam
字号:
# may need to be in a specific order. if ! [ MATCH (&&) : $(p:G=) ] { values = $(p:G=) ; } else { values = [ regex.split $(p:G=) "&&" ] ; } if path in $(att) { result += [ sequence.transform path.native : $(values) ] ; } else { result += $(values) ; } } else { result += $(p:G=) ; } } } else { result += $(value) ; } return $(result) ;}# Given a rule name and a property set, returns a list of interleaved variables# names and values which must be set on targets for that rule/property-set# combination.#rule set-target-variables-aux ( rule-or-module : property-set ){ local result ; properties = [ $(property-set).raw ] ; 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)) ; if ! $(condition) || [ find-property-subset $(condition) : $(properties) ] { local processed ; for local v in $(values) { # The value might be <feature-name> so needs special treatment. processed += [ handle-flag-value $(v) : $(properties) ] ; } for local r in $(processed) { result += $(variable) $(r) ; } } } # Strip away last dot separated part and recurse. local next = [ MATCH ^(.+)\\.([^\\.])* : $(rule-or-module) ] ; if $(next) { result += [ set-target-variables-aux $(next[1]) : $(property-set) ] ; } return $(result) ;}rule set-target-variables ( rule-or-module targets + : property-set ){ properties = [ $(property-set).raw ] ; local key = $(rule-or-module).$(property-set) ; local settings = $(.stv.$(key)) ; if ! $(settings) { settings = [ set-target-variables-aux $(rule-or-module) : $(property-set) ] ; if ! $(settings) { settings = none ; } .stv.$(key) = $(settings) ; } if $(settings) != none { local var-name = ; for local name-or-value in $(settings) { if $(var-name) { $(var-name) on $(targets) += $(name-or-value) ; var-name = ; } else { var-name = $(name-or-value) ; } } }}# Make toolset 'toolset', defined in a module of the same name, inherit from# 'base'.# 1. The 'init' rule from 'base' is imported into 'toolset' with full name.# Another 'init' is called, which forwards to the base one.# 2. All generators from 'base' are cloned. The ids are adjusted and <toolset># property in requires is adjusted too.# 3. All flags are inherited.# 4. All rules are imported.#rule inherit ( toolset : base ){ import $(base) ; inherit-generators $(toolset) : $(base) ; inherit-flags $(toolset) : $(base) ; inherit-rules $(toolset) : $(base) ;}rule inherit-generators ( toolset properties * : base : generators-to-ignore * ){ properties ?= <toolset>$(toolset) ; local base-generators = [ generators.generators-for-toolset $(base) ] ; for local g in $(base-generators) { local id = [ $(g).id ] ; if ! $(id) in $(generators-to-ignore) { # Some generator names have multiple periods in their name, so # $(id:B=$(toolset)) does not generate the right new-id name. E.g. # if id = gcc.compile.c++ then $(id:B=darwin) = darwin.c++, which is # not what we want. Manually parse the base and suffix. If there is # a better way to do this, I would love to see it. See also the # register() rule in the generators module. local base = $(id) ; local suffix = "" ; while $(base:S) { suffix = $(base:S)$(suffix) ; base = $(base:B) ; } local new-id = $(toolset)$(suffix) ; generators.register [ $(g).clone $(new-id) : $(properties) ] ; } }}# Brings all flag definitions from the 'base' toolset into the 'toolset'# toolset. Flag definitions whose conditions make use of properties in# 'prohibited-properties' are ignored. Do not confuse property and feature, for# example <debug-symbols>on and <debug-symbols>off, so blocking one of them does# not block the other one.## The flag conditions are not altered at all, so if a condition includes a name,# or version of a base toolset, it will not ever match the inheriting toolset.# When such flag settings must be inherited, define a rule in base toolset# module and call it as needed.#rule inherit-flags ( toolset : base : prohibited-properties * ){ for local f in $(.module-flags.$(base)) { local rule-or-module = $(.rule-or-module.$(f)) ; if [ set.difference $(.$(rule-or-module).condition.$(f)) : $(prohibited-properties) ] || ! $(.$(rule-or-module).condition.$(f)) { local rule_ = [ MATCH "[^.]*\.(.*)" : $(rule-or-module) ] ; local new-rule-or-module ; if $(rule_) { new-rule-or-module = $(toolset).$(rule_) ; } else { new-rule-or-module = $(toolset) ; } add-flag $(new-rule-or-module) : $(.$(rule-or-module).variable.$(f)) : $(.$(rule-or-module).condition.$(f)) : $(.$(rule-or-module).values.$(f)) ; } }}rule inherit-rules ( toolset : base ){ # It appears that "action" creates a local rule. local base-generators = [ generators.generators-for-toolset $(base) ] ; local rules ; for local g in $(base-generators) { local id = [ MATCH "[^.]*\.(.*)" : [ $(g).id ] ] ; rules += $(id) ; } IMPORT $(base) : $(rules) : $(toolset) : $(rules) ; IMPORT $(base) : $(rules) : : $(toolset).$(rules) ;}# Return the list of global 'toolset requirements'. Those requirements will be# automatically added to the requirements of any main target.#rule requirements ( ){ return $(.requirements) ;}# Adds elements to the list of global 'toolset requirements'. The requirements# will be automatically added to the requirements for all main targets, as if# they were specified literally. For best results, all requirements added should# be conditional or indirect conditional.#rule add-requirements ( requirements * ){ if ! $(.ignore-requirements) { .requirements += $(requirements) ; }}rule __test__ ( ){ import assert ; local p = <b>0 <c>1 <d>2 <e>3 <f>4 ; assert.result <c>1/<d>2/<e>3 : find-property-subset <c>1/<d>2/<e>3 <a>0/<b>0/<c>1 <d>2/<e>5 <a>9 : $(p) ; assert.result : find-property-subset <a>0/<b>0/<c>9/<d>9/<e>5 <a>9 : $(p) ; local p-set = <a>/<b> <a>0/<b> <a>/<b>1 <a>0/<b>1 ; assert.result <a>/<b> : find-property-subset $(p-set) : ; assert.result <a>0/<b> : find-property-subset $(p-set) : <a>0 <c>2 ; assert.result <a>/<b>1 : find-property-subset $(p-set) : <b>1 <c>2 ; assert.result <a>0/<b>1 : find-property-subset $(p-set) : <a>0 <b>1 ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -