annotate mxtool/mx.py @ 21982:6691b182e1a1

Call into mx to generate javadoc for the project
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Fri, 26 Jun 2015 14:47:52 +0200
parents 969ae2657b92
children b8dffa0113ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
5 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 #
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 # This code is free software; you can redistribute it and/or modify it
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 # under the terms of the GNU General Public License version 2 only, as
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 # published by the Free Software Foundation.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 #
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 # This code is distributed in the hope that it will be useful, but WITHOUT
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 # version 2 for more details (a copy is included in the LICENSE file that
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 # accompanied this code).
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 #
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 # You should have received a copy of the GNU General Public License version
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 # 2 along with this work; if not, write to the Free Software Foundation,
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 #
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 # or visit www.oracle.com if you need additional information or have any
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 # questions.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 #
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 # ----------------------------------------------------------------------------------------------------
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 #
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
28 r"""
12553
9af82ca3f225 mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents: 12524
diff changeset
29 mx is a command line tool for managing the development of Java code organized as suites of projects.
9af82ca3f225 mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents: 12524
diff changeset
30
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
31 Version 1.x supports a single suite of projects.
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
32
12553
9af82ca3f225 mxtool: change about text to refer to Wiki doc, add mx.find script
Mick Jordan <mick.jordan@oracle.com>
parents: 12524
diff changeset
33 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
34 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35
17012
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
36 import sys, os, errno, time, subprocess, shlex, types, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch, platform
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
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
39 import tarfile
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
40 import hashlib
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
41 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
42 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
43 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
44 import difflib
18601
676f1800077c mx: removed unused _read_projects_file function
Doug Simon <doug.simon@oracle.com>
parents: 18484
diff changeset
45 from collections import Callable
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 from threading import Thread
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 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
48 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
49
21208
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
50 try:
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
51 # needed to work around https://bugs.python.org/issue1927
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
52 import readline
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
53 #then make pylint happy..
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
54 readline.get_line_buffer()
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
55 except ImportError:
fbe449ca9707 Make readline import best-effort
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21166
diff changeset
56 pass
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
57
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
58 # Support for Python 2.6
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
59 def check_output(*popenargs, **kwargs):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
60 process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
61 output, _ = process.communicate()
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
62 retcode = process.poll()
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
63 if retcode:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
64 cmd = kwargs.get("args")
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
65 if cmd is None:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
66 cmd = popenargs[0]
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
67 error = subprocess.CalledProcessError(retcode, cmd)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
68 error.output = output
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
69 raise error
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
70 return output
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
71
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
72 # Support for jython
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
73 def is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
74 return sys.platform.startswith('java')
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
75
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
76 if not is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
77 import multiprocessing
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
78
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
79 def cpu_count():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
80 if is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
81 from java.lang import Runtime
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
82 runtime = Runtime.getRuntime()
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
83 return runtime.availableProcessors()
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
84 else:
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
85 return multiprocessing.cpu_count()
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
86
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
87
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
88 try: subprocess.check_output
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
89 except: subprocess.check_output = check_output
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
90
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
91 try: zipfile.ZipFile.__enter__
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
92 except:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
93 zipfile.ZipFile.__enter__ = lambda self: self
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
94 zipfile.ZipFile.__exit__ = lambda self, t, value, traceback: self.close()
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
95
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
96 _projects = dict()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
97 _libs = dict()
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
98 _jreLibs = dict()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
99 _dists = dict()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
100 _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
101 _annotationProcessors = None
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
102 _primary_suite_path = None
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
103 _primary_suite = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
104 _opts = None
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
105 _extra_java_homes = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
106 _default_java_home = None
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
107 _warn = False
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
108
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
109 """
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
110 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
111 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
112 class Distribution:
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
113 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance, isProcessorDistribution=False):
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
114 self.suite = suite
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
115 self.name = name
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
116 self.path = path.replace('/', os.sep)
14964
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
117 self.path = _make_absolute(self.path, suite.dir)
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
118 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
119 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
120 self.update_listeners = set()
15819
2460aed6c899 mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 15818
diff changeset
121 self.mainClass = mainClass
15577
406a94c03ffa truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents: 15497
diff changeset
122 self.excludedDependencies = excludedDependencies
15638
83c69954bbaa mxtool: distribution dependency should be a list
Bernhard Urban <bernhard.urban@jku.at>
parents: 15601
diff changeset
123 self.distDependencies = distDependencies
17059
a5dc5513ce85 mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents: 17050
diff changeset
124 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
125 self.isProcessorDistribution = isProcessorDistribution
14775
40aa1eb176db mx: added support for excluding dependencies from distributions
Doug Simon <doug.simon@oracle.com>
parents: 14764
diff changeset
126
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
127 def sorted_deps(self, includeLibs=False, transitive=False, includeAnnotationProcessors=False):
16667
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
128 deps = []
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
129 if transitive:
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
130 for depDist in [distribution(name) for name in self.distDependencies]:
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
131 for d in depDist.sorted_deps(includeLibs=includeLibs, transitive=True):
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
132 if d not in deps:
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
133 deps.append(d)
14781
d2038d372cd2 changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 14775
diff changeset
134 try:
15577
406a94c03ffa truffle distrubtion: move dsl processor in a separated jar, such that it can be a build-time only dependency
Bernhard Urban <bernhard.urban@jku.at>
parents: 15497
diff changeset
135 excl = [dependency(d) for d in self.excludedDependencies]
14781
d2038d372cd2 changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 14775
diff changeset
136 except SystemExit as e:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
137 abort('invalid excluded dependency for {0} distribution: {1}'.format(self.name, e))
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
138 return deps + [d for d in sorted_deps(self.deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) 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
139
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
140 def __str__(self):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
141 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
142
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
143 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
144 self.update_listeners.add(listener)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
145
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
146 def get_dist_deps(self, includeSelf=True, transitive=False):
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
147 deps = []
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
148 if includeSelf:
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
149 deps.append(self)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
150 for name in self.distDependencies:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
151 dist = distribution(name)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
152 if dist not in deps:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
153 deps.append(dist)
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
154 if transitive:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
155 for depName in self.distDependencies:
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
156 for recDep in distribution(depName).get_dist_deps(False, True):
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
157 if recDep not in deps:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21781
diff changeset
158 deps.append(recDep)
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21703
diff changeset
159 return list(deps)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
160
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
161 """
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
162 Gets the directory in which the IDE project configuration
16849
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
163 for this distribution is generated. If this is a distribution
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
164 derived from a project defining an annotation processor, then
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
165 None is return to indicate no IDE configuration should be
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
166 created for this distribution.
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
167 """
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
168 def get_ide_project_dir(self):
16849
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
169 if hasattr(self, 'definingProject') and self.definingProject.definedAnnotationProcessorsDist == self:
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
170 return None
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
171 if hasattr(self, 'subDir'):
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
172 return join(self.suite.dir, self.subDir, self.name + '.dist')
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
173 else:
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
174 return join(self.suite.dir, self.name + '.dist')
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
175
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
176 def make_archive(self):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
177 # are sources combined into main archive?
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
178 unified = self.path == self.sourcesPath
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
179
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
180 with Archiver(self.path) as arc:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
181 with Archiver(None if unified else self.sourcesPath) as srcArcRaw:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
182 srcArc = arc if unified else srcArcRaw
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
183 services = {}
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
184 def overwriteCheck(zf, arcname, source):
21702
70649030d511 mx archive: exclude dotfiles
Andreas Woess <andreas.woess@oracle.com>
parents: 21653
diff changeset
185 if os.path.basename(arcname).startswith('.'):
70649030d511 mx archive: exclude dotfiles
Andreas Woess <andreas.woess@oracle.com>
parents: 21653
diff changeset
186 logv('Excluding dotfile: ' + source)
70649030d511 mx archive: exclude dotfiles
Andreas Woess <andreas.woess@oracle.com>
parents: 21653
diff changeset
187 return True
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
188 if not hasattr(zf, '_provenance'):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
189 zf._provenance = {}
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
190 existingSource = zf._provenance.get(arcname, None)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
191 isOverwrite = False
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
192 if existingSource and existingSource != source:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
193 if arcname[-1] != os.path.sep:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
194 logv('warning: ' + self.path + ': avoid overwrite of ' + arcname + '\n new: ' + source + '\n old: ' + existingSource)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
195 isOverwrite = True
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
196 zf._provenance[arcname] = source
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
197 return isOverwrite
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
198
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
199 if self.mainClass:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
200 manifest = "Manifest-Version: 1.0\nMain-Class: %s\n\n" % (self.mainClass)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
201 if not overwriteCheck(arc.zf, "META-INF/MANIFEST.MF", "project files"):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
202 arc.zf.writestr("META-INF/MANIFEST.MF", manifest)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
203
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
204 for dep in self.sorted_deps(includeLibs=True):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
205 isCoveredByDependecy = False
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
206 for d in self.distDependencies:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
207 if dep in _dists[d].sorted_deps(includeLibs=True, transitive=True):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
208 logv("Excluding {0} from {1} because it's provided by the dependency {2}".format(dep.name, self.path, d))
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
209 isCoveredByDependecy = True
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
210 break
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
211
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
212 if isCoveredByDependecy:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
213 continue
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
214
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
215 if dep.isLibrary():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
216 l = dep
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
217 # merge library jar into distribution jar
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
218 logv('[' + self.path + ': adding library ' + l.name + ']')
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
219 lpath = l.get_path(resolve=True)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
220 libSourcePath = l.get_source_path(resolve=True)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
221 if lpath:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
222 with zipfile.ZipFile(lpath, 'r') as lp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
223 for arcname in lp.namelist():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
224 if arcname.startswith('META-INF/services/') and not arcname == 'META-INF/services/':
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
225 service = arcname[len('META-INF/services/'):]
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
226 assert '/' not in service
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
227 services.setdefault(service, []).extend(lp.read(arcname).splitlines())
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
228 else:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
229 if not overwriteCheck(arc.zf, arcname, lpath + '!' + arcname):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
230 arc.zf.writestr(arcname, lp.read(arcname))
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
231 if srcArc.zf and libSourcePath:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
232 with zipfile.ZipFile(libSourcePath, 'r') as lp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
233 for arcname in lp.namelist():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
234 if not overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
235 srcArc.zf.writestr(arcname, lp.read(arcname))
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
236 elif dep.isProject():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
237 p = dep
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
238
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
239 if self.javaCompliance:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
240 if p.javaCompliance > self.javaCompliance:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
241 abort("Compliance level doesn't match: Distribution {0} requires {1}, but {2} is {3}.".format(self.name, self.javaCompliance, p.name, p.javaCompliance))
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
242
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
243 logv('[' + self.path + ': adding project ' + p.name + ']')
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
244 outputDir = p.output_dir()
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
245 for root, _, files in os.walk(outputDir):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
246 relpath = root[len(outputDir) + 1:]
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
247 if relpath == join('META-INF', 'services'):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
248 for service in files:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
249 with open(join(root, service), 'r') as fp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
250 services.setdefault(service, []).extend([provider.strip() for provider in fp.readlines()])
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
251 elif relpath == join('META-INF', 'providers'):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
252 for provider in files:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
253 with open(join(root, provider), 'r') as fp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
254 for service in fp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
255 services.setdefault(service.strip(), []).append(provider)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
256 else:
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
257 for f in files:
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
258 arcname = join(relpath, f).replace(os.sep, '/')
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
259 if not overwriteCheck(arc.zf, arcname, join(root, f)):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
260 arc.zf.write(join(root, f), arcname)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
261 if srcArc.zf:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
262 sourceDirs = p.source_dirs()
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
263 if p.source_gen_dir():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
264 sourceDirs.append(p.source_gen_dir())
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
265 for srcDir in sourceDirs:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
266 for root, _, files in os.walk(srcDir):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
267 relpath = root[len(srcDir) + 1:]
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
268 for f in files:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
269 if f.endswith('.java'):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
270 arcname = join(relpath, f).replace(os.sep, '/')
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
271 if not overwriteCheck(srcArc.zf, arcname, join(root, f)):
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
272 srcArc.zf.write(join(root, f), arcname)
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
273
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
274 for service, providers in services.iteritems():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
275 arcname = 'META-INF/services/' + service
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
276 arc.zf.writestr(arcname, '\n'.join(providers))
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
277
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
278 self.notify_updated()
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
279
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
280
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
281 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
282 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
283 l(self)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
284
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
285 """
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
286 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
287 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288 class Dependency:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
289 def __init__(self, suite, name):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
290 self.name = name
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
291 self.suite = suite
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
292
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
293 def __cmp__(self, other):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
294 return cmp(self.name, other.name)
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
295
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
296 def __str__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 return self.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
298
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299 def __eq__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 return self.name == other.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
301
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
302 def __ne__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303 return self.name != other.name
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
304
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
305 def __hash__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
306 return hash(self.name)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
307
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
308 def isLibrary(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
309 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
310
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
311 def isJreLibrary(self):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
312 return isinstance(self, JreLibrary)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
313
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
314 def isProject(self):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
315 return isinstance(self, Project)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
316
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
317 class Project(Dependency):
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
318 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
319 Dependency.__init__(self, suite, name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320 self.srcDirs = srcDirs
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321 self.deps = deps
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322 self.checkstyleProj = name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
323 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
324 self.native = False
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
325 self.workingSets = workingSets
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
326 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
327
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
328 # The annotation processors defined by this project
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
329 self.definedAnnotationProcessors = None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
330 self.definedAnnotationProcessorsDist = None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
331
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
332 # Create directories for projects that don't yet exist
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
333 if not exists(d):
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
334 os.mkdir(d)
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
335 for s in self.source_dirs():
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
336 if not exists(s):
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
337 os.mkdir(s)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
338
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
339 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
340 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
341 Add the transitive set of dependencies for this project, including
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
342 libraries if 'includeLibs' is true, to the 'deps' list.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
343 """
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
344 return sorted(self._all_deps_helper(deps, [], includeLibs, includeSelf, includeJreLibs, includeAnnotationProcessors))
17248
03826360967b fix pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 17245
diff changeset
345
17245
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
346 def _all_deps_helper(self, deps, dependants, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
347 if self in dependants:
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
348 abort(str(self) + 'Project dependency cycle found:\n ' +
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
349 '\n |\n V\n '.join(map(str, dependants[dependants.index(self):])) +
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
350 '\n |\n V\n ' + self.name)
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
351 childDeps = list(self.deps)
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
352 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
353 childDeps = self.annotation_processors() + childDeps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
354 if self in deps:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
355 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
356 for name in childDeps:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
357 assert name != self.name
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
358 dep = dependency(name)
17245
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
359 if not dep in deps:
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
360 if dep.isProject():
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
361 dep._all_deps_helper(deps, dependants + [self], includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
17248
03826360967b fix pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 17245
diff changeset
362 elif dep.isProject or (dep.isLibrary() and includeLibs) or (dep.isJreLibrary() and includeJreLibs):
17245
86d9e456ef98 mx: added cyclic dependency checking
Doug Simon <doug.simon@oracle.com>
parents: 17236
diff changeset
363 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4215
diff changeset
364 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
365 deps.append(self)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
366 return deps
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
367
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
368 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
369 currentDist = distances.get(name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
370 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
371 distances[name] = dist
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
372 p = project(name, False)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
373 if p is not None:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
374 for dep in p.deps:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
375 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
376
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
377 def canonical_deps(self):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
378 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
379 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
380 via other dependencies).
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
381 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
382 distances = dict()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
383 result = set()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
384 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
385 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
386 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
387 if d == 1:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
388 result.add(n)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
389
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
390 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
391 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
392 return result
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
393
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
394 def max_depth(self):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
395 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
396 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
397 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
398 distances = dict()
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
399 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
400 return max(distances.values())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
401
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
402 def source_dirs(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
403 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
404 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
405 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
406 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
407
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
408 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
409 """
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
410 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
411 """
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
412 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
413 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
414 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
415
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
416 def output_dir(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
417 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
418 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
419 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
420 if self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
421 return None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
422 return join(self.dir, 'bin')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
423
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
424 def jasmin_output_dir(self):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
425 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
426 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
427 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
428 if self.native:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
429 return None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
430 return join(self.dir, 'jasmin_classes')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
431
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
432 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
433 if not self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
434 cp.append(self.output_dir())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
435
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
436 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
437 """
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
438 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
439 '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
440 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
441 """
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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 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
457 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
458 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
459 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
460 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
461 break
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
462
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
463 if matchFound:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
464 simpleClassName = name[:-len('.java')]
18725
fdf29cc07ec2 Improved error message in mx tool when package statement cannot be found.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18710
diff changeset
465 assert pkg is not None, 'could not find package statement in file ' + name
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
466 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
467 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
468 if exists(pkgOutputDir):
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
469 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
470 if includeInnerClasses:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
471 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
472 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
473 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
474 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
475 className = pkg + '.' + simpleClassName
11245
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
476 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
477 return result
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
478
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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 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
495 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
496 # 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
497 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
498 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
499
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
500 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
501 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
502 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
503 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
504 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
505 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
506
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
507 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
508 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
509 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
510 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
511 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
512 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
513 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
514 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
515 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
516 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
517 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
518 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
519
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
520 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
521 """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
522 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
523 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
524
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
525 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
526 """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
527 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
528 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
529
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
530 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
531 """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
532 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
533 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
534 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
535
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
536 """
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
537 Gets the list of projects defining the annotation processors that will be applied
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
538 when compiling this project. This includes the projects declared by the annotationProcessors property
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
539 of this project and any of its project dependencies. It also includes
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
540 any project dependencies that define an annotation processors.
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
541 """
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
542 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
543 if not hasattr(self, '_annotationProcessors'):
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
544 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
545 if hasattr(self, '_declaredAnnotationProcessors'):
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
546 aps = set(self._declaredAnnotationProcessors)
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
547 for ap in aps:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
548 if project(ap).definedAnnotationProcessorsDist is None:
16847
043575a99815 moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents: 16846
diff changeset
549 config = join(project(ap).source_dirs()[0], 'META-INF', 'services', 'javax.annotation.processing.Processor')
043575a99815 moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents: 16846
diff changeset
550 if not exists(config):
043575a99815 moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents: 16846
diff changeset
551 TimeStampFile(config).touch()
043575a99815 moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents: 16846
diff changeset
552 abort('Project ' + ap + ' declared in annotationProcessors property of ' + self.name + ' does not define any annotation processors.\n' +
043575a99815 moved NodeInfo processor into a separate project to avoid injecting Truffle DSL annotation processor into Graal projects
Doug Simon <doug.simon@oracle.com>
parents: 16846
diff changeset
553 'Please specify the annotation processors in ' + config)
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
554
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
555 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
556 for p in allDeps:
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
557 # Add an annotation processor dependency
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
558 if p.definedAnnotationProcessorsDist is not None:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
559 aps.add(p.name)
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
560
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
561 # Inherit annotation processors from dependencies
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
562 aps.update(p.annotation_processors())
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
563
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
564 self._annotationProcessors = sorted(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
565 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
566
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
567 """
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
568 Gets the class path composed of the distribution jars containing the
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
569 annotation processors that will be applied when compiling this project.
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
570 """
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
571 def annotation_processors_path(self):
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
572 aps = [project(ap) for ap in self.annotation_processors()]
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
573 libAps = [dep for dep in self.all_deps([], includeLibs=True, includeSelf=False) if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true']
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
574 if len(aps) + len(libAps):
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
575 return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist] + [lib.get_path(False) for lib in libAps])
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
576 return None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
577
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
578 def uses_annotation_processor_library(self):
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
579 for dep in self.all_deps([], includeLibs=True, includeSelf=False):
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
580 if dep.isLibrary() and hasattr(dep, 'annotationProcessor'):
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
581 return True
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
582 return False
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
583
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
584 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
585 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
586 outOfDate = False
12641
851aa5341214 moved persistent annotation processor dependency files into mx/currentAnnotationProcessors directory
Doug Simon <doug.simon@oracle.com>
parents: 12640
diff changeset
587 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
588 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
589 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
590 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
591 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
592 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
593 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
594 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
595 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
596 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
597 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
598 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
599 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
600 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
601
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
602 def make_archive(self, path=None):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
603 outputDir = self.output_dir()
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
604 if not path:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
605 path = join(self.dir, self.name + '.jar')
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
606 with Archiver(path) as arc:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
607 for root, _, files in os.walk(outputDir):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
608 for f in files:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
609 relpath = root[len(outputDir) + 1:]
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
610 arcname = join(relpath, f).replace(os.sep, '/')
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
611 arc.zf.write(join(root, f), arcname)
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
612 return path
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
613
14964
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
614 def _make_absolute(path, prefix):
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
615 """
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
616 Makes 'path' absolute if it isn't already by prefixing 'prefix'
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
617 """
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
618 if not isabs(path):
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
619 return join(prefix, path)
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
620 return path
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
621
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
622 def sha1OfFile(path):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
623 with open(path, 'rb') as f:
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
624 d = hashlib.sha1()
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
625 while True:
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
626 buf = f.read(4096)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
627 if not buf:
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
628 break
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
629 d.update(buf)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
630 return d.hexdigest()
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
631
16720
ad19df13df14 mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents: 16706
diff changeset
632 def download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False, canSymlink=True):
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
633 canSymlink = canSymlink and not (get_os() == 'windows' or get_os() == 'cygwin')
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
634 def _download_lib():
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
635 cacheDir = _cygpathW2U(get_env('MX_CACHE_DIR', join(_opts.user_home, '.mx', 'cache')))
16598
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
636 if not exists(cacheDir):
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
637 os.makedirs(cacheDir)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
638 base = basename(path)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
639 cachePath = join(cacheDir, base + '_' + sha1)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
640
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
641 if not exists(cachePath) or sha1OfFile(cachePath) != sha1:
16598
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
642 if exists(cachePath):
21395
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
643 log('SHA1 of ' + cachePath + ' does not match expected value (' + sha1 + ') - found ' + sha1OfFile(cachePath) + ' - re-downloading')
16598
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
644 print 'Downloading ' + ("sources " if sources else "") + name + ' from ' + str(urls)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
645 download(cachePath, urls)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
646
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
647 d = dirname(path)
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
648 if d != '' and not exists(d):
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
649 os.makedirs(d)
16720
ad19df13df14 mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents: 16706
diff changeset
650
ad19df13df14 mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents: 16706
diff changeset
651 if canSymlink and 'symlink' in dir(os):
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
652 if exists(path):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
653 os.unlink(path)
21880
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
654 try:
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
655 os.symlink(cachePath, path)
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
656 except OSError as e:
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
657 # When doing parallel building, the symlink can fail
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
658 # if another thread wins the race to create the symlink
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
659 if not exists(path):
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
660 # It was some other error
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
661 raise e
518052de60d5 handle race creating a symlink in mx
Doug Simon <doug.simon@oracle.com>
parents: 21872
diff changeset
662
16598
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
663 else:
edf653f51521 added per-user cache for mx downloads
Doug Simon <doug.simon@oracle.com>
parents: 16539
diff changeset
664 shutil.copy(cachePath, path)
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
665
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
666 def _sha1Cached():
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
667 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
668 return f.read()[0:40]
e666c172c9aa mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents: 14153
diff changeset
669
e666c172c9aa mx: some cleanup around sha1 digest support
Bernhard Urban <bernhard.urban@jku.at>
parents: 14153
diff changeset
670 def _writeSha1Cached():
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
671 with open(sha1path, 'w') as f:
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
672 f.write(sha1OfFile(path))
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
673
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
674 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
675 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
676 _download_lib()
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
677
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
678 if exists(path):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
679 if sha1 and not exists(sha1path):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
680 _writeSha1Cached()
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
681
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
682 if sha1 and sha1 != _sha1Cached():
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
683 _download_lib()
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
684 if sha1 != sha1OfFile(path):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
685 abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?")
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
686 _writeSha1Cached()
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
687
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
688 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
689
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
690 class BaseLibrary(Dependency):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
691 def __init__(self, suite, name, optional):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
692 Dependency.__init__(self, suite, name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
693 self.optional = optional
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
694
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
695 def __ne__(self, other):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
696 result = self.__eq__(other)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
697 if result is NotImplemented:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
698 return result
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
699 return not result
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
700
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
701 """
16671
7cdd7ede912d mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16670
diff changeset
702 A library that will be provided by the JRE but may be absent.
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
703 Any project or normal library that depends on a missing library
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
704 will be removed from the global project and library dictionaries
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
705 (i.e., _projects and _libs).
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
706
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
707 This mechanism exists primarily to be able to support code
16671
7cdd7ede912d mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16670
diff changeset
708 that may use functionality in one JRE (e.g., Oracle JRE)
7cdd7ede912d mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16670
diff changeset
709 that is not present in another JRE (e.g., OpenJDK). A
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
710 motivating example is the Java Flight Recorder library
16671
7cdd7ede912d mx: fix comments: jrelibrary is about the JRE, not the JDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16670
diff changeset
711 found in the Oracle JRE.
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
712 """
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
713 class JreLibrary(BaseLibrary):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
714 def __init__(self, suite, name, jar, optional):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
715 BaseLibrary.__init__(self, suite, name, optional)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
716 self.jar = jar
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
717
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
718 def __eq__(self, other):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
719 if isinstance(other, JreLibrary):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
720 return self.jar == other.jar
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
721 else:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
722 return NotImplemented
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
723
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
724 def is_present_in_jdk(self, jdk):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
725 return jdk.containsJar(self.jar)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
726
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
727 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
728 """
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
729 Add the transitive set of dependencies for this JRE library to the 'deps' list.
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
730 """
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
731 if includeJreLibs and includeSelf and not self in deps:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
732 deps.append(self)
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
733 return sorted(deps)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
734
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
735 class Library(BaseLibrary):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
736 def __init__(self, suite, name, path, optional, urls, sha1, sourcePath, sourceUrls, sourceSha1, deps):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
737 BaseLibrary.__init__(self, suite, name, optional)
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
738 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
739 self.urls = urls
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
740 self.sha1 = sha1
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
741 self.sourcePath = sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
742 self.sourceUrls = sourceUrls
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
743 if sourcePath == path:
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
744 assert sourceSha1 is None or sourceSha1 == sha1
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
745 sourceSha1 = sha1
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
746 self.sourceSha1 = sourceSha1
15149
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
747 self.deps = deps
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
748 abspath = _make_absolute(path, self.suite.dir)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
749 if not optional and not exists(abspath):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
750 if not len(urls):
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
751 abort('Non-optional library {0} must either exist at {1} or specify one or more URLs from which it can be retrieved'.format(name, abspath))
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
752
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
753 def _checkSha1PropertyCondition(propName, cond, inputPath):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
754 if not cond:
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
755 absInputPath = _make_absolute(inputPath, self.suite.dir)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
756 if exists(absInputPath):
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
757 abort('Missing "{0}" property for library {1}. Add the following line to projects file:\nlibrary@{2}@{3}={4}'.format(propName, name, name, propName, sha1OfFile(absInputPath)))
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
758 abort('Missing "{0}" property for library {1}'.format(propName, name))
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
759
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
760 _checkSha1PropertyCondition('sha1', sha1, path)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
761 _checkSha1PropertyCondition('sourceSha1', not sourcePath or sourceSha1, sourcePath)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
762
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
763 for url in urls:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
764 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
765 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
766
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
767 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
768 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
769 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
770 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
771 else:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
772 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
773 else:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
774 return NotImplemented
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
775
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
776 def get_path(self, resolve):
14964
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
777 path = _make_absolute(self.path, self.suite.dir)
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
778 sha1path = path + '.sha1'
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
779
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
780 includedInJDK = getattr(self, 'includedInJDK', None)
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
781 # TODO since we don't know which JDK will be used, this check is dubious
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
782 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
783 return None
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
784
16725
22b2950a0613 workaround for buggy pylint warning
Doug Simon <doug.simon@oracle.com>
parents: 16720
diff changeset
785 bootClassPathAgent = getattr(self, 'bootClassPathAgent').lower() == 'true' if hasattr(self, 'bootClassPathAgent') else False
16720
ad19df13df14 mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents: 16706
diff changeset
786
ad19df13df14 mx: add support for Java agent libraries that use the Boot-Class-Path manifest attribute to ensure that are loaded by the boot class path loader
Doug Simon <doug.simon@oracle.com>
parents: 16706
diff changeset
787 return download_file_with_sha1(self.name, path, self.urls, self.sha1, sha1path, resolve, not self.optional, canSymlink=not bootClassPathAgent)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
788
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
789 def get_source_path(self, resolve):
15147
d93cc1fdf55e Fix Library.get_source_path (use sourcePath instead of path)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15135
diff changeset
790 if self.sourcePath is None:
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
791 return None
15147
d93cc1fdf55e Fix Library.get_source_path (use sourcePath instead of path)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15135
diff changeset
792 path = _make_absolute(self.sourcePath, self.suite.dir)
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
793 sha1path = path + '.sha1'
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
794
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16598
diff changeset
795 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
796
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
797 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
798 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
799 if path and (exists(path) or not resolve):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
800 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
801
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
802 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
15149
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
803 """
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
804 Add the transitive set of dependencies for this library to the 'deps' list.
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
805 """
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
806 if not includeLibs:
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
807 return sorted(deps)
15149
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
808 childDeps = list(self.deps)
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
809 if self in deps:
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
810 return sorted(deps)
15149
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
811 for name in childDeps:
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
812 assert name != self.name
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
813 dep = library(name)
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
814 if not dep in deps:
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
815 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
15149
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
816 if not self in deps and includeSelf:
2c7b18ae25d2 Add support for library dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15148
diff changeset
817 deps.append(self)
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
818 return sorted(deps)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
819
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
820 class HgConfig:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
821 """
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
822 Encapsulates access to Mercurial (hg)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
823 """
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
824 def __init__(self):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
825 self.missing = 'no hg executable found'
12512
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
826 self.has_hg = None
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
827
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
828 def check(self, abortOnFail=True):
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
829 if self.has_hg is None:
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
830 try:
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
831 subprocess.check_output(['hg'])
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
832 self.has_hg = True
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
833 except OSError:
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
834 self.has_hg = False
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
835 warn(self.missing)
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
836
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
837 if not self.has_hg:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
838 if abortOnFail:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
839 abort(self.missing)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
840 else:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
841 warn(self.missing)
12512
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
842
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
843 def tip(self, sDir, abortOnError=True):
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
844 try:
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
845 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
846 except OSError:
21aa1ce5c666 made hg be called lazily
Doug Simon <doug.simon@oracle.com>
parents: 12508
diff changeset
847 warn(self.missing)
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
848 except subprocess.CalledProcessError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
849 if abortOnError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
850 abort('failed to get tip revision id')
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
851 else:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
852 return None
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
853
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
854 def isDirty(self, sDir, abortOnError=True):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
855 try:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
856 return len(subprocess.check_output(['hg', 'status', '-R', sDir])) > 0
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
857 except OSError:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
858 warn(self.missing)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
859 except subprocess.CalledProcessError:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
860 if abortOnError:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
861 abort('failed to get status')
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
862 else:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
863 return None
20119
1b9841bb304d fixed pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 20112
diff changeset
864
1b9841bb304d fixed pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 20112
diff changeset
865 def locate(self, sDir, patterns=None, abortOnError=True):
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
866 try:
20119
1b9841bb304d fixed pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 20112
diff changeset
867 if patterns is None:
1b9841bb304d fixed pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 20112
diff changeset
868 patterns = []
1b9841bb304d fixed pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 20112
diff changeset
869 elif not isinstance(patterns, list):
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
870 patterns = [patterns]
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
871 return subprocess.check_output(['hg', 'locate', '-R', sDir] + patterns).split('\n')
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
872 except OSError:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
873 warn(self.missing)
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
874 except subprocess.CalledProcessError as e:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
875 if e.returncode == 1:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
876 # hg locate returns 1 if no matches were found
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
877 return []
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
878 if abortOnError:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
879 abort('failed to locate')
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
880 else:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
881 return None
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15386
diff changeset
882
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
883 def _load_suite_dict(mxDir):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
884
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
885 suffix = 1
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
886 suite = None
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
887 dictName = 'suite'
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
888
17169
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
889 def expand(value, context):
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
890 if isinstance(value, types.DictionaryType):
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
891 for n, v in value.iteritems():
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
892 value[n] = expand(v, context + [n])
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
893 elif isinstance(value, types.ListType):
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
894 for i in range(len(value)):
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
895 value[i] = expand(value[i], context + [str(i)])
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
896 else:
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
897 if not isinstance(value, types.StringTypes):
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
898 abort('value of ' + '.'.join(context) + ' is of unexpected type ' + str(type(value)))
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
899 value = expandvars(value)
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
900 if '$' in value or '%' in value:
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
901 abort('value of ' + '.'.join(context) + ' contains an undefined environment variable: ' + value)
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
902
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
903 return value
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
904
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
905 moduleName = 'suite'
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
906 modulePath = join(mxDir, moduleName + '.py')
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
907 while exists(modulePath):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
908
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
909 savedModule = sys.modules.get(moduleName)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
910 if savedModule:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
911 warn(modulePath + ' conflicts with ' + savedModule.__file__)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
912 # temporarily extend the Python path
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
913 sys.path.insert(0, mxDir)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
914
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
915 snapshot = frozenset(sys.modules.keys())
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
916 module = __import__(moduleName)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
917
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
918 if savedModule:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
919 # restore the old module into the module name space
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
920 sys.modules[moduleName] = savedModule
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
921 else:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
922 # remove moduleName from the module name space
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
923 sys.modules.pop(moduleName)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
924
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
925 # For now fail fast if extra modules were loaded.
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
926 # This can later be relaxed to simply remove the extra modules
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
927 # from the sys.modules name space if necessary.
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
928 extraModules = frozenset(sys.modules.keys()) - snapshot
17396
83bbc0e5891a removed suite_helper.py and inlined common maven URL prefix
Doug Simon <doug.simon@oracle.com>
parents: 17262
diff changeset
929 assert len(extraModules) == 0, 'loading ' + modulePath + ' caused extra modules to be loaded: ' + ', '.join([m for m in extraModules])
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
930
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
931 # revert the Python path
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
932 del sys.path[0]
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
933
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
934 if not hasattr(module, dictName):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
935 abort(modulePath + ' must define a variable named "' + dictName + '"')
17169
a8c0553cb2e4 restore support for expanding environment variables in suite declarations
Doug Simon <doug.simon@oracle.com>
parents: 17163
diff changeset
936 d = expand(getattr(module, dictName), [dictName])
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
937 sections = ['projects', 'libraries', 'jrelibraries', 'distributions'] + (['distribution_extensions'] if suite else ['name', 'mxversion'])
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
938 unknown = frozenset(d.keys()) - frozenset(sections)
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
939 if unknown:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
940 abort(modulePath + ' defines unsupported suite sections: ' + ', '.join(unknown))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
941
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
942 if suite is None:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
943 suite = d
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
944 else:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
945 for s in sections:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
946 existing = suite.get(s)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
947 additional = d.get(s)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
948 if additional:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
949 if not existing:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
950 suite[s] = additional
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
951 else:
18620
23de014b38ab mx: fix missing frozenset constructor to fix intersection
Andreas Woess <andreas.woess@jku.at>
parents: 18602
diff changeset
952 conflicting = frozenset(additional.keys()) & frozenset(existing.keys())
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
953 if conflicting:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
954 abort(modulePath + ' redefines: ' + ', '.join(conflicting))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
955 existing.update(additional)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
956 distExtensions = d.get('distribution_extensions')
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
957 if distExtensions:
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
958 existing = suite['distributions']
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
959 for n, attrs in distExtensions.iteritems():
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
960 original = existing.get(n)
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
961 if not original:
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
962 abort('cannot extend non-existing distribution ' + n)
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
963 for k, v in attrs.iteritems():
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
964 if k != 'dependencies':
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
965 abort('Only the dependencies of distribution ' + n + ' can be extended')
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
966 if not isinstance(v, types.ListType):
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
967 abort('distribution_extensions.' + n + '.dependencies must be a list')
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
968 original['dependencies'] += v
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
969
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
970 dictName = 'extra'
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
971 moduleName = 'suite' + str(suffix)
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
972 modulePath = join(mxDir, moduleName + '.py')
17186
ca13853abf0d mx: fix pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 17184
diff changeset
973
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
974 deprecatedModulePath = join(mxDir, 'projects' + str(suffix) + '.py')
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
975 if exists(deprecatedModulePath):
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
976 abort('Please rename ' + deprecatedModulePath + ' to ' + modulePath)
17186
ca13853abf0d mx: fix pylint issues
Doug Simon <doug.simon@oracle.com>
parents: 17184
diff changeset
977
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
978 suffix = suffix + 1
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
979
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
980 return suite, modulePath
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
981
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
982 class Suite:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
983 def __init__(self, mxDir, primary, load=True):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
984 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
985 self.mxDir = mxDir
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
986 self.projects = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
987 self.libs = []
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
988 self.jreLibs = []
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
989 self.dists = []
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
990 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
991 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
992 self.requiredMxVersion = None
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
993 self.name = _suitename(mxDir) # validated in _load_projects
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
994 if load:
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
995 # just check that there are no imports
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
996 self._load_imports()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
997 self._load_env()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
998 self._load_commands()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
999 _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
1000
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
1001 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
1002 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
1003
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1004 def _load_projects(self):
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
1005 suitePyFile = join(self.mxDir, 'suite.py')
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
1006 if not exists(suitePyFile):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1007 return
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1008
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1009 suiteDict, _ = _load_suite_dict(self.mxDir)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1010
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1011 if suiteDict.get('name') is not None and suiteDict.get('name') != self.name:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1012 abort('suite name in project file does not match ' + _suitename(self.mxDir))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1013
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1014 if suiteDict.has_key('mxversion'):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1015 try:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1016 self.requiredMxVersion = VersionSpec(suiteDict['mxversion'])
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1017 except AssertionError as ae:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1018 abort('Exception while parsing "mxversion" in project file: ' + str(ae))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1019
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1020 libsMap = suiteDict['libraries']
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1021 jreLibsMap = suiteDict['jrelibraries']
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1022 projsMap = suiteDict['projects']
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1023 distsMap = suiteDict['distributions']
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1024
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1025 def pop_list(attrs, name, context):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1026 v = attrs.pop(name, None)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1027 if not v:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1028 return []
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1029 if not isinstance(v, list):
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1030 abort('Attribute "' + name + '" for ' + context + ' must be a list')
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1031 return v
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1032
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1033 for name, attrs in sorted(projsMap.iteritems()):
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1034 context = 'project ' + name
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1035 srcDirs = pop_list(attrs, 'sourceDirs', context)
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1036 deps = pop_list(attrs, 'dependencies', context)
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1037 ap = pop_list(attrs, 'annotationProcessors', context)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1038 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
1039 subDir = attrs.pop('subDir', None)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1040 if subDir is None:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
1041 d = join(self.dir, name)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1042 else:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
1043 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
1044 workingSets = attrs.pop('workingSets', None)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
1045 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
1046 p.checkstyleProj = attrs.pop('checkstyle', name)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1047 p.native = attrs.pop('native', '') == 'true'
21395
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
1048 p.checkPackagePrefix = attrs.pop('checkPackagePrefix', 'true') == 'true'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1049 if not p.native and p.javaCompliance is None:
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1050 abort('javaCompliance property required for non-native project ' + name)
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1051 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
1052 p._declaredAnnotationProcessors = ap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1053 p.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1054 self.projects.append(p)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1055
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1056 for name, attrs in sorted(jreLibsMap.iteritems()):
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1057 jar = attrs.pop('jar')
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1058 # JRE libraries are optional by default
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1059 optional = attrs.pop('optional', 'true') != 'false'
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1060 l = JreLibrary(self, name, jar, optional)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1061 self.jreLibs.append(l)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1062
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1063 for name, attrs in sorted(libsMap.iteritems()):
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1064 context = 'library ' + name
17013
0b2675391d01 mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
1065 if "|" in name:
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1066 if name.count('|') != 2:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
1067 abort("Format error in library name: " + name + "\nsyntax: libname|os-platform|architecture")
17013
0b2675391d01 mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
1068 name, platform, architecture = name.split("|")
0b2675391d01 mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
1069 if platform != get_os() or architecture != get_arch():
0b2675391d01 mx library: support platform/architecture specific libraries
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
1070 continue
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
1071 path = attrs.pop('path')
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1072 urls = pop_list(attrs, 'urls', context)
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
1073 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
1074 sourcePath = attrs.pop('sourcePath', None)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1075 sourceUrls = pop_list(attrs, 'sourceUrls', context)
14133
d2e4b81fd8f0 mx: support sha1 digest for dependencies
Bernhard Urban <bernhard.urban@jku.at>
parents: 14103
diff changeset
1076 sourceSha1 = attrs.pop('sourceSha1', None)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1077 deps = pop_list(attrs, 'dependencies', context)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1078 # Add support optional libraries once we have a good use case
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1079 optional = False
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1080 l = Library(self, name, path, optional, urls, sha1, sourcePath, sourceUrls, sourceSha1, deps)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1081 l.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1082 self.libs.append(l)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1083
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1084 for name, attrs in sorted(distsMap.iteritems()):
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1085 context = 'distribution ' + name
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1086 path = attrs.pop('path')
14937
3de340bdb8d3 added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents: 14918
diff changeset
1087 sourcesPath = attrs.pop('sourcesPath', None)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1088 deps = pop_list(attrs, 'dependencies', context)
15819
2460aed6c899 mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 15818
diff changeset
1089 mainClass = attrs.pop('mainClass', None)
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1090 exclDeps = pop_list(attrs, 'exclude', context)
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
1091 distDeps = pop_list(attrs, 'distDependencies', context)
17059
a5dc5513ce85 mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents: 17050
diff changeset
1092 javaCompliance = attrs.pop('javaCompliance', None)
a5dc5513ce85 mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents: 17050
diff changeset
1093 d = Distribution(self, name, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1094 d.__dict__.update(attrs)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1095 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
1096
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1097 # Create a distribution for each project that defines annotation processors
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1098 for p in self.projects:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1099 annotationProcessors = None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1100 for srcDir in p.source_dirs():
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1101 configFile = join(srcDir, 'META-INF', 'services', 'javax.annotation.processing.Processor')
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1102 if exists(configFile):
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1103 with open(configFile) as fp:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1104 annotationProcessors = [ap.strip() for ap in fp]
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1105 if len(annotationProcessors) != 0:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1106 for ap in annotationProcessors:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1107 if not ap.startswith(p.name):
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1108 abort(ap + ' in ' + configFile + ' does not start with ' + p.name)
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1109 if annotationProcessors:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1110 dname = p.name.replace('.', '_').upper()
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1111 apDir = join(p.dir, 'ap')
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1112 path = join(apDir, p.name + '.jar')
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1113 sourcesPath = None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1114 deps = [p.name]
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1115 mainClass = None
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1116 exclDeps = []
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1117 distDeps = []
17059
a5dc5513ce85 mx: add check for compliance level of a distribution
Bernhard Urban <bernhard.urban@jku.at>
parents: 17050
diff changeset
1118 javaCompliance = None
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
1119 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance, True)
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1120 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir)
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1121 self.dists.append(d)
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1122 p.definedAnnotationProcessors = annotationProcessors
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1123 p.definedAnnotationProcessorsDist = d
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1124 d.definingProject = p
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1125
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1126 # Restrict exported annotation processors to those explicitly defined by the project
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1127 def _refineAnnotationProcessorServiceConfig(dist):
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1128 aps = dist.definingProject.definedAnnotationProcessors
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1129 apsJar = dist.path
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1130 config = 'META-INF/services/javax.annotation.processing.Processor'
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1131 with zipfile.ZipFile(apsJar, 'r') as zf:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1132 currentAps = zf.read(config).split()
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1133 if currentAps != aps:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1134 logv('[updating ' + config + ' in ' + apsJar + ']')
18602
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1135 with Archiver(apsJar) as arc:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1136 with zipfile.ZipFile(apsJar, 'r') as lp:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1137 for arcname in lp.namelist():
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1138 if arcname == config:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1139 arc.zf.writestr(arcname, '\n'.join(aps))
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1140 else:
7d8270532cd9 mx: changes towards supporting python 2.6 for call to mx from make/Makefile
Doug Simon <doug.simon@oracle.com>
parents: 18601
diff changeset
1141 arc.zf.writestr(arcname, lp.read(arcname))
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1142 d.add_update_listener(_refineAnnotationProcessorServiceConfig)
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
1143 self.dists.append(d)
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
1144
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
1145 if self.name is None:
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
1146 abort('Missing "suite=<name>" in ' + suitePyFile)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1147
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1148 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
1149 return 'mx_' + self.name.replace('-', '_')
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1150
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1151 def _find_commands(self, name):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1152 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
1153 if exists(commandsPath):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1154 return name
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1155 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1156 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1157
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1158 def _load_commands(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1159 commandsName = self._find_commands(self._commands_name())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1160 if commandsName is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1161 # backwards compatibility
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1162 commandsName = self._find_commands('commands')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1163 if commandsName is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1164 if commandsName in sys.modules:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1165 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
1166 # temporarily extend the Python path
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1167 sys.path.insert(0, self.mxDir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1168 mod = __import__(commandsName)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1169
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1170 self.commands = sys.modules.pop(commandsName)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1171 sys.modules[commandsName] = self.commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1172
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1173 # revert the Python path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1174 del sys.path[0]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1175
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1176 if not hasattr(mod, 'mx_init'):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1177 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
1178 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
1179 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
1180
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1181 mod.mx_init(self)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1182 self.commands = mod
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1183
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1184 def _load_imports(self):
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1185 if exists(join(self.mxDir, 'imports')):
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1186 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
1187
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1188 def _load_env(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1189 e = join(self.mxDir, 'env')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1190 if exists(e):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1191 with open(e) as f:
10585
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
1192 lineNum = 0
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1193 for line in f:
10585
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
1194 lineNum = lineNum + 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1195 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1196 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
1197 if not '=' in line:
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
1198 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
1199 key, value = line.split('=', 1)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1200 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
1201
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
1202 def _post_init(self, opts):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1203 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
1204 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
1205 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
1206 elif self.requiredMxVersion > version:
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1207 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
1208 # 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
1209 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
1210 existing = _projects.get(p.name)
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1211 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
1212 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
1213 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
1214 _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
1215 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
1216 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
1217 # 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
1218 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
1219 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
1220 _libs[l.name] = l
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1221 for l in self.jreLibs:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1222 existing = _jreLibs.get(l.name)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1223 # Check that suites that define same library are consistent
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1224 if existing is not None and existing != l:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1225 abort('inconsistent JRE library redefinition of ' + l.name + ' in ' + existing.suite.dir + ' and ' + l.suite.dir)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1226 _jreLibs[l.name] = l
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1227 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
1228 existing = _dists.get(d.name)
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1229 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
1230 # 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
1231 # abort('cannot redefine distribution ' + d.name)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1232 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
1233 d.path = existing.path
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1234 _dists[d.name] = d
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1235
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1236 # Remove projects and libraries that (recursively) depend on an optional library
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1237 # whose artifact does not exist or on a JRE library that is not present in the
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1238 # JDK for a project. Also remove projects whose Java compliance requirement
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1239 # cannot be satisfied by the configured JDKs.
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1240 #
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1241 # Removed projects and libraries are also removed from
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1242 # distributions in they are listed as dependencies.
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1243 ommittedDeps = set()
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1244 for d in sorted_deps(includeLibs=True):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1245 if d.isLibrary():
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1246 if d.optional:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1247 try:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1248 d.optional = False
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1249 path = d.get_path(resolve=True)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1250 except SystemExit:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1251 path = None
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1252 finally:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1253 d.optional = True
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1254 if not path:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1255 logv('[omitting optional library {0} as {1} does not exist]'.format(d, d.path))
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1256 ommittedDeps.add(d.name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1257 del _libs[d.name]
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1258 self.libs.remove(d)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1259 elif d.isProject():
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1260 if java(d.javaCompliance, cancel='some projects will be omitted which may result in errrors') is None:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1261 logv('[omitting project {0} as Java compliance {1} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance))
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1262 ommittedDeps.add(d.name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1263 del _projects[d.name]
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1264 self.projects.remove(d)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1265 else:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1266 for name in list(d.deps):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1267 jreLib = _jreLibs.get(name)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1268 if jreLib:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1269 if not jreLib.is_present_in_jdk(java(d.javaCompliance)):
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1270 if jreLib.optional:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1271 logv('[omitting project {0} as dependency {1} is missing]'.format(d, name))
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1272 ommittedDeps.add(d.name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1273 del _projects[d.name]
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1274 self.projects.remove(d)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1275 else:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1276 abort('JRE library {0} required by {1} not found'.format(jreLib, d))
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1277 elif not dependency(name, fatalIfMissing=False):
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1278 logv('[omitting project {0} as dependency {1} is missing]'.format(d, name))
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1279 ommittedDeps.add(d.name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1280 del _projects[d.name]
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1281 self.projects.remove(d)
16629
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1282 for dist in _dists.itervalues():
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1283 for name in list(dist.deps):
21634
0a2fc09f6ed6 mx: make dependency omission more strict so that a distribution that lists a non-existent project is detected
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21613
diff changeset
1284 if name in ommittedDeps:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
1285 logv('[omitting {0} from distribution {1}]'.format(name, dist))
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1286 dist.deps.remove(name)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1287
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
1288 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
1289 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
1290
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1291 class XMLElement(xml.dom.minidom.Element):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1292 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
1293 writer.write(indent + "<" + self.tagName)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1294
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1295 attrs = self._get_attributes()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1296 a_names = attrs.keys()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1297 a_names.sort()
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1298
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1299 for a_name in a_names:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1300 writer.write(" %s=\"" % a_name)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1301 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
1302 writer.write("\"")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1303 if self.childNodes:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1304 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
1305 # 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
1306 # 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
1307 writer.write(">")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1308 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
1309 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
1310 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1311 writer.write(">%s" % (newl))
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1312 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
1313 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
1314 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
1315 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1316 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
1317
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1318 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
1319
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
1320 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
1321 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
1322 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
1323 self.padTextNodeWithoutSiblings = False
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1324
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1325 def createElement(self, tagName):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1326 # overwritten to create XMLElement
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1327 e = XMLElement(tagName)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1328 e.ownerDocument = self
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1329 return e
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1330
8302
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
1331 def comment(self, txt):
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
1332 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
1333
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1334 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
1335 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
1336 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
1337 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
1338 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
1339 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
1340 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
1341 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
1342 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
1343 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
1344 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
1345
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1346 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
1347 assert self.current != self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1348 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
1349 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
1350 return self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1351
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1352 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
1353 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
1354 attributes = {}
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1355 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
1356
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
1357 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
1358 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
1359 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
1360 if escape:
13968
6c6d1eacc398 mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1361 entities = {'"': "&quot;", "'": "&apos;", '\n': '&#10;'}
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
1362 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
1363 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
1364 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
1365 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
1366
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1367 def get_jython_os():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1368 from java.lang import System as System
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1369 os_name = System.getProperty('os.name').lower()
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1370 if System.getProperty('isCygwin'):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1371 return 'cygwin'
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1372 elif os_name.startswith('mac'):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1373 return 'darwin'
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1374 elif os_name.startswith('linux'):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1375 return 'linux'
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1376 elif os_name.startswith('sunos'):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1377 return 'solaris'
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1378 elif os_name.startswith('win'):
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1379 return 'windows'
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1380 else:
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1381 abort('Unknown operating system ' + os_name)
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1382
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1383 def get_os():
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1384 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1385 Get a canonical form of sys.platform.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1386 """
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1387 if is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1388 return get_jython_os()
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1389 elif sys.platform.startswith('darwin'):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1390 return 'darwin'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1391 elif sys.platform.startswith('linux'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1392 return 'linux'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1393 elif sys.platform.startswith('sunos'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1394 return 'solaris'
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1395 elif sys.platform.startswith('win32'):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1396 return 'windows'
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1397 elif sys.platform.startswith('cygwin'):
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1398 return 'cygwin'
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1399 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1400 abort('Unknown operating system ' + sys.platform)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1401
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1402 def _cygpathU2W(p):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1403 """
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1404 Translate a path from unix-style to windows-style.
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1405 This method has no effects on other platforms than cygwin.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1406 """
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1407 if p is None or get_os() != "cygwin":
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1408 return p
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1409 return subprocess.check_output(['cygpath', '-a', '-w', p]).strip()
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1410
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1411 def _cygpathW2U(p):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1412 """
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1413 Translate a path from windows-style to unix-style.
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1414 This method has no effects on other platforms than cygwin.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1415 """
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1416 if p is None or get_os() != "cygwin":
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1417 return p
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1418 return subprocess.check_output(['cygpath', '-a', '-u', p]).strip()
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1419
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1420 def _separatedCygpathU2W(p):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1421 """
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1422 Translate a group of paths, separated by a path separator.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1423 unix-style to windows-style.
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1424 This method has no effects on other platforms than cygwin.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1425 """
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1426 if p is None or p == "" or get_os() != "cygwin":
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1427 return p
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1428 return ';'.join(map(_cygpathU2W, p.split(os.pathsep)))
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1429
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1430 def _separatedCygpathW2U(p):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1431 """
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1432 Translate a group of paths, separated by a path separator.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1433 windows-style to unix-style.
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1434 This method has no effects on other platforms than cygwin.
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1435 """
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1436 if p is None or p == "" or get_os() != "cygwin":
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1437 return p
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
1438 return os.pathsep.join(map(_cygpathW2U, p.split(';')))
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1439
17012
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1440 def get_arch():
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1441 machine = platform.uname()[4]
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1442 if machine in ['amd64', 'AMD64', 'x86_64', 'i86pc']:
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1443 return 'amd64'
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1444 if machine in ['sun4v', 'sun4u']:
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1445 return 'sparcv9'
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1446 if machine == 'i386' and get_os() == 'darwin':
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1447 try:
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1448 # Support for Snow Leopard and earlier version of MacOSX
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1449 if subprocess.check_output(['sysctl', '-n', 'hw.cpu64bit_capable']).strip() == '1':
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1450 return 'amd64'
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1451 except OSError:
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1452 # sysctl is not available
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1453 pass
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1454 abort('unknown or unsupported architecture: os=' + get_os() + ', machine=' + machine)
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16947
diff changeset
1455
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1456 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
1457 """
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1458 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
1459 """
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1460 for s in _suites.itervalues():
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1461 if s.mxDir == mxDir:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1462 return s
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1463 # create the new suite
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1464 s = Suite(mxDir, primary)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1465 return s
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1466
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1467 def suites(opt_limit_to_suite=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1468 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1469 Get the list of all loaded suites.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1470 """
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1471 return _suites.values()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1472
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
1473 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
1474 """
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
1475 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
1476 """
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
1477 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
1478 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
1479 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
1480 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
1481
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1482
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
1483 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
1484 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1485 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
1486 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1487 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
1488 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
1489 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
1490 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
1491
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1492 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
1493 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1494 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
1495 """
16944
a04d9cbc149f mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16875
diff changeset
1496 sortedProjects = sorted(_projects.values(), key=lambda p: p.name)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1497 if opt_limit_to_suite:
16944
a04d9cbc149f mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16875
diff changeset
1498 return _projects_opt_limit_to_suites(sortedProjects)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1499 else:
16944
a04d9cbc149f mx: Make order of projects() deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16875
diff changeset
1500 return sortedProjects
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1501
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1502 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
1503 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1504 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
1505 """
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
1506 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
1507
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1508 def _projects_opt_limit_to_suites(projects):
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
1509 return projects
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1510
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
1511 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
1512 """
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
1513 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
1514 """
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
1515 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
1516 if _annotationProcessors is None:
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1517 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
1518 for p in projects():
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1519 for ap in p.annotation_processors():
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1520 if project(ap, False):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1521 aps.add(ap)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1522 _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
1523 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
1524
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1525 def distribution(name, fatalIfMissing=True):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1526 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1527 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
1528 not exist and 'fatalIfMissing' is true.
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1529 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1530 d = _dists.get(name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1531 if d is None and fatalIfMissing:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1532 abort('distribution named ' + name + ' not found')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1533 return d
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1534
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1535 def dependency(name, fatalIfMissing=True):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1536 """
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1537 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
1538 not exist for 'name' and 'fatalIfMissing' is true.
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1539 """
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1540 d = _projects.get(name)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1541 if d is None:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1542 d = _libs.get(name)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1543 if d is None:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
1544 d = _jreLibs.get(name)
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1545 if d is None and fatalIfMissing:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1546 if name in _opts.ignored_projects:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1547 abort('project named ' + name + ' is ignored')
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1548 abort('project or library named ' + name + ' not found')
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1549 return d
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1550
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1551 def project(name, fatalIfMissing=True):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1552 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1553 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
1554 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1555 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1556 p = _projects.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1557 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
1558 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
1559 abort('project named ' + name + ' is ignored')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1560 abort('project named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1561 return p
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1562
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1563 def library(name, fatalIfMissing=True):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1564 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1565 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
1566 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1567 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1568 l = _libs.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1569 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
1570 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
1571 abort(name + ' is a project, not a library')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1572 abort('library named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1573 return l
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1574
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1575 def _as_classpath(deps, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1576 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1577 if _opts.cp_prefix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1578 cp = [_opts.cp_prefix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1579 for d in deps:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1580 d.append_to_classpath(cp, resolve)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1581 if _opts.cp_suffix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1582 cp += [_opts.cp_suffix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1583 return os.pathsep.join(cp)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1584
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1585 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
1586 """
16417
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1587 Get the class path for a list of given dependencies and distributions, resolving each entry in the
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1588 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
1589 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1590 if names is None:
16417
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1591 deps = sorted_deps(includeLibs=True)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1592 dists = list(_dists.values())
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1593 else:
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1594 deps = []
16417
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1595 dists = []
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1596 if isinstance(names, types.StringTypes):
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1597 names = [names]
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1598 for n in names:
16417
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1599 dep = dependency(n, fatalIfMissing=False)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1600 if dep:
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1601 dep.all_deps(deps, True, includeSelf)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1602 else:
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1603 dist = distribution(n)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1604 if not dist:
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1605 abort('project, library or distribution named ' + n + ' not found')
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1606 dists.append(dist)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1607
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1608 if len(dists):
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1609 distsDeps = set()
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1610 for d in dists:
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1611 distsDeps.update(d.sorted_deps())
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1612
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1613 # remove deps covered by a dist that will be on the class path
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1614 deps = [d for d in deps if d not in distsDeps]
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1615
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1616 result = _as_classpath(deps, resolve)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1617
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1618 # prepend distributions
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1619 if len(dists):
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1620 distsCp = os.pathsep.join(dist.path for dist in dists)
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1621 if len(result):
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1622 result = distsCp + os.pathsep + result
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1623 else:
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1624 result = distsCp
9fe3cb463079 mx: classpath function now accepts distributions as well (which are prepend to the class path)
Doug Simon <doug.simon@oracle.com>
parents: 16269
diff changeset
1625
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1626 if includeBootClasspath:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1627 result = os.pathsep.join([java().bootclasspath(), result])
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
1628
18116
c4f649042a7b mx/unittest: fix cygwin path issue
Bernhard Urban <bernhard.urban@jku.at>
parents: 17396
diff changeset
1629 return result
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1630
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1631 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
1632 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1633 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
1634 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
1635 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
1636 to the classpath entry.
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1637 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1638 cp = classpath(names, resolve, includeSelf, includeBootClasspath)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1639 for entry in cp.split(os.pathsep):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1640 if not exists(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1641 continue
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1642 if isdir(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1643 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
1644 for d in dirs:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1645 entryPath = join(root[len(entry) + 1:], d)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1646 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1647 for f in files:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1648 entryPath = join(root[len(entry) + 1:], f)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1649 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1650 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
1651 with zipfile.ZipFile(entry, 'r') as zf:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1652 for zi in zf.infolist():
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1653 entryPath = zi.filename
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1654 yield zf, entryPath
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1655
15785
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
1656 def sorted_deps(projectNames=None, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1657 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1658 Gets projects and libraries sorted such that dependencies
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1659 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
1660 true, libraries are omitted from the result.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1661 """
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
1662 projects = projects_from_names(projectNames)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1663
15785
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
1664 return sorted_project_deps(projects, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
1665
16629
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1666 def sorted_dists():
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1667 """
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1668 Gets distributions sorted such that each distribution comes after
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1669 any distributions it depends upon.
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1670 """
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1671 dists = []
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1672 def add_dist(dist):
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1673 if not dist in dists:
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1674 for depDist in [distribution(name) for name in dist.distDependencies]:
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1675 add_dist(depDist)
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1676 if not dist in dists:
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1677 dists.append(dist)
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1678
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1679 for d in _dists.itervalues():
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1680 add_dist(d)
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1681 return dists
be59a1d39281 respect dependency order between distributions when building them
Doug Simon <doug.simon@oracle.com>
parents: 16623
diff changeset
1682
15785
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
1683 def sorted_project_deps(projects, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1684 deps = []
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1685 for p in projects:
15785
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
1686 p.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1687 return deps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1688
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1689 class ArgParser(ArgumentParser):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1690 # 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
1691 def format_help(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1692 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
1693
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1694
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1695 def __init__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1696 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
1697 # 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
1698 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
1699
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1700 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
1701 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
1702 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
1703 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
1704 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
1705 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"')
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
1706 self.add_argument('--backup-modified', action='store_true', help='backup generated files if they pre-existed and are modified')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1707 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
1708 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
1709 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
1710 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
1711 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
1712 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~'))
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1713 self.add_argument('--java-home', help='primary JDK directory (must be JDK 7 or later)', metavar='<path>')
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1714 self.add_argument('--extra-java-homes', help='secondary JDK directories separated by "' + os.pathsep + '"', metavar='<path>')
21514
b426469fadb7 mx: better description for strict-compliance and fix typo
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21208
diff changeset
1715 self.add_argument('--strict-compliance', action='store_true', dest='strict_compliance', help='Projects with an explicit compliance will only be built if a JDK exactly matching the compliance is available', default=False)
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
1716 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
1717 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
1718 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
1719 # 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
1720 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
1721 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
1722
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1723 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
1724 if args is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1725 args = sys.argv[1:]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1726
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1727 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
1728
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1729 opts = self.parse_args()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1730
18636
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
1731 global _opts
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
1732 _opts = opts
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
1733
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1734 # Give the timeout options a default value to avoid the need for hasattr() tests
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1735 opts.__dict__.setdefault('timeout', 0)
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1736 opts.__dict__.setdefault('ptimeout', 0)
4149
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
1737
5091
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1738 if opts.very_verbose:
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1739 opts.verbose = True
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1740
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1741 if opts.user_home is None or opts.user_home == '':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1742 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
1743
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1744 if opts.java_home:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1745 os.environ['JAVA_HOME'] = opts.java_home
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1746 os.environ['HOME'] = opts.user_home
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1747
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1748 if os.environ.get('STRICT_COMPLIANCE'):
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1749 _opts.strict_compliance = True
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1750
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
1751 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
1752
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1753 commandAndArgs = opts.__dict__.pop('commandAndArgs')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1754 return opts, commandAndArgs
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1755
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1756 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
1757 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
1758
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1759 def _format_commands():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1760 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
1761 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
1762 c, _ = _commands[cmd][:2]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1763 doc = c.__doc__
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1764 if doc is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1765 doc = ''
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1766 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
1767 return msg + '\n'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1768
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1769 _canceled_java_requests = set()
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1770
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1771 def java(requiredCompliance=None, purpose=None, cancel=None):
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1772 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1773 Get a JavaConfig object containing Java commands launch details.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1774 If requiredCompliance is None, the compliance level specified by --java-home/JAVA_HOME
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1775 is returned. Otherwise, the JavaConfig exactly matching requiredCompliance is returned
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1776 or None if there is no exact match.
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1777 """
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1778
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1779 global _default_java_home
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1780 if cancel and (requiredCompliance, purpose) in _canceled_java_requests:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1781 return None
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1782
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1783 if not requiredCompliance:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1784 if not _default_java_home:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1785 _default_java_home = _find_jdk(purpose=purpose, cancel=cancel)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1786 if not _default_java_home:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1787 assert cancel
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1788 _canceled_java_requests.add((requiredCompliance, purpose))
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1789 return _default_java_home
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1790
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1791 if _opts.strict_compliance:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1792 complianceCheck = requiredCompliance.exactMatch
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1793 desc = str(requiredCompliance)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1794 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1795 compVersion = VersionSpec(str(requiredCompliance))
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1796 complianceCheck = lambda version: version >= compVersion
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1797 desc = '>=' + str(requiredCompliance)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1798
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1799 for java in _extra_java_homes:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1800 if complianceCheck(java.version):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1801 return java
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1802
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1803 jdk = _find_jdk(versionCheck=complianceCheck, versionDescription=desc, purpose=purpose, cancel=cancel)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1804 if jdk:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1805 assert jdk not in _extra_java_homes
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1806 _extra_java_homes.append(jdk)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1807 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1808 assert cancel
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1809 _canceled_java_requests.add((requiredCompliance, purpose))
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1810 return jdk
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1811
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1812 def java_version(versionCheck, versionDescription=None, purpose=None):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1813 if _default_java_home and versionCheck(_default_java_home.version):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1814 return _default_java_home
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1815 for java in _extra_java_homes:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1816 if versionCheck(java.version):
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1817 return java
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1818 jdk = _find_jdk(versionCheck, versionDescription, purpose)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1819 assert jdk not in _extra_java_homes
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1820 _extra_java_homes.append(jdk)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1821 return jdk
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1822
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1823 def _find_jdk(versionCheck=None, versionDescription=None, purpose=None, cancel=None):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1824 if not versionCheck:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1825 versionCheck = lambda v: True
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1826 assert not versionDescription or versionCheck
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1827 if not versionCheck and not purpose:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1828 isDefaultJdk = True
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1829 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1830 isDefaultJdk = False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1831
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1832 candidateJdks = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1833 source = ''
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1834 if _opts.java_home:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1835 candidateJdks.append(_opts.java_home)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1836 source = '--java-home'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1837 elif os.environ.get('JAVA_HOME'):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1838 candidateJdks.append(os.environ.get('JAVA_HOME'))
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1839 source = 'JAVA_HOME'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1840
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1841 result = _find_jdk_in_candidates(candidateJdks, versionCheck, warn=True, source=source)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1842 if result:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1843 return result
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1844
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1845 candidateJdks = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1846
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1847 if _opts.extra_java_homes:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1848 candidateJdks += _opts.extra_java_homes.split(os.pathsep)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1849 source = '--extra-java-homes'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1850 elif os.environ.get('EXTRA_JAVA_HOMES'):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1851 candidateJdks += os.environ.get('EXTRA_JAVA_HOMES').split(os.pathsep)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1852 source = 'EXTRA_JAVA_HOMES'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1853
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1854 result = _find_jdk_in_candidates(candidateJdks, versionCheck, warn=True, source=source)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1855 if not result:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1856 candidateJdks = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1857 source = ''
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1858
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1859 if get_os() == 'darwin':
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1860 base = '/Library/Java/JavaVirtualMachines'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1861 if exists(base):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1862 candidateJdks = [join(base, n, 'Contents/Home') for n in os.listdir(base)]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1863 elif get_os() == 'linux':
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1864 base = '/usr/lib/jvm'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1865 if exists(base):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1866 candidateJdks = [join(base, n) for n in os.listdir(base)]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1867 base = '/usr/java'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1868 if exists(base):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1869 candidateJdks += [join(base, n) for n in os.listdir(base)]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1870 elif get_os() == 'solaris':
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1871 base = '/usr/jdk/instances'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1872 if exists(base):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1873 candidateJdks = [join(base, n) for n in os.listdir(base)]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1874 elif get_os() == 'windows':
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1875 base = r'C:\Program Files\Java'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1876 if exists(base):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1877 candidateJdks = [join(base, n) for n in os.listdir(base)]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1878
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1879 configs = _filtered_jdk_configs(candidateJdks, versionCheck)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1880 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1881 if not isDefaultJdk:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1882 return result
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1883 configs = [result]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1884
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1885 if len(configs) > 1:
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1886 if not is_interactive():
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1887 msg = "Multiple possible choices for a JDK"
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1888 if purpose:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1889 msg += ' for' + purpose
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1890 msg += ': '
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1891 if versionDescription:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1892 msg += '(' + versionDescription + ')'
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1893 selected = configs[0]
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1894 msg += ". Selecting " + str(selected)
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1895 log(msg)
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1896 else:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1897 msg = 'Please select a '
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1898 if isDefaultJdk:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1899 msg += 'default '
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1900 msg += 'JDK'
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1901 if purpose:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1902 msg += ' for' + purpose
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1903 msg += ': '
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1904 if versionDescription:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1905 msg += '(' + versionDescription + ')'
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1906 log(msg)
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1907 choices = configs + ['<other>']
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1908 if cancel:
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1909 choices.append('Cancel (' + cancel + ')')
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1910 selected = select_items(choices, allowMultiple=False)
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1911 if isinstance(selected, types.StringTypes) and selected == '<other>':
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1912 selected = None
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1913 if isinstance(selected, types.StringTypes) and selected == 'Cancel (' + cancel + ')':
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1914 return None
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1915 elif len(configs) == 1:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1916 selected = configs[0]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1917 msg = 'Selected ' + str(selected) + ' as '
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1918 if isDefaultJdk:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1919 msg += 'default'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1920 msg += 'JDK'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1921 if versionDescription:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1922 msg = msg + ' ' + versionDescription
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1923 if purpose:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1924 msg += ' for' + purpose
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1925 log(msg)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1926 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1927 msg = 'Could not find any JDK'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1928 if purpose:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1929 msg += ' for' + purpose
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1930 msg += ' '
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1931 if versionDescription:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1932 msg = msg + '(' + versionDescription + ')'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1933 log(msg)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1934 selected = None
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1935
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1936 while not selected:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1937 jdkLocation = raw_input('Enter path of JDK: ')
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1938 selected = _find_jdk_in_candidates([jdkLocation], versionCheck, warn=True)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1939
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1940 varName = 'JAVA_HOME' if isDefaultJdk else 'EXTRA_JAVA_HOMES'
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1941 allowMultiple = not isDefaultJdk
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1942 envPath = join(_primary_suite.mxDir, 'env')
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1943 if is_interactive() and ask_yes_no('Persist this setting by adding "{0}={1}" to {2}'.format(varName, selected.jdk, envPath), 'y'):
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1944 envLines = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1945 with open(envPath) as fp:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1946 append = True
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1947 for line in fp:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1948 if line.rstrip().startswith(varName):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1949 _, currentValue = line.split('=', 1)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1950 currentValue = currentValue.strip()
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1951 if not allowMultiple and currentValue:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1952 if not ask_yes_no('{0} is already set to {1}, overwrite with {2}?'.format(varName, currentValue, selected.jdk), 'n'):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1953 return selected
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1954 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1955 line = varName + '=' + selected.jdk + os.linesep
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1956 else:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1957 line = line.rstrip()
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1958 if currentValue:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1959 line += os.pathsep
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1960 line += selected.jdk + os.linesep
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1961 append = False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1962 envLines.append(line)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1963 if append:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1964 envLines.append(varName + '=' + selected.jdk)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1965
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1966 with open(envPath, 'w') as fp:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1967 for line in envLines:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1968 fp.write(line)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1969
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1970 if varName == 'JAVA_HOME':
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1971 os.environ['JAVA_HOME'] = selected.jdk
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1972
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1973 return selected
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1974
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1975 def is_interactive():
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1976 return sys.__stdin__.isatty()
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1977
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1978 def _filtered_jdk_configs(candidates, versionCheck, warn=False, source=None):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1979 filtered = []
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1980 for candidate in candidates:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1981 try:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1982 config = JavaConfig(candidate)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1983 if versionCheck(config.version):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1984 filtered.append(config)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1985 except JavaConfigException as e:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1986 if warn:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1987 log('Path in ' + source + "' is not pointing to a JDK (" + e.message + ")")
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1988 return filtered
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1989
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1990 def _find_jdk_in_candidates(candidates, versionCheck, warn=False, source=None):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1991 filtered = _filtered_jdk_configs(candidates, versionCheck, warn, source)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1992 if filtered:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
1993 return filtered[0]
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1994 return None
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
1995
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1996
14913
2d1cc640512c Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14907
diff changeset
1997 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
1998 if not javaConfig:
2d1cc640512c Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14907
diff changeset
1999 javaConfig = java()
2d1cc640512c Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14907
diff changeset
2000 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
2001
14153
e328f28f7401 fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents: 14136
diff changeset
2002 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
2003 if not sig:
5454f6bf50bf fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents: 14136
diff changeset
2004 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
2005 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
2006 try:
14134
e71d421370f3 mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents: 14133
diff changeset
2007 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
2008 return True
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2009 except:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2010 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
2011 return False
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2012
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
2013 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
2014 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
2015 while True:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
2016 try:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
2017 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
2018 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
2019 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
2020 continue
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
2021 raise
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2022
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
2023 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
2024 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
2025 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
2026 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
2027 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
2028 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
2029 # 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
2030 raise RuntimeError("Unknown child exit status!")
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2031
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
2032 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
2033 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
2034 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
2035 (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
2036 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
2037 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
2038 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
2039 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
2040 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
2041 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
2042 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
2043
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
2044 # Makes the current subprocess accessible to the abort() function
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2045 # This is a list of tuples of the subprocess.Popen or
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2046 # multiprocessing.Process object and args.
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2047 _currentSubprocesses = []
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2048
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2049 def _addSubprocess(p, args):
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2050 entry = (p, args)
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2051 _currentSubprocesses.append(entry)
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2052 return entry
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2053
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2054 def _removeSubprocess(entry):
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2055 if entry and entry in _currentSubprocesses:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2056 try:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2057 _currentSubprocesses.remove(entry)
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2058 except:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2059 pass
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2060
4660
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2061 def waitOn(p):
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2062 if get_os() == 'windows':
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2063 # 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
2064 retcode = None
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2065 while retcode == None:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2066 retcode = p.poll()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2067 time.sleep(0.05)
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2068 else:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2069 retcode = p.wait()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2070 return retcode
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
2071
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
2072 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
2073 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2074 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
2075 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
2076 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
2077 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
2078 out and err if they are callable objects.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2079 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2080
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2081 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
2082 for arg in args:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2083 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
2084
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
2085 if env is None:
18898
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2086 env = os.environ.copy()
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2087
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2088 # Ideally the command line could be communicated directly in an environment
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2089 # variable. However, since environment variables share the same resource
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2090 # space as the command line itself (on Unix at least), this would cause the
18900
7e500c20208c fixed pylint issue
Doug Simon <doug.simon@oracle.com>
parents: 18899
diff changeset
2091 # limit to be exceeded too easily.
18930
9aa1cff041eb fix in mx.py, MX_SUBPROCESS_COMMAND_FILE opened twice, fails on Windows
Christian Wirth <christian.wirth@oracle.com>
parents: 18900
diff changeset
2092 with tempfile.NamedTemporaryFile(suffix='', prefix='mx_subprocess_command.', mode='w', delete=False) as fp:
9aa1cff041eb fix in mx.py, MX_SUBPROCESS_COMMAND_FILE opened twice, fails on Windows
Christian Wirth <christian.wirth@oracle.com>
parents: 18900
diff changeset
2093 subprocessCommandFile = fp.name
18898
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2094 for arg in args:
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2095 # TODO: handle newlines in args once there's a use case
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2096 assert '\n' not in arg
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2097 print >> fp, arg
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2098 env['MX_SUBPROCESS_COMMAND_FILE'] = subprocessCommandFile
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2099
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2100 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
2101 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
2102 log('Environment variables:')
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
2103 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
2104 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
2105 log(' '.join(map(pipes.quote, args)))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2106
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2107 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
2108 timeout = _opts.ptimeout
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2109
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2110 sub = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2111 try:
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2112 # 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
2113 # 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
2114 preexec_fn = None
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
2115 creationflags = 0
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2116 if not is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2117 if get_os() == 'windows':
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2118 creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2119 else:
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2120 preexec_fn = os.setsid
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
2121 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
2122 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
2123 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
2124 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
2125 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
2126 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
2127 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2128 sub = _addSubprocess(p, args)
15871
11bf5b8973c9 mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents: 15863
diff changeset
2129 joiners = []
12689
697ef4cf18c0 mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12684
diff changeset
2130 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
2131 t = Thread(target=redirect, args=(p.stdout, out))
15701
16059f6f5661 mx: drain *all* output from subprocess if redirecting to functions
Doug Simon <doug.simon@oracle.com>
parents: 15697
diff changeset
2132 # Don't make the reader thread a daemon otherwise output can be droppped
12689
697ef4cf18c0 mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12684
diff changeset
2133 t.start()
15871
11bf5b8973c9 mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents: 15863
diff changeset
2134 joiners.append(t)
12689
697ef4cf18c0 mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12684
diff changeset
2135 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
2136 t = Thread(target=redirect, args=(p.stderr, err))
15701
16059f6f5661 mx: drain *all* output from subprocess if redirecting to functions
Doug Simon <doug.simon@oracle.com>
parents: 15697
diff changeset
2137 # Don't make the reader thread a daemon otherwise output can be droppped
12689
697ef4cf18c0 mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12684
diff changeset
2138 t.start()
15871
11bf5b8973c9 mx: drain all subprocess output to callables before returning from mx.run
Doug Simon <doug.simon@oracle.com>
parents: 15863
diff changeset
2139 joiners.append(t)
15898
c102edf38127 mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents: 15897
diff changeset
2140 while any([t.is_alive() for t in joiners]):
c102edf38127 mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents: 15897
diff changeset
2141 # Need to use timeout otherwise all signals (including CTRL-C) are blocked
c102edf38127 mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents: 15897
diff changeset
2142 # see: http://bugs.python.org/issue1167930
c102edf38127 mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents: 15897
diff changeset
2143 for t in joiners:
c102edf38127 mx: prevent CTRL-C from being blocked while subprocess is running (re-applied without unrelated changes)
Doug Simon <doug.simon@oracle.com>
parents: 15897
diff changeset
2144 t.join(10)
12689
697ef4cf18c0 mx.run should support streams for out/err even if there is no timeout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12684
diff changeset
2145 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
2146 retcode = waitOn(p)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2147 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
2148 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
2149 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
2150 retcode = _waitWithTimeout(p, args, timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2151 except OSError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2152 log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2153 if _opts.verbose:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2154 raise e
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2155 abort(e.errno)
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
2156 except KeyboardInterrupt:
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
2157 abort(1)
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
2158 finally:
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2159 _removeSubprocess(sub)
18898
d199e643f23b mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
Doug Simon <doug.simon@oracle.com>
parents: 18897
diff changeset
2160 os.remove(subprocessCommandFile)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2161
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2162 if retcode and nonZeroIsFatal:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2163 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
2164 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
2165 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
2166 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2167 log('[exit code: ' + str(retcode) + ']')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2168 abort(retcode)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2169
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2170 return retcode
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2171
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2172 def exe_suffix(name):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2173 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2174 Gets the platform specific suffix for an executable
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2175 """
4258
8d2c14f722ac mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents: 4257
diff changeset
2176 if get_os() == 'windows':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2177 return name + '.exe'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2178 return name
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2179
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2180 def add_lib_prefix(name):
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2181 """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2182 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
2183 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2184 os = get_os()
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2185 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
2186 return 'lib' + name
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2187 return name
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2188
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2189 def add_lib_suffix(name):
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2190 """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
2191 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
2192 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2193 os = get_os()
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
2194 if os == 'windows':
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
2195 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
2196 if os == 'linux' or os == 'solaris':
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
2197 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
2198 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
2199 return name + '.dylib'
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
2200 return name
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
2201
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2202 """
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
2203 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
2204 """
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
2205 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
2206 """
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
2207 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
2208 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
2209 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
2210 """
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
2211 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
2212 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
2213 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
2214 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
2215 self.currentFilteredLineCount = 0
7c36ec150036 Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14156
diff changeset
2216 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
2217
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
2218 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
2219 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
2220 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
2221 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
2222 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
2223 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
2224 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
2225 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
2226
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
2227 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
2228 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
2229 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
2230 self.currentFilteredLineCount += 1
7c36ec150036 Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14156
diff changeset
2231 if self.currentFilteredTime:
7c36ec150036 Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14156
diff changeset
2232 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
2233 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
2234 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
2235 else:
7c36ec150036 Make the DuplicateSuppressingStream periodically print while it is filtering output
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14156
diff changeset
2236 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
2237 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
2238 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
2239 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
2240 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
2241 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
2242
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
2243 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2244 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
2245 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2246 class JavaCompliance:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2247 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
2248 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
2249 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
2250 self.value = int(m.group(1))
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2251
13968
6c6d1eacc398 mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
2252 def __str__(self):
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2253 return '1.' + str(self.value)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2254
13968
6c6d1eacc398 mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
2255 def __cmp__(self, other):
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2256 if isinstance(other, types.StringType):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2257 other = JavaCompliance(other)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2258
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2259 return cmp(self.value, other.value)
13779
fc5e2c808a23 fixed pylint warnings
Doug Simon <doug.simon@oracle.com>
parents: 13775
diff changeset
2260
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
2261 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
2262 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
2263
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2264 def exactMatch(self, version):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2265 assert isinstance(version, VersionSpec)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2266 return len(version.parts) > 1 and version.parts[0] == 1 and version.parts[1] == self.value
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2267
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2268 """
13471
020099961eb4 renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents: 13470
diff changeset
2269 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
2270 """
13471
020099961eb4 renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents: 13470
diff changeset
2271 class VersionSpec:
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2272 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
2273 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
2274 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
2275 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
2276 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
2277 self.versionString = versionString
8391
d1d486c03e8a Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8302
diff changeset
2278 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
2279
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2280 def __str__(self):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2281 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
2282
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2283 def __cmp__(self, other):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2284 return cmp(self.parts, other.parts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2285
14940
82971f397b94 mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14939
diff changeset
2286 def _filter_non_existant_paths(paths):
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2287 if paths:
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2288 return os.pathsep.join([path for path in _separatedCygpathW2U(paths).split(os.pathsep) if exists(path)])
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2289 return None
14940
82971f397b94 mx.JavaConfig: filter non-existant paths from bootclasspath, extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14939
diff changeset
2290
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2291 class JavaConfigException(Exception):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2292 def __init__(self, value):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2293 Exception.__init__(self, value)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2294
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2295 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2296 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
2297 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2298 class JavaConfig:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2299 def __init__(self, java_home):
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2300 self.jdk = java_home
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2301 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
2302 self.java = exe_suffix(join(self.jdk, 'bin', 'java'))
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2303 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac'))
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2304 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
2305 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc'))
15863
f04a541af3c9 mx: add pack200 to javaconfig
Bernhard Urban <bernhard.urban@jku.at>
parents: 15861
diff changeset
2306 self.pack200 = exe_suffix(join(self.jdk, 'bin', 'pack200'))
14913
2d1cc640512c Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14907
diff changeset
2307 self.toolsjar = join(self.jdk, 'lib', 'tools.jar')
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2308 self._classpaths_initialized = False
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2309 self._bootclasspath = None
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
2310 self._extdirs = None
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
2311 self._endorseddirs = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2312
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
2313 if not exists(self.java):
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2314 raise JavaConfigException('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
2315
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2316 def delAtAndSplit(s):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2317 return shlex.split(s.lstrip('@'))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2318
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
2319 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
2320 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
2321 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
2322
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2323 # 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
2324 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
2325 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
2326 self.java_args = ['-d64'] + self.java_args
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2327 except subprocess.CalledProcessError as e:
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
2328 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
2329 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
2330 except subprocess.CalledProcessError as e:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2331 raise JavaConfigException(e.returncode + " :" + e.output)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2332
16534
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2333 def _checkOutput(out):
16539
cc30bd72a19b mx: fix in java version parsing
Bernhard Urban <bernhard.urban@jku.at>
parents: 16534
diff changeset
2334 return 'version' in out
16534
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2335
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2336 # hotspot can print a warning, e.g. if there's a .hotspot_compiler file in the cwd
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2337 output = output.split('\n')
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2338 version = None
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2339 for o in output:
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2340 if _checkOutput(o):
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2341 assert version is None
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2342 version = o
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2343
4aaa97f42b92 mx: be less strict while parsing the jvm version
Bernhard Urban <bernhard.urban@jku.at>
parents: 16455
diff changeset
2344 self.version = VersionSpec(version.split()[2].strip('"'))
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2345 self.javaCompliance = JavaCompliance(self.version.versionString)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2346
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2347 if _opts.java_dbg_port is not None:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2348 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(_opts.java_dbg_port)]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2349
14914
a6bd486b1b44 Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14913
diff changeset
2350 def _init_classpaths(self):
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2351 if not self._classpaths_initialized:
21472
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
2352 _, binDir = _compile_mx_class('ClasspathDump', jdk=self)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
2353 self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', _cygpathU2W(binDir), 'ClasspathDump'], stderr=subprocess.PIPE).split('|')]
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2354 if self.javaCompliance <= JavaCompliance('1.8'):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2355 # All 3 system properties accessed by ClasspathDump are expected to exist
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2356 if not self._bootclasspath or not self._extdirs or not self._endorseddirs:
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2357 warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'")
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2358 self._bootclasspath = _filter_non_existant_paths(self._bootclasspath)
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2359 self._extdirs = _filter_non_existant_paths(self._extdirs)
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2360 self._endorseddirs = _filter_non_existant_paths(self._endorseddirs)
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2361 self._classpaths_initialized = True
14914
a6bd486b1b44 Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14913
diff changeset
2362
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2363 def __repr__(self):
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2364 return "JavaConfig(" + str(self.jdk) + ")"
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2365
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2366 def __str__(self):
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2367 return "Java " + str(self.version) + " (" + str(self.javaCompliance) + ") from " + str(self.jdk)
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2368
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2369 def __hash__(self):
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2370 return hash(self.jdk)
14764
5823c399e28f pylint fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
2371
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2372 def __cmp__(self, other):
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2373 if isinstance(other, JavaConfig):
18889
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2374 compilanceCmp = cmp(self.javaCompliance, other.javaCompliance)
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2375 if compilanceCmp:
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2376 return compilanceCmp
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2377 versionCmp = cmp(self.version, other.version)
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2378 if versionCmp:
4dc7b1f66de3 mx: JavaConfig: compare compilance and version before path
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18887
diff changeset
2379 return versionCmp
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
2380 return cmp(self.jdk, other.jdk)
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2381 raise TypeError()
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2382
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
2383 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
2384 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
2385 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
2386 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
2387 return [self.java] + args
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2388
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
2389 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
2390 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
2391
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2392 def bootclasspath(self):
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2393 self._init_classpaths()
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2394 return _separatedCygpathU2W(self._bootclasspath)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2395
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
2396
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2397 """
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2398 Add javadoc style options for the library paths of this JDK.
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2399 """
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2400 def javadocLibOptions(self, args):
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2401 self._init_classpaths()
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2402 if args is None:
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2403 args = []
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2404 if self._bootclasspath:
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2405 args.append('-bootclasspath')
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2406 args.append(self._bootclasspath)
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2407 if self._extdirs:
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2408 args.append('-extdirs')
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2409 args.append(self._extdirs)
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2410 return args
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2411
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2412 """
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2413 Add javac style options for the library paths of this JDK.
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2414 """
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2415 def javacLibOptions(self, args):
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2416 args = self.javadocLibOptions(args)
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2417 if self._endorseddirs:
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2418 args.append('-endorseddirs')
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2419 args.append(self._endorseddirs)
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2420 return args
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2421
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
2422 def containsJar(self, jar):
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2423 self._init_classpaths()
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2424
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2425 if self._bootclasspath:
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2426 for e in self._bootclasspath.split(os.pathsep):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2427 if basename(e) == jar:
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2428 return True
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2429 if self._extdirs:
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2430 for d in self._extdirs.split(os.pathsep):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2431 if len(d) and jar in os.listdir(d):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2432 return True
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2433 if self._endorseddirs:
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2434 for d in self._endorseddirs.split(os.pathsep):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2435 if len(d) and jar in os.listdir(d):
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
2436 return True
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17186
diff changeset
2437 return False
14914
a6bd486b1b44 Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14913
diff changeset
2438
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2439 def check_get_env(key):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2440 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2441 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
2442 """
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
2443 value = get_env(key)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2444 if value is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2445 abort('Required environment variable ' + key + ' must be set')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2446 return value
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2447
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
2448 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
2449 """
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
2450 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
2451 """
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
2452 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
2453 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
2454
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
2455 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
2456 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
2457 log(msg)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2458
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2459 def log(msg=None):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2460 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2461 Write a message to the console.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2462 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
2463 to redirect it.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2464 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2465 if msg is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2466 print
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2467 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2468 print msg
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2469
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2470 def expand_project_in_class_path_arg(cpArg):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2471 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2472 for part in cpArg.split(os.pathsep):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2473 if part.startswith('@'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2474 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
2475 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2476 cp.append(part)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2477 return os.pathsep.join(cp)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2478
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2479 def expand_project_in_args(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2480 for i in range(len(args)):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2481 if args[i] == '-cp' or args[i] == '-classpath':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2482 if i + 1 < len(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2483 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
2484 return
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2485
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2486
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2487 def gmake_cmd():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2488 for a in ['make', 'gmake', 'gnumake']:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2489 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2490 output = subprocess.check_output([a, '--version'])
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2491 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
2492 return a
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2493 except:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2494 pass
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2495 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
2496
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2497 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
2498 result = expandvars(value)
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2499 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
2500 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
2501 return result
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2502
14135
ee66410c0679 mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents: 14134
diff changeset
2503 def _send_sigquit():
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2504 for p, args in _currentSubprocesses:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2505
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2506 def _isJava():
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2507 if args:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2508 name = args[0].split(os.sep)[-1]
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2509 return name == "java"
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2510 return False
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2511
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2512 if p is not None and _isJava():
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2513 if get_os() == 'windows':
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2514 log("mx: implement me! want to send SIGQUIT to my child process")
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2515 else:
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2516 _kill_process_group(p.pid, sig=signal.SIGQUIT)
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2517 time.sleep(0.1)
14781
d2038d372cd2 changed distribution dependency exclusion mechanism to be only for library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 14775
diff changeset
2518
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2519 def abort(codeOrMessage):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2520 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2521 Aborts the program with a SystemExit exception.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2522 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
2523 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
2524 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
2525 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2526
18636
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
2527 if _opts and _opts.killwithsigquit:
14135
ee66410c0679 mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents: 14134
diff changeset
2528 _send_sigquit()
ee66410c0679 mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents: 14134
diff changeset
2529
15823
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2530 def is_alive(p):
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2531 if isinstance(p, subprocess.Popen):
15845
babe4565c371 mx: fixed incorrect test for subprocess being alive
twisti
parents: 15823
diff changeset
2532 return p.poll() is None
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2533 assert is_jython() or isinstance(p, multiprocessing.Process), p
15823
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2534 return p.is_alive()
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2535
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2536 for p, args in _currentSubprocesses:
15823
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2537 if is_alive(p):
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2538 try:
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2539 if get_os() == 'windows':
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2540 p.terminate()
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2541 else:
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2542 _kill_process_group(p.pid, signal.SIGKILL)
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2543 except BaseException as e:
9acad98567dc mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15822
diff changeset
2544 if is_alive(p):
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
2545 log('error while killing subprocess {0} "{1}": {2}'.format(p.pid, ' '.join(args), e))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2546
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
2547 if _opts and _opts.verbose:
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
2548 import traceback
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
2549 traceback.print_stack()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2550 raise SystemExit(codeOrMessage)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2551
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2552 def download(path, urls, verbose=False):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2553 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2554 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
2555 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
2556 is written to the file indicated by 'path'.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2557 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2558 d = dirname(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2559 if d != '' and not exists(d):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2560 os.makedirs(d)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2561
15925
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2562 assert not path.endswith(os.sep)
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2563
21472
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
2564 _, binDir = _compile_mx_class('URLConnectionDownload')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
2565
15925
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2566 verbose = []
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2567 if sys.stderr.isatty():
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2568 verbose.append("-v")
21472
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
2569 if run([java().java, '-cp', _cygpathU2W(binDir), 'URLConnectionDownload', _cygpathU2W(path)] + verbose + urls, nonZeroIsFatal=False) == 0:
15925
674d4065e9fb mxtool: remove python downloader
Bernhard Urban <bernhard.urban@jku.at>
parents: 15922
diff changeset
2570 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2571
4188
148fa38782e8 Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents: 4186
diff changeset
2572 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
2573 '\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
2574
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2575 def update_file(path, content):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2576 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2577 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
2578 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
2579 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2580 existed = exists(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2581 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2582 old = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2583 if existed:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2584 with open(path, 'rb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2585 old = f.read()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2586
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2587 if old == content:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2588 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2589
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2590 if existed and _opts.backup_modified:
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2591 shutil.move(path, path + '.orig')
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2592
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2593 with open(path, 'wb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2594 f.write(content)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2595
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2596 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
2597 return True
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2598 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
2599 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
2600
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2601 # Builtin commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2602
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2603 def _defaultEcjPath():
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2604 return get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar'))
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2605
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2606 class JavaCompileTask:
15496
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2607 def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, jdtJar, deps):
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2608 self.proj = proj
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2609 self.reason = reason
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2610 self.javafilelist = javafilelist
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2611 self.deps = deps
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2612 self.jdk = jdk
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2613 self.outputDir = outputDir
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2614 self.done = False
15496
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2615 self.jdtJar = jdtJar
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2616 self.args = args
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2617
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2618 def __str__(self):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2619 return self.proj.name
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2620
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2621 def logCompilation(self, compiler):
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
2622 log('Compiling Java sources for {0} with {1}... [{2}]'.format(self.proj.name, compiler, self.reason))
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2623
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2624 def execute(self):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2625 argfileName = join(self.proj.dir, 'javafilelist.txt')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2626 argfile = open(argfileName, 'wb')
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2627 argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist)))
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2628 argfile.close()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2629
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2630 processorArgs = []
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2631 processorPath = self.proj.annotation_processors_path()
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2632 if processorPath:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2633 genDir = self.proj.source_gen_dir()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2634 if exists(genDir):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2635 shutil.rmtree(genDir)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2636 os.mkdir(genDir)
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2637 processorArgs += ['-processorpath', _separatedCygpathU2W(join(processorPath)), '-s', _cygpathU2W(genDir)]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2638 else:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2639 processorArgs += ['-proc:none']
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2640
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2641 args = self.args
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2642 jdk = self.jdk
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2643 outputDir = _cygpathU2W(self.outputDir)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2644 compliance = str(jdk.javaCompliance)
18116
c4f649042a7b mx/unittest: fix cygwin path issue
Bernhard Urban <bernhard.urban@jku.at>
parents: 17396
diff changeset
2645 cp = _separatedCygpathU2W(classpath(self.proj.name, includeSelf=True))
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2646 toBeDeleted = [argfileName]
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2647
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2648 try:
15496
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2649 if not self.jdtJar:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2650 mainJava = java()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2651 if not args.error_prone:
16062
a864a411fad3 mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents: 16005
diff changeset
2652 javac = args.alt_javac if args.alt_javac else mainJava.javac
a864a411fad3 mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents: 16005
diff changeset
2653 self.logCompilation('javac' if not args.alt_javac else args.alt_javac)
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2654 javacCmd = [javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir]
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2655 jdk.javacLibOptions(javacCmd)
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2656 if _opts.java_dbg_port is not None:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
2657 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(_opts.java_dbg_port)]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2658 javacCmd += processorArgs
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2659 javacCmd += ['@' + _cygpathU2W(argfile.name)]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2660
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2661 if not args.warnAPI:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2662 javacCmd.append('-XDignore.symbol.file')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2663 run(javacCmd)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2664 else:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2665 self.logCompilation('javac (with error-prone)')
18710
4836c2abc884 mx: removed hard-coded -Xms setting for the 'build' and 'checkstyle' commands to try and avoid unnecessary swapping on low(er) memory machines
Doug Simon <doug.simon@oracle.com>
parents: 18647
diff changeset
2666 javaArgs = ['-Xmx1g']
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2667 javacArgs = ['-g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir]
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2668 jdk.javacLibOptions(javacCmd)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2669 javacArgs += processorArgs
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2670 javacArgs += ['@' + argfile.name]
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2671 if not args.warnAPI:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2672 javacArgs.append('-XDignore.symbol.file')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2673 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2674 else:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2675 self.logCompilation('JDT')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2676
18710
4836c2abc884 mx: removed hard-coded -Xms setting for the 'build' and 'checkstyle' commands to try and avoid unnecessary swapping on low(er) memory machines
Doug Simon <doug.simon@oracle.com>
parents: 18647
diff changeset
2677 jdtVmArgs = ['-Xmx1g', '-jar', _cygpathU2W(self.jdtJar)]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2678
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2679 jdtArgs = ['-' + compliance,
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2680 '-cp', cp, '-g', '-enableJavadoc',
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2681 '-d', outputDir]
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
2682 jdk.javacLibOptions(jdtArgs)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2683 jdtArgs += processorArgs
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2684
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2685 jdtProperties = join(self.proj.dir, '.settings', 'org.eclipse.jdt.core.prefs')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2686 rootJdtProperties = join(self.proj.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2687 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2688 # Try to fix a missing properties file by running eclipseinit
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
2689 _eclipseinit_project(self.proj)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2690 if not exists(jdtProperties):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2691 log('JDT properties file {0} not found'.format(jdtProperties))
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2692 else:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2693 with open(jdtProperties) as fp:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2694 origContent = fp.read()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2695 content = origContent
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
2696 if self.proj.uses_annotation_processor_library():
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
2697 # unfortunately, the command line compiler doesn't let us ignore warnings for generated files only
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
2698 content = content.replace('=warning', '=ignore')
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
2699 elif args.jdt_warning_as_error:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2700 content = content.replace('=warning', '=error')
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2701 if not args.jdt_show_task_tags:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2702 content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore'
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2703 if origContent != content:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2704 jdtPropertiesTmp = jdtProperties + '.tmp'
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2705 with open(jdtPropertiesTmp, 'w') as fp:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2706 fp.write(content)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2707 toBeDeleted.append(jdtPropertiesTmp)
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2708 jdtArgs += ['-properties', _cygpathU2W(jdtPropertiesTmp)]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2709 else:
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2710 jdtArgs += ['-properties', _cygpathU2W(jdtProperties)]
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17259
diff changeset
2711 jdtArgs.append('@' + _cygpathU2W(argfile.name))
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2712
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2713 run_java(jdtVmArgs + jdtArgs)
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2714
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2715 # Create annotation processor jar for a project that defines annotation processors
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2716 if self.proj.definedAnnotationProcessorsDist:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2717 self.proj.definedAnnotationProcessorsDist.make_archive()
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2718
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2719 finally:
16947
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2720 # Do not clean up temp files if verbose as there's
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2721 # a good chance the user wants to copy and paste the
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2722 # Java compiler command directly
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2723 if not _opts.verbose:
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2724 for n in toBeDeleted:
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2725 os.remove(n)
7dbe1207fccf mx: do not clean up temp files from the build command if -v is specified
Doug Simon <doug.simon@oracle.com>
parents: 16945
diff changeset
2726
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2727 self.done = True
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2728
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2729 def build(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2730 """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
2731
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2732 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
2733 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
2734
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
2735 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
2736 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
2737 parser = ArgumentParser(prog='mx build')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2738
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
2739 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
2740 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
2741 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output')
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2742 parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation if possible')
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2743 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
2744 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2745 parser.add_argument('--check-distributions', action='store_true', dest='check_distributions', help='check built distributions for overlap')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2746 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
2747 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
2748 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
2749 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects')
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2750 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors')
15118
3a1f48125f53 added --jdt-show-task-tags option to build command
Doug Simon <doug.simon@oracle.com>
parents: 15087
diff changeset
2751 parser.add_argument('--jdt-show-task-tags', action='store_true', help='show task tags as Eclipse batch compiler warnings')
16062
a864a411fad3 mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents: 16005
diff changeset
2752 parser.add_argument('--alt-javac', dest='alt_javac', help='path to alternative javac executable', metavar='<path>')
15376
b3cd96f137a6 mx build: make --error-prone, --jdt and --force-javac mutually exclusive
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15364
diff changeset
2753 compilerSelect = parser.add_mutually_exclusive_group()
b3cd96f137a6 mx build: make --error-prone, --jdt and --force-javac mutually exclusive
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15364
diff changeset
2754 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>')
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2755 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>')
16062
a864a411fad3 mx: added -alt-javac option to build command to support an external javac executable (or javac wrapper)
Doug Simon <doug.simon@oracle.com>
parents: 16005
diff changeset
2756 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac whether ecj.jar is found or not')
15378
dea98caac669 Fix help text for ideinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15376
diff changeset
2757
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
2758 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
2759 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
2760
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2761 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
2762
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2763 if is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2764 if args.parallelize:
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2765 logv('[multiprocessing not available in jython]')
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2766 args.parallelize = False
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2767
15496
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2768 jdtJar = None
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2769 if not args.javac and args.jdt is not None:
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2770 if not args.jdt.endswith('.jar'):
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2771 abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt)
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2772 jdtJar = args.jdt
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2773 if not exists(jdtJar):
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2774 if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None:
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2775 # Silently ignore JDT if default location is used but does not exist
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2776 jdtJar = None
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2777 else:
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2778 abort('Eclipse batch compiler jar does not exist: ' + args.jdt)
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2779
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
2780 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
2781 # 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
2782 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
2783 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
2784 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
2785 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
2786 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
2787 projectNames = None
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
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 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
2790 # 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
2791 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
2792
21503
12e3d0dfffeb GRAAL-1090: Doug speeds up ./mx.sh build --only com.oracle.truffle.sl from 8s to 4s on my computer.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21472
diff changeset
2793 if args.java and jdtJar:
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
2794 ideinit([], refreshOnly=True, buildProcessorJars=False)
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2795
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2796 tasks = {}
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2797 updatedAnnotationProcessorDists = set()
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
2798 for p in sortedProjects:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2799 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2800 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2801 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
2802
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2803 if args.clean:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2804 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
2805
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2806 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
2807 continue
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2808 else:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2809 if not args.java:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2810 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2811 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
2812 continue
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2813
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2814 # skip building this Java project if its Java compliance level is "higher" than the configured JDK
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2815 requiredCompliance = p.javaCompliance if p.javaCompliance else JavaCompliance(args.compliance) if args.compliance else None
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
2816 jdk = java(requiredCompliance)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2817
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2818 outputDir = p.output_dir()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2819
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2820 sourceDirs = p.source_dirs()
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2821 buildReason = None
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2822 if args.force:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2823 buildReason = 'forced build'
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2824 elif args.clean:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2825 buildReason = 'clean'
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2826
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2827 taskDeps = []
16670
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2828 for dep in p.all_deps([], includeLibs=False, includeAnnotationProcessors=True):
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2829 taskDep = tasks.get(dep.name)
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2830 if taskDep:
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2831 if not buildReason:
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2832 buildReason = dep.name + ' rebuilt'
4ae1d1ed5cc1 fixed regression in use of -f option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 16667
diff changeset
2833 taskDeps.append(taskDep)
12631
2303d9e199e3 rebuild projects if their annotation processor dependencies change; clean output directories before (re)compiling a Java project
Doug Simon <doug.simon@oracle.com>
parents: 12630
diff changeset
2834
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
2835 javafilelist = []
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2836 nonjavafiletuples = []
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2837 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2838 for root, _, files in os.walk(sourceDir):
21776
0c60e14e7796 include package-info.java in mx driven Java compilation
Doug Simon <doug.simon@oracle.com>
parents: 21718
diff changeset
2839 javafiles = [join(root, name) for name in files if name.endswith('.java')]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2840 javafilelist += javafiles
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2841
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2842 nonjavafiletuples += [(sourceDir, [join(root, name) for name in files if not name.endswith('.java')])]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2843
15386
1439685d06e4 mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents: 15378
diff changeset
2844 if not buildReason:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2845 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
2846 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
2847 if not classfile.exists() or classfile.isOlderThan(javafile):
21781
d013bb1cbf9f mx: Filter package-info.class out when checking timestamps for java compilations
Doug Simon <doug.simon@oracle.com>
parents: 21776
diff changeset
2848 if basename(classfile.path) != 'package-info.class':
d013bb1cbf9f mx: Filter package-info.class out when checking timestamps for java compilations
Doug Simon <doug.simon@oracle.com>
parents: 21776
diff changeset
2849 buildReason = 'class file(s) out of date'
d013bb1cbf9f mx: Filter package-info.class out when checking timestamps for java compilations
Doug Simon <doug.simon@oracle.com>
parents: 21776
diff changeset
2850 break
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2851
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
2852 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
2853 if apsOutOfDate:
15386
1439685d06e4 mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents: 15378
diff changeset
2854 buildReason = 'annotation processor(s) changed'
1439685d06e4 mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents: 15378
diff changeset
2855
1439685d06e4 mx: log reason why Java classes are being (re)built
Doug Simon <doug.simon@oracle.com>
parents: 15378
diff changeset
2856 if not buildReason:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2857 logv('[all class files for {0} are up to date - skipping]'.format(p.name))
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2858 _handleNonJavaFiles(outputDir, p, False, nonjavafiletuples)
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
2859 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2860
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2861 _handleNonJavaFiles(outputDir, p, True, nonjavafiletuples)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2862
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
2863 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
2864 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
2865 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
2866
16945
5e5f5073d713 mx: Make java file list order deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16944
diff changeset
2867 javafilelist = sorted(javafilelist)
5e5f5073d713 mx: Make java file list order deterministic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16944
diff changeset
2868
15496
f5eba273a4f2 mx: factored out detection of JDT compilation
Doug Simon <doug.simon@oracle.com>
parents: 15490
diff changeset
2869 task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, jdtJar, taskDeps)
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2870 if p.definedAnnotationProcessorsDist:
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
2871 updatedAnnotationProcessorDists.add(p.definedAnnotationProcessorsDist)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2872
17050
49b8c8932786 projects must be rebuilt when any of their dependencies are rebuilt
Doug Simon <doug.simon@oracle.com>
parents: 17013
diff changeset
2873 tasks[p.name] = task
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2874 if args.parallelize:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2875 # Best to initialize class paths on main process
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2876 jdk.bootclasspath()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2877 task.proc = None
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2878 else:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2879 task.execute()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2880
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2881 if args.parallelize:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2882
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2883 def joinTasks(tasks):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2884 failed = []
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2885 for t in tasks:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2886 t.proc.join()
15786
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2887 _removeSubprocess(t.sub)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2888 if t.proc.exitcode != 0:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2889 failed.append(t)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2890 return failed
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2891
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2892 def checkTasks(tasks):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2893 active = []
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2894 for t in tasks:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2895 if t.proc.is_alive():
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2896 active.append(t)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2897 else:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2898 if t.proc.exitcode != 0:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2899 return ([], joinTasks(tasks))
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2900 return (active, [])
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2901
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2902 def remainingDepsDepth(task):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2903 if task._d is None:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2904 incompleteDeps = [d for d in task.deps if d.proc is None or d.proc.is_alive()]
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2905 if len(incompleteDeps) == 0:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2906 task._d = 0
14913
2d1cc640512c Add possibility to build using error-prone instead of javac.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14907
diff changeset
2907 else:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2908 task._d = max([remainingDepsDepth(t) for t in incompleteDeps]) + 1
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2909 return task._d
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2910
15490
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2911 def compareTasks(t1, t2):
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2912 d = remainingDepsDepth(t1) - remainingDepsDepth(t2)
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2913 if d == 0:
15497
1f28c463e452 mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents: 15496
diff changeset
2914 t1Work = (1 + len(t1.proj.annotation_processors())) * len(t1.javafilelist)
1f28c463e452 mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents: 15496
diff changeset
2915 t2Work = (1 + len(t2.proj.annotation_processors())) * len(t2.javafilelist)
1f28c463e452 mx: slight tweak of parallel Java build heuristics
Doug Simon <doug.simon@oracle.com>
parents: 15496
diff changeset
2916 d = t1Work - t2Work
15490
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2917 return d
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2918
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2919 def sortWorklist(tasks):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2920 for t in tasks:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2921 t._d = None
15490
5d0dd6a6f6b3 mx: improved heuristics for sorting remaining tasks in parallel Java build worklist
Doug Simon <doug.simon@oracle.com>
parents: 15489
diff changeset
2922 return sorted(tasks, compareTasks)
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2923
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
2924 cpus = cpu_count()
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2925 worklist = sortWorklist(tasks.values())
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2926 active = []
15786
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2927 failed = []
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2928 while len(worklist) != 0:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2929 while True:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2930 active, failed = checkTasks(active)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2931 if len(failed) != 0:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2932 assert not active, active
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2933 break
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2934 if len(active) == cpus:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2935 # Sleep for 1 second
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2936 time.sleep(1)
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2937 else:
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2938 break
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2939
15786
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2940 if len(failed) != 0:
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2941 break
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2942
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2943 def executeTask(task):
15781
8b9e7f235d85 mx: fixed spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15701
diff changeset
2944 # Clear sub-process list cloned from parent process
8b9e7f235d85 mx: fixed spurious "error while killing subprocess" messages (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15701
diff changeset
2945 del _currentSubprocesses[:]
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2946 task.execute()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2947
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2948 def depsDone(task):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2949 for d in task.deps:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2950 if d.proc is None or d.proc.exitcode is None:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2951 return False
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2952 return True
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2953
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2954 for task in worklist:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2955 if depsDone(task):
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2956 worklist.remove(task)
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2957 task.proc = multiprocessing.Process(target=executeTask, args=(task,))
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2958 task.proc.start()
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2959 active.append(task)
15489
d0e3f6963ed7 mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
Doug Simon <doug.simon@oracle.com>
parents: 15462
diff changeset
2960 task.sub = _addSubprocess(task.proc, ['JavaCompileTask', str(task)])
15460
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2961 if len(active) == cpus:
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2962 break
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2963
7d24ff89dc7d mx: parallelized Java builds (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15457
diff changeset
2964 worklist = sortWorklist(worklist)
15786
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2965
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2966 failed += joinTasks(active)
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2967 if len(failed):
d54cca247d0b mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
Doug Simon <doug.simon@oracle.com>
parents: 15785
diff changeset
2968 for t in failed:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
2969 log('Compiling {0} failed'.format(t.proj.name))
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
2970 abort('{0} Java compilation tasks failed'.format(len(failed)))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2971
21503
12e3d0dfffeb GRAAL-1090: Doug speeds up ./mx.sh build --only com.oracle.truffle.sl from 8s to 4s on my computer.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21472
diff changeset
2972 if args.java and not args.only:
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2973 files = []
16875
73d994651fcd fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents: 16849
diff changeset
2974 for dist in sorted_dists():
73d994651fcd fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents: 16849
diff changeset
2975 if dist not in updatedAnnotationProcessorDists:
73d994651fcd fixed regression when building original VM without a Java build beforehand
Doug Simon <doug.simon@oracle.com>
parents: 16849
diff changeset
2976 archive(['@' + dist.name])
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2977 if args.check_distributions and not dist.isProcessorDistribution:
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2978 with zipfile.ZipFile(dist.path, 'r') as zf:
21068
53b2d64f8ad1 Distribution overlap is allowed for META-INF*, not just META-INF/services*
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21043
diff changeset
2979 files.extend([member for member in zf.namelist() if not member.startswith('META-INF')])
21043
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2980 dups = set([x for x in files if files.count(x) > 1])
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2981 if len(dups) > 0:
5ea65fe64368 Check distributions overlap in gate
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20983
diff changeset
2982 abort('Distributions overlap! duplicates: ' + str(dups))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2983
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
2984 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
2985 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
2986 return None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2987
18647
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2988 def _handleNonJavaFiles(outputDir, p, clean, nonjavafiletuples):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2989 if exists(outputDir):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2990 if clean:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2991 log('Cleaning {0}...'.format(outputDir))
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2992 shutil.rmtree(outputDir)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2993 os.mkdir(outputDir)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2994 else:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2995 os.mkdir(outputDir)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2996 genDir = p.source_gen_dir()
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2997 if genDir != '' and exists(genDir) and clean:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2998 log('Cleaning {0}...'.format(genDir))
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
2999 for f in os.listdir(genDir):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3000 shutil.rmtree(join(genDir, f))
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3001
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3002 # Copy all non Java resources or assemble Jasmin files
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3003 jasminAvailable = None
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3004 for nonjavafiletuple in nonjavafiletuples:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3005 sourceDir = nonjavafiletuple[0]
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3006 nonjavafilelist = nonjavafiletuple[1]
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3007
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3008 for src in nonjavafilelist:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3009 if src.endswith('.jasm'):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3010 className = None
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3011 with open(src) as f:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3012 for line in f:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3013 if line.startswith('.class '):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3014 className = line.split()[-1]
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3015 break
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3016
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3017 if className is not None:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3018 jasminOutputDir = p.jasmin_output_dir()
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3019 classFile = join(jasminOutputDir, className.replace('/', os.sep) + '.class')
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3020 if exists(dirname(classFile)) and (not exists(classFile) or os.path.getmtime(classFile) < os.path.getmtime(src)):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3021 if jasminAvailable is None:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3022 try:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3023 with open(os.devnull) as devnull:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3024 subprocess.call('jasmin', stdout=devnull, stderr=subprocess.STDOUT)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3025 jasminAvailable = True
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3026 except OSError:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3027 jasminAvailable = False
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3028
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3029 if jasminAvailable:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3030 log('Assembling Jasmin file ' + src)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3031 run(['jasmin', '-d', jasminOutputDir, src])
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3032 else:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3033 log('The jasmin executable could not be found - skipping ' + src)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3034 with file(classFile, 'a'):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3035 os.utime(classFile, None)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3036
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3037 else:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3038 log('could not file .class directive in Jasmin source: ' + src)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3039 else:
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3040 dst = join(outputDir, src[len(sourceDir) + 1:])
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3041 if not exists(dirname(dst)):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3042 os.makedirs(dirname(dst))
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3043 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)):
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3044 shutil.copyfile(src, dst)
beb33138029c Clean bin directory before compiling to remove stale classfiles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18636
diff changeset
3045
19804
ad32fd810c83 mx: Support systems where SC_ARG_MAX has not defined limit
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19094
diff changeset
3046 def _chunk_files_for_command_line(files, limit=None, pathFunction=lambda f: f):
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3047 """
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3048 Returns a generator for splitting up a list of files into chunks such that the
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3049 size of the space separated file paths in a chunk is less than a given limit.
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3050 This is used to work around system command line length limits.
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3051 """
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3052 chunkSize = 0
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3053 chunkStart = 0
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3054 if limit is None:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3055 commandLinePrefixAllowance = 3000
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3056 if get_os() == 'windows':
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3057 # The CreateProcess function on Windows limits the length of a command line to
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3058 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx)
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3059 limit = 32768 - commandLinePrefixAllowance
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3060 else:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3061 # Using just SC_ARG_MAX without extra downwards adjustment
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3062 # results in "[Errno 7] Argument list too long" on MacOS.
19921
ea280aa54d58 Fix arg limit on Mac
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19863
diff changeset
3063 commandLinePrefixAllowance = 20000
19863
bd953f563517 mx: followup fix for SC_ARG_MAX, add more assetions
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19822
diff changeset
3064 syslimit = os.sysconf('SC_ARG_MAX')
19804
ad32fd810c83 mx: Support systems where SC_ARG_MAX has not defined limit
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19094
diff changeset
3065 if syslimit == -1:
ad32fd810c83 mx: Support systems where SC_ARG_MAX has not defined limit
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19094
diff changeset
3066 syslimit = 262144 # we could use sys.maxint but we prefer a more robust smaller value
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3067 limit = syslimit - commandLinePrefixAllowance
19863
bd953f563517 mx: followup fix for SC_ARG_MAX, add more assetions
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19822
diff changeset
3068 assert limit > 0
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3069 for i in range(len(files)):
19804
ad32fd810c83 mx: Support systems where SC_ARG_MAX has not defined limit
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19094
diff changeset
3070 path = pathFunction(files[i])
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3071 size = len(path) + 1
19863
bd953f563517 mx: followup fix for SC_ARG_MAX, add more assetions
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19822
diff changeset
3072 assert size < limit
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3073 if chunkSize + size < limit:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3074 chunkSize += size
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3075 else:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3076 assert i > chunkStart
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3077 yield files[chunkStart:i]
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3078 chunkStart = i
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3079 chunkSize = 0
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3080 if chunkStart == 0:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3081 assert chunkSize < limit
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3082 yield files
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3083
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
3084 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
3085 """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
3086
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
3087 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
3088
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
3089 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
3090 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
3091 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
3092 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
3093
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
3094 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
3095 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
3096 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
3097 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
3098 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
3099
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
3100 # 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
3101 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
3102 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
3103 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
3104
6fb61ad67962 Fix mx eclipseformat always adds the 'eclipse' suffix
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14539
diff changeset
3105 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
3106 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
3107 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
3108 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
3109
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3110 eclipseinit([], buildProcessorJars=False)
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
3111
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3112 # build list of projects to be processed
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3113 projects = sorted_deps()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3114 if args.projects is not None:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3115 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
3116
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3117 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
3118 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
3119 self.path = join(settingsDir, 'org.eclipse.jdt.core.prefs')
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
3120 self.javaCompliance = javaCompliance
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
3121 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
3122 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
3123 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
3124 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
3125 assert 'sp_cleanup.remove_trailing_whitespaces=true' in jdtUiPrefs and 'sp_cleanup.remove_trailing_whitespaces_ignore_empty=false' in jdtUiPrefs
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3126 self.cachedHash = None
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3127
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3128 def __hash__(self):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3129 if not self.cachedHash:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3130 with open(self.path) as fp:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3131 self.cachedHash = (fp.read(), self.javaCompliance, self.removeTrailingWhitespace).__hash__()
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3132 return self.cachedHash
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3133
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3134 def __eq__(self, other):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3135 if not isinstance(other, Batch):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3136 return False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3137 if self.removeTrailingWhitespace != other.removeTrailingWhitespace:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3138 return False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3139 if self.javaCompliance != other.javaCompliance:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3140 return False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3141 if self.path == other.path:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3142 return True
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3143 with open(self.path) as fp:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3144 with open(other.path) as ofp:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3145 if fp.read() != ofp.read():
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3146 return False
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3147 return True
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3148
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3149 class FileInfo:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3150 def __init__(self, path):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3151 self.path = path
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3152 with open(path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3153 self.content = fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3154 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
3155
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
3156 def update(self, removeTrailingWhitespace):
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3157 with open(self.path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3158 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
3159
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
3160 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
3161 # 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
3162 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
3163 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
3164 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
3165 # 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
3166 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
3167 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
3168
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3169 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
3170 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
3171 self.content = content
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3172 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
3173
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
3174 # reset access and modification time of file
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3175 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
3176
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3177 modified = list()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3178 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
3179 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
3180 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
3181 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
3182 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
3183
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
3184 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
3185
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3186 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
3187 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
3188 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
3189 continue
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3190 javafiles = []
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
3191 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
3192 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
3193 for f in [join(root, name) for name in files if name.endswith('.java')]:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3194 javafiles.append(FileInfo(f))
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3195 if len(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
3196 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
3197 continue
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3198
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3199 res = batches.setdefault(batch, javafiles)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3200 if res is not javafiles:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3201 res.extend(javafiles)
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3202
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3203 log("we have: " + str(len(batches)) + " batches")
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3204 for batch, javafiles in batches.iteritems():
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
3205 for chunk in _chunk_files_for_command_line(javafiles, pathFunction=lambda f: f.path):
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3206 run([args.eclipse_exe,
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3207 '-nosplash',
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3208 '-application',
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3209 'org.eclipse.jdt.core.JavaCodeFormatter',
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3210 '-vm', java(batch.javaCompliance).java,
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3211 '-config', batch.path]
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3212 + [f.path for f in chunk])
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3213 for fi in chunk:
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3214 if fi.update(batch.removeTrailingWhitespace):
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3215 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
3216
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
3217 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
3218
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
3219 if len(modified) != 0:
13288
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3220 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
3221 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
3222 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
3223 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
3224 for fi in modified:
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3225 name = os.path.relpath(fi.path, arcbase)
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3226 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
3227 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
3228 log(''.join(fi.diff))
13288
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3229 if args.backup:
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3230 arcname = name.replace(os.sep, '/')
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
3231 zf.writestr(arcname, fi.content)
13288
9c3c915b5f56 Log modiffied files during eclipseformat
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13266
diff changeset
3232 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
3233 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
3234 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
3235 return 1
7533
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7532
diff changeset
3236 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
3237
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3238 def processorjars():
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3239 for s in suites(True):
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3240 _processorjars_suite(s)
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3241
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3242 def _processorjars_suite(s):
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3243 projs = [p for p in s.projects if p.definedAnnotationProcessors is not None]
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3244 if len(projs) <= 0:
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3245 return []
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3246
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3247 pnames = [p.name for p in projs]
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3248 build(['--jdt-warning-as-error', '--projects', ",".join(pnames)])
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3249 return [p.definedAnnotationProcessorsDist.path for p in s.projects if p.definedAnnotationProcessorsDist is not None]
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3250
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3251 def pylint(args):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3252 """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
3253
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3254 parser = ArgumentParser(prog='mx pylint')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3255 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
3256 args = parser.parse_args(args)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3257
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3258 rcfile = join(dirname(__file__), '.pylintrc')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3259 if not exists(rcfile):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3260 log('pylint configuration file does not exist: ' + rcfile)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3261 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3262
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3263 try:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3264 output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3265 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
3266 if not m:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3267 log('could not determine pylint version from ' + output)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3268 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3269 major, minor, micro = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
18135
1700d12ba0ad Require pylint 1.1.x
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18116
diff changeset
3270 if major != 1 or minor != 1:
1700d12ba0ad Require pylint 1.1.x
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18116
diff changeset
3271 log('require pylint version = 1.1.x (got {0}.{1}.{2})'.format(major, minor, micro))
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3272 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3273 except BaseException:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3274 log('pylint is not available')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3275 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3276
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3277 def findfiles_by_walk():
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3278 result = []
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3279 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3280 for root, dirs, files in os.walk(suite.dir):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3281 for f in files:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3282 if f.endswith('.py'):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3283 pyfile = join(root, f)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3284 result.append(pyfile)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3285 if 'bin' in dirs:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3286 dirs.remove('bin')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3287 if 'lib' in dirs:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3288 # avoids downloaded .py files
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3289 dirs.remove('lib')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3290 return result
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3291
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3292 def findfiles_by_hg():
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3293 result = []
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3294 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3295 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
3296 for f in versioned:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3297 if f.endswith('.py') and exists(f):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3298 result.append(f)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3299 return result
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3300
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3301 # 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
3302 if args.walk:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3303 pyfiles = findfiles_by_walk()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3304 else:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3305 pyfiles = findfiles_by_hg()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3306
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3307 env = os.environ.copy()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3308
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3309 pythonpath = dirname(__file__)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3310 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3311 pythonpath = os.pathsep.join([pythonpath, suite.mxDir])
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3312
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3313 env['PYTHONPATH'] = pythonpath
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3314
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3315 for pyfile in pyfiles:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
3316 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
3317 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
3318
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3319 """
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3320 Utility for creating and updating a zip file atomically.
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3321 """
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3322 class Archiver:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3323 def __init__(self, path):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3324 self.path = path
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3325
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3326 def __enter__(self):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3327 if self.path:
16682
63706366f6c5 moved distribution artifacts into build/ sub-directory
Doug Simon <doug.simon@oracle.com>
parents: 16671
diff changeset
3328 if not isdir(dirname(self.path)):
63706366f6c5 moved distribution artifacts into build/ sub-directory
Doug Simon <doug.simon@oracle.com>
parents: 16671
diff changeset
3329 os.makedirs(dirname(self.path))
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3330 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(self.path) + '.', dir=dirname(self.path))
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3331 self.tmpFd = fd
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3332 self.tmpPath = tmp
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3333 self.zf = zipfile.ZipFile(tmp, 'w')
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3334 else:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3335 self.tmpFd = None
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3336 self.tmpPath = None
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3337 self.zf = None
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3338 return self
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3339
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3340 def __exit__(self, exc_type, exc_value, traceback):
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3341 if self.zf:
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3342 self.zf.close()
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3343 os.close(self.tmpFd)
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3344 # Correct the permissions on the temporary file which is created with restrictive permissions
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3345 os.chmod(self.tmpPath, 0o666 & ~currentUmask)
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3346 # Atomic on Unix
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3347 shutil.move(self.tmpPath, self.path)
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3348
15818
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
3349 def _archive(args):
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
3350 archive(args)
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
3351 return 0
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
3352
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3353 def archive(args):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3354 """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
3355 parser = ArgumentParser(prog='mx archive')
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3356 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
3357 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
3358
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
3359 archives = []
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3360 for name in args.names:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3361 if name.startswith('@'):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3362 dname = name[1:]
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3363 d = distribution(dname)
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3364 d.make_archive()
14964
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
3365 archives.append(d.path)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3366 else:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3367 p = project(name)
15226
f1c66b738dae mx: refactored archive command
Doug Simon <doug.simon@oracle.com>
parents: 15149
diff changeset
3368 archives.append(p.make_archive())
14964
e1ce6c66f56e refactored archive command to use "with" statement
Doug Simon <doug.simon@oracle.com>
parents: 14940
diff changeset
3369
15818
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
3370 logv("generated archives: " + str(archives))
13473
69f3251332c9 modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
3371 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
3372
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3373 def canonicalizeprojects(args):
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3374 """check all project specifications for canonical dependencies
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3375
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3376 The exit code of this command reflects how many projects have non-canonical dependencies."""
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3377
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3378 nonCanonical = []
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3379 for s in suites(True):
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3380 for p in s.projects:
21395
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
3381 if p.checkPackagePrefix:
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
3382 for pkg in p.defined_java_packages():
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
3383 if not pkg.startswith(p.name):
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
3384 abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg))
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3385
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3386 ignoredDeps = set([name for name in p.deps if project(name, False) is not None])
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3387 for pkg in p.imported_java_packages():
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3388 for name in p.deps:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3389 dep = project(name, False)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3390 if dep is None:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3391 ignoredDeps.discard(name)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3392 else:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3393 if pkg in dep.defined_java_packages():
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3394 ignoredDeps.discard(name)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3395 if pkg in dep.extended_java_packages():
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3396 ignoredDeps.discard(name)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3397 if len(ignoredDeps) != 0:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3398 candidates = set()
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3399 # Compute dependencies based on projects required by p
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3400 for d in sorted_deps():
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3401 if not d.defined_java_packages().isdisjoint(p.imported_java_packages()):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3402 candidates.add(d)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3403 # Remove non-canonical candidates
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3404 for c in list(candidates):
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3405 candidates.difference_update(c.all_deps([], False, False))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3406 candidates = [d.name for d in candidates]
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3407
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
3408 abort('{0} does not use any packages defined in these projects: {1}\nComputed project dependencies: {2}'.format(
17159
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3409 p, ', '.join(ignoredDeps), ','.join(candidates)))
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3410
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3411 excess = frozenset(p.deps) - set(p.canonical_deps())
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3412 if len(excess) != 0:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3413 nonCanonical.append(p)
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3414 if len(nonCanonical) != 0:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3415 for p in nonCanonical:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3416 canonicalDeps = p.canonical_deps()
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3417 if len(canonicalDeps) != 0:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3418 log('Canonical dependencies for project ' + p.name + ' are: [')
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3419 for d in canonicalDeps:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3420 log(' "' + d + '",')
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3421 log(' ],')
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3422 else:
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3423 log('Canonical dependencies for project ' + p.name + ' are: []')
ef5212ce8091 support for new projects file format including support for automatically updating from old format
Doug Simon <doug.simon@oracle.com>
parents: 17092
diff changeset
3424 return len(nonCanonical)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3425
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3426 class TimeStampFile:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3427 def __init__(self, path):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3428 self.path = path
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3429 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
3430
12524
2583afcd26ee fixed bug in creation of CreateGRAALDist.launch files
Doug Simon <doug.simon@oracle.com>
parents: 12522
diff changeset
3431 def isOlderThan(self, arg):
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3432 if not self.timestamp:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3433 return True
12630
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3434 if isinstance(arg, TimeStampFile):
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3435 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
3436 return False
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3437 else:
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3438 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
3439 elif isinstance(arg, types.ListType):
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3440 files = arg
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3441 else:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3442 files = [arg]
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3443 for f in files:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3444 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
3445 return True
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3446 return False
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3447
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3448 def exists(self):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3449 return exists(self.path)
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3450
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3451 def touch(self):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3452 if exists(self.path):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3453 os.utime(self.path, None)
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3454 else:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3455 if not isdir(dirname(self.path)):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3456 os.makedirs(dirname(self.path))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3457 file(self.path, 'a')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3458
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3459 def checkstyle(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3460 """run Checkstyle on the Java sources
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3461
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3462 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
3463 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
3464
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3465 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
3466
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3467 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
3468 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
3469
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3470 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
3471 for p in projects_opt_limit_to_suites():
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3472 if p.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3473 continue
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3474 sourceDirs = p.source_dirs()
14918
31a9c79399c8 disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents: 14917
diff changeset
3475
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18158
diff changeset
3476 config = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml')
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18158
diff changeset
3477 if not exists(config):
21395
f9883cab4580 mx: Allow disabling of package prefix check
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21277
diff changeset
3478 logv('[No Checkstyle configuration found for {0} - skipping]'.format(p))
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18158
diff changeset
3479 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3480
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
3481 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
3482 jdk = java(p.javaCompliance)
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
3483 assert jdk
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3484
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3485 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3486 javafilelist = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3487 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
3488 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
3489 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
3490 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
3491 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3492
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3493 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
3494 mustCheck = False
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3495 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
3496 mustCheck = timestamp.isOlderThan(javafilelist)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3497 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3498 mustCheck = True
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3499
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3500 if not mustCheck:
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3501 if _opts.verbose:
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3502 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
3503 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3504
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3505 exclude = join(p.dir, '.checkstyle.exclude')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3506 if exists(exclude):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3507 with open(exclude) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3508 # Convert patterns to OS separators
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3509 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
3510 def match(name):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3511 for p in patterns:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3512 if p in name:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3513 if _opts.verbose:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3514 log('excluding: ' + name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3515 return True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3516 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3517
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3518 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
3519
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3520 auditfileName = join(p.dir, 'checkstyleOutput.txt')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3521 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
3522
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3523 try:
15274
1ea79f17ab95 mx: generalized workaround for system command line length limits and used it to fix issue with eclipseformat command
Doug Simon <doug.simon@oracle.com>
parents: 15227
diff changeset
3524 for chunk in _chunk_files_for_command_line(javafilelist):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3525 try:
18710
4836c2abc884 mx: removed hard-coded -Xms setting for the 'build' and 'checkstyle' commands to try and avoid unnecessary swapping on low(er) memory machines
Doug Simon <doug.simon@oracle.com>
parents: 18647
diff changeset
3526 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + chunk, nonZeroIsFatal=False)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3527 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3528 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
3529 errors = []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3530 source = [None]
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
3531 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
3532 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
3533 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
3534 elif name == 'error':
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
3535 errors.append('{0}:{1}: {2}'.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
3536
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3537 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
3538 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
3539 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
3540 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
3541 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
3542 map(log, errors)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3543 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
3544 else:
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3545 timestamp.touch()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3546 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3547 if exists(auditfileName):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3548 os.unlink(auditfileName)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
3549 return totalErrors
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3550
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3551 def clean(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3552 """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
3553
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3554 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
3555 generated images.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3556 """
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
3557
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
3558 suppliedParser = parser is not None
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3559
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
3560 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
3561 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
3562 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects')
16087
64e172733061 mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 16086
diff changeset
3563 parser.add_argument('--no-dist', action='store_false', dest='dist', help='do not delete distributions')
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3564
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3565 args = parser.parse_args(args)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3566
15579
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3567 def _rmtree(dirPath):
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3568 path = dirPath
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3569 if get_os() == 'windows':
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3570 path = unicode("\\\\?\\" + dirPath)
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3571 shutil.rmtree(path)
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3572
16087
64e172733061 mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 16086
diff changeset
3573 def _rmIfExists(name):
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
3574 if name and os.path.isfile(name):
16087
64e172733061 mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 16086
diff changeset
3575 os.unlink(name)
64e172733061 mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 16086
diff changeset
3576
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
3577 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
3578 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3579 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3580 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
3581 else:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3582 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
3583 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
3584 if genDir != '' and exists(genDir):
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
3585 log('Clearing {0}...'.format(genDir))
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
3586 for f in os.listdir(genDir):
15579
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3587 _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
3588
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3589
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3590 outputDir = p.output_dir()
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3591 if outputDir != '' and exists(outputDir):
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3592 log('Removing {0}...'.format(outputDir))
15579
c3869fe3d917 mx clean: make it more reliable on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
3593 _rmtree(outputDir)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3594
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
3595 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
3596 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
3597 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
3598 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
3599
17063
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3600 if args.java:
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3601 if args.dist:
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3602 for d in _dists.keys():
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3603 log('Removing distribution {0}...'.format(d))
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3604 _rmIfExists(distribution(d).path)
75a4acd33159 mx: do not clean distributions if the --no-java option is given to the clean command
Doug Simon <doug.simon@oracle.com>
parents: 17059
diff changeset
3605 _rmIfExists(distribution(d).sourcesPath)
16087
64e172733061 mx clean: delete distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 16086
diff changeset
3606
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
3607 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
3608 return args
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3609
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3610 def about(args):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3611 """show the 'man page' for mx"""
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3612 print __doc__
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3613
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3614 def help_(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3615 """show help for a given command
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3616
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3617 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
3618
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3619 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
3620 if len(args) == 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3621 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3622 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3623
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3624 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
3625 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
3626 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
3627 if len(hits) == 1:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
3628 name = hits[0]
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
3629 elif len(hits) == 0:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
3630 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
3631 else:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
3632 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
3633
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3634 value = _commands[name]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3635 (func, usage) = value[:2]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3636 doc = func.__doc__
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3637 if len(value) > 2:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3638 docArgs = value[2:]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3639 fmtArgs = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3640 for d in docArgs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3641 if isinstance(d, Callable):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3642 fmtArgs += [d()]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3643 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3644 fmtArgs += [str(d)]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3645 doc = doc.format(*fmtArgs)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3646 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
3647
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3648 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
3649 """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
3650
a9f750305a38 added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents: 12571
diff changeset
3651 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
3652 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
3653 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
3654
a9f750305a38 added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents: 12571
diff changeset
3655 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
3656
a9f750305a38 added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents: 12571
diff changeset
3657 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
3658 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
3659 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
3660 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
3661 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
3662 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
3663 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
3664 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
3665 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
3666 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
3667 igv.open('nodes')
15785
7a6f6a7ef886 Add JRE library support to mx projectgraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15781
diff changeset
3668 for p in sorted_deps(includeLibs=True, includeJreLibs=True):
12620
a9f750305a38 added --igv option to "mx projectgraph" command for sending output to IGV instead
Doug Simon <doug.simon@oracle.com>
parents: 12571
diff changeset
3669 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
3670 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
3671 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
3672 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
3673 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
3674 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
3675 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
3676 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
3677 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
3678 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
3679 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
3680 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
3681 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
3682 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
3683 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
3684 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
3685 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
3686 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
3687 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
3688 igv.close('graphDocument')
12630
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3689
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
3690 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
3691 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
3692 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
3693 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
3694 else:
12630
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3695 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
3696 return
12630
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3697
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3698 print 'digraph projects {'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3699 print 'rankdir=BT;'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3700 print 'node [shape=rect];'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3701 for p in projects():
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3702 for dep in p.canonical_deps():
19094
258b3658845a mx: Show annotation processor edges in projectgraph
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18930
diff changeset
3703 print '"' + p.name + '"->"' + dep + '";'
258b3658845a mx: Show annotation processor edges in projectgraph
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18930
diff changeset
3704 if hasattr(p, '_declaredAnnotationProcessors'):
258b3658845a mx: Show annotation processor edges in projectgraph
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18930
diff changeset
3705 for ap in p._declaredAnnotationProcessors:
258b3658845a mx: Show annotation processor edges in projectgraph
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18930
diff changeset
3706 print '"' + p.name + '"->"' + ap + '" [style="dashed"];'
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3707 print '}'
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3708
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3709 def _source_locator_memento(deps):
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
3710 slm = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3711 slm.open('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3712 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
3713
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
3714 javaCompliance = None
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3715 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
3716 if dep.isLibrary():
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3717 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
3718 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
3719 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
3720 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
3721 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
3722 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.debug.core.containerType.externalArchive'})
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
3723 elif dep.isProject():
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
3724 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
3725 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'})
15693
807090ddbbf2 use JDK with highest compliance level for generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents: 15662
diff changeset
3726 if javaCompliance is None or dep.javaCompliance > javaCompliance:
13775
43c7df32d5ab use lowest version JRE specified by any project for source path in Eclipse attach/launch configuration
Doug Simon <doug.simon@oracle.com>
parents: 13727
diff changeset
3727 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
3728
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
3729 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
3730 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
3731 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
3732 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
3733 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
3734 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
3735
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3736 slm.close('sourceContainers')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3737 slm.close('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3738 return slm
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3739
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
3740 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
3741 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3742 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
3743 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3744 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
3745 deps = []
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3746 slm = _source_locator_memento(deps)
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
3747 launch = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3748 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
3749 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
3750 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
3751 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
3752 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
3753 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
3754 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
3755 launch.close('mapAttribute')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3756 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
3757 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
3758 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
3759 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
3760
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3761 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
3762 if len(suites()) == 1:
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3763 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
3764 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
3765 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
3766 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
3767 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
3768 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
3769 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
3770 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
3771 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
3772
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3773 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
3774 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3775 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
3776 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3777 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
3778 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
3779 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
3780 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
3781 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
3782 cp = None
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3783 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
3784 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
3785 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
3786 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
3787 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
3788 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
3789 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
3790 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
3791 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
3792 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
3793 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
3794 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
3795 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
3796 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
3797 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
3798 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
3799 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
3800 break
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3801
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
3802 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
3803 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
3804 return False
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3805
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
3806 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
3807 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
3808 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
3809 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
3810 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
3811 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
3812 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
3813 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
3814
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
3815 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
3816 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
3817 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
3818 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
3819 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
3820
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3821 slm = _source_locator_memento(deps)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3822
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
3823 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
3824 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
3825 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
3826 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
3827 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
3828 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
3829 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
3830 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
3831 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
3832 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
3833 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
3834
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
3835 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
3836 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
3837 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
3838 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
3839
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3840 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
3841 """(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
3842 for s in suites(True):
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
3843 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3844
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
3845 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
3846
13682
c4ff08d2aa0d fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents: 13620
diff changeset
3847 def _check_ide_timestamp(suite, configZip, ide):
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
3848 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip"""
17182
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
3849 suitePyFiles = [join(suite.mxDir, e) for e in os.listdir(suite.mxDir) if e.startswith('suite') and e.endswith('.py')]
d6c7c530ca84 mx: change name of suite specification file from projects.py to suite.py
Doug Simon <doug.simon@oracle.com>
parents: 17169
diff changeset
3850 if configZip.isOlderThan(suitePyFiles):
13243
68529068f08e Update eclipse config when files in eclipse-settings have changed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12689
diff changeset
3851 return False
12630
aadb188e4258 mxtool: regenerate IDE files when suite imports file changes
Mick Jordan <mick.jordan@oracle.com>
parents: 12620
diff changeset
3852 # 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
3853 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
3854 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
3855
13682
c4ff08d2aa0d fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents: 13620
diff changeset
3856 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
3857 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
3858 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
3859 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
3860 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
3861 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
3862 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
3863 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
3864
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3865 def _eclipseinit_project(p, files=None, libFiles=None):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3866 assert java(p.javaCompliance)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3867
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3868 if not exists(p.dir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3869 os.makedirs(p.dir)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3870
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3871 out = XMLDoc()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3872 out.open('classpath')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3873
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3874 for src in p.srcDirs:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3875 srcDir = join(p.dir, src)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3876 if not exists(srcDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3877 os.mkdir(srcDir)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3878 out.element('classpathentry', {'kind' : 'src', 'path' : src})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3879
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3880 processorPath = p.annotation_processors_path()
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3881 if processorPath:
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3882 genDir = p.source_gen_dir()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3883 if not exists(genDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3884 os.mkdir(genDir)
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3885 out.open('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3886 if p.uses_annotation_processor_library():
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3887 # ignore warnings produced by third-party annotation processors
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3888 out.open('attributes')
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3889 out.element('attribute', {'name' : 'ignore_optional_problems', 'value' : 'true'})
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3890 out.close('attributes')
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3891 out.close('classpathentry')
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
3892
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3893 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3894 files.append(genDir)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3895
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3896 # Every Java program depends on a JRE
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3897 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3898
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3899 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3900 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3901
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3902 containerDeps = set()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3903 libraryDeps = set()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3904 projectDeps = set()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3905
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3906 for dep in p.all_deps([], True):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3907 if dep == p:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3908 continue
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3909 if dep.isLibrary():
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3910 if hasattr(dep, 'eclipse.container'):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3911 container = getattr(dep, 'eclipse.container')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3912 containerDeps.add(container)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3913 libraryDeps -= set(dep.all_deps([], True))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3914 else:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3915 libraryDeps.add(dep)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3916 elif dep.isProject():
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3917 projectDeps.add(dep)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3918
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
3919 for dep in sorted(containerDeps):
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3920 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : dep})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3921
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
3922 for dep in sorted(libraryDeps):
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3923 path = dep.path
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3924 dep.get_path(resolve=True)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3925
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3926 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3927 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3928 # safest to simply use absolute paths.
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3929 path = _make_absolute(path, p.suite.dir)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3930
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3931 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path}
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3932
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3933 sourcePath = dep.get_source_path(resolve=True)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3934 if sourcePath is not None:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3935 attributes['sourcepath'] = sourcePath
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3936 out.element('classpathentry', attributes)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3937 if libFiles:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3938 libFiles.append(path)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3939
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
3940 for dep in sorted(projectDeps):
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3941 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3942
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3943 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3944 out.close('classpath')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3945 classpathFile = join(p.dir, '.classpath')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3946 update_file(classpathFile, out.xml(indent='\t', newl='\n'))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3947 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3948 files.append(classpathFile)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3949
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3950 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3951 if exists(csConfig):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3952 out = XMLDoc()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3953
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3954 dotCheckstyle = join(p.dir, ".checkstyle")
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3955 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml'
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3956 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3957 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3958 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3959 out.close('local-check-config')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3960 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3961 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3962 out.close('fileset')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3963 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3964 out.element('filter-data', {'value' : 'java'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3965 out.close('filter')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3966
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3967 exclude = join(p.dir, '.checkstyle.exclude')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3968 if exists(exclude):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3969 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3970 with open(exclude) as f:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3971 for line in f:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3972 if not line.startswith('#'):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3973 line = line.strip()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3974 exclDir = join(p.dir, line)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3975 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3976 out.element('filter-data', {'value' : line})
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3977 out.close('filter')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3978
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3979 out.close('fileset-config')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3980 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n'))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3981 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3982 files.append(dotCheckstyle)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3983 else:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3984 # clean up existing .checkstyle file
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3985 dotCheckstyle = join(p.dir, ".checkstyle")
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3986 if exists(dotCheckstyle):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3987 os.unlink(dotCheckstyle)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3988
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3989 out = XMLDoc()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3990 out.open('projectDescription')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3991 out.element('name', data=p.name)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3992 out.element('comment', data='')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3993 out.element('projects', data='')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3994 out.open('buildSpec')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3995 out.open('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3996 out.element('name', data='org.eclipse.jdt.core.javabuilder')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3997 out.element('arguments', data='')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3998 out.close('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
3999 if exists(csConfig):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4000 out.open('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4001 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4002 out.element('arguments', data='')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4003 out.close('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4004 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4005 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4006 out.open('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4007 out.element('name', data=buildCommand)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4008 out.element('arguments', data='')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4009 out.close('buildCommand')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4010
16849
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4011 if p.definedAnnotationProcessorsDist:
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4012 # Create a launcher that will (re)build the annotation processor
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4013 # jar any time one of its sources is modified.
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4014 dist = p.definedAnnotationProcessorsDist
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4015
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4016 distProjects = [d for d in dist.sorted_deps(transitive=True) if d.isProject()]
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4017 relevantResources = []
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4018 for p in distProjects:
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4019 for srcDir in p.source_dirs():
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4020 relevantResources.append(join(p.name, os.path.relpath(srcDir, p.dir)))
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4021 relevantResources.append(join(p.name, os.path.relpath(p.output_dir(), p.dir)))
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4022
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4023 # The path should always be p.name/dir independent of where the workspace actually is.
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4024 # So we use the parent folder of the project, whatever that is, to generate such a relative path.
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4025 logicalWorkspaceRoot = os.path.dirname(p.dir)
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4026 refreshFile = os.path.relpath(p.definedAnnotationProcessorsDist.path, logicalWorkspaceRoot)
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4027 _genEclipseBuilder(out, p, 'CreateAnnotationProcessorJar', 'archive @' + dist.name, refresh=True, refreshFile=refreshFile, relevantResources=relevantResources, async=True, xmlIndent='', xmlStandalone='no')
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4028
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4029 out.close('buildSpec')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4030 out.open('natures')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4031 out.element('nature', data='org.eclipse.jdt.core.javanature')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4032 if exists(csConfig):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4033 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4034 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4035 out.element('nature', data='org.eclipse.pde.PluginNature')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4036 out.close('natures')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4037 out.close('projectDescription')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4038 projectFile = join(p.dir, '.project')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4039 update_file(projectFile, out.xml(indent='\t', newl='\n'))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4040 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4041 files.append(projectFile)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4042
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4043 settingsDir = join(p.dir, ".settings")
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4044 if not exists(settingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4045 os.mkdir(settingsDir)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4046
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4047 # collect the defaults from mxtool
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4048 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4049 esdict = {}
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4050 if exists(defaultEclipseSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4051 for name in os.listdir(defaultEclipseSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4052 if isfile(join(defaultEclipseSettingsDir, name)):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4053 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4054
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4055 # check for suite overrides
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4056 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4057 if exists(eclipseSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4058 for name in os.listdir(eclipseSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4059 if isfile(join(eclipseSettingsDir, name)):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4060 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4061
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4062 # check for project overrides
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4063 projectSettingsDir = join(p.dir, 'eclipse-settings')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4064 if exists(projectSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4065 for name in os.listdir(projectSettingsDir):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4066 if isfile(join(projectSettingsDir, name)):
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4067 esdict[name] = os.path.abspath(join(projectSettingsDir, name))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4068
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4069 # copy a possibly modified file to the project's .settings directory
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4070 for name, path in esdict.iteritems():
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4071 # ignore this file altogether if this project has no annotation processors
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
4072 if name == "org.eclipse.jdt.apt.core.prefs" and not processorPath:
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4073 continue
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4074
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4075 with open(path) as f:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4076 content = f.read()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4077 content = content.replace('${javaCompliance}', str(p.javaCompliance))
18890
f5cee3a0496c mx: support annotation processors in libraries
Roland Schatz <roland.schatz@oracle.com>
parents: 18889
diff changeset
4078 if processorPath:
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4079 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4080 update_file(join(settingsDir, name), content)
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4081 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4082 files.append(join(settingsDir, name))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4083
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
4084 if processorPath:
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4085 out = XMLDoc()
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4086 out.open('factorypath')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4087 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'})
16839
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
4088 for e in processorPath.split(os.pathsep):
7eca83fd5419 generate distributions for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16725
diff changeset
4089 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : e, 'enabled' : 'true', 'runInBatchMode' : 'false'})
16455
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4090 out.close('factorypath')
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4091 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n'))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4092 if files:
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4093 files.append(join(p.dir, '.factorypath'))
59fdea1f9e36 factored out _eclipseinit_project to all per-project Eclipse configuration
Doug Simon <doug.simon@oracle.com>
parents: 16417
diff changeset
4094
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4095 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
4096 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
4097 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
4098 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
4099 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4100
13682
c4ff08d2aa0d fixed problem in netbeansinit that generated invalid annotation processor paths for projects
Doug Simon <doug.simon@oracle.com>
parents: 13620
diff changeset
4101 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
4102 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
4103 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4104
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
4105 files = []
13475
4a3628c79ff9 separated external libs out from zipped up IDE configs
Doug Simon <doug.simon@oracle.com>
parents: 13473
diff changeset
4106 libFiles = []
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4107 if buildProcessorJars:
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4108 files += _processorjars_suite(suite)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4109
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
4110 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
4111 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
4112 continue
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4113 _eclipseinit_project(p, files, libFiles)
13473
69f3251332c9 modified eclipseinit and netbeansinit to save all created/copied/downloaded project related files in zip files
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
4114
13727
10e6f192631f added library sources (if available) to generated Eclipse attach launcher
Doug Simon <doug.simon@oracle.com>
parents: 13682
diff changeset
4115 _, 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
4116 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
4117
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4118 # Create an Eclipse project for each distribution that will create/update the archive
16667
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
4119 # for the distribution whenever any (transitively) dependent project of the
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
4120 # distribution is updated.
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4121 for dist in suite.dists:
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
4122 projectDir = dist.get_ide_project_dir()
16849
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4123 if not projectDir:
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4124 continue
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4125 if not exists(projectDir):
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4126 os.makedirs(projectDir)
16667
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
4127 distProjects = [d for d in dist.sorted_deps(transitive=True) if d.isProject()]
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4128 relevantResources = []
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4129 for p in distProjects:
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4130 for srcDir in p.source_dirs():
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4131 relevantResources.append(join(p.name, os.path.relpath(srcDir, p.dir)))
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4132 relevantResources.append(join(p.name, os.path.relpath(p.output_dir(), p.dir)))
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4133 out = XMLDoc()
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4134 out.open('projectDescription')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4135 out.element('name', data=dist.name)
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4136 out.element('comment', data='Updates ' + dist.path + ' if a project dependency of ' + dist.name + ' is updated')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4137 out.open('projects')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4138 for p in distProjects:
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4139 out.element('project', data=p.name)
16623
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16599
diff changeset
4140 for d in dist.distDependencies:
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16599
diff changeset
4141 out.element('project', data=d)
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4142 out.close('projects')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4143 out.open('buildSpec')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4144 dist.dir = projectDir
16667
1d4313c3ab38 mx: distribution should (also) be rebuilt when a transitive project dependency is updated
Doug Simon <doug.simon@oracle.com>
parents: 16629
diff changeset
4145 dist.javaCompliance = max([p.javaCompliance for p in distProjects])
15899
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4146 _genEclipseBuilder(out, dist, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, relevantResources=relevantResources, logToFile=True, refresh=False, async=True)
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4147 out.close('buildSpec')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4148 out.open('natures')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4149 out.element('nature', data='org.eclipse.jdt.core.javanature')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4150 out.close('natures')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4151 out.close('projectDescription')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4152 projectFile = join(projectDir, '.project')
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4153 update_file(projectFile, out.xml(indent='\t', newl='\n'))
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4154 files.append(projectFile)
e065b9746246 mx: create Eclipse projects for distributions
Doug Simon <doug.simon@oracle.com>
parents: 15898
diff changeset
4155
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4156 _zip_files(files, suite.dir, configZip.path)
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4157 _zip_files(libFiles, suite.dir, configLibsZip)
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4158
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
4159 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
4160 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
4161 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
4162 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
4163 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
4164 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
4165 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
4166 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
4167 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
4168 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
4169 # 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
4170 shutil.move(tmp, zipPath)
14103
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
4171 # 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
4172 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
4173 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
4174 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
4175 os.remove(tmp)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4176
12661
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4177 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
4178 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
4179 launchOut = XMLDoc()
8181
989e0582a30f enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents: 8180
diff changeset
4180 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
4181 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
4182 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
4183 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
21277
2b8fb2b8b586 Fix JAVA_HOME and EXTRA_JAVA_HOMES was not passed to eclipse builders anymore causing them to fail silently.
Christian Humer <christian.humer@gmail.com>
parents: 21208
diff changeset
4184 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : _default_java_home.jdk})
2b8fb2b8b586 Fix JAVA_HOME and EXTRA_JAVA_HOMES was not passed to eclipse builders anymore causing them to fail silently.
Christian Humer <christian.humer@gmail.com>
parents: 21208
diff changeset
4185 launchOut.element('mapEntry', {'key' : 'EXTRA_JAVA_HOMES', 'value' : os.pathsep.join([extraJavaHome.jdk for extraJavaHome in _extra_java_homes])})
8174
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
4186 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
4187
7681
f81be78f15a5 Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents: 7533
diff changeset
4188 if refresh:
12661
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4189 if refreshFile is None:
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4190 refreshScope = '${project}'
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4191 else:
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4192 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
4193
ec224fef3012 integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents: 12662
diff changeset
4194 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
4195 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
4196
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4197 if relevantResources is not None:
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4198 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
4199 for relevantResource in relevantResources:
12684
ec224fef3012 integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents: 12662
diff changeset
4200 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
4201 resources += '</resources>}'
0497d6702cff mxtool: fixed eclipse builder glitches and rebuild loops.
Christian Humer <christian.humer@gmail.com>
parents: 12640
diff changeset
4202 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
4203
ec224fef3012 integrated auto-formatting changes
Doug Simon <doug.simon@oracle.com>
parents: 12662
diff changeset
4204
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4205 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
4206 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
4207 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
4208 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
4209 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
4210 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
4211
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4212 # 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
4213 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
4214
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
4215 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
4216 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
4217 cmd = 'mx.cmd'
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4218 cmdPath = join(baseDir, cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4219 if not os.path.exists(cmdPath):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4220 # 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
4221 cmdPath = join(dirname(baseDir), cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4222 if not os.path.exists(cmdPath):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4223 abort('cannot locate ' + cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4224
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4225 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
4226 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
4227 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
4228 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
4229 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
4230
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4231
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
4232 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
4233
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
4234 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
4235 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
4236 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
4237
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4238 dotProjectDoc.open('buildCommand')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4239 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
4240 dotProjectDoc.element('triggers', data='auto,full,incremental,')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4241 dotProjectDoc.open('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4242 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
4243 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
4244 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
4245 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4246 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
4247 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
4248 dotProjectDoc.element('value', data='true')
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4249 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4250 dotProjectDoc.close('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4251 dotProjectDoc.close('buildCommand')
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4252
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
4253 def generate_eclipse_workingsets():
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4254 """
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
4255 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
4256 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
4257 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
4258 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
4259 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4260
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4261 # 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
4262 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
4263 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
4264 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
4265 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
4266 else:
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
4267 expected_wsroot = _primary_suite.dir
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4268
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4269 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
4270 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
4271 # 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
4272 wsroot = expected_wsroot
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4273
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
4274 wsdir = join(wsroot, wsloc)
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4275 if not exists(wsdir):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4276 wsdir = wsroot
13480
6215ff792647 put warning about missing Eclipse metadata directory behind -v option
Doug Simon <doug.simon@oracle.com>
parents: 13475
diff changeset
4277 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
4278 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
4279
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4280 # 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
4281 workingSets = dict()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4282 for p in projects():
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4283 if p.workingSets is None:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4284 continue
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4285 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
4286 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
4287 workingSets[w] = [p.name]
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4288 else:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4289 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
4290
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4291 if exists(wspath):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4292 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
4293 else:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4294 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
4295
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4296 update_file(wspath, wsdoc.xml(newl='\n'))
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4297
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
4298 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
4299 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
4300 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
4301 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
4302 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
4303 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
4304 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
4305 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
4306 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
4307
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4308 def _make_workingset_xml(workingSets):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4309 wsdoc = XMLDoc()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4310 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
4311
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4312 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
4313 _workingset_open(wsdoc, w)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4314 for p in workingSets[w]:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4315 _workingset_element(wsdoc, p)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4316 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
4317
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4318 wsdoc.close('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4319 return wsdoc
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4320
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4321 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
4322 target = XMLDoc()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4323 target.open('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4324
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4325 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
4326
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4327 class ParserState(object):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4328 def __init__(self):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4329 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
4330 self.current_ws = None
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4331 self.seen_ws = list()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4332 self.seen_projects = list()
13824
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4333 self.aggregate_ws = False
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4334 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
4335
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4336 ps = ParserState()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4337
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4338 # parsing logic
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4339 def _ws_start(name, attributes):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4340 if name == 'workingSet':
13824
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4341 if attributes.has_key('name'):
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4342 ps.current_ws_name = attributes['name']
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4343 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
4344 ps.aggregate_ws = True
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4345 ps.current_ws = None
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4346 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
4347 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
4348 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
4349 ps.seen_projects = list()
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4350 else:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4351 ps.current_ws = None
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4352 target.open(name, attributes)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4353 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
4354
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4355 def _ws_end(name):
13824
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4356 closeAndResetHandler = False
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4357 if name == 'workingSet':
13824
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4358 if ps.aggregate_ws:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4359 if ps.nested_ws:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4360 ps.nested_ws = False
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4361 else:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4362 ps.aggregate_ws = False
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4363 closeAndResetHandler = True
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4364 else:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4365 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
4366 for p in ps.current_ws:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4367 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
4368 _workingset_element(target, p)
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4369 closeAndResetHandler = True
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4370 if closeAndResetHandler:
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4371 target.close('workingSet')
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4372 parser.StartElementHandler = _ws_start
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4373 elif name == 'workingSetManager':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4374 # 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
4375 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
4376 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
4377 _workingset_open(target, w)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4378 for p in workingSets[w]:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4379 _workingset_element(target, p)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4380 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
4381
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4382 def _ws_item(name, attributes):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4383 if name == 'item':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4384 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
4385 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
4386 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
4387 target.element(name, attributes)
14937
3de340bdb8d3 added support for adding sources to distribution
Doug Simon <doug.simon@oracle.com>
parents: 14918
diff changeset
4388 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
4389 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
4390 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4391 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
4392 _workingset_element(target, p_name)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4393 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
4394 elif name == 'workingSet':
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4395 ps.nested_ws = True
96d5cb754b68 address issue in Eclipse working set generation
Michael Haupt <michael.haupt@oracle.com>
parents: 13779
diff changeset
4396 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
4397
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4398 # process document
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4399 parser.StartElementHandler = _ws_start
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4400 parser.EndElementHandler = _ws_end
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4401 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
4402 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
4403
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4404 target.close('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4405 return target
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4406
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4407 def _workingset_open(wsdoc, ws):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4408 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
4409
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4410 def _workingset_element(wsdoc, p):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
4411 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
4412
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4413 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
4414 """(re)generate NetBeans project configurations"""
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4415
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
4416 for suite in suites(True):
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4417 _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars)
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4418
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4419 def _netbeansinit_project(p, jdks=None, files=None, libFiles=None):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4420 if not exists(join(p.dir, 'nbproject')):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4421 os.makedirs(join(p.dir, 'nbproject'))
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4422
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4423 jdk = java(p.javaCompliance)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4424 assert jdk
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4425
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4426 if jdks:
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
4427 jdks.add(jdk)
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
4428
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4429 out = XMLDoc()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4430 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4431 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4432 out.element('import', {'file' : 'nbproject/build-impl.xml'})
19822
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4433 out.open('target', {'name' : '-post-init'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4434 out.open('pathconvert', {'property' : 'comma.javac.classpath', 'pathsep' : ','})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4435 out.element('path', {'path' : '${javac.classpath}'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4436 out.close('pathconvert')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4437
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4438 out.open('restrict', {'id' : 'missing.javac.classpath'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4439 out.element('filelist', {'dir' : '${basedir}', 'files' : '${comma.javac.classpath}'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4440 out.open('not')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4441 out.element('exists')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4442 out.close('not')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4443 out.close('restrict')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4444
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4445 out.element('property', {'name' : 'missing.javac.classpath', 'refid' : 'missing.javac.classpath'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4446
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4447 out.open('condition', {'property' : 'no.dependencies', 'value' : 'true'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4448 out.element('equals', {'arg1' : '${missing.javac.classpath}', 'arg2' : ''})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4449 out.close('condition')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4450
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4451 out.element('property', {'name' : 'no.dependencies', 'value' : 'false'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4452
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4453 out.open('condition', {'property' : 'no.deps'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4454 out.element('equals', {'arg1' : '${no.dependencies}', 'arg2' : 'true'})
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4455 out.close('condition')
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4456
e87d55dfbbbb trigger building all dependencies in NetBeans only when needed
Doug Simon <doug.simon@oracle.com>
parents: 19804
diff changeset
4457 out.close('target')
21428
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4458 out.open('target', {'name' : 'compile'})
21653
ec47283499ef Fail the build when there are compile errors
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21634
diff changeset
4459 out.open('exec', {'executable' : sys.executable, 'failonerror' : 'true'})
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4460 out.element('env', {'key' : 'JAVA_HOME', 'value' : jdk.jdk})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4461 out.element('arg', {'value' : os.path.abspath(__file__)})
21428
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4462 out.element('arg', {'value' : 'build'})
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4463 out.element('arg', {'value' : '--only'})
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4464 out.element('arg', {'value' : p.name})
21503
12e3d0dfffeb GRAAL-1090: Doug speeds up ./mx.sh build --only com.oracle.truffle.sl from 8s to 4s on my computer.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21472
diff changeset
4465 out.element('arg', {'value' : '--force-javac'})
12e3d0dfffeb GRAAL-1090: Doug speeds up ./mx.sh build --only com.oracle.truffle.sl from 8s to 4s on my computer.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21472
diff changeset
4466 out.element('arg', {'value' : '--no-native'})
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4467 out.close('exec')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4468 out.close('target')
21428
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4469 out.open('target', {'name' : 'jar', 'depends' : 'compile'})
e3438899928c Bind NetBeans Build action directly to ./mx build command line invocation
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21395
diff changeset
4470 out.close('target')
21982
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4471 out.open('target', {'name' : 'javadoc'})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4472 out.open('exec', {'executable' : sys.executable, 'failonerror' : 'true'})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4473 out.element('env', {'key' : 'JAVA_HOME', 'value' : jdk.jdk})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4474 out.element('arg', {'value' : os.path.abspath(__file__)})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4475 out.element('arg', {'value' : 'javadoc'})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4476 out.element('arg', {'value' : '--projects'})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4477 out.element('arg', {'value' : p.name})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4478 out.close('exec')
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4479 out.element('nbbrowse', {'file' : 'javadoc/index.html'})
6691b182e1a1 Call into mx to generate javadoc for the project
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21953
diff changeset
4480 out.close('target')
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4481 out.close('project')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4482 update_file(join(p.dir, 'build.xml'), out.xml(indent='\t', newl='\n'))
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4483 if files:
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
4484 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
4485
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4486 out = XMLDoc()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4487 out.open('project', {'xmlns' : 'http://www.netbeans.org/ns/project/1'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4488 out.element('type', data='org.netbeans.modules.java.j2seproject')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4489 out.open('configuration')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4490 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4491 out.element('name', data=p.name)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4492 out.element('explicit-platform', {'explicit-source-supported' : 'true'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4493 out.open('source-roots')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4494 out.element('root', {'id' : 'src.dir'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4495 if len(p.annotation_processors()) > 0:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4496 out.element('root', {'id' : 'src.ap-source-output.dir', 'name' : 'Generated Packages'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4497 out.close('source-roots')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4498 out.open('test-roots')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4499 out.close('test-roots')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4500 out.close('data')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4501
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4502 firstDep = True
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4503 for dep in p.all_deps([], includeLibs=False, includeAnnotationProcessors=True):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4504 if dep == p:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4505 continue
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4506
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4507 if dep.isProject():
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4508 n = dep.name.replace('.', '_')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4509 if firstDep:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4510 out.open('references', {'xmlns' : 'http://www.netbeans.org/ns/ant-project-references/1'})
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4511 firstDep = False
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4512
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4513 out.open('reference')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4514 out.element('foreign-project', data=n)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4515 out.element('artifact-type', data='jar')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4516 out.element('script', data='build.xml')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4517 out.element('target', data='jar')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4518 out.element('clean-target', data='clean')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4519 out.element('id', data='jar')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4520 out.close('reference')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4521
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4522 if not firstDep:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4523 out.close('references')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4524
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4525 out.close('configuration')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4526 out.close('project')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4527 update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n'))
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4528 if files:
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
4529 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
4530
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4531 out = StringIO.StringIO()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4532 jdkPlatform = 'JDK_' + str(jdk.version)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4533
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4534 annotationProcessorEnabled = "false"
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4535 annotationProcessorSrcFolder = ""
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4536 if len(p.annotation_processors()) > 0:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4537 annotationProcessorEnabled = "true"
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4538 genSrcDir = p.source_gen_dir()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4539 if not exists(genSrcDir):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4540 os.makedirs(genSrcDir)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4541 annotationProcessorSrcFolder = "src.ap-source-output.dir=" + genSrcDir
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4542
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4543 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
4544 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
4545 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
4546 annotation.processing.processors.list=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4547 annotation.processing.run.all.processors=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4548 application.title=""" + p.name + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4549 application.vendor=mx
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4550 build.classes.dir=${build.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4551 build.classes.excludes=**/*.java,**/*.form
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4552 # 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
4553 build.dir=bin
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4554 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
4555 # 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
4556 build.sysclasspath=ignore
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4557 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
4558 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
4559 # 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
4560 #debug.transport=dt_socket
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4561 debug.classpath=\\
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4562 ${run.classpath}
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4563 debug.test.classpath=\\
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4564 ${run.test.classpath}
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4565 # 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
4566 dist.dir=dist
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4567 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
4568 dist.javadoc.dir=${dist.dir}/javadoc
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4569 endorsed.classpath=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4570 excludes=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4571 includes=**
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4572 jar.compress=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4573 # Space-separated list of extra javac options
17075
c24ea91c30ba create generated source dirs as part of netbeansinit
Doug Simon <doug.simon@oracle.com>
parents: 17063
diff changeset
4574 javac.compilerargs=-XDignore.symbol.file
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4575 javac.deprecation=false
16706
ff2b25002a58 set javac.source and javac.target in NetBeans configurations based on per-project Java compliance
Doug Simon <doug.simon@oracle.com>
parents: 16682
diff changeset
4576 javac.source=""" + str(p.javaCompliance) + """
ff2b25002a58 set javac.source and javac.target in NetBeans configurations based on per-project Java compliance
Doug Simon <doug.simon@oracle.com>
parents: 16682
diff changeset
4577 javac.target=""" + str(p.javaCompliance) + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4578 javac.test.classpath=\\
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4579 ${javac.classpath}:\\
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4580 ${build.classes.dir}
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4581 javadoc.additionalparam=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4582 javadoc.author=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4583 javadoc.encoding=${source.encoding}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4584 javadoc.noindex=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4585 javadoc.nonavbar=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4586 javadoc.notree=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4587 javadoc.private=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4588 javadoc.splitindex=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4589 javadoc.use=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4590 javadoc.version=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4591 javadoc.windowtitle=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4592 main.class=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4593 manifest.file=manifest.mf
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4594 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
4595 mkdist.disabled=false
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
4596 platforms.""" + jdkPlatform + """.home=""" + jdk.jdk + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4597 platform.active=""" + jdkPlatform + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4598 run.classpath=\\
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4599 ${javac.classpath}:\\
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4600 ${build.classes.dir}
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4601 # 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
4602 # (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
4603 # 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
4604 run.jvmargs=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4605 run.test.classpath=\\
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4606 ${javac.test.classpath}:\\
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4607 ${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
4608 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
4609 """ + annotationProcessorSrcFolder + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4610 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep)
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4611 print >> out, content
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4612
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4613 mainSrc = True
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4614 for src in p.srcDirs:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4615 srcDir = join(p.dir, src)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4616 if not exists(srcDir):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4617 os.mkdir(srcDir)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4618 ref = 'file.reference.' + p.name + '-' + src
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4619 print >> out, ref + '=' + src
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4620 if mainSrc:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4621 print >> out, 'src.dir=${' + ref + '}'
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4622 mainSrc = False
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4623 else:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4624 print >> out, 'src.' + src + '.dir=${' + ref + '}'
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4625
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4626 javacClasspath = []
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4627
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4628 deps = p.all_deps([], True)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4629 annotationProcessorOnlyDeps = []
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4630 if len(p.annotation_processors()) > 0:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4631 for ap in p.annotation_processors():
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4632 apDep = dependency(ap)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4633 if not apDep in deps:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4634 deps.append(apDep)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4635 annotationProcessorOnlyDeps.append(apDep)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4636
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4637 annotationProcessorReferences = []
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4638
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4639 for dep in deps:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4640 if dep == p:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4641 continue
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4642
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4643 if dep.isLibrary():
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4644 path = dep.get_path(resolve=True)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4645 if path:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4646 if os.sep == '\\':
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4647 path = path.replace('\\', '\\\\')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4648 ref = 'file.reference.' + dep.name + '-bin'
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4649 print >> out, ref + '=' + path
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4650 if libFiles:
17092
2f64a6c771d5 Backed out changeset: f0b55d0c5d2d
Doug Simon <doug.simon@oracle.com>
parents: 17076
diff changeset
4651 libFiles.append(path)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4652
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4653 elif dep.isProject():
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4654 n = dep.name.replace('.', '_')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4655 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4656 ref = 'reference.' + n + '.jar'
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4657 print >> out, 'project.' + n + '=' + relDepPath
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4658 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar'
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4659
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4660 if not dep in annotationProcessorOnlyDeps:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4661 javacClasspath.append('${' + ref + '}')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4662 else:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4663 annotationProcessorReferences.append('${' + ref + '}')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4664
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4665 print >> out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4666 print >> out, 'javac.processorpath=' + (os.pathsep + '\\\n ').join(['${javac.classpath}'] + annotationProcessorReferences)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4667 print >> out, 'javac.test.processorpath=' + (os.pathsep + '\\\n ').join(['${javac.test.classpath}'] + annotationProcessorReferences)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4668
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4669 update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue())
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4670 out.close()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4671 if files:
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
4672 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
4673
18158
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4674 def _netbeansinit_suite(args, suite, refreshOnly=False, buildProcessorJars=True):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4675 configZip = TimeStampFile(join(suite.mxDir, 'netbeans-config.zip'))
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4676 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4677 if refreshOnly and not configZip.exists():
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4678 return
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4679
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4680 if _check_ide_timestamp(suite, configZip, 'netbeans'):
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4681 logv('[NetBeans configurations are up to date - skipping]')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4682 return
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4683
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4684 files = []
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4685 libFiles = []
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4686 jdks = set()
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4687 for p in suite.projects:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4688 if p.native:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4689 continue
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4690
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4691 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4692 continue
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4693
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4694 _netbeansinit_project(p, jdks, files, libFiles)
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4695
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4696 log('If using NetBeans:')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4697 # http://stackoverflow.com/questions/24720665/cant-resolve-jdk-internal-package
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4698 log(' 1. Edit etc/netbeans.conf in your NetBeans installation and modify netbeans_default_options variable to include "-J-DCachingArchiveProvider.disableCtSym=true"')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4699 log(' 2. Ensure that the following platform(s) are defined (Tools -> Java Platforms):')
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4700 for jdk in jdks:
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4701 log(' JDK_' + str(jdk.version))
31ad929e1afd factored out _netbeansinit_project function
Doug Simon <doug.simon@oracle.com>
parents: 18135
diff changeset
4702 log(' 3. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4703
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
4704 _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
4705 _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
4706
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4707 def intellijinit(args, refreshOnly=False):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4708 """(re)generate Intellij project configurations"""
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4709
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4710 for suite in suites(True):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4711 _intellij_suite(args, suite, refreshOnly)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4712
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4713 def _intellij_suite(args, suite, refreshOnly=False):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4714
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4715 libraries = set()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4716
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4717 ideaProjectDirectory = join(suite.dir, '.idea')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4718
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4719 if not exists(ideaProjectDirectory):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4720 os.mkdir(ideaProjectDirectory)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4721 nameFile = join(ideaProjectDirectory, '.name')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4722 update_file(nameFile, "Graal")
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4723 modulesXml = XMLDoc()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4724 modulesXml.open('project', attributes={'version': '4'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4725 modulesXml.open('component', attributes={'name': 'ProjectModuleManager'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4726 modulesXml.open('modules')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4727
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4728
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4729 def _intellij_exclude_if_exists(xml, p, name):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4730 path = join(p.dir, name)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4731 if exists(path):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4732 xml.element('excludeFolder', attributes={'url':'file://$MODULE_DIR$/' + name})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4733
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4734 annotationProcessorProfiles = {}
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4735
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4736 def _complianceToIntellijLanguageLevel(compliance):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4737 return 'JDK_1_' + str(compliance.value)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4738
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4739 # create the modules (1 module = 1 Intellij project)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4740 for p in suite.projects:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4741 if p.native:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4742 continue
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4743
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
4744 assert java(p.javaCompliance)
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4745
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4746 if not exists(p.dir):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4747 os.makedirs(p.dir)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4748
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4749 annotationProcessorProfileKey = tuple(p.annotation_processors())
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4750
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4751 if not annotationProcessorProfileKey in annotationProcessorProfiles:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4752 annotationProcessorProfiles[annotationProcessorProfileKey] = [p]
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4753 else:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4754 annotationProcessorProfiles[annotationProcessorProfileKey].append(p)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4755
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4756 intellijLanguageLevel = _complianceToIntellijLanguageLevel(p.javaCompliance)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4757
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4758 moduleXml = XMLDoc()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4759 moduleXml.open('module', attributes={'type': 'JAVA_MODULE', 'version': '4'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4760
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4761 moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'LANGUAGE_LEVEL': intellijLanguageLevel, 'inherit-compiler-output': 'false'})
15122
11a591a99515 mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents: 15118
diff changeset
4762 moduleXml.element('output', attributes={'url': 'file://$MODULE_DIR$/bin'})
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4763 moduleXml.element('exclude-output')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4764
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4765 moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4766 for src in p.srcDirs:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4767 srcDir = join(p.dir, src)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4768 if not exists(srcDir):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4769 os.mkdir(srcDir)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4770 moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + src, 'isTestSource': 'false'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4771
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4772 if len(p.annotation_processors()) > 0:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4773 genDir = p.source_gen_dir()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4774 if not exists(genDir):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4775 os.mkdir(genDir)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4776 moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + os.path.relpath(genDir, p.dir), 'isTestSource': 'false'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4777
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4778 for name in ['.externalToolBuilders', '.settings', 'nbproject']:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4779 _intellij_exclude_if_exists(moduleXml, p, name)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4780 moduleXml.close('content')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4781
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4782 moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': 'JavaSDK', 'jdkName': str(p.javaCompliance)})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4783 moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4784
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4785 deps = p.all_deps([], True, includeAnnotationProcessors=True)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4786 for dep in deps:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4787 if dep == p:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4788 continue
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4789
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4790 if dep.isLibrary():
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
4791 libraries.add(dep)
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
4792 moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'})
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
4793 elif dep.isProject():
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4794 moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': dep.name})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4795
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4796 moduleXml.close('component')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4797 moduleXml.close('module')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4798 moduleFile = join(p.dir, p.name + '.iml')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4799 update_file(moduleFile, moduleXml.xml(indent=' ', newl='\n'))
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4800
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4801 moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(moduleFile, suite.dir)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4802 modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4803
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4804 modulesXml.close('modules')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4805 modulesXml.close('component')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4806 modulesXml.close('project')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4807 moduleXmlFile = join(ideaProjectDirectory, 'modules.xml')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4808 update_file(moduleXmlFile, modulesXml.xml(indent=' ', newl='\n'))
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4809
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4810 # TODO What about cross-suite dependencies?
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4811
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4812 librariesDirectory = join(ideaProjectDirectory, 'libraries')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4813
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4814 if not exists(librariesDirectory):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4815 os.mkdir(librariesDirectory)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4816
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4817 # Setup the libraries that were used above
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4818 # TODO: setup all the libraries from the suite regardless of usage?
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4819 for library in libraries:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4820 libraryXml = XMLDoc()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4821
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4822 libraryXml.open('component', attributes={'name': 'libraryTable'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4823 libraryXml.open('library', attributes={'name': library.name})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4824 libraryXml.open('CLASSES')
15134
f0fc09c0845e Be sure to resolve and download librariesin mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15122
diff changeset
4825 libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.get_path(True), suite.dir) + '!/'})
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4826 libraryXml.close('CLASSES')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4827 libraryXml.element('JAVADOC')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4828 if library.sourcePath:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4829 libraryXml.open('SOURCES')
15134
f0fc09c0845e Be sure to resolve and download librariesin mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15122
diff changeset
4830 libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.get_source_path(True), suite.dir) + '!/'})
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4831 libraryXml.close('SOURCES')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4832 else:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4833 libraryXml.element('SOURCES')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4834 libraryXml.close('library')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4835 libraryXml.close('component')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4836
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4837 libraryFile = join(librariesDirectory, library.name + '.xml')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4838 update_file(libraryFile, libraryXml.xml(indent=' ', newl='\n'))
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4839
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4840
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4841
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4842 # Set annotation processor profiles up, and link them to modules in compiler.xml
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4843 compilerXml = XMLDoc()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4844 compilerXml.open('project', attributes={'version': '4'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4845 compilerXml.open('component', attributes={'name': 'CompilerConfiguration'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4846
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4847 compilerXml.element('option', attributes={'name': "DEFAULT_COMPILER", 'value': 'Javac'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4848 compilerXml.element('resourceExtensions')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4849 compilerXml.open('wildcardResourcePatterns')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4850 compilerXml.element('entry', attributes={'name': '!?*.java'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4851 compilerXml.close('wildcardResourcePatterns')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4852
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4853 if annotationProcessorProfiles:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4854 compilerXml.open('annotationProcessing')
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
4855 for processors, modules in sorted(annotationProcessorProfiles.iteritems()):
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4856 compilerXml.open('profile', attributes={'default': 'false', 'name': '-'.join(processors), 'enabled': 'true'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4857 compilerXml.element('sourceOutputDir', attributes={'name': 'src_gen'}) # TODO use p.source_gen_dir() ?
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4858 compilerXml.element('outputRelativeToContentRoot', attributes={'value': 'true'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4859 compilerXml.open('processorPath', attributes={'useClasspath': 'false'})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4860 for apName in processors:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4861 pDep = dependency(apName)
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4862 for entry in pDep.all_deps([], True):
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4863 if entry.isLibrary():
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4864 compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.path, suite.dir)})
15662
50fbda571d99 mx: added jrelibrary dependency type
Doug Simon <doug.simon@oracle.com>
parents: 15638
diff changeset
4865 elif entry.isProject():
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4866 assert entry.isProject()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4867 compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.output_dir(), suite.dir)})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4868 compilerXml.close('processorPath')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4869 for module in modules:
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4870 compilerXml.element('module', attributes={'name': module.name})
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4871 compilerXml.close('profile')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4872 compilerXml.close('annotationProcessing')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4873
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4874 compilerXml.close('component')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4875 compilerXml.close('project')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4876 compilerFile = join(ideaProjectDirectory, 'compiler.xml')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4877 update_file(compilerFile, compilerXml.xml(indent=' ', newl='\n'))
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4878
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4879 # Wite misc.xml for global JDK config
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4880 miscXml = XMLDoc()
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4881 miscXml.open('project', attributes={'version': '4'})
15135
0672512feb81 mx intellijinit: fix typo in project's language level settings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15134
diff changeset
4882 miscXml.element('component', attributes={'name': 'ProjectRootManager', 'version': '2', 'languageLevel': _complianceToIntellijLanguageLevel(java().javaCompliance), 'project-jdk-name': str(java().javaCompliance), 'project-jdk-type': 'JavaSDK'})
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4883 miscXml.close('project')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4884 miscFile = join(ideaProjectDirectory, 'misc.xml')
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4885 update_file(miscFile, miscXml.xml(indent=' ', newl='\n'))
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4886
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4887
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4888 # TODO look into copyright settings
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4889 # TODO should add vcs.xml support
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4890
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
4891 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
4892 """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
4893 def rm(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4894 if exists(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4895 os.remove(path)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4896
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4897 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
4898 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
4899 rm(join(s.mxDir, 'netbeans-config.zip'))
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4900 shutil.rmtree(join(s.dir, '.idea'), ignore_errors=True)
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4901
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4902 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
4903 if p.native:
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4904 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4905
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4906 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
4907 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
4908 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
4909 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
4910 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
4911 rm(join(p.dir, '.project'))
10043
e063474076dd clean up .factorypath files on "mx ideclean"
Lukas Stadler <lukas.stadler@jku.at>
parents: 9857
diff changeset
4912 rm(join(p.dir, '.factorypath'))
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4913 rm(join(p.dir, p.name + '.iml'))
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
4914 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
4915 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
4916 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
4917 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
4918 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
4919 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
4920
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
4921 for d in _dists.itervalues():
16849
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4922 if d.get_ide_project_dir():
0d987db807df do not generate IDE configurations for distributions auto-generated for projects that define annotation processors
Doug Simon <doug.simon@oracle.com>
parents: 16847
diff changeset
4923 shutil.rmtree(d.get_ide_project_dir(), ignore_errors=True)
16845
1fd7bb00a77f clean up generated IDE content for distributions as part of 'mx ideclean'
Doug Simon <doug.simon@oracle.com>
parents: 16839
diff changeset
4924
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4925 def ideinit(args, refreshOnly=False, buildProcessorJars=True):
15378
dea98caac669 Fix help text for ideinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15376
diff changeset
4926 """(re)generate Eclipse, NetBeans and Intellij project configurations"""
16846
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4927 eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
e3dd75b3c290 revived creation of annotation processor jars by 'mx ideinit'
Doug Simon <doug.simon@oracle.com>
parents: 16845
diff changeset
4928 netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
4929 intellijinit(args, refreshOnly=refreshOnly)
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4930 if not refreshOnly:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4931 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
4932
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
4933 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
4934 """find directories corresponding to deleted Java projects and delete them"""
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
4935 if not is_interactive():
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4936 log('fsckprojects command must be run in an interactive shell')
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4937 return
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4938 hg = HgConfig()
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
4939 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
4940 projectDirs = [p.dir for p in suite.projects]
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4941 distIdeDirs = [d.get_ide_project_dir() for d in suite.dists if d.get_ide_project_dir() is not None]
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4942 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
4943 if dirpath == suite.dir:
21703
b939ee385ae4 mx fsckprojects: exclude .workspace/
Andreas Woess <andreas.woess@oracle.com>
parents: 21702
diff changeset
4944 # no point in traversing .hg, lib, or .workspace
b939ee385ae4 mx fsckprojects: exclude .workspace/
Andreas Woess <andreas.woess@oracle.com>
parents: 21702
diff changeset
4945 dirnames[:] = [d for d in dirnames if d not in ['.hg', 'lib', '.workspace']]
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4946 elif dirpath in projectDirs:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4947 # 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
4948 dirnames[:] = []
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4949 elif dirpath in distIdeDirs:
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4950 # don't traverse subdirs of an existing distributions in this suite
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4951 dirnames[:] = []
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
4952 else:
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4953 projectConfigFiles = frozenset(['.classpath', '.project', 'nbproject'])
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
4954 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
4955 if len(indicators) != 0:
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4956 indicators = [os.path.relpath(join(dirpath, i), suite.dir) for i in indicators]
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4957 indicatorsInHg = hg.locate(suite.dir, indicators)
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4958 # Only proceed if there are indicator files that are not under HG
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4959 if len(indicators) > len(indicatorsInHg):
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
4960 if not is_interactive() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'):
20112
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4961 shutil.rmtree(dirpath)
02a9b5d77964 improved fsckprojects to take into account hg tracked files
Doug Simon <doug.simon@oracle.com>
parents: 20102
diff changeset
4962 log('Deleted ' + dirpath)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4963
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4964 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
4965 """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
4966
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
4967 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
4968 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
4969 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
4970 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
4971 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
4972 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
4973 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
4974 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
4975 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
4976 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
4977 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
4978
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
4979 args = parser.parse_args(args)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4980
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
4981 # 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
4982 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
4983 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
4984 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
4985 candidates = projects_opt_limit_to_suites()
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4986
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
4987 # optionally restrict packages within a project
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4988 packages = []
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4989 if args.packages is not None:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4990 packages = [name for name in args.packages.split(',')]
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
4991
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
4992 exclude_packages = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
4993 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
4994 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
4995
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4996 def outDir(p):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4997 if args.base is None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4998 return join(p.dir, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4999 return join(args.base, p.name, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5000
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5001 def check_package_list(p):
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
5002 return not exists(join(outDir(p), 'package-list'))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5003
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5004 def assess_candidate(p, projects):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5005 if p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5006 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5007 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
5008 projects.append(p)
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5009 return True
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5010 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5011
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5012 projects = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5013 for p in candidates:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5014 if not p.native:
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
5015 if includeDeps:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5016 deps = p.all_deps([], includeLibs=False, includeSelf=False)
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5017 for d in deps:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5018 assess_candidate(d, projects)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5019 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
5020 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
5021
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5022
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5023 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
5024 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
5025 pkgs = set()
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5026 for sourceDir in sourceDirs:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5027 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
5028 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
5029 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
5030 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
5031 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
5032 pkgs.add(pkg)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5033 return pkgs
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5034
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5035 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
5036 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
5037 extraArgs += ['@' + args.argfile]
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5038 memory = '2g'
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5039 if args.memory is not None:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5040 memory = args.memory
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5041 memory = '-J-Xmx' + memory
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5042
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5043 if not args.unified:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5044 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
5045 # 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
5046 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
5047
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5048 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
5049 deps = p.all_deps([], includeLibs=False, includeSelf=False)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5050 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
5051 out = outDir(p)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5052 for d in deps:
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5053 depOut = outDir(d)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5054 links.append('-link')
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5055 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
5056 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
5057 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
5058 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
5059 delOverviewFile = False
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5060 if not exists(overviewFile):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5061 with open(overviewFile, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5062 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
5063 delOverviewFile = True
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5064 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5065 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5066 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
5067
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
5068 # 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
5069 windowTitle = []
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
5070 if stdDoclet:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
5071 windowTitle = ['-windowtitle', p.name + ' javadoc']
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5072 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5073 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
5074 projectJava = java(p.javaCompliance)
15419
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5075
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5076 # Once https://bugs.openjdk.java.net/browse/JDK-8041628 is fixed,
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5077 # this should be reverted to:
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5078 # javadocExe = java().javadoc
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
5079 # we can then also respect _opts.relatex_compliance
15419
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5080 javadocExe = projectJava.javadoc
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5081
f093fa76e872 made note about workaround for JDK-8041628
Doug Simon <doug.simon@oracle.com>
parents: 15408
diff changeset
5082 run([javadocExe, memory,
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5083 '-XDignore.symbol.file',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5084 '-classpath', cp,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5085 '-quiet',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5086 '-d', out,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5087 '-overview', overviewFile,
14916
66e9855f4ae8 Add -source -bootclasspath and -extdirs arguments to javadoc command
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14915
diff changeset
5088 '-sourcepath', sp,
20965
05e1ab8c5c6a relax expectations on JDK library locations
Doug Simon <doug.simon@oracle.com>
parents: 20181
diff changeset
5089 '-source', str(projectJava.javaCompliance)] +
20983
b99da6d86cfe relax expectations on JDK library locations (bug fixes)
Doug Simon <doug.simon@oracle.com>
parents: 20965
diff changeset
5090 projectJava.javadocLibOptions([]) +
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5091 ([] if projectJava.javaCompliance < JavaCompliance('1.8') else ['-Xdoclint:none']) +
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5092 links +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5093 extraArgs +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5094 nowarnAPI +
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
5095 windowTitle +
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5096 list(pkgs))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5097 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
5098 finally:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5099 if delOverviewFile:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5100 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
5101
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5102 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
5103 # 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
5104 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
5105
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5106 pkgs = set()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5107 sp = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5108 names = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5109 for p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5110 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
5111 sp += p.source_dirs()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5112 names.append(p.name)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5113
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14745
diff changeset
5114 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
5115 out = join(_primary_suite.dir, docDir)
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5116 if args.base is not None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5117 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
5118 cp = classpath()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
5119 sp = os.pathsep.join(sp)
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5120 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5121 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5122 nowarnAPI.append('-XDignore.symbol.file')
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5123 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
5124 run([java().javadoc, memory,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5125 '-classpath', cp,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5126 '-quiet',
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5127 '-d', out,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5128 '-sourcepath', sp] +
15403
a9df38ce8fb7 mx: disable doclint when running javadoc (until the code base is doclint clean)
Doug Simon <doug.simon@oracle.com>
parents: 15386
diff changeset
5129 ([] if java().javaCompliance < JavaCompliance('1.8') else ['-Xdoclint:none']) +
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5130 links +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5131 extraArgs +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5132 nowarnAPI +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
5133 list(pkgs))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
5134 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
5135
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5136 def site(args):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5137 """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
5138
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5139 parser = ArgumentParser(prog='site')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5140 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>')
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5141 parser.add_argument('--tmp', action='store', help='directory to use for intermediate results', metavar='<dir>')
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5142 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
5143 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
5144 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
5145 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
5146 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
5147 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
5148 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
5149 args = parser.parse_args(args)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5150
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5151 args.base = os.path.abspath(args.base)
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5152 tmpbase = args.tmp if args.tmp else tempfile.mkdtemp(prefix=basename(args.base) + '.', dir=dirname(args.base))
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5153 unified = join(tmpbase, 'all')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5154
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5155 exclude_packages_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5156 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
5157 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
5158
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5159 projects = sorted_deps()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5160 projects_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5161 if args.projects is not None:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5162 projects_arg = ['--projects', args.projects]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5163 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
5164
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
5165 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
5166 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
5167 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
5168 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
5169
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5170 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5171 # 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
5172 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
5173
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5174 # 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
5175 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
5176 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
5177 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
5178 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
5179 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
5180 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
5181 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
5182 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
5183 <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
5184 <caption><span>Projects</span><span class="tabEnd">&nbsp;</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
5185 <tr><th class="colFirst" scope="col">Project</th><th class="colLast" scope="col">&nbsp;</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
5186 <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
5187 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
5188 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
5189 print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html",target = "_top">{0}</a></td><td class="colLast">&nbsp;</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
5190 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
5191
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
5192 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
5193 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
5194
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5195 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
5196 javadoc(['--base', tmpbase,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5197 '--unified',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5198 '--arg', '@-windowtitle', '--arg', '@' + title,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5199 '--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
5200 '--arg', '@-overview', '--arg', '@' + args.overview] + exclude_packages_arg + projects_arg + extra_javadoc_args)
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5201
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5202 if exists(unified):
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5203 shutil.rmtree(unified)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5204 os.rename(join(tmpbase, 'javadoc'), unified)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5205
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5206 # Generate dependency graph with Graphviz
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5207 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
5208 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
5209 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
5210 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
5211 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
5212 except subprocess.CalledProcessError as e:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
5213 dotErr = 'error calling "dot -V": {0}'.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
5214 except OSError as e:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
5215 dotErr = 'error calling "dot -V": {0}'.format(e)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5216
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
5217 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
5218 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
5219
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5220 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
5221 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
5222 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
5223 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
5224 with open(dot, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5225 dim = len(projects)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5226 print >> fp, 'digraph projects {'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5227 print >> fp, 'rankdir=BT;'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5228 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
5229 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
5230 # print >> fp, 'edge [color="green"];'
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5231 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5232 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
5233 for dep in p.canonical_deps():
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5234 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
5235 print >> fp, '"' + p.name + '" -> "' + dep + '"'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5236 depths = dict()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5237 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5238 d = p.max_depth()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5239 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
5240 print >> fp, '}'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5241
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5242 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
5243
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
5244 # 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
5245 # 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
5246 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
5247 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
5248 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
5249 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
5250 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
5251 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
5252
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
5253 # 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
5254 with open(html, 'w') as fp:
18635
a8b46348b79f mx: converted format strings to be python 2.6 compliant
Doug Simon <doug.simon@oracle.com>
parents: 18620
diff changeset
5255 print >> fp, '<html><body><object data="{0}.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
5256
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5257 if exists(args.base):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5258 shutil.rmtree(args.base)
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5259 if args.tmp:
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5260 shutil.copytree(tmpbase, args.base)
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5261 else:
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5262 shutil.move(tmpbase, args.base)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5263
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5264 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
5265
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5266 finally:
15406
ca16edfcecd5 mx: fixed site command by removing brittle post-processing of javadoc output
Doug Simon <doug.simon@oracle.com>
parents: 15403
diff changeset
5267 if not args.tmp and exists(tmpbase):
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5268 shutil.rmtree(tmpbase)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5269
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5270 def _kwArg(kwargs):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5271 if len(kwargs) > 0:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5272 return kwargs.pop(0)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5273 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5274
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16087
diff changeset
5275 def findclass(args, logToConsole=True, matcher=lambda string, classname: string in classname):
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5276 """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
5277 matches = []
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5278 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
5279 if filename.endswith('.class'):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5280 if isinstance(entry, zipfile.ZipFile):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5281 classname = filename.replace('/', '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5282 else:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5283 classname = filename.replace(os.sep, '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5284 classname = classname[:-len('.class')]
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5285 for a in args:
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16087
diff changeset
5286 if matcher(a, classname):
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
5287 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
5288 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
5289 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
5290 return matches
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5291
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5292 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
5293 """
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5294 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
5295
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5296 """
11318
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
5297 if len(items) <= 1:
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
5298 return items
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
5299 else:
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
5300 assert is_interactive()
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
5301 numlen = str(len(str(len(items))))
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5302 if allowMultiple:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
5303 log(('[{0:>' + numlen + '}] <all>').format(0))
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5304 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
5305 if descriptions is None:
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
5306 log(('[{0:>' + numlen + '}] {1}').format(i + 1, items[i]))
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5307 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5308 assert len(items) == len(descriptions)
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5309 wrapper = textwrap.TextWrapper(subsequent_indent=' ')
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21068
diff changeset
5310 log('\n'.join(wrapper.wrap(('[{0:>' + numlen + '}] {1} - {2}').format(i + 1, items[i], descriptions[i]))))
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5311 while True:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5312 if allowMultiple:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5313 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
5314 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5315 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
5316 try:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5317 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
5318 except:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5319 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
5320 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5321
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5322 if allowMultiple and 0 in s:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5323 return items
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5324
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5325 indexes = []
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5326 for n in s:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5327 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
5328 log('Invalid selection: ' + str(n))
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5329 continue
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5330 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5331 indexes.append(n - 1)
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5332 if allowMultiple:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5333 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
5334 if len(indexes) == 1:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5335 return items[indexes[0]]
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
5336 return None
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5337
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5338 def exportlibs(args):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5339 """export libraries to an archive file"""
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5340
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5341 parser = ArgumentParser(prog='exportlibs')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5342 parser.add_argument('-b', '--base', action='store', help='base name of archive (default: libs)', default='libs', metavar='<path>')
15364
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5343 parser.add_argument('-a', '--include-all', action='store_true', help="include all defined libaries")
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5344 parser.add_argument('--arc', action='store', choices=['tgz', 'tbz2', 'tar', 'zip'], default='tgz', help='the type of the archive to create')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5345 parser.add_argument('--no-sha1', action='store_false', dest='sha1', help='do not create SHA1 signature of archive')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5346 parser.add_argument('--no-md5', action='store_false', dest='md5', help='do not create MD5 signature of archive')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5347 parser.add_argument('--include-system-libs', action='store_true', help='include system libraries (i.e., those not downloaded from URLs)')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5348 parser.add_argument('extras', nargs=REMAINDER, help='extra files and directories to add to archive', metavar='files...')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5349 args = parser.parse_args(args)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5350
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5351 def createArchive(addMethod):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5352 entries = {}
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5353 def add(path, arcname):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5354 apath = os.path.abspath(path)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5355 if not entries.has_key(arcname):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5356 entries[arcname] = apath
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5357 logv('[adding ' + path + ']')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5358 addMethod(path, arcname=arcname)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5359 elif entries[arcname] != apath:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5360 logv('[warning: ' + apath + ' collides with ' + entries[arcname] + ' as ' + arcname + ']')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5361 else:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5362 logv('[already added ' + path + ']')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5363
15355
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5364 libsToExport = set()
15364
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5365 if args.include_all:
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5366 for lib in _libs.itervalues():
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5367 libsToExport.add(lib)
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5368 else:
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5369 def isValidLibrary(dep):
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5370 if dep in _libs.iterkeys():
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5371 lib = _libs[dep]
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5372 if len(lib.urls) != 0 or args.include_system_libs:
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5373 return lib
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5374 return None
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5375
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5376 # iterate over all project dependencies and find used libraries
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5377 for p in _projects.itervalues():
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5378 for dep in p.deps:
15355
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5379 r = isValidLibrary(dep)
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5380 if r:
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5381 libsToExport.add(r)
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5382
15364
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5383 # a library can have other libraries as dependency
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5384 size = 0
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5385 while size != len(libsToExport):
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5386 size = len(libsToExport)
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5387 for lib in libsToExport.copy():
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5388 for dep in lib.deps:
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5389 r = isValidLibrary(dep)
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5390 if r:
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5391 libsToExport.add(r)
9693513ce95c mx exportlibs: add option to include all defined libaries
Bernhard Urban <bernhard.urban@jku.at>
parents: 15362
diff changeset
5392
15355
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5393 for lib in libsToExport:
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5394 add(lib.get_path(resolve=True), lib.path)
15356
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5395 if lib.sha1:
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5396 add(lib.get_path(resolve=True) + ".sha1", lib.path + ".sha1")
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5397 if lib.sourcePath:
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5398 add(lib.get_source_path(resolve=True), lib.sourcePath)
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5399 if lib.sourceSha1:
9e7f87dc6395 mx exportlibs: include source dependencies and digest files
Bernhard Urban <bernhard.urban@jku.at>
parents: 15355
diff changeset
5400 add(lib.get_source_path(resolve=True) + ".sha1", lib.sourcePath + ".sha1")
15355
43aa6a7e60bd mx exportlibs: include libs only if there's a real dependency from a project
Bernhard Urban <bernhard.urban@jku.at>
parents: 15274
diff changeset
5401
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5402 if args.extras:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5403 for e in args.extras:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5404 if os.path.isdir(e):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5405 for root, _, filenames in os.walk(e):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5406 for name in filenames:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5407 f = join(root, name)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5408 add(f, f)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5409 else:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5410 add(e, e)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5411
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5412 if args.arc == 'zip':
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5413 path = args.base + '.zip'
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5414 with zipfile.ZipFile(path, 'w') as zf:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5415 createArchive(zf.write)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5416 else:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5417 path = args.base + '.tar'
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5418 mode = 'w'
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5419 if args.arc != 'tar':
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5420 sfx = args.arc[1:]
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5421 mode = mode + ':' + sfx
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5422 path = path + '.' + sfx
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5423 with tarfile.open(path, mode) as tar:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5424 createArchive(tar.add)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5425 log('created ' + path)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5426
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5427 def digest(enabled, path, factory, suffix):
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5428 if enabled:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5429 d = factory()
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5430 with open(path, 'rb') as f:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5431 while True:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5432 buf = f.read(4096)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5433 if not buf:
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5434 break
15122
11a591a99515 mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents: 15118
diff changeset
5435 d.update(buf)
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5436 with open(path + '.' + suffix, 'w') as fp:
15122
11a591a99515 mx: fixed bug in exportlibs
Doug Simon <doug.simon@oracle.com>
parents: 15118
diff changeset
5437 print >> fp, d.hexdigest()
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5438 log('created ' + path + '.' + suffix)
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5439
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5440 digest(args.sha1, path, hashlib.sha1, 'sha1')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5441 digest(args.md5, path, hashlib.md5, 'md5')
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5442
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5443 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
5444 """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
5445
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5446 javapExe = java().javap
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5447 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
5448 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
5449 else:
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5450 candidates = findclass(args, logToConsole=False)
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5451 if len(candidates) == 0:
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5452 log('no matches')
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
5453 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
5454 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
5455
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5456 def show_projects(args):
17184
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5457 """show all projects"""
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5458 for s in suites():
17163
30dda118ef3d mx: added support for extending distributions; require list literals for list attributes in projects.py
Doug Simon <doug.simon@oracle.com>
parents: 17159
diff changeset
5459 if len(s.projects) != 0:
17184
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5460 log(join(s.mxDir, 'suite*.py'))
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5461 for p in s.projects:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5462 log('\t' + p.name)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
5463
17184
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5464 def show_suites(args):
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5465 """show all suites"""
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5466 def _show_section(name, section):
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5467 if len(section) != 0:
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5468 log(' ' + name + ':')
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5469 for e in section:
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5470 log(' ' + e.name)
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5471
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5472 for s in suites():
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5473 log(join(s.mxDir, 'suite*.py'))
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5474 _show_section('libraries', s.libs)
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5475 _show_section('jrelibraries', s.jreLibs)
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5476 _show_section('projects', s.projects)
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5477 _show_section('distributions', s.dists)
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5478
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21522
diff changeset
5479 def _compile_mx_class(javaClassName, classpath=None, jdk=None, myDir=None):
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21522
diff changeset
5480 myDir = dirname(__file__) if myDir is None else myDir
21472
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5481 binDir = join(myDir, 'bin' if not jdk else '.jdk' + str(jdk.version))
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5482 javaSource = join(myDir, javaClassName + '.java')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5483 javaClass = join(binDir, javaClassName + '.class')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5484 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5485 if not exists(binDir):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5486 os.mkdir(binDir)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5487 javac = jdk.javac if jdk else java().javac
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5488 cmd = [javac, '-d', _cygpathU2W(binDir)]
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5489 if classpath:
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5490 cmd += ['-cp', _separatedCygpathU2W(binDir + os.pathsep + classpath)]
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5491 cmd += [_cygpathU2W(javaSource)]
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5492 try:
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5493 subprocess.check_call(cmd)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5494 except subprocess.CalledProcessError:
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5495 abort('failed to compile:' + javaSource)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5496
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5497 return (myDir, binDir)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5498
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5499 def checkcopyrights(args):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5500 '''run copyright check on the sources'''
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5501 class CP(ArgumentParser):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5502 def format_help(self):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5503 return ArgumentParser.format_help(self) + self._get_program_help()
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5504
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5505 def _get_program_help(self):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5506 help_output = subprocess.check_output([java().java, '-cp', _cygpathU2W(binDir), 'CheckCopyright', '--help'])
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5507 return '\nother argumemnts preceded with --\n' + help_output
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5508
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5509 myDir, binDir = _compile_mx_class('CheckCopyright')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5510
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5511 parser = CP(prog='mx checkcopyrights')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5512
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5513 parser.add_argument('--primary', action='store_true', help='limit checks to primary suite')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5514 parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5515 args = parser.parse_args(args)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5516 remove_doubledash(args.remainder)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5517
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5518
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5519 # ensure compiled form of code is up to date
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5520
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5521 result = 0
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5522 # copyright checking is suite specific as each suite may have different overrides
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5523 for s in suites(True):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5524 if args.primary and not s.primary:
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5525 continue
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5526 custom_copyrights = _cygpathU2W(join(s.mxDir, 'copyrights'))
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5527 custom_args = []
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5528 if exists(custom_copyrights):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5529 custom_args = ['--custom-copyright-dir', custom_copyrights]
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5530 rc = run([java().java, '-cp', _cygpathU2W(binDir), 'CheckCopyright', '--copyright-dir', _cygpathU2W(myDir)] + custom_args + args.remainder, cwd=s.dir, nonZeroIsFatal=False)
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5531 result = result if rc == 0 else rc
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5532 return result
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5533
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5534 def remove_doubledash(args):
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5535 if '--' in args:
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5536 args.remove('--')
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5537
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5538 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
5539 """"""
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5540 assert not default or default == 'y' or default == 'n'
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
5541 if not is_interactive():
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5542 if default:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5543 return default
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5544 else:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5545 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
5546 questionMark = '? [yn]: '
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5547 if default:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5548 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
5549 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
5550 while not answer:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5551 answer = raw_input(question + questionMark)
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
5552 return answer.lower().startswith('y')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5553
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5554 def add_argument(*args, **kwargs):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5555 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5556 Define how a single command-line argument.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5557 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5558 assert _argParser is not None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5559 _argParser.add_argument(*args, **kwargs)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5560
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
5561 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
5562 for key, value in new_commands.iteritems():
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5563 if _commands.has_key(key):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5564 warn("redefining command '" + key + "' in suite " + suite.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5565 _commands[key] = value
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5566
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5567 def warn(msg):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5568 if _warn:
13968
6c6d1eacc398 mxtool: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
5569 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
5570
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5571 # Table of commands in alphabetical order.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5572 # 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
5573 # 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
5574 # used in the call to str.format().
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5575 # 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
5576 _commands = {
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5577 'about': [about, ''],
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
5578 'build': [build, '[options]'],
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
5579 'checkstyle': [checkstyle, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5580 'canonicalizeprojects': [canonicalizeprojects, ''],
21472
c190ed6b84bf added checkcopyrights command (from mxtool2)
Doug Simon <doug.simon@oracle.com>
parents: 21428
diff changeset
5581 'checkcopyrights': [checkcopyrights, '[options]'],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5582 'clean': [clean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
5583 '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
5584 'eclipseformat': [eclipseformat, ''],
15087
f3e74d317e83 mx: added exportlibs command
Doug Simon <doug.simon@oracle.com>
parents: 15060
diff changeset
5585 'exportlibs': [exportlibs, ''],
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
5586 '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
5587 'fsckprojects': [fsckprojects, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5588 '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
5589 'ideclean': [ideclean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
5590 'ideinit': [ideinit, ''],
15060
858d2b91c1f8 Add a prototype for mx intellijinit
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14964
diff changeset
5591 'intellijinit': [intellijinit, ''],
15818
718034423138 mxtool: fix archive subcommand such that it will return a successful returncode
Bernhard Urban <bernhard.urban@jku.at>
parents: 15786
diff changeset
5592 'archive': [_archive, '[options]'],
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
5593 'projectgraph': [projectgraph, ''],
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
5594 '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
5595 '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
5596 'javadoc': [javadoc, '[options]'],
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
5597 'site': [site, '[options]'],
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
5598 'netbeansinit': [netbeansinit, ''],
17184
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5599 'suites': [show_suites, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5600 'projects': [show_projects, ''],
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5601 }
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5602
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5603 _argParser = ArgParser()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5604
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5605 def _suitename(mxDir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5606 base = os.path.basename(mxDir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5607 parts = base.split('.')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5608 # temporary workaround until mx.graal exists
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5609 if len(parts) == 1:
21953
969ae2657b92 Renaming the suite to truffle
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21880
diff changeset
5610 return 'truffle'
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5611 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5612 return parts[1]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5613
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5614 def _is_suite_dir(d, mxDirName=None):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5615 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5616 Checks if d contains a suite.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5617 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
5618 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5619 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
5620 for f in os.listdir(d):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5621 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
5622 mxDir = join(d, f)
17184
1cc8b62b4d37 mx: added 'suites' command
Doug Simon <doug.simon@oracle.com>
parents: 17183
diff changeset
5623 if exists(mxDir) and isdir(mxDir) and (exists(join(mxDir, 'suite.py'))):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5624 return mxDir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5625
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5626 def _check_primary_suite():
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5627 if _primary_suite is None:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5628 abort('no primary suite found')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5629 else:
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5630 return _primary_suite
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5631
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5632 def _findPrimarySuiteMxDirFrom(d):
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5633 """ 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
5634 while d:
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5635 mxDir = _is_suite_dir(d)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5636 if mxDir is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5637 return mxDir
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5638 parent = dirname(d)
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5639 if d == parent:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5640 return None
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5641 d = parent
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5642
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5643 return None
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
5644
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5645 def _findPrimarySuiteMxDir():
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5646 # check for explicit setting
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5647 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
5648 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
5649 if mxDir is not None:
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5650 return mxDir
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5651 else:
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5652 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
5653
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5654 # try current working directory first
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5655 mxDir = _findPrimarySuiteMxDirFrom(os.getcwd())
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5656 if mxDir is not None:
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5657 return mxDir
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5658 # 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
5659 return _findPrimarySuiteMxDirFrom(dirname(__file__))
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5660
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
5661 def main():
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5662 primarySuiteMxDir = _findPrimarySuiteMxDir()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
5663 if primarySuiteMxDir:
12522
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5664 global _primary_suite
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5665 _primary_suite = _loadSuite(primarySuiteMxDir, True)
5ccee20550ea mxtool: fixes (GRAAL-557) and code cleanups
Mick Jordan <mick.jordan@oracle.com>
parents: 12521
diff changeset
5666 else:
13855
bc32c9f5719b remove multiple suite/repo support
Mick Jordan <mick.jordan@oracle.com>
parents: 13853
diff changeset
5667 abort('no primary suite found')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5668
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5669 opts, commandAndArgs = _argParser._parse_cmd_line()
18636
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
5670 assert _opts == opts
dcf5cd3c6da9 mx: fixed issue with calling abort() before _opts is defined
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
5671
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
5672 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
5673 s._post_init(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5674
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5675 if len(commandAndArgs) == 0:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5676 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5677 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5678
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5679 command = commandAndArgs[0]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5680 command_args = commandAndArgs[1:]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
5681
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5682 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
5683 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
5684 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
5685 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
5686 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
5687 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
5688 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
5689 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
5690
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
5691 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
5692 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
5693 abort(1)
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
5694 if not is_jython():
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
5695 signal.signal(signal.SIGTERM, term_handler)
14134
e71d421370f3 mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents: 14133
diff changeset
5696
14135
ee66410c0679 mx: add option to send sigquit before killing child
Bernhard Urban <bernhard.urban@jku.at>
parents: 14134
diff changeset
5697 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
5698 _send_sigquit()
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18868
diff changeset
5699 if not is_jython() and get_os() != 'windows':
14153
e328f28f7401 fix for mx, did not compile on Windows
Christian Wirth <christian.wirth@oracle.com>
parents: 14136
diff changeset
5700 signal.signal(signal.SIGQUIT, quit_handler)
14134
e71d421370f3 mx: proxy SIGQUIT to child process
Bernhard Urban <bernhard.urban@jku.at>
parents: 14133
diff changeset
5701
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5702 try:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
5703 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
5704 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
5705 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
5706 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
5707 signal.alarm(opts.timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5708 retcode = c(command_args)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5709 if retcode is not None and retcode != 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5710 abort(retcode)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5711 except KeyboardInterrupt:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5712 # 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
5713 abort(1)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5714
13471
020099961eb4 renamed JavaVersion to VersionSpec
Doug Simon <doug.simon@oracle.com>
parents: 13470
diff changeset
5715 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
5716
14103
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
5717 currentUmask = None
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
5718
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5719 if __name__ == '__main__':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5720 # 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
5721 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
5722
14103
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
5723 # 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
5724 currentUmask = os.umask(0)
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
5725 os.umask(currentUmask)
9d8aaa3200a3 make mx respect umask when making jar files
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13982
diff changeset
5726
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
5727 main()