|
Boost-Build : |
From: hf_pabst (hfp_at_[hidden])
Date: 2005-06-24 09:01:29
Hello,
is there any need for an extended lib rule? My personal use-case will
be described here...
At the end, a little bit jam code will follow...
--- Export/import symbols into/from a DLL without the need of a top-level header. Such a typical header is now (logically) moved into the build system. Exporting becomes naturally a 'requirement' and importing will be an 'usage-requirement'. In case of more than one component (dll) per main-projects with inter- dependencies, that mean importing and exporting symbols for a single component at the same time, you can't have a simple control header that says 'dllexport' or(!) 'dllimport'. It's needed to tag each component with an own (unique) symbol. Now you have dllexport/dllimport per component (symbol). This 'dll.lib' rule provides the standard to use the target name (uppercase) as symbol for the preprocessor and define it automatically with dllexport, dllimport or nothing (link static). The target name should always unique per component. Everything that needs to be exported/imported is named (tagged) naturally with the component name, i.e: class LIBMYCOMPONENT my_type { ... }; The 'dll.lib' rule use the original 'lib' rule and provides the same arguments and argument order. If you need a symbol name that isn't derived from the target name, you can use the optional 6'th argument to define an own symbol. If you hold helper jamfiles in a local directory you only need one statement, i.e.: import build/dll : lib ; in your top-level jamfile ("the project") before any targed definition, where './build' contain this file ('dll.jam'). The 'lib' option after the colon prevents you from writing: dll.lib ... Now you can use an unqualified dll.lib (without dll): lib ... This is like a replacement of the built-in 'lib' rule. ---- jam code --- rule lib ( names + : sources * : requirements * : default-build * : usage-requirements * : symbol ? ) { echo $(names)": using extended version of 'lib' rule" ; if ! $(symbol) { # By default use the uppercase name symbol = $(names:U) ; } import os ; if [ os.on-windows ] { requirements += <link>shared:<define>$(symbol)=__declspec(dllexport) <link>static:<define>$(symbol)="" ; usage-requirements += <link>shared:<define>$(symbol)=__declspec(dllimport) <link>static:<define>$(symbol)="" ; } else { requirements += <define>$(symbol)="" ; usage-requirements += <define>$(symbol)="" ; } import builtin : lib : builtin.lib ; builtin.lib $(names) : $(sources) : $(requirements) : $(default- build) : $(usage-requirements) ; }
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