Mercurial > hg > truffle
annotate mxtool/mx.py @ 14940:82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 02 Apr 2014 14:19:38 +0200 |
parents | dd5095578b79 |
children | e1ce6c66f56e |
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 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
36 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
37 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
|
38 import socket |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
39 import hashlib |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 import difflib |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 from collections import Callable |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 from threading import Thread |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
49 _projects = dict() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
50 _libs = dict() |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
51 _dists = dict() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
52 _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
|
53 _annotationProcessors = None |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
54 _primary_suite_path = None |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
55 _primary_suite = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
56 _opts = None |
14763 | 57 _java_homes = None |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
58 _warn = False |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
59 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
60 """ |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
61 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
|
62 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
63 class Distribution: |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
64 def __init__(self, suite, name, path, sourcesPath, deps, excludedLibs): |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
65 self.suite = suite |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
66 self.name = name |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
67 self.path = path.replace('/', os.sep) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
68 self.sourcesPath = sourcesPath.replace('/', os.sep) if sourcesPath else None |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
69 if not isabs(self.path): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
70 self.path = join(suite.dir, self.path) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
71 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
|
72 self.update_listeners = set() |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
73 self.excludedLibs = excludedLibs |
14775
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
74 |
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
75 def sorted_deps(self, includeLibs=False): |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
76 try: |
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
77 excl = [library(d) for d in self.excludedLibs] |
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
78 except SystemExit as e: |
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
79 abort('invalid excluded library for {} distribution: {}'.format(self.name, e)) |
14775
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
80 return [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
|
81 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
82 def __str__(self): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
83 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
|
84 |
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
|
85 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
|
86 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
|
87 |
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
|
88 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
|
89 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
|
90 l(self) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
91 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
92 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
93 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
|
94 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 class Dependency: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
96 def __init__(self, suite, name): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 self.name = name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
98 self.suite = suite |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
99 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 def __str__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 return self.name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
102 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 def __eq__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 return self.name == other.name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
105 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 def __ne__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 return self.name != other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 def __hash__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 return hash(self.name) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
111 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 def isLibrary(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 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
|
114 |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
115 def isProject(self): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
116 return isinstance(self, Project) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
117 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 class Project(Dependency): |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
119 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
|
120 Dependency.__init__(self, suite, name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 self.srcDirs = srcDirs |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 self.deps = deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 self.checkstyleProj = name |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
124 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
|
125 self.native = False |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
126 self.workingSets = workingSets |
7509 | 127 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
|
128 |
14763 | 129 # Verify that a JDK exists for this project if its compliance level is |
130 # less than the compliance level of the default JDK | |
131 jdk = java(self.javaCompliance) | |
132 if jdk is None and self.javaCompliance < java().javaCompliance: | |
133 abort('Cannot find ' + str(self.javaCompliance) + ' JDK required by ' + name + '. ' + | |
14764 | 134 'Specify it with --extra-java-homes option or EXTRA_JAVA_HOMES environment variable.') |
14763 | 135 |
5581
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
136 # Create directories for projects that don't yet exist |
7509 | 137 if not exists(d): |
138 os.mkdir(d) | |
5581
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
139 for s in self.source_dirs(): |
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
140 if not exists(s): |
9911227e6dd3
create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents:
5455
diff
changeset
|
141 os.mkdir(s) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
142 |
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
|
143 def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
144 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
145 Add the transitive set of dependencies for this project, including |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
146 libraries if 'includeLibs' is true, to the 'deps' list. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
147 """ |
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
|
148 childDeps = list(self.deps) |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
149 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
|
150 childDeps = self.annotation_processors() + childDeps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 if self in deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 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
|
153 for name in childDeps: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 assert name != self.name |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
155 dep = dependency(name) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
156 if not dep in deps and (includeLibs or not dep.isLibrary()): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
157 dep.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
158 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
|
159 deps.append(self) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 return deps |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
161 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
162 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
|
163 currentDist = distances.get(name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 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
|
165 distances[name] = dist |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
166 p = project(name, False) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
167 if p is not None: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 for dep in p.deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
169 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
|
170 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
171 def canonical_deps(self): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
172 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
173 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
|
174 via other dependencies). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
175 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 distances = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 result = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 if d == 1: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 result.add(n) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
183 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 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
|
185 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
|
186 return result |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
187 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
188 def max_depth(self): |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
189 """ |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
190 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
|
191 """ |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
192 distances = dict() |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
193 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
|
194 return max(distances.values()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 def source_dirs(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
197 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
198 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
|
199 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
200 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
|
201 |
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
|
202 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
|
203 """ |
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
|
204 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
|
205 """ |
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
|
206 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
|
207 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
|
208 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
|
209 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 def output_dir(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
211 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
212 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
|
213 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
214 if self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
215 return None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
216 return join(self.dir, 'bin') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
218 def jasmin_output_dir(self): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
219 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
220 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
|
221 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
222 if self.native: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
223 return None |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
224 return join(self.dir, 'jasmin_classes') |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
225 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
226 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
227 if not self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
228 cp.append(self.output_dir()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 |
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
|
230 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
|
231 """ |
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
|
232 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
|
233 '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
|
234 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
|
235 """ |
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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 break |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
256 |
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
|
257 if matchFound: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 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
|
262 if exists(pkgOutputDir): |
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
263 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
|
264 if includeInnerClasses: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 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
|
269 className = pkg + '.' + simpleClassName |
11245
d89a5dbaaaf6
ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents:
11205
diff
changeset
|
270 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
|
271 return result |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
272 |
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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 # 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
|
291 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
|
292 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
|
293 |
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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 |
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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 |
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
|
314 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
|
315 """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
|
316 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
|
317 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
|
318 |
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
|
319 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
|
320 """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
|
321 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
|
322 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
|
323 |
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
|
324 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
|
325 """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
|
326 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
|
327 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
|
328 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
|
329 |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
330 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
|
331 if not hasattr(self, '_annotationProcessors'): |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
332 ap = 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
|
333 if hasattr(self, '_declaredAnnotationProcessors'): |
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
|
334 ap = set(self._declaredAnnotationProcessors) |
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
|
335 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
336 # find dependencies that auto-inject themselves as annotation processors to all dependents |
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
|
337 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
|
338 for p in allDeps: |
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
|
339 if hasattr(p, 'annotationProcessorForDependents') and p.annotationProcessorForDependents.lower() == 'true': |
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
|
340 ap.add(p.name) |
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
|
341 self._annotationProcessors = list(ap) |
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
|
342 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
|
343 |
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
|
344 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
|
345 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
|
346 outOfDate = False |
12641
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
362 def _download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
363 def _download_lib(): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
364 print 'Downloading ' + ("Sources " if sources else "") + name + ' from ' + str(urls) |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
365 download(path, urls) |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
366 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
367 def _sha1Cached(): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
368 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
|
369 return f.read()[0:40] |
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
370 |
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
371 def _writeSha1Cached(): |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
372 with open(sha1path, 'w') as f: |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
373 f.write(_sha1OfFile()) |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
374 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
375 def _sha1OfFile(): |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
376 with open(path, 'rb') as f: |
14156
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
377 d = hashlib.sha1() |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
378 while True: |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
379 buf = f.read(4096) |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
380 if not buf: |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
381 break |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
382 d.update(buf) |
7668297a2e67
mx: compute sha1 digest blockwise
Bernhard Urban <bernhard.urban@jku.at>
parents:
14155
diff
changeset
|
383 return d.hexdigest() |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
384 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
385 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
|
386 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
|
387 _download_lib() |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
388 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
389 if sha1 and not exists(sha1path): |
14154
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
390 _writeSha1Cached() |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
391 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
392 if sha1 and sha1 != _sha1Cached(): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
393 _download_lib() |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
394 if sha1 != _sha1OfFile(): |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
395 abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") |
14154
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
396 _writeSha1Cached() |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
397 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
398 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
|
399 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
400 class Library(Dependency): |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
401 def __init__(self, suite, name, path, mustExist, urls, sha1, sourcePath, sourceUrls, sourceSha1): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
402 Dependency.__init__(self, suite, name) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
403 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
|
404 self.urls = urls |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
405 self.sha1 = sha1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
406 self.mustExist = mustExist |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
407 self.sourcePath = sourcePath |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
408 self.sourceUrls = sourceUrls |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
409 self.sourceSha1 = sourceSha1 |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
410 for url in urls: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
411 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
|
412 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
|
413 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
414 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
|
415 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
|
416 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
|
417 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
|
418 else: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
419 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
|
420 else: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
421 return NotImplemented |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
422 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
423 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
424 def __ne__(self, other): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
425 result = self.__eq__(other) |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
426 if result is NotImplemented: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
427 return result |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
428 return not result |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
429 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
430 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
431 def get_path(self, resolve): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
432 path = self.path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
433 if not isabs(path): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
434 path = join(self.suite.dir, path) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
435 sha1path = path + '.sha1' |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
436 |
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
|
437 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
|
438 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
|
439 return None |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
440 |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
441 return _download_file_with_sha1(self.name, path, self.urls, self.sha1, sha1path, resolve, self.mustExist) |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
442 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
443 |
5853
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
444 def get_source_path(self, resolve): |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
445 path = self.sourcePath |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
446 if path is None: |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
447 return None |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
448 if not isabs(path): |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
449 path = join(self.suite.dir, path) |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
450 sha1path = path + '.sha1' |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
451 |
14154
e666c172c9aa
mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents:
14153
diff
changeset
|
452 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
|
453 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
454 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
455 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
|
456 if path and (exists(path) or not resolve): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
457 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
|
458 |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
459 def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
460 if not includeLibs or not includeSelf: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
461 return deps |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
462 deps.append(self) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
463 return deps |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
464 |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
465 class HgConfig: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
466 """ |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
467 Encapsulates access to Mercurial (hg) |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
468 """ |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
469 def __init__(self): |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
470 self.missing = 'no hg executable found' |
12512
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
471 self.has_hg = None |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
472 |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
473 def check(self, abortOnFail=True): |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
474 if self.has_hg is None: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
475 try: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
476 subprocess.check_output(['hg']) |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
477 self.has_hg = True |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
478 except OSError: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
479 self.has_hg = False |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
480 warn(self.missing) |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
481 |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
482 if not self.has_hg: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
483 if abortOnFail: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
484 abort(self.missing) |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
485 else: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
486 warn(self.missing) |
12512
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
487 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
488 def tip(self, sDir, abortOnError=True): |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
489 try: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
490 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
|
491 except OSError: |
21aa1ce5c666
made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents:
12508
diff
changeset
|
492 warn(self.missing) |
12508
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
493 except subprocess.CalledProcessError: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
494 if abortOnError: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
495 abort('failed to get tip revision id') |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
496 else: |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
497 return None |
5cde653f58f9
mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents:
12504
diff
changeset
|
498 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
499 class Suite: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
500 def __init__(self, mxDir, primary, load=True): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
501 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
|
502 self.mxDir = mxDir |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
503 self.projects = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
504 self.libs = [] |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
505 self.dists = [] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
506 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
|
507 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
|
508 self.requiredMxVersion = None |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
509 self.name = _suitename(mxDir) # validated in _load_projects |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
510 if load: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
511 # just check that there are no imports |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
512 self._load_imports() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
513 self._load_env() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
514 self._load_commands() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
515 _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
|
516 |
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
|
517 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
|
518 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
|
519 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
520 def _load_projects(self): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
521 libsMap = dict() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
522 projsMap = dict() |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
523 distsMap = dict() |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
524 projectsFile = join(self.mxDir, 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
525 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
526 return |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
527 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
528 with open(projectsFile) as f: |
12455
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
529 prefix = '' |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
530 lineNum = 0 |
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
531 |
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
532 def error(message): |
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
533 abort(projectsFile + ':' + str(lineNum) + ': ' + message) |
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
534 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
535 for line in f: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
536 lineNum = lineNum + 1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
537 line = line.strip() |
12455
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
538 if line.endswith('\\'): |
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
539 prefix = prefix + line[:-1] |
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
540 continue |
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
541 if len(prefix) != 0: |
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
542 line = prefix + line |
d08accd58925
added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents:
12441
diff
changeset
|
543 prefix = '' |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
544 if len(line) != 0 and line[0] != '#': |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
545 if '=' not in line: |
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
546 error('non-comment line does not contain an "=" character') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
547 key, value = line.split('=', 1) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
548 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
549 parts = key.split('@') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
550 |
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
|
551 if len(parts) == 1: |
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
|
552 if parts[0] == 'suite': |
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
|
553 if self.name != value: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
554 error('suite name in project file does not match ' + _suitename(self.mxDir)) |
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
|
555 elif parts[0] == 'mxversion': |
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
|
556 try: |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
557 self.requiredMxVersion = VersionSpec(value) |
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
|
558 except AssertionError as ae: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
559 error('Exception while parsing "mxversion" in project file: ' + str(ae)) |
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
|
560 else: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
561 error('Single part property must be "suite": ' + key) |
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
|
562 |
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
|
563 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
564 if len(parts) != 3: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
565 error('Property name does not have 3 parts separated by "@": ' + key) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
566 kind, name, attr = parts |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
567 if kind == 'project': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
568 m = projsMap |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
569 elif kind == 'library': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
570 m = libsMap |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
571 elif kind == 'distribution': |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
572 m = distsMap |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
573 else: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
574 error('Property name does not start with "project@", "library@" or "distribution@": ' + key) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
575 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
576 attrs = m.get(name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
577 if attrs is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
578 attrs = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
579 m[name] = attrs |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
580 value = expandvars_in_property(value) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
581 attrs[attr] = value |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
582 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
583 def pop_list(attrs, name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
584 v = attrs.pop(name, None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
585 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
|
586 return [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
587 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
|
588 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
589 for name, attrs in projsMap.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
590 srcDirs = pop_list(attrs, 'sourceDirs') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
591 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
|
592 ap = pop_list(attrs, 'annotationProcessors') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
593 # deps += ap |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
594 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
|
595 subDir = attrs.pop('subDir', None) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
596 if subDir is None: |
7509 | 597 d = join(self.dir, name) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
598 else: |
7509 | 599 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
|
600 workingSets = attrs.pop('workingSets', None) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
601 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
|
602 p.checkstyleProj = attrs.pop('checkstyle', name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
603 p.native = attrs.pop('native', '') == 'true' |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
604 if not p.native and p.javaCompliance is None: |
13620
fa56f5a49270
improved format checking and error reporting when parsing a projects file
Doug Simon <doug.simon@oracle.com>
parents:
13481
diff
changeset
|
605 error('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
|
606 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
|
607 p._declaredAnnotationProcessors = ap |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
608 p.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
609 self.projects.append(p) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
610 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
611 for name, attrs in libsMap.iteritems(): |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
612 path = attrs.pop('path') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
613 mustExist = attrs.pop('optional', 'false') != 'true' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
614 urls = pop_list(attrs, 'urls') |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
615 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
|
616 sourcePath = attrs.pop('sourcePath', None) |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
617 sourceUrls = pop_list(attrs, 'sourceUrls') |
14133
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
618 sourceSha1 = attrs.pop('sourceSha1', None) |
d2e4b81fd8f0
mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents:
14103
diff
changeset
|
619 l = Library(self, name, path, mustExist, urls, sha1, sourcePath, sourceUrls, sourceSha1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
620 l.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
621 self.libs.append(l) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
622 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
623 for name, attrs in distsMap.iteritems(): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
624 path = attrs.pop('path') |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
625 sourcesPath = attrs.pop('sourcesPath', None) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
626 deps = pop_list(attrs, 'dependencies') |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
627 exclLibs = pop_list(attrs, 'excludeLibs') |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
628 d = Distribution(self, name, path, sourcesPath, deps, exclLibs) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
629 d.__dict__.update(attrs) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
630 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
|
631 |
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
|
632 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
|
633 abort('Missing "suite=<name>" in ' + projectsFile) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
634 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
635 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
|
636 return 'mx_' + self.name.replace('-', '_') |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
637 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
638 def _find_commands(self, name): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
639 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
|
640 if exists(commandsPath): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
641 return name |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
642 else: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
643 return None |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
644 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
645 def _load_commands(self): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
646 commandsName = self._find_commands(self._commands_name()) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
647 if commandsName is None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
648 # backwards compatibility |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
649 commandsName = self._find_commands('commands') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
650 if commandsName is not None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
651 if commandsName in sys.modules: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
652 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
|
653 # temporarily extend the Python path |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
654 sys.path.insert(0, self.mxDir) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
655 mod = __import__(commandsName) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
656 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
657 self.commands = sys.modules.pop(commandsName) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
658 sys.modules[commandsName] = self.commands |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
659 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
660 # revert the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
661 del sys.path[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
662 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
663 if not hasattr(mod, 'mx_init'): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
664 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
|
665 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
|
666 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
|
667 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
668 mod.mx_init(self) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
669 self.commands = mod |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
670 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
671 def _load_imports(self): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
672 if exists(join(self.mxDir, 'imports')): |
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
673 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
|
674 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
675 def _load_env(self): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
676 e = join(self.mxDir, 'env') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
677 if exists(e): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
678 with open(e) as f: |
10585
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
679 lineNum = 0 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
680 for line in f: |
10585
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
681 lineNum = lineNum + 1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
682 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
683 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
|
684 if not '=' in line: |
be8b942f448f
made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents:
10576
diff
changeset
|
685 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
|
686 key, value = line.split('=', 1) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
687 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
|
688 |
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
|
689 def _post_init(self, opts): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
690 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
|
691 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
|
692 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
|
693 elif self.requiredMxVersion > version: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
694 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
|
695 # 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
|
696 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
|
697 existing = _projects.get(p.name) |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
698 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
|
699 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
|
700 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
|
701 _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
|
702 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
|
703 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
|
704 # 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
|
705 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
|
706 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
|
707 _libs[l.name] = l |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
708 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
|
709 existing = _dists.get(d.name) |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
710 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
|
711 # 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
|
712 # abort('cannot redefine distribution ' + d.name) |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
713 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
|
714 d.path = existing.path |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
715 _dists[d.name] = d |
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
|
716 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
|
717 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
|
718 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
719 class XMLElement(xml.dom.minidom.Element): |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
720 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
|
721 writer.write(indent + "<" + self.tagName) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
722 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
723 attrs = self._get_attributes() |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
724 a_names = attrs.keys() |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
725 a_names.sort() |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
726 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
727 for a_name in a_names: |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
728 writer.write(" %s=\"" % a_name) |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
729 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
|
730 writer.write("\"") |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
731 if self.childNodes: |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
732 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
|
733 # 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
|
734 # 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
|
735 writer.write(">") |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
736 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
|
737 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
|
738 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
739 writer.write(">%s" % (newl)) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
744 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
|
745 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
746 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
|
747 |
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
|
748 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
|
749 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
|
750 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
|
751 self.padTextNodeWithoutSiblings = False |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
752 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
753 def createElement(self, tagName): |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
754 # overwritten to create XMLElement |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
755 e = XMLElement(tagName) |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
756 e.ownerDocument = self |
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
757 return e |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
758 |
8302
b246434a3e4a
made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents:
8189
diff
changeset
|
759 def comment(self, txt): |
b246434a3e4a
made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents:
8189
diff
changeset
|
760 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
|
761 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
762 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
|
763 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
|
764 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
|
765 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
|
766 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
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
774 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
|
775 assert self.current != self |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
776 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
|
777 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
|
778 return self |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
779 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
780 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
|
781 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
|
782 attributes = {} |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
783 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
|
784 |
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
|
785 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
|
786 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
|
787 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
|
788 if escape: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
789 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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
795 def get_os(): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
796 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
797 Get a canonical form of sys.platform. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
798 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
799 if sys.platform.startswith('darwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
800 return 'darwin' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
801 elif sys.platform.startswith('linux'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
802 return 'linux' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
803 elif sys.platform.startswith('sunos'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
804 return 'solaris' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
805 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
806 return 'windows' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
807 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
808 abort('Unknown operating system ' + sys.platform) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
809 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
810 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
|
811 """ |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
812 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
|
813 """ |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
814 for s in _suites.itervalues(): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
815 if s.mxDir == mxDir: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
816 return s |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
817 # create the new suite |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
818 s = Suite(mxDir, primary) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
819 return s |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
820 |
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
|
821 def suites(opt_limit_to_suite=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
822 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
823 Get the list of all loaded suites. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
824 """ |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
825 return _suites.values() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
826 |
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
|
827 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
|
828 """ |
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
|
829 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
|
830 """ |
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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
836 |
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
|
837 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
|
838 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
839 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
|
840 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
841 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
|
842 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
|
843 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
|
844 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
|
845 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
846 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
|
847 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
848 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
|
849 """ |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
850 |
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
|
851 if opt_limit_to_suite: |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
852 return _projects_opt_limit_to_suites(_projects.values()) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
853 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
|
854 return _projects.values() |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
855 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
856 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
|
857 """ |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
858 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
|
859 """ |
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
|
860 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
|
861 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
862 def _projects_opt_limit_to_suites(projects): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
863 return projects |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
864 |
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
|
865 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
|
866 """ |
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
|
867 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
|
868 """ |
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
|
869 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
|
870 if _annotationProcessors is None: |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
871 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
|
872 for p in projects(): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
873 for ap in p.annotation_processors(): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
874 if project(ap, False): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
875 aps.add(ap) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
876 _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
|
877 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
|
878 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
879 def distribution(name, fatalIfMissing=True): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
880 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
881 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
|
882 not exist and 'fatalIfMissing' is true. |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
883 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
884 d = _dists.get(name) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
885 if d is None and fatalIfMissing: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
886 abort('distribution named ' + name + ' not found') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
887 return d |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
888 |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
889 def dependency(name, fatalIfMissing=True): |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
890 """ |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
891 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
|
892 not exist for 'name' and 'fatalIfMissing' is true. |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
893 """ |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
894 d = _projects.get(name) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
895 if d is None: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
896 d = _libs.get(name) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
897 if d is None and fatalIfMissing: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
898 if name in _opts.ignored_projects: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
899 abort('project named ' + name + ' is ignored') |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
900 abort('project or library named ' + name + ' not found') |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
901 return d |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
902 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
903 def project(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
904 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
905 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
|
906 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
907 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
908 p = _projects.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
909 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
|
910 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
|
911 abort('project named ' + name + ' is ignored') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
912 abort('project named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
913 return p |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
914 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
915 def library(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
916 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
917 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
|
918 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
919 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
920 l = _libs.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
921 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
|
922 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
|
923 abort(name + ' is a project, not a library') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
924 abort('library named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
925 return l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
926 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
927 def _as_classpath(deps, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
928 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
929 if _opts.cp_prefix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
930 cp = [_opts.cp_prefix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
931 for d in deps: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
932 d.append_to_classpath(cp, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
933 if _opts.cp_suffix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
934 cp += [_opts.cp_suffix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
935 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
936 |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
937 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
|
938 """ |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
939 Get the class path for a list of given dependencies, resolving each entry in the |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
940 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
|
941 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
942 if names is None: |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
943 result = _as_classpath(sorted_deps(includeLibs=True), resolve) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
944 else: |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
945 deps = [] |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
946 if isinstance(names, types.StringTypes): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
947 names = [names] |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
948 for n in names: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
949 dependency(n).all_deps(deps, True, includeSelf) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
950 result = _as_classpath(deps, resolve) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
951 if includeBootClasspath: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
952 result = os.pathsep.join([java().bootclasspath(), result]) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
953 return result |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
954 |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
955 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
|
956 """ |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
957 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
|
958 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
|
959 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
|
960 to the classpath entry. |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
961 """ |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
962 cp = classpath(names, resolve, includeSelf, includeBootClasspath) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
963 for entry in cp.split(os.pathsep): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
964 if not exists(entry): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
965 continue |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
966 if isdir(entry): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
967 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
|
968 for d in dirs: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
969 entryPath = join(root[len(entry) + 1:], d) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
970 yield entry, entryPath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
971 for f in files: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
972 entryPath = join(root[len(entry) + 1:], f) |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
973 yield entry, entryPath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
974 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
|
975 with zipfile.ZipFile(entry, 'r') as zf: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
976 for zi in zf.infolist(): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
977 entryPath = zi.filename |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
978 yield zf, entryPath |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
979 |
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
|
980 def sorted_deps(projectNames=None, includeLibs=False, includeAnnotationProcessors=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
981 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
982 Gets projects and libraries sorted such that dependencies |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
983 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
|
984 true, libraries are omitted from the result. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
985 """ |
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
|
986 projects = projects_from_names(projectNames) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
987 |
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
|
988 return sorted_project_deps(projects, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
989 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
990 def sorted_project_deps(projects, includeLibs=False, includeAnnotationProcessors=False): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
991 deps = [] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
992 for p in projects: |
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
|
993 p.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
994 return deps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
995 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
996 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
|
997 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
|
998 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
|
999 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1000 candidateJdks = [] |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1014 javaHome = None |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1015 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
|
1016 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
|
1017 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
|
1018 javaHome = None |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1019 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 javaHome = None |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1026 else: |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1027 break |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1028 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 |
11301
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1034 return javaHome |
8bcae501c51b
added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents:
11295
diff
changeset
|
1035 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1036 class ArgParser(ArgumentParser): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1037 # 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
|
1038 def format_help(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1039 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
|
1040 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1041 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1042 def __init__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1043 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
|
1044 # 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
|
1045 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
|
1046 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 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
|
1052 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
|
1053 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
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) |
14763 | 1059 self.add_argument('--java-home', help='primary JDK directory (must be JDK 7 or later)', metavar='<path>') |
1060 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
|
1061 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
|
1062 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
|
1063 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
|
1064 # 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
|
1065 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
|
1066 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
|
1067 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1068 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
|
1069 if args is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1070 args = sys.argv[1:] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1071 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1072 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
|
1073 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1074 opts = self.parse_args() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1075 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1076 # 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
|
1077 opts.__dict__.setdefault('timeout', 0) |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1078 opts.__dict__.setdefault('ptimeout', 0) |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1079 |
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
|
1080 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
|
1081 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
|
1082 |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1083 if opts.java_home is None: |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
1084 opts.java_home = os.environ.get('JAVA_HOME') |
14763 | 1085 if opts.extra_java_homes is None: |
1086 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
|
1087 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1088 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
|
1089 opts.java_home = _handle_missing_java_home() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1090 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1091 if opts.user_home is None or opts.user_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1092 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
|
1093 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1094 os.environ['JAVA_HOME'] = opts.java_home |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1095 os.environ['HOME'] = opts.user_home |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1096 |
5821
0cd337450409
added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents:
5782
diff
changeset
|
1097 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
|
1098 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1099 commandAndArgs = opts.__dict__.pop('commandAndArgs') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1100 return opts, commandAndArgs |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1101 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
1102 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
|
1103 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
|
1104 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1105 def _format_commands(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1106 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
|
1107 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
|
1108 c, _ = _commands[cmd][:2] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1109 doc = c.__doc__ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1110 if doc is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1111 doc = '' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1112 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
|
1113 return msg + '\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1114 |
14763 | 1115 def java(requiredCompliance=None): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1116 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1117 Get a JavaConfig object containing Java commands launch details. |
14763 | 1118 If requiredCompliance is None, the compliance level specified by --java-home/JAVA_HOME |
1119 is returned. Otherwise, the JavaConfig exactly matching requiredCompliance is returned | |
1120 or None if there is no exact match. | |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1121 """ |
14763 | 1122 assert _java_homes |
1123 if not requiredCompliance: | |
1124 return _java_homes[0] | |
1125 for java in _java_homes: | |
1126 if java.javaCompliance == requiredCompliance: | |
1127 return java | |
1128 return None | |
1129 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1130 |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1131 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
|
1132 if not javaConfig: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1133 javaConfig = java() |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1134 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
|
1135 |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1136 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
|
1137 if not sig: |
5454f6bf50bf
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1138 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
|
1139 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
|
1140 try: |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1141 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
|
1142 return True |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1143 except: |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1144 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
|
1145 return False |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1146 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1147 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
|
1148 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
|
1149 while True: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1150 try: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1151 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
|
1152 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
|
1153 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
|
1154 continue |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1155 raise |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1156 |
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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 # 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
|
1164 raise RuntimeError("Unknown child exit status!") |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1165 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
1166 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
|
1167 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
|
1168 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
|
1169 (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
|
1170 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1178 # Makes the current subprocess accessible to the abort() function |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1179 # This is a tuple of the Popen object and args. |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1180 _currentSubprocess = (None, None) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1181 |
4660
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1182 def waitOn(p): |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1183 if get_os() == 'windows': |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1184 # 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
|
1185 retcode = None |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1186 while retcode == None: |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1187 retcode = p.poll() |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1188 time.sleep(0.05) |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1189 else: |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1190 retcode = p.wait() |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1191 return retcode |
b06ade6e927c
Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4482
diff
changeset
|
1192 |
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
|
1193 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
|
1194 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 out and err if they are callable objects. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1200 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1201 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1202 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
|
1203 for arg in args: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1204 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
|
1205 |
9262
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1206 if env is None: |
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1207 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
|
1208 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1209 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
|
1210 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
|
1211 log('Environment variables:') |
9262
0f4ae7bbe062
fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents:
9193
diff
changeset
|
1212 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
|
1213 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
|
1214 log(' '.join(map(pipes.quote, args))) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1215 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1216 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
|
1217 timeout = _opts.ptimeout |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1218 |
4293
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
1219 global _currentSubprocess |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1220 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1221 try: |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1222 # 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
|
1223 # 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
|
1224 preexec_fn = None |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1225 creationflags = 0 |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1226 if get_os() == 'windows': |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1227 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
|
1228 else: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1229 preexec_fn = os.setsid |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1230 |
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
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env) |
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
|
1238 _currentSubprocess = (p, args) |
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
|
1239 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
|
1240 t = Thread(target=redirect, args=(p.stdout, 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
|
1241 t.daemon = True # thread dies with the program |
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
|
1242 t.start() |
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
|
1243 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
|
1244 t = Thread(target=redirect, args=(p.stderr, 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
|
1245 t.daemon = True # thread dies with the program |
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
|
1246 t.start() |
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
|
1247 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
|
1248 retcode = waitOn(p) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1249 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
|
1250 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
|
1251 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
|
1252 retcode = _waitWithTimeout(p, args, timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1253 except OSError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1254 log('Error executing \'' + ' '.join(args) + '\': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1255 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1256 raise e |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1257 abort(e.errno) |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1258 except KeyboardInterrupt: |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
1259 abort(1) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1260 finally: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1261 _currentSubprocess = (None, None) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1262 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1263 if retcode and nonZeroIsFatal: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1264 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
|
1265 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
|
1266 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
|
1267 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1268 log('[exit code: ' + str(retcode) + ']') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1269 abort(retcode) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1270 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1271 return retcode |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1272 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1273 def exe_suffix(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1274 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1275 Gets the platform specific suffix for an executable |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1276 """ |
4258
8d2c14f722ac
mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents:
4257
diff
changeset
|
1277 if get_os() == 'windows': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1278 return name + '.exe' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1279 return name |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1280 |
11401
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1281 def add_lib_prefix(name): |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1282 """ |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1283 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
|
1284 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1285 os = get_os() |
11401
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1286 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
|
1287 return 'lib' + name |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1288 return name |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1289 |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1290 def add_lib_suffix(name): |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1291 """ |
2d228d304247
minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents:
11374
diff
changeset
|
1292 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
|
1293 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1294 os = get_os() |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1295 if os == 'windows': |
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1296 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
|
1297 if os == 'linux' or os == 'solaris': |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1298 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
|
1299 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
|
1300 return name + '.dylib' |
4482
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1301 return name |
7903b6c28f9c
Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4396
diff
changeset
|
1302 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1303 """ |
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
|
1304 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
|
1305 """ |
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
|
1306 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
|
1307 """ |
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
|
1308 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
|
1309 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
|
1310 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
|
1311 """ |
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
|
1312 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
|
1313 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
|
1314 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
|
1315 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
|
1316 self.currentFilteredLineCount = 0 |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1317 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
|
1318 |
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
|
1319 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
|
1320 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
|
1321 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
|
1322 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
|
1323 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
|
1324 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
|
1325 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
|
1326 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
|
1327 |
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
|
1328 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
|
1329 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
|
1330 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
|
1331 self.currentFilteredLineCount += 1 |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1332 if self.currentFilteredTime: |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1333 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
|
1334 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
|
1335 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
|
1336 else: |
7c36ec150036
Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14156
diff
changeset
|
1337 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
|
1338 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
|
1339 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
|
1340 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
|
1341 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
|
1342 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
|
1343 |
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
|
1344 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1345 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
|
1346 """ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1347 class JavaCompliance: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1348 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
|
1349 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
|
1350 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
|
1351 self.value = int(m.group(1)) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1352 |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1353 def __str__(self): |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1354 return '1.' + str(self.value) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1355 |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1356 def __cmp__(self, other): |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1357 if isinstance(other, types.StringType): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1358 other = JavaCompliance(other) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1359 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1360 return cmp(self.value, other.value) |
13779 | 1361 |
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
|
1362 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
|
1363 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
|
1364 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1365 """ |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
1366 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
|
1367 """ |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
1368 class VersionSpec: |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1369 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
|
1370 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
|
1371 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
|
1372 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
|
1373 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
|
1374 self.versionString = versionString |
8391
d1d486c03e8a
Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8302
diff
changeset
|
1375 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
|
1376 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1377 def __str__(self): |
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1378 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
|
1379 |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1380 def __cmp__(self, other): |
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1381 return cmp(self.parts, other.parts) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1382 |
14940
82971f397b94
mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14939
diff
changeset
|
1383 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
|
1384 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
|
1385 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1386 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1387 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
|
1388 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1389 class JavaConfig: |
14763 | 1390 def __init__(self, java_home, java_dbg_port): |
1391 self.jdk = java_home | |
1392 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
|
1393 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
|
1394 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1395 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1396 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
|
1397 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc')) |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1398 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
|
1399 self._bootclasspath = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1400 |
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
|
1401 if not exists(self.java): |
14763 | 1402 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
|
1403 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1404 def delAtAndSplit(s): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1405 return shlex.split(s.lstrip('@')) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1406 |
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
|
1407 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
|
1408 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
|
1409 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
|
1410 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1411 # 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
|
1412 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1413 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
|
1414 self.java_args = ['-d64'] + self.java_args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1415 except subprocess.CalledProcessError as e: |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1416 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1417 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
|
1418 except subprocess.CalledProcessError as e: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1419 print e.output |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1420 abort(e.returncode) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1421 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1422 output = output.split() |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1423 assert output[1] == 'version' |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
1424 self.version = VersionSpec(output[2].strip('"')) |
7916
9bff64f43299
Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7787
diff
changeset
|
1425 self.javaCompliance = JavaCompliance(self.version.versionString) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1426 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1427 if self.debug_port is not None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1428 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
|
1429 |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1430 def _init_classpaths(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1431 myDir = dirname(__file__) |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1432 javaSource = join(myDir, 'ClasspathDump.java') |
14939
dd5095578b79
Always compile ClasspathDump.java to avoid class version problems
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14937
diff
changeset
|
1433 subprocess.check_call([self.javac, '-d', myDir, javaSource]) |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1434 self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', myDir, 'ClasspathDump']).split('|')] |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1435 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
|
1436 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
|
1437 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
|
1438 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
|
1439 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
|
1440 |
14763 | 1441 def __hash__(self): |
1442 return hash(self.jdk) | |
14764 | 1443 |
14763 | 1444 def __cmp__(self, other): |
1445 if isinstance(other, JavaConfig): | |
1446 return cmp(self.javaCompliance, other.javaCompliance) | |
1447 raise TypeError() | |
1448 | |
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
|
1449 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
|
1450 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
|
1451 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
|
1452 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
|
1453 return [self.java] + args |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1454 |
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
|
1455 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
|
1456 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
|
1457 |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1458 def bootclasspath(self): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1459 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
|
1460 self._init_classpaths() |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1461 return self._bootclasspath |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1462 |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1463 def extdirs(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1464 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
|
1465 self._init_classpaths() |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1466 return self._extdirs |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1467 |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1468 def endorseddirs(self): |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1469 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
|
1470 self._init_classpaths() |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1471 return self._endorseddirs |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1472 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1473 def check_get_env(key): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1474 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1475 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
|
1476 """ |
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
|
1477 value = get_env(key) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1478 if value is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1479 abort('Required environment variable ' + key + ' must be set') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1480 return value |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1481 |
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
|
1482 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
|
1483 """ |
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
|
1484 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
|
1485 """ |
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
|
1486 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
|
1487 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
|
1488 |
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
|
1489 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
|
1490 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
|
1491 log(msg) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1492 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1493 def log(msg=None): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1494 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1495 Write a message to the console. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1496 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
|
1497 to redirect it. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1498 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1499 if msg is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1500 print |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1501 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1502 print msg |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1503 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1504 def expand_project_in_class_path_arg(cpArg): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1505 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1506 for part in cpArg.split(os.pathsep): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1507 if part.startswith('@'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1508 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
|
1509 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1510 cp.append(part) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1511 return os.pathsep.join(cp) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1512 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1513 def expand_project_in_args(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1514 for i in range(len(args)): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1515 if args[i] == '-cp' or args[i] == '-classpath': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1516 if i + 1 < len(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1517 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
|
1518 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1519 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1520 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1521 def gmake_cmd(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1522 for a in ['make', 'gmake', 'gnumake']: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1523 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1524 output = subprocess.check_output([a, '--version']) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1525 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
|
1526 return a |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1527 except: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1528 pass |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1529 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
|
1530 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1531 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
|
1532 result = expandvars(value) |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1533 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
|
1534 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
|
1535 return result |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1536 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
1537 def _send_sigquit(): |
14136
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1538 p, args = _currentSubprocess |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1539 |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1540 def _isJava(): |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1541 if args: |
14155 | 1542 name = args[0].split(os.sep)[-1] |
14136
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1543 return name == "java" |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1544 return False |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1545 |
38c0db058dcd
mx: check if it's a java process before sending sigquit
Bernhard Urban <bernhard.urban@jku.at>
parents:
14135
diff
changeset
|
1546 if p is not None and _isJava(): |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1547 if get_os() == 'windows': |
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1548 log("mx: implement me! want to send SIGQUIT to my child process") |
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1549 else: |
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1550 _kill_process_group(p.pid, sig=signal.SIGQUIT) |
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1551 time.sleep(0.1) |
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
1552 |
14781
d2038d372cd2
changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
14775
diff
changeset
|
1553 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1554 def abort(codeOrMessage): |
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 Aborts the program with a SystemExit exception. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1557 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
|
1558 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
|
1559 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
|
1560 """ |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1561 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
1562 if _opts.killwithsigquit: |
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
1563 _send_sigquit() |
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
1564 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1565 # import traceback |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1566 # traceback.print_stack() |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1567 p, _ = _currentSubprocess |
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1568 if p is not None: |
4252
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1569 if get_os() == 'windows': |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1570 p.kill() |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
1571 else: |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
1572 _kill_process_group(p.pid, signal.SIGKILL) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1573 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1574 raise SystemExit(codeOrMessage) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1575 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1576 def download(path, urls, verbose=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1577 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1578 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
|
1579 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
|
1580 is written to the file indicated by 'path'. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1581 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1582 d = dirname(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1583 if d != '' and not exists(d): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1584 os.makedirs(d) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1585 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1586 |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1587 if not path.endswith(os.sep): |
14914
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1588 # Try it with the Java tool first since it can show a progress counter |
a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14913
diff
changeset
|
1589 myDir = dirname(__file__) |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1590 javaSource = join(myDir, 'URLConnectionDownload.java') |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1591 javaClass = join(myDir, 'URLConnectionDownload.class') |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1592 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1593 subprocess.check_call([java().javac, '-d', myDir, javaSource]) |
7787
2865133eeef2
mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7778
diff
changeset
|
1594 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0: |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1595 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1596 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1597 def url_open(url): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1598 userAgent = 'Mozilla/5.0 (compatible)' |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1599 headers = {'User-Agent' : userAgent} |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1600 req = urllib2.Request(url, headers=headers) |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1601 return urllib2.urlopen(req) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1602 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1603 for url in urls: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1604 try: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
1605 if verbose: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1606 log('Downloading ' + url + ' to ' + path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1607 if url.startswith('zip:') or url.startswith('jar:'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1608 i = url.find('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1609 if i == -1: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1610 abort('Zip or jar URL does not contain "!/": ' + url) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1611 url, _, entry = url[len('zip:'):].partition('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1612 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1613 data = f.read() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1614 zipdata = StringIO.StringIO(f.read()) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1615 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1616 zf = zipfile.ZipFile(zipdata, 'r') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1617 data = zf.read(entry) |
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
|
1618 with open(path, 'wb') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1619 f.write(data) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1620 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1621 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1622 data = f.read() |
6350
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1623 if path.endswith(os.sep): |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1624 # Scrape directory listing for relative URLs |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1625 hrefs = re.findall(r' href="([^"]*)"', data) |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1626 if len(hrefs) != 0: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1627 for href in hrefs: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1628 if not '/' in href: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1629 download(join(path, href), [url + href], verbose) |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1630 else: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1631 log('no locals hrefs scraped from ' + url) |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1632 else: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1633 with open(path, 'wb') as f: |
f45d5cb03c3b
added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents:
6335
diff
changeset
|
1634 f.write(data) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1635 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1636 except IOError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1637 log('Error reading from ' + url + ': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1638 except zipfile.BadZipfile as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1639 log('Error in zip file downloaded from ' + url + ': ' + str(e)) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1640 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
1641 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
|
1642 '\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
|
1643 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1644 def update_file(path, content): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1645 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1646 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
|
1647 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
|
1648 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1649 existed = exists(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1650 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1651 old = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1652 if existed: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1653 with open(path, 'rb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1654 old = f.read() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1655 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1656 if old == content: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1657 return False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1658 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1659 with open(path, 'wb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1660 f.write(content) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1661 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1662 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
|
1663 return True |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1664 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
|
1665 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
|
1666 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1667 # Builtin commands |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1668 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1669 def build(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1670 """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
|
1671 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1672 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
|
1673 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
|
1674 |
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
|
1675 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
|
1676 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
|
1677 parser = ArgumentParser(prog='mx build') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1678 |
13481
d3bd7a3bbb2b
added support for JDT environment variable which forces all Java source compilation to use the Eclipse batch compiler, including compilation as part of other commands such as eclipseinit
Doug Simon <doug.simon@oracle.com>
parents:
13480
diff
changeset
|
1679 defaultEcjPath = get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
1680 |
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
|
1681 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
|
1682 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
|
1683 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
14763 | 1684 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
|
1685 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
|
1686 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
|
1687 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
|
1688 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
|
1689 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
13927
91699ee4e4fa
mx: add option for forcing the usage of javac
Bernhard Urban <bernhard.urban@jku.at>
parents:
13923
diff
changeset
|
1690 parser.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not') |
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
|
1691 parser.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>') |
5778
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1692 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1693 parser.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1694 |
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
|
1695 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
|
1696 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
|
1697 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1698 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
|
1699 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1700 jdtJar = None |
13927
91699ee4e4fa
mx: add option for forcing the usage of javac
Bernhard Urban <bernhard.urban@jku.at>
parents:
13923
diff
changeset
|
1701 if not args.javac and args.jdt is not None: |
13923
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1702 if not args.jdt.endswith('.jar'): |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1703 abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt) |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1704 jdtJar = args.jdt |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1705 if not exists(jdtJar): |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1706 if os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath) and get_env('JDT', None) is None: |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1707 # Silently ignore JDT if default location is used but does not exist |
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
|
1708 jdtJar = None |
13923
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1709 else: |
1472b8d3f142
abort if bad --jdt argument given to 'mx build; command
Doug Simon <doug.simon@oracle.com>
parents:
13855
diff
changeset
|
1710 abort('Eclipse batch compiler jar does not exist: ' + args.jdt) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1711 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1712 built = set() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1713 |
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
|
1714 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
|
1715 # 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
|
1716 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
|
1717 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
|
1718 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
|
1719 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
|
1720 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
|
1721 projectNames = None |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
1722 |
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
|
1723 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
|
1724 # 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
|
1725 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
|
1726 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
1727 if args.java: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
1728 ideinit([], refreshOnly=True, buildProcessorJars=False) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
1729 |
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
|
1730 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
|
1731 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
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 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
|
1738 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
|
1739 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
|
1740 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
|
1741 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
|
1742 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
|
1743 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
|
1744 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
|
1745 |
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
|
1746 for p in sortedProjects: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1747 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1748 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1749 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
|
1750 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1751 if args.clean: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1752 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
|
1753 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1754 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
|
1755 built.add(p.name) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1756 continue |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1757 else: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1758 if not args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1759 continue |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1760 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
|
1761 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1762 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1763 # skip building this Java project if its Java compliance level is "higher" than the configured JDK |
14763 | 1764 requiredCompliance = p.javaCompliance if p.javaCompliance else JavaCompliance(args.compliance) if args.compliance else None |
1765 jdk = java(requiredCompliance) | |
1766 if not jdk: | |
1767 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, requiredCompliance)) | |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1768 continue |
14763 | 1769 compliance = str(jdk.javaCompliance) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1770 |
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
|
1771 outputDir = prepareOutputDirs(p, args.clean) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1772 |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
1773 cp = classpath(p.name, includeSelf=True) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1774 sourceDirs = p.source_dirs() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1775 mustBuild = args.force |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1776 if not mustBuild: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1777 for dep in p.all_deps([], False): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1778 if dep.name in built: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1779 mustBuild = True |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1780 |
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
|
1781 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1782 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
|
1783 javafilelist = [] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1784 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1785 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
|
1786 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
|
1787 javafilelist += javafiles |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1788 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1789 # 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
|
1790 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
|
1791 for src in nonjavafilelist: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1792 if src.endswith('.jasm'): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1793 className = None |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1794 with open(src) as f: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1795 for line in f: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1796 if line.startswith('.class '): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1797 className = line.split()[-1] |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1798 break |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1799 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1800 if className is not None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1801 jasminOutputDir = p.jasmin_output_dir() |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1802 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
|
1803 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
|
1804 if jasminAvailable is None: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1805 try: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1806 with open(os.devnull) as devnull: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1807 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
|
1808 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
|
1809 except OSError: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1810 jasminAvailable = False |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1811 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1812 if jasminAvailable: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1813 log('Assembling Jasmin file ' + src) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1814 run(['jasmin', '-d', jasminOutputDir, src]) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1815 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1816 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
|
1817 with file(classFile, 'a'): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1818 os.utime(classFile, None) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1819 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1820 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1821 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
|
1822 else: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1823 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
|
1824 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
|
1825 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
|
1826 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
|
1827 shutil.copyfile(src, dst) |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1828 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1829 if not mustBuild: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1830 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
|
1831 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
|
1832 if not classfile.exists() or classfile.isOlderThan(javafile): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1833 mustBuild = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1834 break |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1835 |
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
|
1836 aps = p.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
|
1837 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
|
1838 if apsOutOfDate: |
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
|
1839 logv('[annotation processors for {0} changed]'.format(p.name)) |
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
|
1840 mustBuild = True |
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
|
1841 |
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
|
1842 if not mustBuild: |
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
|
1843 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
|
1844 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1845 |
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
|
1846 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
|
1847 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
|
1848 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
|
1849 |
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
|
1850 # Ensure that the output directories are clean |
12641
851aa5341214
moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents:
12640
diff
changeset
|
1851 # prepareOutputDirs(p, True) |
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
|
1852 |
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
|
1853 built.add(p.name) |
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
|
1854 |
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
|
1855 argfileName = join(p.dir, 'javafilelist.txt') |
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
|
1856 argfile = open(argfileName, 'wb') |
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
|
1857 argfile.write('\n'.join(javafilelist)) |
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
|
1858 argfile.close() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1859 |
11189
8ce168d68d49
Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents:
10585
diff
changeset
|
1860 processorArgs = [] |
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
|
1861 |
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
|
1862 if len(aps) > 0: |
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
|
1863 processorPath = classpath(aps, resolve=True) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1864 genDir = p.source_gen_dir() |
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
|
1865 if exists(genDir): |
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
|
1866 shutil.rmtree(genDir) |
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
|
1867 os.mkdir(genDir) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1868 processorArgs += ['-processorpath', join(processorPath), '-s', genDir] |
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
|
1869 else: |
11189
8ce168d68d49
Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents:
10585
diff
changeset
|
1870 processorArgs += ['-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
|
1871 |
5778
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1872 toBeDeleted = [argfileName] |
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
|
1873 try: |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1874 if not jdtJar: |
14915
32121774dfea
When building with javac, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14914
diff
changeset
|
1875 mainJava = java() |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1876 if not args.error_prone: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1877 log('Compiling Java sources for {0} with javac...'.format(p.name)) |
14915
32121774dfea
When building with javac, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14914
diff
changeset
|
1878 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1879 if jdk.debug_port is not None: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1880 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1881 javacCmd += processorArgs |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1882 javacCmd += ['@' + argfile.name] |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1883 |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1884 if not args.warnAPI: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1885 javacCmd.append('-XDignore.symbol.file') |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1886 run(javacCmd) |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1887 else: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1888 log('Compiling Java sources for {0} with javac (with error-prone)...'.format(p.name)) |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1889 javaArgs = ['-Xmx1g'] |
14915
32121774dfea
When building with javac, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14914
diff
changeset
|
1890 javacArgs = ['-g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
14913
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1891 javacArgs += processorArgs |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1892 javacArgs += ['@' + argfile.name] |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1893 if not args.warnAPI: |
2d1cc640512c
Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14907
diff
changeset
|
1894 javacArgs.append('-XDignore.symbol.file') |
14915
32121774dfea
When building with javac, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14914
diff
changeset
|
1895 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) |
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
|
1896 else: |
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
|
1897 log('Compiling Java sources for {0} with JDT...'.format(p.name)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1898 |
14917
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1899 jdtVmArgs = ['-Xmx1g', '-jar', jdtJar] |
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1900 |
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1901 jdtArgs = ['-' + compliance, |
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
|
1902 '-cp', cp, '-g', '-enableJavadoc', |
14917
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1903 '-d', outputDir, |
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1904 '-bootclasspath', jdk.bootclasspath(), |
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1905 '-endorseddirs', jdk.endorseddirs(), |
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1906 '-extdirs', jdk.extdirs()] |
11189
8ce168d68d49
Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents:
10585
diff
changeset
|
1907 jdtArgs += processorArgs |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1908 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1909 |
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
|
1910 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
1911 rootJdtProperties = join(p.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs') |
7787
2865133eeef2
mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7778
diff
changeset
|
1912 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): |
5072
f6503609a12d
Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents:
5071
diff
changeset
|
1913 # Try to fix a missing properties file by running eclipseinit |
7293
4974776828ec
Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7291
diff
changeset
|
1914 eclipseinit([], buildProcessorJars=False) |
5072
f6503609a12d
Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents:
5071
diff
changeset
|
1915 if not exists(jdtProperties): |
f6503609a12d
Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents:
5071
diff
changeset
|
1916 log('JDT properties file {0} not found'.format(jdtProperties)) |
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
|
1917 else: |
5778
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1918 # convert all warnings to errors |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1919 if args.jdt_warning_as_error: |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1920 jdtPropertiesTmp = jdtProperties + '.tmp' |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1921 with open(jdtProperties) as fp: |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1922 content = fp.read().replace('=warning', '=error') |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1923 with open(jdtPropertiesTmp, 'w') as fp: |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1924 fp.write(content) |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1925 toBeDeleted.append(jdtPropertiesTmp) |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1926 jdtArgs += ['-properties', jdtPropertiesTmp] |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1927 else: |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1928 jdtArgs += ['-properties', jdtProperties] |
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
|
1929 jdtArgs.append('@' + argfile.name) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1930 |
14917
3e06a56ab0e6
When building with JDT, use the one from JAVA_HOME but set the booclasspath, extdirs and endorseddirs to the correct JDK for cross-compilation.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14916
diff
changeset
|
1931 run_java(jdtVmArgs + jdtArgs) |
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
|
1932 finally: |
5778
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1933 for n in toBeDeleted: |
74c802348d1f
added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents:
5771
diff
changeset
|
1934 os.remove(n) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
1935 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1936 for dist in _dists.values(): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
1937 archive(['@' + dist.name]) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
1938 |
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
|
1939 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
|
1940 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
|
1941 return None |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1942 |
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
|
1943 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
|
1944 """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
|
1945 |
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
|
1946 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
|
1947 |
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
|
1948 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
|
1949 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
|
1950 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
|
1951 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
|
1952 |
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
|
1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 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
|
1958 |
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
|
1959 # 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
|
1960 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
|
1961 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
|
1962 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
|
1963 |
6fb61ad67962
Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14539
diff
changeset
|
1964 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
|
1965 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
|
1966 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
|
1967 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
|
1968 |
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
|
1969 eclipseinit([], buildProcessorJars=False) |
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
|
1970 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1971 # build list of projects to be processed |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1972 projects = sorted_deps() |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1973 if args.projects is not None: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1974 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
|
1975 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1976 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
|
1977 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
|
1978 self.path = join(settingsDir, 'org.eclipse.jdt.core.prefs') |
14763 | 1979 self.javaCompliance = javaCompliance |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1980 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
|
1981 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
|
1982 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
|
1983 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
|
1984 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
|
1985 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
|
1986 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1987 def settings(self): |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1988 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
|
1989 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
|
1990 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1991 class FileInfo: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1992 def __init__(self, path): |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1993 self.path = path |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1994 with open(path) as fp: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1995 self.content = fp.read() |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1996 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
|
1997 |
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
|
1998 def update(self, removeTrailingWhitespace): |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
1999 with open(self.path) as fp: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2000 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
|
2001 |
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
|
2002 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
|
2003 # 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
|
2004 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
|
2005 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
|
2006 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
|
2007 # 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
|
2008 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
|
2009 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
|
2010 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2011 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
|
2012 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
|
2013 self.content = content |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2014 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
|
2015 |
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
|
2016 # reset access and modification time of file |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2017 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
|
2018 |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2019 modified = list() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2020 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
|
2021 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
|
2022 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
|
2023 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
|
2024 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
|
2025 |
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
|
2026 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
|
2027 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2028 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
|
2029 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
|
2030 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
|
2031 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
|
2032 |
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
|
2033 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
|
2034 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
|
2035 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
|
2036 batch.javafiles.append(FileInfo(f)) |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2037 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
|
2038 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
|
2039 continue |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2040 |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2041 res = batches.setdefault(batch.settings(), batch) |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2042 if res is not batch: |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2043 res.javafiles = res.javafiles + batch.javafiles |
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2044 |
14763 | 2045 print "we have: " + str(len(batches)) + " batches" |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2046 for batch in batches.itervalues(): |
14763 | 2047 run([args.eclipse_exe, |
2048 '-nosplash', | |
2049 '-application', | |
2050 'org.eclipse.jdt.core.JavaCodeFormatter', | |
2051 '-vm', java(batch.javaCompliance).java, | |
2052 '-config', batch.path] | |
2053 + [f.path for f in batch.javafiles]) | |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2054 for fi in batch.javafiles: |
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
|
2055 if fi.update(batch.removeTrailingWhitespace): |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2056 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
|
2057 |
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
|
2058 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
|
2059 |
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
|
2060 if len(modified) != 0: |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2061 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
|
2062 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
|
2063 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
|
2064 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
|
2065 for fi in modified: |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2066 name = os.path.relpath(fi.path, arcbase) |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2067 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
|
2068 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
|
2069 log(''.join(fi.diff)) |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2070 if args.backup: |
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2071 arcname = name.replace(os.sep, '/') |
7528
4584ca2618d5
made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents:
7524
diff
changeset
|
2072 zf.writestr(arcname, fi.content) |
13288
9c3c915b5f56
Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13266
diff
changeset
|
2073 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
|
2074 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
|
2075 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
|
2076 return 1 |
7533
29b0768b7ba6
added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents:
7532
diff
changeset
|
2077 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
|
2078 |
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
|
2079 def processorjars(): |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2080 for s in suites(True): |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2081 _processorjars_suite(s) |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2082 |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2083 def _processorjars_suite(s): |
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
|
2084 projs = set() |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2085 candidates = sorted_project_deps(s.projects) |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2086 for p in candidates: |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2087 if _isAnnotationProcessorDependency(p): |
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
|
2088 projs.add(p) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2089 |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2090 if len(projs) <= 0: |
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
|
2091 return [] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2092 |
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
|
2093 pnames = [p.name for p in projs] |
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
|
2094 build(['--projects', ",".join(pnames)]) |
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
|
2095 return archive(pnames) |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2096 |
11777
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2097 def pylint(args): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2098 """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
|
2099 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2100 parser = ArgumentParser(prog='mx pylint') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2101 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
|
2102 args = parser.parse_args(args) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2103 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2104 rcfile = join(dirname(__file__), '.pylintrc') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2105 if not exists(rcfile): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2106 log('pylint configuration file does not exist: ' + rcfile) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2107 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2108 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2109 try: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2110 output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2111 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
|
2112 if not m: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2113 log('could not determine pylint version from ' + output) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2114 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2115 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
|
2116 if major < 1: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2117 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
|
2118 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2119 except BaseException: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2120 log('pylint is not available') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2121 return |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2122 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2123 def findfiles_by_walk(): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2124 result = [] |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2125 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2126 for root, dirs, files in os.walk(suite.dir): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2127 for f in files: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2128 if f.endswith('.py'): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2129 pyfile = join(root, f) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2130 result.append(pyfile) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2131 if 'bin' in dirs: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2132 dirs.remove('bin') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2133 if 'lib' in dirs: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2134 # avoids downloaded .py files |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2135 dirs.remove('lib') |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2136 return result |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2137 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2138 def findfiles_by_hg(): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2139 result = [] |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2140 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2141 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
|
2142 for f in versioned: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2143 if f.endswith('.py') and exists(f): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2144 result.append(f) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2145 return result |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2146 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2147 # 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
|
2148 if args.walk: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2149 pyfiles = findfiles_by_walk() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2150 else: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2151 pyfiles = findfiles_by_hg() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2152 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2153 env = os.environ.copy() |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2154 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2155 pythonpath = dirname(__file__) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2156 for suite in suites(True): |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2157 pythonpath = os.pathsep.join([pythonpath, suite.mxDir]) |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2158 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2159 env['PYTHONPATH'] = pythonpath |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2160 |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2161 for pyfile in pyfiles: |
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
2162 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
|
2163 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
|
2164 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2165 def archive(args): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2166 """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
|
2167 parser = ArgumentParser(prog='mx archive') |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2168 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
|
2169 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
|
2170 |
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
|
2171 archives = [] |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2172 for name in args.names: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2173 if name.startswith('@'): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2174 dname = name[1:] |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2175 d = distribution(dname) |
8183
4b11a0983557
fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents:
8182
diff
changeset
|
2176 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2177 if d.sourcesPath: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2178 sourcesFd, sourcesTmp = tempfile.mkstemp(suffix='', prefix=basename(d.sourcesPath) + '.', dir=dirname(d.sourcesPath)) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2179 else: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2180 sourcesTmp = None |
8457
b27261747964
mx: merge provider configuration files in distribution jars
Roland Schatz <roland.schatz@oracle.com>
parents:
8447
diff
changeset
|
2181 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2182 |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2183 def overwriteCheck(zf, arcname, source): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2184 if arcname in zf.namelist(): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2185 log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2186 |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2187 try: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2188 zf = zipfile.ZipFile(tmp, 'w') |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2189 szf = zipfile.ZipFile(sourcesTmp, 'w') if sourcesTmp else None |
14775
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
2190 for dep in d.sorted_deps(includeLibs=True): |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2191 if dep.isLibrary(): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2192 l = dep |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2193 # merge library jar into distribution jar |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2194 logv('[' + d.path + ': adding library ' + l.name + ']') |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2195 lpath = l.get_path(resolve=True) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2196 libSourcePath = l.get_source_path(resolve=True) |
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
|
2197 if lpath: |
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
|
2198 with zipfile.ZipFile(lpath, 'r') as lp: |
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
|
2199 for arcname in lp.namelist(): |
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
|
2200 if arcname.startswith('META-INF/services/') and not arcname == 'META-INF/services/': |
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
|
2201 f = arcname[len('META-INF/services/'):].replace('/', os.sep) |
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
|
2202 with open(join(services, f), 'a') as outfile: |
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
|
2203 for line in lp.read(arcname).splitlines(): |
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
|
2204 outfile.write(line) |
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
|
2205 else: |
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
|
2206 overwriteCheck(zf, arcname, lpath + '!' + arcname) |
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
|
2207 zf.writestr(arcname, lp.read(arcname)) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2208 if szf and libSourcePath: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2209 with zipfile.ZipFile(libSourcePath, 'r') as lp: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2210 for arcname in lp.namelist(): |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2211 overwriteCheck(szf, arcname, lpath + '!' + arcname) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2212 szf.writestr(arcname, lp.read(arcname)) |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2213 else: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2214 p = dep |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2215 # skip a Java project if its Java compliance level is "higher" than the configured JDK |
14763 | 2216 jdk = java(p.javaCompliance) |
2217 if not jdk: | |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2218 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path)) |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2219 continue |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2220 |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2221 logv('[' + d.path + ': adding project ' + p.name + ']') |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2222 outputDir = p.output_dir() |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2223 for root, _, files in os.walk(outputDir): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2224 relpath = root[len(outputDir) + 1:] |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2225 if relpath == join('META-INF', 'services'): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2226 for f in files: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2227 with open(join(services, f), 'a') as outfile: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2228 with open(join(root, f), 'r') as infile: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2229 for line in infile: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2230 outfile.write(line) |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2231 elif relpath == join('META-INF', 'providers'): |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2232 for f in files: |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2233 with open(join(root, f), 'r') as infile: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2234 for line in infile: |
10576
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2235 with open(join(services, line.strip()), 'a') as outfile: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2236 outfile.write(f + '\n') |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2237 else: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2238 for f in files: |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2239 arcname = join(relpath, f).replace(os.sep, '/') |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2240 overwriteCheck(zf, arcname, join(root, f)) |
aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents:
10568
diff
changeset
|
2241 zf.write(join(root, f), arcname) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2242 if szf: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2243 for srcDir in p.source_dirs(): |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2244 for root, _, files in os.walk(srcDir): |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2245 relpath = root[len(srcDir) + 1:] |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2246 for f in files: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2247 if f.endswith('.java'): |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2248 arcname = join(relpath, f).replace(os.sep, '/') |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2249 overwriteCheck(szf, arcname, join(root, f)) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2250 szf.write(join(root, f), arcname) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2251 |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2252 for f in os.listdir(services): |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2253 arcname = join('META-INF', 'services', f).replace(os.sep, '/') |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2254 zf.write(join(services, f), arcname) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2255 zf.close() |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2256 os.close(fd) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2257 shutil.rmtree(services) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2258 # Atomic on Unix |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2259 shutil.move(tmp, d.path) |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
2260 # 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
|
2261 os.chmod(d.path, 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
|
2262 archives.append(d.path) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2263 |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2264 if szf: |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2265 szf.close() |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2266 os.close(sourcesFd) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2267 shutil.move(sourcesTmp, d.sourcesPath) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2268 os.chmod(d.sourcesPath, 0o666 & ~currentUmask) |
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
2269 |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2270 d.notify_updated() |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2271 finally: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2272 if exists(tmp): |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2273 os.remove(tmp) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2274 if exists(services): |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2275 shutil.rmtree(services) |
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
|
2276 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2277 else: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2278 p = project(name) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2279 outputDir = p.output_dir() |
8183
4b11a0983557
fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents:
8182
diff
changeset
|
2280 fd, tmp = tempfile.mkstemp(suffix='', prefix=p.name, dir=p.dir) |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2281 try: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2282 zf = zipfile.ZipFile(tmp, 'w') |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2283 for root, _, files in os.walk(outputDir): |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2284 for f in files: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2285 relpath = root[len(outputDir) + 1:] |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2286 arcname = join(relpath, f).replace(os.sep, '/') |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2287 zf.write(join(root, f), arcname) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2288 zf.close() |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2289 os.close(fd) |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2290 # Atomic on Unix |
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
|
2291 jarFile = join(p.dir, p.name + '.jar') |
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
|
2292 shutil.move(tmp, jarFile) |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
2293 # 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
|
2294 os.chmod(jarFile, 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
|
2295 archives.append(jarFile) |
8585
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2296 finally: |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2297 if exists(tmp): |
aaf3988bd1b4
made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents:
8528
diff
changeset
|
2298 os.remove(tmp) |
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
|
2299 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
|
2300 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2301 def canonicalizeprojects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2302 """process all project files to canonicalize the dependencies |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2303 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2304 The exit code of this command reflects how many files were updated.""" |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2305 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2306 changedFiles = 0 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
2307 for s in suites(True): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2308 projectsFile = join(s.mxDir, 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2309 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2310 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2311 with open(projectsFile) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2312 out = StringIO.StringIO() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2313 pattern = re.compile('project@([^@]+)@dependencies=.*') |
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
|
2314 lineNo = 1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2315 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2316 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2317 m = pattern.match(line) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2318 if m is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2319 out.write(line + '\n') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2320 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2321 p = project(m.group(1)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2322 |
6533
250babea75d5
modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents:
6527
diff
changeset
|
2323 for pkg in p.defined_java_packages(): |
250babea75d5
modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents:
6527
diff
changeset
|
2324 if not pkg.startswith(p.name): |
250babea75d5
modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents:
6527
diff
changeset
|
2325 abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2326 |
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
|
2327 ignoredDeps = set([name for name in p.deps if project(name, False) 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
|
2328 for pkg in p.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
|
2329 for name in p.deps: |
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
|
2330 dep = project(name, 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
|
2331 if dep is 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
|
2332 ignoredDeps.discard(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
|
2333 else: |
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
|
2334 if pkg in dep.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
|
2335 ignoredDeps.discard(name) |
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
|
2336 if pkg in dep.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
|
2337 ignoredDeps.discard(name) |
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
|
2338 if len(ignoredDeps) != 0: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2339 candidates = 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
|
2340 # Compute dependencies based on projects required by p |
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
|
2341 for d in sorted_deps(): |
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
|
2342 if not d.defined_java_packages().isdisjoint(p.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
|
2343 candidates.add(d) |
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
|
2344 # Remove non-canonical candidates |
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
|
2345 for c in list(candidates): |
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
|
2346 candidates.difference_update(c.all_deps([], False, 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
|
2347 candidates = [d.name for d in candidates] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2348 |
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
|
2349 abort('{0}:{1}: {2} does not use any packages defined in these projects: {3}\nComputed project dependencies: {4}'.format( |
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
|
2350 projectsFile, lineNo, p, ', '.join(ignoredDeps), ','.join(candidates))) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2351 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2352 out.write('project@' + m.group(1) + '@dependencies=' + ','.join(p.canonical_deps()) + '\n') |
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
|
2353 lineNo = lineNo + 1 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2354 content = out.getvalue() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2355 if update_file(projectsFile, content): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2356 changedFiles += 1 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2357 return changedFiles |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2358 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2359 class TimeStampFile: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2360 def __init__(self, path): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2361 self.path = path |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2362 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
|
2363 |
12524
2583afcd26ee
fixed bug in creation of CreateGRAALDist.launch files
Doug Simon <doug.simon@oracle.com>
parents:
12522
diff
changeset
|
2364 def isOlderThan(self, arg): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2365 if not self.timestamp: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2366 return True |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2367 if isinstance(arg, TimeStampFile): |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2368 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
|
2369 return False |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2370 else: |
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2371 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
|
2372 elif isinstance(arg, types.ListType): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2373 files = arg |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2374 else: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2375 files = [arg] |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2376 for f in files: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2377 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
|
2378 return True |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2379 return False |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2380 |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2381 def exists(self): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2382 return exists(self.path) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2383 |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2384 def touch(self): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2385 if exists(self.path): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2386 os.utime(self.path, None) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2387 else: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2388 if not isdir(dirname(self.path)): |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2389 os.makedirs(dirname(self.path)) |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2390 file(self.path, 'a') |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2391 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2392 def checkstyle(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2393 """run Checkstyle on the Java sources |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2394 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2395 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
|
2396 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
|
2397 |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2398 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
|
2399 |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2400 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
|
2401 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
|
2402 |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2403 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
|
2404 for p in projects_opt_limit_to_suites(): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2405 if p.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2406 continue |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2407 sourceDirs = p.source_dirs() |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2408 |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2409 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
|
2410 if not exists(csConfig): |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2411 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
|
2412 |
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
|
2413 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK |
14763 | 2414 jdk = java(p.javaCompliance) |
2415 if not jdk: | |
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
|
2416 log('Excluding {0} from checking (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) |
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
|
2417 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2418 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2419 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2420 javafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2421 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
|
2422 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
|
2423 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
|
2424 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
|
2425 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2426 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2427 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
|
2428 mustCheck = False |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2429 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
|
2430 mustCheck = timestamp.isOlderThan(javafilelist) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2431 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2432 mustCheck = True |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2433 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2434 if not mustCheck: |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2435 if _opts.verbose: |
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2436 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
|
2437 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2438 |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2439 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
|
2440 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
|
2441 configLocation = localCheckConfig.getAttribute('location') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2442 configType = localCheckConfig.getAttribute('type') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2443 if configType == 'project': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2444 # Eclipse plugin "Project Relative Configuration" format: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2445 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2446 # '/<project_name>/<suffix>' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2447 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2448 if configLocation.startswith('/'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2449 name, _, suffix = configLocation.lstrip('/').partition('/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2450 config = join(project(name).dir, suffix) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2451 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2452 config = join(p.dir, configLocation) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2453 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
|
2454 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
|
2455 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2456 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2457 exclude = join(p.dir, '.checkstyle.exclude') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2458 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2459 if exists(exclude): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2460 with open(exclude) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2461 # Convert patterns to OS separators |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2462 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
|
2463 def match(name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2464 for p in patterns: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2465 if p in name: |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2466 if _opts.verbose: |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2467 log('excluding: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2468 return True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2469 return False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2470 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2471 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
|
2472 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2473 auditfileName = join(p.dir, 'checkstyleOutput.txt') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2474 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
|
2475 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2476 try: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2477 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2478 # Checkstyle is unable to read the filenames to process from a file, and the |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2479 # CreateProcess function on Windows limits the length of a command line to |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2480 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2481 # so calling Checkstyle must be done in batches. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2482 while len(javafilelist) != 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2483 i = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2484 size = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2485 while i < len(javafilelist): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2486 s = len(javafilelist[i]) + 1 |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
2487 if size + s < 30000: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2488 size += s |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2489 i += 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2490 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2491 break |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2492 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2493 batch = javafilelist[:i] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2494 javafilelist = javafilelist[i:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2495 try: |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2496 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch, nonZeroIsFatal=False) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2497 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2498 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
|
2499 errors = [] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2500 source = [None] |
9826
cff647969dfa
fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents:
9262
diff
changeset
|
2501 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
|
2502 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
|
2503 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
|
2504 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
|
2505 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
|
2506 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2507 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
|
2508 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
|
2509 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
|
2510 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
|
2511 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
|
2512 map(log, errors) |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2513 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
|
2514 else: |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2515 timestamp.touch() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2516 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2517 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2518 os.unlink(auditfileName) |
10059
4dada3ec9c58
mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents:
10058
diff
changeset
|
2519 return totalErrors |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2520 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2521 def clean(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2522 """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
|
2523 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2524 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
|
2525 generated images. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2526 """ |
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
|
2527 |
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
|
2528 suppliedParser = parser is not None |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2529 |
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
|
2530 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
|
2531 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
|
2532 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2533 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2534 args = parser.parse_args(args) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2535 |
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
|
2536 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
|
2537 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2538 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2539 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
|
2540 else: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2541 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
|
2542 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
|
2543 if genDir != '' and exists(genDir): |
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
2544 log('Clearing {0}...'.format(genDir)) |
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
2545 for f in os.listdir(genDir): |
6b540bb82312
Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents:
7681
diff
changeset
|
2546 shutil.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
|
2547 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2548 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2549 outputDir = p.output_dir() |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2550 if outputDir != '' and exists(outputDir): |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2551 log('Removing {0}...'.format(outputDir)) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
2552 shutil.rmtree(outputDir) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2553 |
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
|
2554 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
|
2555 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
|
2556 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
|
2557 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
|
2558 |
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
|
2559 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
|
2560 return args |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2561 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2562 def about(args): |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2563 """show the 'man page' for mx""" |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2564 print __doc__ |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2565 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2566 def help_(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2567 """show help for a given command |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2568 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2569 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
|
2570 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2571 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
|
2572 if len(args) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2573 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2574 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2575 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2576 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
|
2577 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
|
2578 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
|
2579 if len(hits) == 1: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
2580 name = hits[0] |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
2581 elif len(hits) == 0: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
2582 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
|
2583 else: |
e952911afd2f
made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents:
5876
diff
changeset
|
2584 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
|
2585 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2586 value = _commands[name] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2587 (func, usage) = value[:2] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2588 doc = func.__doc__ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2589 if len(value) > 2: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2590 docArgs = value[2:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2591 fmtArgs = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2592 for d in docArgs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2593 if isinstance(d, Callable): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
2594 fmtArgs += [d()] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2595 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2596 fmtArgs += [str(d)] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2597 doc = doc.format(*fmtArgs) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2598 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
|
2599 |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2600 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
|
2601 """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
|
2602 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
2603 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
|
2604 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
|
2605 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
|
2606 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
2607 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
|
2608 |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
2609 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
|
2610 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
|
2611 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
|
2612 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
|
2613 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
|
2614 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
|
2615 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
|
2616 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
|
2617 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
|
2618 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
|
2619 igv.open('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
|
2620 for p in sorted_deps(includeLibs=True): |
a9f750305a38
added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents:
12571
diff
changeset
|
2621 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
|
2622 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
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 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
|
2628 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
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 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
|
2634 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
|
2635 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
|
2636 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
|
2637 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
|
2638 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
|
2639 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
|
2640 igv.close('graphDocument') |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2641 |
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
|
2642 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
|
2643 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
|
2644 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
|
2645 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
|
2646 else: |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2647 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
|
2648 return |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2649 |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2650 print 'digraph projects {' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2651 print 'rankdir=BT;' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2652 print 'node [shape=rect];' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2653 for p in projects(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2654 for dep in p.canonical_deps(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2655 print '"' + p.name + '"->"' + dep + '"' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
2656 print '}' |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2657 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2658 def _source_locator_memento(deps): |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2659 slm = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2660 slm.open('sourceLookupDirector') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2661 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
|
2662 |
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
|
2663 javaCompliance = None |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2664 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
|
2665 if dep.isLibrary(): |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2666 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
|
2667 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
|
2668 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
|
2669 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
|
2670 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
|
2671 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.debug.core.containerType.externalArchive'}) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2672 else: |
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
|
2673 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
|
2674 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'}) |
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
|
2675 if javaCompliance is None or dep.javaCompliance < 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
|
2676 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
|
2677 |
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
|
2678 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
|
2679 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
|
2680 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
|
2681 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
|
2682 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
|
2683 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
|
2684 |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2685 slm.close('sourceContainers') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2686 slm.close('sourceLookupDirector') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2687 return slm |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2688 |
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
|
2689 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
|
2690 """ |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2691 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
|
2692 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2693 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
|
2694 deps = [] |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2695 slm = _source_locator_memento(deps) |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2696 launch = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2697 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
|
2698 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
|
2699 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
|
2700 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
|
2701 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
|
2702 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
|
2703 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
|
2704 launch.close('mapAttribute') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2705 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
|
2706 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
|
2707 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
|
2708 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
|
2709 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2710 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
|
2711 if len(suites()) == 1: |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
2712 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
|
2713 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
|
2714 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
|
2715 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
|
2716 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
|
2717 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
|
2718 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
|
2719 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
|
2720 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
|
2721 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2722 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
|
2723 """ |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2724 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
|
2725 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2726 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
|
2727 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
|
2728 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
|
2729 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
|
2730 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
|
2731 cp = None |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2732 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
|
2733 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
|
2734 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
|
2735 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
|
2736 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
|
2737 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
|
2738 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
|
2739 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
|
2740 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
|
2741 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
|
2742 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
|
2743 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
|
2744 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
|
2745 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
|
2746 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
|
2747 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
|
2748 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
|
2749 break |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2750 |
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
|
2751 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
|
2752 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
|
2753 return False |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2754 |
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
|
2755 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
|
2756 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
|
2757 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
|
2758 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
|
2759 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
|
2760 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
|
2761 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
|
2762 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
|
2763 |
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
|
2764 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
|
2765 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
|
2766 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
|
2767 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
|
2768 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
|
2769 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2770 slm = _source_locator_memento(deps) |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2771 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2772 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
|
2773 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
|
2774 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
|
2775 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
|
2776 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
|
2777 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
|
2778 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
|
2779 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
|
2780 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
|
2781 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
|
2782 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
|
2783 |
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
|
2784 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
|
2785 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
|
2786 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
|
2787 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
|
2788 |
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
|
2789 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
|
2790 """(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
|
2791 for s in suites(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
|
2792 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
2793 |
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
|
2794 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
|
2795 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
2796 def _check_ide_timestamp(suite, configZip, ide): |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
2797 """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
|
2798 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
|
2799 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
|
2800 return False |
12630
aadb188e4258
mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents:
12620
diff
changeset
|
2801 # 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
|
2802 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
|
2803 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
|
2804 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
2805 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
|
2806 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
|
2807 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
|
2808 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
|
2809 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
|
2810 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
|
2811 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
|
2812 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
|
2813 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
2814 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
|
2815 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
|
2816 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
|
2817 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
|
2818 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2819 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
2820 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
|
2821 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
|
2822 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
2823 |
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
|
2824 files = [] |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
2825 libFiles = [] |
7293
4974776828ec
Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7291
diff
changeset
|
2826 if buildProcessorJars: |
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
|
2827 files += _processorjars_suite(suite) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2828 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2829 projToDist = dict() |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2830 for dist in _dists.values(): |
14775
40aa1eb176db
mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents:
14764
diff
changeset
|
2831 distDeps = dist.sorted_deps() |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2832 for p in distDeps: |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2833 projToDist[p.name] = (dist, [dep.name for dep in distDeps]) |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2834 |
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
|
2835 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
|
2836 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
|
2837 continue |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2838 |
14763 | 2839 if not java(p.javaCompliance): |
2840 log('Excluding {0} (JDK with compliance level {1} not available)'.format(p.name, p.javaCompliance)) | |
2841 continue | |
2842 | |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2843 if not exists(p.dir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2844 os.makedirs(p.dir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2845 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2846 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2847 out.open('classpath') |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
2848 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2849 for src in p.srcDirs: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2850 srcDir = join(p.dir, src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2851 if not exists(srcDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2852 os.mkdir(srcDir) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2853 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2854 |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
2855 if len(p.annotation_processors()) > 0: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2856 genDir = p.source_gen_dir() |
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
|
2857 if not exists(genDir): |
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
|
2858 os.mkdir(genDir) |
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
|
2859 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) |
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
|
2860 files.append(genDir) |
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
|
2861 |
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
|
2862 # Every Java program depends on a JRE |
13247
e709633d87c6
Use java compilance from project in eclipse settings for compilance, source and target
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13243
diff
changeset
|
2863 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2864 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2865 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
|
2866 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'}) |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2867 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2868 for dep in p.all_deps([], True): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2869 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
|
2870 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2871 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2872 if dep.isLibrary(): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2873 if hasattr(dep, 'eclipse.container'): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2874 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : getattr(dep, 'eclipse.container')}) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2875 elif hasattr(dep, 'eclipse.project'): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2876 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + getattr(dep, 'eclipse.project')}) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2877 else: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2878 path = dep.path |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2879 dep.get_path(resolve=True) |
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
|
2880 if not path or (not exists(path) and not dep.mustExist): |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2881 continue |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2882 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2883 if not isabs(path): |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2884 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2885 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2886 # safest to simply use absolute paths. |
11620
60e3fe0fe939
mxtool: fix eclipseinit to use project suite dir for included suites
Mick Jordan <mick.jordan@oracle.com>
parents:
11605
diff
changeset
|
2887 path = join(p.suite.dir, path) |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2888 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2889 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path} |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2890 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2891 sourcePath = dep.get_source_path(resolve=True) |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2892 if sourcePath is not None: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2893 attributes['sourcepath'] = sourcePath |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
2894 out.element('classpathentry', attributes) |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
2895 libFiles.append(path) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2896 else: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2897 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name}) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2898 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2899 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2900 out.close('classpath') |
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
|
2901 classpathFile = join(p.dir, '.classpath') |
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
|
2902 update_file(classpathFile, out.xml(indent='\t', newl='\n')) |
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
|
2903 files.append(classpathFile) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2904 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2905 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2906 if exists(csConfig): |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2907 out = XMLDoc() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2908 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2909 dotCheckstyle = join(p.dir, ".checkstyle") |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2910 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2911 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2912 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2913 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2914 out.close('local-check-config') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2915 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2916 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2917 out.close('fileset') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2918 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2919 out.element('filter-data', {'value' : 'java'}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2920 out.close('filter') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2921 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2922 exclude = join(p.dir, '.checkstyle.exclude') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2923 if exists(exclude): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2924 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'}) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2925 with open(exclude) as f: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2926 for line in f: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2927 if not line.startswith('#'): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2928 line = line.strip() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2929 exclDir = join(p.dir, line) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2930 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2931 out.element('filter-data', {'value' : line}) |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2932 out.close('filter') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2933 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2934 out.close('fileset-config') |
5219
ddccd4abdb09
configured test source directory for graal.graph project
Doug Simon <doug.simon@oracle.com>
parents:
5217
diff
changeset
|
2935 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) |
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
|
2936 files.append(dotCheckstyle) |
14918
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2937 else: |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2938 # clean up existing .checkstyle file |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2939 dotCheckstyle = join(p.dir, ".checkstyle") |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2940 if exists(dotCheckstyle): |
31a9c79399c8
disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents:
14917
diff
changeset
|
2941 os.unlink(dotCheckstyle) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
2942 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
2943 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2944 out.open('projectDescription') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2945 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
|
2946 out.element('comment', data='') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2947 out.element('projects', data='') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2948 out.open('buildSpec') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2949 out.open('buildCommand') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2950 out.element('name', data='org.eclipse.jdt.core.javabuilder') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2951 out.element('arguments', data='') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2952 out.close('buildCommand') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2953 if exists(csConfig): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2954 out.open('buildCommand') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2955 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2956 out.element('arguments', data='') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2957 out.close('buildCommand') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2958 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
|
2959 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2960 out.open('buildCommand') |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2961 out.element('name', data=buildCommand) |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2962 out.element('arguments', data='') |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
2963 out.close('buildCommand') |
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
|
2964 |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
2965 # The path should always be p.name/dir. independent of where the workspace actually is. |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
2966 # So we use the parent folder of the project, whatever that is, to generate such a relative path. |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
2967 logicalWorkspaceRoot = os.path.dirname(p.dir) |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
2968 binFolder = os.path.relpath(p.output_dir(), logicalWorkspaceRoot) |
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
2969 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2970 if _isAnnotationProcessorDependency(p): |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
2971 refreshFile = os.path.relpath(join(p.dir, p.name + '.jar'), logicalWorkspaceRoot) |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
2972 _genEclipseBuilder(out, p, 'Jar', 'archive ' + p.name, refresh=True, refreshFile=refreshFile, relevantResources=[binFolder], async=True, xmlIndent='', xmlStandalone='no') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2973 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2974 if projToDist.has_key(p.name): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
2975 dist, distDeps = projToDist[p.name] |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
2976 _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, relevantResources=[binFolder], logToFile=True, refresh=False, async=True) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2977 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2978 out.close('buildSpec') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2979 out.open('natures') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2980 out.element('nature', data='org.eclipse.jdt.core.javanature') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2981 if exists(csConfig): |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2982 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
2983 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
|
2984 out.element('nature', data='org.eclipse.pde.PluginNature') |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2985 out.close('natures') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
2986 out.close('projectDescription') |
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
|
2987 projectFile = join(p.dir, '.project') |
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
|
2988 update_file(projectFile, out.xml(indent='\t', newl='\n')) |
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
|
2989 files.append(projectFile) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2990 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2991 settingsDir = join(p.dir, ".settings") |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2992 if not exists(settingsDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2993 os.mkdir(settingsDir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
2994 |
14745
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
2995 # collect the defaults from mxtool |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
2996 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings') |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
2997 esdict = {} |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
2998 if exists(defaultEclipseSettingsDir): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
2999 for name in os.listdir(defaultEclipseSettingsDir): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3000 if isfile(join(defaultEclipseSettingsDir, name)): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3001 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name)) |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3002 |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3003 # check for suite overrides |
11620
60e3fe0fe939
mxtool: fix eclipseinit to use project suite dir for included suites
Mick Jordan <mick.jordan@oracle.com>
parents:
11605
diff
changeset
|
3004 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3005 if exists(eclipseSettingsDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3006 for name in os.listdir(eclipseSettingsDir): |
14745
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3007 if isfile(join(eclipseSettingsDir, name)): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3008 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name)) |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3009 |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3010 # check for project overrides |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3011 projectSettingsDir = join(p.dir, 'eclipse-settings') |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3012 if exists(projectSettingsDir): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3013 for name in os.listdir(projectSettingsDir): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3014 if isfile(join(projectSettingsDir, name)): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3015 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3016 |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3017 # copy a possibly modified file to the project's .settings directory |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3018 for name, path in esdict.iteritems(): |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3019 # ignore this file altogether if this project has no annotation processors |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3020 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3021 continue |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3022 |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3023 with open(path) as f: |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3024 content = f.read() |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3025 content = content.replace('${javaCompliance}', str(p.javaCompliance)) |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3026 if len(p.annotation_processors()) > 0: |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3027 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3028 update_file(join(settingsDir, name), content) |
65b005b58825
Allow project-specific overrides of Eclipse configuration files
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14626
diff
changeset
|
3029 files.append(join(settingsDir, name)) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3030 |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
3031 if len(p.annotation_processors()) > 0: |
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
|
3032 out = XMLDoc() |
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
|
3033 out.open('factorypath') |
11701
e29743466d00
fixed regression in mx.py
Doug Simon <doug.simon@oracle.com>
parents:
11687
diff
changeset
|
3034 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
3035 for ap in p.annotation_processors(): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
3036 for dep in dependency(ap).all_deps([], True): |
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
|
3037 if dep.isLibrary(): |
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
|
3038 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): |
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
|
3039 if dep.mustExist: |
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
|
3040 path = dep.get_path(resolve=True) |
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
|
3041 if path: |
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
|
3042 if not isabs(path): |
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
|
3043 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse |
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
|
3044 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's |
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
|
3045 # safest to simply use absolute paths. |
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
|
3046 path = join(p.suite.dir, path) |
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
|
3047 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : '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
|
3048 files.append(path) |
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
|
3049 else: |
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
|
3050 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
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
|
3051 out.close('factorypath') |
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
|
3052 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) |
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
|
3053 files.append(join(p.dir, '.factorypath')) |
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
|
3054 |
13727
10e6f192631f
added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents:
13682
diff
changeset
|
3055 _, 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
|
3056 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
|
3057 |
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
|
3058 _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
|
3059 _zip_files(libFiles, suite.dir, configLibsZip) |
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
|
3060 |
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
|
3061 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
|
3062 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
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 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
|
3070 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
|
3071 # 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
|
3072 shutil.move(tmp, zipPath) |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
3073 # 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
|
3074 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
|
3075 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
|
3076 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
|
3077 os.remove(tmp) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3078 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3079 def _isAnnotationProcessorDependency(p): |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3080 """ |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3081 Determines if a given project is part of an annotation processor. |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3082 """ |
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
|
3083 return p in sorted_deps(annotation_processors()) |
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
|
3084 |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3085 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
|
3086 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
|
3087 launchOut = XMLDoc() |
8181
989e0582a30f
enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents:
8180
diff
changeset
|
3088 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
|
3089 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
|
3090 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
|
3091 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) |
14763 | 3092 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
|
3093 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
|
3094 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
|
3095 |
7681
f81be78f15a5
Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents:
7533
diff
changeset
|
3096 if refresh: |
12661
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3097 if refreshFile is None: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3098 refreshScope = '${project}' |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3099 else: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3100 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
|
3101 |
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3102 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
|
3103 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
|
3104 |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3105 if relevantResources is not None: |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3106 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
|
3107 for relevantResource in relevantResources: |
12684
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3108 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
|
3109 resources += '</resources>}' |
0497d6702cff
mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents:
12640
diff
changeset
|
3110 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
|
3111 |
ec224fef3012
integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents:
12662
diff
changeset
|
3112 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3113 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
|
3114 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
|
3115 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
|
3116 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
|
3117 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
|
3118 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
|
3119 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3120 # 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
|
3121 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
|
3122 |
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
|
3123 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
|
3124 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
|
3125 cmd = 'mx.cmd' |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3126 cmdPath = join(baseDir, cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3127 if not os.path.exists(cmdPath): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3128 # 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
|
3129 cmdPath = join(dirname(baseDir), cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3130 if not os.path.exists(cmdPath): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3131 abort('cannot locate ' + cmd) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3132 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3133 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
|
3134 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
|
3135 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
|
3136 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
|
3137 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
|
3138 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3139 |
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
|
3140 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
|
3141 |
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
|
3142 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
|
3143 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
|
3144 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
|
3145 |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3146 dotProjectDoc.open('buildCommand') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3147 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
|
3148 dotProjectDoc.element('triggers', data='auto,full,incremental,') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3149 dotProjectDoc.open('arguments') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3150 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
|
3151 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
|
3152 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
|
3153 dotProjectDoc.close('dictionary') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3154 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
|
3155 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
|
3156 dotProjectDoc.element('value', data='true') |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3157 dotProjectDoc.close('dictionary') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3158 dotProjectDoc.close('arguments') |
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
3159 dotProjectDoc.close('buildCommand') |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3160 |
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
|
3161 def generate_eclipse_workingsets(): |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3162 """ |
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
|
3163 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
|
3164 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
|
3165 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
|
3166 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
|
3167 """ |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3168 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3169 # 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
|
3170 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
|
3171 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
|
3172 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
|
3173 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
|
3174 else: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
3175 expected_wsroot = _primary_suite.dir |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3176 |
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3177 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
|
3178 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
|
3179 # 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
|
3180 wsroot = expected_wsroot |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3181 |
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
|
3182 wsdir = join(wsroot, wsloc) |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3183 if not exists(wsdir): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3184 wsdir = wsroot |
13480
6215ff792647
put warning about missing Eclipse metadata directory behind -v option
Doug Simon <doug.simon@oracle.com>
parents:
13475
diff
changeset
|
3185 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
|
3186 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
|
3187 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3188 # 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
|
3189 workingSets = dict() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3190 for p in projects(): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3191 if p.workingSets is None: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3192 continue |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3193 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
|
3194 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
|
3195 workingSets[w] = [p.name] |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3196 else: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3197 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
|
3198 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3199 if exists(wspath): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3200 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
|
3201 else: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3202 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
|
3203 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3204 update_file(wspath, wsdoc.xml(newl='\n')) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
3205 |
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
|
3206 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
|
3207 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
|
3208 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
|
3209 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
|
3210 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
|
3211 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
|
3212 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
|
3213 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
|
3214 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
|
3215 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3216 def _make_workingset_xml(workingSets): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3217 wsdoc = XMLDoc() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3218 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
|
3219 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3220 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
|
3221 _workingset_open(wsdoc, w) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3222 for p in workingSets[w]: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3223 _workingset_element(wsdoc, p) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3224 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
|
3225 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3226 wsdoc.close('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3227 return wsdoc |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3228 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3229 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
|
3230 target = XMLDoc() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3231 target.open('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3232 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3233 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
|
3234 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3235 class ParserState(object): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3236 def __init__(self): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3237 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
|
3238 self.current_ws = None |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3239 self.seen_ws = list() |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3240 self.seen_projects = list() |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3241 self.aggregate_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3242 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
|
3243 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3244 ps = ParserState() |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3245 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3246 # parsing logic |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3247 def _ws_start(name, attributes): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3248 if name == 'workingSet': |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3249 if attributes.has_key('name'): |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3250 ps.current_ws_name = attributes['name'] |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3251 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
|
3252 ps.aggregate_ws = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3253 ps.current_ws = None |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3254 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
|
3255 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
|
3256 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
|
3257 ps.seen_projects = list() |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3258 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3259 ps.current_ws = None |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3260 target.open(name, attributes) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3261 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
|
3262 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3263 def _ws_end(name): |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3264 closeAndResetHandler = False |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3265 if name == 'workingSet': |
13824
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3266 if ps.aggregate_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3267 if ps.nested_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3268 ps.nested_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3269 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3270 ps.aggregate_ws = False |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3271 closeAndResetHandler = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3272 else: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3273 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
|
3274 for p in ps.current_ws: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3275 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
|
3276 _workingset_element(target, p) |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3277 closeAndResetHandler = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3278 if closeAndResetHandler: |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3279 target.close('workingSet') |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3280 parser.StartElementHandler = _ws_start |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3281 elif name == 'workingSetManager': |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3282 # 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
|
3283 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
|
3284 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
|
3285 _workingset_open(target, w) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3286 for p in workingSets[w]: |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3287 _workingset_element(target, p) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3288 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
|
3289 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3290 def _ws_item(name, attributes): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3291 if name == 'item': |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3292 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
|
3293 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
|
3294 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
|
3295 target.element(name, attributes) |
14937
3de340bdb8d3
added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents:
14918
diff
changeset
|
3296 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
|
3297 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
|
3298 else: |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3299 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
|
3300 _workingset_element(target, p_name) |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3301 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
|
3302 elif name == 'workingSet': |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3303 ps.nested_ws = True |
96d5cb754b68
address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents:
13779
diff
changeset
|
3304 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
|
3305 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3306 # process document |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3307 parser.StartElementHandler = _ws_start |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3308 parser.EndElementHandler = _ws_end |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3309 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
|
3310 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
|
3311 |
10061
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3312 target.close('workingSetManager') |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3313 return target |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3314 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3315 def _workingset_open(wsdoc, ws): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3316 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
|
3317 |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3318 def _workingset_element(wsdoc, p): |
b6dfe12478ff
[GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents:
10060
diff
changeset
|
3319 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
|
3320 |
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
|
3321 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
|
3322 """(re)generate NetBeans project configurations""" |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3323 |
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
|
3324 for suite in suites(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
|
3325 _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3326 |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3327 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
|
3328 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
|
3329 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
|
3330 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
|
3331 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3332 |
13682
c4ff08d2aa0d
fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents:
13620
diff
changeset
|
3333 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
|
3334 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
|
3335 return |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3336 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3337 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
|
3338 files = [] |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
3339 libFiles = [] |
14763 | 3340 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
|
3341 for p in suite.projects: |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3342 if p.native: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3343 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3344 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3345 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
|
3346 continue |
767312416f6a
added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents:
5824
diff
changeset
|
3347 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3348 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
|
3349 os.makedirs(join(p.dir, 'nbproject')) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3350 |
14763 | 3351 jdk = java(p.javaCompliance) |
3352 | |
14764 | 3353 if not jdk: |
14763 | 3354 log('Excluding {0} (JDK with compliance level {1} not available)'.format(p.name, p.javaCompliance)) |
3355 continue | |
14764 | 3356 |
14763 | 3357 jdks.add(jdk) |
3358 | |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
3359 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3360 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
|
3361 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
|
3362 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
|
3363 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
|
3364 out.open('exec', {'executable' : sys.executable}) |
14763 | 3365 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
|
3366 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
|
3367 out.element('arg', {'value' : 'archive'}) |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
3368 out.element('arg', {'value' : '@GRAAL'}) |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
3369 out.close('exec') |
3c74a32bb262
generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents:
8183
diff
changeset
|
3370 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
|
3371 out.close('project') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3372 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
|
3373 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
|
3374 |
5217
70777e50f1e6
replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents:
5198
diff
changeset
|
3375 out = XMLDoc() |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3376 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
|
3377 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
|
3378 out.open('configuration') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3379 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
|
3380 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
|
3381 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
|
3382 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
|
3383 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
|
3384 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
|
3385 out.element('root', {'id' : 'src.ap-source-output.dir'}) |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3386 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
|
3387 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
|
3388 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
|
3389 out.close('data') |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
3390 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3391 firstDep = True |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3392 for dep in p.all_deps([], True): |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3393 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
|
3394 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3395 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3396 if not dep.isLibrary(): |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3397 n = dep.name.replace('.', '_') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3398 if firstDep: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3399 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
|
3400 firstDep = False |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3401 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3402 out.open('reference') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3403 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
|
3404 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
|
3405 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
|
3406 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
|
3407 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
|
3408 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
|
3409 out.close('reference') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3410 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3411 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
|
3412 out.close('references') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3413 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3414 out.close('configuration') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3415 out.close('project') |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3416 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
|
3417 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
|
3418 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3419 out = StringIO.StringIO() |
14763 | 3420 jdkPlatform = 'JDK_' + str(jdk.version) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3421 |
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
|
3422 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
|
3423 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
|
3424 annotationProcessorSrcFolder = "" |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
3425 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
|
3426 annotationProcessorEnabled = "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
|
3427 annotationProcessorSrcFolder = "src.ap-source-output.dir=${build.generated.sources.dir}/ap-source-output" |
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
|
3428 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3429 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
|
3430 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
|
3431 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
|
3432 annotation.processing.processors.list= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3433 annotation.processing.run.all.processors=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3434 application.title=""" + p.name + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3435 application.vendor=mx |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3436 build.classes.dir=${build.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3437 build.classes.excludes=**/*.java,**/*.form |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3438 # 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
|
3439 build.dir=bin |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3440 build.generated.dir=${build.dir}/generated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3441 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
|
3442 # 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
|
3443 build.sysclasspath=ignore |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3444 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
|
3445 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
|
3446 # 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
|
3447 #debug.transport=dt_socket |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3448 debug.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3449 ${run.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3450 debug.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3451 ${run.test.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3452 # 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
|
3453 dist.dir=dist |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3454 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
|
3455 dist.javadoc.dir=${dist.dir}/javadoc |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3456 endorsed.classpath= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3457 excludes= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3458 includes=** |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3459 jar.compress=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3460 # Space-separated list of extra javac options |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3461 javac.compilerargs= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3462 javac.deprecation=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3463 javac.source=1.7 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3464 javac.target=1.7 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3465 javac.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3466 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3467 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3468 javadoc.additionalparam= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3469 javadoc.author=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3470 javadoc.encoding=${source.encoding} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3471 javadoc.noindex=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3472 javadoc.nonavbar=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3473 javadoc.notree=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3474 javadoc.private=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3475 javadoc.splitindex=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3476 javadoc.use=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3477 javadoc.version=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3478 javadoc.windowtitle= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3479 main.class= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3480 manifest.file=manifest.mf |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3481 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
|
3482 mkdist.disabled=false |
14763 | 3483 platforms.""" + jdkPlatform + """.home=""" + jdk.jdk + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3484 platform.active=""" + jdkPlatform + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3485 run.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3486 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3487 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3488 # 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
|
3489 # (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
|
3490 # 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
|
3491 run.jvmargs= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3492 run.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3493 ${javac.test.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3494 ${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
|
3495 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
|
3496 """ + annotationProcessorSrcFolder + """ |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3497 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
|
3498 print >> out, content |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3499 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3500 mainSrc = True |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3501 for src in p.srcDirs: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3502 srcDir = join(p.dir, src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3503 if not exists(srcDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3504 os.mkdir(srcDir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3505 ref = 'file.reference.' + p.name + '-' + src |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3506 print >> out, ref + '=' + src |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3507 if mainSrc: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3508 print >> out, 'src.dir=${' + ref + '}' |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3509 mainSrc = False |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3510 else: |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3511 print >> out, 'src.' + src + '.dir=${' + ref + '}' |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3512 |
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3513 javacClasspath = [] |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3514 |
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
|
3515 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
|
3516 annotationProcessorOnlyDeps = [] |
9854
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
3517 if len(p.annotation_processors()) > 0: |
394f38496856
made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents:
9847
diff
changeset
|
3518 for ap in p.annotation_processors(): |
11374
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
3519 apDep = dependency(ap) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
3520 if not apDep in deps: |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
3521 deps.append(apDep) |
9cdf7a9d3475
Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11318
diff
changeset
|
3522 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
|
3523 |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3524 annotationProcessorReferences = [] |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3525 |
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
|
3526 for dep in deps: |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3527 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
|
3528 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3529 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3530 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
|
3531 if not dep.mustExist: |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3532 continue |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3533 path = dep.get_path(resolve=True) |
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
|
3534 if path: |
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
|
3535 if os.sep == '\\': |
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
|
3536 path = path.replace('\\', '\\\\') |
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
|
3537 ref = 'file.reference.' + dep.name + '-bin' |
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
|
3538 print >> out, ref + '=' + path |
13475
4a3628c79ff9
separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents:
13473
diff
changeset
|
3539 libFiles.append(path) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3540 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3541 else: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3542 n = dep.name.replace('.', '_') |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3543 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3544 ref = 'reference.' + n + '.jar' |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3545 print >> out, 'project.' + n + '=' + relDepPath |
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3546 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar' |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3547 |
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
|
3548 if not dep in annotationProcessorOnlyDeps: |
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
|
3549 javacClasspath.append('${' + ref + '}') |
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
|
3550 else: |
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
|
3551 annotationProcessorReferences.append('${' + ref + '}') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3552 |
5198
887b45f6aa02
improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents:
5194
diff
changeset
|
3553 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
|
3554 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
|
3555 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
|
3556 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3557 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
|
3558 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
|
3559 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
|
3560 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3561 if updated: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3562 log('If using NetBeans:') |
14763 | 3563 log(' 1. Ensure that the following platform(s) are defined (Tools -> Java Platforms):') |
3564 for jdk in jdks: | |
3565 log(' JDK_' + str(jdk.version)) | |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
3566 log(' 2. 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
|
3567 |
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
|
3568 _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
|
3569 _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
|
3570 |
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
|
3571 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
|
3572 """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
|
3573 def rm(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3574 if exists(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3575 os.remove(path) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3576 |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3577 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
|
3578 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
|
3579 rm(join(s.mxDir, 'netbeans-config.zip')) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3580 |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3581 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
|
3582 if p.native: |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3583 continue |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3584 |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3585 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
|
3586 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
|
3587 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
|
3588 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
|
3589 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
|
3590 rm(join(p.dir, '.project')) |
10043
e063474076dd
clean up .factorypath files on "mx ideclean"
Lukas Stadler <lukas.stadler@jku.at>
parents:
9857
diff
changeset
|
3591 rm(join(p.dir, '.factorypath')) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
3592 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
|
3593 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
|
3594 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
|
3595 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
|
3596 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
|
3597 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
|
3598 |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
3599 |
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
|
3600 def ideinit(args, refreshOnly=False, buildProcessorJars=True): |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
3601 """(re)generate Eclipse and NetBeans project configurations""" |
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
|
3602 eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
78e6109ee411
mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents:
11701
diff
changeset
|
3603 netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars) |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3604 if not refreshOnly: |
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
3605 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
|
3606 |
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
|
3607 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
|
3608 """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
|
3609 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
|
3610 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
|
3611 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
|
3612 if dirpath == suite.dir: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3613 # no point in traversing .hg |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3614 if '.hg' in dirnames: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3615 dirnames.remove('.hg') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3616 elif dirpath in projectDirs: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3617 # 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
|
3618 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
|
3619 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
|
3620 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
|
3621 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
|
3622 if len(indicators) != 0: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3623 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
|
3624 shutil.rmtree(dirpath) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
3625 log('Deleted ' + dirpath) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3626 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3627 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
|
3628 """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
|
3629 |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
3630 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
|
3631 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
|
3632 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
|
3633 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
|
3634 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
|
3635 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
|
3636 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
|
3637 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
|
3638 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
|
3639 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
|
3640 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
|
3641 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3642 args = parser.parse_args(args) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3643 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3644 # 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
|
3645 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
|
3646 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
|
3647 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
|
3648 candidates = projects_opt_limit_to_suites() |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3649 |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
3650 # optionally restrict packages within a project |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3651 packages = [] |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3652 if args.packages is not None: |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3653 packages = [name for name in args.packages.split(',')] |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3654 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3655 exclude_packages = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3656 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
|
3657 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
|
3658 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3659 def outDir(p): |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3660 if args.base is None: |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3661 return join(p.dir, docDir) |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3662 return join(args.base, p.name, docDir) |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3663 |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3664 def check_package_list(p): |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
3665 return not exists(join(outDir(p), 'package-list')) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3666 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3667 def assess_candidate(p, projects): |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3668 if p in projects: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3669 return False |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3670 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
|
3671 projects.append(p) |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3672 return True |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3673 return False |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3674 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3675 projects = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3676 for p in candidates: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3677 if not p.native: |
5701
d0a6e25de770
integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents:
5699
diff
changeset
|
3678 if includeDeps: |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3679 deps = p.all_deps([], includeLibs=False, includeSelf=False) |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3680 for d in deps: |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3681 assess_candidate(d, projects) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3682 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
|
3683 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
|
3684 |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3685 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3686 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
|
3687 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
|
3688 pkgs = set() |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3689 for sourceDir in sourceDirs: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3690 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
|
3691 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
|
3692 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
|
3693 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
|
3694 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
|
3695 pkgs.add(pkg) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3696 return pkgs |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3697 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3698 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
|
3699 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
|
3700 extraArgs += ['@' + args.argfile] |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3701 memory = '2g' |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3702 if args.memory is not None: |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3703 memory = args.memory |
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3704 memory = '-J-Xmx' + memory |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3705 |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3706 if not args.unified: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3707 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
|
3708 # 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
|
3709 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
|
3710 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3711 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
|
3712 deps = p.all_deps([], includeLibs=False, includeSelf=False) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3713 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
|
3714 out = outDir(p) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3715 for d in deps: |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3716 depOut = outDir(d) |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3717 links.append('-link') |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3718 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
|
3719 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
|
3720 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
|
3721 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
|
3722 delOverviewFile = False |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3723 if not exists(overviewFile): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3724 with open(overviewFile, 'w') as fp: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3725 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
|
3726 delOverviewFile = True |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3727 nowarnAPI = [] |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3728 if not args.warnAPI: |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3729 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
|
3730 |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3731 # 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
|
3732 windowTitle = [] |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3733 if stdDoclet: |
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3734 windowTitle = ['-windowtitle', p.name + ' javadoc'] |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3735 try: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3736 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
|
3737 projectJava = java(p.javaCompliance) |
14907
7683ad455d81
mx: fix post processing of javadoc for jdk8
Bernhard Urban <bernhard.urban@jku.at>
parents:
14874
diff
changeset
|
3738 run([java().javadoc, memory, |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3739 '-XDignore.symbol.file', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3740 '-classpath', cp, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3741 '-quiet', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3742 '-d', out, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3743 '-overview', overviewFile, |
14916
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
3744 '-sourcepath', sp, |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
3745 '-source', str(projectJava.javaCompliance), |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
3746 '-bootclasspath', projectJava.bootclasspath(), |
66e9855f4ae8
Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14915
diff
changeset
|
3747 '-extdirs', projectJava.extdirs()] + |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3748 links + |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3749 extraArgs + |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3750 nowarnAPI + |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
3751 windowTitle + |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3752 list(pkgs)) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3753 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
|
3754 finally: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3755 if delOverviewFile: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3756 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
|
3757 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3758 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
|
3759 # 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
|
3760 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
|
3761 |
5171
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3762 pkgs = set() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3763 sp = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3764 names = [] |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3765 for p in projects: |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3766 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
|
3767 sp += p.source_dirs() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3768 names.append(p.name) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3769 |
14763 | 3770 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
|
3771 out = join(_primary_suite.dir, docDir) |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3772 if args.base is not None: |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
3773 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
|
3774 cp = classpath() |
99ad84da5f99
added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents:
5166
diff
changeset
|
3775 sp = os.pathsep.join(sp) |
5712
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3776 nowarnAPI = [] |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3777 if not args.warnAPI: |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3778 nowarnAPI.append('-XDignore.symbol.file') |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3779 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
|
3780 run([java().javadoc, memory, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3781 '-classpath', cp, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3782 '-quiet', |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3783 '-d', out, |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3784 '-sourcepath', sp] + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3785 links + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3786 extraArgs + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3787 nowarnAPI + |
dfcb73ac6ba2
made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents:
5710
diff
changeset
|
3788 list(pkgs)) |
5376
bfc9aeb1264c
synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents:
5252
diff
changeset
|
3789 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
|
3790 |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3791 class Chunk: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3792 def __init__(self, content, ldelim, rdelim=None): |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3793 lindex = content.find(ldelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3794 if rdelim is not None: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3795 rindex = content.find(rdelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3796 else: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3797 rindex = lindex + len(ldelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3798 self.ldelim = ldelim |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3799 self.rdelim = rdelim |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3800 if lindex != -1 and rindex != -1 and rindex > lindex: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3801 self.text = content[lindex + len(ldelim):rindex] |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3802 else: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3803 self.text = None |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3804 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3805 def replace(self, content, repl): |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3806 lindex = content.find(self.ldelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3807 if self.rdelim is not None: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3808 rindex = content.find(self.rdelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3809 rdelimLen = len(self.rdelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3810 else: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3811 rindex = lindex + len(self.ldelim) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3812 rdelimLen = 0 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3813 old = content[lindex:rindex + rdelimLen] |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3814 return content.replace(old, repl) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3815 |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3816 # Post-process an overview-summary.html file to move the |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3817 # complete overview to the top of the page |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3818 def _fix_overview_summary(path, topLink): |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3819 """ |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3820 Processes an "overview-summary.html" generated by javadoc to put the complete |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3821 summary text above the Packages table. |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3822 """ |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3823 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3824 # This uses scraping and so will break if the relevant content produced by javadoc changes in any way! |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3825 with open(path) as fp: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3826 content = fp.read() |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3827 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3828 chunk1 = Chunk(content, """<div class="header"> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3829 <div class="subTitle"> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3830 <div class="block">""", """</div> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3831 </div> |
14907
7683ad455d81
mx: fix post processing of javadoc for jdk8
Bernhard Urban <bernhard.urban@jku.at>
parents:
14874
diff
changeset
|
3832 <p>See: <a href="#overview.description">Description</a></p> |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3833 </div>""") |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3834 |
14907
7683ad455d81
mx: fix post processing of javadoc for jdk8
Bernhard Urban <bernhard.urban@jku.at>
parents:
14874
diff
changeset
|
3835 chunk2 = Chunk(content, """<div class="contentContainer"><a name="overview.description"> |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3836 <!-- --> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3837 </a> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3838 <div class="block">""", """</div> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3839 </div> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3840 <!-- ======= START OF BOTTOM NAVBAR ====== -->""") |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3841 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3842 assert chunk1.text, 'Could not find header section in ' + path |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3843 assert chunk2.text, 'Could not find footer section in ' + path |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3844 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3845 content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text + '</div></div></div>') |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3846 content = chunk2.replace(content, '') |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3847 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3848 with open(path, 'w') as fp: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3849 fp.write(content) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3850 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3851 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3852 # Post-process a package-summary.html file to move the |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3853 # complete package description to the top of the page |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3854 def _fix_package_summary(path): |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3855 """ |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3856 Processes an "overview-summary.html" generated by javadoc to put the complete |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3857 summary text above the Packages table. |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3858 """ |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3859 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3860 # This uses scraping and so will break if the relevant content produced by javadoc changes in any way! |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3861 with open(path) as fp: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3862 content = fp.read() |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3863 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3864 chunk1 = Chunk(content, """<div class="header"> |
14907
7683ad455d81
mx: fix post processing of javadoc for jdk8
Bernhard Urban <bernhard.urban@jku.at>
parents:
14874
diff
changeset
|
3865 <h1 title="Package" class="title">Package""", """<p>See: <a href="#package.description">Description</a></p> |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3866 </div>""") |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3867 |
14907
7683ad455d81
mx: fix post processing of javadoc for jdk8
Bernhard Urban <bernhard.urban@jku.at>
parents:
14874
diff
changeset
|
3868 chunk2 = Chunk(content, """<a name="package.description"> |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3869 <!-- --> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3870 </a>""", """</div> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3871 </div> |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3872 <!-- ======= START OF BOTTOM NAVBAR ====== -->""") |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3873 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3874 if chunk1.text: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3875 if chunk2.text: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3876 repl = re.sub(r'<h2 title=(.*) Description</h2>', r'<h1 title=\1</h1>', chunk2.text, 1) |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3877 content = chunk1.replace(content, '<div class="header">' + repl + '</div></div>') |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3878 content = chunk2.replace(content, '') |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3879 |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3880 with open(path, 'w') as fp: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3881 fp.write(content) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3882 else: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3883 log('warning: Could not find package description detail section in ' + path) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3884 |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3885 else: |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3886 # no package description given |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3887 pass |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
3888 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3889 def site(args): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3890 """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
|
3891 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3892 parser = ArgumentParser(prog='site') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3893 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3894 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
|
3895 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
|
3896 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
|
3897 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
|
3898 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
|
3899 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
|
3900 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
|
3901 args = parser.parse_args(args) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3902 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3903 args.base = os.path.abspath(args.base) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3904 tmpbase = tempfile.mkdtemp(prefix=basename(args.base) + '.', dir=dirname(args.base)) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3905 unified = join(tmpbase, 'all') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3906 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3907 exclude_packages_arg = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3908 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
|
3909 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
|
3910 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3911 projects = sorted_deps() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3912 projects_arg = [] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3913 if args.projects is not None: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3914 projects_arg = ['--projects', args.projects] |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3915 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
|
3916 |
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
|
3917 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
|
3918 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
|
3919 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
|
3920 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
|
3921 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3922 try: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3923 # 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
|
3924 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
|
3925 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3926 # 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
|
3927 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
|
3928 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
|
3929 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
|
3930 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
|
3931 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
|
3932 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
|
3933 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
|
3934 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
|
3935 <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
|
3936 <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
|
3937 <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
|
3938 <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
|
3939 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
|
3940 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
|
3941 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
|
3942 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
|
3943 |
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
|
3944 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
|
3945 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
|
3946 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3947 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
|
3948 javadoc(['--base', tmpbase, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3949 '--unified', |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3950 '--arg', '@-windowtitle', '--arg', '@' + title, |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3951 '--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
|
3952 '--arg', '@-overview', '--arg', '@' + args.overview] + 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
|
3953 os.rename(join(tmpbase, 'javadoc'), unified) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3954 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3955 # Generate dependency graph with Graphviz |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3956 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
|
3957 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
|
3958 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
|
3959 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
|
3960 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
|
3961 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
|
3962 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
|
3963 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
|
3964 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
|
3965 |
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
|
3966 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
|
3967 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
|
3968 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 with open(dot, 'w') as fp: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3974 dim = len(projects) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3975 print >> fp, 'digraph projects {' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3976 print >> fp, 'rankdir=BT;' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3977 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
|
3978 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
|
3979 # print >> fp, 'edge [color="green"];' |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3980 for p in projects: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3981 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
|
3982 for dep in p.canonical_deps(): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3983 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
|
3984 print >> fp, '"' + p.name + '" -> "' + dep + '"' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3985 depths = dict() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3986 for p in projects: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3987 d = p.max_depth() |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3988 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
|
3989 print >> fp, '}' |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
3990 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
3991 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
|
3992 |
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
|
3993 # 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
|
3994 # 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
|
3995 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
|
3996 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
|
3997 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
|
3998 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
|
3999 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
|
4000 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
|
4001 |
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
|
4002 # 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
|
4003 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
|
4004 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
|
4005 |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4006 top = join(tmpbase, 'all', 'overview-summary.html') |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4007 for root, _, files in os.walk(tmpbase): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4008 for f in files: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4009 if f == 'overview-summary.html': |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4010 path = join(root, f) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4011 topLink = '' |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4012 if top != path: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4013 link = os.path.relpath(join(tmpbase, 'all', 'index.html'), dirname(path)) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4014 topLink = '<p><a href="' + link + '", target="_top"><b>[return to the overall ' + args.name + ' documentation]</b></a></p>' |
6335
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
4015 _fix_overview_summary(path, topLink) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
4016 elif f == 'package-summary.html': |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
4017 path = join(root, f) |
897f5bb96d60
fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents:
6284
diff
changeset
|
4018 _fix_package_summary(path) |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4019 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4020 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4021 if exists(args.base): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4022 shutil.rmtree(args.base) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4023 shutil.move(tmpbase, args.base) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4024 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4025 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
|
4026 |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4027 finally: |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4028 if exists(tmpbase): |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4029 shutil.rmtree(tmpbase) |
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4030 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4031 def _kwArg(kwargs): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4032 if len(kwargs) > 0: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4033 return kwargs.pop(0) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4034 return None |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4035 |
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
|
4036 def findclass(args, logToConsole=True): |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4037 """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
|
4038 matches = [] |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4039 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
|
4040 if filename.endswith('.class'): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4041 if isinstance(entry, zipfile.ZipFile): |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4042 classname = filename.replace('/', '.') |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4043 else: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4044 classname = filename.replace(os.sep, '.') |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4045 classname = classname[:-len('.class')] |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4046 for a in args: |
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4047 if a in 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
|
4048 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
|
4049 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
|
4050 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
|
4051 return matches |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4052 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4053 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
|
4054 """ |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4055 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
|
4056 |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4057 """ |
11318
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4058 if len(items) <= 1: |
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4059 return items |
345bce66c04a
mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11301
diff
changeset
|
4060 else: |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4061 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4062 log('[0] <all>') |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4063 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
|
4064 if descriptions is None: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4065 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
|
4066 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4067 assert len(items) == len(descriptions) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4068 wrapper = textwrap.TextWrapper(subsequent_indent=' ') |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4069 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
|
4070 while True: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4071 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4072 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
|
4073 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4074 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
|
4075 try: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4076 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
|
4077 except: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4078 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
|
4079 continue |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4080 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4081 if allowMultiple and 0 in s: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4082 return items |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4083 |
11295
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4084 indexes = [] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4085 for n in s: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4086 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
|
4087 log('Invalid selection: ' + str(n)) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4088 continue |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4089 else: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4090 indexes.append(n - 1) |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4091 if allowMultiple: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4092 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
|
4093 if len(indexes) == 1: |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4094 return items[indexes[0]] |
bb70a309a7cf
enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents:
11245
diff
changeset
|
4095 return None |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4096 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4097 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
|
4098 """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
|
4099 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4100 javapExe = java().javap |
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4101 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
|
4102 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
|
4103 else: |
11203
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4104 candidates = findclass(args, logToConsole=False) |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4105 if len(candidates) == 0: |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4106 log('no matches') |
8ab76b7c6ff6
added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents:
10585
diff
changeset
|
4107 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
|
4108 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
|
4109 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4110 def show_projects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4111 """show all loaded projects""" |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4112 for s in suites(): |
11659
ec7aad9dfc47
made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents:
11620
diff
changeset
|
4113 projectsFile = join(s.mxDir, 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4114 if exists(projectsFile): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4115 log(projectsFile) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4116 for p in s.projects: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4117 log('\t' + p.name) |
11759
8bcd76c3f23b
mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents:
11756
diff
changeset
|
4118 |
11511
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4119 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
|
4120 """""" |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4121 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
|
4122 if not sys.stdout.isatty(): |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4123 if default: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4124 return default |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4125 else: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4126 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
|
4127 questionMark = '? [yn]: ' |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4128 if default: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4129 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
|
4130 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
|
4131 while not answer: |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4132 answer = raw_input(question + questionMark) |
3110bea9a6b0
mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11401
diff
changeset
|
4133 return answer.lower().startswith('y') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4134 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4135 def add_argument(*args, **kwargs): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4136 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4137 Define how a single command-line argument. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4138 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4139 assert _argParser is not None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4140 _argParser.add_argument(*args, **kwargs) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4141 |
11605
3676540f71cf
Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents:
11597
diff
changeset
|
4142 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
|
4143 for key, value in new_commands.iteritems(): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4144 if _commands.has_key(key): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4145 warn("redefining command '" + key + "' in suite " + suite.name) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4146 _commands[key] = value |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4147 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4148 def warn(msg): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4149 if _warn: |
13968
6c6d1eacc398
mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents:
13952
diff
changeset
|
4150 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
|
4151 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4152 # Table of commands in alphabetical order. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4153 # 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
|
4154 # 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
|
4155 # used in the call to str.format(). |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4156 # 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
|
4157 _commands = { |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4158 'about': [about, ''], |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
4159 'build': [build, '[options]'], |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
4160 'checkstyle': [checkstyle, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4161 'canonicalizeprojects': [canonicalizeprojects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4162 'clean': [clean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4163 '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
|
4164 'eclipseformat': [eclipseformat, ''], |
5455
271e83dcfcef
added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents:
5376
diff
changeset
|
4165 '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
|
4166 'fsckprojects': [fsckprojects, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4167 '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
|
4168 'ideclean': [ideclean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
4169 'ideinit': [ideinit, ''], |
8131
83ec1df0a30f
added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents:
7925
diff
changeset
|
4170 'archive': [archive, '[options]'], |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
4171 'projectgraph': [projectgraph, ''], |
11777
f3e5cbd1efae
move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents:
11759
diff
changeset
|
4172 '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
|
4173 '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
|
4174 'javadoc': [javadoc, '[options]'], |
5771
613a3ddb9a71
moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents:
5762
diff
changeset
|
4175 'site': [site, '[options]'], |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4176 'netbeansinit': [netbeansinit, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4177 'projects': [show_projects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4178 } |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4179 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4180 _argParser = ArgParser() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4181 |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4182 def _suitename(mxDir): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4183 base = os.path.basename(mxDir) |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4184 parts = base.split('.') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4185 # temporary workaround until mx.graal exists |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4186 if len(parts) == 1: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4187 return 'graal' |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4188 else: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4189 return parts[1] |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4190 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4191 def _is_suite_dir(d, mxDirName=None): |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4192 """ |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4193 Checks if d contains a suite. |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4194 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
|
4195 """ |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4196 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
|
4197 for f in os.listdir(d): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4198 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
|
4199 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
|
4200 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
|
4201 return mxDir |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4202 |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4203 def _check_primary_suite(): |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4204 if _primary_suite is None: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4205 abort('no primary suite found') |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4206 else: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4207 return _primary_suite |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4208 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4209 def _findPrimarySuiteMxDirFrom(d): |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4210 """ 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
|
4211 while d: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4212 mxDir = _is_suite_dir(d) |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4213 if mxDir is not None: |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4214 return mxDir |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4215 parent = dirname(d) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4216 if d == parent: |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4217 return None |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4218 d = parent |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4219 |
5699
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4220 return None |
e9f7d16194a8
added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents:
5581
diff
changeset
|
4221 |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4222 def _findPrimarySuiteMxDir(): |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4223 # check for explicit setting |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4224 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
|
4225 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
|
4226 if mxDir is not None: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4227 return mxDir |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4228 else: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4229 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
|
4230 |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4231 # try current working directory first |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4232 mxDir = _findPrimarySuiteMxDirFrom(os.getcwd()) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4233 if mxDir is not None: |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4234 return mxDir |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4235 # 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
|
4236 return _findPrimarySuiteMxDirFrom(dirname(__file__)) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4237 |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
4238 def main(): |
12477
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4239 primarySuiteMxDir = _findPrimarySuiteMxDir() |
a5d83166dca6
mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents:
12455
diff
changeset
|
4240 if primarySuiteMxDir: |
12522
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4241 global _primary_suite |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4242 _primary_suite = _loadSuite(primarySuiteMxDir, True) |
5ccee20550ea
mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents:
12521
diff
changeset
|
4243 else: |
13855
bc32c9f5719b
remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents:
13853
diff
changeset
|
4244 abort('no primary suite found') |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4245 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4246 opts, commandAndArgs = _argParser._parse_cmd_line() |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4247 |
14763 | 4248 global _opts, _java_homes |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4249 _opts = opts |
14763 | 4250 defaultJdk = JavaConfig(opts.java_home, opts.java_dbg_port) |
4251 _java_homes = [defaultJdk] | |
4252 if opts.extra_java_homes: | |
4253 for java_home in opts.extra_java_homes.split(os.pathsep): | |
4254 extraJdk = JavaConfig(java_home, opts.java_dbg_port) | |
4255 if extraJdk > defaultJdk: | |
4256 abort('Secondary JDK ' + extraJdk.jdk + ' has higher compliance level than default JDK ' + defaultJdk.jdk) | |
4257 _java_homes.append(extraJdk) | |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4258 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
4259 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
|
4260 s._post_init(opts) |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4261 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4262 if len(commandAndArgs) == 0: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4263 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4264 return |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4265 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4266 command = commandAndArgs[0] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4267 command_args = commandAndArgs[1:] |
5032
e2de9649f0a9
Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents:
4664
diff
changeset
|
4268 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4269 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
|
4270 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
|
4271 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
|
4272 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
|
4273 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
|
4274 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
|
4275 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
|
4276 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
|
4277 |
11514
dc3c8df55905
added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents:
11511
diff
changeset
|
4278 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
|
4279 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
|
4280 abort(1) |
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
4281 signal.signal(signal.SIGTERM, term_handler) |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
4282 |
14135
ee66410c0679
mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents:
14134
diff
changeset
|
4283 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
|
4284 _send_sigquit() |
14153
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
4285 if get_os() != 'windows': |
e328f28f7401
fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents:
14136
diff
changeset
|
4286 signal.signal(signal.SIGQUIT, quit_handler) |
14134
e71d421370f3
mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents:
14133
diff
changeset
|
4287 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4288 try: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
4289 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
|
4290 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
|
4291 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
|
4292 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
|
4293 signal.alarm(opts.timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4294 retcode = c(command_args) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4295 if retcode is not None and retcode != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4296 abort(retcode) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4297 except KeyboardInterrupt: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4298 # 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
|
4299 abort(1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4300 |
13471
020099961eb4
renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents:
13470
diff
changeset
|
4301 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
|
4302 |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
4303 currentUmask = None |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
4304 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4305 if __name__ == '__main__': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4306 # 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
|
4307 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
|
4308 |
14103
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
4309 # 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
|
4310 currentUmask = os.umask(0) |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
4311 os.umask(currentUmask) |
9d8aaa3200a3
make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13982
diff
changeset
|
4312 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
4313 main() |