Another crack at per-target .ONESHELL.

The major problem with v3 was that the shared struct commands for
implicit rules, .DEFAULT rules suffix rules etc. caused use of .ONESHELL
with any target covered by such a rules to "infect" other targets
sharing the recipe (but not themselves named as .ONESHELL prerequisites)
with oneshell-ness.  That isn't how other special targets work wrt
their dependencies and would obviously be a bug.

The current version here "fixes" this by adding oneshell_* versions of
some struct commands fields and using them as appropriate.  I added a
bunch of tests to ensure I'd found all the sharing and handled it
correctly.

That said I really think that conforming exactly to the behavior of
other special targets isn't the way to go here.  It would be better to
just consider it an error when a recipe is evaluated as both oneshell
and non-oneshell within the same run of make.  .ONESHELL: is different
than other special targets in that it deals with an intrinsic property
of recipes, rather than with the DAG or external management of targets.
It's hard to imagine a user really wanting the same recipe to be run in
different ways wrt oneshell: almost certainly they just have an
incomplete list in their .ONESHELL dependency.  There are comments in
the remaining FIXMEs in the last commit ("Many more tests") that explain
my reasoning a bit more.

So what I propose for the next (and hopefully final) version of this
patch is to use the carefully located sharing cases and turn them into
informative error messages, and simplify the implementation by removing
the extra fields in struct commands that accomodate the alternate
oneshell versions of things in favor of a single field that records the
resolved one-shellness of the recipe st an error can be produced if it
changes.  It might be desirable to also record target name that caused
resolution so it could be reported in the diagnostic.

Please note the first four patch in this series is concerned with my
personal dev setup and can mostly be ignored while considering this
patch (obviously the slight remaining dependency on this stuff will be
stripped out eventually).

Britton Leo Kerin (3):
  Add my logging setup
  Support per-target .ONESHELL
  Tests for .ONESHELL with a prerequisite

 .gitignore                     |   2 +
 Makefile.am                    |  54 ++-
 cflow.rc                       |  16 +
 src/.cscope_rebuild_commands   |   1 +
 src/commands.c                 | 206 +++++---
 src/commands.h                 |  18 +-
 src/default.c                  |   3 +
 src/file.c                     |  11 +
 src/filedef.h                  |   2 +
 src/job.c                      |  89 +++-
 src/main.c                     |  14 +-
 src/makeint.h                  |   2 +-
 src/myMakeLog.c                |  31 ++
 src/myMakeLog.h                |  12 +
 src/read.c                     |   8 -
 src/remake.c                   |  34 +-
 tests/scripts/targets/ONESHELL | 848 +++++++++++++++++++++++++++++++++
 17 files changed, 1244 insertions(+), 107 deletions(-)
 create mode 100644 cflow.rc
 create mode 100644 src/.cscope_rebuild_commands
 create mode 100644 src/myMakeLog.c
 create mode 100644 src/myMakeLog.h


base-commit: d523661ce21a16535d53fe56a3d3d8824432e18e
--
2.43.0


Reply via email to