2021-06-02 12:28 AM
From an Idea discussion with @Pavel A. https://community.st.com/s/ideazone#0873W000000blKWQAY
StCubeMX should enable your programm to know its own code version.
via the autogenerated linker script or any way .
Related with my old question https://community.st.com/s/question/0D53W00000ZVSgbSAH/git-commit-hash-flashed-along-with-my-code
@Pavel A. >In CubeIDE projects you can add a custom pre & post scripts where all this can be easily done.
@Javier Muñoz >Where can i find more information?
All system scripting and behind the scenes of cubeIDE is obscure wizardry to me.
So ...i still dont know :(
Solved! Go to Solution.
2021-06-07 04:49 AM
What ended up working for me: (im using windows STMCUBE IDE 1.5.1)
I struggled with the directories, aparently the build directory is the folder /Debug or /Release but i want to place my script in root project directory so i cd ..;
cd ..;./prebuildJaviscript.sh
The script was placed here:
Containing;
#!/bin/sh
echo "this is the pre-build script!:D"
#variables from git log https://devhints.io/git-log-format
git log --pretty=format:'#define GIT_INFO_PRESENT%n static const char* GIT_INFO = "Commit=%h,CommitDate=%at,CommitSubject=%s";' -n 1 > Core/Inc/gitcommit.h
And the cript creates this:
2021-06-02 06:31 AM
Right click project -> Properties -> C/C++ Build -> Settings -> Build Steps.
2021-06-02 11:40 AM
There's even more reasons to celebrate these scripts. CubeIDE comes with GNU shell (sh) and some GNU tools. You can write portable shell scripts that work both on Windows and Linux. Enough mediocre batch files.
Eclipse variables such as ${BuildArtifactFileName} can be passed to the script as parameters.
--pa
2021-06-03 01:34 AM
That sounds fantastic @Pavel A. ! Im very new in this area, so what is Command expecting from me?
In what languaje should i write the socalled "commands"? shell script?
if i add ./myscript.sh it doesnt find my script and i have no idea where is looking for it.
If i add echo "the PWD is : ${pwd}"
2021-06-07 02:40 AM
I found the answer online:
No script tough, just the command i needed to create the git header
git log --pretty=format:'#define GIT_INFO_PRESENT%n static const char* GIT_INFO = "Version Information=[%H,%d]\r\n";' -n 1 > ../Core/Inc/gitcommit.h
2021-06-07 04:49 AM
What ended up working for me: (im using windows STMCUBE IDE 1.5.1)
I struggled with the directories, aparently the build directory is the folder /Debug or /Release but i want to place my script in root project directory so i cd ..;
cd ..;./prebuildJaviscript.sh
The script was placed here:
Containing;
#!/bin/sh
echo "this is the pre-build script!:D"
#variables from git log https://devhints.io/git-log-format
git log --pretty=format:'#define GIT_INFO_PRESENT%n static const char* GIT_INFO = "Commit=%h,CommitDate=%at,CommitSubject=%s";' -n 1 > Core/Inc/gitcommit.h
And the cript creates this: