evmar / n2

n2 ("into"), a ninja compatible build system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation mode

evmar opened this issue · comments

In various places like #80 we relax the rules to accommodate some questionable Ninja behaviors.

We currently key some of these off a "ninja compat" flag, but I wonder if it would be better to make some sort of explicit mode flag that is extra strict.

I think there are basically two categories of users of n2:

  • people who are just trying to build something and at the mercy of whatever their build system emits; n2 emitting warnings doesn't help them much
  • people who are working explicitly on generating ninja files, e.g. CMake authors; n2 helping them find bugs is helpful

This is very similar to the question of whether you want to enable -Werror on a project, where you have the same two categories of people.

(I wrote a much longer post with some thoughts about -Werror here https://neugierig.org/software/blog/2022/01/rethinking-errors.html )

I think it would be good if n2 had a kind of "capabilities" config file, where each little thing that could be stricter was a separate flag. "ninja compat" mode would be one built-in configuration, and "strict" mode would be another. But projects could start out in ninja compat mode and turn on flags one by one until they eventually reach strict mode.

I think there would probably multiple "editions" (like rust's editions) of strict mode as well, where we have a certain strict mode edition to start, but then when we add more checks we don't want to add them to that strict mode because it will break existing users, but instead we add a new edition of strict mode that has the checks enabled.

It just occurred to me that a reasonable place to put configuration like this is in the ninja file itself, given that the generator is the tool where you know what settings you care about. You could imagine some sort of like

config
  missing_depfiles = error

kind of block, though it would mean breaking syntax compatibility with Ninja. (Ninja already has some configurationy stuff in magic globals that ought to have been done this way)