lymneu / gyp

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

Impossible to have toolset-specific dependencies when toolsets are conditional? #366

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It appears to be impossible to have a target that both:

1) sets toolsets conditionally
2) modifies dependencies conditional on _toolset.

i.e.

{
  'conditions': [
    ['OS=="android"', {
      'toolsets': ['host', 'target'],
    }],
  ],
  'target_conditions': [
    ['_toolset=="target"', {
      'dependencies': ['foo'],
    }].
  ],
}

doesn't work (it crashes with a KeyError), because dependency resolution 
happens *before* target_conditions is processed, and therefore it's not 
possible to add another dependency at this stage. However, it's also not 
possible to test _toolset in conditions if toolsets is being modified in 
conditions.

I discovered this as a theoretical issue when looking into how to make toolset 
handling saner, but it's now come up as a practical problem: libpng in Chromium 
needs to do this in order to use the Android cpufeatures library only when 
building for target. We're going with a workaround for now of making libpng 
(and its transitive dependencies) all build for host and target on all 
platforms, but that's not nice..

I experimented with a bunch of things to try and fix this a while ago, but the 
way that toolsets, toolset, and target_defaults interact during the various 
phases of gyp processing is stupendously complicated and changing the slightest 
thing appears to break some currently working case, so I gave up. Anyone else 
want to try? :)

Original issue reported on code.google.com by torne@chromium.org on 9 Sep 2013 at 4:52