Boost logo

Boost-Build :

Subject: [Boost-build] jam/python function calling
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-07-14 07:24:29

It turns out that bjam is a little bit too flexible with types, which causes some pain.
Support Jamfile has:

        import feature ;
        feature.feature interpreter : : free incidental ;

The matching function in Python is:

        def feature (name, values, attributes = []):

The problem is that bjam language has list of strings as the only data
type, and Python does not have type declaration. So, given the above,
current Python port passes 3 values of type 'list of string' to Python,
and when we try to use 'name' as string, things fall apart. Of course,
I can hack 'feature' to operate on name[0], but this seems, ehm, nasty.

So far, the best approach I came up is:

        @interop([1, 0, 0])
        def feature (name, values, attributes = []):

where parameters to the 'interop' decorator mean that first argument
passed from bjam should be a list of 1 string and be converted to a string,
while two other parameters should be list of strings of any size, and
left unchanged. Things are getting nasty for the toolset.flags rule, though:

        rule flags (
            condition * :

Where the first paramter from bjam should be unpackad into 3 parameters to
python code. But presumably, this case can be handled by a custom code.

It seems like adding such annotation will be a bit of work. Does anybody
have brighter ideas on the syntax, or how to avoid this mess?


Vladimir Prus

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at