STM32CUBEIDE how to add a custom pre & post scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-06-07 4: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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-06-02 6:31 AM
Right click project -> Properties -> C/C++ Build -> Settings -> Build Steps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-06-03 1: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}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-06-07 2: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-06-07 4: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:
