Mercurial > hg > truffle
annotate mxtool/mx.py @ 4477:27c5466afd55
Changes to debug framework.
Intercept not only RuntimeException but Throwable.
Support for named IGV groups through new DebugDumpScope. Printer bugfix.
Open scope with method context in VMToCompilerImpl (was in GraalCompiler).
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 07 Feb 2012 12:35:22 +0100 |
parents | 4023bae16d02 |
children | 7903b6c28f9c |
rev | line source |
---|---|
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 # ---------------------------------------------------------------------------------------------------- |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 # |
4186
71a2cd79c375
Made stdout for mx unbuffered.
Doug Simon <doug.simon@oracle.com>
parents:
4180
diff
changeset
|
5 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 # This code is free software; you can redistribute it and/or modify it |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 # under the terms of the GNU General Public License version 2 only, as |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 # published by the Free Software Foundation. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 # This code is distributed in the hope that it will be useful, but WITHOUT |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 # version 2 for more details (a copy is included in the LICENSE file that |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 # accompanied this code). |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License version |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 # 2 along with this work; if not, write to the Free Software Foundation, |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 # or visit www.oracle.com if you need additional information or have any |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 # questions. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 # ---------------------------------------------------------------------------------------------------- |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 # mx is a command line tool inspired by mvn (http://maven.apache.org/) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 # and hg (http://mercurial.selenic.com/). It includes a mechanism for |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 # managing the dependencies between a set of projects (like Maven) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 # as well as making it simple to run commands |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 # (like hg is the interface to the Mercurial commands). |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 # |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
34 # The organizing principle of mx is a project suite. A suite is a directory |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
35 # containing one or more projects. It's not coincidental that this closely |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
36 # matches the layout of one or more projects in a Mercurial repository. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
37 # The configuration information for a suite lives in an 'mx' sub-directory |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
38 # at the top level of the suite. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 # |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
40 # When launched, mx treats the current working directory as a suite. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
41 # This is the primary suite. All other suites are called included suites. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
42 # |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
43 # The configuration files (i.e. in the 'mx' sub-directory) of a suite are: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 # |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
45 # projects - Defines the projects and libraries in the suite and the dependencies between them |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
46 # commands.py - Suite specific extensions to the commands available to mx. This is only processed |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
47 # for the primary suite. |
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
|
48 # includes - Other suites to be loaded. This is recursive. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 # env - A set of environment variable definitions. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 # The includes and env files are typically not put under version control |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
52 # as they usually contain local file-system paths. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 # The projects file is like the pom.xml file from Maven except that |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
55 # it is a properties file (not XML). Each non-comment line |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 # in the file specifies an attribute of a project or library. The main |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 # difference between a project and a library is that the former contains |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 # source code built by the mx tool where as the latter is an external |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 # dependency. The format of the projects file is |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 # Library specification format: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 # library@<name>@<prop>=<value> |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 # Built-in library properties (* = required): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 # *path: the file system path for the library to appear on a class path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 # urls: a comma seperated list of URLs from which the library can be downloaded |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 # optional: if "true" then this library will be omitted from a class path if it doesn't exist on the file system and no URLs are specified |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 # Project specification format: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 # project@<name>@<prop>=<value> |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 # The name of a project also denotes the directory it is in. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 # Built-in project properties: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 # *sourceDirs: a comma separated list of source directoriy names (relative to the project directory) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 # dependencies: a comma separated list of the libraries and project the project depends upon (transitive dependencies may be omitted) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 # checkstyle: the project whose Checkstyle configuration (i.e. <project>/.checkstyle_checks.xml) is used |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 # Other properties can be specified for projects and libraries for use by extension commands. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 # Values can use environment variables with Bash syntax (e.g. ${HOME}). |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 |
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
|
87 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
88 import shutil, fnmatch, re, xml.dom.minidom |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 from collections import Callable |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 from threading import Thread |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 from argparse import ArgumentParser, REMAINDER |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
92 from os.path import join, 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
|
93 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 DEFAULT_JAVA_ARGS = '-ea -Xss2m -Xmx1g' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
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() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
98 _suites = dict() |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
99 _mainSuite = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
100 _opts = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
101 _java = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
102 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
103 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
104 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
|
105 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 class Dependency: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
107 def __init__(self, suite, name): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 self.name = name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
109 self.suite = suite |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 def __str__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 return self.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 def __eq__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 return self.name == other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 def __ne__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 return self.name != other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 def __hash__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 return hash(self.name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 def isLibrary(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 return isinstance(self, Library) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 class Project(Dependency): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
127 def __init__(self, suite, name, srcDirs, deps, dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
128 Dependency.__init__(self, suite, name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 self.srcDirs = srcDirs |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 self.deps = deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 self.checkstyleProj = name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 self.native = False |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
133 self.dir = dir |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
135 def all_deps(self, deps, includeLibs, includeSelf=True): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
136 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
137 Add the transitive set of dependencies for this project, including |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
138 libraries if 'includeLibs' is true, to the 'deps' list. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
139 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 if self in deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 return deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 for name in self.deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 assert name != self.name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
144 dep = _libs.get(name, None) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 if dep is not None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 if includeLibs and not dep in deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 deps.append(dep) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
149 dep = project(name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 if not dep in deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
151 dep.all_deps(deps, includeLibs) |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
152 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
|
153 deps.append(self) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 return deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
156 def _compute_max_dep_distances(self, name, distances, dist): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 currentDist = distances.get(name); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 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
|
159 distances[name] = dist |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
160 p = project(name, False) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
161 if p is not None: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 for dep in p.deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
163 self._compute_max_dep_distances(dep, distances, dist + 1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
165 def canonical_deps(self): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
166 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
167 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
|
168 via other dependencies). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
169 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 distances = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 result = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
172 self._compute_max_dep_distances(self.name, distances, 0) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 for n,d in distances.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 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
|
175 if d == 1: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 result.add(n) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 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
|
180 return self.deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 return result; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 def source_dirs(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
185 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
186 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
|
187 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
188 return [join(self.dir, s) for s in self.srcDirs] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 def output_dir(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
191 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
192 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
|
193 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
194 if self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
195 return None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
196 return join(self.dir, 'bin') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
198 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
199 if not self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
200 cp.append(self.output_dir()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 class Library(Dependency): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
203 def __init__(self, suite, name, path, mustExist, urls): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
204 Dependency.__init__(self, suite, name) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
205 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
|
206 self.urls = urls |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 self.mustExist = mustExist |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
209 def get_path(self, resolve): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 path = self.path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 if not isabs(path): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
212 path = join(self.suite.dir, path) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 if resolve and self.mustExist and not exists(path): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + " " + path; |
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
|
215 print('Downloading ' + self.name + ' from ' + str(self.urls)) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
216 download(path, self.urls) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
217 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
218 return path |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
219 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
220 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
221 path = self.get_path(resolve) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
222 if exists(path) or not resolve: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
223 cp.append(path) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
224 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
225 class Suite: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
226 def __init__(self, dir, primary): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
227 self.dir = dir |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
228 self.projects = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
229 self.libs = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
230 self.includes = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
231 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
|
232 self.primary = primary |
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
|
233 mxDir = join(dir, 'mx') |
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
|
234 self._load_env(mxDir) |
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
|
235 if primary: |
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
|
236 self._load_commands(mxDir) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
238 def _load_projects(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
239 libsMap = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 projsMap = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 projectsFile = join(mxDir, 'projects') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 with open(projectsFile) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
246 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 if len(line) != 0 and line[0] != '#': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 key, value = line.split('=', 1) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 parts = key.split('@') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
251 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
252 if len(parts) == 2: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
253 pass |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
254 if len(parts) != 3: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
255 abort('Property name does not have 3 parts separated by "@": ' + key) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
256 kind, name, attr = parts |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 if kind == 'project': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 m = projsMap |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 elif kind == 'library': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
260 m = libsMap |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
261 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
262 abort('Property name does not start with "project@" or "library@": ' + key) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
263 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
264 attrs = m.get(name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
265 if attrs is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
266 attrs = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
267 m[name] = attrs |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
268 value = expandvars_in_property(value) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
269 attrs[attr] = value |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
270 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
271 def pop_list(attrs, name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
272 v = attrs.pop(name, None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
273 if v is None or len(v.strip()) == 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
274 return [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
275 return [n.strip() for n in v.split(',')] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
276 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
277 for name, attrs in projsMap.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
278 srcDirs = pop_list(attrs, 'sourceDirs') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
279 deps = pop_list(attrs, 'dependencies') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
280 subDir = attrs.pop('subDir', None); |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
281 if subDir is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
282 dir = join(self.dir, name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
283 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
284 dir = join(self.dir, subDir, name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
285 p = Project(self, name, srcDirs, deps, dir) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
286 p.checkstyleProj = attrs.pop('checkstyle', name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
287 p.native = attrs.pop('native', '') == 'true' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
288 p.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
289 self.projects.append(p) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
290 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 for name, attrs in libsMap.iteritems(): |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
292 path = attrs.pop('path') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
293 mustExist = attrs.pop('optional', 'false') != 'true' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
294 urls = pop_list(attrs, 'urls') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
295 l = Library(self, name, path, mustExist, urls) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
296 l.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
297 self.libs.append(l) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
299 def _load_commands(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
300 commands = join(mxDir, 'commands.py') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
301 if exists(commands): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 # temporarily extend the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 sys.path.insert(0, mxDir) |
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 mod = __import__('commands') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
306 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
307 # revert the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
308 del sys.path[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
309 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
310 if not hasattr(mod, 'mx_init'): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
311 abort(commands + ' must define an mx_init(env) 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
|
312 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
|
313 self.mx_post_parse_cmd_line = mod.mx_post_parse_cmd_line |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
314 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
315 mod.mx_init() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
316 self.commands = mod |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
317 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
318 def _load_includes(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 includes = join(mxDir, 'includes') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
320 if exists(includes): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
321 with open(includes) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
322 for line in f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
323 self.includes.append(expandvars_in_property(line.strip())) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
324 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
325 def _load_env(self, mxDir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
326 e = join(mxDir, 'env') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
327 if exists(e): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
328 with open(e) as f: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
329 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
330 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
331 if len(line) != 0 and line[0] != '#': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
332 key, value = line.split('=', 1) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
333 os.environ[key.strip()] = expandvars_in_property(value.strip()) |
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
|
334 |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
335 def _post_init(self, opts): |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
336 mxDir = join(self.dir, 'mx') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
337 self._load_includes(mxDir) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
338 self._load_projects(mxDir) |
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
|
339 if self.mx_post_parse_cmd_line is not None: |
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
|
340 self.mx_post_parse_cmd_line(opts) |
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
|
341 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
|
342 existing = _projects.get(p.name) |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
343 if existing is not None: |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
344 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir) |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
345 _projects[p.name] = p |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
346 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
|
347 existing = _libs.get(l.name) |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
348 if existing is not None: |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
349 abort('cannot redefine library ' + l.name) |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
350 _libs[l.name] = l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
351 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
352 def get_os(): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
353 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
354 Get a canonical form of sys.platform. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
355 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
356 if sys.platform.startswith('darwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
357 return 'darwin' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
358 elif sys.platform.startswith('linux'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
359 return 'linux' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
360 elif sys.platform.startswith('sunos'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
361 return 'solaris' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
362 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
363 return 'windows' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
364 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
365 abort('Unknown operating system ' + sys.platform) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
366 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
367 def _loadSuite(dir, primary=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
368 mxDir = join(dir, 'mx') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
369 if not exists(mxDir) or not isdir(mxDir): |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
370 return None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
371 if not _suites.has_key(dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
372 suite = Suite(dir, primary) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
373 _suites[dir] = suite |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
374 return suite |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
375 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
376 def suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
377 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
378 Get the list of all loaded suites. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
379 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
380 return _suites.values() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
381 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
382 def projects(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
383 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
384 Get the list of all loaded projects. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
385 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
386 return _projects.values() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
387 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
388 def project(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
389 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
390 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
|
391 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
392 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
393 p = _projects.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
394 if p is None and fatalIfMissing: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
395 abort('project named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
396 return p |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
397 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
398 def library(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
399 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
400 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
|
401 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
402 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
403 l = _libs.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
404 if l is None and fatalIfMissing: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
405 abort('library named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
406 return l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
407 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
408 def _as_classpath(deps, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
409 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
410 if _opts.cp_prefix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
411 cp = [_opts.cp_prefix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
412 for d in deps: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
413 d.append_to_classpath(cp, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
414 if _opts.cp_suffix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
415 cp += [_opts.cp_suffix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
416 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
417 |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
418 def classpath(names=None, resolve=True, includeSelf=True): |
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 Get the class path for a list of given projects, resolving each entry in the |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
421 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
|
422 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
423 if names is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
424 return _as_classpath(sorted_deps(True), resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
425 deps = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
426 if isinstance(names, types.StringTypes): |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
427 project(names).all_deps(deps, True, includeSelf) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
428 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
429 for n in names: |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
430 project(n).all_deps(deps, True, includeSelf) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
431 return _as_classpath(deps, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
432 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
433 def sorted_deps(includeLibs=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
434 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
435 Gets the loaded projects and libraries sorted such that dependencies |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
436 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
|
437 true, libraries are omitted from the result. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
438 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
439 deps = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
440 for p in _projects.itervalues(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
441 p.all_deps(deps, includeLibs) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
442 return deps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
443 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
444 class ArgParser(ArgumentParser): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
445 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
446 # 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
|
447 def format_help(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
448 return ArgumentParser.format_help(self) + _format_commands() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
449 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
450 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
451 def __init__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
452 self.java_initialized = False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
453 ArgumentParser.__init__(self, prog='mx') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
454 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
455 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
456 self.add_argument('-d', action='store_true', dest='java_dbg', help='make Java processes wait on port 8000 for a debugger') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
457 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
|
458 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
459 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default=DEFAULT_JAVA_ARGS) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
460 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
|
461 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
|
462 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
463 self.add_argument('--java-home', help='JDK installation directory (must be JDK 6 or later)', metavar='<path>') |
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
|
464 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
|
465 # Time outs are (currently) implemented with Unix specific functionality |
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
|
466 self.add_argument('--timeout', help='Timeout (in seconds) for command', type=int, default=0, metavar='<secs>') |
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
|
467 self.add_argument('--ptimeout', help='Timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') |
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
|
468 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
469 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
|
470 if args is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
471 args = sys.argv[1:] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
472 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
473 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
474 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
475 opts = self.parse_args() |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
476 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
477 # 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
|
478 opts.__dict__.setdefault('timeout', 0) |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
479 opts.__dict__.setdefault('ptimeout', 0) |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
480 |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
481 if opts.java_home is None: |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
482 opts.java_home = os.environ.get('JAVA_HOME') |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
483 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
484 if opts.java_home is None or opts.java_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
485 abort('Could not find Java home. Use --java-home option or ensure JAVA_HOME environment variable is set.') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
486 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
487 if opts.user_home is None or opts.user_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
488 abort('Could not find user home. Use --user-home option or ensure HOME environment variable is set.') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
489 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
490 os.environ['JAVA_HOME'] = opts.java_home |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
491 os.environ['HOME'] = opts.user_home |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
492 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
493 commandAndArgs = opts.__dict__.pop('commandAndArgs') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
494 return opts, commandAndArgs |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
495 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
496 def _format_commands(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
497 msg = '\navailable commands:\n\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
498 for cmd in sorted(commands.iterkeys()): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
499 c, _ = commands[cmd][:2] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
500 doc = c.__doc__ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
501 if doc is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
502 doc = '' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
503 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
|
504 return msg + '\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
505 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
506 def java(): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
507 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
508 Get a JavaConfig object containing Java commands launch details. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
509 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
510 assert _java is not None |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
511 return _java |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
512 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
513 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None): |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
514 return run(java().format_cmd(args), 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
|
515 |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
516 def _kill_process_group(pid): |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
517 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
|
518 try: |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
519 os.killpg(pgid, signal.SIGKILL) |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
520 return True |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
521 except: |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
522 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
|
523 return False |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
524 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
525 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
|
526 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
|
527 while True: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
528 try: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 continue |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
533 raise |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
534 |
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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 # 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
|
542 raise RuntimeError("Unknown child exit 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
|
543 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
544 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
|
545 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
|
546 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
|
547 (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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
556 # Makes the current subprocess accessible to the abort() function |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
557 # This is a tuple of the Popen object and args. |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
558 _currentSubprocess = None |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
559 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
560 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
561 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
562 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
|
563 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
|
564 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
|
565 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
|
566 out and err if they are callable objects. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
567 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
568 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
569 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
|
570 for arg in args: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
571 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
572 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
573 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
574 log(' '.join(args)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
575 |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
576 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
|
577 timeout = _opts.ptimeout |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
578 |
4293
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
579 global _currentSubprocess |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
580 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
581 try: |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
582 # 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
|
583 # 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
|
584 preexec_fn = None |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
585 creationflags = 0 |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
586 if get_os() == 'windows': |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
587 creationflags = subprocess.CREATE_NEW_PROCESS_GROUP |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
588 else: |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
589 preexec_fn = os.setsid |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
590 |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
591 if not callable(out) and not callable(err) and timeout is None: |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
592 # The preexec_fn=os.setsid |
4252
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
593 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags) |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
594 _currentSubprocess = (p, args) |
4396
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
595 if get_os() == 'windows': |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
596 # on windows use a poll loop, otherwise signal does not get handled |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
597 retcode = None |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
598 while retcode == None: |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
599 retcode = p.poll() |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
600 time.sleep(0.05) |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
601 else: |
4023bae16d02
Make mx script killable on Windows. renamed mx.bat to mx.cmd.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
602 retcode = p.wait() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
603 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
604 def redirect(stream, f): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
605 for line in iter(stream.readline, ''): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
606 f(line) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
607 stream.close() |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
608 stdout=out if not callable(out) else subprocess.PIPE |
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
609 stderr=err if not callable(err) else subprocess.PIPE |
4252
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
610 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
611 _currentSubprocess = (p, args) |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
612 if callable(out): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
613 t = Thread(target=redirect, args=(p.stdout, out)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
614 t.daemon = True # thread dies with the program |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
615 t.start() |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
616 if callable(err): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
617 t = Thread(target=redirect, args=(p.stderr, err)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
618 t.daemon = True # thread dies with the program |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
619 t.start() |
4161
8c507a8dd6a4
Interpret '--timeout 0' correctly (i.e. as no timeout).
Doug Simon <doug.simon@oracle.com>
parents:
4158
diff
changeset
|
620 if timeout is None or timeout == 0: |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
621 retcode = p.wait() |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
622 else: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
623 if get_os() == 'windows': |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
624 abort('Use of timeout not (yet) supported on Windows') |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
625 retcode = _waitWithTimeout(p, args, timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
626 except OSError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
627 log('Error executing \'' + ' '.join(args) + '\': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
628 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
629 raise e |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
630 abort(e.errno) |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
631 except KeyboardInterrupt: |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
632 abort(1) |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
633 finally: |
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
634 _currentSubprocess = None |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
635 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
636 if retcode and nonZeroIsFatal: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
637 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
638 raise subprocess.CalledProcessError(retcode, ' '.join(args)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
639 abort(retcode) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
640 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
641 return retcode |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
642 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
643 def exe_suffix(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
644 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
645 Gets the platform specific suffix for an executable |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
646 """ |
4258
8d2c14f722ac
mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents:
4257
diff
changeset
|
647 if get_os() == 'windows': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
648 return name + '.exe' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
649 return name |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
650 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
651 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
652 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
|
653 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
654 class JavaConfig: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
655 def __init__(self, opts): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
656 self.jdk = opts.java_home |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
657 self.debug = opts.java_dbg |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
658 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
659 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
660 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap')) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
661 |
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
|
662 if not exists(self.java): |
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
|
663 abort('Java launcher derived from JAVA_HOME does not exist: ' + self.java) |
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
|
664 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
665 def delAtAndSplit(s): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
666 return shlex.split(s.lstrip('@')) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
667 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
668 self.java_args = delAtAndSplit(_opts.java_args) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
669 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
|
670 self.java_args_sfx = sum(map(delAtAndSplit, _opts.java_args_sfx), []) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
671 |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
672 # 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
|
673 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
674 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
|
675 self.java_args = ['-d64'] + self.java_args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
676 except subprocess.CalledProcessError as e: |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
677 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
678 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
|
679 except subprocess.CalledProcessError as e: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
680 print e.output |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
681 abort(e.returncode) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
682 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
683 output = output.split() |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
684 assert output[1] == 'version' |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
685 self.version = output[2].strip('"') |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
686 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
687 if self.debug: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
688 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
689 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
690 def format_cmd(self, args): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
691 return [self.java] + self.java_args_pfx + self.java_args + self.java_args_sfx + args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
692 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
693 def check_get_env(key): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
694 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
695 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
|
696 """ |
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
|
697 value = get_env(key) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
698 if value is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
699 abort('Required environment variable ' + key + ' must be set') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
700 return value |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
701 |
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
|
702 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
|
703 """ |
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
|
704 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
|
705 """ |
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
|
706 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
|
707 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
|
708 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
709 def log(msg=None): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
710 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
711 Write a message to the console. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
712 All script output goes through this method thus allowing a subclass |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
713 to redirect it. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
714 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
715 if msg is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
716 print |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
717 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
718 print msg |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
719 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
720 def expand_project_in_class_path_arg(cpArg): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
721 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
722 for part in cpArg.split(os.pathsep): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
723 if part.startswith('@'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
724 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
|
725 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
726 cp.append(part) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
727 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
728 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
729 def expand_project_in_args(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
730 for i in range(len(args)): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
731 if args[i] == '-cp' or args[i] == '-classpath': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
732 if i + 1 < len(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
733 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
|
734 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
735 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
736 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
737 def gmake_cmd(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
738 for a in ['make', 'gmake', 'gnumake']: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
739 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
740 output = subprocess.check_output([a, '--version']) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
741 if 'GNU' in output: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
742 return a; |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
743 except: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
744 pass |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
745 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
|
746 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
747 def expandvars_in_property(value): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
748 result = expandvars(value) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
749 if '$' in result or '%' in result: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
750 abort('Property contains an undefined environment variable: ' + value) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
751 return result |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
752 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
753 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
754 def abort(codeOrMessage): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
755 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
756 Aborts the program with a SystemExit exception. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
757 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
|
758 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
|
759 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
|
760 """ |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
761 |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
762 #import traceback |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
763 #traceback.print_stack() |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
764 currentSubprocess = _currentSubprocess |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
765 if currentSubprocess is not None: |
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
766 p, _ = currentSubprocess |
4252
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
767 if get_os() == 'windows': |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
768 p.kill() |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
769 else: |
67e88b7624d5
Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents:
4248
diff
changeset
|
770 _kill_process_group(p.pid) |
4242
3e25132be4b4
Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents:
4241
diff
changeset
|
771 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
772 raise SystemExit(codeOrMessage) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
773 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
774 def download(path, urls, verbose=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
775 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
776 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
|
777 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
|
778 is written to the file indicated by 'path'. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
779 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
780 d = dirname(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
781 if d != '' and not exists(d): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
782 os.makedirs(d) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
783 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
784 # Try it with the Java tool first since it can show a progress counter |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
785 myDir = dirname(__file__) |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
786 |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
787 javaSource = join(myDir, 'URLConnectionDownload.java') |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
788 javaClass = join(myDir, 'URLConnectionDownload.class') |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
789 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
790 subprocess.check_call([java().javac, '-d', myDir, javaSource]) |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
791 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls) == 0: |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
792 return |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
793 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
794 def url_open(url): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
795 userAgent = 'Mozilla/5.0 (compatible)' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
796 headers = { 'User-Agent' : userAgent } |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
797 req = urllib2.Request(url, headers=headers) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
798 return urllib2.urlopen(req); |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
799 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
800 for url in urls: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
801 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
802 if (verbose): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
803 log('Downloading ' + url + ' to ' + path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
804 if url.startswith('zip:') or url.startswith('jar:'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
805 i = url.find('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
806 if i == -1: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
807 abort('Zip or jar URL does not contain "!/": ' + url) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
808 url, _, entry = url[len('zip:'):].partition('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
809 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
810 data = f.read() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
811 zipdata = StringIO.StringIO(f.read()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
812 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
813 zf = zipfile.ZipFile(zipdata, 'r') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
814 data = zf.read(entry) |
4178
d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4161
diff
changeset
|
815 with open(path, 'wb') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
816 f.write(data) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
817 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
818 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
819 data = f.read() |
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
|
820 with open(path, 'wb') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
821 f.write(data) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
822 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
823 except IOError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
824 log('Error reading from ' + url + ': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
825 except zipfile.BadZipfile as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
826 log('Error in zip file downloaded from ' + url + ': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
827 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
828 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
|
829 '\n '.join(urls) + '\n\nPlease use a web browser to do the download manually') |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
830 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
831 def update_file(path, content): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
832 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
833 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
|
834 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
|
835 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
836 existed = exists(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
837 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
838 old = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
839 if existed: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
840 with open(path, 'rb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
841 old = f.read() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
842 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
843 if old == content: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
844 return False |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
845 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
846 with open(path, 'wb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
847 f.write(content) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
848 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
849 log(('modified ' if existed else 'created ') + path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
850 return True; |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
851 except IOError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
852 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
|
853 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
854 # Builtin commands |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
855 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
856 def build(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
857 """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
|
858 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
859 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
|
860 and linkers for the various source code types.""" |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
861 |
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
|
862 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
|
863 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
|
864 parser = ArgumentParser(prog='mx build') |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
865 |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
866 parser = parser if parser is not None else ArgumentParser(prog='mx build') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
867 parser.add_argument('-f', action='store_true', dest='force', help='force compilation even if class files are up to date') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
868 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
869 parser.add_argument('--source', dest='compliance', help='Java compliance level', default='1.6') |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
870 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
871 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
|
872 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
873 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='<path>') |
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
|
874 |
057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents:
4227
diff
changeset
|
875 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
|
876 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
|
877 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
878 args = parser.parse_args(args) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
879 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
880 jdtJar = None |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
881 if args.jdt is not None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
882 if args.jdt.endswith('.jar'): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
883 jdtJar=args.jdt |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
884 elif isdir(args.jdt): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
885 plugins = join(args.jdt, 'plugins') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
886 choices = [f for f in os.listdir(plugins) if fnmatch.fnmatch(f, 'org.eclipse.jdt.core_*.jar')] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
887 if len(choices) != 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
888 jdtJar = join(plugins, sorted(choices, reverse=True)[0]) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
889 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
890 built = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
891 for p in sorted_deps(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
892 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
893 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
894 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
895 log('Calling GNU make {0}...'.format(p.dir)) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
896 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
897 if args.clean: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
898 run([gmake_cmd(), 'clean'], cwd=p.dir) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
899 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
900 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
|
901 built.add(p.name) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
902 continue |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
903 else: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
904 if not args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
905 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
906 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
907 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
908 outputDir = p.output_dir() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
909 if exists(outputDir): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
910 if args.clean: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
911 log('Cleaning {0}...'.format(outputDir)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
912 shutil.rmtree(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
913 os.mkdir(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
914 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
915 os.mkdir(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
916 |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
917 cp = classpath(p.name, includeSelf=True) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
918 sourceDirs = p.source_dirs() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
919 mustBuild = args.force |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
920 if not mustBuild: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
921 for dep in p.all_deps([], False): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
922 if dep.name in built: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
923 mustBuild = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
924 |
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
|
925 javafilelist = [] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
926 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
927 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
|
928 javafiles = [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java'] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
929 javafilelist += javafiles |
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
|
930 |
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
|
931 # Copy all non Java resources |
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
|
932 nonjavafilelist = [join(root, name) for name in files if not name.endswith('.java')] |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
933 for src in nonjavafilelist: |
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
|
934 dst = join(outputDir, src[len(sourceDir) + 1:]) |
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
|
935 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) != os.path.getmtime(src)): |
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
|
936 shutil.copyfile(src, dst) |
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
|
937 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
938 if not mustBuild: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
939 for javafile in javafiles: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
940 classfile = outputDir + javafile[len(sourceDir):-len('java')] + 'class' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
941 if not exists(classfile) or os.path.getmtime(javafile) > os.path.getmtime(classfile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
942 mustBuild = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
943 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
944 |
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
|
945 if not mustBuild: |
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
|
946 log('[all class files for {0} are up to date - skipping]'.format(p.name)) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
947 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
948 |
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
|
949 if len(javafilelist) == 0: |
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
|
950 log('[no Java sources for {0} - skipping]'.format(p.name)) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
951 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
|
952 |
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
|
953 built.add(p.name) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
954 |
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
|
955 argfileName = join(p.dir, 'javafilelist.txt') |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
956 argfile = open(argfileName, 'wb') |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
957 argfile.write('\n'.join(javafilelist)) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
958 argfile.close() |
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
|
959 |
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
|
960 try: |
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
|
961 if jdtJar is None: |
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
|
962 log('Compiling Java sources for {0} with javac...'.format(p.name)) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
963 errFilt = None |
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
|
964 if not args.warnAPI: |
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
|
965 class Filter: |
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
|
966 """ |
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
|
967 Class to errFilt the 'is Sun proprietary API and may be removed in a future release' |
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
|
968 warning when compiling the VM classes. |
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
|
969 |
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
|
970 """ |
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
|
971 def __init__(self): |
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
|
972 self.c = 0 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
973 |
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
|
974 def eat(self, line): |
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
|
975 if 'proprietary API' in line: |
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
|
976 self.c = 2 |
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
|
977 elif self.c != 0: |
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
|
978 self.c -= 1 |
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
|
979 else: |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
980 log(line.rstrip()) |
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
|
981 errFilt=Filter().eat |
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
|
982 |
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
|
983 run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt) |
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
|
984 else: |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
985 log('Compiling Java sources for {0} with JDT...'.format(p.name)) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
986 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
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
|
987 if not exists(jdtProperties): |
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
|
988 raise SystemError('JDT properties file {0} not found'.format(jdtProperties)) |
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
|
989 run([java().java, '-Xmx1g', '-jar', jdtJar, |
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
|
990 '-properties', jdtProperties, |
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
|
991 '-' + args.compliance, |
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
|
992 '-cp', cp, '-g', |
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
|
993 '-warn:-unusedImport,-unchecked', |
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
|
994 '-d', outputDir, '@' + argfile.name]) |
3f6c6e61614e
Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents:
4242
diff
changeset
|
995 finally: |
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
|
996 os.remove(argfileName) |
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
|
997 |
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
|
998 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
|
999 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
|
1000 return None |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1001 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1002 def canonicalizeprojects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1003 """process all project files to canonicalize the dependencies |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1004 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1005 The exit code of this command reflects how many files were updated.""" |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1006 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1007 changedFiles = 0 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1008 for s in suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1009 projectsFile = join(s.dir, 'mx', 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1010 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1011 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1012 with open(projectsFile) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1013 out = StringIO.StringIO() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1014 pattern = re.compile('project@([^@]+)@dependencies=.*') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1015 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1016 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1017 m = pattern.match(line) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1018 if m is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1019 out.write(line + '\n') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1020 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1021 p = project(m.group(1)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1022 out.write('project@' + m.group(1) + '@dependencies=' + ','.join(p.canonical_deps()) + '\n') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1023 content = out.getvalue() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1024 if update_file(projectsFile, content): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1025 changedFiles += 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1026 return changedFiles; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1027 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1028 def checkstyle(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1029 """run Checkstyle on the Java sources |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1030 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1031 Run Checkstyle over the Java sources. Any errors or warnings |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1032 produced by Checkstyle result in a non-zero exit code. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1033 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1034 If no projects are given, then all Java projects are checked.""" |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1035 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1036 for p in sorted_deps(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1037 if p.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1038 continue |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1039 sourceDirs = p.source_dirs() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1040 dotCheckstyle = join(p.dir, '.checkstyle') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1041 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1042 if not exists(dotCheckstyle): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1043 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1044 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1045 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1046 javafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1047 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
|
1048 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
|
1049 if len(javafilelist) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1050 log('[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
|
1051 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1052 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1053 timestampFile = join(p.suite.dir, 'mx', '.checkstyle' + sourceDir[len(p.suite.dir):].replace(os.sep, '_') + '.timestamp') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1054 mustCheck = False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1055 if exists(timestampFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1056 timestamp = os.path.getmtime(timestampFile) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1057 for f in javafilelist: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1058 if os.path.getmtime(f) > timestamp: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1059 mustCheck = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1060 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1061 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1062 mustCheck = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1063 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1064 if not mustCheck: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1065 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
|
1066 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1067 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1068 if exists(timestampFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1069 os.utime(timestampFile, None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1070 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1071 file(timestampFile, 'a') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1072 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1073 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1074 localCheckConfig = dotCheckstyleXML.getElementsByTagName('local-check-config')[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1075 configLocation = localCheckConfig.getAttribute('location') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1076 configType = localCheckConfig.getAttribute('type') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1077 if configType == 'project': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1078 # Eclipse plugin "Project Relative Configuration" format: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1079 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1080 # '/<project_name>/<suffix>' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1081 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1082 if configLocation.startswith('/'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1083 name, _, suffix = configLocation.lstrip('/').partition('/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1084 config = join(project(name).dir, suffix) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1085 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1086 config = join(p.dir, configLocation) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1087 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1088 log('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1089 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1090 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1091 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
|
1092 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1093 if exists(exclude): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1094 with open(exclude) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1095 # Convert patterns to OS separators |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1096 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
|
1097 def match(name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1098 for p in patterns: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1099 if p in name: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1100 log('excluding: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1101 return True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1102 return False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1103 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1104 javafilelist = [name for name in javafilelist if not match(name)] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1105 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1106 auditfileName = join(p.dir, 'checkstyleOutput.txt') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1107 log('Running Checkstyle on {0} using {1}...'.format(sourceDir, config)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1108 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1109 try: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1110 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1111 # Checkstyle is unable to read the filenames to process from a file, and the |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1112 # CreateProcess function on Windows limits the length of a command line to |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1113 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1114 # so calling Checkstyle must be done in batches. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1115 while len(javafilelist) != 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1116 i = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1117 size = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1118 while i < len(javafilelist): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1119 s = len(javafilelist[i]) + 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1120 if (size + s < 30000): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1121 size += s |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1122 i += 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1123 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1124 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1125 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1126 batch = javafilelist[:i] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1127 javafilelist = javafilelist[i:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1128 try: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1129 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-c', config, '-o', auditfileName] + batch) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1130 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1131 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1132 with open(auditfileName) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1133 warnings = [line.strip() for line in f if 'warning:' in line] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1134 if len(warnings) != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1135 map(log, warnings) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1136 return 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1137 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1138 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1139 os.unlink(auditfileName) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1140 return 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1141 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1142 def clean(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1143 """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
|
1144 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1145 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
|
1146 generated images. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1147 """ |
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
|
1148 |
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
|
1149 suppliedParser = parser is not None |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1150 |
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
|
1151 parser = parser if suppliedParser else ArgumentParser(prog='mx build'); |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1152 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
|
1153 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1154 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1155 args = parser.parse_args(args) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1156 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1157 for p in projects(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1158 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1159 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1160 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
|
1161 else: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1162 if args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1163 outputDir = p.output_dir() |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1164 if outputDir != '' and exists(outputDir): |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1165 log('Removing {0}...'.format(outputDir)) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1166 shutil.rmtree(outputDir) |
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
|
1167 |
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
|
1168 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
|
1169 return args |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1170 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1171 def help_(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1172 """show help for a given command |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1173 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1174 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
|
1175 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1176 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
|
1177 if len(args) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1178 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1179 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1180 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1181 name = args[0] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1182 if not commands.has_key(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1183 _argParser.error('unknown command: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1184 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1185 value = commands[name] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1186 (func, usage) = value[:2] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1187 doc = func.__doc__ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1188 if len(value) > 2: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1189 docArgs = value[2:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1190 fmtArgs = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1191 for d in docArgs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1192 if isinstance(d, Callable): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1193 fmtArgs += [d()] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1194 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1195 fmtArgs += [str(d)] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1196 doc = doc.format(*fmtArgs) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1197 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
|
1198 |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1199 def projectgraph(args, suite=None): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1200 """create dot graph for project structure ("mx projectgraph | dot -Tpdf -oprojects.pdf")""" |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1201 |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1202 print 'digraph projects {' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1203 print 'rankdir=BT;' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1204 print 'node [shape=rect];' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1205 for p in projects(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1206 for dep in p.canonical_deps(): |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1207 print '"' + p.name + '"->"' + dep + '"' |
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1208 print '}' |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1209 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1210 def eclipseinit(args, suite=None): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1211 """(re)generate Eclipse project configurations""" |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1212 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1213 if suite is None: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1214 suite = _mainSuite |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1215 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1216 def println(out, obj): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1217 out.write(str(obj) + '\n') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1218 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1219 for p in projects(): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1220 if p.native: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1221 continue |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1222 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1223 if not exists(p.dir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1224 os.makedirs(p.dir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1225 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1226 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1227 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1228 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1229 println(out, '<classpath>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1230 for src in p.srcDirs: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1231 srcDir = join(p.dir, src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1232 if not exists(srcDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1233 os.mkdir(srcDir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1234 println(out, '\t<classpathentry kind="src" path="' + src + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1235 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1236 # Every Java program depends on the JRE |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1237 println(out, '\t<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1238 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1239 for dep in p.all_deps([], True): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1240 if dep == p: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1241 continue; |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1242 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1243 if dep.isLibrary(): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1244 if hasattr(dep, 'eclipse.container'): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1245 println(out, '\t<classpathentry exported="true" kind="con" path="' + getattr(dep, 'eclipse.container') + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1246 elif hasattr(dep, 'eclipse.project'): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1247 println(out, '\t<classpathentry combineaccessrules="false" exported="true" kind="src" path="/' + getattr(dep, 'eclipse.project') + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1248 else: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1249 path = dep.path |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1250 if dep.mustExist: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1251 dep.get_path(resolve=True) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1252 if isabs(path): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1253 println(out, '\t<classpathentry exported="true" kind="lib" path="' + path + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1254 else: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1255 println(out, '\t<classpathentry exported="true" kind="lib" path="' + join(suite.dir, path) + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1256 else: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1257 println(out, '\t<classpathentry combineaccessrules="false" exported="true" kind="src" path="/' + dep.name + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1258 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1259 println(out, '\t<classpathentry kind="output" path="' + getattr(p, 'eclipse.output', 'bin') + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1260 println(out, '</classpath>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1261 update_file(join(p.dir, '.classpath'), out.getvalue()) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1262 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1263 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1264 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1265 if exists(csConfig): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1266 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1267 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1268 dotCheckstyle = join(p.dir, ".checkstyle") |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1269 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1270 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1271 println(out, '<fileset-config file-format-version="1.2.0" simple-config="true">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1272 println(out, '\t<local-check-config name="Checks" location="' + checkstyleConfigPath + '" type="project" description="">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1273 println(out, '\t\t<additional-data name="protect-config-file" value="false"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1274 println(out, '\t</local-check-config>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1275 println(out, '\t<fileset name="all" enabled="true" check-config-name="Checks" local="true">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1276 println(out, '\t\t<file-match-pattern match-pattern="." include-pattern="true"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1277 println(out, '\t</fileset>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1278 println(out, '\t<filter name="FileTypesFilter" enabled="true">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1279 println(out, '\t\t<filter-data value="java"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1280 println(out, '\t</filter>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1281 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1282 exclude = join(p.dir, '.checkstyle.exclude') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1283 if exists(exclude): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1284 println(out, '\t<filter name="FilesFromPackage" enabled="true">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1285 with open(exclude) as f: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1286 for line in f: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1287 if not line.startswith('#'): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1288 line = line.strip() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1289 exclDir = join(p.dir, line) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1290 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1291 println(out, '\t\t<filter-data value="' + line + '"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1292 println(out, '\t</filter>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1293 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1294 println(out, '</fileset-config>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1295 update_file(dotCheckstyle, out.getvalue()) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1296 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1297 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1298 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1299 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1300 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1301 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1302 println(out, '<projectDescription>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1303 println(out, '\t<name>' + p.name + '</name>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1304 println(out, '\t<comment></comment>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1305 println(out, '\t<projects>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1306 println(out, '\t</projects>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1307 println(out, '\t<buildSpec>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1308 println(out, '\t\t<buildCommand>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1309 println(out, '\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1310 println(out, '\t\t\t<arguments>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1311 println(out, '\t\t\t</arguments>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1312 println(out, '\t\t</buildCommand>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1313 if exists(csConfig): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1314 println(out, '\t\t<buildCommand>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1315 println(out, '\t\t\t<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1316 println(out, '\t\t\t<arguments>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1317 println(out, '\t\t\t</arguments>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1318 println(out, '\t\t</buildCommand>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1319 println(out, '\t</buildSpec>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1320 println(out, '\t<natures>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1321 println(out, '\t\t<nature>org.eclipse.jdt.core.javanature</nature>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1322 if exists(csConfig): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1323 println(out, '\t\t<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1324 println(out, '\t</natures>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1325 println(out, '</projectDescription>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1326 update_file(join(p.dir, '.project'), out.getvalue()) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1327 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1328 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1329 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1330 settingsDir = join(p.dir, ".settings") |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1331 if not exists(settingsDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1332 os.mkdir(settingsDir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1333 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1334 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1335 if exists(eclipseSettingsDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1336 for name in os.listdir(eclipseSettingsDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1337 path = join(eclipseSettingsDir, name) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1338 if isfile(path): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1339 with open(join(eclipseSettingsDir, name)) as f: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1340 content = f.read() |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1341 update_file(join(settingsDir, name), content) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1342 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1343 def netbeansinit(args, suite=None): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1344 """(re)generate NetBeans project configurations""" |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1345 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1346 if suite is None: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1347 suite = _mainSuite |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1348 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1349 def println(out, obj): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1350 out.write(str(obj) + '\n') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1351 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1352 updated = False |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1353 for p in projects(): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1354 if p.native: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1355 continue |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1356 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1357 if not exists(join(p.dir, 'nbproject')): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1358 os.makedirs(join(p.dir, 'nbproject')) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1359 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1360 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1361 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1362 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1363 println(out, '<project name="' + p.name + '" default="default" basedir=".">') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1364 println(out, '\t<description>Builds, tests, and runs the project ' + p.name + '.</description>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1365 println(out, '\t<import file="nbproject/build-impl.xml"/>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1366 println(out, '</project>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1367 updated = update_file(join(p.dir, 'build.xml'), out.getvalue()) or updated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1368 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1369 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1370 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1371 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1372 println(out, '<project xmlns="http://www.netbeans.org/ns/project/1">') |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1373 println(out, ' <type>org.netbeans.modules.java.j2seproject</type>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1374 println(out, ' <configuration>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1375 println(out, ' <data xmlns="http://www.netbeans.org/ns/j2se-project/3">') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1376 println(out, ' <name>' + p.name+ '</name>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1377 println(out, ' <explicit-platform explicit-source-supported="true"/>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1378 println(out, ' <source-roots>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1379 println(out, ' <root id="src.dir"/>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1380 println(out, ' </source-roots>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1381 println(out, ' <test-roots>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1382 println(out, ' <root id="test.src.dir"/>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1383 println(out, ' </test-roots>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1384 println(out, ' </data>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1385 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1386 firstDep = True |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1387 for dep in p.all_deps([], True): |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1388 if dep == p: |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1389 continue; |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1390 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1391 if not dep.isLibrary(): |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1392 n = dep.name.replace('.', '_') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1393 if firstDep: |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1394 println(out, ' <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1395 firstDep = False |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1396 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1397 println(out, ' <reference>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1398 println(out, ' <foreign-project>' + n + '</foreign-project>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1399 println(out, ' <artifact-type>jar</artifact-type>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1400 println(out, ' <script>build.xml</script>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1401 println(out, ' <target>jar</target>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1402 println(out, ' <clean-target>clean</clean-target>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1403 println(out, ' <id>jar</id>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1404 println(out, ' </reference>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1405 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1406 if not firstDep: |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1407 println(out, ' </references>') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1408 |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1409 println(out, ' </configuration>') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1410 println(out, '</project>') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1411 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.getvalue()) or updated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1412 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1413 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1414 out = StringIO.StringIO() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1415 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1416 jdkPlatform = 'JDK_' + java().version |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1417 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1418 content = """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1419 annotation.processing.enabled=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1420 annotation.processing.enabled.in.editor=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1421 annotation.processing.processors.list= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1422 annotation.processing.run.all.processors=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1423 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1424 application.title=""" + p.name + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1425 application.vendor=mx |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1426 build.classes.dir=${build.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1427 build.classes.excludes=**/*.java,**/*.form |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1428 # 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
|
1429 build.dir=bin |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1430 build.generated.dir=${build.dir}/generated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1431 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
|
1432 # 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
|
1433 build.sysclasspath=ignore |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1434 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
|
1435 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
|
1436 # 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
|
1437 #debug.transport=dt_socket |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1438 debug.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1439 ${run.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1440 debug.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1441 ${run.test.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1442 # 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
|
1443 dist.dir=dist |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1444 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
|
1445 dist.javadoc.dir=${dist.dir}/javadoc |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1446 endorsed.classpath= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1447 excludes= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1448 includes=** |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1449 jar.compress=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1450 # Space-separated list of extra javac options |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1451 javac.compilerargs= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1452 javac.deprecation=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1453 javac.processorpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1454 ${javac.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1455 javac.source=1.7 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1456 javac.target=1.7 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1457 javac.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1458 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1459 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1460 javac.test.processorpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1461 ${javac.test.classpath} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1462 javadoc.additionalparam= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1463 javadoc.author=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1464 javadoc.encoding=${source.encoding} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1465 javadoc.noindex=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1466 javadoc.nonavbar=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1467 javadoc.notree=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1468 javadoc.private=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1469 javadoc.splitindex=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1470 javadoc.use=true |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1471 javadoc.version=false |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1472 javadoc.windowtitle= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1473 main.class= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1474 manifest.file=manifest.mf |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1475 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
|
1476 mkdist.disabled=false |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1477 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1478 platform.active=""" + jdkPlatform + """ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1479 run.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1480 ${javac.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1481 ${build.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1482 # 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
|
1483 # (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
|
1484 # 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
|
1485 run.jvmargs= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1486 run.test.classpath=\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1487 ${javac.test.classpath}:\\ |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1488 ${build.test.classes.dir} |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1489 test.src.dir= |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1490 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1491 println(out, content) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1492 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1493 mainSrc = True |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1494 for src in p.srcDirs: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1495 srcDir = join(p.dir, src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1496 if not exists(srcDir): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1497 os.mkdir(srcDir) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1498 ref = 'file.reference.' + p.name + '-' + src |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1499 println(out, ref + '=' + src) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1500 if mainSrc: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1501 println(out, 'src.dir=${' + ref + '}') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1502 mainSrc = False |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1503 else: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1504 println(out, 'src.' + src + '.dir=${' + ref + '}') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1505 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1506 javacClasspath = [] |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1507 for dep in p.all_deps([], True): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1508 if dep == p: |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1509 continue; |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1510 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1511 if dep.isLibrary(): |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1512 if not dep.mustExist: |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1513 continue |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1514 path = dep.get_path(resolve=True) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1515 if os.sep == '\\': |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1516 path = path.replace('\\', '\\\\') |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1517 ref = 'file.reference.' + dep.name + '-bin' |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1518 println(out, ref + '=' + path) |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1519 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1520 else: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1521 n = dep.name.replace('.', '_') |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1522 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1523 ref = 'reference.' + n + '.jar' |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1524 println(out, 'project.' + n + '=' + relDepPath) |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1525 println(out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1526 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1527 javacClasspath.append('${' + ref + '}') |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1528 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1529 println(out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1530 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1531 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1532 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1533 out.close() |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1534 |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1535 if updated: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1536 log('If using NetBeans:') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1537 log(' 1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)') |
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1538 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1539 |
4271
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1540 def ideclean(args, suite=None): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1541 """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
|
1542 |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1543 def rm(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1544 if exists(path): |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1545 os.remove(path) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1546 |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1547 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
|
1548 if p.native: |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1549 continue |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1550 |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1551 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1552 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
|
1553 rm(join(p.dir, '.classpath')) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1554 rm(join(p.dir, '.project')) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1555 rm(join(p.dir, 'build.xml')) |
311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents:
4270
diff
changeset
|
1556 |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1557 def ideinit(args, suite=None): |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1558 """(re)generate Eclipse and NetBeans project configurations""" |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1559 eclipseinit(args, suite) |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1560 netbeansinit(args, suite) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1561 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1562 def javap(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1563 """launch javap with a -classpath option denoting all available classes |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1564 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1565 Run the JDK javap class file disassembler with the following prepended options: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1566 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1567 -private -verbose -classpath <path to project classes>""" |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1568 |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
1569 javap = java().javap |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1570 if not exists(javap): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1571 abort('The javap executable does not exists: ' + javap) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1572 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1573 run([javap, '-private', '-verbose', '-classpath', classpath()] + args) |
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 show_projects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1576 """show all loaded projects""" |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1577 for s in suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1578 projectsFile = join(s.dir, 'mx', 'projects') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1579 if exists(projectsFile): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1580 log(projectsFile) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1581 for p in s.projects: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1582 log('\t' + p.name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1583 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1584 def add_argument(*args, **kwargs): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1585 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1586 Define how a single command-line argument. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1587 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1588 assert _argParser is not None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1589 _argParser.add_argument(*args, **kwargs) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1590 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1591 # Table of commands in alphabetical order. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1592 # 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
|
1593 # If any of the format args are instances of Callable, then they are called with an 'env' are before being |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1594 # used in the call to str.format(). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1595 # Extensions should update this table directly |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1596 commands = { |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1597 'build': [build, '[options]'], |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1598 'checkstyle': [checkstyle, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1599 'canonicalizeprojects': [canonicalizeprojects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1600 'clean': [clean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1601 'eclipseinit': [eclipseinit, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1602 '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
|
1603 'ideclean': [ideclean, ''], |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1604 'ideinit': [ideinit, ''], |
4301
fad6f1ebeb44
mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents:
4271
diff
changeset
|
1605 'projectgraph': [projectgraph, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1606 'javap': [javap, ''], |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1607 'netbeansinit': [netbeansinit, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1608 'projects': [show_projects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1609 } |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1610 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1611 _argParser = ArgParser() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1612 |
4241
8fece0287975
Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents:
4239
diff
changeset
|
1613 def main(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1614 cwdMxDir = join(os.getcwd(), 'mx') |
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
|
1615 if exists(cwdMxDir) and isdir(cwdMxDir): |
4269
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1616 global _mainSuite |
ffd5ce8fc736
Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents:
4258
diff
changeset
|
1617 _mainSuite = _loadSuite(os.getcwd(), True) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1618 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1619 opts, commandAndArgs = _argParser._parse_cmd_line() |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1620 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1621 global _opts, _java |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1622 _opts = opts |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1623 _java = JavaConfig(opts) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1624 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1625 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
|
1626 s._post_init(opts) |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1627 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1628 if len(commandAndArgs) == 0: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1629 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1630 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1631 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1632 command = commandAndArgs[0] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1633 command_args = commandAndArgs[1:] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1634 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1635 if not commands.has_key(command): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1636 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands())) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1637 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1638 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
|
1639 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
|
1640 abort(1) |
d4906ea4255b
Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4271
diff
changeset
|
1641 signal.signal(signal.SIGTERM, term_handler) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1642 try: |
4270
2158e26b50cf
Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents:
4269
diff
changeset
|
1643 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
|
1644 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
|
1645 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
|
1646 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
|
1647 signal.alarm(opts.timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1648 retcode = c(command_args) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1649 if retcode is not None and retcode != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1650 abort(retcode) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1651 except KeyboardInterrupt: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1652 # 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
|
1653 abort(1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1654 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1655 if __name__ == '__main__': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1656 # 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
|
1657 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
|
1658 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1659 main() |