Skip to main content
RAltm
Senior
Feb 13, 2021 10:59 AM UTC
Solved

[solved] CubeIDE: using __date__/__time__ macros & force rebuild of files using them

Hello,

I'm using the __date__/__time__ macros. Their values are only updated if the file using them is re-compiled. Cleaning up before building forces the values to be updated, but this is not feasible on bigger projects.

Is there a way to tell CubeIDE that a specific file always has to be rebuild? I only found solutions for makefiles, but CubeIDE is not using makefiles.

Regards

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
Feb 13, 2021 1:17 PM UTC

You can add a pre-build step in the C/C++ Build Settings. The pre-build step can be any command like touch or a shell script generating a version file etc..

10 replies

Pavel A.
Feb 13, 2021 12:22 PM UTC

>  but CubeIDE is not using makefiles

Nevertheless if you touch a source file, eclipse usually recompiles it.

-- pa

KnarfB
KnarfBBest answer
Super User
Feb 13, 2021 1:17 PM UTC

You can add a pre-build step in the C/C++ Build Settings. The pre-build step can be any command like touch or a shell script generating a version file etc..

RAltm
RAltmAuthor
Senior
Feb 14, 2021 9:07 AM UTC

Hello Pavel & KnarfB,

okay, I'll check those ways. I'll have to figure out if Windows has a function similar to the touch command on Linux.

Thank you.

Regards

KnarfB
Super User
Feb 14, 2021 10:01 AM UTC

Hi RAltm,

copy/b test.txt +,,

does the trick in Windows. A real "touch" comes with the STM32CubeIDE plugins like:

C:\ST\STM32CubeIDE\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_1.5.0.202011040924\tools\bin\busybox.exe touch test.txt

Your path may vary

hth

KnarfB

Pavel A.
Feb 14, 2021 11:51 AM UTC

Actually much easier. Just make a small change in the file, undo, save. Or, delete corresponding object files.

-- pa

robmilne
Associate II
Dec 13, 2024 7:06 PM UTC

As in previous replies, touching the file will force a recompile of the file.  In my case I need to recompile a version.c file to capture __date__ and __time__ for every build and was able to do so with the following line as the pre-build step command.  The path refers to the directory structure within the build directory.

if [ -f path/to/version.o ]; then rm path/to/version.o; fi


-rob