vak / makefile2dot Goto Github PK
View Code? Open in Web Editor NEWVisualize your Makefile using GraphViz dot utility
Visualize your Makefile using GraphViz dot utility
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.
I realize you're probably not interested in maintaining this program any more, but just in case: I downloaded a copy and made a couple changes to make it work better. First, changed the print statements to Python3 (actually, to stderr.write(...) statements).
More importantly, I added code to chop off comments (which were being interpreted as if they were makefile code), and to escape '%'. I'm not sure why the latter is necessary, but without it "%.foo" turns into something like "%27". The line in question was
line_to_emit += line
and is now
line_to_emit += line.split('#')[0].replace('%', '\%')
There are some other things going on that I haven't been able to pin down, but as you say, it was experimental...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.