Page MenuHomeVyOS Platform

Use m4 as a template processor
Closed, ResolvedPublic

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
Issue type
Internal change (not visible to end users)

Event Timeline

jjakob triaged this task as Wishlist priority.Jul 31 2020, 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.

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

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.

Yes the GCC preprocessors is limited (but works for the current use case) and m4 is indeed more powerful but not a user-friendly tool IMHO.

erkin claimed this task.
erkin added a subscriber: erkin.

A small ad hoc in-house script obviated the need for a separate preprocessor.