Using CB 8.02 on Win XP (with the expectation of porting to Linux) for a project that is under Git source code management. I am trying to set a gcc compiler define dynamically from the current Git branch name so that the branch name can be incorporated into the compiled code. I can get the branch name onto the CB build log by including the following as a Project build options target pre-build step
[[ if (PLATFORM == PLATFORM_MSW) { print (_T("cmd /c win_getbranch.bat")); } else { print (_T("sh nix_getbranch.sh")); } ]]
showing that the script is basically functional but if analogously I attempt to set Project build options target Compiler Settings #defines as
branch="[[ if (PLATFORM == PLATFORM_MSW) { print (_T("cmd /c win_getbranch.bat")); } else { print (_T("sh nix_getbranch.sh")); } ]]"
then branch gets set to
cmd /c win_getbranch.bat rather than to the result of executing that Windows batch file.
How might the required effect be achieved, please? (Alternatively this could be done by getting Git checkout to write the branch name into a C source file, but IMHO that's not an elegant solution).
TIA
Chris