Search code examples
gyp

how to print variable value in generate your project ( gyp )


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?


Solution

  • 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.