|
Boost-Build : |
From: Hassan Mehmet (hassan_mehmet_at_[hidden])
Date: 2007-01-04 04:18:30
Denis N. Kononenko <denisn.kononenko <at> gmail.com> writes:
>
> 2006/12/19, Hassan Mehmet <hassan_mehmet <at> hotmail.com>:
>
> Hello.
>
> I'm newbie to bbv2, but I'll try to help you.
>
> >
> > The problem is:
> > I have taken over some Jamfiles written by someone else. In it they have
> > created an action to generate CPP files from SWIG files which are then used
> > to generate a python-extension. The action to create the CPP from SWIG
> > follows the verbatim example in the manual and is fairly easy to follow.
> >
> > import type ;
> > import generators ;
> >
> > type.register SWIG : i ;
> > actions swig-action { swig -c++ -python -Iinclude -o $(<) $(>) }
> >
> > generators.register-standard swig-swig-action : SWIG : CPP ;
> >
> > The build system now knows how to convert SWIG files to CPP which are then
> > used to create the python extension library.
> >
> > Now I want to generate a C# version. This also creates CPP files from SWIG
> > but has different arguments. So I need an action like
> >
> > actions swig-csharp { swig -c++ -csharp -Iinclude -o $(<) $(>) }
> >
> > The problem now is I (obviously) cannot use the python-extension rule. So
I
> > assume I need to create my own rule ? How do I get this new rule to call
the
> > swig-csharp action. Or do I need to do something more complicated?
>
> I think you have to parametrize the existing swig-action with using
> features. Something, like this:
>
> import feature : feature ;
> feature swig-target : python csharp : propagated ;
>
> import toolset : flags ;
> flags swig-action SWIG_TARGET <swig-target>python : -python ;
> flags swig-action SWIG_TARGET <swig-target>csharp : -csharp ;
>
> actions swig-action { swig -c++ $(SWIG_TARGET) -Iinclude -o $(<) $(>) }
>
> And then, you may explicitly specify a desired target in your Jamfile
> by using the feature <swig-target> in requirements:
>
> exe myapp : myapp.i : <swig-target>csharp ;
>
> or
>
> exe myapp : myapp.i : <swig-target>python ;
>
> WBR,
> Denis.
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost-build
>
>
Hi Denis (& Vladimir)
Thanks for your help.
I managed to solve the problem using OPTIONS and <main-target-type>. I don't
know if this is the most elegant solution but it works :-)
import type ;
import generators ;
import "class" : "new" ;
type.register SWIG : i ;
rule swig-converter ( targets * : sources * : properties * )
{
if <main-target-type>PYTHON_EXTENSION in $(properties)
{
OPTIONS on $(targets) = -python ;
}
else
{
if <main-target-type>CSHARP_WRAPPER in $(properties)
{
OPTIONS on $(targets) = -csharp ;
}
else
{
EXIT "*** Error *** swig.swig-converter: Unknown main-target-
type" ;
}
}
}
import toolset : flags ;
flags swig.swig-converter INCLUDES <include> ;
actions swig-converter
{
swig -c++ $(OPTIONS) -I"$(INCLUDES)" -o $(<) $(>)
}
generators.register [ new generator swig.swig-converter : SWIG : CPP ] ;
type.register CSHARP_WRAPPER ;
actions csharp-wrapper-action
{
echo "csharp-wrapper-action : do something or it fails ??"
}
generators.register-standard swig.csharp-wrapper-action : CPP :
CSHARP_WRAPPER ;
Regards
Hassan
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