[ create a new paste ] login | about

Link: http://codepad.org/nZuE8ppq    [ raw code | fork ]

Plain Text, pasted on Aug 19:
import "class" : new ;
import type ;
import targets ;
import generators ;

path-constant BOOST_PATH : C:/bumbershoot/src/pwiz-src/libraries/boost_1_39_0 ;

exe bcp
: # sources
    [ glob $(location)/tools/bcp/*.cpp ]
    filesystem
    regex
    prg_exec_monitor
: # requirements
;

type.register BCP : bcp ;

path-constant BOOST_PATH : $(location) ;

actions bcp.create
{
    C:\bumbershoot\src\pwiz-src\build\ext\boost\boost\msvc-9.0\release\link-static\threading-multi\bcp.exe --scan --boost=$(BOOST_PATH) --module-list-file=module_list.txt $(<:D)
}

class bcp-generator : generator
{
    rule recurse-to-sources ( roots * )
    {
        local real-sources ;
        for local r in $(roots)
        {
            #echo "r: " [ $(r).str ] ;
            local temp = [ virtual-target.traverse $(r) : include-root : include-sources ] ;
            for local t in $(temp[2-])
            {
                #echo "t: " [ $(t).str ] ;
                if ! $(t) = $(r) &&
                   [ type.is-derived [ $(t).type ] EXE ] ||
                   [ type.is-derived [ $(t).type ] LIB ] ||
                   [ type.is-derived [ $(t).type ] OBJ ] ||
                   [ type.is-derived [ $(t).type ] UNIT_TEST ] ||
                   [ type.is-derived [ $(t).type ] TEST ]
                {
                    real-sources += [ recurse-to-sources $(t) ] ;
                }
                else if [ type.is-derived [ $(t).type ] CPP ] ||
                        [ type.is-derived [ $(t).type ] HPP ] ||
                        [ type.is-derived [ $(t).type ] C ] ||
                        [ type.is-derived [ $(t).type ] H ]
                {
                    real-sources += $(t) ;
                }
                else
                {
                    echo "Warning: ignoring dependency with unknown type:" [ $(t).str ] ;
                }
            }
        }
        return $(real-sources) ;
    }


    rule generated-targets ( sources + : property-set : project name ? )
    {
        #for local r in $(sources) { echo "Input source: " [ $(r).str ] ; }
        local real-sources = [ sequence.unique [ recurse-to-sources $(sources) ] ] ;
        #for local r in $(real-sources) { echo "Real source: " [ $(r).path ] ; }

        local modules ;
        for local source in $(real-sources)
        {
            local source-name = [ $(source).name ] ;
            if ! [ path.is-rooted $(source-name) ]
            {
                modules += [ path.native [ path.join [ $(source).path ] $(source-name) ] ] ;
            }
            else
            {
                modules += [ path.native $(source-name) ] ;
            }
        }

        local NL = "
" ;
        module-list = $(modules:J=$(NL)) ;
        local f = @(module_list.txt:E=$(module-list)) ;

        return [ generator.generated-targets $(real-sources)
            : $(property-set) : $(project) $(name) ] ;
    }
}

generators.register [ new bcp-generator ext-boost.bcp.create true : : BCP ] ;


########################################
# The public interface for running bcp #
########################################
rule copy-boost-dependencies ( target-name : sources + : requirements * )
{
    targets.create-typed-target BCP : [ project.current ] : $(target-name) :
        $(sources) : $(requirements) ;
}



# a library target to copy the boost dependencies of
lib boost_program_options : [ glob $(BOOST_PATH)/libs/program_options/src/*.cpp ] ;

# the call to copy those dependencies to the directory bcp-output
copy-boost-dependencies bcp_task : boost_program_options : <location>bcp-output ;


Create a new paste based on this one


Comments: