2

i'm trying to play around with GYP and got stucked with defining "default variable"

have 2 files(one main, and one expected to store common data, included to main:

1) v_common.gypi:

{
    'variables': {
        'mymodule%': "blblblb",
        'mymoduleLibs' : "<(mymodule)/Libs",

    },

    'target_defaults': {

    },
}

2) mymodule.gyp

{
    'variables':{
    },
    'includes': [
        'v_common.gypi',
    ], # includes

    'targets': [
        {
                'target_name': 'myModule',
                'type': 'none',
                'actions' : [
                    {
                        'action_name': 'create_libs_folder',
                        'inputs': ['one_file'],
                        'outputs':['blabla'],
                        'action': ['mkdir', '<(mymoduleLibs)'],
                    }
                ]

        },
    ], # targets
}

per my expectations:

  • mymodule should get value of "blblblb", (as far as it wasn't defined previously anywhere),

  • then I should be able to use it for compute value of mymoduleLibs

  • and after all mymoduleLibs should be usable in mymodule.gyp

but, i just getting error that mymodule is "Undefined variable". If I do exact definition of mymodyle like in example below(withot percent sign), everything works fine. :

'variables': {
        'mymodule': "blblblb",
        'mymoduleLibs' : "<(mymodule)/Libs",

    }

any ideas?

Volodymyr
  • 41
  • 3

1 Answers1

2

i've found issue. it's described here https://groups.google.com/forum/?fromgroups#!topicsearchin/gyp-developer/default/gyp-developer/1EWXAXe-qWs

correct workaroud is to define default variables in sub-dict 'variables':{...}, so they will be evaluated before expanding other variables, like below:

{
    'variables': {
        'variables': {
            'mymodule%': "blblblb",
         },
        'mymoduleLibs' : "<(mymodule)/Libs",

    },

    'target_defaults': {

    },
} 
Volodymyr
  • 41
  • 3