Question

I want many gyp scripts to have a common target. So I decided to move it to a separate include file. Simplest test-case that produces an error:

foo.gyp

{
    'includes'  : [
        'bar.gypi',
    ],
}

bar.gypi

{
    'targets': [
        {
            'target_name' : 'phony',
            'type' :    'none',
            'actions' : [
                {
                    'action_name' : '_phony_',
                    'inputs' :  ['',],
                    'outputs' : ['',],
                    'action' :  ['_phony_',],
                    'message' : '_phony_',
                },
            ],
        },
    ],
}

Produces error:

IndexError: string index out of range while reading includes of foo.gyp while tr ying to load foo.gyp

Some observations:

  • If I delete actions from target, everything parses well

  • If I move targets (with actions) to foo.gyp, everything parses well

Am I doing something wrong?

Was it helpful?

Solution

It looks like the "outputs" list can not be empty or contain an empty string:

# gyp/make.py:893
self.WriteLn("%s: obj := $(abs_obj)" % QuoteSpaces(outputs[0]))

You may have empty inputs but in this case the phony action will shoot only once. I haven't found any mentions of phony actions in the GYP documentation, but I have the following variant working:

# bar.gypi
{
'targets': [
  {
    'target_name'   :   'phony',
    'type'          :   'none',
    'actions'       :   [
      {
        'action_name'   :   '_phony_',
        'inputs'        :   ['./bar.gypi'], # The action depends on this file
        'outputs'       :   ['test'],       # Some dummy file
        'action'        :   ['echo', 'test'],
        'message'       :   'Running phony target',
      },
    ],
  },
],

}

I could try to find a better way if you tell me more about the task you are trying to solve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top