vak/makefile2dot

Does not take target-local variable assignments into account

Opened this issue · 1 comments

I am actually coming from the fork at https://github.com/chadsgilbert/makefile2dot, which is linked by the PyPI page at https://pypi.org/project/makefile2dot/. However, there I cannot create issues and I am assuming, that the same issue persists in this repository:

In Makefiles one can assign variables locally for only one target. For example:

target1: SOME_VAR := some_value
target1:
    printf "%s\n" "${SOME_VAR}"

When this kind of Makefile is input for makefile2dot, then makefile2dot fails:

$ makefile2dot
Traceback (most recent call last):
  File "LOCATION_OF_MYVENV/bin/makefile2dot", line 23, in <module>
    makefile2dot(direction=ARGS.direction, output=ARGS.output, view=ARGS.view)
  File "LOCATION_OF_MYVENV/lib/python3.10/site-packages/makefile2dot/__init__.py", line 71, in makefile2dot
    graph = build_graph(stream_database(), direction=direction)
  File "LOCATION_OF_MYVENV/lib/python3.10/site-packages/makefile2dot/__init__.py", line 39, in build_graph
    target, dependencies = line.split(':')
ValueError: too many values to unpack (expected 2)
make: *** [Makefile:385: makefile-graph] Error 1

makefile2dot does not take local variable assignment syntax into account and runs into an error.

vak commented

thank you for your interest.

This project was just to solve the task I was having. I never considered this project seriously :)
Feel free to clone, fix and enrich it!