ChrisPei / gyp

Automatically exported from code.google.com/p/gyp
0 stars 0 forks source link

GYP: unable to exclude source file under condition "chromeos==1" #335

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
During review of a recent CL (see Nico's comment at 
https://codereview.chromium.org/13486004/#msg15) I had trouble excluding a 
source file under condition "chromeos==1" if the source file is already 
included in the general section of the gypi. The gypi looks like

'sources': [
  'browser/extensions/api/audio/audio_service.cc',
  ...
],
'conditions': [
  ['chromeos==1', {
    ...
    'sources!': [
      'browser/extensions/api/audio/audio_service.cc',
      ...
    ],
    ...

Even though the 'sources!' section explicitly excludes the audio_service.cc 
from the build, I can still see the rule for audio_service.o generated in the 
resulting .ninja file, and the associated class methods in the symbol table of 
the output chrome binary.

I have verified that my gclient runhooks commandline has 
GYP_DEFINES="chromeos=1" set.

Original issue reported on code.google.com by hshi@chromium.org on 23 Apr 2013 at 4:37

GoogleCodeExporter commented 9 years ago
Note: inclusion rules ('sources': [...] or 'sources/': ['include': '...']) work 
correctly. I have been able to work around this bug by removing 
audio_service.cc from the general section and create another section under 
conditions with 'chromeos==0'. However, the bug remains.

Original comment by hshi@chromium.org on 23 Apr 2013 at 5:37

GoogleCodeExporter commented 9 years ago
Not sure what's going on here. I added some debug prints in input.py and 
confirmed that my source file (audio_service.cc) is indeed correctly listed 
under the_dict[exclude_key] and the action for the corresponding item is set to 
0 (exclude). However the generated ninja file still lists the target.

Original comment by hshi@chromium.org on 23 Apr 2013 at 5:47

GoogleCodeExporter commented 9 years ago
Some more debugging shows that:
(1) at the end of the first loop:
    if exclude_key in the_dict:
      for exclude_item in the_dict[exclude_key]:
...
We have found the exclusion item and set list_actions[index] = 0 for 
audio_service.cc

but (2) at the end of the second loop:
    regex_key = list_key + '/'
    if regex_key in the_dict:
      for regex_item in the_dict[regex_key]:

The list_actions[index] is back to 1.

Original comment by hshi@chromium.org on 23 Apr 2013 at 6:02

GoogleCodeExporter commented 9 years ago
never mind... I think this is not a GYP bug. The gyp file itself contains a 
regex rule that forced inclusion.

Original comment by hshi@chromium.org on 23 Apr 2013 at 6:06

GoogleCodeExporter commented 9 years ago

Original comment by thakis@chromium.org on 23 Apr 2013 at 7:50