0

I want to add a variable to use inside my .gpy file but I dont want to define it inside a .gyp file but outside. Usually variables are set in the gyp dictionary and can then be used in this file or dependant files. However, I want to set the variable outside of gyp so that all parsed gyp files can use it without it being hardcoded in any of them. Im using windows and this is what I have tried

Batch file to start the process

set GYP_MSVS_VERSION=2015
set GYP_DEFINES="TOOLSET=v140"
gclient --runhooks

How TOOLSET is being used in a .gyp file that gets parsed from the above gclient --runhooks

'msbuild_toolset': TOOLSET,

Gyp output:

NameError: name 'TOOLSET' is not defined while reading test.gyp

Any idea how I can get this working? Thanks

codetemplar
  • 671
  • 6
  • 19

1 Answers1

1

You can defines variables outside of gyp in two ways :

  • Using GYP_DEFINES environement variables as you did
  • By provding the variable when invoking gyp by using the -D flag (for example gyp build -DTOLLSET=v140 file.gyp )

Then in your gyp file, the variable can be used as a regular variable using <(TOOLSET) see gyp Variable Expansions documentation for more informations

efyx
  • 26
  • 2
  • 3