How to preprocess HTML files before "spiffs_create_partition_image"

mbedninja
Posts: 2
Joined: Fri Apr 12, 2019 9:39 am

How to preprocess HTML files before "spiffs_create_partition_image"

Postby mbedninja » Mon Dec 09, 2019 10:11 am

Hello.
I would like to know how to invoke xtensa-esp32 preprocessor over HTML files?
This needs to be done before execution of spiffs_create_partition_image.
I mean what should be written (and where: MakeFile or component.mk, looking at restful_server example it must be in the Makefile right before

Code: Select all

$(eval $(call spiffs_create_partition_image,www,$(WEB_SRC_DIR)/dist,FLASH_IN_PROJECT))
Normally I manage to accomplish this by manually launching a bat file before a compilation and the bat contains the following:

Code: Select all

@ECHO OFF
SET TOOL_DIR=C:\msys32\opt\xtensa-esp32-elf\bin
%TOOL_DIR%\xtensa-esp32-elf-gcc -E -x c -P -C index_template.html -o index.html
Obviously i need to automate this by using the make itself but how?

Little background:
I am trying to build a little web server (for a smart socket if it's matter). Thanks to the restful esample I have no problem with that.
The headache begin when I have to keep parameters names in sync (between the name arguments of html tags and the name of the variables in the code, consuming the info from the tags in the post handlers). Easiest approach is to use the preprocessor. This way the names and default values of the parameters are defined in one particular .h file only. Any subsequent change of the name or the value will be automatically done for the html too.

And this is last I promise:
It would really be nice to keep the comments in the .h file!
Is there any way to make preprocessor ignore the comments in the input .h file so they not be pasted out in the output (they mess the output html).

Who is online

Users browsing this forum: Bing [Bot], ok-home and 136 guests