How to assure pre-build action finishes before proceeding?

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

How to assure pre-build action finishes before proceeding?

Jump to solution
4,846 Views
robertpoor
Senior Contributor I

I'm using the Pre-build steps and Post-build-steps feature of KDS 3.2. (Yes, I will switch to MCUXpresso as soon as I can figure out how to create a Bootloader Configuration Area in MCUXpresso.)

I have observed that the build process proceeds asynchronously: it doesn't wait for the pre-build script to complete before moving on.  In my case, that causes an error, since the pre-build step creates a file that is required by other parts of the build.

Question: is there a way to make the pre-build step synchronous, that is, cause the build process to wait until the pre-build step completes?

To demonstrate the problem, here are two simple scripts, pre-build.sh and post-build.sh.  pre-build creates a file, post-build prints out its size.  Note that pre-build.sh imposes an artificial ten second delay to expose the problem.

file: pre-build.sh

#/bin/sh
/bin/echo === pre start ===
rm -f woof.txt
sleep 10
/bin/echo woof > woof.txt
/bin/echo -n pre `date "+%H:%M:%S"` " "
ls -l woof.txt
/bin/echo === pre end ===

file: post-build.sh

#/bin/sh
/bin/echo === post start ===
/bin/echo -n post `date "+%H:%M:%S"` " "
ls -l woof.txt
/bin/echo === post end ===

The result of running:

**** Incremental Build of configuration Debug for project myproj ****
make -j7 pre-build main-build 
./pre-script.sh
Building file: ../source/probe.c
=== pre start ===
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -O0 ...
Finished building: ../source/probe.c
 
Building target: myproj.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -O0 ...
Finished building target: myproj.elf
 
make --no-print-directory post-build
./post-script.sh
=== post start ===
ls: woof.txt: No such file or directory
post 18:16:45 === post end ===
 
Invoking: Cross ARM GNU Create Flash Image
arm-none-eabi-objcopy -O srec "myproj.elf" "myproj.srec"
Invoking: Cross ARM GNU Print Size
arm-none-eabi-size --format=berkeley "myproj.elf"
 text data bss dec hex filename
 35124 1516 3216 39856 9bb0 myproj.elf
Finished building: myproj.siz
Finished building: myproj.srec
 
pre 18:16:55 -rw-r--r-- 1 r staff 5 Sep 18 18:16 woof.txt
=== pre end ===
 
18:16:55 Build Finished (took 10s.162ms)

Note that pre-build created the file long after post-build (unsuccessfully) tried to access it.

Labels (1)
0 Kudos
1 Solution
4,431 Views
robertpoor
Senior Contributor I

Suspecting that this is a generic problem with Eclipse and not a problem specific to KDS, I found  "Bug 501065 - Pre-build steps not terminated before build is started with enabled parallel build op... in the Eclipse bug database.

And good news: In Project => Properties => C/C++ Build => [Behavior], unchecking the "Enable Parallel Build" box forces the pre-build step to complete before moving on to the rest of the build.

Solved.

View solution in original post

0 Kudos
2 Replies
4,394 Views
wrljet
Contributor II

A perhaps better workaround, that will let you keep the parallel builds, can be found here:

Parallel build using generated makefile doesn't manage dependencies 

Until CDT 9.3 is out, the following workaround can be used:


1. Add a makefile.init in the project root with the following content:
allwithpre :
    $(MAKE) --no-print-directory pre-build
    $(MAKE) --no-print-directory main-build
2. Remove the pre-build task from the configuration
3. In the project settings, C/C++ Build -> Behavior -> Workbench Build Behavior, Change "all" to "allwithpre"

 

4,432 Views
robertpoor
Senior Contributor I

Suspecting that this is a generic problem with Eclipse and not a problem specific to KDS, I found  "Bug 501065 - Pre-build steps not terminated before build is started with enabled parallel build op... in the Eclipse bug database.

And good news: In Project => Properties => C/C++ Build => [Behavior], unchecking the "Enable Parallel Build" box forces the pre-build step to complete before moving on to the rest of the build.

Solved.

0 Kudos