|
Boost-Build : |
Subject: Re: [Boost-build] How to remove code duplication from Jamfile
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-03-19 12:06:19
On Friday 19 March 2010 17:56:40 Ðвгений ШÑбин wrote:
> I have have a project with Jamroot, which consists of some subprojects with Jamfiles.
> In each Jamfile I have this block of code:
> ...
>
> DAEMON_NAME = daemon_name ; #specific for each subproject
>
>
> explicit install install-bin install-conf $(INSTALL_PATH)/scripts/$(DAEMON_NAME) ;
>
>
>
> Could anyone explain me how to move this block of code to Jamroot of top project?
You can put this in Jamroot:
constant JAMROOT : $(__name__) ;
actions transform-script
{
sed "s_at_PREFIX@$(INSTALL_PATH)@g" $(>) | sed "s_at_NAME@$(DAEMON_NAME)@g" > $(<)
}
rule your-install ( DAEMON_NAME )
{
alias install : install-bin install-conf $(INSTALL_PATH)/scripts/$(DAEMON_NAME) ;
install install-bin : $(DAEMON_NAME) : <location>$(INSTALL_PATH)/bin ;
install install-conf : ../../conf/$(DAEMON_NAME).conf : <location>$(INSTALL_PATH)/conf ;
make $(INSTALL_PATH)/scripts/$(DAEMON_NAME) : ../../scripts/rc_script.freebsd : @$(JAMROOT).transform-script ;
}
and then have:
your-install some-daemon ;
inside Jamfile for each component. Does this work?
Thanks,
-- Vladimir Prus http://vladimir_prus.blogspot.com Boost.Build: http://boost.org/boost-build2
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk