Boost logo

Boost-Build :

From: Pedro Ferreira (pedro.ferreira_at_[hidden])
Date: 2003-12-16 10:08:40


------=_NextPart_001_00E0_01C3C3E6.7D2C5E60 Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

As far as I know, with BBv2 it is not possible to stage files of different =
types to different locations.
For instance, we usually place import libs in a 'lib' directory and shared =
libs and exe in a 'bin' directory.

So, I've hacked stage.jam and:

- Refactored stage-target-class::construct
- Moved the logic to get the <location> value out of the class
- Moved the responsibility of setting the path to the STAGED_* type impleme=
ntations
- Added generators for staged shared, static and imports libs
- Added the dll-location and lib-location features

The corresponding patch is attached.

This allows one to say:

stage stage-MXFParser=20
: MXFParser=20
: <location>bin <lib-location>lib
;

And it will place everything in bin, except static and import libs which wi=
ll go to lib.

This is most probably not the best approach to do this. I would prefer, for=
instance to say something like:

<type>STATIC_LIB:<location>lib
<location>bin

Comments?

Cheers,

Pedro

 ------=_NextPart_001_00E0_01C3C3E6.7D2C5E60 Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"=
>
<META content=3D"MSHTML 6.00.2734.1600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As far as I know, with BBv2 it is not poss=
ible to=20
stage files of different types to different locations.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For instance, we usually place import libs=
in a=20
'lib' directory and shared libs and exe in a 'bin' directory.</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So, I've hacked stage.jam and:</FONT></DIV=
>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial size=3D2></FONT><=
FONT=20
face=3DArial size=3D2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- Refactored=20
stage-target-class::construct</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>- Moved the logic to get the &lt;location&=
gt; value=20
out of the class</FONT></DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>- Moved the responsibility of setting the =
path to=20
the STAGED_* type implementations</FONT></DIV>
<DIV>- Added generators for staged shared, static and imports libs</DIV>
<DIV>- Added the dll-location and lib-location features</DIV>
<DIV>&nbsp;</DIV>
<DIV>The corresponding&nbsp;patch is attached.</DIV>
<DIV>&nbsp;</DIV>
<DIV>This allows one to say:</DIV>
<DIV>&nbsp;</DIV>
<DIV>stage stage-MXFParser </DIV>
<DIV>&nbsp;&nbsp;&nbsp; :&nbsp;MXFParser </DIV>
<DIV>&nbsp;&nbsp;&nbsp; : &lt;location&gt;bin &lt;lib-location&gt;lib</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ;</DIV>
<DIV>&nbsp;</DIV>
<DIV>And it will place everything in bin, except static and import libs whi=
ch=20
will go to lib.</DIV>
<DIV>&nbsp;</DIV>
<DIV>This is most probably not the best approach to do this. I would prefer=
, for=20
instance to say something like:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&lt;type&gt;STATIC_LIB:&lt;location&gt;lib</DIV>
<DIV>&lt;location&gt;bin</DIV>
<DIV>&nbsp;</DIV>
<DIV>Comments?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Cheers,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Pedro</DIV>
<DIV>&nbsp;</DIV></FONT></BODY></HTML>
 ------=_NextPart_001_00E0_01C3C3E6.7D2C5E60-- ------=_NextPart_000_00DF_01C3C3E6.7D2C5E60 Content-Type: text/plain;
name="patch.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="patch.txt"

Index: boost-build/tools/stage.jam
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/cvs/Workspace/boost-build/tools/stage.jam,v
retrieving revision 1.4
diff -u -r1.4 stage.jam
--- boost-build/tools/stage.jam 15 Dec 2003 17:46:02 -0000 1.4
+++ boost-build/tools/stage.jam 16 Dec 2003 15:05:29 -0000
@@ -59,6 +59,15 @@
=20
feature.feature <traverse-dependencies> : off on : incidental ;
feature.feature <include-type> : : free incidental ;
+feature.feature <dll-location> : : free path ;
+feature.feature <lib-location> : : free path ;
+
+rule get-location ( property-set )
+{
+ return [ feature.get-values <location> :=20
+ [ $(property-set).raw ] ] ;
+}
+IMPORT $(__name__) : get-location : : get-location ;
=20
class stage-target-class : basic-target
{
@@ -70,7 +79,65 @@
basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : =
$(requirements)=20
: $(default-build) ;
}
+
+ # If <location> is not set, sets it based on the project data.
+ rule update-location ( property-set )
+ {
+ local loc =3D [ get-location $(property-set) ] ;
+ if ! $(loc)
+ {
+ loc =3D [ project.path-relative-to-project-location $(self.nam=
e)
+ $(self.project) ] ;
+
+ property-set =3D [ $(property-set).add-raw $(loc:G=3D<location=
>) ] ;
+ }
+=20=20=20=20=20=20=20=20
+ return $(property-set) ;
+ }
=20=20=20=20=20=20=20=20=20
+ # Constructs the targets of types for which a type exists
+ # with the form STAGED_*.
+ rule construct-special-targets ( property-set : source : type )
+ {
+ local targets =3D [ generators.construct $(self.project) : $(type)=
:
+ $(property-set) : $(source) : * ] ;
+
+ return $(targets) ;
+ }
+=20=20=20=20
+ # Constructs the targets of types for which there is no STAGED_* type.
+ rule construct-regular-targets ( property-set : source )
+ {
+ local n =3D [ $(source).name ] ;
+ if $(name)
+ {
+ n =3D $(name) ;
+ }
+=20=20=20=20=20=20=20=20
+ targets =3D [ new file-target $(n:D=3D) : [ $(source).type ]=20
+ : $(self.project) ] ;
+ local a =3D [ $(source).action ] ;
+ local new-a ;
+ if $(a)
+ {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ # Copy the properties of original target. They, in particular
+ # can affect the suffix of the target.
+ new-a =3D [ new action $(targets) : $(source) : common.copy : =
[ $(a).properties ] ] ;
+ }
+ else
+ {
+ new-a =3D [ new action $(targets) : $(source) : common.copy ] =
;
+ } =
=20
+ $(targets).suffix [ $(source).suffix ] ;
+ $(targets).action $(new-a) ;
+=20=20=20=20
+ # FIXME: Since we can have <location> property, it might be better
+ # to use it to distinguish staged copies with different locations.
+ $(targets).set-path [ get-location $(property-set) ] ;
+
+ return $(targets) ;
+ }
+=20=20=20=20
rule construct ( source-targets * : property-set )
{
local name =3D [ $(property-set).get <name> ] ;
@@ -84,68 +151,41 @@
source-targets =3D [ collect-targets $(source-targets)=20
: [ $(property-set).get <include-type> ] ] ;
}
- =
=20
- local location =3D [ feature.get-values <location> :=20
- [ $(property-set).raw ] ] ;
- if ! $(location)
- {
- location =3D [ project.path-relative-to-project-location $(sel=
f.name)
- $(self.project) ] ;
- }
-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+
+ property-set =3D [ update-location $(property-set) ] ;
+
local result ;
for local i in $(source-targets)
{
- local i2 ; # Staged target(s)
-=20=20=20=20=20=20=20=20=20=20=20=20
- local t =3D [ $(i).type ] ;=20=20=20=20=20=20=20=20=20=20=20
-=20=20=20=20=20=20=20=20=20=20=20=20
- # See if something special should be done when staging this
- # type. It is indicated by presense of special "staged" type =
=20=20=20=20=20=20=20=20=20=20
- if $(t) && [ type.registered STAGED_$(t) ]
+ if [ $(i).type ] !=3D SEARCHED_LIB
{
- i2 =3D [ generators.construct $(self.project) : STAGED_$(t=
) :
- $(property-set) : $(i) : * ] ;
- if ! $(i2)
- { =
=20
- errors.error "Unable to generate staged version of " [=
$(i).str ] ;
- }=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
- }
- else=20=20=20=20=20=20=20=20=20=20=20=20=20
- {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
- local n =3D [ $(i).name ] ;
- if $(name)
+ local staged-targets ;
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ local t =3D [ $(i).type ] ;
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ # See if something special should be done when staging thi=
s
+ # type. It is indicated by presense of special "staged" ty=
pe=20=20=20=20=20=20=20=20=20=20=20=20
+ if $(t) && [ type.registered STAGED_$(t) ]
{
- n =3D $(name) ;
+ staged-targets =3D [ construct-special-targets $(prope=
rty-set) : $(i) : STAGED_$(t) ] ;
+ }
+ else=20=20=20=20=20=20=20=20=20=20=20=20=20
+ {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ staged-targets =3D [ construct-regular-targets $(prope=
rty-set) : $(i) ] ;
}
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
- i2 =3D [ new file-target $(n:D=3D) : [ $(i).type ]=20
- : $(self.project) ] ;
- local a =3D [ $(i).action ] ;
- local new-a ;
- if $(a)
+ if ! $(staged-targets)
{ =
=20
- # Copy the properties of original target. They, in par=
ticular
- # can affect the suffix of the target.
- new-a =3D [ new action $(i2) : $(i) : common.copy : [ =
$(a).properties ] ] ;
- }
- else
- {
- new-a =3D [ new action $(i2) : $(i) : common.copy ] ;
- } =
=20
- $(i2).suffix [ $(i).suffix ] ;
- $(i2).action $(new-a) ;
- }
-=20=20=20=20=20=20=20=20=20=20=20=20
- # FIXME: Since we can have <location> property, it might be be=
tter
- # to use it to distinguish staged copies with different locati=
ons.
- for t in $(i2)
- {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
- $(t).set-path $(location) ;
- result +=3D [ virtual-target.register $(t) ] ; =
=20=20=20=20
- }=20=20=20=20=20=20=20=20=20=20=20=20
+ errors.error "Unable to generate staged version of " [=
$(source).str ] ;
+ }=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20
+ for t in $(staged-targets)
+ {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ result +=3D [ virtual-target.register $(t) ] ; =
=20=20=20=20=20=20=20=20
+ }=20=20=20=20=20=20=20=20=20=20=20=20
+ }
}
+
return $(result) ;
}=20=20=20
=20=20=20=20=20
@@ -235,13 +275,121 @@
local cloned-action =3D [ virtual-target.clone-action $(action) : =
$(project) :
"" : $(new-ps) ] ;
local result =3D [ $(cloned-action).targets ] ; =
=20=20=20=20=20
+
+ local location =3D [ get-location $(property-set) ] ;
+=20=20=20=20=20=20=20=20=20=20=20=20
+ for t in $(result)
+ {
+ $(t).set-path $(location) ;
+ }=20=20=20=20=20=20=20=20=20=20=20=20
+
return $(result) ;
-=20=20=20=20=20=20=20=20
}=20=20=20=20
}
=20
generators.register [ new stage-exe-generator ] ;
=20
+
+class stage-relocatable-generator : generator
+{
+ import type property-set modules ;=20=20=20=20
+
+ rule __init__ ( location-id : id : source-types * : target-types-and-=
names + )
+ {
+ generator.__init__ $(id) : $(source-types) : $(target-types-and-na=
mes) ;
+ self.location-id =3D $(location-id) ;
+ }
+=20=20=20=20
+ rule location ( property-set )
+ {
+ local location =3D [ feature.get-values $(self.location-id) :=20
+ [ $(property-set).raw ] ] ;
+=20=20=20=20=20=20=20=20=20=20=20=20
+ if ! $(location)
+ {
+ location =3D [ get-location $(property-set) ] ;
+ }
+=20=20=20=20=20=20=20=20=20=20=20=20
+ return $(location) ;
+ }
+=20=20=20=20
+ rule run ( project name ? : property-set : source : multiple ? )
+ {
+ local n =3D [ $(source).name ] ;
+ if $(name)
+ {
+ n =3D $(name) ;
+ }
+
+ local target =3D [ new file-target $(n:D=3D) : [ $(source).type ]=
=20
+ : $(project) ] ;
+ local a =3D [ $(source).action ] ;
+ local new-a ;
+ if $(a)
+ {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ # Copy the properties of original target. They, in particular
+ # can affect the suffix of the target.
+ new-a =3D [ new action $(target) : $(source) : common.copy : [=
$(a).properties ] ] ;
+ }
+ else
+ {
+ new-a =3D [ new action $(target) : $(source) : common.copy ] ;
+ } =
=20
+ $(target).suffix [ $(source).suffix ] ;
+ $(target).action $(new-a) ;
+
+ local loc =3D [ location $(property-set) ] ;
+ $(target).set-path $(loc) ;
+
+ return $(target) ;
+ }
+}
+
+# Declare staged version of the SHARED_LIB type.=20
+# Allows to define the location via <dll-location>
+type.register STAGED_SHARED_LIB : : SHARED_LIB ;
+
+class stage-shared-lib-generator : stage-relocatable-generator
+{
+ rule __init__ ( )
+ {
+ stage-relocatable-generator.__init__ <dll-location> : stage-shared=
-lib : SHARED_LIB : STAGED_SHARED_LIB ;
+ }
+}
+
+generators.register [ new stage-shared-lib-generator ] ;
+
+
+
+# Declare staged version of the STATIC_LIB type.=20
+# Allows to define the location via <lib-location>
+type.register STAGED_STATIC_LIB : : STATIC_LIB ;
+
+class stage-static-lib-generator : stage-relocatable-generator
+{
+ rule __init__ ( )
+ {
+ stage-relocatable-generator.__init__ <lib-location> : stage-static=
-lib : STATIC_LIB : STAGED_STATIC_LIB ;
+ }
+}
+
+generators.register [ new stage-static-lib-generator ] ;
+
+
+
+# Declare staged version of the IMPORT_LIB type.=20
+# Allows to define the location via <lib-location>
+type.register STAGED_IMPORT_LIB : : IMPORT_LIB ;
+
+class stage-import-lib-generator : stage-static-lib-generator
+{
+ rule __init__ ( )
+ {
+ stage-relocatable-generator.__init__ <lib-location> : stage-import=
-lib : IMPORT_LIB : STAGED_IMPORT_LIB ;
+ }
+}
+
+generators.register [ new stage-import-lib-generator ] ;
=20
=20
# Declares a stage target. When build, it will construct all sources
 ------=_NextPart_000_00DF_01C3C3E6.7D2C5E60--


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