Pre-build command is always executed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pre-build command is always executed

491 Views
biafra
Senior Contributor I

Hi everyone,

 

I'm using MCUXpresso 11.9.1.

I noticed that if I build a project the pre-build command is always executed (if it is configured) regardless the project is up to date or not.

 

In the MCUXpresso online help it's stated that the pre-build command is not executed if the project is up to date.

biafra_0-1716884066299.png

 

This is a part of the makefile generated in the build process:

 

# All Target
all:
	+@$(MAKE) --no-print-directory pre-build && $(MAKE) --no-print-directory main-build && $(MAKE) --no-print-directory post-build

 

 

In the "all" target there are no dependencies, so the target is always executed.

 

To reproduce the issue, I create a new project and I buld it. The first time it is built, the following times it is executed only the post-build command (that is automatically configured on the project creation step).

Then I create a simple batch script prebuild.cmd and configure it to be executed as pre-build step:

 

echo ==== Executing pre-build command ====

 

 

Then, every time I build the project, there is always the message in the build console, even if nothing is modified in the project.

 

Did I forget some configuration so that the pre-build command is executed only if the project is not up to date?

 

Many thanks

Biafra

4 Replies

308 Views
AdrianOltean
NXP Employee
NXP Employee

I don't think that's a problem. Even your analysis shows that execution of pre-build steps is part of the "make all" - "pre-build" is added by the managed build system from CDT. I think that the part related to determining whether the project is up to date is actually done from Eclipse/CDT and it has nothing do do with the generated makefiles. In other words, if Eclipse/CDT determines that project build must not be triggered, pre-build/post-build steps will implicitly not be invoked because "make all" is not invoked.

As far as I'm concerned, it functions as designed with one note - it's unclear from the Eclipse documentation what is the strategy used to determine whether a function is "up to date" or not.

Thanks,

Adrian

302 Views
biafra
Senior Contributor I

Hi @AdrianOltean,

 

Many thanks for your answer.

 

My goal is to force to build a file that contains the build date (__DATE__) variable and the build count variable, but only if other files have to be built.

I thought to delete the build.o file to force the rebuid of build.c file. So it's problem for me if the prebuild step command is called if no file has to be built. This way the bulid.c file is built every time I call the build process, because the prebuild command deletes the build.o file (and implicitly forces the build count to be updated).

biafra_1-1718034763137.png

The imagine above shows the output of the build console when the project isn't built, but the pre build command is called anyway.

 

Many thanks

Biafra

 

 

265 Views
AdrianOltean
NXP Employee
NXP Employee

I think you'll have to rely on actual makefiles to address your use case. Please inspect one generated makefile and note the "makefile.defs", "makefile.init" and "makefile.targets" that you can contribute to a generated makefile. Also, you have the Behavior tab in the C/C++ Build section of the project's build properties that you can play with, and maybe call custom make targets. It's all Eclipse/CDT-specific implementation so you'll probably find related documentation on the web,

Thanks,

Adrian

467 Views
biafra
Senior Contributor I

Hi everyone,

 

Update:

There is the same behaviour for the post-build command too.

 

Many thanks

Biafra