Boost logo

Boost-Build :

Subject: [Boost-build] generator that tracks the executable as dependency
From: George Georgiev (george.georgiev.sf_at_[hidden])
Date: 2012-12-28 17:30:33


Hi,

I am working on project that creates a code generator application. Now I
start using it in other projects, but as you may assume it is not so stable
as gcc or other generator tools. This is why I would like to add to the
dependencies the generator binary itself (or with other words in
incremental build environment if the generator binary is updated this to
trigger rebuild on all generated from it files).

I think I am almost there but I am missing how to set the dependency
feature - the line in red.

Thanks,
George

import type ;

import scanner ;

import generators ;

import feature ;

import toolset ;

import "class" : new ;

type.register COMPILSTABLE : scompil ;

feature.feature <compil-stable-binary> : : free ;

feature.feature <compil-stable-binary-dependencies> : : free dependency ;

feature.feature <compil-stable-type> : main partial test : free optional ;

class compil-stable-scanner : common-scanner

{

    rule pattern ( )

    {

        return "[ \t]*import[ \t]*\"([^\"]*)\"[ \t]*;" ;

    }

}

scanner.register compil-stable-scanner : include ;

type.set-scanner COMPILSTABLE : compil-stable-scanner ;

class compil-stable-generator : generator

{

    import modules path targets jamcompilstable ;

    rule __init__ ( * : * )

    {

        generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) :
$(8) : $(9) ;

    }

    rule tool-directory

    {

        ...

    }

    rule run ( project name ? : property-set : sources * : multiple ? )

    {

        local directory = [ tool-directory ] ;

        local compil-stable-binary-dependencies = [ path.join $(directory)
generator ] ;

        local compil-stable-binary = [ path.native
$(compil-stable-binary-dependencies) ] ;

        property-set = [ $(property-set).add-raw

            <compil-stable-binary>$(compil-stable-binary)

<compil-stable-binary-dependencies>$(compil-stable-binary-dependencies)

        ] ;

        return [ generator.run $(project) $(name) : $(property-set) :
$(sources) : $(multiple) ] ;

    }

}

generators.register [

    new compil-stable-generator jamcompilstable.generate

                         : COMPILSTABLE

                         : CPP H

                         : <compil-stable-type>main ] ;

generators.register [

    new compil-stable-generator jamcompilstable.generate

                         : COMPILSTABLE

                         : CPP(%-partial) H(%-partial)

                         : <compil-stable-type>partial ] ;

generators.register [

    new compil-stable-generator jamcompilstable.generate

                         : COMPILSTABLE

                         : CPP(%-test)

                         : <compil-stable-type>test ] ;

toolset.flags jamcompilstable.generate COMPIL-STABLE-COMMAND
<compil-stable-binary> ;

toolset.flags jamcompilstable.generate COMPIL-STABLE-DEPENDENCIES
<compil-stable-binary-dependencies> ;

toolset.flags jamcompilstable.generate COMPIL-STABLE-TYPE
<compil-stable-type> ;

toolset.flags jamcompilstable.generate IMPORTS <include> ;

rule generate ( targets * : source * : properties * )

{

    DEPENDS $(targets) : [ on $(targets) return
$(COMPIL-STABLE-DEPENDENCIES) ] ;

}

actions generate

{

    $(COMPIL-STABLE-COMMAND) -I$(IMPORTS:W) -t $(COMPIL-STABLE-TYPE)
--core-directory=core/c++ $(>) -o $(<[1]:D) || exit 1

}



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