2

I am new to gyp & i googled a lot, but i am not getting any information regarding printing variable value in .gyp or .gypi file. I tried using echo, but that did not worked for me.

so, my question is very simple : How to print variable in gyp?

Nishant Bijani A
  • 148
  • 1
  • 13

1 Answers1

3

You can use an action to print the variables:

{
    "variables": {
        "BUILD_TESTS": "false",
    },
    "targets": [
        {
        "target_name": "my_target",
        'actions': [
            {
                'action_name': 'print_variables',
                'action': [ 'echo', 'BUILD_TESTS: <(BUILD_TESTS) | BASE_DIR: <(BASE_DIR)', ],

                'inputs': [],
                'outputs': [ "src/some_file.cc" ],
            }
        ],
        ...
        }
    ]
}

Make sure that "outputs" points to a file that is referenced in your "sources", even though you don't actually create that file. Otherwise the action won't run and you will not see any output.

David Tanzer
  • 2,732
  • 18
  • 30
  • I added the targets according to your instruction, but it didn't work. I guess "my_target" needs to be added as a dependency somewhere!? – Bogi Oct 27 '17 at 11:58