[Scons-users] generating cpp defines with a function

Tom Tanner (BLOOMBERG/ LONDON) ttanner2 at bloomberg.net
Wed Jun 3 09:00:08 EDT 2015


That doesn't seem like the problem to me. It seems almost the opposite.

If I have CCPDEFINES = '${myfunc()}', and myfunc returns [['ABC', '123'], ['DEF', '456'], 'XYZZY'], then I'd like CPPDEFINES to contain [['ABC', '123'], ['DEF', '456'], 'XYZZY']

it doesn't though, it gets set to ['ABC', '123', 'DEF', '456', 'XYZZY'] which gives a totally wrong result when evaluated, i get '-DABC 123 DEF 456 XYZZY']

Mind you I have a feeling that fixing this so that subst maintained lists and dicts might be liable to break existing builds.


From: jason.l.kenny at intel.com At: Jun  2 2015 16:11:28
To: Tom Tanner (BLOOMBERG/ LONDON), scons-users at scons.org
Subject: RE: [Scons-users] generating cpp defines with a function

     

The issue is in subst().
 
The code that subst a list assumes a 1:1 mapping of a given item in the list so it assumes that given:
 
[‘$sayit’,’$foo’] 
 
The current code assume that “$sayit” return a value like “hello” it does not assume that [‘hello’,’world’] would be returned. 
 
So it replaces [‘$sayit’]  with [[‘hello’,’world’],’fooval’] instead of what the desired [‘hello’,’world’,’fooval’].
 
Jason
 

From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Tom Tanner (BLOOMBERG/ LONDON)
Sent: Tuesday, June 2, 2015 10:01 AM
To: scons-users at scons.org
Subject: Re: [Scons-users] generating cpp defines with a function
 

 

The code in _defines doesn't like that at all.

 

return [ [ 'ABC', 'ABC' ] ] 

 

Is fine (but wrong)

 

return [ { 'ABC' : 'ABC' } ] # or variants thereon

 

Gets this:

 

scons: *** [test.o] TypeError `get expected at least 1 arguments, got 0' trying to evaluate `${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}'

 

 

 

From: garyo at oberbrunner.com At: Jun 2 2015 15:48:07

To: Tom Tanner (BLOOMBERG/ LONDON), scons-users at scons.org
Subject: Re: [Scons-users] generating cpp defines with a function


Does it help if you return a dict (or convert your nested list to a dict)?

It may help if you look at the tests in test/CPPDEFINES (and if you see missing cases there, feel free to add them.)

 

On Tue, Jun 2, 2015 at 10:21 AM, Tom Tanner (BLOOMBERG/ LONDON) <ttanner2 at bloomberg.net> wrote:

I have a requirement to do something like this:

 

env.Append(CPPDEFINES = '${some_func(arg1, arg2)}')

 

My trouble comes when some_func returns something relatively complicated, like

 

[['FGH', 'string'], ['ABC', 'another string'], 'IJK' ]

 

This appears to get flattened and you get

 

gcc ... "-DFGH FGH ABC ABC IJK"

 

Which is very definitely not very helpful.

 

Is there anything I can do to get the return from some_func not to be flattened?

 

 

_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://pairlist4.pair.net/mailman/listinfo/scons-users

 

 
-- 

Gary

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150603/9b33d416/attachment.html>


More information about the Scons-users mailing list