|
Boost-Build : |
Subject: Re: [Boost-build] how to use exe target from generator tool
From: George Georgiev (george.georgiev.sf_at_[hidden])
Date: 2012-02-29 10:32:01
Hi Steven,
This was extremely helpful. Now I have all my compil files compiled
and if I change the generator code it makes the compil files to be
regenerated. If a compil file is changed the dependent compil files
are regenerated too.
I have the following issues that I still need to resolve. If you give
me some pointers it will be great.
1. The generated code is a cpp and header file. If a compil file A
imports compil file B, the generated cpp file A will include the
header file of B. This means I need to make sure that the header and
cpp files for B are generated before A cpp is compiled. Also how to
make the header files for one compil included for the dependent cpp
files.
2. Obviously the generated header files are used from other
non-generated cpp files too. I need to make sure these cpp files that
directly or indirectly depend on generated header file are compiled
after the headers are generated/updated. And again how to make these
header files visible.
My jam code so far is:
import type ;
import scanner ;
import generators ;
import feature ;
import toolset ;
import "class" : new ;
type.register COMPIL : compil ;
feature.feature <compil-binary> : : free ;
feature.feature <compil-binary-dependencies> : : free dependency ;
class compil-scanner : common-scanner
{
rule pattern ( )
{
return "[ \t]*import[ \t]*\"([^\"]*)\"[ \t]*;" ;
}
}
scanner.register compil-scanner : include ;
type.set-scanner COMPIL : compil-scanner ;
class compil-generator : generator
{
import modules path targets jamcompil ;
rule run ( project name ? : property-set : sources * : multiple ? )
{
local compil-binary = [ modules.peek jamcompil : .compil-binary ] ;
local compil-binary-dependencies ;
local compil-main-target = [ targets.resolve-reference
/generator : $(project) ] ;
compil-main-target =
[ $(compil-main-target[1]).main-target generator ] ;
compil-binary-dependencies =
[ $(compil-main-target).generate [ $(property-set).propagated ] ] ;
# Ignore usage-requirements returned as first element.
compil-binary-dependencies = $(compil-binary-dependencies[2-]) ;
for local target in $(compil-binary-dependencies)
{
if [ $(target).type ] = EXE
{
compil-binary =
[ path.native
[ path.join
[ $(target).path ]
[ $(target).name ]
]
] ;
}
}
property-set = [ $(property-set).add-raw
<dependency>$(compil-binary-dependencies)
<compil-binary>$(compil-binary)
<compil-binary-dependencies>$(compil-binary-dependencies)
] ;
return [ generator.run $(project) $(name) : $(property-set) :
$(sources) : $(multiple) ] ;
}
}
generators.register [ new compil-generator jamcompil.generate : COMPIL : CPP ] ;
toolset.flags jamcompil.generate COMPIL-COMMAND <compil-binary> ;
toolset.flags jamcompil.generate COMPIL-DEPENDENCIES
<compil-binary-dependencies> ;
rule generate ( target : source * : properties * )
{
DEPENDS $(target) : [ on $(target) return $(COMPIL-DEPENDENCIES) ] ;
}
actions generate
{
$(COMPIL-COMMAND) $(>) -o $(<:D)
}
Thank you,
George
On Tue, Feb 28, 2012 at 1:25 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> On 02/25/2012 07:42 PM, George Georgiev wrote:
>> I am Boost.Build newbie. I have project that is generator itself. And
>> I have second project that should use the just compiled generator tool
>> to produce cpp and header files.
>>
>
> Look at the quickbook toolset. It has some
> features that you don't need, but the important
> part is to
> a) define a feature to pass the tool executable
> b) Create a custom generator class that adds
> a dependency on your tool.
> c) use toolset.flags to convert the feature to
> a VARIABLE in the updating action.
>
>> My generation jam code so far looks like:
>>
>> //////////////// jamcompil ////////////////
>> rule generate ( target : source * : properties * )
>> {
>> echo $(target) $(source) ;
>> }
>>
>> actions generate
>> {
>> generator $(<) $(>)
>> }
>>
>> //////////////// jamfile ////////////////
>> import type ;
>> import scanner ;
>> import generators ;
>> import jamcompil ;
>>
>> type.register COMPIL : compil ;
>>
>> class compil-scanner : common-scanner
>> {
>> rule pattern ( )
>> {
>> return "[ \t]*import[ \t]*\"([^\"]*)\"[ \t]*;" ;
>> }
>> }
>>
>> scanner.register compil-scanner : include ;
>>
>> type.set-scanner COMPIL : compil-scanner ;
>> generators.register-standard jamcompil.generate : COMPIL : CPP ;
>>
>>
>> I cannot find how to specify the jamcompil generate actions to use the
>> executable compiled from the other project. How it to take the
>> executable from the exact location and how to make the target to
>> depend on it - if it is updated this to cause the targets to be
>> regenerated
>>
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
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