Get easily Ly version from C++ of the file user_settings.options

Hi there! Is there a way to easily get the value “version” of the engine from the user_settings.options u another way to get the current version of the Ly engine at runtime?


Hi there @Prompt,

I looked into this a bit, and have an idea of something you can try. Version information for Lumberyard is set and managed through the WAF build system, and I would try using a wscript to read this value and define it for use in C++ code.

An example of all of the things I am about to talk about can be found in dev/Code/Sandbox/Editor/wscript

Looking at that wscript file, you can see that there is a section near the top that declares an array called “additionalDefines”, and that right below that there is actually a call to get the current version of Lumberyard (“bld.get_lumberyard_version()”). Now while that “version” variable is used elsewhere in the wscript, it is not stored in a way that is accessible in regular C++ code.

However, you can see that there is a “METRICS_VERSION” value that is added to the “additionalDefines” array. That “additionalDefines” array is then used again later in the wscript as an input value for the “defines =” argument. If you do a project-wide search for “METRICS_VERSION” you can see it used in C++ code.

So, I recommend finding the wscript of the module or area of code you wish to define the LY version for, and follow the example set forth by the “METRICS_VERSION” define. This will probably require you to run “lmbr_waf configure” and do a rebuild for the changes to take.

I hope that helps! Let me know if you get it working, I’m really curious :slight_smile:

Ok, finally I could compile again. The theory looks good @Hawkeye, however, it seems to not be added in my Gem, at least automatically. I’m using [All] profile config, not sure if that macro it’s added to every project.

It seems to be easier to open the file and read the values. I know it’s only used for the build system but seems to be very handy and has something in Ly already built-in to read those key-values.

I guess I’ll need to do that after all.

Thanks a lot for your help @Hawkeye,