我有一个小的Jamfile,我使用Boost Build进行处理,如下所示:
exe add-account : add-account.cpp ..//server-lib ../../shared//shared ;
exe add-deck : add-deck.cpp ..//server-lib ../../shared//shared ;
exe give-all-cards : give-all-cards.cpp ..//server-lib ../../shared//shared ;
exe give-card : give-card.cpp ..//server-lib ../../shared//shared ;
install . :
add-account
add-deck
give-all-cards
give-card
;
我觉得我应该能够通过某种模板来做到这一点。我一直在Boost Build user manual环顾四周,但我们找不到能帮助我的语言规则。
可能值得一提的是,我意识到更多代码可能不是最好的解决方案,但我仍然感兴趣,如果可以做到的话。如果我想编译一个充满单个源文件程序的整个目录,它至少会很有用。
答案 0 :(得分:2)
有几种方法可以使这更简洁。仅仅是为了说明:
local exe-list = add-account add-deck give-all-cards give-card ;
for exe-file in $(exe-list)
{
exe $(exe-file) : $(exe-file).cpp ..//server-lib ../../shared//shared ;
}
install . : $(exe-list) ;
您还可以创建帮助规则。
rule simple-exe ( name )
{
exe $(name) : $(name).cpp ..//server-lib ../../shared//shared ;
}
local exe-list = add-account add-deck give-all-cards give-card ;
for exe-file in $(exe-list)
{
simple-exe $(exe-file) ;
}
install . : $(exe-list) ;
此外 - 如果经常使用相同的库依赖项,则可以将它们放入alias
alias common : ..//server-lib ../../shared//shared ;
exe add-account : add-account.cpp common ;
exe add-deck : add-deck.cpp common ;
exe give-all-cards : give-all-cards.cpp common ;
exe give-card : give-card.cpp common ;
或project requirements
project my-project : requirements
<library>..//server-lib
<library../../shared//shared
;
exe add-account : add-account.cpp ;
exe add-deck : add-deck.cpp ;
exe give-all-cards : give-all-cards.cpp ;
exe give-card : give-card.cpp ;
这些技术的某些组合应该可以解决问题。