cancel
Showing results for 
Search instead for 
Did you mean: 

What command shell is used for STM32CubeIDE's pre- and post-build steps.

nesterenborg
Associate

What shell is used to execute pre- and post-build steps in CubeIDE? It seems to be different to my system shell.

I have a pre-build (bash) script that I want to run automatically before each build. I've added the line to execute it to the projects Properties/C/C++ Build/Settings/Build steps. The script is only one line, namely:

awk -i inplace 'BEGIN{FS=OFS=" "} /SW_REV_BUILD/{match($NF, /^[0-9]+/); $NF=($NF+1) substr($NF, RLENGTH+1)}1' ${BASEDIR}/../Core/Inc/version.h
which increases the integer number in the file "version.h" after the string SW_REV_BUILD.
When I execute this file from cmd or powershell, it does exactly that. When STM32CubeIDE calls the script however, I get the following error:
nesterenborg_0-1699522613711.png

This error basically says that the awk version does not support the -i inplace option, so the version is older. If I remove the option, the file isn't edited in place but printed to the terminal, and the command works as expected (also in CubeIDE). When I launch a command shell console from CubeIDE however, and check the version of awk it is the same as my system version. It seems to me that the pre-build step is executed in a different shell enviroment.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

On Windows it is a busybox bundled with the CubeIDE host utilities, with "dash" shell and usual set of commands (awk among them). But these utilities in busybox are limited versions, compared to full-size linux. Adapt your script to the limitations, or get a newer/better busybox, or use external package of GNU utilities (Cygwin?)

 

View solution in original post

2 REPLIES 2
Bob S
Principal

Don't know what shell or what version, though I suspect it is some form of "sh".

Regardless, can you change your script to explicitly run a shell/environment that has your desired version of awk?

Pavel A.
Evangelist III

On Windows it is a busybox bundled with the CubeIDE host utilities, with "dash" shell and usual set of commands (awk among them). But these utilities in busybox are limited versions, compared to full-size linux. Adapt your script to the limitations, or get a newer/better busybox, or use external package of GNU utilities (Cygwin?)