2021-06-07 05:33 AM
I want the IDE to save inside a buildinfo.h various const strings containing build timestamp names and other system variables.
But im unable to use them inside my pre-build script:
#!/bin/sh
echo "this is the pre-build script!:D"
set _current_date=${current_date}
echo ${current_date}
echo ${_current_date}
echo "static const char BUILD_INFO[] = \"build_date=_current_date\";" > buildinfo.h
The pre-build script creates the build.infofile but the variable current_date is not shown...
Solved! Go to Solution.
2021-06-07 12:32 PM
The eclipse variables can be substituted in the command line, but not in the script file itself.
Try to change the command so:
cd..;./script.sh ${current_date}
and in the script:
#!/bin/sh
echo "this is the pre-build script!:D"
set _current_date=$1
.........
2021-06-07 05:35 AM
I first tested
#!/bin/sh
echo "this is the pre-build script!:D"
echo "static const char BUILD_INFO[] = \"build_date=${current_date}\";" > buildinfo.h
and this got generated inside buildinfo.h:
static const char BUILD_INFO[] = "build_date=";
:(
2021-06-07 06:47 AM
It works when i use the date GNU command but i would like to use the IDE build variables.
echo "this is the pre-build script!:D"
cd Core/Inc
NOW=$(date +"%Y-%m-%d_%T")
echo "static const char BUILD_INFO[] = \"build_date="$NOW"\";" > buildinfo.h
2021-06-07 12:32 PM
The eclipse variables can be substituted in the command line, but not in the script file itself.
Try to change the command so:
cd..;./script.sh ${current_date}
and in the script:
#!/bin/sh
echo "this is the pre-build script!:D"
set _current_date=$1
.........