Giter VIP home page Giter VIP logo

makefileviz's Introduction

MakefileViz

Background

Started as a project to help debugging makefiles marshaling non trivial bioinformatics pipelines in the mid 2000's, did its job and was promptly forgotten. Resurrected spring 2014 in a more open environment and released into the wild.

Goal

Create a graphical representation of a makefile targets and their dependencies.

Sample MakefileViz ourput

Requirements

  • errr ... practically none ("We don't need no steenking requirements")
  • Pretty much any *nix based system or other OS with make & awk ported.
  • And any tool to view or convert GraphViz's dot format files into an image.

Reasons

  • Evidence you are doing what you intend without lapses or redundancy.
  • Figuring out what someone else (or previous self) was thinking.
  • Live Documentation

Process

  • convert the Makefile into a partially ordered set.
  • convert a partial ordered set into the dot directed graph format
  • generate an image of the dot file

Usage

One Way

include introspect.makefile in your makefile
(or another file included by your makefile)
adjust paths to dot and the awk scripts if necessary,
then issue

    make introspect  

you can also invoke the introspect_clean target to delete the files created.

Another Way

Call the awk scripts yourself on the command line
without needing to include anything in the makefile.
something like:

   makefile2po.awk yourmakefile | potodot.awk -v "TAG=graphname" | dot -Tpng -o graphname.png

This gives an easy opportunity to filter out or modify labels before the pipe to potodot.awk

ex:

    makefile2po.awk yourmakefile | grep -vE "PHONY|clean" | potodot.awk ...

to keep housekeeping nodes & edges from cluttering up the graph.

Other uses include topologically sorting the makefile labels to help find critical paths

   makefile2po.awk yourmakefile | tsort

Or use potodot.awk to turn any reasonable list of pairs into a graph!

(where reasonable is defined by what the GraphViz dot format accepts as node labels)

Notes

Designed to take the fairly straightforward makefiles I tend to generate building data processing workflows and reduce them to a simplified 'adjacency list' aka 'partially ordered set'.

Currently excluding nodes not participating in an edge but I may revisit that.

Depending on how you want to look at it

  • root nodes are displayed as rectangular boxes
  • interior nodes are ovals
  • leaf nodes are bolded ovals
  • dependency arrows point to targets that required them

Limitations

It is just using pattern matching, not full on parsing of makefiles.
So it will not understand suffix rules, conditionals or looping etc.

It will remove all the decorations (non alphanumeric and underscore)
from the labels so your labels should not only differ by decoration if that is important.
i.e. nodes that are not the same being collapsed together.

makefileviz's People

Contributors

bibermann avatar tomconlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mdperry

makefileviz's Issues

Dot error with makefile rule 'subgraph'

This is a rare issue, but in case someone else might have it, it might be worth documenting:

If there is a Makefile rule which is identical to a Dot keyword (in my case, subgraph), the potodot.awk script will produce syntactically invalid DOT, which will then fail when given to dot, with errors such as syntax error in line X near '->', or syntax error in line Y near '['. The solution is simply to rename the target, e.g. subgraph_.

It seems that using double quotes around target names is sufficient to prevent this from happening. I did a quick test and it seemed to work, but I didn't look too much into it, to see if there were downsides.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.