suriab / gyp

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

ExpandInputRoot() in generator/make.py adds ./ to parameters #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create a gyp file like below

% cat > foo.gyp                  
{
  'targets': [
    {
      'target_name': 'gen_qrc',
      'type': 'none',
      'sources': [
        'foo.qrc'
      ],
      'rules': [
        {
          'rule_name': 'qrc',
          'extension': 'qrc',
          'outputs': [
            '<(SHARED_INTERMEDIATE_DIR)/qrc_<(RULE_INPUT_ROOT).cc'
          ],
          'action': [
            'rcc<(EXECUTABLE_SUFFIX)',
            '-o', '<(SHARED_INTERMEDIATE_DIR)/qrc_<(RULE_INPUT_ROOT).cc',
            '-name', 'qrc_<(RULE_INPUT_ROOT)',
            '<(RULE_INPUT_PATH)'
          ],
          'message': 'Generating Resource file from <(RULE_INPUT_PATH)',
        },
      ],
    },
  ],
}

2. Generate make files by "gyp --depth=. -f make foo.gyp"

3. See the gen_qrc.target.mk:

cmd_gen_qrc_qrc_0 = export 
LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; 
mkdir -p 
$(obj)/gen; rcc -o "$(obj)/gen/qrc_foo.cc" -name ./qrc_foo "$(abspath $<)"

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

The problem in the generated command line is this portion "-name ./qrc_foo".
"qrc_foo" is not a file name and "rcc" does not behave right if ./ is added to 
the parameter.

What version of the product are you using? On what operating system?

GYP r797

Please provide any additional information below.

Looking at generator/make.py, the ./ is added in ExpandInputRoot(). I thought 
about fixing the issue by changing the code as 
follows, but I wasn't sure if this would be the right fix.

-    if not os.path.dirname(path):
+    if not os.path.dirname(path) and os.path.isfile(path)
       # If it's just the file name, turn it into a path so FixupArgPath()       
       # will know to Absolutify() it.                                           
       path = os.path.join('.', path)

Original issue reported on code.google.com by sato...@chromium.org on 10 Mar 2010 at 6:19

GoogleCodeExporter commented 9 years ago
I think that might be the wrong fix.

Imagine a rule where an input file is generated at build time.
Depending on whether that file has been generated yet, this logic will have a 
different result.  But gyp only runs at checkout time, so it only can run once.

Original comment by evan@chromium.org on 17 Apr 2010 at 9:24