Hello there,
I'm trying to find out if there is way to implement pre- and post-builds for make without editing $(IDF_PATH)/make/project.mk file.
Pre- and Post-builds events
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Pre- and Post-builds events
You can add stuff (e.g. dependencies) to the Makefile of your project, or to a Makefile.projbuild of a component. Perhaps that helps?
Re: Pre- and Post-builds events
Could you give some example?
Some details about my question:
I have two shell-scripts prebuild.sh and postbuild.sh.
Expected execution order: prebuild.sh -> main build -> postbuild.sh
Some details about my question:
I have two shell-scripts prebuild.sh and postbuild.sh.
Expected execution order: prebuild.sh -> main build -> postbuild.sh
Re: Pre- and Post-builds events
Makefiles usually have multiple targets. Do you want these pre- and post- build event to run for all targets, or only for some? For example, targets may be 'all', 'app', 'bootloader', 'menuconfig', 'flash', etc.
Also do you want to run your scripts if the target is already built (i.e. no files have been changed)?
Also do you want to run your scripts if the target is already built (i.e. no files have been changed)?
Re: Pre- and Post-builds events
I need this events for targets that change firmware (i.e. 'all', 'menuconfig', 'defconfig', 'app', etc) and only in case when some files was changed.
If speak about my current target - I want add some kind of automatic generation of software version and use it inside in project.
In another my project I use Autorevision + Visual Studio build events.
If speak about my current target - I want add some kind of automatic generation of software version and use it inside in project.
In another my project I use Autorevision + Visual Studio build events.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Pre- and Post-builds events
Gotcha. What you can do for versioning is add a file (say, my_version.h) containing the versioning info your program uses, then tell Make how to generate this. You can do this in the component.mk of e.g. the main component of your project:
Can you also explain why you want to run the post-build script? Maybe we can come up with some useful Makefile snippet to incorporate that as well.
Code: Select all
main.o: my_version.h
my_version.h:
echo "#define BUILD_DATE \""`date`"\"" > my_version.h
Re: Pre- and Post-builds events
About your example: maybe I misunderstood it but I don't generate version manual I use autorevision for this and it generate h-file with set of defines based on git repo information. Also this h-file can be used in many places inside the program.
About post-build scripts: in another project I use it for several targets: generate firmware image for bootloader (maybe not very useful in ESP32 case) and remove h-file generated by autorevision on pre-build state - this is additional protection for case when someone didn't setup environment for autorevision's correct work because project even won't be built.
About post-build scripts: in another project I use it for several targets: generate firmware image for bootloader (maybe not very useful in ESP32 case) and remove h-file generated by autorevision on pre-build state - this is additional protection for case when someone didn't setup environment for autorevision's correct work because project even won't be built.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Pre- and Post-builds events
My guess is that I don't know what your autorevision does: my guess was that it's some script that uses a bunch of version control information to generate a header file? If so, my Makefile snippet can be used to automatically run autorevision: just change my_version.h to whatever autorevision generates and the echo line to an invocation of autorevision.
Re: Pre- and Post-builds events
Thanks for your advices!
I solve this using Makefile.projbuild for component to add particular CPPFLAGS.
I solve this using Makefile.projbuild for component to add particular CPPFLAGS.
Who is online
Users browsing this forum: No registered users and 166 guests