Arduino Forum

Development => Other Software Development => Topic started by: stephan14x on Dec 06, 2017, 08:04 pm

Title: hook into preprocessor
Post by: stephan14x on Dec 06, 2017, 08:04 pm
Hi,

is there a way to add a step before the normal arduino preprocessor starts its work?

Some background information:

I'm using arduino IDE for ESP8266 dev work where the esp is serving websites.

I'd like to use .css .js and .html files within the arduino project folder and minify them and generate a temp .ino file where the content of each file is set as a variable value.

After that the normal build process should start.

Any ideas?

Thanks
Title: Re: hook into preprocessor
Post by: pert on Dec 06, 2017, 11:25 pm
There is a list of hooks here:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#pre-and-post-build-hooks-since-ide-165 (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#pre-and-post-build-hooks-since-ide-165)
but I'm guessing recipe.hooks.sketch.prebuild.NUMBER.pattern actually happens after the sketch preprocessing. Is that correct?

I don't see any reason why you would need your generated file to be run through the preprocessor though. How about turn it into a .h file and copy it to the temporary build folder. It would be brought into your sketch by an include of the generated .h file. If you do that then recipe.hooks.sketch.prebuild.NUMBER.pattern should work fine for your needs.
Title: Re: hook into preprocessor
Post by: stephan14x on Dec 07, 2017, 08:15 pm
hi pert,

thanks for your response.

This is all new to me and you helped me a lot.

I will build a prototype and see if it can do what I need.

Thanks
Title: Re: hook into preprocessor
Post by: pert on Dec 07, 2017, 11:27 pm
I'd be interested to hear how it goes. It sounds like a cool project. I don't see these hooks used very often but it's nice the Arduino developers added them.
Title: Re: hook into preprocessor
Post by: stephan14x on Dec 08, 2017, 08:47 am
Hi,

I've started documenting my "progress" on my blog.

Starting a rudimentary HTML template and code minifier for Arduino IDE and ESP8266 (http://www.evidente.de/2017/12/rudimentary-html-template-and-code-minifier-for-arduino-ide-and-esp8266/)