wutingcindy / gyp

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

Can't add dependencies in target_conditions #380

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I sometimes need to make a target that other executables (and/or dynamic libs) 
depend on (default options for ASan/TSan in Chrome is one example, see 
https://codereview.chromium.org/25687005/; another example is 
base/allocator/allocator.gyp:allocator in Chrome, on which every Linux 
executable should depend)

The natural thing to do this is to add a '_type=="executable"' clause with a 
dependencies section into the project-wide target_conditions:

'target_conditions': [
...
              ['_type=="executable"', {
                'dependencies': [
                  '<(DEPTH)/base/base.gyp:sanitizer_options',
                ],
              }],
...
]

However GYP is unable to handle 'dependencies' within the target_conditions 
section:

Traceback (most recent call last):
  File "src/build/gyp_chromium", line 161, in <module>
    sys.exit(gyp.main(args))
  File "/usr/local/google/chrome-asan/src/tools/gyp/pylib/gyp/__init__.py", line
527, in main
    return gyp_main(args)
  File "/usr/local/google/chrome-asan/src/tools/gyp/pylib/gyp/__init__.py", line
512, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File
"/usr/local/google/chrome-asan/src/tools/gyp/pylib/gyp/generator/ninja.py", line
2133, in GenerateOutput
    pool.map(CallGenerateOutputForConfig, arglists)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 227, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
    raise self._value
KeyError: '../../../base/base.gyp:sanitizer_options'

This is because the target dictionary isn't populated at the time target
conditions are checked (the target in the dependencies hasn't even been 
normalized yet)

Original issue reported on code.google.com by gli...@chromium.org on 11 Nov 2013 at 9:10

GoogleCodeExporter commented 9 years ago
According to pylib/gyp/input.py:

 424   # Look for dependencies.  This means that dependency resolution occurs
 425   # after "pre" conditionals and variable expansion, but before "post" -
 426   # in other words, you can't put a "dependencies" section inside a "post"
 427   # conditional within a target.

Looks like some fundamental restriction.

Original comment by gli...@chromium.org on 15 Nov 2013 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by gli...@chromium.org on 21 Nov 2013 at 11:08