You can also try to use scripting: http://wiki.codeblocks.org/index.php?title=Scripting_commands
the "ExecuteAndGetOutput" command should help.
For more reading:
http://wiki.codeblocks.org/index.php/Variable_expansion#Script_expansion
greetings
Trying to get this working, but having trouble.
Previously, I had this (although I had to recompile C::B to not use the backtick cache; I've since changed it back so I can try the scripting) under the
#defines tab of project compiler settings, which works:
BUILD_VERSION=\"`git describe --abbrev=5 --dirty --always --tags"`\"
Following the example in the C::B project file (I think it's under
Other compiler options) I changed it to this:
BUILD_VERSION=\"[[IO.ExecuteAndGetOutput(_T("git describe --abbrev=5 --dirty --always --tags"))]]\"
But it always comes out blank. I tried adding .ToStdString().c_str(), but it complained that they were unknown or undefined or something.
So following this example from the C::B project itself:
[[if (GetCompilerFactory().GetCompilerVersionString(_T("gcc")) >= _T("4.8.0")) print(_T("-Wno-unused-local-typedefs"));]]
I tried changing mine to this:
BUILD_VERSION=\"[[print(_T(IO.ExecuteAndGetOutput(_T("git describe --abbrev=5 --dirty --always --tags"))))]]\"
but it fails, with a messagebox saying:
Filename: CommandLine
Error: Incorrect function argument
Details:
(Details were blank). So, I'm not sure how to do this since finding examples regarding the [[]] ability is turning up next to nothing. I couldn't figure how to to use the "allowInsecureScripts" constant to see if the macro was defined, and I tried grepping for the macro itself but it was nowhere to be found except in sc_io.cpp, where it's only checked. Regardless, I removed the #ifndef and recompiled C::B just to test if ExecuteAndGetOutput was returning blank because of security, but it still returns blank.