Mercurial > hg > truffle
comparison mxtool/mx.py @ 6509:534c45127aad
added packageinfo command
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 04 Oct 2012 19:54:22 +0200 |
parents | 305b9166b455 |
children | 3c5b19e8f2a3 |
comparison
equal
deleted
inserted
replaced
6508:84cdfa55d23c | 6509:534c45127aad |
---|---|
2390 | 2390 |
2391 else: | 2391 else: |
2392 # no package description given | 2392 # no package description given |
2393 pass | 2393 pass |
2394 | 2394 |
2395 def packageinfo(args): | |
2396 """show Java packages defined by each project""" | |
2397 | |
2398 parser = ArgumentParser(prog='packageinfo') | |
2399 parser.add_argument('-l', action='store_true', help='show packages one per line') | |
2400 parser.add_argument('filters', nargs=REMAINDER, metavar='filters...', help='substrings filtering the projects processed') | |
2401 | |
2402 args = parser.parse_args(args) | |
2403 filters = args.filters | |
2404 | |
2405 projects = sorted_deps() | |
2406 | |
2407 projToPkgs = dict() | |
2408 pkgToProjs = dict() | |
2409 for p in projects: | |
2410 if len(filters) == 0 or len([f for f in filters if f in p.name]) != 0: | |
2411 pkgs = set() | |
2412 projToPkgs[p.name] = pkgs | |
2413 for sourceDir in p.source_dirs(): | |
2414 for root, _, files in os.walk(sourceDir): | |
2415 if len([name for name in files if name.endswith('.java')]) != 0: | |
2416 pkg = root[len(sourceDir) + 1:].replace(os.sep,'.') | |
2417 pkgs.add(pkg) | |
2418 pkgToProjs.setdefault(pkg, set()).add(p.name) | |
2419 | |
2420 for key,value in projToPkgs.iteritems(): | |
2421 if args.l: | |
2422 print key, 'defines packages:' | |
2423 for v in value: | |
2424 print ' ', v | |
2425 else: | |
2426 print key, 'defines packages:', ', '.join(value) | |
2427 | |
2428 for key,value in pkgToProjs.iteritems(): | |
2429 if len(value) > 1: | |
2430 print 'package', key, 'is defined by multiple projects:', ', '.join(value) | |
2431 | |
2395 def site(args): | 2432 def site(args): |
2396 """creates a website containing javadoc and the project dependency graph""" | 2433 """creates a website containing javadoc and the project dependency graph""" |
2397 | 2434 |
2398 parser = ArgumentParser(prog='site') | 2435 parser = ArgumentParser(prog='site') |
2399 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>') | 2436 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>') |
2597 'javap': [javap, ''], | 2634 'javap': [javap, ''], |
2598 'javadoc': [javadoc, '[options]'], | 2635 'javadoc': [javadoc, '[options]'], |
2599 'site': [site, '[options]'], | 2636 'site': [site, '[options]'], |
2600 'netbeansinit': [netbeansinit, ''], | 2637 'netbeansinit': [netbeansinit, ''], |
2601 'projects': [show_projects, ''], | 2638 'projects': [show_projects, ''], |
2639 'packageinfo': [packageinfo, '[options]'], | |
2602 } | 2640 } |
2603 | 2641 |
2604 _argParser = ArgParser() | 2642 _argParser = ArgParser() |
2605 | 2643 |
2606 def _findPrimarySuite(): | 2644 def _findPrimarySuite(): |