Page MenuHomeVyOS Platform

Use m4 as a template processor
Open, WishlistPublic

Description

Right now interface definitions are preprocessed with the GCC preprocessor. This has the consequence that they can't include lines that are interpreted by the GCC preprocessor as directives or C comment start or end anchors, like # comments and path/wildcards/*.

m4 is made exactly for this use case, templating, so it would be much more suitable.

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible

Event Timeline

jjakob triaged this task as Wishlist priority.Fri, Jul 31, 4:31 PM
jjakob created this task.
jjakob created this object in space S1 VyOS Public.

There is now some python XML code to parse the XML. m4 is not a nice tool. If better pre-processing is required, which I would not argue for, please explain the issue you are trying to solve.

If anything this code could/should be extracted in an internal library and then a tool created to replace what we have so the behaviour is consistent in both cases.

thomas-mangin added a comment.EditedFri, Jul 31, 4:55 PM

And there are some PR pending on that exact code ..

jjakob added a comment.Tue, Aug 4, 2:31 PM

I wasn't trying to solve any specific issue. I was working on some other project, trying to use GCC as a preprocessor, the same way as it's used here, and ran into those obstacles I listed in the original description, which are present here too. I was made aware m4 is much more suitable to template processing than GCC as it was actually designed and made for it.
As for using any self-made code to do this, I have no problem with that as long as it's well known this is what is now used, is documented, and then an effort made to port all preprocessing to it. I see no sense using two or three different preprocessors.