Mercurial > hg > truffle
annotate mxtool/mx.py @ 17159:ef5212ce8091
support for new projects file format including support for automatically updating from old format
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 19 Sep 2014 13:48:53 +0200 |
parents | 2f64a6c771d5 |
children | 30dda118ef3d |
rev | line source |
---|---|
13470
eb7bc1fd38de
made mx.py (first line) more portable
Doug Simon <doug.simon@oracle.com>
parents:
13358
diff
changeset
|
1 #!/usr/bin/env python2.7 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 # ---------------------------------------------------------------------------------------------------- |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 # |
4186
71a2cd79c375
Made stdout for mx unbuffered.
Doug Simon <doug.simon@oracle.com>
parents:
4180
diff
changeset
|
5 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 # This code is free software; you can redistribute it and/or modify it |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 # under the terms of the GNU General Public License version 2 only, as |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 # published by the Free Software Foundation. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 # This code is distributed in the hope that it will be useful, but WITHOUT |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 # version 2 for more details (a copy is included in the LICENSE file that |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 # accompanied this code). |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License version |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 # 2 along with this work; if not, write to the Free Software Foundation, |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 # or visit www.oracle.com if you need additional information or have any |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 # questions. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 # ---------------------------------------------------------------------------------------------------- |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 # |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
28 r""" |
12553
9af82ca3f225
mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents:
12524
diff
changeset
|
29 mx is a command line tool for managing the development of Java code organized as suites of projects. |
9af82ca3f225
mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents:
12524
diff
changeset
|
30 |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
31 Version 1.x supports a single suite of projects. |
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
32 |
12553
9af82ca3f225
mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents:
12524
diff
changeset
|
33 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
34 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
17012
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
36 import sys, os, errno, time, subprocess, shlex, types, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch, platform |
15823
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
37 import multiprocessing |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
38 import textwrap |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
39 import socket |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
40 import tarfile |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
41 import hashlib |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
42 import xml.parsers.expat |
8447
b6b9ab1fde62
removed support for using the Eclipse batch compiler bundled with Eclipse - depending on the version, it has bugs with respect to annotation processing
Doug Simon <doug.simon@oracle.com>
parents:
8439
diff
changeset
|
43 import shutil, re, xml.dom.minidom |
13950
35783e78eaef
mx.run: shell-escape arguments when printing them in verbose mode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13927
diff
changeset
|
44 import pipes |
14626
4f8268dee8aa
mx: eclipseformat now prints all the changes that were found to the console.
Christian Humer <christian.humer@gmail.com>
parents:
14553
diff
changeset
|
45 import difflib |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
46 from collections import Callable, OrderedDict |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 from threading import Thread |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 from argparse import ArgumentParser, REMAINDER |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
49 from os.path import join, basename, dirname, exists, getmtime, isabs, expandvars, isdir, isfile |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
51 _projects = dict() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
52 _libs = dict() |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
53 _jreLibs = dict() |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
54 _dists = dict() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
55 _suites = dict() |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
56 _annotationProcessors = None |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
57 _primary_suite_path = None |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
58 _primary_suite = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
59 _opts = None |
14763 | 60 _java_homes = None |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
61 _warn = False |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
62 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
63 """ |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
64 A distribution is a jar or zip file containing the output from one or more Java projects. |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
65 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
66 class Distribution: |
17059
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
67 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance): |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
68 self.suite = suite |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
69 self.name = name |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
70 self.path = path.replace('/', os.sep) |
14964
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
71 self.path = _make_absolute(self.path, suite.dir) |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
72 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
73 self.deps = deps |
8134
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
74 self.update_listeners = set() |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
75 self.mainClass = mainClass |
15577
406a94c03ffa
truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents:
15497
diff
changeset
|
76 self.excludedDependencies = excludedDependencies |
15638
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
77 self.distDependencies = distDependencies |
17059
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
78 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None |
14775
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
79 |
16667
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
80 def sorted_deps(self, includeLibs=False, transitive=False): |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
81 deps = [] |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
82 if transitive: |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
83 for depDist in [distribution(name) for name in self.distDependencies]: |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
84 for d in depDist.sorted_deps(includeLibs=includeLibs, transitive=True): |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
85 if d not in deps: |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
86 deps.append(d) |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
87 try: |
15577
406a94c03ffa
truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents:
15497
diff
changeset
|
88 excl = [dependency(d) for d in self.excludedDependencies] |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
89 except SystemExit as e: |
15577
406a94c03ffa
truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents:
15497
diff
changeset
|
90 abort('invalid excluded dependency for {} distribution: {}'.format(self.name, e)) |
16667
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
91 return deps + [d for d in sorted_deps(self.deps, includeLibs=includeLibs) if d not in excl] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
92 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
93 def __str__(self): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
94 return self.name |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
95 |
8134
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
96 def add_update_listener(self, listener): |
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
97 self.update_listeners.add(listener) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
98 |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
99 """ |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
100 Gets the directory in which the IDE project configuration |
16849
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
101 for this distribution is generated. If this is a distribution |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
102 derived from a project defining an annotation processor, then |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
103 None is return to indicate no IDE configuration should be |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
104 created for this distribution. |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
105 """ |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
106 def get_ide_project_dir(self): |
16849
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
107 if hasattr(self, 'definingProject') and self.definingProject.definedAnnotationProcessorsDist == self: |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
108 return None |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
109 if hasattr(self, 'subDir'): |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
110 return join(self.suite.dir, self.subDir, self.name + '.dist') |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
111 else: |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
112 return join(self.suite.dir, self.name + '.dist') |
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
113 |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
114 def make_archive(self): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
115 # are sources combined into main archive? |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
116 unified = self.path == self.sourcesPath |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
117 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
118 with Archiver(self.path) as arc, Archiver(None if unified else self.sourcesPath) as srcArcRaw: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
119 srcArc = arc if unified else srcArcRaw |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
120 services = {} |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
121 def overwriteCheck(zf, arcname, source): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
122 if not hasattr(zf, '_provenance'): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
123 zf._provenance = {} |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
124 existingSource = zf._provenance.get(arcname, None) |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
125 isOverwrite = False |
15821
de8296c27680
mx archive: avoid multiple directory entries too
Bernhard Urban <bernhard.urban@jku.at>
parents:
15819
diff
changeset
|
126 if existingSource and existingSource != source: |
16086
6eef506c173d
mx archive: only print overwrite warning on files
Bernhard Urban <bernhard.urban@jku.at>
parents:
16062
diff
changeset
|
127 if arcname[-1] != os.path.sep: |
16262
55f369530122
mx archive: print warning only in verbose mode
Bernhard Urban <bernhard.urban@jku.at>
parents:
16167
diff
changeset
|
128 logv('warning: ' + self.path + ': avoid overwrite of ' + arcname + '\n new: ' + source + '\n old: ' + existingSource) |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
129 isOverwrite = True |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
130 zf._provenance[arcname] = source |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
131 return isOverwrite |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
132 |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
133 if self.mainClass: |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
134 manifest = "Manifest-Version: 1.0\nMain-Class: %s\n\n" % (self.mainClass) |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
135 if not overwriteCheck(arc.zf, "META-INF/MANIFEST.MF", "project files"): |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
136 arc.zf.writestr("META-INF/MANIFEST.MF", manifest) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
137 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
138 for dep in self.sorted_deps(includeLibs=True): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
139 if dep.isLibrary(): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
140 l = dep |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
141 # merge library jar into distribution jar |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
142 logv('[' + self.path + ': adding library ' + l.name + ']') |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
143 lpath = l.get_path(resolve=True) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
144 libSourcePath = l.get_source_path(resolve=True) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
145 if lpath: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
146 with zipfile.ZipFile(lpath, 'r') as lp: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
147 for arcname in lp.namelist(): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
148 if arcname.startswith('META-INF/services/') and not arcname == 'META-INF/services/': |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
149 service = arcname[len('META-INF/services/'):] |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
150 assert '/' not in service |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
151 services.setdefault(service, []).extend(lp.read(arcname).splitlines()) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
152 else: |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
153 if not overwriteCheck(arc.zf, arcname, lpath + '!' + arcname): |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
154 arc.zf.writestr(arcname, lp.read(arcname)) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
155 if srcArc.zf and libSourcePath: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
156 with zipfile.ZipFile(libSourcePath, 'r') as lp: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
157 for arcname in lp.namelist(): |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
158 if not overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname): |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
159 srcArc.zf.writestr(arcname, lp.read(arcname)) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
160 elif dep.isProject(): |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
161 p = dep |
15601
4aeb0b80324f
mx distributions: allow to specify dependencies between distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15579
diff
changeset
|
162 |
15638
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
163 isCoveredByDependecy = False |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
164 for d in self.distDependencies: |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
165 if p in _dists[d].sorted_deps(): |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
166 logv("Excluding {0} from {1} because it's provided by the dependency {2}".format(p.name, self.path, d)) |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
167 isCoveredByDependecy = True |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
168 break |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
169 |
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
170 if isCoveredByDependecy: |
15601
4aeb0b80324f
mx distributions: allow to specify dependencies between distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15579
diff
changeset
|
171 continue |
4aeb0b80324f
mx distributions: allow to specify dependencies between distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15579
diff
changeset
|
172 |
17059
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
173 if self.javaCompliance: |
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
174 if p.javaCompliance > self.javaCompliance: |
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
175 abort("Compliance level doesn't match: Distribution {0} requires {1}, but {2} is {3}.".format(self.name, self.javaCompliance, p.name, p.javaCompliance)) |
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
176 |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
177 # skip a Java project if its Java compliance level is "higher" than the configured JDK |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
178 jdk = java(p.javaCompliance) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
179 assert jdk |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
180 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
181 logv('[' + self.path + ': adding project ' + p.name + ']') |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
182 outputDir = p.output_dir() |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
183 for root, _, files in os.walk(outputDir): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
184 relpath = root[len(outputDir) + 1:] |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
185 if relpath == join('META-INF', 'services'): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
186 for service in files: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
187 with open(join(root, service), 'r') as fp: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
188 services.setdefault(service, []).extend([provider.strip() for provider in fp.readlines()]) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
189 elif relpath == join('META-INF', 'providers'): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
190 for provider in files: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
191 with open(join(root, provider), 'r') as fp: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
192 for service in fp: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
193 services.setdefault(service.strip(), []).append(provider) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
194 else: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
195 for f in files: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
196 arcname = join(relpath, f).replace(os.sep, '/') |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
197 if not overwriteCheck(arc.zf, arcname, join(root, f)): |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
198 arc.zf.write(join(root, f), arcname) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
199 if srcArc.zf: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
200 sourceDirs = p.source_dirs() |
15227
7be43cbf3568
mx: include generated sources in archived distribution sources
Doug Simon <doug.simon@oracle.com>
parents:
15226
diff
changeset
|
201 if p.source_gen_dir(): |
7be43cbf3568
mx: include generated sources in archived distribution sources
Doug Simon <doug.simon@oracle.com>
parents:
15226
diff
changeset
|
202 sourceDirs.append(p.source_gen_dir()) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
203 for srcDir in sourceDirs: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
204 for root, _, files in os.walk(srcDir): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
205 relpath = root[len(srcDir) + 1:] |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
206 for f in files: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
207 if f.endswith('.java'): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
208 arcname = join(relpath, f).replace(os.sep, '/') |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
209 if not overwriteCheck(srcArc.zf, arcname, join(root, f)): |
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
210 srcArc.zf.write(join(root, f), arcname) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
211 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
212 for service, providers in services.iteritems(): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
213 arcname = 'META-INF/services/' + service |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
214 arc.zf.writestr(arcname, '\n'.join(providers)) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
215 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
216 self.notify_updated() |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
217 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
218 |
8134
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
219 def notify_updated(self): |
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
220 for l in self.update_listeners: |
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
221 l(self) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
222 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
223 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
224 A dependency is a library or project specified in a suite. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
225 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
226 class Dependency: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
227 def __init__(self, suite, name): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
228 self.name = name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
229 self.suite = suite |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
230 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 def __str__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 return self.name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
233 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
234 def __eq__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 return self.name == other.name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
236 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 def __ne__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 return self.name != other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
239 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 def __hash__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 return hash(self.name) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
242 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 def isLibrary(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 return isinstance(self, Library) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
245 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
246 def isJreLibrary(self): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
247 return isinstance(self, JreLibrary) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
248 |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
249 def isProject(self): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
250 return isinstance(self, Project) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
251 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 class Project(Dependency): |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
253 def __init__(self, suite, name, srcDirs, deps, javaCompliance, workingSets, d): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
254 Dependency.__init__(self, suite, name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
255 self.srcDirs = srcDirs |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
256 self.deps = deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 self.checkstyleProj = name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
258 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance is not None else None |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 self.native = False |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
260 self.workingSets = workingSets |
7509 | 261 self.dir = d |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
262 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
263 # The annotation processors defined by this project |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
264 self.definedAnnotationProcessors = None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
265 self.definedAnnotationProcessorsDist = None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
266 |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
267 |
14763 | 268 # Verify that a JDK exists for this project if its compliance level is |
269 # less than the compliance level of the default JDK | |
270 jdk = java(self.javaCompliance) | |
271 if jdk is None and self.javaCompliance < java().javaCompliance: | |
272 abort('Cannot find ' + str(self.javaCompliance) + ' JDK required by ' + name + '. ' + | |
14764 | 273 'Specify it with --extra-java-homes option or EXTRA_JAVA_HOMES environment variable.') |
14763 | 274 |
5581
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
275 # Create directories for projects that don't yet exist |
7509 | 276 if not exists(d): |
277 os.mkdir(d) | |
5581
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
278 for s in self.source_dirs(): |
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
279 if not exists(s): |
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
280 os.mkdir(s) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
281 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
282 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
283 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
284 Add the transitive set of dependencies for this project, including |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
285 libraries if 'includeLibs' is true, to the 'deps' list. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
286 """ |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
287 childDeps = list(self.deps) |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
288 if includeAnnotationProcessors and len(self.annotation_processors()) > 0: |
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
289 childDeps = self.annotation_processors() + childDeps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
290 if self in deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 return deps |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
292 for name in childDeps: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
293 assert name != self.name |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
294 dep = dependency(name) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
295 if not dep in deps and (dep.isProject or (dep.isLibrary() and includeLibs) or (dep.isJreLibrary() and includeJreLibs)): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
296 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
297 if not self in deps and includeSelf: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 deps.append(self) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 return deps |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
300 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
301 def _compute_max_dep_distances(self, name, distances, dist): |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
302 currentDist = distances.get(name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 if currentDist is None or currentDist < dist: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
304 distances[name] = dist |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
305 p = project(name, False) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
306 if p is not None: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
307 for dep in p.deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
308 self._compute_max_dep_distances(dep, distances, dist + 1) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
309 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
310 def canonical_deps(self): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
311 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
312 Get the dependencies of this project that are not recursive (i.e. cannot be reached |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
313 via other dependencies). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
314 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
315 distances = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
316 result = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
317 self._compute_max_dep_distances(self.name, distances, 0) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
318 for n, d in distances.iteritems(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 assert d > 0 or n == self.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
320 if d == 1: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
321 result.add(n) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
322 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
323 if len(result) == len(self.deps) and frozenset(self.deps) == result: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
324 return self.deps |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
325 return result |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
326 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
327 def max_depth(self): |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
328 """ |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
329 Get the maximum canonical distance between this project and its most distant dependency. |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
330 """ |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
331 distances = dict() |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
332 self._compute_max_dep_distances(self.name, distances, 0) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
333 return max(distances.values()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
334 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
335 def source_dirs(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
336 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
337 Get the directories in which the sources of this project are found. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
338 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
339 return [join(self.dir, s) for s in self.srcDirs] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
340 |
6535
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
341 def source_gen_dir(self): |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
342 """ |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
343 Get the directory in which source files generated by the annotation processor are found/placed. |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
344 """ |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
345 if self.native: |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
346 return None |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
347 return join(self.dir, 'src_gen') |
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
348 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
349 def output_dir(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
350 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
351 Get the directory in which the class files of this project are found/placed. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
352 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
353 if self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
354 return None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
355 return join(self.dir, 'bin') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
356 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
357 def jasmin_output_dir(self): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
358 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
359 Get the directory in which the Jasmin assembled class files of this project are found/placed. |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
360 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
361 if self.native: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
362 return None |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
363 return join(self.dir, 'jasmin_classes') |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
364 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
365 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
366 if not self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
367 cp.append(self.output_dir()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
368 |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
369 def find_classes_with_matching_source_line(self, pkgRoot, function, includeInnerClasses=False): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
370 """ |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
371 Scan the sources of this project for Java source files containing a line for which |
8607
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
372 'function' returns true. A map from class name to source file path for each existing class |
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
373 corresponding to a matched source file is returned. |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
374 """ |
8607
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
375 result = dict() |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
376 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
377 for srcDir in self.source_dirs(): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
378 outputDir = self.output_dir() |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
379 for root, _, files in os.walk(srcDir): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
380 for name in files: |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
381 if name.endswith('.java') and name != 'package-info.java': |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
382 matchFound = False |
8607
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
383 source = join(root, name) |
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
384 with open(source) as f: |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
385 pkg = None |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
386 for line in f: |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
387 if line.startswith("package "): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
388 match = pkgDecl.match(line) |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
389 if match: |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
390 pkg = match.group(1) |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
391 if function(line.strip()): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
392 matchFound = True |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
393 if pkg and matchFound: |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
394 break |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
395 |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
396 if matchFound: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
397 simpleClassName = name[:-len('.java')] |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
398 assert pkg is not None |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
399 if pkgRoot is None or pkg.startswith(pkgRoot): |
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
400 pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep)) |
11245
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
401 if exists(pkgOutputDir): |
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
402 for e in os.listdir(pkgOutputDir): |
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
403 if includeInnerClasses: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
404 if e.endswith('.class') and (e.startswith(simpleClassName) or e.startswith(simpleClassName + '$')): |
11245
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
405 className = pkg + '.' + e[:-len('.class')] |
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
406 result[className] = source |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
407 elif e == simpleClassName + '.class': |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
408 className = pkg + '.' + simpleClassName |
11245
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
409 result[className] = source |
8607
c7672a325faf
search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents:
8585
diff
changeset
|
410 return result |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
411 |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
412 def _init_packages_and_imports(self): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
413 if not hasattr(self, '_defined_java_packages'): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
414 packages = set() |
8439
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
415 extendedPackages = set() |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
416 depPackages = set() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
417 for d in self.all_deps([], includeLibs=False, includeSelf=False): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
418 depPackages.update(d.defined_java_packages()) |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
419 imports = set() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
420 importRe = re.compile(r'import\s+(?:static\s+)?([^;]+);') |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
421 for sourceDir in self.source_dirs(): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
422 for root, _, files in os.walk(sourceDir): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
423 javaSources = [name for name in files if name.endswith('.java')] |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
424 if len(javaSources) != 0: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
425 pkg = root[len(sourceDir) + 1:].replace(os.sep, '.') |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
426 if not pkg in depPackages: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
427 packages.add(pkg) |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
428 else: |
8439
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
429 # A project extends a package already defined by one of it dependencies |
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
430 extendedPackages.add(pkg) |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
431 imports.add(pkg) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
432 |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
433 for n in javaSources: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
434 with open(join(root, n)) as fp: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
435 content = fp.read() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
436 imports.update(importRe.findall(content)) |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
437 self._defined_java_packages = frozenset(packages) |
8439
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
438 self._extended_java_packages = frozenset(extendedPackages) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
439 |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
440 importedPackages = set() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
441 for imp in imports: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
442 name = imp |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
443 while not name in depPackages and len(name) > 0: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
444 lastDot = name.rfind('.') |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
445 if lastDot == -1: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
446 name = None |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
447 break |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
448 name = name[0:lastDot] |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
449 if name is not None: |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
450 importedPackages.add(name) |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
451 self._imported_java_packages = frozenset(importedPackages) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
452 |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
453 def defined_java_packages(self): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
454 """Get the immutable set of Java packages defined by the Java sources of this project""" |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
455 self._init_packages_and_imports() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
456 return self._defined_java_packages |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
457 |
8439
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
458 def extended_java_packages(self): |
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
459 """Get the immutable set of Java packages extended by the Java sources of this project""" |
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
460 self._init_packages_and_imports() |
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
461 return self._extended_java_packages |
39c7142e7aef
added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents:
8391
diff
changeset
|
462 |
6527
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
463 def imported_java_packages(self): |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
464 """Get the immutable set of Java packages defined by other Java projects that are |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
465 imported by the Java sources of this project.""" |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
466 self._init_packages_and_imports() |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
467 return self._imported_java_packages |
3c5b19e8f2a3
modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents:
6509
diff
changeset
|
468 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
469 """ |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
470 Gets the list of projects defining the annotation processors that will be applied |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
471 when compiling this project. This includes the projects declared by the annotationProcessors property |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
472 of this project and any of its project dependencies. It also includes |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
473 any project dependencies that define an annotation processors. |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
474 """ |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
475 def annotation_processors(self): |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
476 if not hasattr(self, '_annotationProcessors'): |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
477 aps = set() |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
478 if hasattr(self, '_declaredAnnotationProcessors'): |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
479 aps = set(self._declaredAnnotationProcessors) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
480 for ap in aps: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
481 if project(ap).definedAnnotationProcessorsDist is None: |
16847
043575a99815
moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents:
16846
diff
changeset
|
482 config = join(project(ap).source_dirs()[0], 'META-INF', 'services', 'javax.annotation.processing.Processor') |
043575a99815
moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents:
16846
diff
changeset
|
483 if not exists(config): |
043575a99815
moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents:
16846
diff
changeset
|
484 TimeStampFile(config).touch() |
043575a99815
moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents:
16846
diff
changeset
|
485 abort('Project ' + ap + ' declared in annotationProcessors property of ' + self.name + ' does not define any annotation processors.\n' + |
043575a99815
moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents:
16846
diff
changeset
|
486 'Please specify the annotation processors in ' + config) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
487 |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
488 allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False) |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
489 for p in allDeps: |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
490 # Add an annotation processor dependency |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
491 if p.definedAnnotationProcessorsDist is not None: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
492 aps.add(p.name) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
493 |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
494 # Inherit annotation processors from dependencies |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
495 aps.update(p.annotation_processors()) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
496 |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
497 self._annotationProcessors = list(aps) |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
498 return self._annotationProcessors |
5762
b30cced39597
generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5712
diff
changeset
|
499 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
500 """ |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
501 Gets the class path composed of the distribution jars containing the |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
502 annotation processors that will be applied when compiling this project. |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
503 """ |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
504 def annotation_processors_path(self): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
505 aps = [project(ap) for ap in self.annotation_processors()] |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
506 if len(aps): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
507 return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist]) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
508 return None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
509 |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
510 def update_current_annotation_processors_file(self): |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
511 aps = self.annotation_processors() |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
512 outOfDate = False |
12641
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
513 currentApsFile = join(self.suite.mxDir, 'currentAnnotationProcessors', self.name) |
12648
1fbe3ca3d30d
don't equate missing current annotation processor file with it being out of date
Doug Simon <doug.simon@oracle.com>
parents:
12641
diff
changeset
|
514 currentApsFileExists = exists(currentApsFile) |
1fbe3ca3d30d
don't equate missing current annotation processor file with it being out of date
Doug Simon <doug.simon@oracle.com>
parents:
12641
diff
changeset
|
515 if currentApsFileExists: |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
516 with open(currentApsFile) as fp: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
517 currentAps = [l.strip() for l in fp.readlines()] |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
518 if currentAps != aps: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
519 outOfDate = True |
12648
1fbe3ca3d30d
don't equate missing current annotation processor file with it being out of date
Doug Simon <doug.simon@oracle.com>
parents:
12641
diff
changeset
|
520 if outOfDate or not currentApsFileExists: |
12641
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
521 if not exists(dirname(currentApsFile)): |
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
522 os.mkdir(dirname(currentApsFile)) |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
523 with open(currentApsFile, 'w') as fp: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
524 for ap in aps: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
525 print >> fp, ap |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
526 return outOfDate |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
527 |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
528 def make_archive(self, path=None): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
529 outputDir = self.output_dir() |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
530 if not path: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
531 path = join(self.dir, self.name + '.jar') |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
532 with Archiver(path) as arc: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
533 for root, _, files in os.walk(outputDir): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
534 for f in files: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
535 relpath = root[len(outputDir) + 1:] |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
536 arcname = join(relpath, f).replace(os.sep, '/') |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
537 arc.zf.write(join(root, f), arcname) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
538 return path |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
539 |
14964
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
540 def _make_absolute(path, prefix): |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
541 """ |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
542 Makes 'path' absolute if it isn't already by prefixing 'prefix' |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
543 """ |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
544 if not isabs(path): |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
545 return join(prefix, path) |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
546 return path |
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
547 |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
548 def sha1OfFile(path): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
549 with open(path, 'rb') as f: |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
550 d = hashlib.sha1() |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
551 while True: |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
552 buf = f.read(4096) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
553 if not buf: |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
554 break |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
555 d.update(buf) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
556 return d.hexdigest() |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
557 |
16720
ad19df13df14
mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents:
16706
diff
changeset
|
558 def download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False, canSymlink=True): |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
559 def _download_lib(): |
16598
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
560 cacheDir = get_env('MX_CACHE_DIR', join(_opts.user_home, '.mx', 'cache')) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
561 if not exists(cacheDir): |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
562 os.makedirs(cacheDir) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
563 base = basename(path) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
564 cachePath = join(cacheDir, base + '_' + sha1) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
565 |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
566 if not exists(cachePath) or sha1OfFile(cachePath) != sha1: |
16598
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
567 if exists(cachePath): |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
568 log('SHA1 of ' + cachePath + ' does not match expected value (' + sha1 + ') - re-downloading') |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
569 print 'Downloading ' + ("sources " if sources else "") + name + ' from ' + str(urls) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
570 download(cachePath, urls) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
571 |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
572 d = dirname(path) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
573 if d != '' and not exists(d): |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
574 os.makedirs(d) |
16720
ad19df13df14
mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents:
16706
diff
changeset
|
575 |
ad19df13df14
mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents:
16706
diff
changeset
|
576 if canSymlink and 'symlink' in dir(os): |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
577 if exists(path): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
578 os.unlink(path) |
16598
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
579 os.symlink(cachePath, path) |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
580 else: |
edf653f51521
added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents:
16539
diff
changeset
|
581 shutil.copy(cachePath, path) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
582 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
583 def _sha1Cached(): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
584 with open(sha1path, 'r') as f: |
14154
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
585 return f.read()[0:40] |
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
586 |
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
587 def _writeSha1Cached(): |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
588 with open(sha1path, 'w') as f: |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
589 f.write(sha1OfFile(path)) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
590 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
591 if resolve and mustExist and not exists(path): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
592 assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
593 _download_lib() |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
594 |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
595 if exists(path): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
596 if sha1 and not exists(sha1path): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
597 _writeSha1Cached() |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
598 |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
599 if sha1 and sha1 != _sha1Cached(): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
600 _download_lib() |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
601 if sha1 != sha1OfFile(path): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
602 abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
603 _writeSha1Cached() |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
604 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
605 return path |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
606 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
607 class BaseLibrary(Dependency): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
608 def __init__(self, suite, name, optional): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
609 Dependency.__init__(self, suite, name) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
610 self.optional = optional |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
611 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
612 def __ne__(self, other): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
613 result = self.__eq__(other) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
614 if result is NotImplemented: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
615 return result |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
616 return not result |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
617 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
618 """ |
16671
7cdd7ede912d
mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16670
diff
changeset
|
619 A library that will be provided by the JRE but may be absent. |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
620 Any project or normal library that depends on a missing library |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
621 will be removed from the global project and library dictionaries |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
622 (i.e., _projects and _libs). |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
623 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
624 This mechanism exists primarily to be able to support code |
16671
7cdd7ede912d
mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16670
diff
changeset
|
625 that may use functionality in one JRE (e.g., Oracle JRE) |
7cdd7ede912d
mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16670
diff
changeset
|
626 that is not present in another JRE (e.g., OpenJDK). A |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
627 motivating example is the Java Flight Recorder library |
16671
7cdd7ede912d
mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16670
diff
changeset
|
628 found in the Oracle JRE. |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
629 """ |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
630 class JreLibrary(BaseLibrary): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
631 def __init__(self, suite, name, jar, optional): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
632 BaseLibrary.__init__(self, suite, name, optional) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
633 self.jar = jar |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
634 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
635 def __eq__(self, other): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
636 if isinstance(other, JreLibrary): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
637 return self.jar == other.jar |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
638 else: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
639 return NotImplemented |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
640 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
641 def is_present_in_jdk(self, jdk): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
642 for e in jdk.bootclasspath().split(os.pathsep): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
643 if basename(e) == self.jar: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
644 return True |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
645 for d in jdk.extdirs().split(os.pathsep): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
646 if len(d) and self.jar in os.listdir(d): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
647 return True |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
648 for d in jdk.endorseddirs().split(os.pathsep): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
649 if len(d) and self.jar in os.listdir(d): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
650 return True |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
651 return False |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
652 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
653 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
654 """ |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
655 Add the transitive set of dependencies for this JRE library to the 'deps' list. |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
656 """ |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
657 if includeJreLibs and includeSelf and not self in deps: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
658 deps.append(self) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
659 return deps |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
660 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
661 class Library(BaseLibrary): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
662 def __init__(self, suite, name, path, optional, urls, sha1, sourcePath, sourceUrls, sourceSha1, deps): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
663 BaseLibrary.__init__(self, suite, name, optional) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
664 self.path = path.replace('/', os.sep) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
665 self.urls = urls |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
666 self.sha1 = sha1 |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
667 self.sourcePath = sourcePath |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
668 self.sourceUrls = sourceUrls |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
669 if sourcePath == path: |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
670 assert sourceSha1 is None or sourceSha1 == sha1 |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
671 sourceSha1 = sha1 |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
672 self.sourceSha1 = sourceSha1 |
15149
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
673 self.deps = deps |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
674 abspath = _make_absolute(path, self.suite.dir) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
675 if not optional and not exists(abspath): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
676 if not len(urls): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
677 abort('Non-optional library {} must either exist at {} or specify one or more URLs from which it can be retrieved'.format(name, abspath)) |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
678 |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
679 def _checkSha1PropertyCondition(propName, cond, inputPath): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
680 if not cond: |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
681 absInputPath = _make_absolute(inputPath, self.suite.dir) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
682 if exists(absInputPath): |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
683 abort('Missing "{}" property for library {}. Add the following line to projects file:\nlibrary@{}@{}={}'.format(propName, name, name, propName, sha1OfFile(absInputPath))) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
684 abort('Missing "{}" property for library {}'.format(propName, name)) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
685 |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
686 _checkSha1PropertyCondition('sha1', sha1, path) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
687 _checkSha1PropertyCondition('sourceSha1', not sourcePath or sourceSha1, sourcePath) |
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
688 |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
689 for url in urls: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
690 if url.endswith('/') != self.path.endswith(os.sep): |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
691 abort('Path for dependency directory must have a URL ending with "/": path=' + self.path + ' url=' + url) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
692 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
693 def __eq__(self, other): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
694 if isinstance(other, Library): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
695 if len(self.urls) == 0: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
696 return self.path == other.path |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
697 else: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
698 return self.urls == other.urls |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
699 else: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
700 return NotImplemented |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
701 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
702 def get_path(self, resolve): |
14964
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
703 path = _make_absolute(self.path, self.suite.dir) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
704 sha1path = path + '.sha1' |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
705 |
11687
facb442de5db
added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents:
11659
diff
changeset
|
706 includedInJDK = getattr(self, 'includedInJDK', None) |
facb442de5db
added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents:
11659
diff
changeset
|
707 if includedInJDK and java().javaCompliance >= JavaCompliance(includedInJDK): |
facb442de5db
added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents:
11659
diff
changeset
|
708 return None |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
709 |
16725
22b2950a0613
workaround for buggy pylint warning
Doug Simon <doug.simon@oracle.com>
parents:
16720
diff
changeset
|
710 bootClassPathAgent = getattr(self, 'bootClassPathAgent').lower() == 'true' if hasattr(self, 'bootClassPathAgent') else False |
16720
ad19df13df14
mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents:
16706
diff
changeset
|
711 |
ad19df13df14
mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents:
16706
diff
changeset
|
712 return download_file_with_sha1(self.name, path, self.urls, self.sha1, sha1path, resolve, not self.optional, canSymlink=not bootClassPathAgent) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
713 |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
714 def get_source_path(self, resolve): |
15147
d93cc1fdf55e
Fix Library.get_source_path (use sourcePath instead of path)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15135
diff
changeset
|
715 if self.sourcePath is None: |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
716 return None |
15147
d93cc1fdf55e
Fix Library.get_source_path (use sourcePath instead of path)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15135
diff
changeset
|
717 path = _make_absolute(self.sourcePath, self.suite.dir) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
718 sha1path = path + '.sha1' |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
719 |
16599
89be7c4db12c
made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents:
16598
diff
changeset
|
720 return download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
721 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
722 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
723 path = self.get_path(resolve) |
11687
facb442de5db
added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents:
11659
diff
changeset
|
724 if path and (exists(path) or not resolve): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
725 cp.append(path) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
726 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
727 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False): |
15149
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
728 """ |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
729 Add the transitive set of dependencies for this library to the 'deps' list. |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
730 """ |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
731 if not includeLibs: |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
732 return deps |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
733 childDeps = list(self.deps) |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
734 if self in deps: |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
735 return deps |
15149
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
736 for name in childDeps: |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
737 assert name != self.name |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
738 dep = library(name) |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
739 if not dep in deps: |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
740 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
15149
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
741 if not self in deps and includeSelf: |
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
742 deps.append(self) |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
743 return deps |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
744 |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
745 class HgConfig: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
746 """ |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
747 Encapsulates access to Mercurial (hg) |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
748 """ |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
749 def __init__(self): |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
750 self.missing = 'no hg executable found' |
12512
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
751 self.has_hg = None |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
752 |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
753 def check(self, abortOnFail=True): |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
754 if self.has_hg is None: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
755 try: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
756 subprocess.check_output(['hg']) |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
757 self.has_hg = True |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
758 except OSError: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
759 self.has_hg = False |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
760 warn(self.missing) |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
761 |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
762 if not self.has_hg: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
763 if abortOnFail: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
764 abort(self.missing) |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
765 else: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
766 warn(self.missing) |
12512
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
767 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
768 def tip(self, sDir, abortOnError=True): |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
769 try: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
770 return subprocess.check_output(['hg', 'tip', '-R', sDir, '--template', '{node}']) |
12512
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
771 except OSError: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
772 warn(self.missing) |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
773 except subprocess.CalledProcessError: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
774 if abortOnError: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
775 abort('failed to get tip revision id') |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
776 else: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
777 return None |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
778 |
15402
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
779 def isDirty(self, sDir, abortOnError=True): |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
780 try: |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
781 return len(subprocess.check_output(['hg', 'status', '-R', sDir])) > 0 |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
782 except OSError: |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
783 warn(self.missing) |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
784 except subprocess.CalledProcessError: |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
785 if abortOnError: |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
786 abort('failed to get status') |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
787 else: |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
788 return None |
5dcf0ae606f3
mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents:
15386
diff
changeset
|
789 |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
790 # TODO: remove this function once all repos have transitioned |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
791 # to the new project format |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
792 def _read_projects_file(projectsFile): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
793 suite = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
794 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
795 suite['projects'] = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
796 suite['libraries'] = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
797 suite['jrelibraries'] = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
798 suite['distributions'] = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
799 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
800 with open(projectsFile) as f: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
801 prefix = '' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
802 lineNum = 0 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
803 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
804 def error(message): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
805 abort(projectsFile + ':' + str(lineNum) + ': ' + message) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
806 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
807 for line in f: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
808 lineNum = lineNum + 1 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
809 line = line.strip() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
810 if line.endswith('\\'): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
811 prefix = prefix + line[:-1] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
812 continue |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
813 if len(prefix) != 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
814 line = prefix + line |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
815 prefix = '' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
816 if len(line) != 0 and line[0] != '#': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
817 if '=' not in line: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
818 error('non-comment line does not contain an "=" character') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
819 key, value = line.split('=', 1) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
820 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
821 parts = key.split('@') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
822 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
823 if len(parts) == 1: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
824 if parts[0] == 'suite': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
825 suite['name'] = value |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
826 elif parts[0] == 'mxversion': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
827 suite['mxversion'] = value |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
828 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
829 error('Single part property must be "suite": ' + key) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
830 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
831 continue |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
832 if len(parts) != 3: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
833 error('Property name does not have 3 parts separated by "@": ' + key) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
834 kind, name, attr = parts |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
835 if kind == 'project': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
836 m = suite['projects'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
837 elif kind == 'library': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
838 m = suite['libraries'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
839 elif kind == 'jrelibrary': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
840 m = suite['jrelibraries'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
841 elif kind == 'distribution': |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
842 m = suite['distributions'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
843 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
844 error('Property name does not start with "project@", "library@" or "distribution@": ' + key) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
845 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
846 attrs = m.get(name) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
847 if attrs is None: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
848 attrs = OrderedDict() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
849 m[name] = attrs |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
850 value = expandvars_in_property(value) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
851 attrs[attr] = value |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
852 return suite |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
853 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
854 # TODO: remove this command once all repos have transitioned |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
855 # to the new project format |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
856 def convertprojects(args, verbose=True): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
857 """convert old style projects file to projects*.py file(s)""" |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
858 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
859 class Printer: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
860 def __init__(self, fp, indent): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
861 self.fp = fp |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
862 self.indent = indent |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
863 self.prefix = '' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
864 def println(self, s): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
865 if len(s) == 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
866 print >> self.fp, s |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
867 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
868 print >> self.fp, self.prefix + s |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
869 def inc(self): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
870 self.prefix = ''.rjust(len(self.prefix) + self.indent) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
871 def dec(self): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
872 self.prefix = ''.rjust(len(self.prefix) - self.indent) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
873 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
874 for projectsFile in args: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
875 suite = _read_projects_file(projectsFile) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
876 def print_attrs(p, name, attrs, listKeys, is_last=False): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
877 p.println('"' + name + '" : {') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
878 p.inc() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
879 for n, v in attrs.iteritems(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
880 if n in listKeys: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
881 if len(v) == 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
882 p.println('"{}" : [],'.format(n)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
883 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
884 p.println('"{}" : ['.format(n)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
885 p.inc() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
886 for e in v.split(','): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
887 p.println('"' + e.strip() + '",') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
888 p.dec() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
889 p.println('],') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
890 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
891 p.println('"{}" : "{}",'.format(n, v)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
892 p.dec() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
893 if is_last: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
894 p.println('}') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
895 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
896 p.println('},') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
897 p.println('') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
898 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
899 def print_section(p, sname, suite, is_last=False): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
900 section = suite.get(sname) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
901 if section: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
902 p.println('"' + sname + '" : {') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
903 p.inc() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
904 i = 0 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
905 for name, attrs in section.iteritems(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
906 i = i + 1 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
907 print_attrs(p, name, attrs, ['urls', 'dependencies', 'sourceUrls'], i == len(section)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
908 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
909 p.dec() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
910 if is_last: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
911 p.println('}') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
912 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
913 p.println('},') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
914 p.println('') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
915 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
916 existing, projectsPyFile = _load_suite_dict(dirname(projectsFile)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
917 if existing: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
918 assert existing['name'] == suite.pop('name') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
919 assert existing['mxversion'] == suite.pop('mxversion') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
920 for s in ['projects', 'libraries', 'jrelibraries', 'distributions']: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
921 for k in existing[s].iterkeys(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
922 suite[s].pop(k) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
923 if len(suite[s]) == 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
924 suite.pop(s) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
925 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
926 if len(suite): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
927 out = StringIO.StringIO() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
928 p = Printer(out, 2) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
929 p.println(('extra' if existing else 'suite') + ' = {') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
930 p.inc() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
931 if not existing: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
932 p.println('"mxversion" : "' + suite['mxversion'] + '",') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
933 p.println('"name" : "' + suite['name'] + '",') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
934 print_section(p, 'libraries', suite) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
935 print_section(p, 'jrelibraries', suite) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
936 print_section(p, 'projects', suite) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
937 print_section(p, 'distributions', suite, is_last=True) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
938 p.dec() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
939 p.println('}') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
940 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
941 with open(projectsPyFile, 'w') as fp: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
942 fp.write(out.getvalue()) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
943 if verbose: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
944 print 'created: ' + projectsPyFile |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
945 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
946 def _load_suite_dict(mxDir): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
947 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
948 suffix = 1 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
949 suite = None |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
950 dictName = 'suite' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
951 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
952 moduleName = 'projects' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
953 modulePath = join(mxDir, moduleName + '.py') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
954 while exists(modulePath): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
955 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
956 savedModule = sys.modules.get(moduleName) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
957 if savedModule: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
958 warn(modulePath + ' conflicts with ' + savedModule.__file__) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
959 # temporarily extend the Python path |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
960 sys.path.insert(0, mxDir) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
961 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
962 snapshot = frozenset(sys.modules.viewkeys()) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
963 module = __import__(moduleName) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
964 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
965 if savedModule: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
966 # restore the old module into the module name space |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
967 sys.modules[moduleName] = savedModule |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
968 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
969 # remove moduleName from the module name space |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
970 sys.modules.pop(moduleName) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
971 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
972 # For now fail fast if extra modules were loaded. |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
973 # This can later be relaxed to simply remove the extra modules |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
974 # from the sys.modules name space if necessary. |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
975 extraModules = snapshot - sys.modules.viewkeys() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
976 assert len(extraModules) == 0, 'loading ' + modulePath + ' caused extra modules to be loaded: ' + ', '.join([m.__file__ for m in extraModules]) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
977 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
978 # revert the Python path |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
979 del sys.path[0] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
980 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
981 if not hasattr(module, dictName): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
982 abort(modulePath + ' must define a variable named "' + dictName + '"') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
983 d = getattr(module, dictName) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
984 sections = ['projects', 'libraries', 'jrelibraries', 'distributions'] + ([] if suite else ['name', 'mxversion']) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
985 unknown = d.viewkeys() - sections |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
986 if unknown: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
987 abort(modulePath + ' defines unsupported suite sections: ' + ', '.join(unknown)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
988 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
989 if suite is None: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
990 suite = d |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
991 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
992 for s in sections: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
993 existing = suite.get(s) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
994 additional = d.get(s) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
995 if additional: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
996 if not existing: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
997 suite[s] = additional |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
998 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
999 conflicting = additional.viewkeys() & existing.viewkeys() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1000 if conflicting: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1001 abort(modulePath + ' redefines: ' + ', '.join(conflicting)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1002 existing.update(additional) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1003 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1004 dictName = 'extra' |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1005 moduleName = 'projects' + str(suffix) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1006 modulePath = join(mxDir, moduleName + '.py') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1007 suffix = suffix + 1 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1008 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1009 return suite, modulePath |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1010 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1011 class Suite: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1012 def __init__(self, mxDir, primary, load=True): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1013 self.dir = dirname(mxDir) |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1014 self.mxDir = mxDir |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1015 self.projects = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1016 self.libs = [] |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1017 self.jreLibs = [] |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1018 self.dists = [] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1019 self.commands = None |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1020 self.primary = primary |
13358
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
1021 self.requiredMxVersion = None |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1022 self.name = _suitename(mxDir) # validated in _load_projects |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1023 if load: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1024 # just check that there are no imports |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1025 self._load_imports() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1026 self._load_env() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1027 self._load_commands() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1028 _suites[self.name] = self |
9193
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1029 |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1030 def __str__(self): |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1031 return self.name |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1032 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1033 def _load_projects(self): |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1034 # TODO: remove once mx/projects has been deprecated |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1035 projectsFile = join(self.mxDir, 'projects') |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1036 if exists(projectsFile): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1037 convertprojects([projectsFile], verbose=False) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1038 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1039 projectsPyFile = join(self.mxDir, 'projects.py') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1040 if not exists(projectsPyFile): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1041 return |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
1042 |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1043 suiteDict, _ = _load_suite_dict(self.mxDir) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1044 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1045 if suiteDict.get('name') is not None and suiteDict.get('name') != self.name: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1046 abort('suite name in project file does not match ' + _suitename(self.mxDir)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1047 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1048 if suiteDict.has_key('mxversion'): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1049 try: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1050 self.requiredMxVersion = VersionSpec(suiteDict['mxversion']) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1051 except AssertionError as ae: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1052 abort('Exception while parsing "mxversion" in project file: ' + str(ae)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1053 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1054 libsMap = suiteDict['libraries'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1055 jreLibsMap = suiteDict['jrelibraries'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1056 projsMap = suiteDict['projects'] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1057 distsMap = suiteDict['distributions'] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1058 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1059 def pop_list(attrs, name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1060 v = attrs.pop(name, None) |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1061 if isinstance(v, list): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1062 return v |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1063 if v is None or len(v.strip()) == 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1064 return [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1065 return [n.strip() for n in v.split(',')] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1066 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1067 for name, attrs in projsMap.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1068 srcDirs = pop_list(attrs, 'sourceDirs') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1069 deps = pop_list(attrs, 'dependencies') |
5876
c21886d4e125
Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5854
diff
changeset
|
1070 ap = pop_list(attrs, 'annotationProcessors') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1071 javaCompliance = attrs.pop('javaCompliance', None) |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
1072 subDir = attrs.pop('subDir', None) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1073 if subDir is None: |
7509 | 1074 d = join(self.dir, name) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1075 else: |
7509 | 1076 d = join(self.dir, subDir, name) |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
1077 workingSets = attrs.pop('workingSets', None) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
1078 p = Project(self, name, srcDirs, deps, javaCompliance, workingSets, d) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1079 p.checkstyleProj = attrs.pop('checkstyle', name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1080 p.native = attrs.pop('native', '') == 'true' |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1081 if not p.native and p.javaCompliance is None: |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1082 abort('javaCompliance property required for non-native project ' + name) |
5876
c21886d4e125
Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5854
diff
changeset
|
1083 if len(ap) > 0: |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1084 p._declaredAnnotationProcessors = ap |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1085 p.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1086 self.projects.append(p) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1087 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1088 for name, attrs in jreLibsMap.iteritems(): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1089 jar = attrs.pop('jar') |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1090 # JRE libraries are optional by default |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1091 optional = attrs.pop('optional', 'true') != 'false' |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1092 l = JreLibrary(self, name, jar, optional) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1093 self.jreLibs.append(l) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1094 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1095 for name, attrs in libsMap.iteritems(): |
17013
0b2675391d01
mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents:
17012
diff
changeset
|
1096 if "|" in name: |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1097 if name.count('|') != 2: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
1098 abort("Format error in library name: " + name + "\nsyntax: libname|os-platform|architecture") |
17013
0b2675391d01
mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents:
17012
diff
changeset
|
1099 name, platform, architecture = name.split("|") |
0b2675391d01
mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents:
17012
diff
changeset
|
1100 if platform != get_os() or architecture != get_arch(): |
0b2675391d01
mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents:
17012
diff
changeset
|
1101 continue |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1102 path = attrs.pop('path') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1103 urls = pop_list(attrs, 'urls') |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
1104 sha1 = attrs.pop('sha1', None) |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
1105 sourcePath = attrs.pop('sourcePath', None) |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
1106 sourceUrls = pop_list(attrs, 'sourceUrls') |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
1107 sourceSha1 = attrs.pop('sourceSha1', None) |
15149
2c7b18ae25d2
Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15148
diff
changeset
|
1108 deps = pop_list(attrs, 'dependencies') |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1109 # Add support optional libraries once we have a good use case |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1110 optional = False |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1111 l = Library(self, name, path, optional, urls, sha1, sourcePath, sourceUrls, sourceSha1, deps) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1112 l.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1113 self.libs.append(l) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1114 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1115 for name, attrs in distsMap.iteritems(): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1116 path = attrs.pop('path') |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
1117 sourcesPath = attrs.pop('sourcesPath', None) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1118 deps = pop_list(attrs, 'dependencies') |
15819
2460aed6c899
mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
15818
diff
changeset
|
1119 mainClass = attrs.pop('mainClass', None) |
15577
406a94c03ffa
truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents:
15497
diff
changeset
|
1120 exclDeps = pop_list(attrs, 'exclude') |
15638
83c69954bbaa
mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents:
15601
diff
changeset
|
1121 distDeps = pop_list(attrs, 'distDependencies') |
17059
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
1122 javaCompliance = attrs.pop('javaCompliance', None) |
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
1123 d = Distribution(self, name, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1124 d.__dict__.update(attrs) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1125 self.dists.append(d) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1126 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1127 # Create a distribution for each project that defines annotation processors |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1128 for p in self.projects: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1129 annotationProcessors = None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1130 for srcDir in p.source_dirs(): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1131 configFile = join(srcDir, 'META-INF', 'services', 'javax.annotation.processing.Processor') |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1132 if exists(configFile): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1133 with open(configFile) as fp: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1134 annotationProcessors = [ap.strip() for ap in fp] |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1135 if len(annotationProcessors) != 0: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1136 for ap in annotationProcessors: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1137 if not ap.startswith(p.name): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1138 abort(ap + ' in ' + configFile + ' does not start with ' + p.name) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1139 if annotationProcessors: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1140 dname = p.name.replace('.', '_').upper() |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1141 apDir = join(p.dir, 'ap') |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1142 path = join(apDir, p.name + '.jar') |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1143 sourcesPath = None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1144 deps = [p.name] |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1145 mainClass = None |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1146 exclDeps = [] |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1147 distDeps = [] |
17059
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
1148 javaCompliance = None |
a5dc5513ce85
mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents:
17050
diff
changeset
|
1149 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1150 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1151 self.dists.append(d) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1152 p.definedAnnotationProcessors = annotationProcessors |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1153 p.definedAnnotationProcessorsDist = d |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1154 d.definingProject = p |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1155 |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1156 # Restrict exported annotation processors to those explicitly defined by the project |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1157 def _refineAnnotationProcessorServiceConfig(dist): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1158 aps = dist.definingProject.definedAnnotationProcessors |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1159 apsJar = dist.path |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1160 config = 'META-INF/services/javax.annotation.processing.Processor' |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1161 with zipfile.ZipFile(apsJar, 'r') as zf: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1162 currentAps = zf.read(config).split() |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1163 if currentAps != aps: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1164 logv('[updating ' + config + ' in ' + apsJar + ']') |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1165 with Archiver(apsJar) as arc, zipfile.ZipFile(apsJar, 'r') as lp: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1166 for arcname in lp.namelist(): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1167 if arcname == config: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1168 arc.zf.writestr(arcname, '\n'.join(aps)) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1169 else: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1170 arc.zf.writestr(arcname, lp.read(arcname)) |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1171 d.add_update_listener(_refineAnnotationProcessorServiceConfig) |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
1172 self.dists.append(d) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
1173 |
9193
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1174 if self.name is None: |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1175 abort('Missing "suite=<name>" in ' + projectsFile) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1176 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1177 def _commands_name(self): |
12641
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
1178 return 'mx_' + self.name.replace('-', '_') |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1179 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1180 def _find_commands(self, name): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1181 commandsPath = join(self.mxDir, name + '.py') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1182 if exists(commandsPath): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1183 return name |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1184 else: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1185 return None |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1186 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1187 def _load_commands(self): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1188 commandsName = self._find_commands(self._commands_name()) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1189 if commandsName is None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1190 # backwards compatibility |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1191 commandsName = self._find_commands('commands') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1192 if commandsName is not None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1193 if commandsName in sys.modules: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1194 abort(commandsName + '.py in suite ' + self.name + ' duplicates ' + sys.modules[commandsName].__file__) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1195 # temporarily extend the Python path |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1196 sys.path.insert(0, self.mxDir) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1197 mod = __import__(commandsName) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1198 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1199 self.commands = sys.modules.pop(commandsName) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1200 sys.modules[commandsName] = self.commands |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1201 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1202 # revert the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1203 del sys.path[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1204 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1205 if not hasattr(mod, 'mx_init'): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1206 abort(commandsName + '.py in suite ' + self.name + ' must define an mx_init(suite) function') |
4215
a2caa019ba3a
Fix mx : commands' scripts mx_init hook should be called before parsing command line arguments.
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4188
diff
changeset
|
1207 if hasattr(mod, 'mx_post_parse_cmd_line'): |
a2caa019ba3a
Fix mx : commands' scripts mx_init hook should be called before parsing command line arguments.
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4188
diff
changeset
|
1208 self.mx_post_parse_cmd_line = mod.mx_post_parse_cmd_line |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1209 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1210 mod.mx_init(self) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1211 self.commands = mod |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1212 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1213 def _load_imports(self): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1214 if exists(join(self.mxDir, 'imports')): |
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1215 abort('multiple suites are not supported in this version of mx') |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1216 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1217 def _load_env(self): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1218 e = join(self.mxDir, 'env') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1219 if exists(e): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1220 with open(e) as f: |
10585
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
1221 lineNum = 0 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1222 for line in f: |
10585
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
1223 lineNum = lineNum + 1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1224 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1225 if len(line) != 0 and line[0] != '#': |
10585
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
1226 if not '=' in line: |
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
1227 abort(e + ':' + str(lineNum) + ': line does not match pattern "key=value"') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1228 key, value = line.split('=', 1) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1229 os.environ[key.strip()] = expandvars_in_property(value.strip()) |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1230 |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1231 def _post_init(self, opts): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1232 self._load_projects() |
13358
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
1233 if self.requiredMxVersion is None: |
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
1234 warn("This suite does not express any required mx version. Consider adding 'mxversion=<version>' to your projects file.") |
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
1235 elif self.requiredMxVersion > version: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1236 abort("This suite requires mx version " + str(self.requiredMxVersion) + " while your current mx version is " + str(version) + ". Please update mx.") |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1237 # set the global data structures, checking for conflicts unless _check_global_structures is False |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1238 for p in self.projects: |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1239 existing = _projects.get(p.name) |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1240 if existing is not None: |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1241 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir) |
5821
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1242 if not p.name in _opts.ignored_projects: |
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1243 _projects[p.name] = p |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1244 for l in self.libs: |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1245 existing = _libs.get(l.name) |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1246 # Check that suites that define same library are consistent |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1247 if existing is not None and existing != l: |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1248 abort('inconsistent library redefinition of ' + l.name + ' in ' + existing.suite.dir + ' and ' + l.suite.dir) |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1249 _libs[l.name] = l |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1250 for l in self.jreLibs: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1251 existing = _jreLibs.get(l.name) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1252 # Check that suites that define same library are consistent |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1253 if existing is not None and existing != l: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1254 abort('inconsistent JRE library redefinition of ' + l.name + ' in ' + existing.suite.dir + ' and ' + l.suite.dir) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1255 _jreLibs[l.name] = l |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1256 for d in self.dists: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1257 existing = _dists.get(d.name) |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1258 if existing is not None: |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1259 # allow redefinition, so use path from existing |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1260 # abort('cannot redefine distribution ' + d.name) |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1261 warn('distribution ' + d.name + ' redefined') |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1262 d.path = existing.path |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1263 _dists[d.name] = d |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1264 |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1265 # Remove projects and libraries that (recursively) depend on an optional library |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1266 # whose artifact does not exist or on a JRE library that is not present in the |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1267 # JDK for a project. Also remove projects whose Java compliance requirement |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1268 # cannot be satisfied by the configured JDKs. |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1269 # |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1270 # Removed projects and libraries are also removed from |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1271 # distributions in they are listed as dependencies. |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1272 for d in sorted_deps(includeLibs=True): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1273 if d.isLibrary(): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1274 if d.optional: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1275 try: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1276 d.optional = False |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1277 path = d.get_path(resolve=True) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1278 except SystemExit: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1279 path = None |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1280 finally: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1281 d.optional = True |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1282 if not path: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1283 logv('[omitting optional library {} as {} does not exist]'.format(d, d.path)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1284 del _libs[d.name] |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1285 self.libs.remove(d) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1286 elif d.isProject(): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1287 if java(d.javaCompliance) is None: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1288 logv('[omitting project {} as Java compliance {} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1289 del _projects[d.name] |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1290 self.projects.remove(d) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1291 else: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1292 for name in list(d.deps): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1293 jreLib = _jreLibs.get(name) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1294 if jreLib: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1295 if not jreLib.is_present_in_jdk(java(d.javaCompliance)): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1296 if jreLib.optional: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1297 logv('[omitting project {} as dependency {} is missing]'.format(d, name)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1298 del _projects[d.name] |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1299 self.projects.remove(d) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1300 else: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1301 abort('JRE library {} required by {} not found'.format(jreLib, d)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1302 elif not dependency(name, fatalIfMissing=False): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1303 logv('[omitting project {} as dependency {} is missing]'.format(d, name)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1304 del _projects[d.name] |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1305 self.projects.remove(d) |
16629
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1306 for dist in _dists.itervalues(): |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1307 for name in list(dist.deps): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1308 if not dependency(name, fatalIfMissing=False): |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1309 logv('[omitting {} from distribution {}]'.format(name, dist)) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1310 dist.deps.remove(name) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1311 |
8134
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
1312 if hasattr(self, 'mx_post_parse_cmd_line'): |
6e3ebc6fd5a4
graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents:
8131
diff
changeset
|
1313 self.mx_post_parse_cmd_line(opts) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1314 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1315 class XMLElement(xml.dom.minidom.Element): |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1316 def writexml(self, writer, indent="", addindent="", newl=""): |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1317 writer.write(indent + "<" + self.tagName) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1318 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1319 attrs = self._get_attributes() |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1320 a_names = attrs.keys() |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1321 a_names.sort() |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1322 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1323 for a_name in a_names: |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1324 writer.write(" %s=\"" % a_name) |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1325 xml.dom.minidom._write_data(writer, attrs[a_name].value) |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1326 writer.write("\"") |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1327 if self.childNodes: |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1328 if not self.ownerDocument.padTextNodeWithoutSiblings and len(self.childNodes) == 1 and isinstance(self.childNodes[0], xml.dom.minidom.Text): |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1329 # if the only child of an Element node is a Text node, then the |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1330 # text is printed without any indentation or new line padding |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1331 writer.write(">") |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1332 self.childNodes[0].writexml(writer) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1333 writer.write("</%s>%s" % (self.tagName, newl)) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1334 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1335 writer.write(">%s" % (newl)) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1336 for node in self.childNodes: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1337 node.writexml(writer, indent + addindent, addindent, newl) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1338 writer.write("%s</%s>%s" % (indent, self.tagName, newl)) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1339 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1340 writer.write("/>%s" % (newl)) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1341 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1342 class XMLDoc(xml.dom.minidom.Document): |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1343 |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1344 def __init__(self): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1345 xml.dom.minidom.Document.__init__(self) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1346 self.current = self |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1347 self.padTextNodeWithoutSiblings = False |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1348 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1349 def createElement(self, tagName): |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1350 # overwritten to create XMLElement |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1351 e = XMLElement(tagName) |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1352 e.ownerDocument = self |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
1353 return e |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1354 |
8302
b246434a3e4a
made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents:
8189
diff
changeset
|
1355 def comment(self, txt): |
b246434a3e4a
made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents:
8189
diff
changeset
|
1356 self.current.appendChild(self.createComment(txt)) |
b246434a3e4a
made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents:
8189
diff
changeset
|
1357 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1358 def open(self, tag, attributes=None, data=None): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1359 if attributes is None: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1360 attributes = {} |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1361 element = self.createElement(tag) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1362 for key, value in attributes.items(): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1363 element.setAttribute(key, value) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1364 self.current.appendChild(element) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1365 self.current = element |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1366 if data is not None: |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1367 element.appendChild(self.createTextNode(data)) |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1368 return self |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1369 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1370 def close(self, tag): |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1371 assert self.current != self |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1372 assert tag == self.current.tagName, str(tag) + ' != ' + self.current.tagName |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1373 self.current = self.current.parentNode |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1374 return self |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1375 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1376 def element(self, tag, attributes=None, data=None): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1377 if attributes is None: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1378 attributes = {} |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
1379 return self.open(tag, attributes, data).close(tag) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1380 |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
1381 def xml(self, indent='', newl='', escape=False, standalone=None): |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1382 assert self.current == self |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1383 result = self.toprettyxml(indent, newl, encoding="UTF-8") |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1384 if escape: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1385 entities = {'"': """, "'": "'", '\n': ' '} |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1386 result = xml.sax.saxutils.escape(result, entities) |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
1387 if standalone is not None: |
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
1388 result = result.replace('encoding="UTF-8"?>', 'encoding="UTF-8" standalone="' + str(standalone) + '"?>') |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1389 return result |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
1390 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1391 def get_os(): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1392 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1393 Get a canonical form of sys.platform. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1394 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1395 if sys.platform.startswith('darwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1396 return 'darwin' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1397 elif sys.platform.startswith('linux'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1398 return 'linux' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1399 elif sys.platform.startswith('sunos'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1400 return 'solaris' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1401 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1402 return 'windows' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1403 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1404 abort('Unknown operating system ' + sys.platform) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
1405 |
17012
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1406 def get_arch(): |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1407 machine = platform.uname()[4] |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1408 if machine in ['amd64', 'AMD64', 'x86_64', 'i86pc']: |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1409 return 'amd64' |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1410 if machine in ['sun4v', 'sun4u']: |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1411 return 'sparcv9' |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1412 if machine == 'i386' and get_os() == 'darwin': |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1413 try: |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1414 # Support for Snow Leopard and earlier version of MacOSX |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1415 if subprocess.check_output(['sysctl', '-n', 'hw.cpu64bit_capable']).strip() == '1': |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1416 return 'amd64' |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1417 except OSError: |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1418 # sysctl is not available |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1419 pass |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1420 abort('unknown or unsupported architecture: os=' + get_os() + ', machine=' + machine) |
ad10671d1bbd
mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents:
16947
diff
changeset
|
1421 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1422 def _loadSuite(mxDir, primary=False): |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1423 """ |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1424 Load a suite from 'mxDir'. |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1425 """ |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1426 for s in _suites.itervalues(): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1427 if s.mxDir == mxDir: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1428 return s |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1429 # create the new suite |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1430 s = Suite(mxDir, primary) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1431 return s |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1432 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1433 def suites(opt_limit_to_suite=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1434 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1435 Get the list of all loaded suites. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1436 """ |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1437 return _suites.values() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1438 |
9193
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1439 def suite(name, fatalIfMissing=True): |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1440 """ |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1441 Get the suite for a given name. |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1442 """ |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1443 s = _suites.get(name) |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1444 if s is None and fatalIfMissing: |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1445 abort('suite named ' + name + ' not found') |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1446 return s |
c8f4e1081c0b
support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents:
9144
diff
changeset
|
1447 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1448 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1449 def projects_from_names(projectNames): |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1450 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1451 Get the list of projects corresponding to projectNames; all projects if None |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1452 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1453 if projectNames is None: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1454 return projects() |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1455 else: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1456 return [project(name) for name in projectNames] |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1457 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1458 def projects(opt_limit_to_suite=False): |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1459 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1460 Get the list of all loaded projects limited by --suite option if opt_limit_to_suite == True |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1461 """ |
16944
a04d9cbc149f
mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16875
diff
changeset
|
1462 sortedProjects = sorted(_projects.values(), key=lambda p: p.name) |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1463 if opt_limit_to_suite: |
16944
a04d9cbc149f
mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16875
diff
changeset
|
1464 return _projects_opt_limit_to_suites(sortedProjects) |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1465 else: |
16944
a04d9cbc149f
mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16875
diff
changeset
|
1466 return sortedProjects |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1467 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1468 def projects_opt_limit_to_suites(): |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1469 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1470 Get the list of all loaded projects optionally limited by --suite option |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1471 """ |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1472 return projects(True) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1473 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1474 def _projects_opt_limit_to_suites(projects): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
1475 return projects |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1476 |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1477 def annotation_processors(): |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1478 """ |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1479 Get the list of all loaded projects that define an annotation processor. |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1480 """ |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1481 global _annotationProcessors |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1482 if _annotationProcessors is None: |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1483 aps = set() |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1484 for p in projects(): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1485 for ap in p.annotation_processors(): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1486 if project(ap, False): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1487 aps.add(ap) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1488 _annotationProcessors = list(aps) |
9857
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1489 return _annotationProcessors |
719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents:
9854
diff
changeset
|
1490 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1491 def distribution(name, fatalIfMissing=True): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1492 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1493 Get the distribution for a given name. This will abort if the named distribution does |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1494 not exist and 'fatalIfMissing' is true. |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1495 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1496 d = _dists.get(name) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1497 if d is None and fatalIfMissing: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1498 abort('distribution named ' + name + ' not found') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1499 return d |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1500 |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1501 def dependency(name, fatalIfMissing=True): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1502 """ |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1503 Get the project or library for a given name. This will abort if a project or library does |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1504 not exist for 'name' and 'fatalIfMissing' is true. |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1505 """ |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1506 d = _projects.get(name) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1507 if d is None: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1508 d = _libs.get(name) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1509 if d is None: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
1510 d = _jreLibs.get(name) |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1511 if d is None and fatalIfMissing: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1512 if name in _opts.ignored_projects: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1513 abort('project named ' + name + ' is ignored') |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1514 abort('project or library named ' + name + ' not found') |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1515 return d |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1516 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1517 def project(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1518 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1519 Get the project for a given name. This will abort if the named project does |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1520 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1521 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1522 p = _projects.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1523 if p is None and fatalIfMissing: |
5821
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1524 if name in _opts.ignored_projects: |
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1525 abort('project named ' + name + ' is ignored') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1526 abort('project named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1527 return p |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1528 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1529 def library(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1530 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1531 Gets the library for a given name. This will abort if the named library does |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1532 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1533 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1534 l = _libs.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1535 if l is None and fatalIfMissing: |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
1536 if _projects.get(name): |
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
1537 abort(name + ' is a project, not a library') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1538 abort('library named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1539 return l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1540 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1541 def _as_classpath(deps, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1542 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1543 if _opts.cp_prefix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1544 cp = [_opts.cp_prefix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1545 for d in deps: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1546 d.append_to_classpath(cp, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1547 if _opts.cp_suffix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1548 cp += [_opts.cp_suffix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1549 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1550 |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1551 def classpath(names=None, resolve=True, includeSelf=True, includeBootClasspath=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1552 """ |
16417
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1553 Get the class path for a list of given dependencies and distributions, resolving each entry in the |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1554 path (e.g. downloading a missing library) if 'resolve' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1555 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1556 if names is None: |
16417
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1557 deps = sorted_deps(includeLibs=True) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1558 dists = list(_dists.values()) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1559 else: |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1560 deps = [] |
16417
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1561 dists = [] |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1562 if isinstance(names, types.StringTypes): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1563 names = [names] |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
1564 for n in names: |
16417
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1565 dep = dependency(n, fatalIfMissing=False) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1566 if dep: |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1567 dep.all_deps(deps, True, includeSelf) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1568 else: |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1569 dist = distribution(n) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1570 if not dist: |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1571 abort('project, library or distribution named ' + n + ' not found') |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1572 dists.append(dist) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1573 |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1574 if len(dists): |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1575 distsDeps = set() |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1576 for d in dists: |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1577 distsDeps.update(d.sorted_deps()) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1578 |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1579 # remove deps covered by a dist that will be on the class path |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1580 deps = [d for d in deps if d not in distsDeps] |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1581 |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1582 result = _as_classpath(deps, resolve) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1583 |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1584 # prepend distributions |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1585 if len(dists): |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1586 distsCp = os.pathsep.join(dist.path for dist in dists) |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1587 if len(result): |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1588 result = distsCp + os.pathsep + result |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1589 else: |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1590 result = distsCp |
9fe3cb463079
mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents:
16269
diff
changeset
|
1591 |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1592 if includeBootClasspath: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1593 result = os.pathsep.join([java().bootclasspath(), result]) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1594 return result |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1595 |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1596 def classpath_walk(names=None, resolve=True, includeSelf=True, includeBootClasspath=False): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1597 """ |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1598 Walks the resources available in a given classpath, yielding a tuple for each resource |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1599 where the first member of the tuple is a directory path or ZipFile object for a |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1600 classpath entry and the second member is the qualified path of the resource relative |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1601 to the classpath entry. |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1602 """ |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1603 cp = classpath(names, resolve, includeSelf, includeBootClasspath) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1604 for entry in cp.split(os.pathsep): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1605 if not exists(entry): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1606 continue |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1607 if isdir(entry): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1608 for root, dirs, files in os.walk(entry): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1609 for d in dirs: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1610 entryPath = join(root[len(entry) + 1:], d) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1611 yield entry, entryPath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1612 for f in files: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1613 entryPath = join(root[len(entry) + 1:], f) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1614 yield entry, entryPath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1615 elif entry.endswith('.jar') or entry.endswith('.zip'): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1616 with zipfile.ZipFile(entry, 'r') as zf: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1617 for zi in zf.infolist(): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1618 entryPath = zi.filename |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1619 yield zf, entryPath |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1620 |
15785
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
1621 def sorted_deps(projectNames=None, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1622 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1623 Gets projects and libraries sorted such that dependencies |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1624 are before the projects that depend on them. Unless 'includeLibs' is |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1625 true, libraries are omitted from the result. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1626 """ |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
1627 projects = projects_from_names(projectNames) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
1628 |
15785
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
1629 return sorted_project_deps(projects, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
1630 |
16629
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1631 def sorted_dists(): |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1632 """ |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1633 Gets distributions sorted such that each distribution comes after |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1634 any distributions it depends upon. |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1635 """ |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1636 dists = [] |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1637 def add_dist(dist): |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1638 if not dist in dists: |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1639 for depDist in [distribution(name) for name in dist.distDependencies]: |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1640 add_dist(depDist) |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1641 if not dist in dists: |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1642 dists.append(dist) |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1643 |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1644 for d in _dists.itervalues(): |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1645 add_dist(d) |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1646 return dists |
be59a1d39281
respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents:
16623
diff
changeset
|
1647 |
15785
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
1648 def sorted_project_deps(projects, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1649 deps = [] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1650 for p in projects: |
15785
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
1651 p.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1652 return deps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1653 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1654 def _handle_missing_java_home(): |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1655 if not sys.stdout.isatty(): |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1656 abort('Could not find bootstrap JDK. Use --java-home option or ensure JAVA_HOME environment variable is set.') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1657 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1658 candidateJdks = [] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1659 if get_os() == 'darwin': |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1660 base = '/Library/Java/JavaVirtualMachines' |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1661 candidateJdks = [join(base, n, 'Contents/Home') for n in os.listdir(base) if exists(join(base, n, 'Contents/Home'))] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1662 elif get_os() == 'linux': |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1663 base = '/usr/lib/jvm' |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1664 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, 'jre/lib/rt.jar'))] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1665 elif get_os() == 'solaris': |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1666 base = '/usr/jdk/instances' |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1667 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, 'jre/lib/rt.jar'))] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1668 elif get_os() == 'windows': |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1669 base = r'C:\Program Files\Java' |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1670 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, r'jre\lib\rt.jar'))] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1671 |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1672 javaHome = None |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1673 if len(candidateJdks) != 0: |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1674 javaHome = select_items(candidateJdks + ['<other>'], allowMultiple=False) |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1675 if javaHome == '<other>': |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1676 javaHome = None |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1677 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1678 while javaHome is None: |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1679 javaHome = raw_input('Enter path of bootstrap JDK: ') |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1680 rtJarPath = join(javaHome, 'jre', 'lib', 'rt.jar') |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1681 if not exists(rtJarPath): |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1682 log('Does not appear to be a valid JDK as ' + rtJarPath + ' does not exist') |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1683 javaHome = None |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1684 else: |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1685 break |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1686 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
1687 envPath = join(_primary_suite.mxDir, 'env') |
11511
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
1688 if ask_yes_no('Persist this setting by adding "JAVA_HOME=' + javaHome + '" to ' + envPath, 'y'): |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1689 with open(envPath, 'a') as fp: |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1690 print >> fp, 'JAVA_HOME=' + javaHome |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1691 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1692 return javaHome |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1693 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1694 class ArgParser(ArgumentParser): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1695 # Override parent to append the list of available commands |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1696 def format_help(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1697 return ArgumentParser.format_help(self) + _format_commands() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1698 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1699 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1700 def __init__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1701 self.java_initialized = False |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1702 # this doesn't resolve the right way, but can't figure out how to override _handle_conflict_resolve in _ActionsContainer |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1703 ArgumentParser.__init__(self, prog='mx', conflict_handler='resolve') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1704 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1705 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') |
5091
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1706 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output') |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1707 self.add_argument('-w', action='store_true', dest='warn', help='enable warning messages') |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
1708 self.add_argument('-p', '--primary-suite-path', help='set the primary suite directory', metavar='<path>') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1709 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>') |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1710 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1711 self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1712 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') |
13952
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
1713 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1714 self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[]) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1715 self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[]) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1716 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) |
14763 | 1717 self.add_argument('--java-home', help='primary JDK directory (must be JDK 7 or later)', metavar='<path>') |
1718 self.add_argument('--extra-java-homes', help='secondary JDK directories separated by "' + os.pathsep + '"', metavar='<path>') | |
5821
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1719 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[]) |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
1720 self.add_argument('--kill-with-sigquit', action='store_true', dest='killwithsigquit', help='send sigquit first before killing child processes') |
4239
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
1721 if get_os() != 'windows': |
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
1722 # Time outs are (currently) implemented with Unix specific functionality |
11401
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1723 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>') |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1724 self.add_argument('--ptimeout', help='timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1725 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1726 def _parse_cmd_line(self, args=None): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1727 if args is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1728 args = sys.argv[1:] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1729 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1730 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1731 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1732 opts = self.parse_args() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1733 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1734 # Give the timeout options a default value to avoid the need for hasattr() tests |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1735 opts.__dict__.setdefault('timeout', 0) |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1736 opts.__dict__.setdefault('ptimeout', 0) |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1737 |
5091
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1738 if opts.very_verbose: |
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1739 opts.verbose = True |
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1740 |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1741 if opts.java_home is None: |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1742 opts.java_home = os.environ.get('JAVA_HOME') |
14763 | 1743 if opts.extra_java_homes is None: |
1744 opts.extra_java_homes = os.environ.get('EXTRA_JAVA_HOMES') | |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1745 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1746 if opts.java_home is None or opts.java_home == '': |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1747 opts.java_home = _handle_missing_java_home() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1748 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1749 if opts.user_home is None or opts.user_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1750 abort('Could not find user home. Use --user-home option or ensure HOME environment variable is set.') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1751 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1752 os.environ['JAVA_HOME'] = opts.java_home |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1753 os.environ['HOME'] = opts.user_home |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1754 |
5821
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1755 opts.ignored_projects = opts.ignored_projects + os.environ.get('IGNORED_PROJECTS', '').split(',') |
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1756 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1757 commandAndArgs = opts.__dict__.pop('commandAndArgs') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1758 return opts, commandAndArgs |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1759 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1760 def _handle_conflict_resolve(self, action, conflicting_actions): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1761 self._handle_conflict_error(action, conflicting_actions) |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1762 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1763 def _format_commands(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1764 msg = '\navailable commands:\n\n' |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1765 for cmd in sorted(_commands.iterkeys()): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1766 c, _ = _commands[cmd][:2] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1767 doc = c.__doc__ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1768 if doc is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1769 doc = '' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1770 msg += ' {0:<20} {1}\n'.format(cmd, doc.split('\n', 1)[0]) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1771 return msg + '\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1772 |
14763 | 1773 def java(requiredCompliance=None): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1774 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1775 Get a JavaConfig object containing Java commands launch details. |
14763 | 1776 If requiredCompliance is None, the compliance level specified by --java-home/JAVA_HOME |
1777 is returned. Otherwise, the JavaConfig exactly matching requiredCompliance is returned | |
1778 or None if there is no exact match. | |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1779 """ |
14763 | 1780 assert _java_homes |
1781 if not requiredCompliance: | |
1782 return _java_homes[0] | |
1783 for java in _java_homes: | |
1784 if java.javaCompliance == requiredCompliance: | |
1785 return java | |
1786 return None | |
1787 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1788 |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1789 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, addDefaultArgs=True, javaConfig=None): |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1790 if not javaConfig: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1791 javaConfig = java() |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1792 return run(javaConfig.format_cmd(args, addDefaultArgs), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1793 |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1794 def _kill_process_group(pid, sig): |
14538
5454f6bf50bf
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1795 if not sig: |
5454f6bf50bf
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1796 sig = signal.SIGKILL |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1797 pgid = os.getpgid(pid) |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1798 try: |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1799 os.killpg(pgid, sig) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1800 return True |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1801 except: |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1802 log('Error killing subprocess ' + str(pgid) + ': ' + str(sys.exc_info()[1])) |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1803 return False |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1804 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1805 def _waitWithTimeout(process, args, timeout): |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1806 def _waitpid(pid): |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1807 while True: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1808 try: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1809 return os.waitpid(pid, os.WNOHANG) |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1810 except OSError, e: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1811 if e.errno == errno.EINTR: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1812 continue |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1813 raise |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1814 |
4236
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1815 def _returncode(status): |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1816 if os.WIFSIGNALED(status): |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1817 return -os.WTERMSIG(status) |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1818 elif os.WIFEXITED(status): |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1819 return os.WEXITSTATUS(status) |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1820 else: |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1821 # Should never happen |
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1822 raise RuntimeError("Unknown child exit status!") |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1823 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1824 end = time.time() + timeout |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1825 delay = 0.0005 |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1826 while True: |
4236
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1827 (pid, status) = _waitpid(process.pid) |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1828 if pid == process.pid: |
4236
11383dafc318
Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents:
4234
diff
changeset
|
1829 return _returncode(status) |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1830 remaining = end - time.time() |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1831 if remaining <= 0: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1832 abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args))) |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1833 delay = min(delay * 2, remaining, .05) |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1834 time.sleep(delay) |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1835 |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1836 # Makes the current subprocess accessible to the abort() function |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1837 # This is a list of tuples of the subprocess.Popen or |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1838 # multiprocessing.Process object and args. |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1839 _currentSubprocesses = [] |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1840 |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1841 def _addSubprocess(p, args): |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1842 entry = (p, args) |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1843 _currentSubprocesses.append(entry) |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1844 return entry |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1845 |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1846 def _removeSubprocess(entry): |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1847 if entry and entry in _currentSubprocesses: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1848 try: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1849 _currentSubprocesses.remove(entry) |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1850 except: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1851 pass |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1852 |
4660
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1853 def waitOn(p): |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1854 if get_os() == 'windows': |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1855 # on windows use a poll loop, otherwise signal does not get handled |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1856 retcode = None |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1857 while retcode == None: |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1858 retcode = p.poll() |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1859 time.sleep(0.05) |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1860 else: |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1861 retcode = p.wait() |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1862 return retcode |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1863 |
8884
51a8368d0231
Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8633
diff
changeset
|
1864 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1865 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1866 Run a command in a subprocess, wait for it to complete and return the exit status of the process. |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1867 If the exit status is non-zero and `nonZeroIsFatal` is true, then mx is exited with |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1868 the same exit status. |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
1869 Each line of the standard output and error streams of the subprocess are redirected to |
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
1870 out and err if they are callable objects. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1871 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1872 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1873 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1874 for arg in args: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1875 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1876 |
9262
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1877 if env is None: |
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1878 env = os.environ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1879 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1880 if _opts.verbose: |
5091
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1881 if _opts.very_verbose: |
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1882 log('Environment variables:') |
9262
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1883 for key in sorted(env.keys()): |
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1884 log(' ' + key + '=' + env[key]) |
13950
35783e78eaef
mx.run: shell-escape arguments when printing them in verbose mode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13927
diff
changeset
|
1885 log(' '.join(map(pipes.quote, args))) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1886 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1887 if timeout is None and _opts.ptimeout != 0: |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1888 timeout = _opts.ptimeout |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1889 |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1890 sub = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1891 try: |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1892 # On Unix, the new subprocess should be in a separate group so that a timeout alarm |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1893 # can use os.killpg() to kill the whole subprocess group |
4252
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1894 preexec_fn = None |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1895 creationflags = 0 |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1896 if get_os() == 'windows': |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1897 creationflags = subprocess.CREATE_NEW_PROCESS_GROUP |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1898 else: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1899 preexec_fn = os.setsid |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1900 |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1901 def redirect(stream, f): |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1902 for line in iter(stream.readline, ''): |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1903 f(line) |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1904 stream.close() |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1905 stdout = out if not callable(out) else subprocess.PIPE |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1906 stderr = err if not callable(err) else subprocess.PIPE |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1907 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env) |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1908 sub = _addSubprocess(p, args) |
15871
11bf5b8973c9
mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents:
15863
diff
changeset
|
1909 joiners = [] |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1910 if callable(out): |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1911 t = Thread(target=redirect, args=(p.stdout, out)) |
15701
16059f6f5661
mx: drain *all* output from subprocess if redirecting to functions
Doug Simon <doug.simon@oracle.com>
parents:
15697
diff
changeset
|
1912 # Don't make the reader thread a daemon otherwise output can be droppped |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1913 t.start() |
15871
11bf5b8973c9
mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents:
15863
diff
changeset
|
1914 joiners.append(t) |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1915 if callable(err): |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1916 t = Thread(target=redirect, args=(p.stderr, err)) |
15701
16059f6f5661
mx: drain *all* output from subprocess if redirecting to functions
Doug Simon <doug.simon@oracle.com>
parents:
15697
diff
changeset
|
1917 # Don't make the reader thread a daemon otherwise output can be droppped |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1918 t.start() |
15871
11bf5b8973c9
mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents:
15863
diff
changeset
|
1919 joiners.append(t) |
15898
c102edf38127
mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents:
15897
diff
changeset
|
1920 while any([t.is_alive() for t in joiners]): |
c102edf38127
mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents:
15897
diff
changeset
|
1921 # Need to use timeout otherwise all signals (including CTRL-C) are blocked |
c102edf38127
mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents:
15897
diff
changeset
|
1922 # see: http://bugs.python.org/issue1167930 |
c102edf38127
mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents:
15897
diff
changeset
|
1923 for t in joiners: |
c102edf38127
mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents:
15897
diff
changeset
|
1924 t.join(10) |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1925 if timeout is None or timeout == 0: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1926 retcode = waitOn(p) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1927 else: |
12689
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1928 if get_os() == 'windows': |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1929 abort('Use of timeout not (yet) supported on Windows') |
697ef4cf18c0
mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12684
diff
changeset
|
1930 retcode = _waitWithTimeout(p, args, timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1931 except OSError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1932 log('Error executing \'' + ' '.join(args) + '\': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1933 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1934 raise e |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1935 abort(e.errno) |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1936 except KeyboardInterrupt: |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1937 abort(1) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1938 finally: |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
1939 _removeSubprocess(sub) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1940 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1941 if retcode and nonZeroIsFatal: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1942 if _opts.verbose: |
5091
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1943 if _opts.very_verbose: |
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1944 raise subprocess.CalledProcessError(retcode, ' '.join(args)) |
54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents:
5072
diff
changeset
|
1945 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1946 log('[exit code: ' + str(retcode) + ']') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1947 abort(retcode) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1948 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1949 return retcode |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1950 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1951 def exe_suffix(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1952 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1953 Gets the platform specific suffix for an executable |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1954 """ |
4258
8d2c14f722ac
mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents:
4257
diff
changeset
|
1955 if get_os() == 'windows': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1956 return name + '.exe' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1957 return name |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1958 |
11401
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1959 def add_lib_prefix(name): |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1960 """ |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1961 Adds the platform specific library prefix to a name |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1962 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1963 os = get_os() |
11401
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1964 if os == 'linux' or os == 'solaris' or os == 'darwin': |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1965 return 'lib' + name |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1966 return name |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1967 |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1968 def add_lib_suffix(name): |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1969 """ |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1970 Adds the platform specific library suffix to a name |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1971 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1972 os = get_os() |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1973 if os == 'windows': |
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1974 return name + '.dll' |
5189
6fbf12b8e572
automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents:
5171
diff
changeset
|
1975 if os == 'linux' or os == 'solaris': |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1976 return name + '.so' |
5189
6fbf12b8e572
automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents:
5171
diff
changeset
|
1977 if os == 'darwin': |
6fbf12b8e572
automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents:
5171
diff
changeset
|
1978 return name + '.dylib' |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1979 return name |
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1980 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1981 """ |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1982 Utility for filtering duplicate lines. |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1983 """ |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1984 class DuplicateSuppressingStream: |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1985 """ |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1986 Creates an object that will suppress duplicate lines sent to 'out'. |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1987 The lines considered for suppression are those that contain one of the |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1988 strings in 'restrictTo' if it is not None. |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1989 """ |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1990 def __init__(self, restrictTo=None, out=sys.stdout): |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1991 self.restrictTo = restrictTo |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1992 self.seen = set() |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1993 self.out = out |
14522
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1994 self.currentFilteredLineCount = 0 |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1995 self.currentFilteredTime = None |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1996 |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1997 def isSuppressionCandidate(self, line): |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1998 if self.restrictTo: |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
1999 for p in self.restrictTo: |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2000 if p in line: |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2001 return True |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2002 return False |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2003 else: |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2004 return True |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2005 |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2006 def write(self, line): |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2007 if self.isSuppressionCandidate(line): |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2008 if line in self.seen: |
14522
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2009 self.currentFilteredLineCount += 1 |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2010 if self.currentFilteredTime: |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2011 if time.time() - self.currentFilteredTime > 1 * 60: |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2012 self.out.write(" Filtered " + str(self.currentFilteredLineCount) + " repeated lines...\n") |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2013 self.currentFilteredTime = time.time() |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2014 else: |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2015 self.currentFilteredTime = time.time() |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2016 return |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2017 self.seen.add(line) |
14522
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2018 self.currentFilteredLineCount = 0 |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2019 self.out.write(line) |
14522
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
2020 self.currentFilteredTime = None |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2021 |
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
2022 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2023 A JavaCompliance simplifies comparing Java compliance values extracted from a JDK version string. |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2024 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2025 class JavaCompliance: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2026 def __init__(self, ver): |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2027 m = re.match(r'1\.(\d+).*', ver) |
5071
9d055af068a8
Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents:
5032
diff
changeset
|
2028 assert m is not None, 'not a recognized version string: ' + ver |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2029 self.value = int(m.group(1)) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2030 |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
2031 def __str__(self): |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2032 return '1.' + str(self.value) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2033 |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
2034 def __cmp__(self, other): |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2035 if isinstance(other, types.StringType): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2036 other = JavaCompliance(other) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2037 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2038 return cmp(self.value, other.value) |
13779 | 2039 |
13775
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
2040 def __hash__(self): |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
2041 return self.value.__hash__() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2042 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2043 """ |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
2044 A version specification as defined in JSR-56 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2045 """ |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
2046 class VersionSpec: |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2047 def __init__(self, versionString): |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2048 validChar = r'[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]' |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2049 separator = r'[.\-_]' |
13358
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
2050 m = re.match("^" + validChar + '+(' + separator + validChar + '+)*$', versionString) |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2051 assert m is not None, 'not a recognized version string: ' + versionString |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2052 self.versionString = versionString |
8391
d1d486c03e8a
Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8302
diff
changeset
|
2053 self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2054 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2055 def __str__(self): |
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2056 return self.versionString |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2057 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2058 def __cmp__(self, other): |
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2059 return cmp(self.parts, other.parts) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2060 |
14940
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2061 def _filter_non_existant_paths(paths): |
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2062 return os.pathsep.join([path for path in paths.split(os.pathsep) if exists(path)]) |
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2063 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2064 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2065 A JavaConfig object encapsulates info on how Java commands are run. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2066 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2067 class JavaConfig: |
14763 | 2068 def __init__(self, java_home, java_dbg_port): |
2069 self.jdk = java_home | |
2070 self.debug_port = java_dbg_port | |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2071 self.jar = exe_suffix(join(self.jdk, 'bin', 'jar')) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2072 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2073 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2074 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap')) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
2075 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc')) |
15863
f04a541af3c9
mx: add pack200 to javaconfig
Bernhard Urban <bernhard.urban@jku.at>
parents:
15861
diff
changeset
|
2076 self.pack200 = exe_suffix(join(self.jdk, 'bin', 'pack200')) |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
2077 self.toolsjar = join(self.jdk, 'lib', 'tools.jar') |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2078 self._bootclasspath = None |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2079 self._extdirs = None |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2080 self._endorseddirs = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2081 |
4257
32b8274f52ad
Made 'mx ideinit' resolve library dependencies eagerly as well as put absolute paths into the generated Eclipse project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4252
diff
changeset
|
2082 if not exists(self.java): |
14763 | 2083 abort('Java launcher does not exist: ' + self.java) |
4257
32b8274f52ad
Made 'mx ideinit' resolve library dependencies eagerly as well as put absolute paths into the generated Eclipse project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4252
diff
changeset
|
2084 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2085 def delAtAndSplit(s): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2086 return shlex.split(s.lstrip('@')) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2087 |
13952
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
2088 self.java_args = delAtAndSplit(_opts.java_args) if _opts.java_args else [] |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2089 self.java_args_pfx = sum(map(delAtAndSplit, _opts.java_args_pfx), []) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2090 self.java_args_sfx = sum(map(delAtAndSplit, _opts.java_args_sfx), []) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2091 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2092 # Prepend the -d64 VM option only if the java command supports it |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2093 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
2094 output = subprocess.check_output([self.java, '-d64', '-version'], stderr=subprocess.STDOUT) |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2095 self.java_args = ['-d64'] + self.java_args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2096 except subprocess.CalledProcessError as e: |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2097 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
2098 output = subprocess.check_output([self.java, '-version'], stderr=subprocess.STDOUT) |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2099 except subprocess.CalledProcessError as e: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2100 print e.output |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
2101 abort(e.returncode) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2102 |
16534
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2103 def _checkOutput(out): |
16539
cc30bd72a19b
mx: fix in java version parsing
Bernhard Urban <bernhard.urban@jku.at>
parents:
16534
diff
changeset
|
2104 return 'version' in out |
16534
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2105 |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2106 # hotspot can print a warning, e.g. if there's a .hotspot_compiler file in the cwd |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2107 output = output.split('\n') |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2108 version = None |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2109 for o in output: |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2110 if _checkOutput(o): |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2111 assert version is None |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2112 version = o |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2113 |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2114 self.version = VersionSpec(version.split()[2].strip('"')) |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
2115 self.javaCompliance = JavaCompliance(self.version.versionString) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2116 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2117 if self.debug_port is not None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2118 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2119 |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2120 def _init_classpaths(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2121 myDir = dirname(__file__) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2122 outDir = join(dirname(__file__), '.jdk' + str(self.version)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2123 if not exists(outDir): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2124 os.makedirs(outDir) |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2125 javaSource = join(myDir, 'ClasspathDump.java') |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2126 if not exists(join(outDir, 'ClasspathDump.class')): |
16534
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2127 subprocess.check_call([self.javac, '-d', outDir, javaSource], stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
4aaa97f42b92
mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents:
16455
diff
changeset
|
2128 self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', outDir, 'ClasspathDump'], stderr=subprocess.PIPE).split('|')] |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2129 if not self._bootclasspath or not self._extdirs or not self._endorseddirs: |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2130 warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'") |
14940
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2131 self._bootclasspath = _filter_non_existant_paths(self._bootclasspath) |
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2132 self._extdirs = _filter_non_existant_paths(self._extdirs) |
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
2133 self._endorseddirs = _filter_non_existant_paths(self._endorseddirs) |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2134 |
14763 | 2135 def __hash__(self): |
2136 return hash(self.jdk) | |
14764 | 2137 |
14763 | 2138 def __cmp__(self, other): |
2139 if isinstance(other, JavaConfig): | |
2140 return cmp(self.javaCompliance, other.javaCompliance) | |
2141 raise TypeError() | |
2142 | |
13951
392b6ac8da36
Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents:
13950
diff
changeset
|
2143 def format_cmd(self, args, addDefaultArgs): |
392b6ac8da36
Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents:
13950
diff
changeset
|
2144 if addDefaultArgs: |
13952
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
2145 return [self.java] + self.processArgs(args) |
13951
392b6ac8da36
Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents:
13950
diff
changeset
|
2146 else: |
392b6ac8da36
Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents:
13950
diff
changeset
|
2147 return [self.java] + args |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2148 |
13952
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
2149 def processArgs(self, args): |
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
2150 return self.java_args_pfx + self.java_args + self.java_args_sfx + args |
b076b5c13c3f
mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13951
diff
changeset
|
2151 |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2152 def bootclasspath(self): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2153 if self._bootclasspath is None: |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2154 self._init_classpaths() |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2155 return self._bootclasspath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2156 |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2157 def extdirs(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2158 if self._extdirs is None: |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2159 self._init_classpaths() |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2160 return self._extdirs |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2161 |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2162 def endorseddirs(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2163 if self._endorseddirs is None: |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2164 self._init_classpaths() |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2165 return self._endorseddirs |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
2166 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2167 def check_get_env(key): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2168 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2169 Gets an environment variable, aborting with a useful message if it is not set. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2170 """ |
4178
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2171 value = get_env(key) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2172 if value is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2173 abort('Required environment variable ' + key + ' must be set') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2174 return value |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2175 |
4227
1fe200db8c30
Environment variables for HotSpot's make are only set by mx.build if they aren't already defined.
Doug Simon <doug.simon@oracle.com>
parents:
4226
diff
changeset
|
2176 def get_env(key, default=None): |
4178
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2177 """ |
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2178 Gets an environment variable. |
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2179 """ |
4227
1fe200db8c30
Environment variables for HotSpot's make are only set by mx.build if they aren't already defined.
Doug Simon <doug.simon@oracle.com>
parents:
4226
diff
changeset
|
2180 value = os.environ.get(key, default) |
4178
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2181 return value |
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
2182 |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2183 def logv(msg=None): |
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2184 if _opts.verbose: |
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2185 log(msg) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2186 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2187 def log(msg=None): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2188 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2189 Write a message to the console. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2190 All script output goes through this method thus allowing a subclass |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2191 to redirect it. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2192 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2193 if msg is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2194 print |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2195 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2196 print msg |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2197 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2198 def expand_project_in_class_path_arg(cpArg): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2199 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2200 for part in cpArg.split(os.pathsep): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2201 if part.startswith('@'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2202 cp += classpath(part[1:]).split(os.pathsep) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2203 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2204 cp.append(part) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2205 return os.pathsep.join(cp) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2206 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2207 def expand_project_in_args(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2208 for i in range(len(args)): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2209 if args[i] == '-cp' or args[i] == '-classpath': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2210 if i + 1 < len(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2211 args[i + 1] = expand_project_in_class_path_arg(args[i + 1]) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2212 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2213 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2214 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2215 def gmake_cmd(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2216 for a in ['make', 'gmake', 'gnumake']: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2217 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2218 output = subprocess.check_output([a, '--version']) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2219 if 'GNU' in output: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2220 return a |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2221 except: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2222 pass |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2223 abort('Could not find a GNU make executable on the current path.') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2224 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2225 def expandvars_in_property(value): |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2226 result = expandvars(value) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2227 if '$' in result or '%' in result: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2228 abort('Property contains an undefined environment variable: ' + value) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2229 return result |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2230 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
2231 def _send_sigquit(): |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2232 for p, args in _currentSubprocesses: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2233 |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2234 def _isJava(): |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2235 if args: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2236 name = args[0].split(os.sep)[-1] |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2237 return name == "java" |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2238 return False |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2239 |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2240 if p is not None and _isJava(): |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2241 if get_os() == 'windows': |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2242 log("mx: implement me! want to send SIGQUIT to my child process") |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2243 else: |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2244 _kill_process_group(p.pid, sig=signal.SIGQUIT) |
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2245 time.sleep(0.1) |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
2246 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2247 def abort(codeOrMessage): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2248 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2249 Aborts the program with a SystemExit exception. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2250 If 'codeOrMessage' is a plain integer, it specifies the system exit status; |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2251 if it is None, the exit status is zero; if it has another type (such as a string), |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2252 the object's value is printed and the exit status is one. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2253 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2254 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
2255 if _opts.killwithsigquit: |
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
2256 _send_sigquit() |
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
2257 |
15823
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2258 def is_alive(p): |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2259 if isinstance(p, subprocess.Popen): |
15845
babe4565c371
mx: fixed incorrect test for subprocess being alive
twisti
parents:
15823
diff
changeset
|
2260 return p.poll() is None |
15823
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2261 assert isinstance(p, multiprocessing.Process), p |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2262 return p.is_alive() |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2263 |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2264 for p, args in _currentSubprocesses: |
15823
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2265 if is_alive(p): |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2266 try: |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2267 if get_os() == 'windows': |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2268 p.terminate() |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2269 else: |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2270 _kill_process_group(p.pid, signal.SIGKILL) |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2271 except BaseException as e: |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2272 if is_alive(p): |
9acad98567dc
mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15822
diff
changeset
|
2273 log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2274 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2275 if _opts and _opts.verbose: |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2276 import traceback |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2277 traceback.print_stack() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2278 raise SystemExit(codeOrMessage) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2279 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2280 def download(path, urls, verbose=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2281 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2282 Attempts to downloads content for each URL in a list, stopping after the first successful download. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2283 If the content cannot be retrieved from any URL, the program is aborted. The downloaded content |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2284 is written to the file indicated by 'path'. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2285 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2286 d = dirname(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2287 if d != '' and not exists(d): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2288 os.makedirs(d) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2289 |
15925
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2290 assert not path.endswith(os.sep) |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2291 |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2292 myDir = dirname(__file__) |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2293 javaSource = join(myDir, 'URLConnectionDownload.java') |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2294 javaClass = join(myDir, 'URLConnectionDownload.class') |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2295 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2296 subprocess.check_call([java().javac, '-d', myDir, javaSource]) |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2297 verbose = [] |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2298 if sys.stderr.isatty(): |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2299 verbose.append("-v") |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2300 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + verbose + urls, nonZeroIsFatal=False) == 0: |
674d4065e9fb
mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
2301 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2302 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
2303 abort('Could not download to ' + path + ' from any of the following URLs:\n\n ' + |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
2304 '\n '.join(urls) + '\n\nPlease use a web browser to do the download manually') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2305 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2306 def update_file(path, content): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2307 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2308 Updates a file with some given content if the content differs from what's in |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2309 the file already. The return value indicates if the file was updated. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2310 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2311 existed = exists(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2312 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2313 old = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2314 if existed: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2315 with open(path, 'rb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2316 old = f.read() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2317 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2318 if old == content: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2319 return False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2320 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2321 with open(path, 'wb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2322 f.write(content) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2323 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2324 log(('modified ' if existed else 'created ') + path) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2325 return True |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2326 except IOError as e: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2327 abort('Error while writing to ' + path + ': ' + str(e)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2328 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2329 # Builtin commands |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2330 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2331 def _defaultEcjPath(): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2332 return get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2333 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2334 class JavaCompileTask: |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2335 def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, jdtJar, deps): |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2336 self.proj = proj |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2337 self.reason = reason |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2338 self.javafilelist = javafilelist |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2339 self.deps = deps |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2340 self.jdk = jdk |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2341 self.outputDir = outputDir |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2342 self.done = False |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2343 self.jdtJar = jdtJar |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2344 self.args = args |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2345 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2346 def __str__(self): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2347 return self.proj.name |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2348 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2349 def logCompilation(self, compiler): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2350 log('Compiling Java sources for {} with {}... [{}]'.format(self.proj.name, compiler, self.reason)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2351 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2352 def execute(self): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2353 argfileName = join(self.proj.dir, 'javafilelist.txt') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2354 argfile = open(argfileName, 'wb') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2355 argfile.write('\n'.join(self.javafilelist)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2356 argfile.close() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2357 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2358 processorArgs = [] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2359 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2360 processorPath = self.proj.annotation_processors_path() |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2361 if processorPath: |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2362 genDir = self.proj.source_gen_dir() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2363 if exists(genDir): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2364 shutil.rmtree(genDir) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2365 os.mkdir(genDir) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2366 processorArgs += ['-processorpath', join(processorPath), '-s', genDir] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2367 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2368 processorArgs += ['-proc:none'] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2369 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2370 args = self.args |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2371 jdk = self.jdk |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2372 outputDir = self.outputDir |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2373 compliance = str(jdk.javaCompliance) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2374 cp = classpath(self.proj.name, includeSelf=True) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2375 toBeDeleted = [argfileName] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2376 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2377 try: |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2378 if not self.jdtJar: |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2379 mainJava = java() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2380 if not args.error_prone: |
16062
a864a411fad3
mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents:
16005
diff
changeset
|
2381 javac = args.alt_javac if args.alt_javac else mainJava.javac |
a864a411fad3
mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents:
16005
diff
changeset
|
2382 self.logCompilation('javac' if not args.alt_javac else args.alt_javac) |
a864a411fad3
mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents:
16005
diff
changeset
|
2383 javacCmd = [javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2384 if jdk.debug_port is not None: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2385 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2386 javacCmd += processorArgs |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2387 javacCmd += ['@' + argfile.name] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2388 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2389 if not args.warnAPI: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2390 javacCmd.append('-XDignore.symbol.file') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2391 run(javacCmd) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2392 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2393 self.logCompilation('javac (with error-prone)') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2394 javaArgs = ['-Xmx1g'] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2395 javacArgs = ['-g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2396 javacArgs += processorArgs |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2397 javacArgs += ['@' + argfile.name] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2398 if not args.warnAPI: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2399 javacArgs.append('-XDignore.symbol.file') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2400 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2401 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2402 self.logCompilation('JDT') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2403 |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2404 jdtVmArgs = ['-Xmx1g', '-jar', self.jdtJar] |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2405 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2406 jdtArgs = ['-' + compliance, |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2407 '-cp', cp, '-g', '-enableJavadoc', |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2408 '-d', outputDir, |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2409 '-bootclasspath', jdk.bootclasspath(), |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2410 '-endorseddirs', jdk.endorseddirs(), |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2411 '-extdirs', jdk.extdirs()] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2412 jdtArgs += processorArgs |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2413 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2414 jdtProperties = join(self.proj.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2415 rootJdtProperties = join(self.proj.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2416 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2417 # Try to fix a missing properties file by running eclipseinit |
16455
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
2418 _eclipseinit_project(self.proj) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2419 if not exists(jdtProperties): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2420 log('JDT properties file {0} not found'.format(jdtProperties)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2421 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2422 with open(jdtProperties) as fp: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2423 origContent = fp.read() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2424 content = origContent |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2425 if args.jdt_warning_as_error: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2426 content = content.replace('=warning', '=error') |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2427 if not args.jdt_show_task_tags: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2428 content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore' |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2429 if origContent != content: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2430 jdtPropertiesTmp = jdtProperties + '.tmp' |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2431 with open(jdtPropertiesTmp, 'w') as fp: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2432 fp.write(content) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2433 toBeDeleted.append(jdtPropertiesTmp) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2434 jdtArgs += ['-properties', jdtPropertiesTmp] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2435 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2436 jdtArgs += ['-properties', jdtProperties] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2437 jdtArgs.append('@' + argfile.name) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2438 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2439 run_java(jdtVmArgs + jdtArgs) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2440 |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2441 # Create annotation processor jar for a project that defines annotation processors |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2442 if self.proj.definedAnnotationProcessorsDist: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2443 self.proj.definedAnnotationProcessorsDist.make_archive() |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2444 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2445 finally: |
16947
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2446 # Do not clean up temp files if verbose as there's |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2447 # a good chance the user wants to copy and paste the |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2448 # Java compiler command directly |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2449 if not _opts.verbose: |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2450 for n in toBeDeleted: |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2451 os.remove(n) |
7dbe1207fccf
mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents:
16945
diff
changeset
|
2452 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2453 self.done = True |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2454 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2455 def build(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2456 """compile the Java and C sources, linking the latter |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2457 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2458 Compile all the Java source code using the appropriate compilers |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2459 and linkers for the various source code types.""" |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2460 |
4234
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2461 suppliedParser = parser is not None |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2462 if not suppliedParser: |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2463 parser = ArgumentParser(prog='mx build') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2464 |
4234
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2465 parser = parser if parser is not None else ArgumentParser(prog='mx build') |
5239
b9db4fee6eb2
skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents:
5219
diff
changeset
|
2466 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2467 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2468 parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation') |
14763 | 2469 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one') |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
2470 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2471 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') |
6535
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
2472 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2473 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
2474 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
5778
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
2475 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') |
15118
3a1f48125f53
added --jdt-show-task-tags option to build command
Doug Simon <doug.simon@oracle.com>
parents:
15087
diff
changeset
|
2476 parser.add_argument('--jdt-show-task-tags', action='store_true', help='show task tags as Eclipse batch compiler warnings') |
16062
a864a411fad3
mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents:
16005
diff
changeset
|
2477 parser.add_argument('--alt-javac', dest='alt_javac', help='path to alternative javac executable', metavar='<path>') |
15376
b3cd96f137a6
mx build: make --error-prone, --jdt and --force-javac mutually exclusive
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15364
diff
changeset
|
2478 compilerSelect = parser.add_mutually_exclusive_group() |
b3cd96f137a6
mx build: make --error-prone, --jdt and --force-javac mutually exclusive
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15364
diff
changeset
|
2479 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2480 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>') |
16062
a864a411fad3
mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents:
16005
diff
changeset
|
2481 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac whether ecj.jar is found or not') |
15378
dea98caac669
Fix help text for ideinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15376
diff
changeset
|
2482 |
4234
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2483 if suppliedParser: |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
2484 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2485 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2486 args = parser.parse_args(args) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2487 |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2488 jdtJar = None |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2489 if not args.javac and args.jdt is not None: |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2490 if not args.jdt.endswith('.jar'): |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2491 abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt) |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2492 jdtJar = args.jdt |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2493 if not exists(jdtJar): |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2494 if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None: |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2495 # Silently ignore JDT if default location is used but does not exist |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2496 jdtJar = None |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2497 else: |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2498 abort('Eclipse batch compiler jar does not exist: ' + args.jdt) |
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2499 |
6535
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
2500 if args.only is not None: |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2501 # N.B. This build will not include dependencies including annotation processor dependencies |
6535
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
2502 sortedProjects = [project(name) for name in args.only.split(',')] |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
2503 else: |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2504 if args.projects is not None: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2505 projectNames = args.projects.split(',') |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2506 else: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2507 projectNames = None |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
2508 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2509 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames)) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2510 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2511 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2512 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2513 if args.java: |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2514 ideinit([], refreshOnly=True, buildProcessorJars=False) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2515 |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2516 def prepareOutputDirs(p, clean): |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2517 outputDir = p.output_dir() |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2518 if exists(outputDir): |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2519 if clean: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2520 log('Cleaning {0}...'.format(outputDir)) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2521 shutil.rmtree(outputDir) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2522 os.mkdir(outputDir) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2523 else: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2524 os.mkdir(outputDir) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2525 genDir = p.source_gen_dir() |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2526 if genDir != '' and exists(genDir) and clean: |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2527 log('Cleaning {0}...'.format(genDir)) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2528 for f in os.listdir(genDir): |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2529 shutil.rmtree(join(genDir, f)) |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2530 return outputDir |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2531 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2532 tasks = {} |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2533 updatedAnnotationProcessorDists = set() |
6535
f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6533
diff
changeset
|
2534 for p in sortedProjects: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2535 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2536 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2537 log('Calling GNU make {0}...'.format(p.dir)) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2538 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2539 if args.clean: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2540 run([gmake_cmd(), 'clean'], cwd=p.dir) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2541 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2542 run([gmake_cmd()], cwd=p.dir) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2543 continue |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2544 else: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2545 if not args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2546 continue |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2547 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2548 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2549 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2550 # skip building this Java project if its Java compliance level is "higher" than the configured JDK |
14763 | 2551 requiredCompliance = p.javaCompliance if p.javaCompliance else JavaCompliance(args.compliance) if args.compliance else None |
2552 jdk = java(requiredCompliance) | |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
2553 assert jdk |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2554 |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2555 outputDir = prepareOutputDirs(p, args.clean) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2556 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2557 sourceDirs = p.source_dirs() |
15386
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2558 buildReason = 'forced build' if args.force else None |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2559 taskDeps = [] |
16670
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2560 for dep in p.all_deps([], includeLibs=False, includeAnnotationProcessors=True): |
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2561 taskDep = tasks.get(dep.name) |
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2562 if taskDep: |
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2563 if not buildReason: |
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2564 buildReason = dep.name + ' rebuilt' |
4ae1d1ed5cc1
fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
16667
diff
changeset
|
2565 taskDeps.append(taskDep) |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2566 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2567 jasminAvailable = None |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2568 javafilelist = [] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2569 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2570 for root, _, files in os.walk(sourceDir): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2571 javafiles = [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java'] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2572 javafilelist += javafiles |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2573 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2574 # Copy all non Java resources or assemble Jasmin files |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2575 nonjavafilelist = [join(root, name) for name in files if not name.endswith('.java')] |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2576 for src in nonjavafilelist: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2577 if src.endswith('.jasm'): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2578 className = None |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2579 with open(src) as f: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2580 for line in f: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2581 if line.startswith('.class '): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2582 className = line.split()[-1] |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2583 break |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2584 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2585 if className is not None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2586 jasminOutputDir = p.jasmin_output_dir() |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2587 classFile = join(jasminOutputDir, className.replace('/', os.sep) + '.class') |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2588 if exists(dirname(classFile)) and (not exists(classFile) or os.path.getmtime(classFile) < os.path.getmtime(src)): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2589 if jasminAvailable is None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2590 try: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2591 with open(os.devnull) as devnull: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2592 subprocess.call('jasmin', stdout=devnull, stderr=subprocess.STDOUT) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2593 jasminAvailable = True |
5071
9d055af068a8
Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents:
5032
diff
changeset
|
2594 except OSError: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2595 jasminAvailable = False |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2596 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2597 if jasminAvailable: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2598 log('Assembling Jasmin file ' + src) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2599 run(['jasmin', '-d', jasminOutputDir, src]) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2600 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2601 log('The jasmin executable could not be found - skipping ' + src) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2602 with file(classFile, 'a'): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2603 os.utime(classFile, None) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2604 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2605 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2606 log('could not file .class directive in Jasmin source: ' + src) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2607 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2608 dst = join(outputDir, src[len(sourceDir) + 1:]) |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
2609 if not exists(dirname(dst)): |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
2610 os.makedirs(dirname(dst)) |
7299
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
2611 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)): |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2612 shutil.copyfile(src, dst) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2613 |
15386
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2614 if not buildReason: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2615 for javafile in javafiles: |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2616 classfile = TimeStampFile(outputDir + javafile[len(sourceDir):-len('java')] + 'class') |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2617 if not classfile.exists() or classfile.isOlderThan(javafile): |
15386
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2618 buildReason = 'class file(s) out of date' |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2619 break |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2620 |
12631
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2621 apsOutOfDate = p.update_current_annotation_processors_file() |
2303d9e199e3
rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents:
12630
diff
changeset
|
2622 if apsOutOfDate: |
15386
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2623 buildReason = 'annotation processor(s) changed' |
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2624 |
1439685d06e4
mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents:
15378
diff
changeset
|
2625 if not buildReason: |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2626 logv('[all class files for {0} are up to date - skipping]'.format(p.name)) |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2627 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2628 |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2629 if len(javafilelist) == 0: |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2630 logv('[no Java sources for {0} - skipping]'.format(p.name)) |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2631 continue |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2632 |
16945
5e5f5073d713
mx: Make java file list order deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16944
diff
changeset
|
2633 javafilelist = sorted(javafilelist) |
5e5f5073d713
mx: Make java file list order deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16944
diff
changeset
|
2634 |
15496
f5eba273a4f2
mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents:
15490
diff
changeset
|
2635 task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, jdtJar, taskDeps) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2636 if p.definedAnnotationProcessorsDist: |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
2637 updatedAnnotationProcessorDists.add(p.definedAnnotationProcessorsDist) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2638 |
17050
49b8c8932786
projects must be rebuilt when any of their dependencies are rebuilt
Doug Simon <doug.simon@oracle.com>
parents:
17013
diff
changeset
|
2639 tasks[p.name] = task |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2640 if args.parallelize: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2641 # Best to initialize class paths on main process |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2642 jdk.bootclasspath() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2643 task.proc = None |
5876
c21886d4e125
Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5854
diff
changeset
|
2644 else: |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2645 task.execute() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2646 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2647 if args.parallelize: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2648 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2649 def joinTasks(tasks): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2650 failed = [] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2651 for t in tasks: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2652 t.proc.join() |
15786
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2653 _removeSubprocess(t.sub) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2654 if t.proc.exitcode != 0: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2655 failed.append(t) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2656 return failed |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2657 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2658 def checkTasks(tasks): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2659 active = [] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2660 for t in tasks: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2661 if t.proc.is_alive(): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2662 active.append(t) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2663 else: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2664 if t.proc.exitcode != 0: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2665 return ([], joinTasks(tasks)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2666 return (active, []) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2667 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2668 def remainingDepsDepth(task): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2669 if task._d is None: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2670 incompleteDeps = [d for d in task.deps if d.proc is None or d.proc.is_alive()] |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2671 if len(incompleteDeps) == 0: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2672 task._d = 0 |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
2673 else: |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2674 task._d = max([remainingDepsDepth(t) for t in incompleteDeps]) + 1 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2675 return task._d |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2676 |
15490
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2677 def compareTasks(t1, t2): |
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2678 d = remainingDepsDepth(t1) - remainingDepsDepth(t2) |
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2679 if d == 0: |
15497
1f28c463e452
mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents:
15496
diff
changeset
|
2680 t1Work = (1 + len(t1.proj.annotation_processors())) * len(t1.javafilelist) |
1f28c463e452
mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents:
15496
diff
changeset
|
2681 t2Work = (1 + len(t2.proj.annotation_processors())) * len(t2.javafilelist) |
1f28c463e452
mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents:
15496
diff
changeset
|
2682 d = t1Work - t2Work |
15490
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2683 return d |
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2684 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2685 def sortWorklist(tasks): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2686 for t in tasks: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2687 t._d = None |
15490
5d0dd6a6f6b3
mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents:
15489
diff
changeset
|
2688 return sorted(tasks, compareTasks) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2689 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2690 cpus = multiprocessing.cpu_count() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2691 worklist = sortWorklist(tasks.values()) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2692 active = [] |
15786
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2693 failed = [] |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2694 while len(worklist) != 0: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2695 while True: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2696 active, failed = checkTasks(active) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2697 if len(failed) != 0: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2698 assert not active, active |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2699 break |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2700 if len(active) == cpus: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2701 # Sleep for 1 second |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2702 time.sleep(1) |
5071
9d055af068a8
Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents:
5032
diff
changeset
|
2703 else: |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2704 break |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2705 |
15786
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2706 if len(failed) != 0: |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2707 break |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2708 |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2709 def executeTask(task): |
15781
8b9e7f235d85
mx: fixed spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15701
diff
changeset
|
2710 # Clear sub-process list cloned from parent process |
8b9e7f235d85
mx: fixed spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15701
diff
changeset
|
2711 del _currentSubprocesses[:] |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2712 task.execute() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2713 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2714 def depsDone(task): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2715 for d in task.deps: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2716 if d.proc is None or d.proc.exitcode is None: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2717 return False |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2718 return True |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2719 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2720 for task in worklist: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2721 if depsDone(task): |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2722 worklist.remove(task) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2723 task.proc = multiprocessing.Process(target=executeTask, args=(task,)) |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2724 task.proc.start() |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2725 active.append(task) |
15489
d0e3f6963ed7
mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents:
15462
diff
changeset
|
2726 task.sub = _addSubprocess(task.proc, ['JavaCompileTask', str(task)]) |
15460
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2727 if len(active) == cpus: |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2728 break |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2729 |
7d24ff89dc7d
mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15457
diff
changeset
|
2730 worklist = sortWorklist(worklist) |
15786
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2731 |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2732 failed += joinTasks(active) |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2733 if len(failed): |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2734 for t in failed: |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2735 log('Compiling {} failed'.format(t.proj.name)) |
d54cca247d0b
mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents:
15785
diff
changeset
|
2736 abort('{} Java compilation tasks failed'.format(len(failed))) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2737 |
16875
73d994651fcd
fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents:
16849
diff
changeset
|
2738 if args.java: |
73d994651fcd
fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents:
16849
diff
changeset
|
2739 for dist in sorted_dists(): |
73d994651fcd
fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents:
16849
diff
changeset
|
2740 if dist not in updatedAnnotationProcessorDists: |
73d994651fcd
fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents:
16849
diff
changeset
|
2741 archive(['@' + dist.name]) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2742 |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2743 if suppliedParser: |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2744 return args |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
2745 return None |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2746 |
15274
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2747 def _chunk_files_for_command_line(files, limit=None, pathFunction=None): |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2748 """ |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2749 Returns a generator for splitting up a list of files into chunks such that the |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2750 size of the space separated file paths in a chunk is less than a given limit. |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2751 This is used to work around system command line length limits. |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2752 """ |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2753 chunkSize = 0 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2754 chunkStart = 0 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2755 if limit is None: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2756 commandLinePrefixAllowance = 3000 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2757 if get_os() == 'windows': |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2758 # The CreateProcess function on Windows limits the length of a command line to |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2759 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx) |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2760 limit = 32768 - commandLinePrefixAllowance |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2761 else: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2762 # Using just SC_ARG_MAX without extra downwards adjustment |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2763 # results in "[Errno 7] Argument list too long" on MacOS. |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2764 syslimit = os.sysconf('SC_ARG_MAX') - 20000 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2765 limit = syslimit - commandLinePrefixAllowance |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2766 for i in range(len(files)): |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2767 path = files[i] if pathFunction is None else pathFunction(files[i]) |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2768 size = len(path) + 1 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2769 if chunkSize + size < limit: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2770 chunkSize += size |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2771 else: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2772 assert i > chunkStart |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2773 yield files[chunkStart:i] |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2774 chunkStart = i |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2775 chunkSize = 0 |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2776 if chunkStart == 0: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2777 assert chunkSize < limit |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2778 yield files |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2779 |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2780 def eclipseformat(args): |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2781 """run the Eclipse Code Formatter on the Java sources |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2782 |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2783 The exit code 1 denotes that at least one file was modified.""" |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2784 |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2785 parser = ArgumentParser(prog='mx eclipseformat') |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2786 parser.add_argument('-e', '--eclipse-exe', help='location of the Eclipse executable') |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2787 parser.add_argument('-C', '--no-backup', action='store_false', dest='backup', help='do not save backup of modified files') |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2788 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2789 |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2790 args = parser.parse_args(args) |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2791 if args.eclipse_exe is None: |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2792 args.eclipse_exe = os.environ.get('ECLIPSE_EXE') |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2793 if args.eclipse_exe is None: |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2794 abort('Could not find Eclipse executable. Use -e option or ensure ECLIPSE_EXE environment variable is set.') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2795 |
8991
096725f4da58
the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents:
8958
diff
changeset
|
2796 # Maybe an Eclipse installation dir was specified - look for the executable in it |
14553
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2797 if isdir(args.eclipse_exe): |
8991
096725f4da58
the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents:
8958
diff
changeset
|
2798 args.eclipse_exe = join(args.eclipse_exe, exe_suffix('eclipse')) |
14553
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2799 warn("The eclipse-exe was a directory, now using " + args.eclipse_exe) |
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2800 |
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2801 if not os.path.isfile(args.eclipse_exe): |
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2802 abort('File does not exist: ' + args.eclipse_exe) |
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
2803 if not os.access(args.eclipse_exe, os.X_OK): |
8991
096725f4da58
the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents:
8958
diff
changeset
|
2804 abort('Not an executable file: ' + args.eclipse_exe) |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2805 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2806 eclipseinit([], buildProcessorJars=False) |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2807 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2808 # build list of projects to be processed |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2809 projects = sorted_deps() |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2810 if args.projects is not None: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2811 projects = [project(name) for name in args.projects.split(',')] |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2812 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2813 class Batch: |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2814 def __init__(self, settingsDir, javaCompliance): |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2815 self.path = join(settingsDir, 'org.eclipse.jdt.core.prefs') |
14763 | 2816 self.javaCompliance = javaCompliance |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2817 self.javafiles = list() |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2818 with open(join(settingsDir, 'org.eclipse.jdt.ui.prefs')) as fp: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2819 jdtUiPrefs = fp.read() |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2820 self.removeTrailingWhitespace = 'sp_cleanup.remove_trailing_whitespaces_all=true' in jdtUiPrefs |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2821 if self.removeTrailingWhitespace: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2822 assert 'sp_cleanup.remove_trailing_whitespaces=true' in jdtUiPrefs and 'sp_cleanup.remove_trailing_whitespaces_ignore_empty=false' in jdtUiPrefs |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2823 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2824 def settings(self): |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2825 with open(self.path) as fp: |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2826 return fp.read() + java(self.javaCompliance).java + str(self.removeTrailingWhitespace) |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2827 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2828 class FileInfo: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2829 def __init__(self, path): |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2830 self.path = path |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2831 with open(path) as fp: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2832 self.content = fp.read() |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2833 self.times = (os.path.getatime(path), os.path.getmtime(path)) |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2834 |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2835 def update(self, removeTrailingWhitespace): |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2836 with open(self.path) as fp: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2837 content = fp.read() |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2838 |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2839 if self.content != content: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2840 # Only apply *after* formatting to match the order in which the IDE does it |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2841 if removeTrailingWhitespace: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2842 content, n = re.subn(r'[ \t]+$', '', content, flags=re.MULTILINE) |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2843 if n != 0 and self.content == content: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2844 # undo on-disk changes made by the Eclipse formatter |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2845 with open(self.path, 'w') as fp: |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2846 fp.write(content) |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2847 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2848 if self.content != content: |
14626
4f8268dee8aa
mx: eclipseformat now prints all the changes that were found to the console.
Christian Humer <christian.humer@gmail.com>
parents:
14553
diff
changeset
|
2849 self.diff = difflib.unified_diff(self.content.splitlines(1), content.splitlines(1)) |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2850 self.content = content |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2851 return True |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2852 |
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2853 # reset access and modification time of file |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2854 os.utime(self.path, self.times) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2855 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2856 modified = list() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2857 batches = dict() # all sources with the same formatting settings are formatted together |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2858 for p in projects: |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2859 if p.native: |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2860 continue |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2861 sourceDirs = p.source_dirs() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2862 |
14874
7dfc0e9fd45a
added removal of trailing whitespace to eclipseformat to emulate the actions performed by the IDE
Doug Simon <doug.simon@oracle.com>
parents:
14785
diff
changeset
|
2863 batch = Batch(join(p.dir, '.settings'), p.javaCompliance) |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2864 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2865 if not exists(batch.path): |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2866 if _opts.verbose: |
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2867 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2868 continue |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2869 |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2870 for sourceDir in sourceDirs: |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2871 for root, _, files in os.walk(sourceDir): |
7532
780269e56ddd
eclipseformat is also applied to package-info.java files
Doug Simon <doug.simon@oracle.com>
parents:
7528
diff
changeset
|
2872 for f in [join(root, name) for name in files if name.endswith('.java')]: |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2873 batch.javafiles.append(FileInfo(f)) |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2874 if len(batch.javafiles) == 0: |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
2875 logv('[no Java sources in {0} - skipping]'.format(p.name)) |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2876 continue |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2877 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2878 res = batches.setdefault(batch.settings(), batch) |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2879 if res is not batch: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2880 res.javafiles = res.javafiles + batch.javafiles |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2881 |
15274
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2882 log("we have: " + str(len(batches)) + " batches") |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2883 for batch in batches.itervalues(): |
15274
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2884 for chunk in _chunk_files_for_command_line(batch.javafiles, pathFunction=lambda f: f.path): |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2885 run([args.eclipse_exe, |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2886 '-nosplash', |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2887 '-application', |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2888 'org.eclipse.jdt.core.JavaCodeFormatter', |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2889 '-vm', java(batch.javaCompliance).java, |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2890 '-config', batch.path] |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2891 + [f.path for f in chunk]) |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2892 for fi in chunk: |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2893 if fi.update(batch.removeTrailingWhitespace): |
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
2894 modified.append(fi) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2895 |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2896 log('{0} files were modified'.format(len(modified))) |
14626
4f8268dee8aa
mx: eclipseformat now prints all the changes that were found to the console.
Christian Humer <christian.humer@gmail.com>
parents:
14553
diff
changeset
|
2897 |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2898 if len(modified) != 0: |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2899 arcbase = _primary_suite.dir |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2900 if args.backup: |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2901 backup = os.path.abspath('eclipseformat.backup.zip') |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2902 zf = zipfile.ZipFile(backup, 'w', zipfile.ZIP_DEFLATED) |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2903 for fi in modified: |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2904 name = os.path.relpath(fi.path, arcbase) |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2905 log(' - {0}'.format(name)) |
14626
4f8268dee8aa
mx: eclipseformat now prints all the changes that were found to the console.
Christian Humer <christian.humer@gmail.com>
parents:
14553
diff
changeset
|
2906 log('Changes:') |
4f8268dee8aa
mx: eclipseformat now prints all the changes that were found to the console.
Christian Humer <christian.humer@gmail.com>
parents:
14553
diff
changeset
|
2907 log(''.join(fi.diff)) |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2908 if args.backup: |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2909 arcname = name.replace(os.sep, '/') |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2910 zf.writestr(arcname, fi.content) |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2911 if args.backup: |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2912 zf.close() |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2913 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup)) |
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2914 return 1 |
7533
29b0768b7ba6
added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents:
7532
diff
changeset
|
2915 return 0 |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
2916 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2917 def processorjars(): |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2918 for s in suites(True): |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2919 _processorjars_suite(s) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2920 |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2921 def _processorjars_suite(s): |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2922 projs = [p for p in s.projects if p.definedAnnotationProcessors is not None] |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2923 if len(projs) <= 0: |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2924 return [] |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2925 |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2926 pnames = [p.name for p in projs] |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2927 build(['--jdt-warning-as-error', '--projects', ",".join(pnames)]) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2928 return [p.definedAnnotationProcessorsDist.path for p in s.projects if p.definedAnnotationProcessorsDist is not None] |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
2929 |
11777
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2930 def pylint(args): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2931 """run pylint (if available) over Python source files (found by 'hg locate' or by tree walk with -walk)""" |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2932 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2933 parser = ArgumentParser(prog='mx pylint') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2934 parser.add_argument('--walk', action='store_true', help='use tree walk find .py files') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2935 args = parser.parse_args(args) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2936 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2937 rcfile = join(dirname(__file__), '.pylintrc') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2938 if not exists(rcfile): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2939 log('pylint configuration file does not exist: ' + rcfile) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2940 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2941 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2942 try: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2943 output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2944 m = re.match(r'.*pylint (\d+)\.(\d+)\.(\d+).*', output, re.DOTALL) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2945 if not m: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2946 log('could not determine pylint version from ' + output) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2947 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2948 major, minor, micro = (int(m.group(1)), int(m.group(2)), int(m.group(3))) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2949 if major < 1: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2950 log('require pylint version >= 1 (got {0}.{1}.{2})'.format(major, minor, micro)) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2951 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2952 except BaseException: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2953 log('pylint is not available') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2954 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2955 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2956 def findfiles_by_walk(): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2957 result = [] |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2958 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2959 for root, dirs, files in os.walk(suite.dir): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2960 for f in files: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2961 if f.endswith('.py'): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2962 pyfile = join(root, f) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2963 result.append(pyfile) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2964 if 'bin' in dirs: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2965 dirs.remove('bin') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2966 if 'lib' in dirs: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2967 # avoids downloaded .py files |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2968 dirs.remove('lib') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2969 return result |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2970 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2971 def findfiles_by_hg(): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2972 result = [] |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2973 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2974 versioned = subprocess.check_output(['hg', 'locate', '-f'], stderr=subprocess.STDOUT, cwd=suite.dir).split(os.linesep) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2975 for f in versioned: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2976 if f.endswith('.py') and exists(f): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2977 result.append(f) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2978 return result |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2979 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2980 # Perhaps we should just look in suite.mxDir directories for .py files? |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2981 if args.walk: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2982 pyfiles = findfiles_by_walk() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2983 else: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2984 pyfiles = findfiles_by_hg() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2985 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2986 env = os.environ.copy() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2987 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2988 pythonpath = dirname(__file__) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2989 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2990 pythonpath = os.pathsep.join([pythonpath, suite.mxDir]) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2991 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2992 env['PYTHONPATH'] = pythonpath |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2993 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2994 for pyfile in pyfiles: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2995 log('Running pylint on ' + pyfile + '...') |
13266
78ed696884b3
fixed regression in pylint command (exit code must be non-zero if at least one warning/error was found)
Doug Simon <doug.simon@oracle.com>
parents:
13247
diff
changeset
|
2996 run(['pylint', '--reports=n', '--rcfile=' + rcfile, pyfile], env=env) |
11777
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2997 |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
2998 """ |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
2999 Utility for creating and updating a zip file atomically. |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3000 """ |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3001 class Archiver: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3002 def __init__(self, path): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3003 self.path = path |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3004 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3005 def __enter__(self): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3006 if self.path: |
16682
63706366f6c5
moved distribution artifacts into build/ sub-directory
Doug Simon <doug.simon@oracle.com>
parents:
16671
diff
changeset
|
3007 if not isdir(dirname(self.path)): |
63706366f6c5
moved distribution artifacts into build/ sub-directory
Doug Simon <doug.simon@oracle.com>
parents:
16671
diff
changeset
|
3008 os.makedirs(dirname(self.path)) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3009 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(self.path) + '.', dir=dirname(self.path)) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3010 self.tmpFd = fd |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3011 self.tmpPath = tmp |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3012 self.zf = zipfile.ZipFile(tmp, 'w') |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3013 else: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3014 self.tmpFd = None |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3015 self.tmpPath = None |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3016 self.zf = None |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3017 return self |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3018 |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3019 def __exit__(self, exc_type, exc_value, traceback): |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3020 if self.zf: |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3021 self.zf.close() |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3022 os.close(self.tmpFd) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3023 # Correct the permissions on the temporary file which is created with restrictive permissions |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3024 os.chmod(self.tmpPath, 0o666 & ~currentUmask) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3025 # Atomic on Unix |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3026 shutil.move(self.tmpPath, self.path) |
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3027 |
15818
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
3028 def _archive(args): |
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
3029 archive(args) |
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
3030 return 0 |
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
3031 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3032 def archive(args): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3033 """create jar files for projects and distributions""" |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3034 parser = ArgumentParser(prog='mx archive') |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3035 parser.add_argument('names', nargs=REMAINDER, metavar='[<project>|@<distribution>]...') |
7925
c7d7d9936809
use zipfile module instead of an external call to jar for creating jar files from projects
Doug Simon <doug.simon@oracle.com>
parents:
7918
diff
changeset
|
3036 args = parser.parse_args(args) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3037 |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3038 archives = [] |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3039 for name in args.names: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3040 if name.startswith('@'): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3041 dname = name[1:] |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3042 d = distribution(dname) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3043 d.make_archive() |
14964
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
3044 archives.append(d.path) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3045 else: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3046 p = project(name) |
15226
f1c66b738dae
mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents:
15149
diff
changeset
|
3047 archives.append(p.make_archive()) |
14964
e1ce6c66f56e
refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents:
14940
diff
changeset
|
3048 |
15818
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
3049 logv("generated archives: " + str(archives)) |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3050 return archives |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
3051 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3052 def canonicalizeprojects(args): |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3053 """check all project specifications for canonical dependencies |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3054 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3055 The exit code of this command reflects how many projects have non-canonical dependencies.""" |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3056 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3057 nonCanonical = [] |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3058 for s in suites(True): |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3059 projectsPyFile = join(s.mxDir, 'projects') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3060 if not exists(projectsPyFile): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3061 continue |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3062 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3063 for p in s.projects: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3064 for pkg in p.defined_java_packages(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3065 if not pkg.startswith(p.name): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3066 abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3067 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3068 ignoredDeps = set([name for name in p.deps if project(name, False) is not None]) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3069 for pkg in p.imported_java_packages(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3070 for name in p.deps: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3071 dep = project(name, False) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3072 if dep is None: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3073 ignoredDeps.discard(name) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3074 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3075 if pkg in dep.defined_java_packages(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3076 ignoredDeps.discard(name) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3077 if pkg in dep.extended_java_packages(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3078 ignoredDeps.discard(name) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3079 if len(ignoredDeps) != 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3080 candidates = set() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3081 # Compute dependencies based on projects required by p |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3082 for d in sorted_deps(): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3083 if not d.defined_java_packages().isdisjoint(p.imported_java_packages()): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3084 candidates.add(d) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3085 # Remove non-canonical candidates |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3086 for c in list(candidates): |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3087 candidates.difference_update(c.all_deps([], False, False)) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3088 candidates = [d.name for d in candidates] |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3089 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3090 abort('{} does not use any packages defined in these projects: {}\nComputed project dependencies: {}'.format( |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3091 p, ', '.join(ignoredDeps), ','.join(candidates))) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3092 |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3093 excess = frozenset(p.deps) - set(p.canonical_deps()) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3094 if len(excess) != 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3095 nonCanonical.append(p) |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3096 if len(nonCanonical) != 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3097 for p in nonCanonical: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3098 canonicalDeps = p.canonical_deps() |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3099 if len(canonicalDeps) != 0: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3100 log('Canonical dependencies for project ' + p.name + ' are: [') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3101 for d in canonicalDeps: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3102 log(' "' + d + '",') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3103 log(' ],') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3104 else: |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3105 log('Canonical dependencies for project ' + p.name + ' are: []') |
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
3106 return len(nonCanonical) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3107 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3108 class TimeStampFile: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3109 def __init__(self, path): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3110 self.path = path |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3111 self.timestamp = os.path.getmtime(path) if exists(path) else None |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3112 |
12524
2583afcd26ee
fixed bug in creation of CreateGRAALDist.launch files
Doug Simon <doug.simon@oracle.com>
parents:
12522
diff
changeset
|
3113 def isOlderThan(self, arg): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3114 if not self.timestamp: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3115 return True |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3116 if isinstance(arg, TimeStampFile): |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3117 if arg.timestamp is None: |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3118 return False |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3119 else: |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3120 return arg.timestamp > self.timestamp |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3121 elif isinstance(arg, types.ListType): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3122 files = arg |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3123 else: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3124 files = [arg] |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3125 for f in files: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3126 if os.path.getmtime(f) > self.timestamp: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3127 return True |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3128 return False |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3129 |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3130 def exists(self): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3131 return exists(self.path) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3132 |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3133 def touch(self): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3134 if exists(self.path): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3135 os.utime(self.path, None) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3136 else: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3137 if not isdir(dirname(self.path)): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3138 os.makedirs(dirname(self.path)) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3139 file(self.path, 'a') |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3140 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3141 def checkstyle(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3142 """run Checkstyle on the Java sources |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3143 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3144 Run Checkstyle over the Java sources. Any errors or warnings |
6284
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3145 produced by Checkstyle result in a non-zero exit code.""" |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3146 |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3147 parser = ArgumentParser(prog='mx checkstyle') |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3148 |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3149 parser.add_argument('-f', action='store_true', dest='force', help='force checking (disables timestamp checking)') |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3150 args = parser.parse_args(args) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3151 |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3152 totalErrors = 0 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3153 for p in projects_opt_limit_to_suites(): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3154 if p.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3155 continue |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3156 sourceDirs = p.source_dirs() |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
3157 |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
3158 csConfig = join(p.dir, '.checkstyle_checks.xml') |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
3159 if not exists(csConfig): |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
3160 abort('ERROR: Checkstyle configuration for project {} is missing: {}'.format(p.name, csConfig)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3161 |
10060
193d5163a94a
exclude projects from mx checkstyle if their Java compliance level is higher than the configured JDK
Doug Simon <doug.simon@oracle.com>
parents:
10059
diff
changeset
|
3162 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK |
14763 | 3163 jdk = java(p.javaCompliance) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
3164 assert jdk |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3165 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3166 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3167 javafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3168 for root, _, files in os.walk(sourceDir): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3169 javafilelist += [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java'] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3170 if len(javafilelist) == 0: |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
3171 logv('[no Java sources in {0} - skipping]'.format(sourceDir)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3172 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3173 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3174 timestamp = TimeStampFile(join(p.suite.mxDir, 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp')) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3175 mustCheck = False |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3176 if not args.force and timestamp.exists(): |
12524
2583afcd26ee
fixed bug in creation of CreateGRAALDist.launch files
Doug Simon <doug.simon@oracle.com>
parents:
12522
diff
changeset
|
3177 mustCheck = timestamp.isOlderThan(javafilelist) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3178 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3179 mustCheck = True |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3180 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3181 if not mustCheck: |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3182 if _opts.verbose: |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3183 log('[all Java sources in {0} already checked - skipping]'.format(sourceDir)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3184 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3185 |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
3186 dotCheckstyleXML = xml.dom.minidom.parse(csConfig) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3187 localCheckConfig = dotCheckstyleXML.getElementsByTagName('local-check-config')[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3188 configLocation = localCheckConfig.getAttribute('location') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3189 configType = localCheckConfig.getAttribute('type') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3190 if configType == 'project': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3191 # Eclipse plugin "Project Relative Configuration" format: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3192 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3193 # '/<project_name>/<suffix>' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3194 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3195 if configLocation.startswith('/'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3196 name, _, suffix = configLocation.lstrip('/').partition('/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3197 config = join(project(name).dir, suffix) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3198 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3199 config = join(p.dir, configLocation) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3200 else: |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
3201 logv('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir)) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3202 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3203 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3204 exclude = join(p.dir, '.checkstyle.exclude') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3205 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3206 if exists(exclude): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3207 with open(exclude) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3208 # Convert patterns to OS separators |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3209 patterns = [name.rstrip().replace('/', os.sep) for name in f.readlines()] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3210 def match(name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3211 for p in patterns: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3212 if p in name: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3213 if _opts.verbose: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3214 log('excluding: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3215 return True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3216 return False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3217 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3218 javafilelist = [name for name in javafilelist if not match(name)] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3219 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3220 auditfileName = join(p.dir, 'checkstyleOutput.txt') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3221 log('Running Checkstyle on {0} using {1}...'.format(sourceDir, config)) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3222 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3223 try: |
15274
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
3224 for chunk in _chunk_files_for_command_line(javafilelist): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3225 try: |
15274
1ea79f17ab95
mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents:
15227
diff
changeset
|
3226 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + chunk, nonZeroIsFatal=False) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3227 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3228 if exists(auditfileName): |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3229 errors = [] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3230 source = [None] |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3231 def start_element(name, attrs): |
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3232 if name == 'file': |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3233 source[0] = attrs['name'] |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3234 elif name == 'error': |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3235 errors.append('{}:{}: {}'.format(source[0], attrs['line'], attrs['message'])) |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3236 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3237 xp = xml.parsers.expat.ParserCreate() |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3238 xp.StartElementHandler = start_element |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3239 with open(auditfileName) as fp: |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3240 xp.ParseFile(fp) |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3241 if len(errors) != 0: |
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3242 map(log, errors) |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3243 totalErrors = totalErrors + len(errors) |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
3244 else: |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3245 timestamp.touch() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3246 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3247 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3248 os.unlink(auditfileName) |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
3249 return totalErrors |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3250 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3251 def clean(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3252 """remove all class files, images, and executables |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3253 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3254 Removes all files created by a build, including Java class files, executables, and |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3255 generated images. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3256 """ |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
3257 |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
3258 suppliedParser = parser is not None |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3259 |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3260 parser = parser if suppliedParser else ArgumentParser(prog='mx clean') |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3261 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3262 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') |
16087
64e172733061
mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
16086
diff
changeset
|
3263 parser.add_argument('--no-dist', action='store_false', dest='dist', help='do not delete distributions') |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3264 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3265 args = parser.parse_args(args) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3266 |
15579
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3267 def _rmtree(dirPath): |
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3268 path = dirPath |
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3269 if get_os() == 'windows': |
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3270 path = unicode("\\\\?\\" + dirPath) |
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3271 shutil.rmtree(path) |
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3272 |
16087
64e172733061
mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
16086
diff
changeset
|
3273 def _rmIfExists(name): |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
3274 if name and os.path.isfile(name): |
16087
64e172733061
mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
16086
diff
changeset
|
3275 os.unlink(name) |
64e172733061
mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
16086
diff
changeset
|
3276 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3277 for p in projects_opt_limit_to_suites(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3278 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3279 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3280 run([gmake_cmd(), '-C', p.dir, 'clean']) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3281 else: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3282 if args.java: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3283 genDir = p.source_gen_dir() |
7778
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
3284 if genDir != '' and exists(genDir): |
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
3285 log('Clearing {0}...'.format(genDir)) |
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
3286 for f in os.listdir(genDir): |
15579
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3287 _rmtree(join(genDir, f)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3288 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3289 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3290 outputDir = p.output_dir() |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3291 if outputDir != '' and exists(outputDir): |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
3292 log('Removing {0}...'.format(outputDir)) |
15579
c3869fe3d917
mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents:
15577
diff
changeset
|
3293 _rmtree(outputDir) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3294 |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3295 for configName in ['netbeans-config.zip', 'eclipse-config.zip']: |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3296 config = TimeStampFile(join(p.suite.mxDir, configName)) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3297 if config.exists(): |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3298 os.unlink(config.path) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3299 |
17063
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3300 if args.java: |
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3301 if args.dist: |
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3302 for d in _dists.keys(): |
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3303 log('Removing distribution {0}...'.format(d)) |
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3304 _rmIfExists(distribution(d).path) |
75a4acd33159
mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents:
17059
diff
changeset
|
3305 _rmIfExists(distribution(d).sourcesPath) |
16087
64e172733061
mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents:
16086
diff
changeset
|
3306 |
4247
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
3307 if suppliedParser: |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
3308 return args |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3309 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3310 def about(args): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3311 """show the 'man page' for mx""" |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3312 print __doc__ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3313 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3314 def help_(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3315 """show help for a given command |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3316 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3317 With no arguments, print a list of commands and short help for each command. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3318 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3319 Given a command name, print help for that command.""" |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3320 if len(args) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3321 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3322 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3323 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3324 name = args[0] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3325 if not _commands.has_key(name): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3326 hits = [c for c in _commands.iterkeys() if c.startswith(name)] |
6284
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3327 if len(hits) == 1: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3328 name = hits[0] |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3329 elif len(hits) == 0: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3330 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(name, _format_commands())) |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3331 else: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
3332 abort('mx: command \'{0}\' is ambiguous\n {1}'.format(name, ' '.join(hits))) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3333 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3334 value = _commands[name] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3335 (func, usage) = value[:2] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3336 doc = func.__doc__ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3337 if len(value) > 2: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3338 docArgs = value[2:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3339 fmtArgs = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3340 for d in docArgs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3341 if isinstance(d, Callable): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
3342 fmtArgs += [d()] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3343 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3344 fmtArgs += [str(d)] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3345 doc = doc.format(*fmtArgs) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3346 print 'mx {0} {1}\n\n{2}\n'.format(name, usage, doc) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3347 |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3348 def projectgraph(args, suite=None): |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3349 """create graph for project structure ("mx projectgraph | dot -Tpdf -oprojects.pdf" or "mx projectgraph --igv")""" |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3350 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3351 parser = ArgumentParser(prog='mx projectgraph') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3352 parser.add_argument('--igv', action='store_true', help='output to IGV listening on 127.0.0.1:4444') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3353 parser.add_argument('--igv-format', action='store_true', help='output graph in IGV format') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3354 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3355 args = parser.parse_args(args) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3356 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3357 if args.igv or args.igv_format: |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3358 ids = {} |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3359 nextToIndex = {} |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3360 igv = XMLDoc() |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3361 igv.open('graphDocument') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3362 igv.open('group') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3363 igv.open('properties') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3364 igv.element('p', {'name' : 'name'}, 'GraalProjectDependencies') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3365 igv.close('properties') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3366 igv.open('graph', {'name' : 'dependencies'}) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3367 igv.open('nodes') |
15785
7a6f6a7ef886
Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents:
15781
diff
changeset
|
3368 for p in sorted_deps(includeLibs=True, includeJreLibs=True): |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3369 ident = len(ids) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3370 ids[p.name] = str(ident) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3371 igv.open('node', {'id' : str(ident)}) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3372 igv.open('properties') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3373 igv.element('p', {'name' : 'name'}, p.name) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3374 igv.close('properties') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3375 igv.close('node') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3376 igv.close('nodes') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3377 igv.open('edges') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3378 for p in projects(): |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3379 fromIndex = 0 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3380 for dep in p.canonical_deps(): |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3381 toIndex = nextToIndex.get(dep, 0) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3382 nextToIndex[dep] = toIndex + 1 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3383 igv.element('edge', {'from' : ids[p.name], 'fromIndex' : str(fromIndex), 'to' : ids[dep], 'toIndex' : str(toIndex), 'label' : 'dependsOn'}) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3384 fromIndex = fromIndex + 1 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3385 igv.close('edges') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3386 igv.close('graph') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3387 igv.close('group') |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3388 igv.close('graphDocument') |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3389 |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3390 if args.igv: |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3391 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3392 s.connect(('127.0.0.1', 4444)) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3393 s.send(igv.xml()) |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3394 else: |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3395 print igv.xml(indent=' ', newl='\n') |
12620
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
3396 return |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3397 |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3398 print 'digraph projects {' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3399 print 'rankdir=BT;' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3400 print 'node [shape=rect];' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3401 for p in projects(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3402 for dep in p.canonical_deps(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3403 print '"' + p.name + '"->"' + dep + '"' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
3404 print '}' |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3405 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3406 def _source_locator_memento(deps): |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
3407 slm = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3408 slm.open('sourceLookupDirector') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3409 slm.open('sourceContainers', {'duplicates' : 'false'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3410 |
13775
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3411 javaCompliance = None |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3412 for dep in deps: |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3413 if dep.isLibrary(): |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3414 if hasattr(dep, 'eclipse.container'): |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
3415 memento = XMLDoc().element('classpathContainer', {'path' : getattr(dep, 'eclipse.container')}).xml(standalone='no') |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3416 slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'}) |
13727
10e6f192631f
added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
13682
diff
changeset
|
3417 elif dep.get_source_path(resolve=True): |
10e6f192631f
added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
13682
diff
changeset
|
3418 memento = XMLDoc().element('archive', {'detectRoot' : 'true', 'path' : dep.get_source_path(resolve=True)}).xml(standalone='no') |
10e6f192631f
added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
13682
diff
changeset
|
3419 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.debug.core.containerType.externalArchive'}) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
3420 elif dep.isProject(): |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
3421 memento = XMLDoc().element('javaProject', {'name' : dep.name}).xml(standalone='no') |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3422 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'}) |
15693
807090ddbbf2
use JDK with highest compliance level for generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
15662
diff
changeset
|
3423 if javaCompliance is None or dep.javaCompliance > javaCompliance: |
13775
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3424 javaCompliance = dep.javaCompliance |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3425 |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3426 if javaCompliance: |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3427 memento = XMLDoc().element('classpathContainer', {'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(javaCompliance)}).xml(standalone='no') |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3428 slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'}) |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3429 else: |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3430 memento = XMLDoc().element('classpathContainer', {'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}).xml(standalone='no') |
43c7df32d5ab
use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents:
13727
diff
changeset
|
3431 slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'}) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3432 |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3433 slm.close('sourceContainers') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3434 slm.close('sourceLookupDirector') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3435 return slm |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3436 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3437 def make_eclipse_attach(suite, hostname, port, name=None, deps=None): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3438 """ |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3439 Creates an Eclipse launch configuration file for attaching to a Java process. |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3440 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3441 if deps is None: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3442 deps = [] |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3443 slm = _source_locator_memento(deps) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
3444 launch = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3445 launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.remoteJavaApplication'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3446 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3447 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3448 launch.element('booleanAttribute', {'key' : 'org.eclipse.jdt.launching.ALLOW_TERMINATE', 'value' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3449 launch.open('mapAttribute', {'key' : 'org.eclipse.jdt.launching.CONNECT_MAP'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3450 launch.element('mapEntry', {'key' : 'hostname', 'value' : hostname}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3451 launch.element('mapEntry', {'key' : 'port', 'value' : port}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3452 launch.close('mapAttribute') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3453 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROJECT_ATTR', 'value' : ''}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3454 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.VM_CONNECTOR_ID', 'value' : 'org.eclipse.jdt.launching.socketAttachConnector'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3455 launch.close('launchConfiguration') |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
3456 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no') |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3457 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3458 if name is None: |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3459 if len(suites()) == 1: |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3460 suitePrefix = '' |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3461 else: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3462 suitePrefix = suite.name + '-' |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3463 name = suitePrefix + 'attach-' + hostname + '-' + port |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3464 eclipseLaunches = join(suite.mxDir, 'eclipse-launches') |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3465 if not exists(eclipseLaunches): |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3466 os.makedirs(eclipseLaunches) |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3467 launchFile = join(eclipseLaunches, name + '.launch') |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3468 return update_file(launchFile, launch), launchFile |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3469 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3470 def make_eclipse_launch(javaArgs, jre, name=None, deps=None): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3471 """ |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3472 Creates an Eclipse launch configuration file for running/debugging a Java command. |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3473 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3474 if deps is None: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3475 deps = [] |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3476 mainClass = None |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3477 vmArgs = [] |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3478 appArgs = [] |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3479 cp = None |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3480 argsCopy = list(reversed(javaArgs)) |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3481 while len(argsCopy) != 0: |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3482 a = argsCopy.pop() |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3483 if a == '-jar': |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3484 mainClass = '-jar' |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3485 appArgs = list(reversed(argsCopy)) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3486 break |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3487 if a == '-cp' or a == '-classpath': |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3488 assert len(argsCopy) != 0 |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3489 cp = argsCopy.pop() |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3490 vmArgs.append(a) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3491 vmArgs.append(cp) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3492 elif a.startswith('-'): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3493 vmArgs.append(a) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3494 else: |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3495 mainClass = a |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3496 appArgs = list(reversed(argsCopy)) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3497 break |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3498 |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3499 if mainClass is None: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3500 log('Cannot create Eclipse launch configuration without main class or jar file: java ' + ' '.join(javaArgs)) |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3501 return False |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3502 |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3503 if name is None: |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3504 if mainClass == '-jar': |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3505 name = basename(appArgs[0]) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3506 if len(appArgs) > 1 and not appArgs[1].startswith('-'): |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3507 name = name + '_' + appArgs[1] |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3508 else: |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3509 name = mainClass |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3510 name = time.strftime('%Y-%m-%d-%H%M%S_' + name) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3511 |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3512 if cp is not None: |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3513 for e in cp.split(os.pathsep): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3514 for s in suites(): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3515 deps += [p for p in s.projects if e == p.output_dir()] |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3516 deps += [l for l in s.libs if e == l.get_path(False)] |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3517 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3518 slm = _source_locator_memento(deps) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3519 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
3520 launch = XMLDoc() |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3521 launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.localJavaApplication'}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3522 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3523 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3524 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.JRE_CONTAINER', 'value' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/' + jre}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3525 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.MAIN_TYPE', 'value' : mainClass}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3526 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS', 'value' : ' '.join(appArgs)}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3527 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROJECT_ATTR', 'value' : ''}) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3528 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.VM_ARGUMENTS', 'value' : ' '.join(vmArgs)}) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3529 launch.close('launchConfiguration') |
8633
c4bca84d86d7
ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
8607
diff
changeset
|
3530 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no') |
5194
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3531 |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3532 eclipseLaunches = join('mx', 'eclipse-launches') |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3533 if not exists(eclipseLaunches): |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3534 os.makedirs(eclipseLaunches) |
a6eceb5efb0e
added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents:
5189
diff
changeset
|
3535 return update_file(join(eclipseLaunches, name + '.launch'), launch) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3536 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3537 def eclipseinit(args, buildProcessorJars=True, refreshOnly=False): |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3538 """(re)generate Eclipse project configurations and working sets""" |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3539 for s in suites(True): |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3540 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3541 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3542 generate_eclipse_workingsets() |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3543 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3544 def _check_ide_timestamp(suite, configZip, ide): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
3545 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip""" |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3546 projectsFile = join(suite.mxDir, 'projects') |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3547 if configZip.isOlderThan(projectsFile): |
13243
68529068f08e
Update eclipse config when files in eclipse-settings have changed
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12689
diff
changeset
|
3548 return False |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
3549 # Assume that any mx change might imply changes to the generated IDE files |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3550 if configZip.isOlderThan(__file__): |
13243
68529068f08e
Update eclipse config when files in eclipse-settings have changed
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12689
diff
changeset
|
3551 return False |
13266
78ed696884b3
fixed regression in pylint command (exit code must be non-zero if at least one warning/error was found)
Doug Simon <doug.simon@oracle.com>
parents:
13247
diff
changeset
|
3552 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3553 if ide == 'eclipse': |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3554 eclipseSettingsDir = join(suite.mxDir, 'eclipse-settings') |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3555 if exists(eclipseSettingsDir): |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3556 for name in os.listdir(eclipseSettingsDir): |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3557 path = join(eclipseSettingsDir, name) |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3558 if configZip.isOlderThan(path): |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3559 return False |
13266
78ed696884b3
fixed regression in pylint command (exit code must be non-zero if at least one warning/error was found)
Doug Simon <doug.simon@oracle.com>
parents:
13247
diff
changeset
|
3560 return True |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3561 |
16455
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3562 def _eclipseinit_project(p, files=None, libFiles=None): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3563 assert java(p.javaCompliance) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3564 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3565 if not exists(p.dir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3566 os.makedirs(p.dir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3567 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3568 out = XMLDoc() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3569 out.open('classpath') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3570 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3571 for src in p.srcDirs: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3572 srcDir = join(p.dir, src) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3573 if not exists(srcDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3574 os.mkdir(srcDir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3575 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3576 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3577 if len(p.annotation_processors()) > 0: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3578 genDir = p.source_gen_dir() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3579 if not exists(genDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3580 os.mkdir(genDir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3581 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3582 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3583 files.append(genDir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3584 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3585 # Every Java program depends on a JRE |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3586 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3587 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3588 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3589 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3590 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3591 containerDeps = set() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3592 libraryDeps = set() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3593 projectDeps = set() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3594 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3595 for dep in p.all_deps([], True): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3596 if dep == p: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3597 continue |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3598 if dep.isLibrary(): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3599 if hasattr(dep, 'eclipse.container'): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3600 container = getattr(dep, 'eclipse.container') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3601 containerDeps.add(container) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3602 libraryDeps -= set(dep.all_deps([], True)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3603 else: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3604 libraryDeps.add(dep) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3605 elif dep.isProject(): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3606 projectDeps.add(dep) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3607 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3608 for dep in containerDeps: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3609 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : dep}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3610 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3611 for dep in libraryDeps: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3612 path = dep.path |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3613 dep.get_path(resolve=True) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3614 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3615 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3616 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3617 # safest to simply use absolute paths. |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3618 path = _make_absolute(path, p.suite.dir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3619 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3620 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path} |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3621 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3622 sourcePath = dep.get_source_path(resolve=True) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3623 if sourcePath is not None: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3624 attributes['sourcepath'] = sourcePath |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3625 out.element('classpathentry', attributes) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3626 if libFiles: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3627 libFiles.append(path) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3628 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3629 for dep in projectDeps: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3630 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3631 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3632 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3633 out.close('classpath') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3634 classpathFile = join(p.dir, '.classpath') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3635 update_file(classpathFile, out.xml(indent='\t', newl='\n')) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3636 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3637 files.append(classpathFile) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3638 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3639 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3640 if exists(csConfig): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3641 out = XMLDoc() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3642 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3643 dotCheckstyle = join(p.dir, ".checkstyle") |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3644 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3645 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3646 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3647 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3648 out.close('local-check-config') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3649 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3650 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3651 out.close('fileset') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3652 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3653 out.element('filter-data', {'value' : 'java'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3654 out.close('filter') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3655 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3656 exclude = join(p.dir, '.checkstyle.exclude') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3657 if exists(exclude): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3658 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3659 with open(exclude) as f: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3660 for line in f: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3661 if not line.startswith('#'): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3662 line = line.strip() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3663 exclDir = join(p.dir, line) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3664 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3665 out.element('filter-data', {'value' : line}) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3666 out.close('filter') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3667 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3668 out.close('fileset-config') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3669 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3670 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3671 files.append(dotCheckstyle) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3672 else: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3673 # clean up existing .checkstyle file |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3674 dotCheckstyle = join(p.dir, ".checkstyle") |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3675 if exists(dotCheckstyle): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3676 os.unlink(dotCheckstyle) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3677 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3678 out = XMLDoc() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3679 out.open('projectDescription') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3680 out.element('name', data=p.name) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3681 out.element('comment', data='') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3682 out.element('projects', data='') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3683 out.open('buildSpec') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3684 out.open('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3685 out.element('name', data='org.eclipse.jdt.core.javabuilder') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3686 out.element('arguments', data='') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3687 out.close('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3688 if exists(csConfig): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3689 out.open('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3690 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3691 out.element('arguments', data='') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3692 out.close('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3693 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3694 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3695 out.open('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3696 out.element('name', data=buildCommand) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3697 out.element('arguments', data='') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3698 out.close('buildCommand') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3699 |
16849
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3700 if p.definedAnnotationProcessorsDist: |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3701 # Create a launcher that will (re)build the annotation processor |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3702 # jar any time one of its sources is modified. |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3703 dist = p.definedAnnotationProcessorsDist |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3704 |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3705 distProjects = [d for d in dist.sorted_deps(transitive=True) if d.isProject()] |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3706 relevantResources = [] |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3707 for p in distProjects: |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3708 for srcDir in p.source_dirs(): |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3709 relevantResources.append(join(p.name, os.path.relpath(srcDir, p.dir))) |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3710 relevantResources.append(join(p.name, os.path.relpath(p.output_dir(), p.dir))) |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3711 |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3712 # The path should always be p.name/dir independent of where the workspace actually is. |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3713 # So we use the parent folder of the project, whatever that is, to generate such a relative path. |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3714 logicalWorkspaceRoot = os.path.dirname(p.dir) |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3715 refreshFile = os.path.relpath(p.definedAnnotationProcessorsDist.path, logicalWorkspaceRoot) |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3716 _genEclipseBuilder(out, p, 'CreateAnnotationProcessorJar', 'archive @' + dist.name, refresh=True, refreshFile=refreshFile, relevantResources=relevantResources, async=True, xmlIndent='', xmlStandalone='no') |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3717 |
16455
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3718 out.close('buildSpec') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3719 out.open('natures') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3720 out.element('nature', data='org.eclipse.jdt.core.javanature') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3721 if exists(csConfig): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3722 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3723 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3724 out.element('nature', data='org.eclipse.pde.PluginNature') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3725 out.close('natures') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3726 out.close('projectDescription') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3727 projectFile = join(p.dir, '.project') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3728 update_file(projectFile, out.xml(indent='\t', newl='\n')) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3729 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3730 files.append(projectFile) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3731 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3732 settingsDir = join(p.dir, ".settings") |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3733 if not exists(settingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3734 os.mkdir(settingsDir) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3735 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3736 # collect the defaults from mxtool |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3737 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3738 esdict = {} |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3739 if exists(defaultEclipseSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3740 for name in os.listdir(defaultEclipseSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3741 if isfile(join(defaultEclipseSettingsDir, name)): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3742 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3743 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3744 # check for suite overrides |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3745 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3746 if exists(eclipseSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3747 for name in os.listdir(eclipseSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3748 if isfile(join(eclipseSettingsDir, name)): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3749 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3750 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3751 # check for project overrides |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3752 projectSettingsDir = join(p.dir, 'eclipse-settings') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3753 if exists(projectSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3754 for name in os.listdir(projectSettingsDir): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3755 if isfile(join(projectSettingsDir, name)): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3756 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3757 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3758 # copy a possibly modified file to the project's .settings directory |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3759 for name, path in esdict.iteritems(): |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3760 # ignore this file altogether if this project has no annotation processors |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3761 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3762 continue |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3763 |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3764 with open(path) as f: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3765 content = f.read() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3766 content = content.replace('${javaCompliance}', str(p.javaCompliance)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3767 if len(p.annotation_processors()) > 0: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3768 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3769 update_file(join(settingsDir, name), content) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3770 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3771 files.append(join(settingsDir, name)) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3772 |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
3773 processorPath = p.annotation_processors_path() |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
3774 if processorPath: |
16455
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3775 out = XMLDoc() |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3776 out.open('factorypath') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3777 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
16839
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
3778 for e in processorPath.split(os.pathsep): |
7eca83fd5419
generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16725
diff
changeset
|
3779 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : e, 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
16455
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3780 out.close('factorypath') |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3781 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3782 if files: |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3783 files.append(join(p.dir, '.factorypath')) |
59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents:
16417
diff
changeset
|
3784 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3785 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3786 configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
3787 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3788 if refreshOnly and not configZip.exists(): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3789 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3790 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3791 if _check_ide_timestamp(suite, configZip, 'eclipse'): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3792 logv('[Eclipse configurations are up to date - skipping]') |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3793 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3794 |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3795 files = [] |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
3796 libFiles = [] |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3797 if buildProcessorJars: |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3798 files += _processorjars_suite(suite) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3799 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3800 for p in suite.projects: |
5071
9d055af068a8
Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents:
5032
diff
changeset
|
3801 if p.native: |
9d055af068a8
Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents:
5032
diff
changeset
|
3802 continue |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3803 _eclipseinit_project(p, files, libFiles) |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3804 |
13727
10e6f192631f
added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
13682
diff
changeset
|
3805 _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=sorted_deps(projectNames=None, includeLibs=True)) |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3806 files.append(launchFile) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3807 |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3808 # Create an Eclipse project for each distribution that will create/update the archive |
16667
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
3809 # for the distribution whenever any (transitively) dependent project of the |
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
3810 # distribution is updated. |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3811 for dist in suite.dists: |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
3812 projectDir = dist.get_ide_project_dir() |
16849
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3813 if not projectDir: |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
3814 continue |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3815 if not exists(projectDir): |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3816 os.makedirs(projectDir) |
16667
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
3817 distProjects = [d for d in dist.sorted_deps(transitive=True) if d.isProject()] |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3818 relevantResources = [] |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3819 for p in distProjects: |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3820 for srcDir in p.source_dirs(): |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3821 relevantResources.append(join(p.name, os.path.relpath(srcDir, p.dir))) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3822 relevantResources.append(join(p.name, os.path.relpath(p.output_dir(), p.dir))) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3823 out = XMLDoc() |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3824 out.open('projectDescription') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3825 out.element('name', data=dist.name) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3826 out.element('comment', data='Updates ' + dist.path + ' if a project dependency of ' + dist.name + ' is updated') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3827 out.open('projects') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3828 for p in distProjects: |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3829 out.element('project', data=p.name) |
16623
addc0564e5b5
split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents:
16599
diff
changeset
|
3830 for d in dist.distDependencies: |
addc0564e5b5
split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents:
16599
diff
changeset
|
3831 out.element('project', data=d) |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3832 out.close('projects') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3833 out.open('buildSpec') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3834 dist.dir = projectDir |
16667
1d4313c3ab38
mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents:
16629
diff
changeset
|
3835 dist.javaCompliance = max([p.javaCompliance for p in distProjects]) |
15899
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3836 _genEclipseBuilder(out, dist, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, relevantResources=relevantResources, logToFile=True, refresh=False, async=True) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3837 out.close('buildSpec') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3838 out.open('natures') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3839 out.element('nature', data='org.eclipse.jdt.core.javanature') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3840 out.close('natures') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3841 out.close('projectDescription') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3842 projectFile = join(projectDir, '.project') |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3843 update_file(projectFile, out.xml(indent='\t', newl='\n')) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3844 files.append(projectFile) |
e065b9746246
mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents:
15898
diff
changeset
|
3845 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3846 _zip_files(files, suite.dir, configZip.path) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3847 _zip_files(libFiles, suite.dir, configLibsZip) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
3848 |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3849 def _zip_files(files, baseDir, zipPath): |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3850 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(zipPath), dir=baseDir) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3851 try: |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3852 zf = zipfile.ZipFile(tmp, 'w') |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3853 for f in sorted(set(files)): |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3854 relpath = os.path.relpath(f, baseDir) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3855 arcname = relpath.replace(os.sep, '/') |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3856 zf.write(f, arcname) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3857 zf.close() |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3858 os.close(fd) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3859 # Atomic on Unix |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3860 shutil.move(tmp, zipPath) |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
3861 # Correct the permissions on the temporary file which is created with restrictive permissions |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
3862 os.chmod(zipPath, 0o666 & ~currentUmask) |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3863 finally: |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3864 if exists(tmp): |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
3865 os.remove(tmp) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3866 |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3867 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, refreshFile=None, relevantResources=None, async=False, logToConsole=False, logToFile=False, appendToLogFile=True, xmlIndent='\t', xmlStandalone=None): |
12514
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3868 externalToolDir = join(p.dir, '.externalToolBuilders') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3869 launchOut = XMLDoc() |
8181
989e0582a30f
enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents:
8180
diff
changeset
|
3870 consoleOn = 'true' if logToConsole else 'false' |
7299
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3871 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3872 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn}) |
8174
67d654d9ee9a
pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents:
8138
diff
changeset
|
3873 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) |
14763 | 3874 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java(p.javaCompliance).jdk}) |
14785
66ac13a2c7a1
pass EXTRA_JAVA_HOMES to eclipse builders
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14781
diff
changeset
|
3875 launchOut.element('mapEntry', {'key' : 'EXTRA_JAVA_HOMES', 'value' : _opts.extra_java_homes}) |
8174
67d654d9ee9a
pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents:
8138
diff
changeset
|
3876 launchOut.close('mapAttribute') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3877 |
7681
f81be78f15a5
Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents:
7533
diff
changeset
|
3878 if refresh: |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3879 if refreshFile is None: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3880 refreshScope = '${project}' |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3881 else: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3882 refreshScope = '${working_set:<?xml version="1.0" encoding="UTF-8"?><resources><item path="' + refreshFile + '" type="1"/></resources>}' |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3883 |
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3884 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_RECURSIVE', 'value': 'false'}) |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3885 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': refreshScope}) |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3886 |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3887 if relevantResources is not None: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3888 resources = '${working_set:<?xml version="1.0" encoding="UTF-8"?><resources>' |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3889 for relevantResource in relevantResources: |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3890 resources += '<item path="' + relevantResource + '" type="2" />' |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3891 resources += '</resources>}' |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3892 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE', 'value': resources}) |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3893 |
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3894 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3895 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn}) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3896 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'}) |
12514
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3897 if logToFile: |
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3898 logFile = join(externalToolDir, name + '.log') |
12524
2583afcd26ee
fixed bug in creation of CreateGRAALDist.launch files
Doug Simon <doug.simon@oracle.com>
parents:
12522
diff
changeset
|
3899 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE', 'value': logFile}) |
12514
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3900 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_APPEND_TO_FILE', 'value': 'true' if appendToLogFile else 'false'}) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3901 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3902 # expect to find the OS command to invoke mx in the same directory |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3903 baseDir = dirname(os.path.abspath(__file__)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3904 |
7299
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3905 cmd = 'mx.sh' |
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3906 if get_os() == 'windows': |
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3907 cmd = 'mx.cmd' |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3908 cmdPath = join(baseDir, cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3909 if not os.path.exists(cmdPath): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3910 # backwards compatibility for when the commands lived in parent of mxtool |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3911 cmdPath = join(dirname(baseDir), cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3912 if not os.path.exists(cmdPath): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3913 abort('cannot locate ' + cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3914 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3915 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': cmdPath}) |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3916 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'full,incremental,auto,'}) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3917 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand}) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3918 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED', 'value': 'true'}) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3919 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir}) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3920 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3921 |
7299
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3922 launchOut.close('launchConfiguration') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3923 |
7299
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3924 if not exists(externalToolDir): |
57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents:
7293
diff
changeset
|
3925 os.makedirs(externalToolDir) |
12514
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3926 update_file(join(externalToolDir, name + '.launch'), launchOut.xml(indent=xmlIndent, standalone=xmlStandalone, newl='\n')) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3927 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3928 dotProjectDoc.open('buildCommand') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3929 dotProjectDoc.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3930 dotProjectDoc.element('triggers', data='auto,full,incremental,') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3931 dotProjectDoc.open('arguments') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3932 dotProjectDoc.open('dictionary') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3933 dotProjectDoc.element('key', data='LaunchConfigHandle') |
12514
8c64f10f86b7
append output of mx command to (re)build graal.jar to a per-project log file
Doug Simon <doug.simon@oracle.com>
parents:
12513
diff
changeset
|
3934 dotProjectDoc.element('value', data='<project>/.externalToolBuilders/' + name + '.launch') |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3935 dotProjectDoc.close('dictionary') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3936 dotProjectDoc.open('dictionary') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3937 dotProjectDoc.element('key', data='incclean') |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3938 dotProjectDoc.element('value', data='true') |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3939 dotProjectDoc.close('dictionary') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3940 dotProjectDoc.close('arguments') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3941 dotProjectDoc.close('buildCommand') |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3942 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3943 def generate_eclipse_workingsets(): |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3944 """ |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3945 Populate the workspace's working set configuration with working sets generated from project data for the primary suite |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3946 If the workspace already contains working set definitions, the existing ones will be retained and extended. |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3947 In case mx/env does not contain a WORKSPACE definition pointing to the workspace root directory, a parent search from the primary suite directory is performed. |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3948 If no workspace root directory can be identified, the primary suite directory is used and the user has to place the workingsets.xml file by hand. |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3949 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3950 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3951 # identify the location where to look for workingsets.xml |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3952 wsfilename = 'workingsets.xml' |
11597
723796685546
more verbose output for eclipseinit if it cannot place workingsets.xml in Eclipse metadata location
Michael Haupt <michael.haupt@oracle.com>
parents:
11514
diff
changeset
|
3953 wsloc = '.metadata/.plugins/org.eclipse.ui.workbench' |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3954 if os.environ.has_key('WORKSPACE'): |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3955 expected_wsroot = os.environ['WORKSPACE'] |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3956 else: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
3957 expected_wsroot = _primary_suite.dir |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3958 |
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3959 wsroot = _find_eclipse_wsroot(expected_wsroot) |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3960 if wsroot is None: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3961 # failed to find it |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3962 wsroot = expected_wsroot |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3963 |
11597
723796685546
more verbose output for eclipseinit if it cannot place workingsets.xml in Eclipse metadata location
Michael Haupt <michael.haupt@oracle.com>
parents:
11514
diff
changeset
|
3964 wsdir = join(wsroot, wsloc) |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3965 if not exists(wsdir): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3966 wsdir = wsroot |
13480
6215ff792647
put warning about missing Eclipse metadata directory behind -v option
Doug Simon <doug.simon@oracle.com>
parents:
13475
diff
changeset
|
3967 logv('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.') |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3968 wspath = join(wsdir, wsfilename) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3969 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3970 # gather working set info from project data |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3971 workingSets = dict() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3972 for p in projects(): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3973 if p.workingSets is None: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3974 continue |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3975 for w in p.workingSets.split(","): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3976 if not workingSets.has_key(w): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3977 workingSets[w] = [p.name] |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3978 else: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3979 workingSets[w].append(p.name) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3980 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3981 if exists(wspath): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3982 wsdoc = _copy_workingset_xml(wspath, workingSets) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3983 else: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3984 wsdoc = _make_workingset_xml(workingSets) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3985 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3986 update_file(wspath, wsdoc.xml(newl='\n')) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3987 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3988 def _find_eclipse_wsroot(wsdir): |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3989 md = join(wsdir, '.metadata') |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3990 if exists(md): |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3991 return wsdir |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3992 split = os.path.split(wsdir) |
12042
fbe1ee508936
added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents:
11807
diff
changeset
|
3993 if split[0] == wsdir: # root directory |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3994 return None |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3995 else: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3996 return _find_eclipse_wsroot(split[0]) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3997 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3998 def _make_workingset_xml(workingSets): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3999 wsdoc = XMLDoc() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4000 wsdoc.open('workingSetManager') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4001 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4002 for w in sorted(workingSets.keys()): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4003 _workingset_open(wsdoc, w) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4004 for p in workingSets[w]: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4005 _workingset_element(wsdoc, p) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4006 wsdoc.close('workingSet') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4007 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4008 wsdoc.close('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4009 return wsdoc |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4010 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4011 def _copy_workingset_xml(wspath, workingSets): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4012 target = XMLDoc() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4013 target.open('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4014 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4015 parser = xml.parsers.expat.ParserCreate() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4016 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4017 class ParserState(object): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4018 def __init__(self): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4019 self.current_ws_name = 'none yet' |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4020 self.current_ws = None |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4021 self.seen_ws = list() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4022 self.seen_projects = list() |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4023 self.aggregate_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4024 self.nested_ws = False |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4025 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4026 ps = ParserState() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4027 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4028 # parsing logic |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4029 def _ws_start(name, attributes): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4030 if name == 'workingSet': |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4031 if attributes.has_key('name'): |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4032 ps.current_ws_name = attributes['name'] |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4033 if attributes.has_key('aggregate') and attributes['aggregate'] == 'true': |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4034 ps.aggregate_ws = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4035 ps.current_ws = None |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4036 elif workingSets.has_key(ps.current_ws_name): |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4037 ps.current_ws = workingSets[ps.current_ws_name] |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4038 ps.seen_ws.append(ps.current_ws_name) |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4039 ps.seen_projects = list() |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4040 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4041 ps.current_ws = None |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4042 target.open(name, attributes) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4043 parser.StartElementHandler = _ws_item |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4044 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4045 def _ws_end(name): |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4046 closeAndResetHandler = False |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4047 if name == 'workingSet': |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4048 if ps.aggregate_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4049 if ps.nested_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4050 ps.nested_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4051 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4052 ps.aggregate_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4053 closeAndResetHandler = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4054 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4055 if not ps.current_ws is None: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4056 for p in ps.current_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4057 if not p in ps.seen_projects: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4058 _workingset_element(target, p) |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4059 closeAndResetHandler = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4060 if closeAndResetHandler: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4061 target.close('workingSet') |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4062 parser.StartElementHandler = _ws_start |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4063 elif name == 'workingSetManager': |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4064 # process all working sets that are new to the file |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4065 for w in sorted(workingSets.keys()): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4066 if not w in ps.seen_ws: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4067 _workingset_open(target, w) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4068 for p in workingSets[w]: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4069 _workingset_element(target, p) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4070 target.close('workingSet') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4071 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4072 def _ws_item(name, attributes): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4073 if name == 'item': |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4074 if ps.current_ws is None: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4075 target.element(name, attributes) |
13982
b167b1838029
mx eclipseinit: take care of working sets that were edited by hand
Michael Haupt <michael.haupt@oracle.com>
parents:
13968
diff
changeset
|
4076 elif not attributes.has_key('elementID') and attributes.has_key('factoryID') and attributes.has_key('path') and attributes.has_key('type'): |
b167b1838029
mx eclipseinit: take care of working sets that were edited by hand
Michael Haupt <michael.haupt@oracle.com>
parents:
13968
diff
changeset
|
4077 target.element(name, attributes) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
4078 p_name = attributes['path'][1:] # strip off the leading '/' |
13982
b167b1838029
mx eclipseinit: take care of working sets that were edited by hand
Michael Haupt <michael.haupt@oracle.com>
parents:
13968
diff
changeset
|
4079 ps.seen_projects.append(p_name) |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4080 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4081 p_name = attributes['elementID'][1:] # strip off the leading '=' |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4082 _workingset_element(target, p_name) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4083 ps.seen_projects.append(p_name) |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4084 elif name == 'workingSet': |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4085 ps.nested_ws = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
4086 target.element(name, attributes) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4087 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4088 # process document |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4089 parser.StartElementHandler = _ws_start |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4090 parser.EndElementHandler = _ws_end |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4091 with open(wspath, 'r') as wsfile: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4092 parser.ParseFile(wsfile) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4093 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4094 target.close('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4095 return target |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4096 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4097 def _workingset_open(wsdoc, ws): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4098 wsdoc.open('workingSet', {'editPageID': 'org.eclipse.jdt.ui.JavaWorkingSetPage', 'factoryID': 'org.eclipse.ui.internal.WorkingSetFactory', 'id': 'wsid_' + ws, 'label': ws, 'name': ws}) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4099 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4100 def _workingset_element(wsdoc, p): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
4101 wsdoc.element('item', {'elementID': '=' + p, 'factoryID': 'org.eclipse.jdt.ui.PersistableJavaElementFactory'}) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4102 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4103 def netbeansinit(args, refreshOnly=False, buildProcessorJars=True): |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4104 """(re)generate NetBeans project configurations""" |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4105 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4106 for suite in suites(True): |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4107 _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4108 |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4109 def _netbeansinit_suite(args, suite, refreshOnly=False, buildProcessorJars=True): |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4110 configZip = TimeStampFile(join(suite.mxDir, 'netbeans-config.zip')) |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
4111 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4112 if refreshOnly and not configZip.exists(): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4113 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4114 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
4115 if _check_ide_timestamp(suite, configZip, 'netbeans'): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4116 logv('[NetBeans configurations are up to date - skipping]') |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4117 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4118 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4119 updated = False |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4120 files = [] |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
4121 libFiles = [] |
14763 | 4122 jdks = set() |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4123 for p in suite.projects: |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4124 if p.native: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4125 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4126 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4127 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
4128 continue |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
4129 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4130 if not exists(join(p.dir, 'nbproject')): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4131 os.makedirs(join(p.dir, 'nbproject')) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4132 |
14763 | 4133 jdk = java(p.javaCompliance) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4134 assert jdk |
14764 | 4135 |
14763 | 4136 jdks.add(jdk) |
4137 | |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
4138 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4139 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4140 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4141 out.element('import', {'file' : 'nbproject/build-impl.xml'}) |
8189
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4142 out.open('target', {'name' : '-post-compile'}) |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
4143 out.open('exec', {'executable' : sys.executable}) |
14763 | 4144 out.element('env', {'key' : 'JAVA_HOME', 'value' : jdk.jdk}) |
8189
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4145 out.element('arg', {'value' : os.path.abspath(__file__)}) |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4146 out.element('arg', {'value' : 'archive'}) |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4147 out.element('arg', {'value' : '@GRAAL'}) |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4148 out.close('exec') |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
4149 out.close('target') |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4150 out.close('project') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4151 updated = update_file(join(p.dir, 'build.xml'), out.xml(indent='\t', newl='\n')) or updated |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4152 files.append(join(p.dir, 'build.xml')) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4153 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
4154 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4155 out.open('project', {'xmlns' : 'http://www.netbeans.org/ns/project/1'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4156 out.element('type', data='org.netbeans.modules.java.j2seproject') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4157 out.open('configuration') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4158 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4159 out.element('name', data=p.name) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4160 out.element('explicit-platform', {'explicit-source-supported' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4161 out.open('source-roots') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4162 out.element('root', {'id' : 'src.dir'}) |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
4163 if len(p.annotation_processors()) > 0: |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4164 out.element('root', {'id' : 'src.ap-source-output.dir', 'name' : 'Generated Packages'}) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4165 out.close('source-roots') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4166 out.open('test-roots') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4167 out.close('test-roots') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4168 out.close('data') |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4169 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4170 firstDep = True |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4171 for dep in p.all_deps([], includeLibs=False, includeAnnotationProcessors=True): |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4172 if dep == p: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4173 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4174 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4175 if dep.isProject(): |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4176 n = dep.name.replace('.', '_') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4177 if firstDep: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4178 out.open('references', {'xmlns' : 'http://www.netbeans.org/ns/ant-project-references/1'}) |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4179 firstDep = False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4180 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4181 out.open('reference') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4182 out.element('foreign-project', data=n) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4183 out.element('artifact-type', data='jar') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4184 out.element('script', data='build.xml') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4185 out.element('target', data='jar') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4186 out.element('clean-target', data='clean') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4187 out.element('id', data='jar') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4188 out.close('reference') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4189 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4190 if not firstDep: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4191 out.close('references') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4192 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4193 out.close('configuration') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4194 out.close('project') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4195 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4196 files.append(join(p.dir, 'nbproject', 'project.xml')) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4197 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4198 out = StringIO.StringIO() |
14763 | 4199 jdkPlatform = 'JDK_' + str(jdk.version) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4200 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4201 annotationProcessorEnabled = "false" |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4202 annotationProcessorReferences = "" |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4203 annotationProcessorSrcFolder = "" |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
4204 if len(p.annotation_processors()) > 0: |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4205 annotationProcessorEnabled = "true" |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4206 genSrcDir = p.source_gen_dir() |
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4207 if not exists(genSrcDir): |
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4208 os.makedirs(genSrcDir) |
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4209 annotationProcessorSrcFolder = "src.ap-source-output.dir=" + genSrcDir |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4210 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4211 content = """ |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4212 annotation.processing.enabled=""" + annotationProcessorEnabled + """ |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4213 annotation.processing.enabled.in.editor=""" + annotationProcessorEnabled + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4214 annotation.processing.processors.list= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4215 annotation.processing.run.all.processors=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4216 application.title=""" + p.name + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4217 application.vendor=mx |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4218 build.classes.dir=${build.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4219 build.classes.excludes=**/*.java,**/*.form |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4220 # This directory is removed when the project is cleaned: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4221 build.dir=bin |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4222 build.generated.sources.dir=${build.dir}/generated-sources |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4223 # Only compile against the classpath explicitly listed here: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4224 build.sysclasspath=ignore |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4225 build.test.classes.dir=${build.dir}/test/classes |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4226 build.test.results.dir=${build.dir}/test/results |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4227 # Uncomment to specify the preferred debugger connection transport: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4228 #debug.transport=dt_socket |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4229 debug.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4230 ${run.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4231 debug.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4232 ${run.test.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4233 # This directory is removed when the project is cleaned: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4234 dist.dir=dist |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4235 dist.jar=${dist.dir}/""" + p.name + """.jar |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4236 dist.javadoc.dir=${dist.dir}/javadoc |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4237 endorsed.classpath= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4238 excludes= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4239 includes=** |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4240 jar.compress=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4241 # Space-separated list of extra javac options |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4242 javac.compilerargs=-XDignore.symbol.file |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4243 javac.deprecation=false |
16706
ff2b25002a58
set javac.source and javac.target in NetBeans configurations based on per-project Java compliance
Doug Simon <doug.simon@oracle.com>
parents:
16682
diff
changeset
|
4244 javac.source=""" + str(p.javaCompliance) + """ |
ff2b25002a58
set javac.source and javac.target in NetBeans configurations based on per-project Java compliance
Doug Simon <doug.simon@oracle.com>
parents:
16682
diff
changeset
|
4245 javac.target=""" + str(p.javaCompliance) + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4246 javac.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4247 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4248 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4249 javadoc.additionalparam= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4250 javadoc.author=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4251 javadoc.encoding=${source.encoding} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4252 javadoc.noindex=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4253 javadoc.nonavbar=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4254 javadoc.notree=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4255 javadoc.private=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4256 javadoc.splitindex=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4257 javadoc.use=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4258 javadoc.version=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4259 javadoc.windowtitle= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4260 main.class= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4261 manifest.file=manifest.mf |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4262 meta.inf.dir=${src.dir}/META-INF |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4263 mkdist.disabled=false |
14763 | 4264 platforms.""" + jdkPlatform + """.home=""" + jdk.jdk + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4265 platform.active=""" + jdkPlatform + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4266 run.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4267 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4268 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4269 # Space-separated list of JVM arguments used when running the project |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4270 # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4271 # or test-sys-prop.name=value to set system properties for unit tests): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4272 run.jvmargs= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4273 run.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4274 ${javac.test.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4275 ${build.test.classes.dir} |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4276 test.src.dir=./test |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4277 """ + annotationProcessorSrcFolder + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4278 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4279 print >> out, content |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4280 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4281 mainSrc = True |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4282 for src in p.srcDirs: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4283 srcDir = join(p.dir, src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4284 if not exists(srcDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4285 os.mkdir(srcDir) |
17092
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4286 ref = 'file.reference.' + p.name + '-' + src |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4287 print >> out, ref + '=' + src |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4288 if mainSrc: |
17092
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4289 print >> out, 'src.dir=${' + ref + '}' |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4290 mainSrc = False |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4291 else: |
17092
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4292 print >> out, 'src.' + src + '.dir=${' + ref + '}' |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4293 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4294 javacClasspath = [] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4295 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4296 deps = p.all_deps([], True) |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4297 annotationProcessorOnlyDeps = [] |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
4298 if len(p.annotation_processors()) > 0: |
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
4299 for ap in p.annotation_processors(): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
4300 apDep = dependency(ap) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
4301 if not apDep in deps: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
4302 deps.append(apDep) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
4303 annotationProcessorOnlyDeps.append(apDep) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4304 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4305 annotationProcessorReferences = [] |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4306 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4307 for dep in deps: |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4308 if dep == p: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4309 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4310 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4311 if dep.isLibrary(): |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4312 path = dep.get_path(resolve=True) |
17092
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4313 if path: |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4314 if os.sep == '\\': |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4315 path = path.replace('\\', '\\\\') |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4316 ref = 'file.reference.' + dep.name + '-bin' |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4317 print >> out, ref + '=' + path |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4318 libFiles.append(path) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4319 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4320 elif dep.isProject(): |
17092
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4321 n = dep.name.replace('.', '_') |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4322 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4323 ref = 'reference.' + n + '.jar' |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4324 print >> out, 'project.' + n + '=' + relDepPath |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4325 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar' |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4326 |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4327 if not dep in annotationProcessorOnlyDeps: |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4328 javacClasspath.append('${' + ref + '}') |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4329 else: |
2f64a6c771d5
Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents:
17076
diff
changeset
|
4330 annotationProcessorReferences.append('${' + ref + '}') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4331 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
4332 print >> out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath) |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
4333 print >> out, 'javac.processorpath=' + (os.pathsep + '\\\n ').join(['${javac.classpath}'] + annotationProcessorReferences) |
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
4334 print >> out, 'javac.test.processorpath=' + (os.pathsep + '\\\n ').join(['${javac.test.classpath}'] + annotationProcessorReferences) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4335 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4336 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4337 out.close() |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4338 files.append(join(p.dir, 'nbproject', 'project.properties')) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4339 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4340 if updated: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4341 log('If using NetBeans:') |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4342 # http://stackoverflow.com/questions/24720665/cant-resolve-jdk-internal-package |
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4343 log(' 1. Edit etc/netbeans.conf in your NetBeans installation and modify netbeans_default_options variable to include "-J-DCachingArchiveProvider.disableCtSym=true"') |
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4344 log(' 2. Ensure that the following platform(s) are defined (Tools -> Java Platforms):') |
14763 | 4345 for jdk in jdks: |
4346 log(' JDK_' + str(jdk.version)) | |
17075
c24ea91c30ba
create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents:
17063
diff
changeset
|
4347 log(' 3. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4348 |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4349 _zip_files(files, suite.dir, configZip.path) |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
4350 _zip_files(libFiles, suite.dir, configLibsZip) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4351 |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4352 def intellijinit(args, refreshOnly=False): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4353 """(re)generate Intellij project configurations""" |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4354 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4355 for suite in suites(True): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4356 _intellij_suite(args, suite, refreshOnly) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4357 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4358 def _intellij_suite(args, suite, refreshOnly=False): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4359 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4360 libraries = set() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4361 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4362 ideaProjectDirectory = join(suite.dir, '.idea') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4363 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4364 if not exists(ideaProjectDirectory): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4365 os.mkdir(ideaProjectDirectory) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4366 nameFile = join(ideaProjectDirectory, '.name') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4367 update_file(nameFile, "Graal") |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4368 modulesXml = XMLDoc() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4369 modulesXml.open('project', attributes={'version': '4'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4370 modulesXml.open('component', attributes={'name': 'ProjectModuleManager'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4371 modulesXml.open('modules') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4372 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4373 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4374 def _intellij_exclude_if_exists(xml, p, name): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4375 path = join(p.dir, name) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4376 if exists(path): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4377 xml.element('excludeFolder', attributes={'url':'file://$MODULE_DIR$/' + name}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4378 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4379 annotationProcessorProfiles = {} |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4380 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4381 def _complianceToIntellijLanguageLevel(compliance): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4382 return 'JDK_1_' + str(compliance.value) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4383 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4384 # create the modules (1 module = 1 Intellij project) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4385 for p in suite.projects: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4386 if p.native: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4387 continue |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4388 |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4389 assert java(p.javaCompliance) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4390 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4391 if not exists(p.dir): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4392 os.makedirs(p.dir) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4393 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4394 annotationProcessorProfileKey = tuple(p.annotation_processors()) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4395 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4396 if not annotationProcessorProfileKey in annotationProcessorProfiles: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4397 annotationProcessorProfiles[annotationProcessorProfileKey] = [p] |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4398 else: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4399 annotationProcessorProfiles[annotationProcessorProfileKey].append(p) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4400 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4401 intellijLanguageLevel = _complianceToIntellijLanguageLevel(p.javaCompliance) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4402 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4403 moduleXml = XMLDoc() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4404 moduleXml.open('module', attributes={'type': 'JAVA_MODULE', 'version': '4'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4405 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4406 moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'LANGUAGE_LEVEL': intellijLanguageLevel, 'inherit-compiler-output': 'false'}) |
15122
11a591a99515
mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents:
15118
diff
changeset
|
4407 moduleXml.element('output', attributes={'url': 'file://$MODULE_DIR$/bin'}) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4408 moduleXml.element('exclude-output') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4409 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4410 moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4411 for src in p.srcDirs: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4412 srcDir = join(p.dir, src) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4413 if not exists(srcDir): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4414 os.mkdir(srcDir) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4415 moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + src, 'isTestSource': 'false'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4416 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4417 if len(p.annotation_processors()) > 0: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4418 genDir = p.source_gen_dir() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4419 if not exists(genDir): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4420 os.mkdir(genDir) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4421 moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + os.path.relpath(genDir, p.dir), 'isTestSource': 'false'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4422 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4423 for name in ['.externalToolBuilders', '.settings', 'nbproject']: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4424 _intellij_exclude_if_exists(moduleXml, p, name) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4425 moduleXml.close('content') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4426 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4427 moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': 'JavaSDK', 'jdkName': str(p.javaCompliance)}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4428 moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4429 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4430 deps = p.all_deps([], True, includeAnnotationProcessors=True) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4431 for dep in deps: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4432 if dep == p: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4433 continue |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4434 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4435 if dep.isLibrary(): |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4436 libraries.add(dep) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4437 moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'}) |
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4438 elif dep.isProject(): |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4439 moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': dep.name}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4440 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4441 moduleXml.close('component') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4442 moduleXml.close('module') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4443 moduleFile = join(p.dir, p.name + '.iml') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4444 update_file(moduleFile, moduleXml.xml(indent=' ', newl='\n')) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4445 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4446 moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(moduleFile, suite.dir) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4447 modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4448 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4449 modulesXml.close('modules') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4450 modulesXml.close('component') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4451 modulesXml.close('project') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4452 moduleXmlFile = join(ideaProjectDirectory, 'modules.xml') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4453 update_file(moduleXmlFile, modulesXml.xml(indent=' ', newl='\n')) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4454 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4455 # TODO What about cross-suite dependencies? |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4456 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4457 librariesDirectory = join(ideaProjectDirectory, 'libraries') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4458 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4459 if not exists(librariesDirectory): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4460 os.mkdir(librariesDirectory) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4461 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4462 # Setup the libraries that were used above |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4463 # TODO: setup all the libraries from the suite regardless of usage? |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4464 for library in libraries: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4465 libraryXml = XMLDoc() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4466 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4467 libraryXml.open('component', attributes={'name': 'libraryTable'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4468 libraryXml.open('library', attributes={'name': library.name}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4469 libraryXml.open('CLASSES') |
15134
f0fc09c0845e
Be sure to resolve and download librariesin mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15122
diff
changeset
|
4470 libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.get_path(True), suite.dir) + '!/'}) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4471 libraryXml.close('CLASSES') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4472 libraryXml.element('JAVADOC') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4473 if library.sourcePath: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4474 libraryXml.open('SOURCES') |
15134
f0fc09c0845e
Be sure to resolve and download librariesin mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15122
diff
changeset
|
4475 libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.get_source_path(True), suite.dir) + '!/'}) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4476 libraryXml.close('SOURCES') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4477 else: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4478 libraryXml.element('SOURCES') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4479 libraryXml.close('library') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4480 libraryXml.close('component') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4481 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4482 libraryFile = join(librariesDirectory, library.name + '.xml') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4483 update_file(libraryFile, libraryXml.xml(indent=' ', newl='\n')) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4484 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4485 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4486 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4487 # Set annotation processor profiles up, and link them to modules in compiler.xml |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4488 compilerXml = XMLDoc() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4489 compilerXml.open('project', attributes={'version': '4'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4490 compilerXml.open('component', attributes={'name': 'CompilerConfiguration'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4491 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4492 compilerXml.element('option', attributes={'name': "DEFAULT_COMPILER", 'value': 'Javac'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4493 compilerXml.element('resourceExtensions') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4494 compilerXml.open('wildcardResourcePatterns') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4495 compilerXml.element('entry', attributes={'name': '!?*.java'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4496 compilerXml.close('wildcardResourcePatterns') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4497 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4498 if annotationProcessorProfiles: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4499 compilerXml.open('annotationProcessing') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4500 for processors, modules in annotationProcessorProfiles.items(): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4501 compilerXml.open('profile', attributes={'default': 'false', 'name': '-'.join(processors), 'enabled': 'true'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4502 compilerXml.element('sourceOutputDir', attributes={'name': 'src_gen'}) # TODO use p.source_gen_dir() ? |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4503 compilerXml.element('outputRelativeToContentRoot', attributes={'value': 'true'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4504 compilerXml.open('processorPath', attributes={'useClasspath': 'false'}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4505 for apName in processors: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4506 pDep = dependency(apName) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4507 for entry in pDep.all_deps([], True): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4508 if entry.isLibrary(): |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4509 compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.path, suite.dir)}) |
15662
50fbda571d99
mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents:
15638
diff
changeset
|
4510 elif entry.isProject(): |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4511 assert entry.isProject() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4512 compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.output_dir(), suite.dir)}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4513 compilerXml.close('processorPath') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4514 for module in modules: |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4515 compilerXml.element('module', attributes={'name': module.name}) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4516 compilerXml.close('profile') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4517 compilerXml.close('annotationProcessing') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4518 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4519 compilerXml.close('component') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4520 compilerXml.close('project') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4521 compilerFile = join(ideaProjectDirectory, 'compiler.xml') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4522 update_file(compilerFile, compilerXml.xml(indent=' ', newl='\n')) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4523 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4524 # Wite misc.xml for global JDK config |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4525 miscXml = XMLDoc() |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4526 miscXml.open('project', attributes={'version': '4'}) |
15135
0672512feb81
mx intellijinit: fix typo in project's language level settings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15134
diff
changeset
|
4527 miscXml.element('component', attributes={'name': 'ProjectRootManager', 'version': '2', 'languageLevel': _complianceToIntellijLanguageLevel(java().javaCompliance), 'project-jdk-name': str(java().javaCompliance), 'project-jdk-type': 'JavaSDK'}) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4528 miscXml.close('project') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4529 miscFile = join(ideaProjectDirectory, 'misc.xml') |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4530 update_file(miscFile, miscXml.xml(indent=' ', newl='\n')) |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4531 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4532 |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4533 # TODO look into copyright settings |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4534 # TODO should add vcs.xml support |
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4535 |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4536 def ideclean(args): |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4537 """remove all Eclipse and NetBeans project configurations""" |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4538 def rm(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4539 if exists(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4540 os.remove(path) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4541 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4542 for s in suites(): |
13473
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4543 rm(join(s.mxDir, 'eclipse-config.zip')) |
69f3251332c9
modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents:
13471
diff
changeset
|
4544 rm(join(s.mxDir, 'netbeans-config.zip')) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4545 shutil.rmtree(join(s.dir, '.idea'), ignore_errors=True) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4546 |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4547 for p in projects(): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4548 if p.native: |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4549 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4550 |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4551 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True) |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4552 shutil.rmtree(join(p.dir, '.externalToolBuilders'), ignore_errors=True) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4553 shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4554 rm(join(p.dir, '.classpath')) |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
4555 rm(join(p.dir, '.checkstyle')) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4556 rm(join(p.dir, '.project')) |
10043
e063474076dd
clean up .factorypath files on "mx ideclean"
Lukas Stadler <lukas.stadler@jku.at>
parents:
9857
diff
changeset
|
4557 rm(join(p.dir, '.factorypath')) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4558 rm(join(p.dir, p.name + '.iml')) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
4559 rm(join(p.dir, 'build.xml')) |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4560 rm(join(p.dir, 'eclipse-build.xml')) |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4561 try: |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4562 rm(join(p.dir, p.name + '.jar')) |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4563 except: |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
6535
diff
changeset
|
4564 log("Error removing {0}".format(p.name + '.jar')) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4565 |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
4566 for d in _dists.itervalues(): |
16849
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
4567 if d.get_ide_project_dir(): |
0d987db807df
do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents:
16847
diff
changeset
|
4568 shutil.rmtree(d.get_ide_project_dir(), ignore_errors=True) |
16845
1fd7bb00a77f
clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents:
16839
diff
changeset
|
4569 |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4570 def ideinit(args, refreshOnly=False, buildProcessorJars=True): |
15378
dea98caac669
Fix help text for ideinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15376
diff
changeset
|
4571 """(re)generate Eclipse, NetBeans and Intellij project configurations""" |
16846
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4572 eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
e3dd75b3c290
revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents:
16845
diff
changeset
|
4573 netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
4574 intellijinit(args, refreshOnly=refreshOnly) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4575 if not refreshOnly: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4576 fsckprojects([]) |
7913
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4577 |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4578 def fsckprojects(args): |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4579 """find directories corresponding to deleted Java projects and delete them""" |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4580 for suite in suites(True): |
7913
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4581 projectDirs = [p.dir for p in suite.projects] |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4582 for dirpath, dirnames, files in os.walk(suite.dir): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4583 if dirpath == suite.dir: |
16269
f5437f2db322
mx fsckprojects: do not traverse lib subdirectory
Andreas Woess <andreas.woess@jku.at>
parents:
16262
diff
changeset
|
4584 # no point in traversing .hg or lib/ |
f5437f2db322
mx fsckprojects: do not traverse lib subdirectory
Andreas Woess <andreas.woess@jku.at>
parents:
16262
diff
changeset
|
4585 dirnames[:] = [d for d in dirnames if d not in ['.hg', 'lib']] |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4586 elif dirpath in projectDirs: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4587 # don't traverse subdirs of an existing project in this suite |
7913
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4588 dirnames[:] = [] |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4589 else: |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4590 projectConfigFiles = frozenset(['.classpath', 'nbproject']) |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4591 indicators = projectConfigFiles.intersection(files) |
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
4592 if len(indicators) != 0: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4593 if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4594 shutil.rmtree(dirpath) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4595 log('Deleted ' + dirpath) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4596 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4597 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True): |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4598 """generate javadoc for some/all Java projects""" |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4599 |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
4600 parser = ArgumentParser(prog='mx javadoc') if parser is None else parser |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4601 parser.add_argument('-d', '--base', action='store', help='base directory for output') |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4602 parser.add_argument('--unified', action='store_true', help='put javadoc in a single directory instead of one per project') |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4603 parser.add_argument('--force', action='store_true', help='(re)generate javadoc even if package-list file exists') |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4604 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)') |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4605 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4606 parser.add_argument('--argfile', action='store', help='name of file containing extra javadoc options') |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4607 parser.add_argument('--arg', action='append', dest='extra_args', help='extra Javadoc arguments (e.g. --arg @-use)', metavar='@<arg>', default=[]) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4608 parser.add_argument('-m', '--memory', action='store', help='-Xmx value to pass to underlying JVM') |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4609 parser.add_argument('--packages', action='store', help='comma separated packages to process (omit to process all packages)') |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4610 parser.add_argument('--exclude-packages', action='store', help='comma separated packages to exclude') |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4611 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4612 args = parser.parse_args(args) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4613 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4614 # build list of projects to be processed |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4615 if args.projects is not None: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4616 candidates = [project(name) for name in args.projects.split(',')] |
11756
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4617 else: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
4618 candidates = projects_opt_limit_to_suites() |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4619 |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
4620 # optionally restrict packages within a project |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4621 packages = [] |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4622 if args.packages is not None: |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4623 packages = [name for name in args.packages.split(',')] |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4624 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4625 exclude_packages = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4626 if args.exclude_packages is not None: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4627 exclude_packages = [name for name in args.exclude_packages.split(',')] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4628 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4629 def outDir(p): |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4630 if args.base is None: |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4631 return join(p.dir, docDir) |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4632 return join(args.base, p.name, docDir) |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4633 |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4634 def check_package_list(p): |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
4635 return not exists(join(outDir(p), 'package-list')) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4636 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4637 def assess_candidate(p, projects): |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4638 if p in projects: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4639 return False |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4640 if args.force or args.unified or check_package_list(p): |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4641 projects.append(p) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4642 return True |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4643 return False |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4644 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4645 projects = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4646 for p in candidates: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4647 if not p.native: |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
4648 if includeDeps: |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4649 deps = p.all_deps([], includeLibs=False, includeSelf=False) |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4650 for d in deps: |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4651 assess_candidate(d, projects) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4652 if not assess_candidate(p, projects): |
10568
070b4a3c56f3
disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents:
10530
diff
changeset
|
4653 logv('[package-list file exists - skipping {0}]'.format(p.name)) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4654 |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4655 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4656 def find_packages(sourceDirs, pkgs=None): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4657 if pkgs is None: |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4658 pkgs = set() |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4659 for sourceDir in sourceDirs: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4660 for root, _, files in os.walk(sourceDir): |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4661 if len([name for name in files if name.endswith('.java')]) != 0: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4662 pkg = root[len(sourceDir) + 1:].replace(os.sep, '.') |
5709
24347f3b605f
fixed javadoc command on Windows
Doug Simon <doug.simon@oracle.com>
parents:
5706
diff
changeset
|
4663 if len(packages) == 0 or pkg in packages: |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4664 if len(exclude_packages) == 0 or not pkg in exclude_packages: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4665 pkgs.add(pkg) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4666 return pkgs |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4667 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4668 extraArgs = [a.lstrip('@') for a in args.extra_args] |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4669 if args.argfile is not None: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4670 extraArgs += ['@' + args.argfile] |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4671 memory = '2g' |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4672 if args.memory is not None: |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4673 memory = args.memory |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4674 memory = '-J-Xmx' + memory |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4675 |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4676 if not args.unified: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4677 for p in projects: |
5710
8d31a849ca97
make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents:
5709
diff
changeset
|
4678 # The project must be built to ensure javadoc can find class files for all referenced classes |
8d31a849ca97
make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents:
5709
diff
changeset
|
4679 build(['--no-native', '--projects', p.name]) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4680 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4681 pkgs = find_packages(p.source_dirs(), set()) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4682 deps = p.all_deps([], includeLibs=False, includeSelf=False) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4683 links = ['-link', 'http://docs.oracle.com/javase/' + str(p.javaCompliance.value) + '/docs/api/'] |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4684 out = outDir(p) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4685 for d in deps: |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4686 depOut = outDir(d) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4687 links.append('-link') |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4688 links.append(os.path.relpath(depOut, out)) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4689 cp = classpath(p.name, includeSelf=True) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4690 sp = os.pathsep.join(p.source_dirs()) |
5706
6f2ccb483d96
added overview.html for each project and integrated it into the generated 'mx site' command
Doug Simon <doug.simon@oracle.com>
parents:
5701
diff
changeset
|
4691 overviewFile = join(p.dir, 'overview.html') |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4692 delOverviewFile = False |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4693 if not exists(overviewFile): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4694 with open(overviewFile, 'w') as fp: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4695 print >> fp, '<html><body>Documentation for the <code>' + p.name + '</code> project.</body></html>' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4696 delOverviewFile = True |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4697 nowarnAPI = [] |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4698 if not args.warnAPI: |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4699 nowarnAPI.append('-XDignore.symbol.file') |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4700 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4701 # windowTitle onloy applies to the standard doclet processor |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4702 windowTitle = [] |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4703 if stdDoclet: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4704 windowTitle = ['-windowtitle', p.name + ' javadoc'] |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4705 try: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4706 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) |
14916
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
4707 projectJava = java(p.javaCompliance) |
15419
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4708 |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4709 # Once https://bugs.openjdk.java.net/browse/JDK-8041628 is fixed, |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4710 # this should be reverted to: |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4711 # javadocExe = java().javadoc |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4712 javadocExe = projectJava.javadoc |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4713 |
f093fa76e872
made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents:
15408
diff
changeset
|
4714 run([javadocExe, memory, |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4715 '-XDignore.symbol.file', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4716 '-classpath', cp, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4717 '-quiet', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4718 '-d', out, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4719 '-overview', overviewFile, |
14916
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
4720 '-sourcepath', sp, |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
4721 '-source', str(projectJava.javaCompliance), |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
4722 '-bootclasspath', projectJava.bootclasspath(), |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
4723 '-extdirs', projectJava.extdirs()] + |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4724 ([] if projectJava.javaCompliance < JavaCompliance('1.8') else ['-Xdoclint:none']) + |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4725 links + |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4726 extraArgs + |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4727 nowarnAPI + |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4728 windowTitle + |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4729 list(pkgs)) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4730 log('Generated {2} for {0} in {1}'.format(p.name, out, docDir)) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4731 finally: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4732 if delOverviewFile: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4733 os.remove(overviewFile) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4734 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4735 else: |
5710
8d31a849ca97
make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents:
5709
diff
changeset
|
4736 # The projects must be built to ensure javadoc can find class files for all referenced classes |
8d31a849ca97
make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents:
5709
diff
changeset
|
4737 build(['--no-native']) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4738 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4739 pkgs = set() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4740 sp = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4741 names = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4742 for p in projects: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4743 find_packages(p.source_dirs(), pkgs) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4744 sp += p.source_dirs() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4745 names.append(p.name) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4746 |
14763 | 4747 links = ['-link', 'http://docs.oracle.com/javase/' + str(java().javaCompliance.value) + '/docs/api/'] |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4748 out = join(_primary_suite.dir, docDir) |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4749 if args.base is not None: |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4750 out = join(args.base, docDir) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4751 cp = classpath() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4752 sp = os.pathsep.join(sp) |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4753 nowarnAPI = [] |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4754 if not args.warnAPI: |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4755 nowarnAPI.append('-XDignore.symbol.file') |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4756 log('Generating {2} for {0} in {1}'.format(', '.join(names), out, docDir)) |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4757 run([java().javadoc, memory, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4758 '-classpath', cp, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4759 '-quiet', |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4760 '-d', out, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4761 '-sourcepath', sp] + |
15403
a9df38ce8fb7
mx: disable doclint when running javadoc (until the code base is doclint clean)
Doug Simon <doug.simon@oracle.com>
parents:
15386
diff
changeset
|
4762 ([] if java().javaCompliance < JavaCompliance('1.8') else ['-Xdoclint:none']) + |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4763 links + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4764 extraArgs + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4765 nowarnAPI + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
4766 list(pkgs)) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
4767 log('Generated {2} for {0} in {1}'.format(', '.join(names), out, docDir)) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
4768 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4769 def site(args): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4770 """creates a website containing javadoc and the project dependency graph""" |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4771 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4772 parser = ArgumentParser(prog='site') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4773 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>') |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4774 parser.add_argument('--tmp', action='store', help='directory to use for intermediate results', metavar='<dir>') |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4775 parser.add_argument('--name', action='store', help='name of overall documentation', required=True, metavar='<name>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4776 parser.add_argument('--overview', action='store', help='path to the overview content for overall documentation', required=True, metavar='<path>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4777 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)') |
5782
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4778 parser.add_argument('--jd', action='append', help='extra Javadoc arguments (e.g. --jd @-use)', metavar='@<arg>', default=[]) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4779 parser.add_argument('--exclude-packages', action='store', help='comma separated packages to exclude', metavar='<pkgs>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4780 parser.add_argument('--dot-output-base', action='store', help='base file name (relative to <dir>/all) for project dependency graph .svg and .jpg files generated by dot (omit to disable dot generation)', metavar='<path>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4781 parser.add_argument('--title', action='store', help='value used for -windowtitle and -doctitle javadoc args for overall documentation (default: "<name>")', metavar='<title>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4782 args = parser.parse_args(args) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4783 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4784 args.base = os.path.abspath(args.base) |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4785 tmpbase = args.tmp if args.tmp else tempfile.mkdtemp(prefix=basename(args.base) + '.', dir=dirname(args.base)) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4786 unified = join(tmpbase, 'all') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4787 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4788 exclude_packages_arg = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4789 if args.exclude_packages is not None: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4790 exclude_packages_arg = ['--exclude-packages', args.exclude_packages] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4791 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4792 projects = sorted_deps() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4793 projects_arg = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4794 if args.projects is not None: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4795 projects_arg = ['--projects', args.projects] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4796 projects = [project(name) for name in args.projects.split(',')] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4797 |
5782
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4798 extra_javadoc_args = [] |
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4799 for a in args.jd: |
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4800 extra_javadoc_args.append('--arg') |
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4801 extra_javadoc_args.append('@' + a) |
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4802 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4803 try: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4804 # Create javadoc for each project |
5782
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4805 javadoc(['--base', tmpbase] + exclude_packages_arg + projects_arg + extra_javadoc_args) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4806 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4807 # Create unified javadoc for all projects |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4808 with open(args.overview) as fp: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4809 content = fp.read() |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4810 idx = content.rfind('</body>') |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4811 if idx != -1: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4812 args.overview = join(tmpbase, 'overview_with_projects.html') |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4813 with open(args.overview, 'w') as fp2: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4814 print >> fp2, content[0:idx] |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4815 print >> fp2, """<div class="contentContainer"> |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4816 <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Projects table"> |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4817 <caption><span>Projects</span><span class="tabEnd"> </span></caption> |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4818 <tr><th class="colFirst" scope="col">Project</th><th class="colLast" scope="col"> </th></tr> |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4819 <tbody>""" |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4820 color = 'row' |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4821 for p in projects: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4822 print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html",target = "_top">{0}</a></td><td class="colLast"> </td></tr>'.format(p.name, color) |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4823 color = 'row' if color == 'alt' else 'alt' |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4824 |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4825 print >> fp2, '</tbody></table></div>' |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4826 print >> fp2, content[idx:] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4827 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4828 title = args.title if args.title is not None else args.name |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4829 javadoc(['--base', tmpbase, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4830 '--unified', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4831 '--arg', '@-windowtitle', '--arg', '@' + title, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4832 '--arg', '@-doctitle', '--arg', '@' + title, |
5782
488864d5069a
added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents:
5778
diff
changeset
|
4833 '--arg', '@-overview', '--arg', '@' + args.overview] + exclude_packages_arg + projects_arg + extra_javadoc_args) |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4834 |
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4835 if exists(unified): |
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4836 shutil.rmtree(unified) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4837 os.rename(join(tmpbase, 'javadoc'), unified) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4838 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4839 # Generate dependency graph with Graphviz |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4840 if args.dot_output_base is not None: |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4841 dotErr = None |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4842 try: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4843 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT): |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4844 dotErr = 'dot -V does not print a string containing "version"' |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4845 except subprocess.CalledProcessError as e: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4846 dotErr = 'error calling "dot -V": {}'.format(e) |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4847 except OSError as e: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4848 dotErr = 'error calling "dot -V": {}'.format(e) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4849 |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4850 if dotErr != None: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4851 abort('cannot generate dependency graph: ' + dotErr) |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4852 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4853 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4854 svg = join(tmpbase, 'all', str(args.dot_output_base) + '.svg') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4855 jpg = join(tmpbase, 'all', str(args.dot_output_base) + '.jpg') |
5854
2c00c51357d8
added more content to graal.api.meta overview
Doug Simon <doug.simon@oracle.com>
parents:
5853
diff
changeset
|
4856 html = join(tmpbase, 'all', str(args.dot_output_base) + '.html') |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4857 with open(dot, 'w') as fp: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4858 dim = len(projects) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4859 print >> fp, 'digraph projects {' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4860 print >> fp, 'rankdir=BT;' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4861 print >> fp, 'size = "' + str(dim) + ',' + str(dim) + '";' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4862 print >> fp, 'node [shape=rect, fontcolor="blue"];' |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4863 # print >> fp, 'edge [color="green"];' |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4864 for p in projects: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4865 print >> fp, '"' + p.name + '" [URL = "../' + p.name + '/javadoc/index.html", target = "_top"]' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4866 for dep in p.canonical_deps(): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4867 if dep in [proj.name for proj in projects]: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4868 print >> fp, '"' + p.name + '" -> "' + dep + '"' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4869 depths = dict() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4870 for p in projects: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4871 d = p.max_depth() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4872 depths.setdefault(d, list()).append(p.name) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4873 print >> fp, '}' |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4874 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4875 run(['dot', '-Tsvg', '-o' + svg, '-Tjpg', '-o' + jpg, dot]) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4876 |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4877 # Post-process generated SVG to remove title elements which most browsers |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4878 # render as redundant (and annoying) tooltips. |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4879 with open(svg, 'r') as fp: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4880 content = fp.read() |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4881 content = re.sub('<title>.*</title>', '', content) |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4882 content = re.sub('xlink:title="[^"]*"', '', content) |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4883 with open(svg, 'w') as fp: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4884 fp.write(content) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4885 |
6506
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4886 # Create HTML that embeds the svg file in an <object> frame |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4887 with open(html, 'w') as fp: |
305b9166b455
added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents:
6350
diff
changeset
|
4888 print >> fp, '<html><body><object data="{}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base) |
5854
2c00c51357d8
added more content to graal.api.meta overview
Doug Simon <doug.simon@oracle.com>
parents:
5853
diff
changeset
|
4889 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4890 if exists(args.base): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4891 shutil.rmtree(args.base) |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4892 if args.tmp: |
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4893 shutil.copytree(tmpbase, args.base) |
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4894 else: |
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4895 shutil.move(tmpbase, args.base) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4896 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4897 print 'Created website - root is ' + join(args.base, 'all', 'index.html') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4898 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4899 finally: |
15406
ca16edfcecd5
mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents:
15403
diff
changeset
|
4900 if not args.tmp and exists(tmpbase): |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4901 shutil.rmtree(tmpbase) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4902 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4903 def _kwArg(kwargs): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4904 if len(kwargs) > 0: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4905 return kwargs.pop(0) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4906 return None |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4907 |
16167
1f4955abca9b
mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents:
16087
diff
changeset
|
4908 def findclass(args, logToConsole=True, matcher=lambda string, classname: string in classname): |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4909 """find all classes matching a given substring""" |
9009
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
4910 matches = [] |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4911 for entry, filename in classpath_walk(includeBootClasspath=True): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4912 if filename.endswith('.class'): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4913 if isinstance(entry, zipfile.ZipFile): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4914 classname = filename.replace('/', '.') |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4915 else: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4916 classname = filename.replace(os.sep, '.') |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4917 classname = classname[:-len('.class')] |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4918 for a in args: |
16167
1f4955abca9b
mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents:
16087
diff
changeset
|
4919 if matcher(a, classname): |
9009
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
4920 matches.append(classname) |
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
4921 if logToConsole: |
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
4922 log(classname) |
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
4923 return matches |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4924 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4925 def select_items(items, descriptions=None, allowMultiple=True): |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4926 """ |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4927 Presents a command line interface for selecting one or more (if allowMultiple is true) items. |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4928 |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4929 """ |
11318
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4930 if len(items) <= 1: |
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4931 return items |
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4932 else: |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4933 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4934 log('[0] <all>') |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4935 for i in range(0, len(items)): |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4936 if descriptions is None: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4937 log('[{0}] {1}'.format(i + 1, items[i])) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4938 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4939 assert len(items) == len(descriptions) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4940 wrapper = textwrap.TextWrapper(subsequent_indent=' ') |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4941 log('\n'.join(wrapper.wrap('[{0}] {1} - {2}'.format(i + 1, items[i], descriptions[i])))) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4942 while True: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4943 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4944 s = raw_input('Enter number(s) of selection (separate multiple choices with spaces): ').split() |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4945 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4946 s = [raw_input('Enter number of selection: ')] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4947 try: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4948 s = [int(x) for x in s] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4949 except: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4950 log('Selection contains non-numeric characters: "' + ' '.join(s) + '"') |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4951 continue |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4952 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4953 if allowMultiple and 0 in s: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4954 return items |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4955 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4956 indexes = [] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4957 for n in s: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4958 if n not in range(1, len(items) + 1): |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4959 log('Invalid selection: ' + str(n)) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4960 continue |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4961 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4962 indexes.append(n - 1) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4963 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4964 return [items[i] for i in indexes] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4965 if len(indexes) == 1: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4966 return items[indexes[0]] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4967 return None |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4968 |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4969 def exportlibs(args): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4970 """export libraries to an archive file""" |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4971 |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4972 parser = ArgumentParser(prog='exportlibs') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4973 parser.add_argument('-b', '--base', action='store', help='base name of archive (default: libs)', default='libs', metavar='<path>') |
15364
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
4974 parser.add_argument('-a', '--include-all', action='store_true', help="include all defined libaries") |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4975 parser.add_argument('--arc', action='store', choices=['tgz', 'tbz2', 'tar', 'zip'], default='tgz', help='the type of the archive to create') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4976 parser.add_argument('--no-sha1', action='store_false', dest='sha1', help='do not create SHA1 signature of archive') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4977 parser.add_argument('--no-md5', action='store_false', dest='md5', help='do not create MD5 signature of archive') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4978 parser.add_argument('--include-system-libs', action='store_true', help='include system libraries (i.e., those not downloaded from URLs)') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4979 parser.add_argument('extras', nargs=REMAINDER, help='extra files and directories to add to archive', metavar='files...') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4980 args = parser.parse_args(args) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4981 |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4982 def createArchive(addMethod): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4983 entries = {} |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4984 def add(path, arcname): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4985 apath = os.path.abspath(path) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4986 if not entries.has_key(arcname): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4987 entries[arcname] = apath |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4988 logv('[adding ' + path + ']') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4989 addMethod(path, arcname=arcname) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4990 elif entries[arcname] != apath: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4991 logv('[warning: ' + apath + ' collides with ' + entries[arcname] + ' as ' + arcname + ']') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4992 else: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4993 logv('[already added ' + path + ']') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
4994 |
15355
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
4995 libsToExport = set() |
15364
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
4996 if args.include_all: |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
4997 for lib in _libs.itervalues(): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
4998 libsToExport.add(lib) |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
4999 else: |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5000 def isValidLibrary(dep): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5001 if dep in _libs.iterkeys(): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5002 lib = _libs[dep] |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5003 if len(lib.urls) != 0 or args.include_system_libs: |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5004 return lib |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5005 return None |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5006 |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5007 # iterate over all project dependencies and find used libraries |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5008 for p in _projects.itervalues(): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5009 for dep in p.deps: |
15355
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5010 r = isValidLibrary(dep) |
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5011 if r: |
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5012 libsToExport.add(r) |
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5013 |
15364
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5014 # a library can have other libraries as dependency |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5015 size = 0 |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5016 while size != len(libsToExport): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5017 size = len(libsToExport) |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5018 for lib in libsToExport.copy(): |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5019 for dep in lib.deps: |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5020 r = isValidLibrary(dep) |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5021 if r: |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5022 libsToExport.add(r) |
9693513ce95c
mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents:
15362
diff
changeset
|
5023 |
15355
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5024 for lib in libsToExport: |
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5025 add(lib.get_path(resolve=True), lib.path) |
15356
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5026 if lib.sha1: |
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5027 add(lib.get_path(resolve=True) + ".sha1", lib.path + ".sha1") |
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5028 if lib.sourcePath: |
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5029 add(lib.get_source_path(resolve=True), lib.sourcePath) |
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5030 if lib.sourceSha1: |
9e7f87dc6395
mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents:
15355
diff
changeset
|
5031 add(lib.get_source_path(resolve=True) + ".sha1", lib.sourcePath + ".sha1") |
15355
43aa6a7e60bd
mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents:
15274
diff
changeset
|
5032 |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5033 if args.extras: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5034 for e in args.extras: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5035 if os.path.isdir(e): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5036 for root, _, filenames in os.walk(e): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5037 for name in filenames: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5038 f = join(root, name) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5039 add(f, f) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5040 else: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5041 add(e, e) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5042 |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5043 if args.arc == 'zip': |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5044 path = args.base + '.zip' |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5045 with zipfile.ZipFile(path, 'w') as zf: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5046 createArchive(zf.write) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5047 else: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5048 path = args.base + '.tar' |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5049 mode = 'w' |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5050 if args.arc != 'tar': |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5051 sfx = args.arc[1:] |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5052 mode = mode + ':' + sfx |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5053 path = path + '.' + sfx |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5054 with tarfile.open(path, mode) as tar: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5055 createArchive(tar.add) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5056 log('created ' + path) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5057 |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5058 def digest(enabled, path, factory, suffix): |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5059 if enabled: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5060 d = factory() |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5061 with open(path, 'rb') as f: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5062 while True: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5063 buf = f.read(4096) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5064 if not buf: |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5065 break |
15122
11a591a99515
mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents:
15118
diff
changeset
|
5066 d.update(buf) |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5067 with open(path + '.' + suffix, 'w') as fp: |
15122
11a591a99515
mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents:
15118
diff
changeset
|
5068 print >> fp, d.hexdigest() |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5069 log('created ' + path + '.' + suffix) |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5070 |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5071 digest(args.sha1, path, hashlib.sha1, 'sha1') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5072 digest(args.md5, path, hashlib.md5, 'md5') |
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5073 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5074 def javap(args): |
9009
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
5075 """disassemble classes matching given pattern with javap""" |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5076 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5077 javapExe = java().javap |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5078 if not exists(javapExe): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5079 abort('The javap executable does not exists: ' + javapExe) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5080 else: |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
5081 candidates = findclass(args, logToConsole=False) |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
5082 if len(candidates) == 0: |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
5083 log('no matches') |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
5084 selection = select_items(candidates) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5085 run([javapExe, '-private', '-verbose', '-classpath', classpath()] + selection) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5086 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5087 def show_projects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5088 """show all loaded projects""" |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5089 for s in suites(): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
5090 projectsFile = join(s.mxDir, 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5091 if exists(projectsFile): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5092 log(projectsFile) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5093 for p in s.projects: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5094 log('\t' + p.name) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
5095 |
11511
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5096 def ask_yes_no(question, default=None): |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5097 """""" |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5098 assert not default or default == 'y' or default == 'n' |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5099 if not sys.stdout.isatty(): |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5100 if default: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5101 return default |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5102 else: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5103 abort("Can not answer '" + question + "?' if stdout is not a tty") |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5104 questionMark = '? [yn]: ' |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5105 if default: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5106 questionMark = questionMark.replace(default, default.upper()) |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5107 answer = raw_input(question + questionMark) or default |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5108 while not answer: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5109 answer = raw_input(question + questionMark) |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
5110 return answer.lower().startswith('y') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5111 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5112 def add_argument(*args, **kwargs): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5113 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5114 Define how a single command-line argument. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5115 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5116 assert _argParser is not None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5117 _argParser.add_argument(*args, **kwargs) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5118 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5119 def update_commands(suite, new_commands): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5120 for key, value in new_commands.iteritems(): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5121 if _commands.has_key(key): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5122 warn("redefining command '" + key + "' in suite " + suite.name) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5123 _commands[key] = value |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5124 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5125 def warn(msg): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5126 if _warn: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
5127 print 'WARNING: ' + msg |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5128 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5129 # Table of commands in alphabetical order. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5130 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5131 # If any of the format args are instances of Callable, then they are called with an 'env' are before being |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5132 # used in the call to str.format(). |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5133 # Suite extensions should not update this table directly, but use update_commands |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5134 _commands = { |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5135 'about': [about, ''], |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
5136 'build': [build, '[options]'], |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
5137 'checkstyle': [checkstyle, ''], |
17159
ef5212ce8091
support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents:
17092
diff
changeset
|
5138 'convertprojects' : [convertprojects, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5139 'canonicalizeprojects': [canonicalizeprojects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5140 'clean': [clean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
5141 'eclipseinit': [eclipseinit, ''], |
7524
bbaa734b3627
added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents:
7509
diff
changeset
|
5142 'eclipseformat': [eclipseformat, ''], |
15087
f3e74d317e83
mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents:
15060
diff
changeset
|
5143 'exportlibs': [exportlibs, ''], |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
5144 'findclass': [findclass, ''], |
7913
0df252296c8d
added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents:
7787
diff
changeset
|
5145 'fsckprojects': [fsckprojects, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5146 'help': [help_, '[command]'], |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
5147 'ideclean': [ideclean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
5148 'ideinit': [ideinit, ''], |
15060
858d2b91c1f8
Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14964
diff
changeset
|
5149 'intellijinit': [intellijinit, ''], |
15818
718034423138
mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents:
15786
diff
changeset
|
5150 'archive': [_archive, '[options]'], |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
5151 'projectgraph': [projectgraph, ''], |
11777
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
5152 'pylint': [pylint, ''], |
9009
1eb16dbb31a7
changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents:
9002
diff
changeset
|
5153 'javap': [javap, '<class name patterns>'], |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
5154 'javadoc': [javadoc, '[options]'], |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
5155 'site': [site, '[options]'], |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
5156 'netbeansinit': [netbeansinit, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5157 'projects': [show_projects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5158 } |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5159 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5160 _argParser = ArgParser() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5161 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5162 def _suitename(mxDir): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5163 base = os.path.basename(mxDir) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5164 parts = base.split('.') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5165 # temporary workaround until mx.graal exists |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5166 if len(parts) == 1: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5167 return 'graal' |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5168 else: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5169 return parts[1] |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5170 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5171 def _is_suite_dir(d, mxDirName=None): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5172 """ |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5173 Checks if d contains a suite. |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5174 If mxDirName is None, matches any suite name, otherwise checks for exactly that suite. |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5175 """ |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5176 if os.path.isdir(d): |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5177 for f in os.listdir(d): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5178 if (mxDirName == None and (f == 'mx' or fnmatch.fnmatch(f, 'mx.*'))) or f == mxDirName: |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5179 mxDir = join(d, f) |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
5180 if exists(mxDir) and isdir(mxDir) and exists(join(mxDir, 'projects')): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5181 return mxDir |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5182 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5183 def _check_primary_suite(): |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5184 if _primary_suite is None: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5185 abort('no primary suite found') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5186 else: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5187 return _primary_suite |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5188 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5189 def _findPrimarySuiteMxDirFrom(d): |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5190 """ search for a suite directory upwards from 'd' """ |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5191 while d: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5192 mxDir = _is_suite_dir(d) |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5193 if mxDir is not None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5194 return mxDir |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5195 parent = dirname(d) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5196 if d == parent: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5197 return None |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5198 d = parent |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5199 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
5200 return None |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
5201 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5202 def _findPrimarySuiteMxDir(): |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5203 # check for explicit setting |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5204 if _primary_suite_path is not None: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5205 mxDir = _is_suite_dir(_primary_suite_path) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5206 if mxDir is not None: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5207 return mxDir |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5208 else: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5209 abort(_primary_suite_path + ' does not contain an mx suite') |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5210 |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5211 # try current working directory first |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5212 mxDir = _findPrimarySuiteMxDirFrom(os.getcwd()) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5213 if mxDir is not None: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5214 return mxDir |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5215 # backwards compatibility: search from path of this file |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5216 return _findPrimarySuiteMxDirFrom(dirname(__file__)) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5217 |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
5218 def main(): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5219 primarySuiteMxDir = _findPrimarySuiteMxDir() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
5220 if primarySuiteMxDir: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5221 global _primary_suite |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5222 _primary_suite = _loadSuite(primarySuiteMxDir, True) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
5223 else: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
5224 abort('no primary suite found') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5225 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5226 opts, commandAndArgs = _argParser._parse_cmd_line() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5227 |
14763 | 5228 global _opts, _java_homes |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5229 _opts = opts |
14763 | 5230 defaultJdk = JavaConfig(opts.java_home, opts.java_dbg_port) |
5231 _java_homes = [defaultJdk] | |
5232 if opts.extra_java_homes: | |
5233 for java_home in opts.extra_java_homes.split(os.pathsep): | |
5234 extraJdk = JavaConfig(java_home, opts.java_dbg_port) | |
5235 if extraJdk > defaultJdk: | |
5236 abort('Secondary JDK ' + extraJdk.jdk + ' has higher compliance level than default JDK ' + defaultJdk.jdk) | |
5237 _java_homes.append(extraJdk) | |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5238 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
5239 for s in suites(): |
4180
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
5240 s._post_init(opts) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5241 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5242 if len(commandAndArgs) == 0: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5243 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5244 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5245 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5246 command = commandAndArgs[0] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5247 command_args = commandAndArgs[1:] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5248 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5249 if not _commands.has_key(command): |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5250 hits = [c for c in _commands.iterkeys() if c.startswith(command)] |
5824
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5251 if len(hits) == 1: |
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5252 command = hits[0] |
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5253 elif len(hits) == 0: |
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5254 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands())) |
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5255 else: |
b1dc8fbebb48
mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents:
5821
diff
changeset
|
5256 abort('mx: command \'{0}\' is ambiguous\n {1}'.format(command, ' '.join(hits))) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
5257 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
5258 c, _ = _commands[command][:2] |
4293
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
5259 def term_handler(signum, frame): |
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
5260 abort(1) |
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
5261 signal.signal(signal.SIGTERM, term_handler) |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
5262 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
5263 def quit_handler(signum, frame): |
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
5264 _send_sigquit() |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
5265 if get_os() != 'windows': |
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
5266 signal.signal(signal.SIGQUIT, quit_handler) |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
5267 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5268 try: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
5269 if opts.timeout != 0: |
4239
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
5270 def alarm_handler(signum, frame): |
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
5271 abort('Command timed out after ' + str(opts.timeout) + ' seconds: ' + ' '.join(commandAndArgs)) |
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
5272 signal.signal(signal.SIGALRM, alarm_handler) |
676feaf8adee
Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents:
4236
diff
changeset
|
5273 signal.alarm(opts.timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5274 retcode = c(command_args) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5275 if retcode is not None and retcode != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5276 abort(retcode) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5277 except KeyboardInterrupt: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5278 # no need to show the stack trace when the user presses CTRL-C |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5279 abort(1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5280 |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
5281 version = VersionSpec("1.0") |
13358
e1a50eac0eac
Add a version number for the mxtool and support for requesting a minimum mx version in a suite
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13288
diff
changeset
|
5282 |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5283 currentUmask = None |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5284 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5285 if __name__ == '__main__': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5286 # rename this module as 'mx' so it is not imported twice by the commands.py modules |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5287 sys.modules['mx'] = sys.modules.pop('__main__') |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
5288 |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5289 # Capture the current umask since there's no way to query it without mutating it. |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5290 currentUmask = os.umask(0) |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5291 os.umask(currentUmask) |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
5292 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
5293 main() |