Mercurial > hg > truffle
comparison mxtool/mx.py @ 11759:8bcd76c3f23b
mx.py whitespace fixes
author | Mick Jordan <mick.jordan@oracle.com> |
---|---|
date | Mon, 23 Sep 2013 22:04:51 -0700 |
parents | 78e6109ee411 |
children | f3e5cbd1efae |
comparison
equal
deleted
inserted
replaced
11758:4ac92e735a16 | 11759:8bcd76c3f23b |
---|---|
516 projsMap = dict() | 516 projsMap = dict() |
517 distsMap = dict() | 517 distsMap = dict() |
518 projectsFile = join(mxDir, 'projects') | 518 projectsFile = join(mxDir, 'projects') |
519 if not exists(projectsFile): | 519 if not exists(projectsFile): |
520 return | 520 return |
521 | 521 |
522 def _find_suite_key(): | 522 def _find_suite_key(): |
523 for items in _suites.items(): | 523 for items in _suites.items(): |
524 if items[1].dir == self.dir: | 524 if items[1].dir == self.dir: |
525 return items[0] | 525 return items[0] |
526 raise KeyError | 526 raise KeyError |
527 | 527 |
528 with open(projectsFile) as f: | 528 with open(projectsFile) as f: |
529 for line in f: | 529 for line in f: |
530 line = line.strip() | 530 line = line.strip() |
531 if len(line) != 0 and line[0] != '#': | 531 if len(line) != 0 and line[0] != '#': |
532 key, value = line.split('=', 1) | 532 key, value = line.split('=', 1) |
767 return 'solaris' | 767 return 'solaris' |
768 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): | 768 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): |
769 return 'windows' | 769 return 'windows' |
770 else: | 770 else: |
771 abort('Unknown operating system ' + sys.platform) | 771 abort('Unknown operating system ' + sys.platform) |
772 | 772 |
773 def _loadSuite(d, primary=False): | 773 def _loadSuite(d, primary=False): |
774 """ | 774 """ |
775 Load a suite from the 'mx' or 'mx.bbb' subdirectory of d, where 'bbb' is basename of d | 775 Load a suite from the 'mx' or 'mx.bbb' subdirectory of d, where 'bbb' is basename of d |
776 """ | 776 """ |
777 mxDefaultDir = join(d, 'mx') | 777 mxDefaultDir = join(d, 'mx') |
826 | 826 |
827 def projects(opt_limit_to_suite=False): | 827 def projects(opt_limit_to_suite=False): |
828 """ | 828 """ |
829 Get the list of all loaded projects limited by --suite option if opt_limit_to_suite == True | 829 Get the list of all loaded projects limited by --suite option if opt_limit_to_suite == True |
830 """ | 830 """ |
831 | 831 |
832 if opt_limit_to_suite: | 832 if opt_limit_to_suite: |
833 return _projects_opt_limit_to_suites(_projects.values()) | 833 return _projects_opt_limit_to_suites(_projects.values()) |
834 else: | 834 else: |
835 return _projects.values() | 835 return _projects.values() |
836 | 836 |
969 Gets projects and libraries sorted such that dependencies | 969 Gets projects and libraries sorted such that dependencies |
970 are before the projects that depend on them. Unless 'includeLibs' is | 970 are before the projects that depend on them. Unless 'includeLibs' is |
971 true, libraries are omitted from the result. | 971 true, libraries are omitted from the result. |
972 """ | 972 """ |
973 projects = projects_from_names(projectNames) | 973 projects = projects_from_names(projectNames) |
974 | 974 |
975 return sorted_project_deps(projects, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) | 975 return sorted_project_deps(projects, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
976 | 976 |
977 def sorted_project_deps(projects, includeLibs=False, includeAnnotationProcessors=False): | 977 def sorted_project_deps(projects, includeLibs=False, includeAnnotationProcessors=False): |
978 deps = [] | 978 deps = [] |
979 for p in projects: | 979 for p in projects: |
1599 built = set() | 1599 built = set() |
1600 | 1600 |
1601 if args.only is not None: | 1601 if args.only is not None: |
1602 # N.B. This build will not include dependencies including annotation processor dependencies | 1602 # N.B. This build will not include dependencies including annotation processor dependencies |
1603 sortedProjects = [project(name) for name in args.only.split(',')] | 1603 sortedProjects = [project(name) for name in args.only.split(',')] |
1604 else: | 1604 else: |
1605 if args.projects is not None: | 1605 if args.projects is not None: |
1606 projectNames = args.projects.split(',') | 1606 projectNames = args.projects.split(',') |
1607 else: | 1607 else: |
1608 projectNames = None | 1608 projectNames = None |
1609 | 1609 |
1610 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames)) | 1610 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames)) |
1611 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled | 1611 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled |
1612 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True) | 1612 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True) |
1613 | 1613 |
1614 if args.java: | 1614 if args.java: |
2353 launch.close('launchConfiguration') | 2353 launch.close('launchConfiguration') |
2354 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no') | 2354 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no') |
2355 | 2355 |
2356 if name is None: | 2356 if name is None: |
2357 if len(suites()) == 1: | 2357 if len(suites()) == 1: |
2358 suitePrefix ='' | 2358 suitePrefix = '' |
2359 else: | 2359 else: |
2360 suitePrefix = suite.name + '-' | 2360 suitePrefix = suite.name + '-' |
2361 name = suitePrefix + 'attach-' + hostname + '-' + port | 2361 name = suitePrefix + 'attach-' + hostname + '-' + port |
2362 eclipseLaunches = join(suite.mxDir, 'eclipse-launches') | 2362 eclipseLaunches = join(suite.mxDir, 'eclipse-launches') |
2363 if not exists(eclipseLaunches): | 2363 if not exists(eclipseLaunches): |
2433 | 2433 |
2434 def eclipseinit(args, buildProcessorJars=True, refreshOnly=False): | 2434 def eclipseinit(args, buildProcessorJars=True, refreshOnly=False): |
2435 """(re)generate Eclipse project configurations and working sets""" | 2435 """(re)generate Eclipse project configurations and working sets""" |
2436 for s in suites(True): | 2436 for s in suites(True): |
2437 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly) | 2437 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly) |
2438 | 2438 |
2439 generate_eclipse_workingsets() | 2439 generate_eclipse_workingsets() |
2440 | 2440 |
2441 | 2441 |
2442 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): | 2442 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): |
2443 projectsFile = join(suite.mxDir, 'projects') | 2443 projectsFile = join(suite.mxDir, 'projects') |
2634 out.close('factorypath') | 2634 out.close('factorypath') |
2635 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) | 2635 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) |
2636 | 2636 |
2637 make_eclipse_attach(suite, 'localhost', '8000', deps=projects()) | 2637 make_eclipse_attach(suite, 'localhost', '8000', deps=projects()) |
2638 timestamp.touch() | 2638 timestamp.touch() |
2639 | 2639 |
2640 def _isAnnotationProcessorDependency(p): | 2640 def _isAnnotationProcessorDependency(p): |
2641 """ | 2641 """ |
2642 Determines if a given project is part of an annotation processor. | 2642 Determines if a given project is part of an annotation processor. |
2643 """ | 2643 """ |
2644 return p in sorted_deps(annotation_processors()) | 2644 return p in sorted_deps(annotation_processors()) |
2705 wsloc = '.metadata/.plugins/org.eclipse.ui.workbench' | 2705 wsloc = '.metadata/.plugins/org.eclipse.ui.workbench' |
2706 if os.environ.has_key('WORKSPACE'): | 2706 if os.environ.has_key('WORKSPACE'): |
2707 expected_wsroot = os.environ['WORKSPACE'] | 2707 expected_wsroot = os.environ['WORKSPACE'] |
2708 else: | 2708 else: |
2709 expected_wsroot = _mainSuite.dir | 2709 expected_wsroot = _mainSuite.dir |
2710 | 2710 |
2711 wsroot =_find_eclipse_wsroot(expected_wsroot) | 2711 wsroot = _find_eclipse_wsroot(expected_wsroot) |
2712 if wsroot is None: | 2712 if wsroot is None: |
2713 # failed to find it | 2713 # failed to find it |
2714 wsroot = expected_wsroot | 2714 wsroot = expected_wsroot |
2715 | 2715 |
2716 wsdir = join(wsroot, wsloc) | 2716 wsdir = join(wsroot, wsloc) |
2717 if not exists(wsdir): | 2717 if not exists(wsdir): |
2718 wsdir = wsroot | 2718 wsdir = wsroot |
2719 log('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.') | 2719 log('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.') |
2720 wspath = join(wsdir, wsfilename) | 2720 wspath = join(wsdir, wsfilename) |
2734 wsdoc = _copy_workingset_xml(wspath, workingSets) | 2734 wsdoc = _copy_workingset_xml(wspath, workingSets) |
2735 else: | 2735 else: |
2736 wsdoc = _make_workingset_xml(workingSets) | 2736 wsdoc = _make_workingset_xml(workingSets) |
2737 | 2737 |
2738 update_file(wspath, wsdoc.xml(newl='\n')) | 2738 update_file(wspath, wsdoc.xml(newl='\n')) |
2739 | 2739 |
2740 def _find_eclipse_wsroot(wsdir): | 2740 def _find_eclipse_wsroot(wsdir): |
2741 md = join(wsdir, '.metadata') | 2741 md = join(wsdir, '.metadata') |
2742 if exists(md): | 2742 if exists(md): |
2743 return wsdir | 2743 return wsdir |
2744 split = os.path.split(wsdir) | 2744 split = os.path.split(wsdir) |
3601 projectsFile = join(s.mxDir, 'projects') | 3601 projectsFile = join(s.mxDir, 'projects') |
3602 if exists(projectsFile): | 3602 if exists(projectsFile): |
3603 log(projectsFile) | 3603 log(projectsFile) |
3604 for p in s.projects: | 3604 for p in s.projects: |
3605 log('\t' + p.name) | 3605 log('\t' + p.name) |
3606 | 3606 |
3607 def ask_yes_no(question, default=None): | 3607 def ask_yes_no(question, default=None): |
3608 """""" | 3608 """""" |
3609 assert not default or default == 'y' or default == 'n' | 3609 assert not default or default == 'y' or default == 'n' |
3610 if not sys.stdout.isatty(): | 3610 if not sys.stdout.isatty(): |
3611 if default: | 3611 if default: |