wangyu5 / gyp

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

Included gypi file overrides includer's attributes #164

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
== What steps will reproduce the problem? ==
1. Add an 'includes' section to the root of a gyp or gypi file.
2. Declare the same attribute in both files (especially 'target_defaults').
3. Run gyp.

== What is the expected output? What do you see instead? ==
Attributes in the including file should take precedence over the included file; 
or, to be precise, the includer should be merged into the includee, rather than 
the reverse.

Instead, the included file takes precedence, resulting in the unintuitive 
behavior that the _least_ specific target_defaults are used.

== What version of the product are you using? On what operating system? ==
Revision 839 (current HEAD).  Mac OS X 10.6.4.  MacPorts Python 2.6.5.

== Please provide any additional information below. ==
I've attached a test case which demonstrates the problem.  It has four tests.  
The first test demonstrates everything in the absence of any inclusions, where 
the gyp file's target_defaults are used unless a rule overrides them.  The 
second demonstrates that an included gypi's target_defaults override the gyp's. 
 The third demonstrates that a recursively-included gypi overrides a 
directly-included gypi.  The fourth demonstrates that the second test passes 
when the gyp file's settings are in a condition (since condition resolution is 
deferred until after inclusion).

The test case is written for Mac, and takes advantage of the fact that 
xcode_settings are passed as environment variables and that 'OS=="mac"' is 
true.  It could probably be rewritten in a platform-agnostic way.

Original issue reported on code.google.com by sfiera on 10 Aug 2010 at 1:30

Attachments:

GoogleCodeExporter commented 9 years ago
I've written a tentative patch for MergeDicts() to fix this, adding two boolean 
flags to control its behavior.  This was generated from my git-svn repo, and I 
don't know anything about applying it cleanly to a svn repo.

Original comment by sfiera on 25 Aug 2010 at 1:17

Attachments:

GoogleCodeExporter commented 9 years ago
After some further musing, I don't believe this patch to be correct, 
particularly in its implementation of |reverse|, as my "simplification" of 
'target_defaults' borks it instead.  I'm going to have a further look at this.

Original comment by sfiera on 25 Aug 2010 at 11:47