Advise on Technique for Branch Aware Code

Hello,

I am trying to make my custom script and I have never worked with branches before. I am looking for some advice on dealing with branches within code.

I would like my script to work on 3.3.5 and on master without editing or separately deploying for each. For example I would like to refer to enumerations (races/classes/etc) that may not exist in both branches. I would rather not patch or git patch. Is there a define somewhere that indicates the current @{} branch?

What I am using right now is the define CURRENT_EXPANSION, which is great as it seems to be a core header to the project in master. It not existing in 3.3.5 doesn’t much matter.

master/src/server/game/Miscellaneous/SharedDefines.h:#define CURRENT_EXPANSION EXPANSION_LEGION

I somewhat expected that a cmake variable would pass the branch to be used by source, but I guess that would make people write things very awkward and fragmented (like i am likely doing).

Thanks for the advice.

You can use _BRANCH, which is defined in the revision_data.h file filled in by CMake.

https://github.com/TrinityCore/TrinityCore/blob/master/src/common/GitRevision.cpp#L14

A (pretty hard) dream of mine is having a single branch that supports multiple expansions :')

Thank you, that looks great.

You actually cannot use _BRANCH because its a string, so #ifdef code for missing enum values will not work

Right, no strings in macros.

Use CURRENT_EXPANSION, https://github.com/TrinityCore/TrinityCore/blob/adbe8daf8af45623ecd8c3d62b8fc72690578f4d/src/server/game/Miscellaneous/SharedDefines.h#L90