Boost logo

Boost-Build :

From: Motonari Ito (motonarii_at_[hidden])
Date: 2007-05-23 22:39:35


Hello,

 

Let's say, you have an executable (foo.exe) and DLL (bar.dll). In debug
build, the DLL is renamed to "bar-d.dll" (See List-1). Now, the
executable wants to LoadLibrary() the DLL. (See List-2). Is it possible
to pass the actual DLL filename to foo.exe so that foo.exe can load the
correct DLL for release / debug builds?

 

 

##########################

# List-1

##########################

import virtual-target : add-prefix-and-suffix ;

 

rule rename ( name : type ? : property-set ) {

    local postfix ;

    local properties = [ $(property-set).raw ] ;

    if <variant>debug in $(properties) { postfix += d ; }

    

    local result = $(name)-$(postfix:J=-) ;

    

    return [ add-prefix-and-suffix $(result) : $(type) : $(property-set)
] ; }

 

lib bar : bar.cpp

        : <tag>@rename

          <link>shared

;

 

exe foo : foo.cpp

        : <define>FOO_FILENAME=????

;

 

install . : bar foo ;

 

##########################

# List-2

##########################

 

#define STRING(s) # s

#define XSTRING(s) STRING(s)

 

int main(){

  // ...

  LoadLibrary(XSTRING(FOO_FILENAME))

  // ...

}

 

Motonari Ito

 

 



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