I'm trying to add those two lines to the pre-build steps and I cannot for the life of me get it to work. It always returns failed for the first line. I've tried:
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
GIT_VERSION := `git describe --abbrev=4 --dirty --always --tags`
GIT_VERSION := {cmd /c git describe --abbrev=4 --dirty --always --tags}
GIT_VERSION := {git describe --abbrev=4 --dirty --always --tags}
Output of the first one shows it removing the $(shell part, but it leaves the trailing ) in there.
I've also tried only having different variations of the second line in the pre-build steps and adding the first one to the custom variables tab (the next one over from pre/post build tab), but that didn't work either (it does substitute the variable for the command, but it still fails).
I'm obviously misunderstanding how this works. I figured it would be added to pre-build steps exactly as you would have it in a Makefile, but I guess not. This is on Windows 10, svn 10703, and I've add git's bin directory to the system path.
I ended up going to the #defines tab of the Compiler Settings and putting this there:
BUILD_VERSION=\"`git describe --abbrev=5 --dirty --always --tags`\"
which worked as I needed it to.
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.
I added this
TEST="[[print(IO.ExecuteAndGetOutput(_T("git --version")).RemoveLast(1))]]"
into Project->Build options->#defines
and it seems to work
greetings
[EDIT:] Corrected the code!!!! No ticks!!!