Mercurial > hg > truffle
annotate mxtool/mx.py @ 4233:fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Thu, 05 Jan 2012 17:02:58 -0800 |
parents | 1fe200db8c30 |
children | 057620486c90 |
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. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
48 # includes - Other suites to be loaded. This is a 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 # |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
51 # The MX_INCLUDES environment variable can also be used to specify other suites. |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 # This value of this variable has the same format as a Java class path. |
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 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
|
55 # 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
|
56 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 # 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
|
58 # 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
|
59 # 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
|
60 # 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
|
61 # 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
|
62 # 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
|
63 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 # Library specification format: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 # library@<name>@<prop>=<value> |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 # Built-in library properties (* = required): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 # *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
|
71 # 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
|
72 # 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
|
73 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 # Project specification format: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 # project@<name>@<prop>=<value> |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 # 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
|
79 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 # Built-in project properties: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 # *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
|
83 # 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
|
84 # 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
|
85 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 # 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
|
87 # |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 # 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
|
89 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
90 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
91 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
|
92 from collections import Callable |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 from threading import Thread |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 from argparse import ArgumentParser, REMAINDER |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 from os.path import join, dirname, exists, getmtime, isabs, expandvars, isdir |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 DEFAULT_JAVA_ARGS = '-ea -Xss2m -Xmx1g' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
99 _projects = dict() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
100 _libs = dict() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
101 _suites = dict() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
102 _opts = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
103 _java = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
104 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
105 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
106 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
|
107 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 class Dependency: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
109 def __init__(self, suite, name): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 self.name = name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
111 self.suite = suite |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 def __str__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 return self.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 def __eq__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 return self.name == other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 def __ne__(self, other): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 return self.name != other.name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 def __hash__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 return hash(self.name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 def isLibrary(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 return isinstance(self, Library) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 class Project(Dependency): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
129 def __init__(self, suite, name, srcDirs, deps, dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
130 Dependency.__init__(self, suite, name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 self.srcDirs = srcDirs |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 self.deps = deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 self.checkstyleProj = name |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 self.native = False |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
135 self.dir = dir |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
137 def all_deps(self, deps, includeLibs, includeSelf=True): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
138 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
139 Add the transitive set of dependencies for this project, including |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
140 libraries if 'includeLibs' is true, to the 'deps' list. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
141 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 if self in deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 return deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 for name in self.deps: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 assert name != self.name |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
146 dep = _libs.get(name, None) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 if dep is not None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 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
|
149 deps.append(dep) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
151 dep = project(name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 if not dep in deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
153 dep.all_deps(deps, includeLibs) |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
154 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
|
155 deps.append(self) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 return deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
158 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
|
159 currentDist = distances.get(name); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 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
|
161 distances[name] = dist |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
162 p = project(name, False) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
163 if p is not None: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 for dep in p.deps: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
165 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
|
166 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
167 def canonical_deps(self): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
168 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
169 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
|
170 via other dependencies). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
171 """ |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 distances = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 result = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
174 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
|
175 for n,d in distances.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 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
|
177 if d == 1: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 result.add(n) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 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
|
182 return self.deps |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 return result; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 def source_dirs(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
187 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
188 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
|
189 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
190 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
|
191 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 def output_dir(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
193 """ |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
194 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
|
195 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
196 if self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
197 return None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
198 return join(self.dir, 'bin') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
200 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
201 if not self.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
202 cp.append(self.output_dir()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 class Library(Dependency): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
205 def __init__(self, suite, name, path, mustExist, urls): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
206 Dependency.__init__(self, suite, name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 self.path = path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 self.urls = urls |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 self.mustExist = mustExist |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
211 def get_path(self, resolve): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 path = self.path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 if not isabs(path): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 print('Downloading ' + self.name + ' from ' + str(self.urls)) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
218 download(path, self.urls) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
219 return path |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
220 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
221 def append_to_classpath(self, cp, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
222 path = self.get_path(resolve) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
223 if exists(path) or not resolve: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
224 cp.append(path) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
226 class Suite: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
227 def __init__(self, dir, primary): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
228 self.dir = dir |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
229 self.projects = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
230 self.libs = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
231 self.includes = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 self._load_commands(mxDir) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
239 def _load_projects(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 libsMap = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 projsMap = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 projectsFile = join(mxDir, 'projects') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 with open(projectsFile) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
246 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 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
|
249 key, value = line.split('=', 1) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 parts = key.split('@') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
252 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
253 if len(parts) == 2: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
254 pass |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
255 if len(parts) != 3: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
256 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
|
257 kind, name, attr = parts |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 if kind == 'project': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 m = projsMap |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
260 elif kind == 'library': |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
261 m = libsMap |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
262 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
263 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
|
264 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
265 attrs = m.get(name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
266 if attrs is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
267 attrs = dict() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
268 m[name] = attrs |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
269 value = expandvars_in_property(value) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
270 attrs[attr] = value |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
271 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
272 def pop_list(attrs, name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
273 v = attrs.pop(name, None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
274 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
|
275 return [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
276 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
|
277 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
278 for name, attrs in projsMap.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
279 srcDirs = pop_list(attrs, 'sourceDirs') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
280 deps = pop_list(attrs, 'dependencies') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
281 subDir = attrs.pop('subDir', None); |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
282 if subDir is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
283 dir = join(self.dir, name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
284 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
285 dir = join(self.dir, subDir, name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
286 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
|
287 p.checkstyleProj = attrs.pop('checkstyle', name) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
288 p.native = attrs.pop('native', '') == 'true' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
289 p.__dict__.update(attrs) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
290 self.projects.append(p) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
292 for name, attrs in libsMap.iteritems(): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
293 path = attrs['path'] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
294 mustExist = attrs.pop('optional', 'false') != 'true' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
295 urls = pop_list(attrs, 'urls') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
296 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
|
297 l.__dict__.update(attrs) |
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
|
298 l.get_path(True) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
299 self.libs.append(l) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
300 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
301 def _load_commands(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 commands = join(mxDir, 'commands.py') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 if exists(commands): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
304 # temporarily extend the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
305 sys.path.insert(0, mxDir) |
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 mod = __import__('commands') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
308 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
309 # revert the Python path |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
310 del sys.path[0] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
311 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
312 if not hasattr(mod, 'mx_init'): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
317 mod.mx_init() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
318 self.commands = mod |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
320 def _load_includes(self, mxDir): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
321 includes = join(mxDir, 'includes') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
322 if exists(includes): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
323 with open(includes) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
324 for line in f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
325 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
|
326 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
327 def _load_env(self, mxDir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
328 e = join(mxDir, 'env') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
329 if exists(e): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
330 with open(e) as f: |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
331 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
332 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
333 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
|
334 key, value = line.split('=', 1) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
335 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
|
336 |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
337 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
|
338 mxDir = join(self.dir, 'mx') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
339 self._load_includes(mxDir) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 _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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 _libs[l.name] = l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
353 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
354 def get_os(): |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
355 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
356 Get a canonical form of sys.platform. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
357 """ |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
358 if sys.platform.startswith('darwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
359 return 'darwin' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
360 elif sys.platform.startswith('linux'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
361 return 'linux' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
362 elif sys.platform.startswith('sunos'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
363 return 'solaris' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
364 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
365 return 'windows' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
366 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
367 abort('Unknown operating system ' + sys.platform) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
368 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
369 def _loadSuite(dir, primary=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
370 mxDir = join(dir, 'mx') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
371 if not exists(mxDir) or not isdir(mxDir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
372 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
373 if not _suites.has_key(dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
374 suite = Suite(dir, primary) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
375 _suites[dir] = suite |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
376 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
377 def suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
378 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
379 Get the list of all loaded suites. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
380 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
381 return _suites.values() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
382 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
383 def projects(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
384 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
385 Get the list of all loaded projects. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
386 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
387 return _projects.values() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
388 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
389 def project(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
390 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
391 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
|
392 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
393 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
394 p = _projects.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
395 if p is None and fatalIfMissing: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
396 abort('project named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
397 return p |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
398 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
399 def library(name, fatalIfMissing=True): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
400 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
401 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
|
402 not exist and 'fatalIfMissing' is true. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
403 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
404 l = _libs.get(name) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
405 if l is None and fatalIfMissing: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
406 abort('library named ' + name + ' not found') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
407 return l |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
408 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
409 def _as_classpath(deps, resolve): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
410 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
411 if _opts.cp_prefix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
412 cp = [_opts.cp_prefix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
413 for d in deps: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
414 d.append_to_classpath(cp, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
415 if _opts.cp_suffix is not None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
416 cp += [_opts.cp_suffix] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
417 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
418 |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
419 def classpath(names=None, resolve=True, includeSelf=True): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
420 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
421 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
|
422 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
|
423 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
424 if names is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
425 return _as_classpath(sorted_deps(True), resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
426 deps = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
427 if isinstance(names, types.StringTypes): |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
428 project(names).all_deps(deps, True, includeSelf) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
429 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
430 for n in names: |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
431 project(n).all_deps(deps, True, includeSelf) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
432 return _as_classpath(deps, resolve) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
433 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
434 def sorted_deps(includeLibs=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
435 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
436 Gets the loaded projects and libraries sorted such that dependencies |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
437 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
|
438 true, libraries are omitted from the result. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
439 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
440 deps = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
441 for p in _projects.itervalues(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
442 p.all_deps(deps, includeLibs) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
443 return deps |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
444 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
445 class ArgParser(ArgumentParser): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
446 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
447 # 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
|
448 def format_help(self): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
449 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
|
450 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
451 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
452 def __init__(self): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
453 self.java_initialized = False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
454 ArgumentParser.__init__(self, prog='mx') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
455 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 self.add_argument('--java-home', help='JDK installation directory (must be JDK 6 or later)', metavar='<path>') |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
465 self.add_argument('--timeout', help='Timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
466 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
467 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
|
468 if args is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
469 args = sys.argv[1:] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
470 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
471 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
|
472 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
473 opts = self.parse_args() |
4149
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
474 |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
475 if opts.java_home is None: |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
476 opts.java_home = os.environ.get('JAVA_HOME') |
cf4de9cc1268
Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
477 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
478 if opts.java_home is None or opts.java_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
479 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
|
480 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
481 if opts.user_home is None or opts.user_home == '': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
482 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
|
483 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
484 os.environ['JAVA_HOME'] = opts.java_home |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
485 os.environ['HOME'] = opts.user_home |
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 commandAndArgs = opts.__dict__.pop('commandAndArgs') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
488 return opts, commandAndArgs |
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 def _format_commands(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
491 msg = '\navailable commands:\n\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
492 for cmd in sorted(commands.iterkeys()): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
493 c, _ = commands[cmd][:2] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
494 doc = c.__doc__ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
495 if doc is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
496 doc = '' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
497 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
|
498 return msg + '\n' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
499 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
500 def java(): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
501 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
502 Get a JavaConfig object containing Java commands launch details. |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
503 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
504 assert _java is not None |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
505 return _java |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
506 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
507 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
|
508 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
|
509 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
510 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
|
511 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
|
512 while True: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
513 try: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
514 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
|
515 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
|
516 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
|
517 continue |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
518 raise |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
519 |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
520 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
|
521 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
|
522 while True: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
523 (pid, _) = _waitpid(process.pid) |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
524 if pid == process.pid: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
525 return process.wait() |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
526 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
|
527 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
|
528 process.kill() |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
533 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
|
534 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 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
|
539 out and err if they are callable objects. |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
540 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
541 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
542 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
|
543 for arg in args: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
544 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
|
545 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
546 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
547 log(' '.join(args)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
548 |
4158
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
549 if timeout is None and _opts.timeout != 0: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
550 timeout = _opts.timeout |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
551 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
552 try: |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
553 if not callable(out) and not callable(err) and timeout is None: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
554 retcode = subprocess.call(args, cwd=cwd) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
555 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
556 def redirect(stream, f): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
557 for line in iter(stream.readline, ''): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
558 f(line) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
559 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
|
560 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
|
561 stderr=err if not callable(err) 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
|
562 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr) |
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
563 if callable(out): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
564 t = Thread(target=redirect, args=(p.stdout, out)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
565 t.daemon = True # thread dies with the program |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
566 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
|
567 if callable(err): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
568 t = Thread(target=redirect, args=(p.stderr, err)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
569 t.daemon = True # thread dies with the program |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
570 t.start() |
4161
8c507a8dd6a4
Interpret '--timeout 0' correctly (i.e. as no timeout).
Doug Simon <doug.simon@oracle.com>
parents:
4158
diff
changeset
|
571 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
|
572 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
|
573 else: |
f3a50640333b
Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents:
4150
diff
changeset
|
574 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
|
575 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
|
576 retcode = _waitWithTimeout(p, args, timeout) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
577 except OSError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
578 log('Error executing \'' + ' '.join(args) + '\': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
579 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
580 raise e |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
581 abort(e.errno) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
582 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
583 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
584 if retcode and nonZeroIsFatal: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
585 if _opts.verbose: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
586 raise subprocess.CalledProcessError(retcode, ' '.join(args)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
587 abort(retcode) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
588 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
589 return retcode |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
590 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
591 def exe_suffix(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
592 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
593 Gets the platform specific suffix for an executable |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
594 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
595 if os == 'windows': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
596 return name + '.exe' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
597 return name |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
598 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
599 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
600 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
|
601 """ |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
602 class JavaConfig: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
603 def __init__(self, opts): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
604 self.jdk = opts.java_home |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
605 self.debug = opts.java_dbg |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
606 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
607 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
608 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap')) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
609 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
610 def delAtAndSplit(s): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
611 return shlex.split(s.lstrip('@')) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
612 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
613 self.java_args = delAtAndSplit(_opts.java_args) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
614 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
|
615 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
|
616 |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
617 # 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
|
618 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
619 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
|
620 self.java_args = ['-d64'] + self.java_args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
621 except subprocess.CalledProcessError as e: |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
622 try: |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
623 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
|
624 except subprocess.CalledProcessError as e: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
625 print e.output |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
626 abort(e.returncode) |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
627 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
628 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
|
629 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
|
630 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
|
631 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
632 if self.debug: |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
633 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
|
634 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
635 def format_cmd(self, args): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
636 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
|
637 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
638 def check_get_env(key): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
639 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
640 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
|
641 """ |
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
|
642 value = get_env(key) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
643 if value is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
644 abort('Required environment variable ' + key + ' must be set') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
645 return value |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
646 |
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
|
647 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
|
648 """ |
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
|
649 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
|
650 """ |
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
|
651 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
|
652 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
|
653 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
654 def log(msg=None): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
655 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
656 Write a message to the console. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
657 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
|
658 to redirect it. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
659 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
660 if msg is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
661 print |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
662 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
663 print msg |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
664 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
665 def expand_project_in_class_path_arg(cpArg): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
666 cp = [] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
667 for part in cpArg.split(os.pathsep): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
668 if part.startswith('@'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
669 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
|
670 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
671 cp.append(part) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
672 return os.pathsep.join(cp) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
673 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
674 def expand_project_in_args(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
675 for i in range(len(args)): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
676 if args[i] == '-cp' or args[i] == '-classpath': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
677 if i + 1 < len(args): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
678 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
|
679 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
680 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
681 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
682 def gmake_cmd(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
683 for a in ['make', 'gmake', 'gnumake']: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
684 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
685 output = subprocess.check_output([a, '--version']) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
686 if 'GNU' in output: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
687 return a; |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
688 except: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
689 pass |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
690 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
|
691 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
692 def expandvars_in_property(value): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
693 result = expandvars(value) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
694 if '$' in result or '%' in result: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
695 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
|
696 return result |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
697 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
698 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
699 def abort(codeOrMessage): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
700 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
701 Aborts the program with a SystemExit exception. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
706 raise SystemExit(codeOrMessage) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
707 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
708 def download(path, urls, verbose=False): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
709 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
710 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
|
711 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
|
712 is written to the file indicated by 'path'. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
713 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
714 d = dirname(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
715 if d != '' and not exists(d): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
716 os.makedirs(d) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
717 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
718 # 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
|
719 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
|
720 |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 return |
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
727 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
728 def url_open(url): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
729 userAgent = 'Mozilla/5.0 (compatible)' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
730 headers = { 'User-Agent' : userAgent } |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
731 req = urllib2.Request(url, headers=headers) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
732 return urllib2.urlopen(req); |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
733 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
734 for url in urls: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
735 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
736 if (verbose): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
737 log('Downloading ' + url + ' to ' + path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
738 if url.startswith('zip:') or url.startswith('jar:'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
739 i = url.find('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
740 if i == -1: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
741 abort('Zip or jar URL does not contain "!/": ' + url) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
742 url, _, entry = url[len('zip:'):].partition('!/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
743 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
744 data = f.read() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
745 zipdata = StringIO.StringIO(f.read()) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
746 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
747 zf = zipfile.ZipFile(zipdata, 'r') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
748 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
|
749 with open(path, 'wb') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
750 f.write(data) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
751 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
752 with contextlib.closing(url_open(url)) as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
753 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
|
754 with open(path, 'wb') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
755 f.write(data) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
756 return |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
757 except IOError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
758 log('Error reading from ' + url + ': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
759 except zipfile.BadZipfile as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
760 log('Error in zip file downloaded from ' + url + ': ' + str(e)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
761 |
4188
148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents:
4186
diff
changeset
|
762 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
|
763 '\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
|
764 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
765 def update_file(path, content): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
766 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
767 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
|
768 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
|
769 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
770 existed = exists(path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
771 try: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
772 old = None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
773 if existed: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
774 with open(path, 'rb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
775 old = f.read() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
776 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
777 if old == content: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
778 return False |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
779 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
780 with open(path, 'wb') as f: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
781 f.write(content) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
782 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
783 log(('modified ' if existed else 'created ') + path) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
784 return True; |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
785 except IOError as e: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
786 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
|
787 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
788 # Builtin commands |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
789 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
790 def build(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
791 """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
|
792 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
793 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
|
794 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
|
795 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='<path>') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
804 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
805 args = parser.parse_args(args) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
806 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
807 jdtJar = None |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
808 if args.jdt is not None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
809 if args.jdt.endswith('.jar'): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
810 jdtJar=args.jdt |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
811 elif isdir(args.jdt): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
812 plugins = join(args.jdt, 'plugins') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
813 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
|
814 if len(choices) != 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
815 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
|
816 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
817 built = set() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
818 for p in sorted_deps(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
819 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
820 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
821 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
822 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
|
823 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
824 if args.clean: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
825 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
|
826 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
827 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
|
828 built.add(p.name) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
829 continue |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
830 else: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
831 if not args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
832 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
833 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
834 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
835 outputDir = p.output_dir() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
836 if exists(outputDir): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
837 if args.clean: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
838 log('Cleaning {0}...'.format(outputDir)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
839 shutil.rmtree(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
840 os.mkdir(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
841 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
842 os.mkdir(outputDir) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
843 |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
844 cp = classpath(p.name, includeSelf=True) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
845 sourceDirs = p.source_dirs() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
846 mustBuild = args.force |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
847 if not mustBuild: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
848 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
|
849 if dep.name in built: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
850 mustBuild = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
851 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
852 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
853 javafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
854 nonjavafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
855 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
|
856 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
|
857 javafilelist += javafiles |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
858 nonjavafilelist += [join(root, name) for name in files if not name.endswith('.java')] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
859 if not mustBuild: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
860 for javafile in javafiles: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
861 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
|
862 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
|
863 mustBuild = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
864 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
865 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
866 if not mustBuild: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
867 log('[all class files in {0} are up to date - skipping]'.format(sourceDir)) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
868 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
869 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
870 if len(javafilelist) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
871 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
|
872 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
873 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
874 built.add(p.name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
875 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
876 argfileName = join(p.dir, 'javafilelist.txt') |
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
|
877 argfile = open(argfileName, 'wb') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
878 argfile.write('\n'.join(javafilelist)) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
879 argfile.close() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
880 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
881 try: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
882 if jdtJar is None: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
883 log('Compiling Java sources in {0} with javac...'.format(sourceDir)) |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
884 errFilt = None |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
885 if not args.warnAPI: |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
886 class Filter: |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
887 """ |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
888 Class to errFilt the 'is Sun proprietary API and may be removed in a future release' |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
889 warning when compiling the VM classes. |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
890 |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
891 """ |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
892 def __init__(self): |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
893 self.c = 0 |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
894 |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
895 def eat(self, line): |
4225
339cf8d4904d
Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents:
4219
diff
changeset
|
896 if 'proprietary API' in line: |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
897 self.c = 2 |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
898 elif self.c != 0: |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
899 self.c -= 1 |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
900 else: |
4219
47f7d91d34cf
Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4215
diff
changeset
|
901 log(line.rstrip()) |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
902 errFilt=Filter().eat |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
903 |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
904 run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
905 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
906 log('Compiling Java sources in {0} with JDT...'.format(sourceDir)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
907 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
908 if not exists(jdtProperties): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
909 raise SystemError('JDT properties file {0} not found'.format(jdtProperties)) |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
910 run([java().java, '-Xmx1g', '-jar', jdtJar, |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
911 '-properties', jdtProperties, |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
912 '-' + args.compliance, |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
913 '-cp', cp, '-g', |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
914 '-warn:-unusedImport,-unchecked', |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
915 '-d', outputDir, '@' + argfile.name]) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
916 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
917 os.remove(argfileName) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
918 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
919 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
920 for name in nonjavafilelist: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
921 dst = join(outputDir, name[len(sourceDir) + 1:]) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
922 if exists(dirname(dst)): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
923 shutil.copyfile(name, dst) |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
924 return args |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
925 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
926 def canonicalizeprojects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
927 """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
|
928 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
929 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
|
930 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
931 changedFiles = 0 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
932 for s in suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
933 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
|
934 if not exists(projectsFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
935 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
936 with open(projectsFile) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
937 out = StringIO.StringIO() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
938 pattern = re.compile('project@([^@]+)@dependencies=.*') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
939 for line in f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
940 line = line.strip() |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
941 m = pattern.match(line) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
942 if m is None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
943 out.write(line + '\n') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
944 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
945 p = project(m.group(1)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
946 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
|
947 content = out.getvalue() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
948 if update_file(projectsFile, content): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
949 changedFiles += 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
950 return changedFiles; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
951 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
952 def checkstyle(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
953 """run Checkstyle on the Java sources |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
954 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
955 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
|
956 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
|
957 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
958 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
|
959 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
960 for p in sorted_deps(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
961 if p.native: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
962 continue |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
963 sourceDirs = p.source_dirs() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
964 dotCheckstyle = join(p.dir, '.checkstyle') |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
965 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
966 if not exists(dotCheckstyle): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
967 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
968 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
969 for sourceDir in sourceDirs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
970 javafilelist = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
971 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
|
972 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
|
973 if len(javafilelist) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
974 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
|
975 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
976 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
977 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
|
978 mustCheck = False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
979 if exists(timestampFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
980 timestamp = os.path.getmtime(timestampFile) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
981 for f in javafilelist: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
982 if os.path.getmtime(f) > timestamp: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
983 mustCheck = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
984 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
985 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
986 mustCheck = True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
987 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
988 if not mustCheck: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
989 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
|
990 continue |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
991 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
992 if exists(timestampFile): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
993 os.utime(timestampFile, None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
994 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
995 file(timestampFile, 'a') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
996 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
997 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
998 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
|
999 configLocation = localCheckConfig.getAttribute('location') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1000 configType = localCheckConfig.getAttribute('type') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1001 if configType == 'project': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1002 # Eclipse plugin "Project Relative Configuration" format: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1003 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1004 # '/<project_name>/<suffix>' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1005 # |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1006 if configLocation.startswith('/'): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1007 name, _, suffix = configLocation.lstrip('/').partition('/') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1008 config = join(project(name).dir, suffix) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1009 else: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1010 config = join(p.dir, configLocation) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1011 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1012 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
|
1013 continue |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1014 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1015 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
|
1016 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1017 if exists(exclude): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1018 with open(exclude) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1019 # Convert patterns to OS separators |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1020 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
|
1021 def match(name): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1022 for p in patterns: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1023 if p in name: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1024 log('excluding: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1025 return True |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1026 return False |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1027 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1028 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
|
1029 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1030 auditfileName = join(p.dir, 'checkstyleOutput.txt') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1031 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
|
1032 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1033 try: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1034 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1035 # 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
|
1036 # 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
|
1037 # 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
|
1038 # 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
|
1039 while len(javafilelist) != 0: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1040 i = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1041 size = 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1042 while i < len(javafilelist): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1043 s = len(javafilelist[i]) + 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1044 if (size + s < 30000): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1045 size += s |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1046 i += 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1047 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1048 break |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1049 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1050 batch = javafilelist[:i] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1051 javafilelist = javafilelist[i:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1052 try: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1053 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
|
1054 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1055 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1056 with open(auditfileName) as f: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1057 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
|
1058 if len(warnings) != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1059 map(log, warnings) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1060 return 1 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1061 finally: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1062 if exists(auditfileName): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1063 os.unlink(auditfileName) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1064 return 0 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1065 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1066 def clean(args, parser=None): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1067 """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
|
1068 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1069 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
|
1070 generated images. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1071 """ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1072 |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1073 parser = parser if parser is not None else ArgumentParser(prog='mx build'); |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1074 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
|
1075 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
|
1076 |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1077 args = parser.parse_args(args) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1078 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1079 for p in projects(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1080 if p.native: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1081 if args.native: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1082 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
|
1083 else: |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1084 if args.java: |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1085 outputDir = p.output_dir() |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1086 if outputDir != '' and exists(outputDir): |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1087 log('Removing {0}...'.format(outputDir)) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1088 shutil.rmtree(outputDir) |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1089 return args |
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 def help_(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1092 """show help for a given command |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1093 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1094 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
|
1095 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1096 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
|
1097 if len(args) == 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1098 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1099 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1100 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1101 name = args[0] |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1102 if not commands.has_key(name): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1103 _argParser.error('unknown command: ' + name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1104 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1105 value = commands[name] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1106 (func, usage) = value[:2] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1107 doc = func.__doc__ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1108 if len(value) > 2: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1109 docArgs = value[2:] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1110 fmtArgs = [] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1111 for d in docArgs: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1112 if isinstance(d, Callable): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1113 fmtArgs += [d()] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1114 else: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1115 fmtArgs += [str(d)] |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1116 doc = doc.format(*fmtArgs) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1117 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
|
1118 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1119 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1120 # Commands are in alphabetical order in this file. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1121 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1122 def javap(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1123 """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
|
1124 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1125 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
|
1126 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1127 -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
|
1128 |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4145
diff
changeset
|
1129 javap = java().javap |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1130 if not exists(javap): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1131 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
|
1132 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1133 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
|
1134 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1135 def show_projects(args): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1136 """show all loaded projects""" |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1137 for s in suites(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1138 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
|
1139 if exists(projectsFile): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1140 log(projectsFile) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1141 for p in s.projects: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1142 log('\t' + p.name) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1143 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1144 def add_argument(*args, **kwargs): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1145 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1146 Define how a single command-line argument. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1147 """ |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1148 assert _argParser is not None |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1149 _argParser.add_argument(*args, **kwargs) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1150 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1151 # Table of commands in alphabetical order. |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1152 # 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
|
1153 # 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
|
1154 # used in the call to str.format(). |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1155 # Extensions should update this table directly |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1156 commands = { |
4226
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1157 'build': [build, '[options]'], |
e03ff10d4bfc
Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents:
4225
diff
changeset
|
1158 'checkstyle': [checkstyle, ''], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1159 'canonicalizeprojects': [canonicalizeprojects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1160 'clean': [clean, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1161 'help': [help_, '[command]'], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1162 'javap': [javap, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1163 'projects': [show_projects, ''], |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1164 } |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1165 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1166 _argParser = ArgParser() |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1167 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1168 def main(): |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1169 MX_INCLUDES = os.environ.get('MX_INCLUDES', None) |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1170 if MX_INCLUDES is not None: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1171 for path in MX_INCLUDES.split(os.pathsep): |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1172 d = join(path, 'mx') |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1173 if exists(d) and isdir(d): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1174 _loadSuite(path) |
3723
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 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
|
1177 if exists(cwdMxDir) and isdir(cwdMxDir): |
383c1272cd1f
Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4178
diff
changeset
|
1178 _loadSuite(os.getcwd(), True) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1179 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1180 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
|
1181 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1182 global _opts, _java |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1183 _opts = opts |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
1184 _java = JavaConfig(opts) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1185 |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
1186 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
|
1187 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
|
1188 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1189 if len(commandAndArgs) == 0: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1190 _argParser.print_help() |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1191 return |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1192 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1193 command = commandAndArgs[0] |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1194 command_args = commandAndArgs[1:] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1195 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1196 if not commands.has_key(command): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1197 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
|
1198 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1199 c, _ = commands[command][:2] |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1200 try: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1201 retcode = c(command_args) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1202 if retcode is not None and retcode != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1203 abort(retcode) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1204 except KeyboardInterrupt: |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1205 # 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
|
1206 abort(1) |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1207 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1208 if __name__ == '__main__': |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1209 # 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
|
1210 sys.modules['mx'] = sys.modules.pop('__main__') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1211 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3732
diff
changeset
|
1212 main() |