verpas / gyp

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

incorrect ninja output for copies with different directory component #331

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a gyp configuration with a copies section where 'files' is a list of 
paths with different directory components. For example:

'copies': [
  {
    # Copy localized resources.
    'destination': '<(PRODUCT_DIR)/path/to/Resources/',
    'files': [
      '<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))',
    ],
  },
]

Where the value of 'files' will be:

$!INTERMEDIATE_DIR/repack/am.lproj/locale.pak
$!INTERMEDIATE_DIR/repack/ar.lproj/locale.pak
$!INTERMEDIATE_DIR/repack/bg.lproj/locale.pak
...

2. The ninja output looks like this:

build ./my.app: stamp $
    path/to/Resources/locale.pak $
    path/to/Resources/locale.pak $
    path/to/Resources/locale.pak $
    ...

What is the expected output? What do you see instead?

The component of the path which is different should be maintained. For example, 
the Xcode output looks like this:

D0C928E6B9A90B8E7C82948B /* am */ = {isa = PBXFileReference; lastKnownFileType 
= text; name = am; path = am.lproj/locale.pak; sourceTree = "<group>"; };
2887799486DC2264974AAA31 /* ar */ = {isa = PBXFileReference; lastKnownFileType 
= text; name = ar; path = ar.lproj/locale.pak; sourceTree = "<group>"; };
DDA467E96A26AD4D03D9510E /* bg */ = {isa = PBXFileReference; lastKnownFileType 
= text; name = bg; path = bg.lproj/locale.pak; sourceTree = "<group>"; };
...

What version of the product are you using? On what operating system?
OS-X 10.8 gyp revision 1602.

Original issue reported on code.google.com by marshall@chromium.org on 8 Apr 2013 at 8:43

GoogleCodeExporter commented 9 years ago
Where did you get the value of 'files' from? ninja.py tries to replace "$!FOO" 
variables before writing its output, they should never be user-visible (done by 
ExpandSpecial() which is called from GypPathToNinja() which is called from 
WriteCopies()).

Original comment by thakis@chromium.org on 8 Apr 2013 at 9:07

GoogleCodeExporter commented 9 years ago
@comment#1: I added a "print path" line after the "for path in copy['files']:" 
in the ninja.py WriteCopies function.

Original comment by marshall@chromium.org on 8 Apr 2013 at 9:16

GoogleCodeExporter commented 9 years ago
@comment#1: For reference, adding a "print path" in the xcodeproj_file.py 
AddFile function gives the following output:

$(INTERMEDIATE_DIR)/repack/am.lproj/locale.pak
$(INTERMEDIATE_DIR)/repack/ar.lproj/locale.pak
$(INTERMEDIATE_DIR)/repack/bg.lproj/locale.pak

Original comment by marshall@chromium.org on 8 Apr 2013 at 9:25

GoogleCodeExporter commented 9 years ago
That's the wrong place to put a print then :-) Printing after the calls to 
GypPathToNinja() is more useful.

Generally, ninja/mac tries to be compatible to the xcode generator and when it 
isn't that's a bug (since you said you weren't sure if it is on email). Since 
chromium doesn't run into this bug, I likely won't fix it myself though.

Original comment by thakis@chromium.org on 8 Apr 2013 at 9:33

GoogleCodeExporter commented 9 years ago
@comment#4: Thanks. I'm trying to identify where the path logic lives in the 
Xcode generator. If I'm successful I'll submit a patch for the ninja generator 
to give it the same behavior.

As a potential work-around, is there currently a way to have ninja copy a list 
of files like those shown above and maintain the directory component?

Original comment by magreenb...@gmail.com on 8 Apr 2013 at 9:36

GoogleCodeExporter commented 9 years ago
It looks like the Xcode generator has a special case for directories ending in 
".lproj". From AddOrGetFileByPath in xcodeproj_file.py:

    # Adding or getting a variant?  Variants are files inside directories
    # with an ".lproj" extension.  Xcode uses variants for localization.  For
    # a variant path/to/Language.lproj/MainMenu.nib, put a variant group named
    # MainMenu.nib inside path/to, and give it a variant named Language.  In
    # this example, grandparent would be set to path/to and parent_root would
    # be set to Language.

Any objection to having a similar special case in the ninja generator?

Original comment by marshall@chromium.org on 8 Apr 2013 at 10:17

GoogleCodeExporter commented 9 years ago
Uploaded a proposed patch here: https://codereview.chromium.org/13832003

Original comment by marshall@chromium.org on 8 Apr 2013 at 11:11