Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 12620:a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 28 Oct 2013 16:04:58 +0100 |
parents | 693622f11dc3 |
children | aadb188e4258 |
comparison
equal
deleted
inserted
replaced
12619:62b05f62a75c | 12620:a9f750305a38 |
---|---|
32 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool | 32 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool |
33 """ | 33 """ |
34 | 34 |
35 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch | 35 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch |
36 import textwrap | 36 import textwrap |
37 import socket | |
37 import xml.parsers.expat | 38 import xml.parsers.expat |
38 import shutil, re, xml.dom.minidom | 39 import shutil, re, xml.dom.minidom |
39 from collections import Callable | 40 from collections import Callable |
40 from threading import Thread | 41 from threading import Thread |
41 from argparse import ArgumentParser, REMAINDER | 42 from argparse import ArgumentParser, REMAINDER |
2532 generated images. | 2533 generated images. |
2533 """ | 2534 """ |
2534 | 2535 |
2535 suppliedParser = parser is not None | 2536 suppliedParser = parser is not None |
2536 | 2537 |
2537 parser = parser if suppliedParser else ArgumentParser(prog='mx build') | 2538 parser = parser if suppliedParser else ArgumentParser(prog='mx clean') |
2538 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') | 2539 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') |
2539 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') | 2540 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') |
2540 | 2541 |
2541 args = parser.parse_args(args) | 2542 args = parser.parse_args(args) |
2542 | 2543 |
2598 fmtArgs += [str(d)] | 2599 fmtArgs += [str(d)] |
2599 doc = doc.format(*fmtArgs) | 2600 doc = doc.format(*fmtArgs) |
2600 print 'mx {0} {1}\n\n{2}\n'.format(name, usage, doc) | 2601 print 'mx {0} {1}\n\n{2}\n'.format(name, usage, doc) |
2601 | 2602 |
2602 def projectgraph(args, suite=None): | 2603 def projectgraph(args, suite=None): |
2603 """create dot graph for project structure ("mx projectgraph | dot -Tpdf -oprojects.pdf")""" | 2604 """create graph for project structure ("mx projectgraph | dot -Tpdf -oprojects.pdf" or "mx projectgraph --igv")""" |
2604 | 2605 |
2606 parser = ArgumentParser(prog='mx projectgraph') | |
2607 parser.add_argument('--igv', action='store_true', help='output to IGV listening on 127.0.0.1:4444') | |
2608 parser.add_argument('--igv-format', action='store_true', help='output graph in IGV format') | |
2609 | |
2610 args = parser.parse_args(args) | |
2611 | |
2612 if args.igv or args.igv_format: | |
2613 ids = {} | |
2614 nextToIndex = {} | |
2615 igv = XMLDoc() | |
2616 igv.open('graphDocument') | |
2617 igv.open('group') | |
2618 igv.open('properties') | |
2619 igv.element('p', {'name' : 'name'}, 'GraalProjectDependencies') | |
2620 igv.close('properties') | |
2621 igv.open('graph', {'name' : 'dependencies'}) | |
2622 igv.open('nodes') | |
2623 for p in sorted_deps(includeLibs=True): | |
2624 ident = len(ids) | |
2625 ids[p.name] = str(ident) | |
2626 igv.open('node', {'id' : str(ident)}) | |
2627 igv.open('properties') | |
2628 igv.element('p', {'name' : 'name'}, p.name) | |
2629 igv.close('properties') | |
2630 igv.close('node') | |
2631 igv.close('nodes') | |
2632 igv.open('edges') | |
2633 for p in projects(): | |
2634 fromIndex = 0 | |
2635 for dep in p.canonical_deps(): | |
2636 toIndex = nextToIndex.get(dep, 0) | |
2637 nextToIndex[dep] = toIndex + 1 | |
2638 igv.element('edge', {'from' : ids[p.name], 'fromIndex' : str(fromIndex), 'to' : ids[dep], 'toIndex' : str(toIndex), 'label' : 'dependsOn'}) | |
2639 fromIndex = fromIndex + 1 | |
2640 igv.close('edges') | |
2641 igv.close('graph') | |
2642 igv.close('group') | |
2643 igv.close('graphDocument') | |
2644 | |
2645 if args.igv: | |
2646 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
2647 s.connect(('127.0.0.1', 4444)) | |
2648 s.send(igv.xml()) | |
2649 else: | |
2650 print igv.xml(indent=' ', newl='\n'); | |
2651 return | |
2652 | |
2653 | |
2605 print 'digraph projects {' | 2654 print 'digraph projects {' |
2606 print 'rankdir=BT;' | 2655 print 'rankdir=BT;' |
2607 print 'node [shape=rect];' | 2656 print 'node [shape=rect];' |
2608 for p in projects(): | 2657 for p in projects(): |
2609 for dep in p.canonical_deps(): | 2658 for dep in p.canonical_deps(): |