Mercurial > hg > truffle
comparison mxtool/mx.py @ 16846:e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 13:54:37 +0200 |
parents | 1fd7bb00a77f |
children | 043575a99815 |
comparison
equal
deleted
inserted
replaced
16845:1fd7bb00a77f | 16846:e3dd75b3c290 |
---|---|
2283 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames)) | 2283 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames)) |
2284 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled | 2284 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled |
2285 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True) | 2285 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True) |
2286 | 2286 |
2287 if args.java: | 2287 if args.java: |
2288 ideinit([], refreshOnly=True) | 2288 ideinit([], refreshOnly=True, buildProcessorJars=False) |
2289 | 2289 |
2290 def prepareOutputDirs(p, clean): | 2290 def prepareOutputDirs(p, clean): |
2291 outputDir = p.output_dir() | 2291 outputDir = p.output_dir() |
2292 if exists(outputDir): | 2292 if exists(outputDir): |
2293 if clean: | 2293 if clean: |
2572 if not os.path.isfile(args.eclipse_exe): | 2572 if not os.path.isfile(args.eclipse_exe): |
2573 abort('File does not exist: ' + args.eclipse_exe) | 2573 abort('File does not exist: ' + args.eclipse_exe) |
2574 if not os.access(args.eclipse_exe, os.X_OK): | 2574 if not os.access(args.eclipse_exe, os.X_OK): |
2575 abort('Not an executable file: ' + args.eclipse_exe) | 2575 abort('Not an executable file: ' + args.eclipse_exe) |
2576 | 2576 |
2577 eclipseinit([]) | 2577 eclipseinit([], buildProcessorJars=False) |
2578 | 2578 |
2579 # build list of projects to be processed | 2579 # build list of projects to be processed |
2580 projects = sorted_deps() | 2580 projects = sorted_deps() |
2581 if args.projects is not None: | 2581 if args.projects is not None: |
2582 projects = [project(name) for name in args.projects.split(',')] | 2582 projects = [project(name) for name in args.projects.split(',')] |
2682 if args.backup: | 2682 if args.backup: |
2683 zf.close() | 2683 zf.close() |
2684 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup)) | 2684 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup)) |
2685 return 1 | 2685 return 1 |
2686 return 0 | 2686 return 0 |
2687 | |
2688 def processorjars(): | |
2689 for s in suites(True): | |
2690 _processorjars_suite(s) | |
2691 | |
2692 def _processorjars_suite(s): | |
2693 projs = [p for p in s.projects if p.definedAnnotationProcessors is not None] | |
2694 if len(projs) <= 0: | |
2695 return [] | |
2696 | |
2697 pnames = [p.name for p in projs] | |
2698 build(['--jdt-warning-as-error', '--projects', ",".join(pnames)]) | |
2699 return [p.definedAnnotationProcessorsDist.path for p in s.projects if p.definedAnnotationProcessorsDist is not None] | |
2687 | 2700 |
2688 def pylint(args): | 2701 def pylint(args): |
2689 """run pylint (if available) over Python source files (found by 'hg locate' or by tree walk with -walk)""" | 2702 """run pylint (if available) over Python source files (found by 'hg locate' or by tree walk with -walk)""" |
2690 | 2703 |
2691 parser = ArgumentParser(prog='mx pylint') | 2704 parser = ArgumentParser(prog='mx pylint') |
3290 eclipseLaunches = join('mx', 'eclipse-launches') | 3303 eclipseLaunches = join('mx', 'eclipse-launches') |
3291 if not exists(eclipseLaunches): | 3304 if not exists(eclipseLaunches): |
3292 os.makedirs(eclipseLaunches) | 3305 os.makedirs(eclipseLaunches) |
3293 return update_file(join(eclipseLaunches, name + '.launch'), launch) | 3306 return update_file(join(eclipseLaunches, name + '.launch'), launch) |
3294 | 3307 |
3295 def eclipseinit(args, refreshOnly=False): | 3308 def eclipseinit(args, buildProcessorJars=True, refreshOnly=False): |
3296 """(re)generate Eclipse project configurations and working sets""" | 3309 """(re)generate Eclipse project configurations and working sets""" |
3297 for s in suites(True): | 3310 for s in suites(True): |
3298 _eclipseinit_suite(args, s, refreshOnly) | 3311 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly) |
3299 | 3312 |
3300 generate_eclipse_workingsets() | 3313 generate_eclipse_workingsets() |
3301 | 3314 |
3302 def _check_ide_timestamp(suite, configZip, ide): | 3315 def _check_ide_timestamp(suite, configZip, ide): |
3303 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip""" | 3316 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip""" |
3520 out.close('factorypath') | 3533 out.close('factorypath') |
3521 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) | 3534 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) |
3522 if files: | 3535 if files: |
3523 files.append(join(p.dir, '.factorypath')) | 3536 files.append(join(p.dir, '.factorypath')) |
3524 | 3537 |
3525 def _eclipseinit_suite(args, suite, refreshOnly=False): | 3538 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): |
3526 configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) | 3539 configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) |
3527 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') | 3540 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') |
3528 if refreshOnly and not configZip.exists(): | 3541 if refreshOnly and not configZip.exists(): |
3529 return | 3542 return |
3530 | 3543 |
3531 if _check_ide_timestamp(suite, configZip, 'eclipse'): | 3544 if _check_ide_timestamp(suite, configZip, 'eclipse'): |
3532 logv('[Eclipse configurations are up to date - skipping]') | 3545 logv('[Eclipse configurations are up to date - skipping]') |
3533 return | 3546 return |
3534 | 3547 |
3535 | |
3536 | |
3537 files = [] | 3548 files = [] |
3538 libFiles = [] | 3549 libFiles = [] |
3550 if buildProcessorJars: | |
3551 files += _processorjars_suite(suite) | |
3539 | 3552 |
3540 for p in suite.projects: | 3553 for p in suite.projects: |
3541 if p.native: | 3554 if p.native: |
3542 continue | 3555 continue |
3543 _eclipseinit_project(p) | 3556 _eclipseinit_project(p, files, libFiles) |
3544 | 3557 |
3545 _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=sorted_deps(projectNames=None, includeLibs=True)) | 3558 _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=sorted_deps(projectNames=None, includeLibs=True)) |
3546 files.append(launchFile) | 3559 files.append(launchFile) |
3547 | |
3548 _zip_files(files, suite.dir, configZip.path) | |
3549 _zip_files(libFiles, suite.dir, configLibsZip) | |
3550 | 3560 |
3551 # Create an Eclipse project for each distribution that will create/update the archive | 3561 # Create an Eclipse project for each distribution that will create/update the archive |
3552 # for the distribution whenever any (transitively) dependent project of the | 3562 # for the distribution whenever any (transitively) dependent project of the |
3553 # distribution is updated. | 3563 # distribution is updated. |
3554 for dist in suite.dists: | 3564 for dist in suite.dists: |
3582 out.close('projectDescription') | 3592 out.close('projectDescription') |
3583 projectFile = join(projectDir, '.project') | 3593 projectFile = join(projectDir, '.project') |
3584 update_file(projectFile, out.xml(indent='\t', newl='\n')) | 3594 update_file(projectFile, out.xml(indent='\t', newl='\n')) |
3585 files.append(projectFile) | 3595 files.append(projectFile) |
3586 | 3596 |
3597 _zip_files(files, suite.dir, configZip.path) | |
3598 _zip_files(libFiles, suite.dir, configLibsZip) | |
3599 | |
3587 def _zip_files(files, baseDir, zipPath): | 3600 def _zip_files(files, baseDir, zipPath): |
3588 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(zipPath), dir=baseDir) | 3601 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(zipPath), dir=baseDir) |
3589 try: | 3602 try: |
3590 zf = zipfile.ZipFile(tmp, 'w') | 3603 zf = zipfile.ZipFile(tmp, 'w') |
3591 for f in sorted(set(files)): | 3604 for f in sorted(set(files)): |
3836 wsdoc.open('workingSet', {'editPageID': 'org.eclipse.jdt.ui.JavaWorkingSetPage', 'factoryID': 'org.eclipse.ui.internal.WorkingSetFactory', 'id': 'wsid_' + ws, 'label': ws, 'name': ws}) | 3849 wsdoc.open('workingSet', {'editPageID': 'org.eclipse.jdt.ui.JavaWorkingSetPage', 'factoryID': 'org.eclipse.ui.internal.WorkingSetFactory', 'id': 'wsid_' + ws, 'label': ws, 'name': ws}) |
3837 | 3850 |
3838 def _workingset_element(wsdoc, p): | 3851 def _workingset_element(wsdoc, p): |
3839 wsdoc.element('item', {'elementID': '=' + p, 'factoryID': 'org.eclipse.jdt.ui.PersistableJavaElementFactory'}) | 3852 wsdoc.element('item', {'elementID': '=' + p, 'factoryID': 'org.eclipse.jdt.ui.PersistableJavaElementFactory'}) |
3840 | 3853 |
3841 def netbeansinit(args, refreshOnly=False): | 3854 def netbeansinit(args, refreshOnly=False, buildProcessorJars=True): |
3842 """(re)generate NetBeans project configurations""" | 3855 """(re)generate NetBeans project configurations""" |
3843 | 3856 |
3844 for suite in suites(True): | 3857 for suite in suites(True): |
3845 _netbeansinit_suite(args, suite, refreshOnly) | 3858 _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars) |
3846 | 3859 |
3847 def _netbeansinit_suite(args, suite, refreshOnly=False): | 3860 def _netbeansinit_suite(args, suite, refreshOnly=False, buildProcessorJars=True): |
3848 configZip = TimeStampFile(join(suite.mxDir, 'netbeans-config.zip')) | 3861 configZip = TimeStampFile(join(suite.mxDir, 'netbeans-config.zip')) |
3849 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') | 3862 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') |
3850 if refreshOnly and not configZip.exists(): | 3863 if refreshOnly and not configZip.exists(): |
3851 return | 3864 return |
3852 | 3865 |
4298 log("Error removing {0}".format(p.name + '.jar')) | 4311 log("Error removing {0}".format(p.name + '.jar')) |
4299 | 4312 |
4300 for d in _dists.itervalues(): | 4313 for d in _dists.itervalues(): |
4301 shutil.rmtree(d.get_ide_project_dir(), ignore_errors=True) | 4314 shutil.rmtree(d.get_ide_project_dir(), ignore_errors=True) |
4302 | 4315 |
4303 | 4316 def ideinit(args, refreshOnly=False, buildProcessorJars=True): |
4304 def ideinit(args, refreshOnly=False): | |
4305 """(re)generate Eclipse, NetBeans and Intellij project configurations""" | 4317 """(re)generate Eclipse, NetBeans and Intellij project configurations""" |
4306 eclipseinit(args, refreshOnly=refreshOnly) | 4318 eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
4307 netbeansinit(args, refreshOnly=refreshOnly) | 4319 netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
4308 intellijinit(args, refreshOnly=refreshOnly) | 4320 intellijinit(args, refreshOnly=refreshOnly) |
4309 if not refreshOnly: | 4321 if not refreshOnly: |
4310 fsckprojects([]) | 4322 fsckprojects([]) |
4311 | 4323 |
4312 def fsckprojects(args): | 4324 def fsckprojects(args): |