BJam 小技巧:indirect conditional
1241713550|%Y-%m-%d|agohover
問題:使用不同的編譯參數時,想用 install rule 把結果安裝到不同的目錄下。比如以下的 Jamfile:
lib foo : foo.cpp ;
install dist : foo
: <toolset>gcc,<variant>debug:<location>"gcc/debug"
<toolset>gcc,<variant>release:<location>"gcc/release"
<toolset>msvc,<variant>debug:<location>"msvc/debug"
<toolset>msvc,<variant>release:<location>"msvc/release"
;
當我們有更多的選項組合時,窮舉法絕對不是好主意!有什麼方法可以改進?
答案是使用一個稱為 indirect conditional requirements 的功能。語法如下:
import property-set ;
lib foo : foo.cpp ;
install dist : foo : <conditional>@get-location ;
rule get-location ( properties * )
{
local pset = [ property-set.create $(properties) ] ;
local toolset = [ $(pset).get <toolset> ] ;
local variant = [ $(pset).get <variant> ] ;
return <location>$(toolset)/$(variant) ;
}
Comments
page revision: 2, last edited: 07 May 2009 16:33
Post preview:
Close preview