list overrides do not work in 'conditions'

22 views
Skip to first unread message

Erik Ackermann

unread,
Jun 22, 2017, 5:23:47 PM6/22/17
to gyp-developer
Hello gyp-developers,

I have three simple files which seem to indicate that list overrides using "=" are broken inside of conditionals:

<dest.gyp>
{
  'includes': [
    'source1.gypi',
    'source2.gypi',
  ],
  'mylist': [ 'dest' ],
  'mycondlist': [ 'dest' ],
}

<source1.gypi>
{
    'mylist=': [ 'source1' ],
    'conditions': [
      ['OS=="linux"', {
        'mycondlist=': [ 'source1' ],
      }],
    ],
}

{
    'mylist=': [ 'source2' ],
    'conditions': [
      ['OS=="linux"', {
        'mycondlist=': [ 'source2' ],
      }],
    ],
}


The output of gypd compiler target contains these values:
    'mycondlist': ['dest', 'source1', 'source2']
    'mylist': ['source2']

What is going on here? This seems like a bug. It is not overriding the conditions since the final mycondlist contains all 3 values.

Refael Ackermann

unread,
Jun 23, 2017, 7:02:02 AM6/23/17
to gyp-developer
Defo looks like a bug, I'm investigating.
Full working example:

<test.gyp>
{
 
'targets': [
   
{
     
'includes': [
       
'inc1.gypi',
     
],

     
'variables': {
       
'mycondlist': ['source0.c'],
       
'conditions': [
         
['1==1', {
           
'mycondlist=': ['source0c.c'],
         
}],
       
],
     
},

     
'target_name': 't1',
     
'type': 'executable',
     
'sources': ['<@(mycondlist)'],
   
}
 
]
}
<inc1.gypi>
{
 
'variables': {
   
'conditions': [
     
['1==1', {
       
'mycondlist=': [ 'source1c.c' ],
     
}],
   
],
 
}
}

Outputs:
C:\bin\dev\python27\python.exe D:/code/3party/gyp/gyp_main.py -f msvs test.gyp --depth=.
Warning: Missing input files:
source1c.c
source0c.c


Erik Ackermann

unread,
Jul 10, 2017, 5:38:51 PM7/10/17
to gyp-developer
Anyone able to comment on this behavior? It seems like the handling of "=" merge operator is broken in the "conditions" case.

(also third block is missing the label as <source2.gypi>)

Refael Ackermann

unread,
Jul 10, 2017, 9:16:13 PM7/10/17
to gyp-developer
I was debugging the code, and it does seem like a bug.
In the case of an 'includes' directive, all variable resolution is done for the included file without the context of the includer, so mycondlist= gets flattened and loses its `=` modifier

Refael Ackermann

unread,
Jul 10, 2017, 9:21:04 PM7/10/17
to gyp-developer
I believe that if you can use:
'dependencies': [
'source1.gypi',
]

Or use the `-Isource1.gypi` cli argument, it works better
Reply all
Reply to author
Forward
0 new messages