annotate mxtool/mx.py @ 10059:4dada3ec9c58

mx checkstyle command no longer exits on first error
author Doug Simon <doug.simon@oracle.com>
date Sat, 15 Jun 2013 21:27:14 +0200
parents 440661cc7908
children 193d5163a94a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
28
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
29 r"""
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
30 mx is a command line tool inspired by mvn (http://maven.apache.org/)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
31 and hg (http://mercurial.selenic.com/). It includes a mechanism for
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
32 managing the dependencies between a set of projects (like Maven)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
33 as well as making it simple to run commands
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
34 (like hg is the interface to the Mercurial commands).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
35
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
36 The organizing principle of mx is a project suite. A suite is a directory
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
37 containing one or more projects. It's not coincidental that this closely
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
38 matches the layout of one or more projects in a Mercurial repository.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
39 The configuration information for a suite lives in an 'mx' sub-directory
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
40 at the top level of the suite.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
41
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
42 When launched, mx treats the current working directory as a suite.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
43 This is the primary suite. All other suites are called included suites.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
44
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
45 The configuration files (i.e. in the 'mx' sub-directory) of a suite are:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
46
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
47 projects
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
48 Defines the projects and libraries in the suite and the
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
49 dependencies between them.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
50
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
51 commands.py
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
52 Suite specific extensions to the commands available to mx.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
53
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
54 includes
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
55 Other suites to be loaded. This is recursive. Each
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
56 line in an includes file is a path to a suite directory.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
57
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
58 env
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
59 A set of environment variable definitions. These override any
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
60 existing environment variables. Common properties set here
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
61 include JAVA_HOME and IGNORED_PROJECTS.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
62
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
63 The includes and env files are typically not put under version control
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
64 as they usually contain local file-system paths.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
65
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
66 The projects file is like the pom.xml file from Maven except that
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
67 it is a properties file (not XML). Each non-comment line
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
68 in the file specifies an attribute of a project or library. The main
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
69 difference between a project and a library is that the former contains
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
70 source code built by the mx tool where as the latter is an external
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
71 dependency. The format of the projects file is
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
72
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
73 Library specification format:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
74
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
75 library@<name>@<prop>=<value>
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
76
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
77 Built-in library properties (* = required):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
78
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
79 *path
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
80 The file system path for the library to appear on a class path.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
81
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
82 urls
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
83 A comma separated list of URLs from which the library (jar) can
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
84 be downloaded and saved in the location specified by 'path'.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
85
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
86 optional
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
87 If "true" then this library will be omitted from a class path
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
88 if it doesn't exist on the file system and no URLs are specified.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
89
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
90 sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
91 The file system path for a jar file containing the library sources.
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
92
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
93 sourceUrls
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
94 A comma separated list of URLs from which the library source jar can
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
95 be downloaded and saved in the location specified by 'sourcePath'.
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
96
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
97 Project specification format:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
98
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
99 project@<name>@<prop>=<value>
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
100
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
101 The name of a project also denotes the directory it is in.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
102
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
103 Built-in project properties (* = required):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
104
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
105 subDir
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
106 The sub-directory of the suite in which the project directory is
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
107 contained. If not specified, the project directory is directly
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
108 under the suite directory.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
109
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
110 *sourceDirs
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
111 A comma separated list of source directory names (relative to
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
112 the project directory).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
113
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
114 dependencies
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
115 A comma separated list of the libraries and project the project
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
116 depends upon (transitive dependencies should be omitted).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
117
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
118 checkstyle
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
119 The project whose Checkstyle configuration
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
120 (i.e. <project>/.checkstyle_checks.xml) is used.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
121
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
122 native
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
123 "true" if the project is native.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
124
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
125 javaCompliance
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
126 The minimum JDK version (format: x.y) to which the project's
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
127 sources comply (required for non-native projects).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
128
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
129 Other properties can be specified for projects and libraries for use
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
130 by extension commands.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
131
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
132 Property values can use environment variables with Bash syntax (e.g. ${HOME}).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
133 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
135 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
136 import xml.parsers.expat
8447
b6b9ab1fde62 removed support for using the Eclipse batch compiler bundled with Eclipse - depending on the version, it has bugs with respect to annotation processing
Doug Simon <doug.simon@oracle.com>
parents: 8439
diff changeset
137 import shutil, re, xml.dom.minidom
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 from collections import Callable
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 from threading import Thread
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 from argparse import ArgumentParser, REMAINDER
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
141 from os.path import join, basename, dirname, exists, getmtime, isabs, expandvars, isdir, isfile
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 DEFAULT_JAVA_ARGS = '-ea -Xss2m -Xmx1g'
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
145 _projects = dict()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
146 _libs = dict()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
147 _dists = dict()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
148 _suites = dict()
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
149 _annotationProcessors = None
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
150 _mainSuite = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
151 _opts = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
152 _java = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
153
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
154 """
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
155 A distribution is a jar or zip file containing the output from one or more Java projects.
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
156 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
157 class Distribution:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
158 def __init__(self, suite, name, path, deps):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
159 self.suite = suite
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
160 self.name = name
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
161 self.path = path.replace('/', os.sep)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
162 if not isabs(self.path):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
163 self.path = join(suite.dir, self.path)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
164 self.deps = deps
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
165 self.update_listeners = set()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
166
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
167 def __str__(self):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
168 return self.name
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
169
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
170 def add_update_listener(self, listener):
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
171 self.update_listeners.add(listener)
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
172
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
173 def notify_updated(self):
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
174 for l in self.update_listeners:
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
175 l(self)
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
176
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
177 """
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
178 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
179 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 class Dependency:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
181 def __init__(self, suite, name):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 self.name = name
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
183 self.suite = suite
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
184
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 def __str__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 return self.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
187
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 def __eq__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 return self.name == other.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
190
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
191 def __ne__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 return self.name != other.name
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 def __hash__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 return hash(self.name)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
196
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 def isLibrary(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 return isinstance(self, Library)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
199
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200 class Project(Dependency):
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
201 def __init__(self, suite, name, srcDirs, deps, javaCompliance, d):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
202 Dependency.__init__(self, suite, name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 self.srcDirs = srcDirs
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 self.deps = deps
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205 self.checkstyleProj = name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
206 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance is not None else None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 self.native = False
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
208 self.dir = d
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
209
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
210 # Create directories for projects that don't yet exist
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
211 if not exists(d):
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
212 os.mkdir(d)
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
213 for s in self.source_dirs():
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
214 if not exists(s):
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
215 os.mkdir(s)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
216
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
217 def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False):
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
218 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
219 Add the transitive set of dependencies for this project, including
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
220 libraries if 'includeLibs' is true, to the 'deps' list.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
221 """
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
222 childDeps = list(self.deps)
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
223 if includeAnnotationProcessors and len(self.annotation_processors()) > 0:
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
224 childDeps = self.annotation_processors() + childDeps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 if self in deps:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226 return deps
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
227 for name in childDeps:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 assert name != self.name
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
229 dep = _libs.get(name, None)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 if dep is not None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 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
232 deps.append(dep)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 else:
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
234 dep = _projects.get(name, None)
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
235 if dep is None:
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
236 if name in _opts.ignored_projects:
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
237 abort('project named ' + name + ' required by ' + self.name + ' is ignored')
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
238 abort('dependency named ' + name + ' required by ' + self.name + ' is not found')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 if not dep in deps:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
240 dep.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors)
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4215
diff changeset
241 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
242 deps.append(self)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
243 return deps
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
244
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
245 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
246 currentDist = distances.get(name);
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247 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
248 distances[name] = dist
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
249 p = project(name, False)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
250 if p is not None:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
251 for dep in p.deps:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
252 self._compute_max_dep_distances(dep, distances, dist + 1)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
253
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
254 def canonical_deps(self):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
255 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
256 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
257 via other dependencies).
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
258 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
259 distances = dict()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
260 result = set()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
261 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
262 for n,d in distances.iteritems():
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
263 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
264 if d == 1:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
265 result.add(n)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
266
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
267 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
268 return self.deps
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
269 return result;
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
270
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
271 def max_depth(self):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
272 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
273 Get the maximum canonical distance between this project and its most distant dependency.
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
274 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
275 distances = dict()
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
276 self._compute_max_dep_distances(self.name, distances, 0)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
277 return max(distances.values())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
278
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
279 def source_dirs(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
280 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
281 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
282 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
283 return [join(self.dir, s) for s in self.srcDirs]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
284
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
285 def source_gen_dir(self):
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
286 """
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
287 Get the directory in which source files generated by the annotation processor are found/placed.
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
288 """
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
289 if self.native:
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
290 return None
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
291 return join(self.dir, 'src_gen')
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
292
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
293 def output_dir(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
294 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
295 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
296 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
297 if self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
298 return None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
299 return join(self.dir, 'bin')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
301 def jasmin_output_dir(self):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
302 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
303 Get the directory in which the Jasmin assembled class files of this project are found/placed.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
304 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
305 if self.native:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
306 return None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
307 return join(self.dir, 'jasmin_classes')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
308
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
309 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
310 if not self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
311 cp.append(self.output_dir())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
312
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
313 def find_classes_with_matching_source_line(self, pkgRoot, function, includeInnerClasses=False):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
314 """
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
315 Scan the sources of this project for Java source files containing a line for which
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
316 'function' returns true. A map from class name to source file path for each existing class
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
317 corresponding to a matched source file is returned.
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
318 """
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
319 result = dict()
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
320 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$")
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
321 for srcDir in self.source_dirs():
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
322 outputDir = self.output_dir()
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
323 for root, _, files in os.walk(srcDir):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
324 for name in files:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
325 if name.endswith('.java') and name != 'package-info.java':
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
326 matchFound = False
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
327 source = join(root, name)
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
328 with open(source) as f:
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
329 pkg = None
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
330 for line in f:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
331 if line.startswith("package "):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
332 match = pkgDecl.match(line)
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
333 if match:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
334 pkg = match.group(1)
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
335 if function(line.strip()):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
336 matchFound = True
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
337 if pkg and matchFound:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
338 break
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
339
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
340 if matchFound:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
341 basename = name[:-len('.java')]
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
342 assert pkg is not None
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
343 if pkgRoot is None or pkg.startswith(pkgRoot):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
344 pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep))
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
345 for e in os.listdir(pkgOutputDir):
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
346 if includeInnerClasses:
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
347 if e.endswith('.class') and (e.startswith(basename) or e.startswith(basename + '$')):
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
348 className = pkg + '.' + e[:-len('.class')]
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
349 result[className] = source
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
350 elif e == basename + '.class':
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
351 className = pkg + '.' + basename
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
352 result[className] = source
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
353 return result
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
354
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
355 def _init_packages_and_imports(self):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
356 if not hasattr(self, '_defined_java_packages'):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
357 packages = set()
8439
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
358 extendedPackages = set()
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
359 depPackages = set()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
360 for d in self.all_deps([], includeLibs=False, includeSelf=False):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
361 depPackages.update(d.defined_java_packages())
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
362 imports = set()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
363 importRe = re.compile(r'import\s+(?:static\s+)?([^;]+);')
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
364 for sourceDir in self.source_dirs():
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
365 for root, _, files in os.walk(sourceDir):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
366 javaSources = [name for name in files if name.endswith('.java')]
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
367 if len(javaSources) != 0:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
368 pkg = root[len(sourceDir) + 1:].replace(os.sep,'.')
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
369 if not pkg in depPackages:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
370 packages.add(pkg)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
371 else:
8439
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
372 # A project extends a package already defined by one of it dependencies
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
373 extendedPackages.add(pkg)
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
374 imports.add(pkg)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
375
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
376 for n in javaSources:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
377 with open(join(root, n)) as fp:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
378 content = fp.read()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
379 imports.update(importRe.findall(content))
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
380 self._defined_java_packages = frozenset(packages)
8439
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
381 self._extended_java_packages = frozenset(extendedPackages)
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
382
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
383 importedPackages = set()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
384 for imp in imports:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
385 name = imp
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
386 while not name in depPackages and len(name) > 0:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
387 lastDot = name.rfind('.')
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
388 if lastDot == -1:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
389 name = None
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
390 break
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
391 name = name[0:lastDot]
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
392 if name is not None:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
393 importedPackages.add(name)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
394 self._imported_java_packages = frozenset(importedPackages)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
395
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
396 def defined_java_packages(self):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
397 """Get the immutable set of Java packages defined by the Java sources of this project"""
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
398 self._init_packages_and_imports()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
399 return self._defined_java_packages
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
400
8439
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
401 def extended_java_packages(self):
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
402 """Get the immutable set of Java packages extended by the Java sources of this project"""
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
403 self._init_packages_and_imports()
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
404 return self._extended_java_packages
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
405
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
406 def imported_java_packages(self):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
407 """Get the immutable set of Java packages defined by other Java projects that are
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
408 imported by the Java sources of this project."""
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
409 self._init_packages_and_imports()
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
410 return self._imported_java_packages
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
411
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
412 def annotation_processors(self):
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
413 if not hasattr(self, '_annotationProcessors'):
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
414 ap = set()
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
415 if hasattr(self, '_declaredAnnotationProcessors'):
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
416 ap = set(self._declaredAnnotationProcessors)
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
417
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
418 # find dependencies that auto-inject themselves as annotation processors to all dependents
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
419 allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False)
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
420 for p in allDeps:
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
421 if hasattr(p, 'annotationProcessorForDependents') and p.annotationProcessorForDependents.lower() == 'true':
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
422 ap.add(p.name)
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
423 self._annotationProcessors = list(ap)
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
424 return self._annotationProcessors
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
425
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
426 class Library(Dependency):
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
427 def __init__(self, suite, name, path, mustExist, urls, sourcePath, sourceUrls):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
428 Dependency.__init__(self, suite, name)
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
429 self.path = path.replace('/', os.sep)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
430 self.urls = urls
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
431 self.mustExist = mustExist
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
432 self.sourcePath = sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
433 self.sourceUrls = sourceUrls
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
434 for url in urls:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
435 if url.endswith('/') != self.path.endswith(os.sep):
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
436 abort('Path for dependency directory must have a URL ending with "/": path=' + self.path + ' url=' + url)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
437
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
438 def get_path(self, resolve):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
439 path = self.path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
440 if not isabs(path):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
441 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
442 if resolve and self.mustExist and not exists(path):
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
443 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
444 print('Downloading ' + self.name + ' from ' + str(self.urls))
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
445 download(path, self.urls)
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
446 return path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
447
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
448 def get_source_path(self, resolve):
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
449 path = self.sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
450 if path is None:
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
451 return None
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
452 if not isabs(path):
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
453 path = join(self.suite.dir, path)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
454 if resolve and len(self.sourceUrls) != 0 and not exists(path):
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
455 print('Downloading sources for ' + self.name + ' from ' + str(self.sourceUrls))
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
456 download(path, self.sourceUrls)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
457 return path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
458
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
459 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
460 path = self.get_path(resolve)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
461 if exists(path) or not resolve:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
462 cp.append(path)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
463
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
464 class Suite:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
465 def __init__(self, d, primary):
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
466 self.dir = d
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
467 self.projects = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
468 self.libs = []
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
469 self.dists = []
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
470 self.includes = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
471 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
472 self.primary = primary
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
473 mxDir = join(d, 'mx')
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
474 self._load_env(mxDir)
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
475 self._load_commands(mxDir)
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
476 self._load_includes(mxDir)
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
477 self.name = d # re-initialized in _load_projects
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
478
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
479 def __str__(self):
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
480 return self.name
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
481
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
482 def _load_projects(self, mxDir):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
483 libsMap = dict()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
484 projsMap = dict()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
485 distsMap = dict()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
486 projectsFile = join(mxDir, 'projects')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
487 if not exists(projectsFile):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
488 return
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
489 with open(projectsFile) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
490 for line in f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
491 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
492 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
493 key, value = line.split('=', 1)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
494
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
495 parts = key.split('@')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
496
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
497 if len(parts) == 1:
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
498 if parts[0] != 'suite':
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
499 abort('Single part property must be "suite": ' + key)
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
500 self.name = value
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
501 continue
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
502 if len(parts) != 3:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
503 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
504 kind, name, attr = parts
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
505 if kind == 'project':
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
506 m = projsMap
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
507 elif kind == 'library':
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
508 m = libsMap
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
509 elif kind == 'distribution':
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
510 m = distsMap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
511 else:
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
512 abort('Property name does not start with "project@", "library@" or "distribution@": ' + key)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
513
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
514 attrs = m.get(name)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
515 if attrs is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
516 attrs = dict()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
517 m[name] = attrs
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
518 value = expandvars_in_property(value)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
519 attrs[attr] = value
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
520
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
521 def pop_list(attrs, name):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
522 v = attrs.pop(name, None)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
523 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
524 return []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
525 return [n.strip() for n in v.split(',')]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
526
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
527 for name, attrs in projsMap.iteritems():
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
528 srcDirs = pop_list(attrs, 'sourceDirs')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
529 deps = pop_list(attrs, 'dependencies')
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
530 ap = pop_list(attrs, 'annotationProcessors')
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
531 #deps += ap
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
532 javaCompliance = attrs.pop('javaCompliance', None)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
533 subDir = attrs.pop('subDir', None);
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
534 if subDir is None:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
535 d = join(self.dir, name)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
536 else:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
537 d = join(self.dir, subDir, name)
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
538 p = Project(self, name, srcDirs, deps, javaCompliance, d)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
539 p.checkstyleProj = attrs.pop('checkstyle', name)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
540 p.native = attrs.pop('native', '') == 'true'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
541 if not p.native and p.javaCompliance is None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
542 abort('javaCompliance property required for non-native project ' + name)
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
543 if len(ap) > 0:
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
544 p._declaredAnnotationProcessors = ap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
545 p.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
546 self.projects.append(p)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
547
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
548 for name, attrs in libsMap.iteritems():
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
549 path = attrs.pop('path')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
550 mustExist = attrs.pop('optional', 'false') != 'true'
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
551 urls = pop_list(attrs, 'urls')
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
552 sourcePath = attrs.pop('sourcePath', None)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
553 sourceUrls = pop_list(attrs, 'sourceUrls')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
554 l = Library(self, name, path, mustExist, urls, sourcePath, sourceUrls)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
555 l.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
556 self.libs.append(l)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
557
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
558 for name, attrs in distsMap.iteritems():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
559 path = attrs.pop('path')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
560 deps = pop_list(attrs, 'dependencies')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
561 d = Distribution(self, name, path, deps)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
562 d.__dict__.update(attrs)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
563 self.dists.append(d)
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
564
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
565 if self.name is None:
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
566 abort('Missing "suite=<name>" in ' + projectsFile)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
567
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
568 def _load_commands(self, mxDir):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
569 commands = join(mxDir, 'commands.py')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
570 if exists(commands):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
571 # temporarily extend the Python path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
572 sys.path.insert(0, mxDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
573 mod = __import__('commands')
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
574
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
575 self.commands = sys.modules.pop('commands')
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
576 sys.modules[join(mxDir, 'commands')] = self.commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
577
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
578 # revert the Python path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
579 del sys.path[0]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
580
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
581 if not hasattr(mod, 'mx_init'):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
582 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
583 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
584 self.mx_post_parse_cmd_line = mod.mx_post_parse_cmd_line
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
585
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
586 mod.mx_init()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
587 self.commands = mod
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
588
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
589 def _load_includes(self, mxDir):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
590 includes = join(mxDir, 'includes')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
591 if exists(includes):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
592 with open(includes) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
593 for line in f:
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
594 include = expandvars_in_property(line.strip())
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
595 self.includes.append(include)
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
596 _loadSuite(include, False)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
597
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
598 def _load_env(self, mxDir):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
599 e = join(mxDir, 'env')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
600 if exists(e):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
601 with open(e) as f:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
602 for line in f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
603 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
604 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
605 key, value = line.split('=', 1)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
606 os.environ[key.strip()] = expandvars_in_property(value.strip())
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
607
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
608 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
609 mxDir = join(self.dir, 'mx')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
610 self._load_projects(mxDir)
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
611 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
612 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
613 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
614 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir)
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
615 if not p.name in _opts.ignored_projects:
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
616 _projects[p.name] = p
4180
383c1272cd1f Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4178
diff changeset
617 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
618 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
619 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
620 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
621 _libs[l.name] = l
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
622 for d in self.dists:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
623 existing = _dists.get(l.name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
624 if existing is not None:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
625 abort('cannot redefine distribution ' + d.name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
626 _dists[d.name] = d
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
627 if hasattr(self, 'mx_post_parse_cmd_line'):
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
628 self.mx_post_parse_cmd_line(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
629
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
630 class XMLElement(xml.dom.minidom.Element):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
631 def writexml(self, writer, indent="", addindent="", newl=""):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
632 writer.write(indent+"<" + self.tagName)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
633
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
634 attrs = self._get_attributes()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
635 a_names = attrs.keys()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
636 a_names.sort()
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
637
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
638 for a_name in a_names:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
639 writer.write(" %s=\"" % a_name)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
640 xml.dom.minidom._write_data(writer, attrs[a_name].value)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
641 writer.write("\"")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
642 if self.childNodes:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
643 if not self.ownerDocument.padTextNodeWithoutSiblings and len(self.childNodes) == 1 and isinstance(self.childNodes[0], xml.dom.minidom.Text):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
644 # if the only child of an Element node is a Text node, then the
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
645 # text is printed without any indentation or new line padding
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
646 writer.write(">")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
647 self.childNodes[0].writexml(writer)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
648 writer.write("</%s>%s" % (self.tagName,newl))
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
649 else:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
650 writer.write(">%s"%(newl))
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
651 for node in self.childNodes:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
652 node.writexml(writer,indent+addindent,addindent,newl)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
653 writer.write("%s</%s>%s" % (indent,self.tagName,newl))
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
654 else:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
655 writer.write("/>%s"%(newl))
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
656
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
657 class XMLDoc(xml.dom.minidom.Document):
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
658
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
659 def __init__(self):
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
660 xml.dom.minidom.Document.__init__(self)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
661 self.current = self
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
662 self.padTextNodeWithoutSiblings = False
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
663
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
664 def createElement(self, tagName):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
665 # overwritten to create XMLElement
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
666 e = XMLElement(tagName)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
667 e.ownerDocument = self
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
668 return e
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
669
8302
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
670 def comment(self, txt):
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
671 self.current.appendChild(self.createComment(txt))
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
672
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
673 def open(self, tag, attributes={}, data=None):
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
674 element = self.createElement(tag)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
675 for key, value in attributes.items():
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
676 element.setAttribute(key, value)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
677 self.current.appendChild(element)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
678 self.current = element
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
679 if data is not None:
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
680 element.appendChild(self.createTextNode(data))
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
681 return self
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
682
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
683 def close(self, tag):
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
684 assert self.current != self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
685 assert tag == self.current.tagName, str(tag) + ' != ' + self.current.tagName
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
686 self.current = self.current.parentNode
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
687 return self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
688
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
689 def element(self, tag, attributes={}, data=None):
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
690 return self.open(tag, attributes, data).close(tag)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
691
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
692 def xml(self, indent='', newl='', escape=False, standalone=None):
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
693 assert self.current == self
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
694 result = self.toprettyxml(indent, newl, encoding="UTF-8")
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
695 if escape:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
696 entities = { '"': "&quot;", "'": "&apos;", '\n': '&#10;' }
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
697 result = xml.sax.saxutils.escape(result, entities)
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
698 if standalone is not None:
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
699 result = result.replace('encoding="UTF-8"?>', 'encoding="UTF-8" standalone="' + str(standalone) + '"?>')
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
700 return result
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
701
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
702 def get_os():
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
703 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
704 Get a canonical form of sys.platform.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
705 """
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
706 if sys.platform.startswith('darwin'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
707 return 'darwin'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
708 elif sys.platform.startswith('linux'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
709 return 'linux'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
710 elif sys.platform.startswith('sunos'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
711 return 'solaris'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
712 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
713 return 'windows'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
714 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
715 abort('Unknown operating system ' + sys.platform)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
716
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
717 def _loadSuite(d, primary=False):
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
718 mxDir = join(d, 'mx')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
719 if not exists(mxDir) or not isdir(mxDir):
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
720 return None
10058
440661cc7908 a suite should be registered in the global _suites map at most once
Doug Simon <doug.simon@oracle.com>
parents: 10043
diff changeset
721 if len([s for s in _suites.itervalues() if s.dir == d]) == 0:
440661cc7908 a suite should be registered in the global _suites map at most once
Doug Simon <doug.simon@oracle.com>
parents: 10043
diff changeset
722 s = Suite(d, primary)
440661cc7908 a suite should be registered in the global _suites map at most once
Doug Simon <doug.simon@oracle.com>
parents: 10043
diff changeset
723 _suites[s.name] = s
440661cc7908 a suite should be registered in the global _suites map at most once
Doug Simon <doug.simon@oracle.com>
parents: 10043
diff changeset
724 return s
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
725
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
726 def suites():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
727 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
728 Get the list of all loaded suites.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
729 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
730 return _suites.values()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
731
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
732 def suite(name, fatalIfMissing=True):
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
733 """
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
734 Get the suite for a given name.
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
735 """
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
736 s = _suites.get(name)
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
737 if s is None and fatalIfMissing:
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
738 abort('suite named ' + name + ' not found')
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
739 return s
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
740
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
741 def projects():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
742 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
743 Get the list of all loaded projects.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
744 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
745 return _projects.values()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
746
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
747 def annotation_processors():
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
748 """
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
749 Get the list of all loaded projects that define an annotation processor.
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
750 """
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
751 global _annotationProcessors
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
752 if _annotationProcessors is None:
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
753 ap = set()
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
754 for p in projects():
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
755 ap.update(p.annotation_processors())
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
756 _annotationProcessors = list(ap)
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
757 return _annotationProcessors
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
758
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
759 def distribution(name, fatalIfMissing=True):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
760 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
761 Get the distribution for a given name. This will abort if the named distribution does
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
762 not exist and 'fatalIfMissing' is true.
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
763 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
764 d = _dists.get(name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
765 if d is None and fatalIfMissing:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
766 abort('distribution named ' + name + ' not found')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
767 return d
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
768
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
769 def project(name, fatalIfMissing=True):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
770 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
771 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
772 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
773 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
774 p = _projects.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
775 if p is None and fatalIfMissing:
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
776 if name in _opts.ignored_projects:
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
777 abort('project named ' + name + ' is ignored')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
778 abort('project named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
779 return p
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
780
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
781 def library(name, fatalIfMissing=True):
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 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
784 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
785 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
786 l = _libs.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
787 if l is None and fatalIfMissing:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
788 abort('library named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
789 return l
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
790
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
791 def _as_classpath(deps, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
792 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
793 if _opts.cp_prefix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
794 cp = [_opts.cp_prefix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
795 for d in deps:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
796 d.append_to_classpath(cp, resolve)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
797 if _opts.cp_suffix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
798 cp += [_opts.cp_suffix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
799 return os.pathsep.join(cp)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
800
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
801 def classpath(names=None, resolve=True, includeSelf=True, includeBootClasspath=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
802 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
803 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
804 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
805 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
806 if names is None:
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
807 result = _as_classpath(sorted_deps(includeLibs=True), resolve)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
808 else:
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
809 deps = []
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
810 if isinstance(names, types.StringTypes):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
811 project(names).all_deps(deps, True, includeSelf)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
812 else:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
813 for n in names:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
814 project(n).all_deps(deps, True, includeSelf)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
815 result = _as_classpath(deps, resolve)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
816 if includeBootClasspath:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
817 result = os.pathsep.join([java().bootclasspath(), result])
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
818 return result
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
819
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
820 def classpath_walk(names=None, resolve=True, includeSelf=True, includeBootClasspath=False):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
821 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
822 Walks the resources available in a given classpath, yielding a tuple for each resource
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
823 where the first member of the tuple is a directory path or ZipFile object for a
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
824 classpath entry and the second member is the qualified path of the resource relative
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
825 to the classpath entry.
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
826 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
827 cp = classpath(names, resolve, includeSelf, includeBootClasspath)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
828 for entry in cp.split(os.pathsep):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
829 if not exists(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
830 continue
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
831 if isdir(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
832 for root, dirs, files in os.walk(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
833 for d in dirs:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
834 entryPath = join(root[len(entry) + 1:], d)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
835 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
836 for f in files:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
837 entryPath = join(root[len(entry) + 1:], f)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
838 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
839 elif entry.endswith('.jar') or entry.endswith('.zip'):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
840 with zipfile.ZipFile(entry, 'r') as zf:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
841 for zi in zf.infolist():
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
842 entryPath = zi.filename
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
843 yield zf, entryPath
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
844
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
845 def sorted_deps(projectNames=None, includeLibs=False, includeAnnotationProcessors=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
846 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
847 Gets projects and libraries sorted such that dependencies
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
848 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
849 true, libraries are omitted from the result.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
850 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
851 deps = []
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
852 if projectNames is None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
853 projects = _projects.values()
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
854 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
855 projects = [project(name) for name in projectNames]
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
856
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
857 for p in projects:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
858 p.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
859 return deps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
860
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
861 class ArgParser(ArgumentParser):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
862
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
863 # 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
864 def format_help(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
865 return ArgumentParser.format_help(self) + _format_commands()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
866
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
867
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
868 def __init__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
869 self.java_initialized = False
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
870 ArgumentParser.__init__(self, prog='mx')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
871
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
872 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output')
5091
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
873 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
874 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
875 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
876 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
877 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
878 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
879 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
880 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
881 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
882 self.add_argument('--java-home', help='JDK installation directory (must be JDK 6 or later)', metavar='<path>')
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
883 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[])
4239
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
884 if get_os() != 'windows':
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
885 # Time outs are (currently) implemented with Unix specific functionality
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
886 self.add_argument('--timeout', help='Timeout (in seconds) for command', type=int, default=0, metavar='<secs>')
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
887 self.add_argument('--ptimeout', help='Timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
888
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
889 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
890 if args is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
891 args = sys.argv[1:]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
892
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
893 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
894
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
895 opts = self.parse_args()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
896
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
897 # Give the timeout options a default value to avoid the need for hasattr() tests
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
898 opts.__dict__.setdefault('timeout', 0)
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
899 opts.__dict__.setdefault('ptimeout', 0)
4149
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
900
5091
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
901 if opts.very_verbose:
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
902 opts.verbose = True
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
903
4149
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
904 if opts.java_home is None:
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
905 opts.java_home = os.environ.get('JAVA_HOME')
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
906
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
907 if opts.java_home is None or opts.java_home == '':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
908 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
909
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
910 if opts.user_home is None or opts.user_home == '':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
911 abort('Could not find user home. Use --user-home option or ensure HOME environment variable is set.')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
912
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
913 os.environ['JAVA_HOME'] = opts.java_home
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
914 os.environ['HOME'] = opts.user_home
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
915
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
916 opts.ignored_projects = opts.ignored_projects + os.environ.get('IGNORED_PROJECTS', '').split(',')
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
917
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
918 commandAndArgs = opts.__dict__.pop('commandAndArgs')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
919 return opts, commandAndArgs
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
920
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
921 def _format_commands():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
922 msg = '\navailable commands:\n\n'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
923 for cmd in sorted(commands.iterkeys()):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
924 c, _ = commands[cmd][:2]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
925 doc = c.__doc__
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
926 if doc is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
927 doc = ''
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
928 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
929 return msg + '\n'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
930
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
931 def java():
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
932 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
933 Get a JavaConfig object containing Java commands launch details.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
934 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
935 assert _java is not None
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
936 return _java
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
937
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
938 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
939 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
940
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
941 def _kill_process_group(pid):
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
942 pgid = os.getpgid(pid)
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
943 try:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
944 os.killpg(pgid, signal.SIGKILL)
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
945 return True
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
946 except:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
947 log('Error killing subprocess ' + str(pgid) + ': ' + str(sys.exc_info()[1]))
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
948 return False
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
949
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
950 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
951 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
952 while True:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
953 try:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
954 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
955 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
956 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
957 continue
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
958 raise
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
959
4236
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
960 def _returncode(status):
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
961 if os.WIFSIGNALED(status):
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
962 return -os.WTERMSIG(status)
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
963 elif os.WIFEXITED(status):
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
964 return os.WEXITSTATUS(status)
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
965 else:
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
966 # Should never happen
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
967 raise RuntimeError("Unknown child exit status!")
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
968
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
969 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
970 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
971 while True:
4236
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
972 (pid, status) = _waitpid(process.pid)
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
973 if pid == process.pid:
4236
11383dafc318 Fixed bug in getting correct result code for a subprocess executed with a timeout.
Doug Simon <doug.simon@oracle.com>
parents: 4234
diff changeset
974 return _returncode(status)
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
975 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
976 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
977 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
978 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
979 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
980
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
981 # Makes the current subprocess accessible to the abort() function
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
982 # This is a tuple of the Popen object and args.
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
983 _currentSubprocess = None
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
984
4660
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
985 def waitOn(p):
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
986 if get_os() == 'windows':
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
987 # on windows use a poll loop, otherwise signal does not get handled
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
988 retcode = None
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
989 while retcode == None:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
990 retcode = p.poll()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
991 time.sleep(0.05)
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
992 else:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
993 retcode = p.wait()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
994 return retcode
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
995
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8633
diff changeset
996 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
997 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
998 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
999 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
1000 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
1001 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
1002 out and err if they are callable objects.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1003 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1004
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1005 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
1006 for arg in args:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1007 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1008
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1009 if env is None:
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1010 env = os.environ
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1011
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1012 if _opts.verbose:
5091
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1013 if _opts.very_verbose:
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1014 log('Environment variables:')
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1015 for key in sorted(env.keys()):
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1016 log(' ' + key + '=' + env[key])
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1017 log(' '.join(args))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1018
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1019 if timeout is None and _opts.ptimeout != 0:
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1020 timeout = _opts.ptimeout
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1021
4293
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
1022 global _currentSubprocess
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1023
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1024 try:
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1025 # On Unix, the new subprocess should be in a separate group so that a timeout alarm
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1026 # can use os.killpg() to kill the whole subprocess group
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1027 preexec_fn = None
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1028 creationflags = 0
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1029 if get_os() == 'windows':
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1030 creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1031 else:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1032 preexec_fn = os.setsid
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1033
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
1034 if not callable(out) and not callable(err) and timeout is None:
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1035 # The preexec_fn=os.setsid
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8633
diff changeset
1036 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1037 _currentSubprocess = (p, args)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1038 retcode = waitOn(p)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1039 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1040 def redirect(stream, f):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1041 for line in iter(stream.readline, ''):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1042 f(line)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1043 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
1044 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
1045 stderr=err if not callable(err) else subprocess.PIPE
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8633
diff changeset
1046 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1047 _currentSubprocess = (p, args)
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
1048 if callable(out):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1049 t = Thread(target=redirect, args=(p.stdout, out))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1050 t.daemon = True # thread dies with the program
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1051 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
1052 if callable(err):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1053 t = Thread(target=redirect, args=(p.stderr, err))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1054 t.daemon = True # thread dies with the program
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1055 t.start()
4161
8c507a8dd6a4 Interpret '--timeout 0' correctly (i.e. as no timeout).
Doug Simon <doug.simon@oracle.com>
parents: 4158
diff changeset
1056 if timeout is None or timeout == 0:
4660
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1057 retcode = waitOn(p)
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1058 else:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1059 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
1060 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
1061 retcode = _waitWithTimeout(p, args, timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1062 except OSError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1063 log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1064 if _opts.verbose:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1065 raise e
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1066 abort(e.errno)
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1067 except KeyboardInterrupt:
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1068 abort(1)
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1069 finally:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1070 _currentSubprocess = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1071
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1072 if retcode and nonZeroIsFatal:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1073 if _opts.verbose:
5091
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1074 if _opts.very_verbose:
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1075 raise subprocess.CalledProcessError(retcode, ' '.join(args))
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1076 else:
54819cdcca7f Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
Doug Simon <doug.simon@oracle.com>
parents: 5072
diff changeset
1077 log('[exit code: ' + str(retcode)+ ']')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1078 abort(retcode)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1079
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1080 return retcode
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1081
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1082 def exe_suffix(name):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1083 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1084 Gets the platform specific suffix for an executable
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1085 """
4258
8d2c14f722ac mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents: 4257
diff changeset
1086 if get_os() == 'windows':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1087 return name + '.exe'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1088 return name
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1089
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1090 def lib_suffix(name):
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1091 """
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1092 Gets the platform specific suffix for a library
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1093 """
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1094 os = get_os();
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1095 if os == 'windows':
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1096 return name + '.dll'
5189
6fbf12b8e572 automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents: 5171
diff changeset
1097 if os == 'linux' or os == 'solaris':
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1098 return name + '.so'
5189
6fbf12b8e572 automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents: 5171
diff changeset
1099 if os == 'darwin':
6fbf12b8e572 automated download of hsdis lib if PrintAssembly option is used; added support for hsdis on the Mac
Doug Simon <doug.simon@oracle.com>
parents: 5171
diff changeset
1100 return name + '.dylib'
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1101 return name
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1102
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1103 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1104 A JavaCompliance simplifies comparing Java compliance values extracted from a JDK version string.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1105 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1106 class JavaCompliance:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1107 def __init__(self, ver):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1108 m = re.match('1\.(\d+).*', ver)
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1109 assert m is not None, 'not a recognized version string: ' + ver
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1110 self.value = int(m.group(1))
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1111
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1112 def __str__ (self):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1113 return '1.' + str(self.value)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1114
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1115 def __cmp__ (self, other):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1116 if isinstance(other, types.StringType):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1117 other = JavaCompliance(other)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1118
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1119 return cmp(self.value, other.value)
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1120
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1121 """
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1122 A Java version as defined in JSR-56
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1123 """
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1124 class JavaVersion:
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1125 def __init__(self, versionString):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1126 validChar = '[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
8391
d1d486c03e8a Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8302
diff changeset
1127 separator = '[.\-_]'
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1128 m = re.match(validChar + '+(' + separator + validChar + '+)*', versionString)
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1129 assert m is not None, 'not a recognized version string: ' + versionString
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1130 self.versionString = versionString;
8391
d1d486c03e8a Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8302
diff changeset
1131 self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)]
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1132
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1133 def __str__(self):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1134 return self.versionString
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1135
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1136 def __cmp__(self, other):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1137 return cmp(self.parts, other.parts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1138
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1139 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1140 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
1141 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1142 class JavaConfig:
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1143 def __init__(self, opts):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1144 self.jdk = opts.java_home
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1145 self.debug_port = opts.java_dbg_port
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1146 self.jar = exe_suffix(join(self.jdk, 'bin', 'jar'))
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1147 self.java = exe_suffix(join(self.jdk, 'bin', 'java'))
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1148 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac'))
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1149 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap'))
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
1150 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc'))
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1151 self._bootclasspath = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1152
4257
32b8274f52ad Made 'mx ideinit' resolve library dependencies eagerly as well as put absolute paths into the generated Eclipse project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4252
diff changeset
1153 if not exists(self.java):
32b8274f52ad Made 'mx ideinit' resolve library dependencies eagerly as well as put absolute paths into the generated Eclipse project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4252
diff changeset
1154 abort('Java launcher derived from JAVA_HOME does not exist: ' + self.java)
32b8274f52ad Made 'mx ideinit' resolve library dependencies eagerly as well as put absolute paths into the generated Eclipse project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4252
diff changeset
1155
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1156 def delAtAndSplit(s):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1157 return shlex.split(s.lstrip('@'))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1158
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1159 self.java_args = delAtAndSplit(_opts.java_args)
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1160 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
1161 self.java_args_sfx = sum(map(delAtAndSplit, _opts.java_args_sfx), [])
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1162
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1163 # 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
1164 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1165 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
1166 self.java_args = ['-d64'] + self.java_args
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1167 except subprocess.CalledProcessError as e:
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1168 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1169 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
1170 except subprocess.CalledProcessError as e:
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1171 print e.output
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1172 abort(e.returncode)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1173
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1174 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
1175 assert output[1] == 'version'
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1176 self.version = JavaVersion(output[2].strip('"'))
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1177 self.javaCompliance = JavaCompliance(self.version.versionString)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1178
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1179 if self.debug_port is not None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1180 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1181
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1182 def format_cmd(self, args):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1183 return [self.java] + self.java_args_pfx + self.java_args + self.java_args_sfx + args
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1184
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1185 def bootclasspath(self):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1186 if self._bootclasspath is None:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1187 tmpDir = tempfile.mkdtemp()
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1188 try:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1189 src = join(tmpDir, 'bootclasspath.java')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1190 with open(src, 'w') as fp:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1191 print >> fp, """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1192 public class bootclasspath {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1193 public static void main(String[] args) {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1194 String s = System.getProperty("sun.boot.class.path");
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1195 if (s != null) {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1196 System.out.println(s);
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1197 }
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1198 }
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1199 }"""
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1200 subprocess.check_call([self.javac, '-d', tmpDir, src])
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1201 self._bootclasspath = subprocess.check_output([self.java, '-cp', tmpDir, 'bootclasspath'])
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1202 finally:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1203 shutil.rmtree(tmpDir)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1204 return self._bootclasspath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1205
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1206 def check_get_env(key):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1207 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1208 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
1209 """
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
1210 value = get_env(key)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1211 if value is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1212 abort('Required environment variable ' + key + ' must be set')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1213 return value
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1214
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
1215 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
1216 """
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
1217 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
1218 """
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
1219 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
1220 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
1221
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1222 def log(msg=None):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1223 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1224 Write a message to the console.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1225 All script output goes through this method thus allowing a subclass
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1226 to redirect it.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1227 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1228 if msg is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1229 print
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1230 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1231 print msg
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1232
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1233 def expand_project_in_class_path_arg(cpArg):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1234 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1235 for part in cpArg.split(os.pathsep):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1236 if part.startswith('@'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1237 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
1238 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1239 cp.append(part)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1240 return os.pathsep.join(cp)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1241
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1242 def expand_project_in_args(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1243 for i in range(len(args)):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1244 if args[i] == '-cp' or args[i] == '-classpath':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1245 if i + 1 < len(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1246 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
1247 return
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1248
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1249
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1250 def gmake_cmd():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1251 for a in ['make', 'gmake', 'gnumake']:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1252 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1253 output = subprocess.check_output([a, '--version'])
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1254 if 'GNU' in output:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1255 return a;
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1256 except:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1257 pass
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1258 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
1259
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1260 def expandvars_in_property(value):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1261 result = expandvars(value)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1262 if '$' in result or '%' in result:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1263 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
1264 return result
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1265
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1266
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1267 def abort(codeOrMessage):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1268 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1269 Aborts the program with a SystemExit exception.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1270 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
1271 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
1272 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
1273 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1274
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1275 #import traceback
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1276 #traceback.print_stack()
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1277 currentSubprocess = _currentSubprocess
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1278 if currentSubprocess is not None:
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1279 p, _ = currentSubprocess
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1280 if get_os() == 'windows':
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1281 p.kill()
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1282 else:
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1283 _kill_process_group(p.pid)
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1284
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1285 raise SystemExit(codeOrMessage)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1286
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1287 def download(path, urls, verbose=False):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1288 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1289 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
1290 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
1291 is written to the file indicated by 'path'.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1292 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1293 d = dirname(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1294 if d != '' and not exists(d):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1295 os.makedirs(d)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1296
4188
148fa38782e8 Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents: 4186
diff changeset
1297 # 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
1298 myDir = dirname(__file__)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1299
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1300 if not path.endswith(os.sep):
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1301 javaSource = join(myDir, 'URLConnectionDownload.java')
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1302 javaClass = join(myDir, 'URLConnectionDownload.class')
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1303 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1304 subprocess.check_call([java().javac, '-d', myDir, javaSource])
7787
2865133eeef2 mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7778
diff changeset
1305 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0:
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1306 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1307
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1308 def url_open(url):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1309 userAgent = 'Mozilla/5.0 (compatible)'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1310 headers = { 'User-Agent' : userAgent }
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1311 req = urllib2.Request(url, headers=headers)
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1312 return urllib2.urlopen(req)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1313
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1314 for url in urls:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1315 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1316 if (verbose):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1317 log('Downloading ' + url + ' to ' + path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1318 if url.startswith('zip:') or url.startswith('jar:'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1319 i = url.find('!/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1320 if i == -1:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1321 abort('Zip or jar URL does not contain "!/": ' + url)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1322 url, _, entry = url[len('zip:'):].partition('!/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1323 with contextlib.closing(url_open(url)) as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1324 data = f.read()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1325 zipdata = StringIO.StringIO(f.read())
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1326
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1327 zf = zipfile.ZipFile(zipdata, 'r')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1328 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
1329 with open(path, 'wb') as f:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1330 f.write(data)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1331 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1332 with contextlib.closing(url_open(url)) as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1333 data = f.read()
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1334 if path.endswith(os.sep):
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1335 # Scrape directory listing for relative URLs
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1336 hrefs = re.findall(r' href="([^"]*)"', data)
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1337 if len(hrefs) != 0:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1338 for href in hrefs:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1339 if not '/' in href:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1340 download(join(path, href), [url + href], verbose)
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1341 else:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1342 log('no locals hrefs scraped from ' + url)
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1343 else:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1344 with open(path, 'wb') as f:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1345 f.write(data)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1346 return
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1347 except IOError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1348 log('Error reading from ' + url + ': ' + str(e))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1349 except zipfile.BadZipfile as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1350 log('Error in zip file downloaded from ' + url + ': ' + str(e))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1351
4188
148fa38782e8 Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents: 4186
diff changeset
1352 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
1353 '\n '.join(urls) + '\n\nPlease use a web browser to do the download manually')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1354
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1355 def update_file(path, content):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1356 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1357 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
1358 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
1359 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1360 existed = exists(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1361 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1362 old = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1363 if existed:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1364 with open(path, 'rb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1365 old = f.read()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1366
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1367 if old == content:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1368 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1369
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1370 with open(path, 'wb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1371 f.write(content)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1372
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1373 log(('modified ' if existed else 'created ') + path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1374 return True;
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1375 except IOError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1376 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
1377
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1378 # Builtin commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1379
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1380 def build(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1381 """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
1382
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1383 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
1384 and linkers for the various source code types."""
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1385
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1386 suppliedParser = parser is not None
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1387 if not suppliedParser:
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1388 parser = ArgumentParser(prog='mx build')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1389
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1390 javaCompliance = java().javaCompliance
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1391
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1392 defaultEcjPath = join(_mainSuite.dir, 'mx', 'ecj.jar')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1393
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1394 parser = parser if parser is not None else ArgumentParser(prog='mx build')
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5219
diff changeset
1395 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1396 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output')
9002
7844a36d0216 use a project's explicit Java compliance level instead of --source option to mx build command
Doug Simon <doug.simon@oracle.com>
parents: 8991
diff changeset
1397 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one', default=str(javaCompliance))
4147
55376d8953a6 Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents: 4145
diff changeset
1398 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1399 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)')
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1400 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)')
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1401 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
1402 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects')
8447
b6b9ab1fde62 removed support for using the Eclipse batch compiler bundled with Eclipse - depending on the version, it has bugs with respect to annotation processing
Doug Simon <doug.simon@oracle.com>
parents: 8439
diff changeset
1403 parser.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>')
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1404 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1405
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1406 if suppliedParser:
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4227
diff changeset
1407 parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1408
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1409 args = parser.parse_args(args)
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
1410
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1411 jdtJar = None
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1412 if args.jdt is not None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1413 if args.jdt.endswith('.jar'):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1414 jdtJar=args.jdt
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1415 if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath):
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1416 # Silently ignore JDT if default location is used but not ecj.jar exists there
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1417 jdtJar = None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1418
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1419 built = set()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1420
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1421 projects = None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1422 if args.projects is not None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1423 projects = args.projects.split(',')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1424
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1425 if args.only is not None:
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1426 sortedProjects = [project(name) for name in args.only.split(',')]
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1427 else:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1428 sortedProjects = sorted_deps(projects, includeAnnotationProcessors=True)
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1429
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1430 for p in sortedProjects:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1431 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1432 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1433 log('Calling GNU make {0}...'.format(p.dir))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1434
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1435 if args.clean:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1436 run([gmake_cmd(), 'clean'], cwd=p.dir)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1437
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1438 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
1439 built.add(p.name)
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1440 continue
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1441 else:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1442 if not args.java:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1443 continue
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
1444 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
1445 continue
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1446
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1447 # skip building this Java project if its Java compliance level is "higher" than the configured JDK
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1448 if javaCompliance < p.javaCompliance:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1449 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, p.javaCompliance))
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1450 continue
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1451
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1452 outputDir = p.output_dir()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1453 if exists(outputDir):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1454 if args.clean:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1455 log('Cleaning {0}...'.format(outputDir))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1456 shutil.rmtree(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1457 os.mkdir(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1458 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1459 os.mkdir(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1460
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
1461 cp = classpath(p.name, includeSelf=True)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1462 sourceDirs = p.source_dirs()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1463 mustBuild = args.force
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1464 if not mustBuild:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1465 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
1466 if dep.name in built:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1467 mustBuild = True
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1468
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1469 jasminAvailable = None
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1470 javafilelist = []
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1471 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1472 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
1473 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
1474 javafilelist += javafiles
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1475
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1476 # Copy all non Java resources or assemble Jasmin files
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1477 nonjavafilelist = [join(root, name) for name in files if not name.endswith('.java')]
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1478 for src in nonjavafilelist:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1479 if src.endswith('.jasm'):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1480 className = None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1481 with open(src) as f:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1482 for line in f:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1483 if line.startswith('.class '):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1484 className = line.split()[-1]
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1485 break
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1486
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1487 if className is not None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1488 jasminOutputDir = p.jasmin_output_dir()
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1489 classFile = join(jasminOutputDir, className.replace('/', os.sep) + '.class')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1490 if exists(dirname(classFile)) and (not exists(classFile) or os.path.getmtime(classFile) < os.path.getmtime(src)):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1491 if jasminAvailable is None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1492 try:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1493 with open(os.devnull) as devnull:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1494 subprocess.call('jasmin', stdout=devnull, stderr=subprocess.STDOUT)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1495 jasminAvailable = True
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1496 except OSError:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1497 jasminAvailable = False
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1498
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1499 if jasminAvailable:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1500 log('Assembling Jasmin file ' + src)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1501 run(['jasmin', '-d', jasminOutputDir, src])
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1502 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1503 log('The jasmin executable could not be found - skipping ' + src)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1504 with file(classFile, 'a'):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1505 os.utime(classFile, None)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1506
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1507 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1508 log('could not file .class directive in Jasmin source: ' + src)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1509 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1510 dst = join(outputDir, src[len(sourceDir) + 1:])
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1511 if not exists(dirname(dst)):
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1512 os.makedirs(dirname(dst))
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
1513 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)):
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1514 shutil.copyfile(src, dst)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1515
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1516 if not mustBuild:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1517 for javafile in javafiles:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1518 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
1519 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
1520 mustBuild = True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1521 break
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1522
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1523 if not mustBuild:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1524 log('[all class files for {0} are up to date - skipping]'.format(p.name))
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1525 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1526
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1527 if len(javafilelist) == 0:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1528 log('[no Java sources for {0} - skipping]'.format(p.name))
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1529 continue
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1530
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1531 built.add(p.name)
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1532
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1533 argfileName = join(p.dir, 'javafilelist.txt')
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1534 argfile = open(argfileName, 'wb')
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1535 argfile.write('\n'.join(javafilelist))
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1536 argfile.close()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1537
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1538 javacArgs = []
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1539 if java().debug_port is not None:
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1540 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1541
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
1542 ap = p.annotation_processors()
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
1543 if len(ap) > 0:
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
1544 processorPath = classpath(ap, resolve=True)
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1545 genDir = p.source_gen_dir();
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1546 if exists(genDir):
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1547 shutil.rmtree(genDir)
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1548 os.mkdir(genDir)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1549 javacArgs += ['-processorpath', join(processorPath), '-s', genDir]
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1550 else:
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1551 javacArgs += ['-proc:none']
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1552
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1553 toBeDeleted = [argfileName]
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1554 try:
9002
7844a36d0216 use a project's explicit Java compliance level instead of --source option to mx build command
Doug Simon <doug.simon@oracle.com>
parents: 8991
diff changeset
1555 compliance = str(p.javaCompliance) if p.javaCompliance is not None else args.compliance
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1556 if jdtJar is None:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1557 log('Compiling Java sources for {0} with javac...'.format(p.name))
9002
7844a36d0216 use a project's explicit Java compliance level instead of --source option to mx build command
Doug Simon <doug.simon@oracle.com>
parents: 8991
diff changeset
1558 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-classpath', cp, '-d', outputDir] + javacArgs + ['@' + argfile.name]
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1559 if not args.warnAPI:
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
1560 javacCmd.append('-XDignore.symbol.file')
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
1561 run(javacCmd)
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1562 else:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1563 log('Compiling Java sources for {0} with JDT...'.format(p.name))
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1564 jdtArgs = [java().java, '-Xmx1g', '-jar', jdtJar,
9002
7844a36d0216 use a project's explicit Java compliance level instead of --source option to mx build command
Doug Simon <doug.simon@oracle.com>
parents: 8991
diff changeset
1565 '-' + compliance,
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1566 '-cp', cp, '-g', '-enableJavadoc',
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1567 '-d', outputDir] + javacArgs
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1568 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
7787
2865133eeef2 mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7778
diff changeset
1569 rootJdtProperties = join(p.suite.dir, 'mx', 'eclipse-settings', 'org.eclipse.jdt.core.prefs')
2865133eeef2 mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7778
diff changeset
1570 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties):
5072
f6503609a12d Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents: 5071
diff changeset
1571 # Try to fix a missing properties file by running eclipseinit
7293
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
1572 eclipseinit([], buildProcessorJars=False)
5072
f6503609a12d Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents: 5071
diff changeset
1573 if not exists(jdtProperties):
f6503609a12d Made the Eclipse properties be automatically generated if they don't exist when building with the Eclipse batch compiler.
Doug Simon <doug.simon@oracle.com>
parents: 5071
diff changeset
1574 log('JDT properties file {0} not found'.format(jdtProperties))
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1575 else:
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1576 # convert all warnings to errors
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1577 if args.jdt_warning_as_error:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1578 jdtPropertiesTmp = jdtProperties + '.tmp'
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1579 with open(jdtProperties) as fp:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1580 content = fp.read().replace('=warning', '=error')
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1581 with open(jdtPropertiesTmp, 'w') as fp:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1582 fp.write(content)
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1583 toBeDeleted.append(jdtPropertiesTmp)
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1584 jdtArgs += ['-properties', jdtPropertiesTmp]
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1585 else:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1586 jdtArgs += ['-properties', jdtProperties]
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1587 jdtArgs.append('@' + argfile.name)
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1588 run(jdtArgs)
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1589 finally:
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1590 for n in toBeDeleted:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
1591 os.remove(n)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1592
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1593 for dist in _dists.values():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1594 archive(['@' + dist.name])
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1595
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1596 if suppliedParser:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1597 return args
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1598 return None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1599
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1600 def eclipseformat(args):
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1601 """run the Eclipse Code Formatter on the Java sources
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1602
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1603 The exit code 1 denotes that at least one file was modified."""
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1604
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1605 parser = ArgumentParser(prog='mx eclipseformat')
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1606 parser.add_argument('-e', '--eclipse-exe', help='location of the Eclipse executable')
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1607 parser.add_argument('-C', '--no-backup', action='store_false', dest='backup', help='do not save backup of modified files')
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1608 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)')
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1609
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1610 args = parser.parse_args(args)
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1611 if args.eclipse_exe is None:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1612 args.eclipse_exe = os.environ.get('ECLIPSE_EXE')
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1613 if args.eclipse_exe is None:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1614 abort('Could not find Eclipse executable. Use -e option or ensure ECLIPSE_EXE environment variable is set.')
8991
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1615
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1616 # Maybe an Eclipse installation dir was specified - look for the executable in it
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1617 if join(args.eclipse_exe, exe_suffix('eclipse')):
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1618 args.eclipse_exe = join(args.eclipse_exe, exe_suffix('eclipse'))
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1619
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1620 if not os.path.isfile(args.eclipse_exe) or not os.access(args.eclipse_exe, os.X_OK):
096725f4da58 the -e option to the eclipseformat can now also accept an Eclipse installation directory
Doug Simon <doug.simon@oracle.com>
parents: 8958
diff changeset
1621 abort('Not an executable file: ' + args.eclipse_exe)
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1622
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1623 eclipseinit([], buildProcessorJars=False)
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1624
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1625 # build list of projects to be processed
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1626 projects = sorted_deps()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1627 if args.projects is not None:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1628 projects = [project(name) for name in args.projects.split(',')]
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1629
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1630 class Batch:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1631 def __init__(self, settingsFile):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1632 self.path = settingsFile
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1633 self.javafiles = list()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1634
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1635 def settings(self):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1636 with open(self.path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1637 return fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1638
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1639 class FileInfo:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1640 def __init__(self, path):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1641 self.path = path
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1642 with open(path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1643 self.content = fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1644 self.times = (os.path.getatime(path), os.path.getmtime(path))
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1645
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1646 def update(self):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1647 with open(self.path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1648 content = fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1649 if self.content != content:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1650 self.content = content
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1651 return True
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1652 os.utime(self.path, self.times)
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1653
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1654 modified = list()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1655 batches = dict() # all sources with the same formatting settings are formatted together
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1656 for p in projects:
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1657 if p.native:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1658 continue
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1659 sourceDirs = p.source_dirs()
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1660
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1661 batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs'))
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1662
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1663 if not exists(batch.path):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1664 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path))
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1665 continue
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1666
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1667 for sourceDir in sourceDirs:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1668 for root, _, files in os.walk(sourceDir):
7532
780269e56ddd eclipseformat is also applied to package-info.java files
Doug Simon <doug.simon@oracle.com>
parents: 7528
diff changeset
1669 for f in [join(root, name) for name in files if name.endswith('.java')]:
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1670 batch.javafiles.append(FileInfo(f))
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1671 if len(batch.javafiles) == 0:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1672 log('[no Java sources in {0} - skipping]'.format(p.name))
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1673 continue
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1674
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1675 res = batches.setdefault(batch.settings(), batch)
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1676 if res is not batch:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1677 res.javafiles = res.javafiles + batch.javafiles
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1678
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1679 for batch in batches.itervalues():
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1680 run([args.eclipse_exe, '-nosplash', '-application', 'org.eclipse.jdt.core.JavaCodeFormatter', '-config', batch.path] + [f.path for f in batch.javafiles])
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1681 for fi in batch.javafiles:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1682 if fi.update():
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1683 modified.append(fi)
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1684
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1685 log('{0} files were modified'.format(len(modified)))
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1686 if len(modified) != 0:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1687 if args.backup:
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1688 backup = os.path.abspath('eclipseformat.backup.zip')
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1689 arcbase = _mainSuite.dir
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1690 zf = zipfile.ZipFile(backup, 'w', zipfile.ZIP_DEFLATED)
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1691 for fi in modified:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1692 arcname = os.path.relpath(fi.path, arcbase).replace(os.sep, '/')
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
1693 zf.writestr(arcname, fi.content)
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1694 zf.close()
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1695 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup))
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1696 return 1
7533
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7532
diff changeset
1697 return 0
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1698
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1699 def processorjars():
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1700
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1701 projs = set()
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1702 for p in sorted_deps():
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1703 if _isAnnotationProcessorDependency(p):
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1704 projs.add(p)
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1705
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1706 if len(projs) < 0:
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1707 return
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
1708
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1709 pnames = [p.name for p in projs]
7925
c7d7d9936809 use zipfile module instead of an external call to jar for creating jar files from projects
Doug Simon <doug.simon@oracle.com>
parents: 7918
diff changeset
1710 build(['--projects', ",".join(pnames)])
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1711 archive(pnames)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1712
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1713 def archive(args):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1714 """create jar files for projects and distributions"""
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1715 parser = ArgumentParser(prog='mx archive');
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1716 parser.add_argument('names', nargs=REMAINDER, metavar='[<project>|@<distribution>]...')
7925
c7d7d9936809 use zipfile module instead of an external call to jar for creating jar files from projects
Doug Simon <doug.simon@oracle.com>
parents: 7918
diff changeset
1717 args = parser.parse_args(args)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1718
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1719 for name in args.names:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1720 if name.startswith('@'):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1721 dname = name[1:]
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1722 d = distribution(dname)
8183
4b11a0983557 fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents: 8182
diff changeset
1723 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
8457
b27261747964 mx: merge provider configuration files in distribution jars
Roland Schatz <roland.schatz@oracle.com>
parents: 8447
diff changeset
1724 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
8585
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1725 try:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1726 zf = zipfile.ZipFile(tmp, 'w')
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1727 for p in sorted_deps(d.deps):
9847
931f9ced42ad omit projects from distributions where the project's Java compliance level is too high
Doug Simon <doug.simon@oracle.com>
parents: 9826
diff changeset
1728 # skip a Java project if its Java compliance level is "higher" than the configured JDK
931f9ced42ad omit projects from distributions where the project's Java compliance level is too high
Doug Simon <doug.simon@oracle.com>
parents: 9826
diff changeset
1729 if java().javaCompliance < p.javaCompliance:
931f9ced42ad omit projects from distributions where the project's Java compliance level is too high
Doug Simon <doug.simon@oracle.com>
parents: 9826
diff changeset
1730 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path))
931f9ced42ad omit projects from distributions where the project's Java compliance level is too high
Doug Simon <doug.simon@oracle.com>
parents: 9826
diff changeset
1731 continue
931f9ced42ad omit projects from distributions where the project's Java compliance level is too high
Doug Simon <doug.simon@oracle.com>
parents: 9826
diff changeset
1732
8585
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1733 outputDir = p.output_dir()
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1734 for root, _, files in os.walk(outputDir):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1735 relpath = root[len(outputDir) + 1:]
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1736 if relpath == join('META-INF', 'services'):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1737 for f in files:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1738 with open(join(services, f), 'a') as outfile:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1739 with open(join(root, f), 'r') as infile:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1740 for line in infile:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1741 outfile.write(line)
9144
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1742 elif relpath == join('META-INF', 'providers'):
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1743 for f in files:
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1744 with open(join(root, f), 'r') as infile:
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1745 for line in infile:
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1746 with open(join(services, line.strip()), 'a') as outfile:
025448743177 mx: generate services files from provider descriptions
Roland Schatz <roland.schatz@oracle.com>
parents: 9009
diff changeset
1747 outfile.write(f + '\n')
8585
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1748 else:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1749 for f in files:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1750 arcname = join(relpath, f).replace(os.sep, '/')
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1751 zf.write(join(root, f), arcname)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1752 for f in os.listdir(services):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1753 arcname = join('META-INF', 'services', f).replace(os.sep, '/')
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1754 zf.write(join(services, f), arcname)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1755 zf.close()
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1756 os.close(fd)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1757 shutil.rmtree(services)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1758 # Atomic on Unix
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1759 shutil.move(tmp, d.path)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1760 #print time.time(), 'move:', tmp, '->', d.path
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1761 d.notify_updated()
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1762 finally:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1763 if exists(tmp):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1764 os.remove(tmp)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1765 if exists(services):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1766 shutil.rmtree(services)
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8131
diff changeset
1767
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1768 else:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1769 p = project(name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1770 outputDir = p.output_dir()
8183
4b11a0983557 fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents: 8182
diff changeset
1771 fd, tmp = tempfile.mkstemp(suffix='', prefix=p.name, dir=p.dir)
8585
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1772 try:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1773 zf = zipfile.ZipFile(tmp, 'w')
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1774 for root, _, files in os.walk(outputDir):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1775 for f in files:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1776 relpath = root[len(outputDir) + 1:]
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1777 arcname = join(relpath, f).replace(os.sep, '/')
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1778 zf.write(join(root, f), arcname)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1779 zf.close()
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1780 os.close(fd)
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1781 # Atomic on Unix
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1782 shutil.move(tmp, join(p.dir, p.name + '.jar'))
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1783 finally:
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1784 if exists(tmp):
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
1785 os.remove(tmp)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
1786
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1787 def canonicalizeprojects(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1788 """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
1789
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1790 The exit code of this command reflects how many files were updated."""
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1791
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1792 changedFiles = 0
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1793 for s in suites():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1794 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
1795 if not exists(projectsFile):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1796 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1797 with open(projectsFile) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1798 out = StringIO.StringIO()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1799 pattern = re.compile('project@([^@]+)@dependencies=.*')
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1800 lineNo = 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1801 for line in f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1802 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1803 m = pattern.match(line)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1804 if m is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1805 out.write(line + '\n')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1806 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1807 p = project(m.group(1))
6533
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
1808
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
1809 for pkg in p.defined_java_packages():
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
1810 if not pkg.startswith(p.name):
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
1811 abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg))
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
1812
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1813 ignoredDeps = set([name for name in p.deps if project(name, False) is not None])
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1814 for pkg in p.imported_java_packages():
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1815 for name in p.deps:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1816 dep = project(name, False)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1817 if dep is None:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1818 ignoredDeps.discard(name)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1819 else:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1820 if pkg in dep.defined_java_packages():
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1821 ignoredDeps.discard(name)
8439
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
1822 if pkg in dep.extended_java_packages():
39c7142e7aef added support for projects that extend a package defined in another project when canonicalizing projects
Doug Simon <doug.simon@oracle.com>
parents: 8391
diff changeset
1823 ignoredDeps.discard(name)
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1824 if len(ignoredDeps) != 0:
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1825 candidates = set();
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1826 # Compute dependencies based on projects required by p
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1827 for d in sorted_deps():
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1828 if not d.defined_java_packages().isdisjoint(p.imported_java_packages()):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1829 candidates.add(d)
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1830 # Remove non-canonical candidates
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1831 for c in list(candidates):
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1832 candidates.difference_update(c.all_deps([], False, False))
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1833 candidates = [d.name for d in candidates]
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1834
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1835 abort('{0}:{1}: {2} does not use any packages defined in these projects: {3}\nComputed project dependencies: {4}'.format(
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1836 projectsFile, lineNo, p, ', '.join(ignoredDeps), ','.join(candidates)))
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1837
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1838 out.write('project@' + m.group(1) + '@dependencies=' + ','.join(p.canonical_deps()) + '\n')
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
1839 lineNo = lineNo + 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1840 content = out.getvalue()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1841 if update_file(projectsFile, content):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1842 changedFiles += 1
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1843 return changedFiles;
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1844
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1845 def checkstyle(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1846 """run Checkstyle on the Java sources
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1847
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1848 Run Checkstyle over the Java sources. Any errors or warnings
6284
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
1849 produced by Checkstyle result in a non-zero exit code."""
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1850
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1851 parser = ArgumentParser(prog='mx checkstyle')
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1852
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1853 parser.add_argument('-f', action='store_true', dest='force', help='force checking (disables timestamp checking)')
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1854 args = parser.parse_args(args)
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1855
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1856 totalErrors = 0
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1857 for p in sorted_deps():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1858 if p.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1859 continue
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1860 sourceDirs = p.source_dirs()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1861 dotCheckstyle = join(p.dir, '.checkstyle')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1862
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1863 if not exists(dotCheckstyle):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1864 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1865
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1866 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1867 javafilelist = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1868 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
1869 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
1870 if len(javafilelist) == 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1871 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
1872 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1873
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
1874 timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp')
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
1875 if not exists(dirname(timestampFile)):
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
1876 os.makedirs(dirname(timestampFile))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1877 mustCheck = False
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1878 if not args.force and exists(timestampFile):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1879 timestamp = os.path.getmtime(timestampFile)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1880 for f in javafilelist:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1881 if os.path.getmtime(f) > timestamp:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1882 mustCheck = True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1883 break
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1884 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1885 mustCheck = True
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1886
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1887 if not mustCheck:
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1888 if _opts.verbose:
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1889 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
1890 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1891
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1892 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1893 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
1894 configLocation = localCheckConfig.getAttribute('location')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1895 configType = localCheckConfig.getAttribute('type')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1896 if configType == 'project':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1897 # Eclipse plugin "Project Relative Configuration" format:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1898 #
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1899 # '/<project_name>/<suffix>'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1900 #
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1901 if configLocation.startswith('/'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1902 name, _, suffix = configLocation.lstrip('/').partition('/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1903 config = join(project(name).dir, suffix)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1904 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1905 config = join(p.dir, configLocation)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1906 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1907 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
1908 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1909
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1910 exclude = join(p.dir, '.checkstyle.exclude')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1911
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1912 if exists(exclude):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1913 with open(exclude) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1914 # Convert patterns to OS separators
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1915 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
1916 def match(name):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1917 for p in patterns:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1918 if p in name:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1919 if _opts.verbose:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1920 log('excluding: ' + name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1921 return True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1922 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1923
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1924 javafilelist = [name for name in javafilelist if not match(name)]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1925
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1926 auditfileName = join(p.dir, 'checkstyleOutput.txt')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1927 log('Running Checkstyle on {0} using {1}...'.format(sourceDir, config))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1928
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1929 try:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1930
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1931 # 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
1932 # 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
1933 # 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
1934 # 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
1935 while len(javafilelist) != 0:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1936 i = 0
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1937 size = 0
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1938 while i < len(javafilelist):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1939 s = len(javafilelist[i]) + 1
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1940 if (size + s < 30000):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1941 size += s
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1942 i += 1
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1943 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1944 break
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1945
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1946 batch = javafilelist[:i]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1947 javafilelist = javafilelist[i:]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1948 try:
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1949 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch, nonZeroIsFatal=False)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1950 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1951 if exists(auditfileName):
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1952 errors = []
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1953 source = None
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1954 def start_element(name, attrs):
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1955 if name == 'file':
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1956 global source
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1957 source = attrs['name']
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1958 elif name == 'error':
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1959 errors.append('{}:{}: {}'.format(source, attrs['line'], attrs['message']))
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1960
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1961 p = xml.parsers.expat.ParserCreate()
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1962 p.StartElementHandler = start_element
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1963 with open(auditfileName) as fp:
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1964 p.ParseFile(fp)
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1965 if len(errors) != 0:
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1966 map(log, errors)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1967 totalErrors = totalErrors + len(errors)
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1968 else:
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1969 if exists(timestampFile):
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1970 os.utime(timestampFile, None)
8958
64d3d352f943 Do not skip a checkstyle test on the next run if it does not succeed in the current run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8884
diff changeset
1971 else:
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
1972 file(timestampFile, 'a')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1973 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1974 if exists(auditfileName):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1975 os.unlink(auditfileName)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
1976 return totalErrors
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1977
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1978 def clean(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1979 """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
1980
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1981 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
1982 generated images.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1983 """
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1984
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1985 suppliedParser = parser is not None
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1986
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
1987 parser = parser if suppliedParser else ArgumentParser(prog='mx build');
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1988 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
1989 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
1990
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1991 args = parser.parse_args(args)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1992
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1993 for p in projects():
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1994 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1995 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1996 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
1997 else:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1998 if args.java:
7778
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
1999 genDir = p.source_gen_dir();
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2000 if genDir != '' and exists(genDir):
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2001 log('Clearing {0}...'.format(genDir))
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2002 for f in os.listdir(genDir):
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2003 shutil.rmtree(join(genDir, f))
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2004
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2005
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2006 outputDir = p.output_dir()
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2007 if outputDir != '' and exists(outputDir):
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2008 log('Removing {0}...'.format(outputDir))
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2009 shutil.rmtree(outputDir)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2010
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
2011 if suppliedParser:
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
2012 return args
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2013
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2014 def about(args):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2015 """show the 'man page' for mx"""
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2016 print __doc__
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2017
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2018 def help_(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2019 """show help for a given command
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2020
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2021 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
2022
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2023 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
2024 if len(args) == 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2025 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2026 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2027
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2028 name = args[0]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2029 if not commands.has_key(name):
6284
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2030 hits = [c for c in commands.iterkeys() if c.startswith(name)]
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2031 if len(hits) == 1:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2032 name = hits[0]
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2033 elif len(hits) == 0:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2034 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(name, _format_commands()))
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2035 else:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2036 abort('mx: command \'{0}\' is ambiguous\n {1}'.format(name, ' '.join(hits)))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2037
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2038 value = commands[name]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2039 (func, usage) = value[:2]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2040 doc = func.__doc__
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2041 if len(value) > 2:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2042 docArgs = value[2:]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2043 fmtArgs = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2044 for d in docArgs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2045 if isinstance(d, Callable):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2046 fmtArgs += [d()]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2047 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2048 fmtArgs += [str(d)]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2049 doc = doc.format(*fmtArgs)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2050 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
2051
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2052 def projectgraph(args, suite=None):
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2053 """create dot graph for project structure ("mx projectgraph | dot -Tpdf -oprojects.pdf")"""
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2054
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2055 print 'digraph projects {'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2056 print 'rankdir=BT;'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2057 print 'node [shape=rect];'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2058 for p in projects():
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2059 for dep in p.canonical_deps():
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2060 print '"' + p.name + '"->"' + dep + '"'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2061 print '}'
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2062
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2063 def _source_locator_memento(deps):
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2064 slm = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2065 slm.open('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2066 slm.open('sourceContainers', {'duplicates' : 'false'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2067
5252
1a9a048386d6 added JRE to source path in generated Eclipse launches
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
2068 # Every Java program depends on the JRE
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2069 memento = XMLDoc().element('classpathContainer', {'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}).xml(standalone='no')
5252
1a9a048386d6 added JRE to source path in generated Eclipse launches
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
2070 slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'})
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2071
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2072 for dep in deps:
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2073 if dep.isLibrary():
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2074 if hasattr(dep, 'eclipse.container'):
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2075 memento = XMLDoc().element('classpathContainer', {'path' : getattr(dep, 'eclipse.container')}).xml(standalone='no')
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2076 slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2077 else:
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2078 memento = XMLDoc().element('javaProject', {'name' : dep.name}).xml(standalone='no')
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2079 slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2080
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2081 slm.close('sourceContainers')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2082 slm.close('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2083 return slm
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2084
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2085 def make_eclipse_attach(hostname, port, name=None, deps=[]):
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2086 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2087 Creates an Eclipse launch configuration file for attaching to a Java process.
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2088 """
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2089 slm = _source_locator_memento(deps)
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2090 launch = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2091 launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.remoteJavaApplication'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2092 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2093 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2094 launch.element('booleanAttribute', {'key' : 'org.eclipse.jdt.launching.ALLOW_TERMINATE', 'value' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2095 launch.open('mapAttribute', {'key' : 'org.eclipse.jdt.launching.CONNECT_MAP'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2096 launch.element('mapEntry', {'key' : 'hostname', 'value' : hostname})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2097 launch.element('mapEntry', {'key' : 'port', 'value' : port})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2098 launch.close('mapAttribute')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2099 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROJECT_ATTR', 'value' : ''})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2100 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.VM_CONNECTOR_ID', 'value' : 'org.eclipse.jdt.launching.socketAttachConnector'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2101 launch.close('launchConfiguration')
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2102 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2103
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2104 if name is None:
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2105 name = 'attach-' + hostname + '-' + port
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2106 eclipseLaunches = join('mx', 'eclipse-launches')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2107 if not exists(eclipseLaunches):
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2108 os.makedirs(eclipseLaunches)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2109 return update_file(join(eclipseLaunches, name + '.launch'), launch)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2110
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2111 def make_eclipse_launch(javaArgs, jre, name=None, deps=[]):
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2112 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2113 Creates an Eclipse launch configuration file for running/debugging a Java command.
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2114 """
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2115 mainClass = None
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2116 vmArgs = []
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2117 appArgs = []
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2118 cp = None
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2119 argsCopy = list(reversed(javaArgs))
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2120 while len(argsCopy) != 0:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2121 a = argsCopy.pop()
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2122 if a == '-jar':
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2123 mainClass = '-jar'
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2124 appArgs = list(reversed(argsCopy))
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2125 break
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2126 if a == '-cp' or a == '-classpath':
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2127 assert len(argsCopy) != 0
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2128 cp = argsCopy.pop()
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2129 vmArgs.append(a)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2130 vmArgs.append(cp)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2131 elif a.startswith('-'):
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2132 vmArgs.append(a)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2133 else:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2134 mainClass = a
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2135 appArgs = list(reversed(argsCopy))
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2136 break
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2137
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2138 if mainClass is None:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2139 log('Cannot create Eclipse launch configuration without main class or jar file: java ' + ' '.join(javaArgs))
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2140 return False
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2141
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2142 if name is None:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2143 if mainClass == '-jar':
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2144 name = basename(appArgs[0])
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2145 if len(appArgs) > 1 and not appArgs[1].startswith('-'):
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2146 name = name + '_' + appArgs[1]
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2147 else:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2148 name = mainClass
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2149 name = time.strftime('%Y-%m-%d-%H%M%S_' + name)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2150
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2151 if cp is not None:
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2152 for e in cp.split(os.pathsep):
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2153 for s in suites():
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2154 deps += [p for p in s.projects if e == p.output_dir()]
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2155 deps += [l for l in s.libs if e == l.get_path(False)]
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2156
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2157 slm = _source_locator_memento(deps)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2158
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2159 launch = XMLDoc()
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2160 launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.localJavaApplication'})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2161 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2162 launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2163 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.JRE_CONTAINER', 'value' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/' + jre})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2164 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.MAIN_TYPE', 'value' : mainClass})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2165 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS', 'value' : ' '.join(appArgs)})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2166 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.PROJECT_ATTR', 'value' : ''})
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2167 launch.element('stringAttribute', {'key' : 'org.eclipse.jdt.launching.VM_ARGUMENTS', 'value' : ' '.join(vmArgs)})
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2168 launch.close('launchConfiguration')
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2169 launch = launch.xml(newl='\n', standalone='no') % slm.xml(escape=True, standalone='no')
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2170
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2171 eclipseLaunches = join('mx', 'eclipse-launches')
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2172 if not exists(eclipseLaunches):
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2173 os.makedirs(eclipseLaunches)
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2174 return update_file(join(eclipseLaunches, name + '.launch'), launch)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2175
7293
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
2176 def eclipseinit(args, suite=None, buildProcessorJars=True):
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2177 """(re)generate Eclipse project configurations"""
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2178
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2179 if suite is None:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2180 suite = _mainSuite
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2181
7293
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
2182 if buildProcessorJars:
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
2183 processorjars()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2184
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2185 projToDist = dict()
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2186 for dist in _dists.values():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2187 distDeps = sorted_deps(dist.deps)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2188 for p in distDeps:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2189 projToDist[p.name] = (dist, [dep.name for dep in distDeps])
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2190
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2191 for p in projects():
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2192 if p.native:
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2193 continue
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2194
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2195 if not exists(p.dir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2196 os.makedirs(p.dir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2197
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2198 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2199 out.open('classpath')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2200
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2201 for src in p.srcDirs:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2202 srcDir = join(p.dir, src)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2203 if not exists(srcDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2204 os.mkdir(srcDir)
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2205 out.element('classpathentry', {'kind' : 'src', 'path' : src})
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2206
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2207 if len(p.annotation_processors()) > 0:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2208 genDir = p.source_gen_dir();
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2209 if not exists(genDir):
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2210 os.mkdir(genDir)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2211 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2212
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2213 # Every Java program depends on the JRE
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2214 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'})
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2215
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2216 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2217 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'})
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2218
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2219 for dep in p.all_deps([], True):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2220 if dep == p:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2221 continue;
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2222
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2223 if dep.isLibrary():
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2224 if hasattr(dep, 'eclipse.container'):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2225 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : getattr(dep, 'eclipse.container')})
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2226 elif hasattr(dep, 'eclipse.project'):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2227 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + getattr(dep, 'eclipse.project')})
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2228 else:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2229 path = dep.path
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2230 if dep.mustExist:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2231 dep.get_path(resolve=True)
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2232 if not isabs(path):
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2233 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2234 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2235 # safest to simply use absolute paths.
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2236 path = join(suite.dir, path)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2237
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2238 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path}
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2239
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2240 sourcePath = dep.get_source_path(resolve=True)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2241 if sourcePath is not None:
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2242 attributes['sourcepath'] = sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2243 out.element('classpathentry', attributes)
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2244 else:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2245 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name})
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2246
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2247 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2248 out.close('classpath')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2249 update_file(join(p.dir, '.classpath'), out.xml(indent='\t', newl='\n'))
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2250
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2251 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml')
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2252 if exists(csConfig):
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2253 out = XMLDoc()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2254
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2255 dotCheckstyle = join(p.dir, ".checkstyle")
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2256 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml'
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2257 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2258 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2259 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2260 out.close('local-check-config')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2261 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2262 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2263 out.close('fileset')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2264 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2265 out.element('filter-data', {'value' : 'java'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2266 out.close('filter')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2267
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2268 exclude = join(p.dir, '.checkstyle.exclude')
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2269 if exists(exclude):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2270 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'})
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2271 with open(exclude) as f:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2272 for line in f:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2273 if not line.startswith('#'):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2274 line = line.strip()
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2275 exclDir = join(p.dir, line)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2276 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2277 out.element('filter-data', {'value' : line})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2278 out.close('filter')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2279
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2280 out.close('fileset-config')
5219
ddccd4abdb09 configured test source directory for graal.graph project
Doug Simon <doug.simon@oracle.com>
parents: 5217
diff changeset
2281 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n'))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2282
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2283 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2284 out.open('projectDescription')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2285 out.element('name', data=p.name)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2286 out.element('comment', data='')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2287 out.element('projects', data='')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2288 out.open('buildSpec')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2289 out.open('buildCommand')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2290 out.element('name', data='org.eclipse.jdt.core.javabuilder')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2291 out.element('arguments', data='')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2292 out.close('buildCommand')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2293 if exists(csConfig):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2294 out.open('buildCommand')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2295 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2296 out.element('arguments', data='')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2297 out.close('buildCommand')
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2298 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2299 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']:
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2300 out.open('buildCommand')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2301 out.element('name', data=buildCommand)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2302 out.element('arguments', data='')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2303 out.close('buildCommand')
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2304
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2305 if _isAnnotationProcessorDependency(p):
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2306 _genEclipseBuilder(out, p, 'Jar.launch', 'archive ' + p.name, refresh = False, async = False, xmlIndent='', xmlStandalone='no')
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2307 _genEclipseBuilder(out, p, 'Refresh.launch', '', refresh = True, async = True)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2308
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2309 if projToDist.has_key(p.name):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2310 dist, distDeps = projToDist[p.name]
8183
4b11a0983557 fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents: 8182
diff changeset
2311 _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist.launch', 'archive @' + dist.name, refresh=False, async=True)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2312
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2313 out.close('buildSpec')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2314 out.open('natures')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2315 out.element('nature', data='org.eclipse.jdt.core.javanature')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2316 if exists(csConfig):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2317 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature')
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2318 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2319 out.element('nature', data='org.eclipse.pde.PluginNature')
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2320 out.close('natures')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2321 out.close('projectDescription')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2322 update_file(join(p.dir, '.project'), out.xml(indent='\t', newl='\n'))
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2323
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2324 settingsDir = join(p.dir, ".settings")
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2325 if not exists(settingsDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2326 os.mkdir(settingsDir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2327
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2328 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings')
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2329 if exists(eclipseSettingsDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2330 for name in os.listdir(eclipseSettingsDir):
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2331 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0:
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2332 continue
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2333 path = join(eclipseSettingsDir, name)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2334 if isfile(path):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2335 with open(join(eclipseSettingsDir, name)) as f:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2336 content = f.read()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2337 content = content.replace('${javaCompliance}', str(p.javaCompliance))
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2338 if len(p.annotation_processors()) > 0:
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
2339 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2340 update_file(join(settingsDir, name), content)
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2341
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2342 if len(p.annotation_processors()) > 0:
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2343 out = XMLDoc()
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2344 out.open('factorypath')
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2345 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'})
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2346 for ap in p.annotation_processors():
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2347 apProject = project(ap)
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2348 for dep in apProject.all_deps([], True):
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2349 if dep.isLibrary():
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2350 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'):
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2351 if dep.mustExist:
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2352 path = dep.get_path(resolve=True)
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2353 if not isabs(path):
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2354 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2355 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2356 # safest to simply use absolute paths.
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2357 path = join(suite.dir, path)
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2358 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'})
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2359 else:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2360 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'})
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2361 out.close('factorypath')
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2362 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n'))
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2363
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2364 make_eclipse_attach('localhost', '8000', deps=projects())
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2365
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2366
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2367 def _isAnnotationProcessorDependency(p):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2368 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2369 Determines if a given project is part of an annotation processor.
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2370 """
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
2371 return p in sorted_deps(annotation_processors())
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2372
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2373 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, xmlIndent='\t', xmlStandalone=None):
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2374 launchOut = XMLDoc();
8181
989e0582a30f enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents: 8180
diff changeset
2375 consoleOn = 'true' if logToConsole else 'false'
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2376 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'})
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2377 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn})
8174
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
2378 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
2379 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk})
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
2380 launchOut.close('mapAttribute')
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
2381
7681
f81be78f15a5 Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents: 7533
diff changeset
2382 if refresh:
f81be78f15a5 Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents: 7533
diff changeset
2383 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'})
8181
989e0582a30f enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents: 8180
diff changeset
2384 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn})
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2385 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'})
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2386
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2387 baseDir = dirname(dirname(os.path.abspath(__file__)))
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2388
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2389 cmd = 'mx.sh'
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2390 if get_os() == 'windows':
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2391 cmd = 'mx.cmd'
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2392 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': join(baseDir, cmd) })
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2393 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'})
7681
f81be78f15a5 Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents: 7533
diff changeset
2394 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand})
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2395 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED','value': 'true'})
8528
67f19ede4891 mx: Use correct working directory in eclipse builders.
Roland Schatz <roland.schatz@oracle.com>
parents: 8457
diff changeset
2396 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir})
7299
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2397
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2398
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2399 launchOut.close('launchConfiguration')
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2400
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2401 externalToolDir = join(p.dir, '.externalToolBuilders')
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2402
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2403 if not exists(externalToolDir):
57edf6b07d36 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
Christian Humer <christian.humer@gmail.com>
parents: 7293
diff changeset
2404 os.makedirs(externalToolDir)
8633
c4bca84d86d7 ensure generated Jar.launch files have the same format as that produced when refreshing in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 8607
diff changeset
2405 update_file(join(externalToolDir, name), launchOut.xml(indent=xmlIndent, standalone=xmlStandalone, newl='\n'))
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2406
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2407 dotProjectDoc.open('buildCommand')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2408 dotProjectDoc.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2409 dotProjectDoc.element('triggers', data='auto,full,incremental,')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2410 dotProjectDoc.open('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2411 dotProjectDoc.open('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2412 dotProjectDoc.element('key', data = 'LaunchConfigHandle')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2413 dotProjectDoc.element('value', data = '<project>/.externalToolBuilders/' + name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2414 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2415 dotProjectDoc.open('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2416 dotProjectDoc.element('key', data = 'incclean')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2417 dotProjectDoc.element('value', data = 'true')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2418 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2419 dotProjectDoc.close('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2420 dotProjectDoc.close('buildCommand')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2421
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2422 def netbeansinit(args, suite=None):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2423 """(re)generate NetBeans project configurations"""
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2424
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2425 if suite is None:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2426 suite = _mainSuite
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2427
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2428 def println(out, obj):
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2429 out.write(str(obj) + '\n')
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2430
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2431 updated = False
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2432 for p in projects():
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2433 if p.native:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2434 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2435
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2436 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2437 continue
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2438
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2439 if not exists(join(p.dir, 'nbproject')):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2440 os.makedirs(join(p.dir, 'nbproject'))
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2441
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2442 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2443 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2444 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2445 out.element('import', {'file' : 'nbproject/build-impl.xml'})
8189
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2446 out.open('target', {'name' : '-post-compile'})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2447 out.open('exec', { 'executable' : sys.executable})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2448 out.element('env', {'key' : 'JAVA_HOME', 'value' : java().jdk})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2449 out.element('arg', {'value' : os.path.abspath(__file__)})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2450 out.element('arg', {'value' : 'archive'})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2451 out.element('arg', {'value' : '@GRAAL'})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2452 out.close('exec')
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
2453 out.close('target')
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2454 out.close('project')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2455 updated = update_file(join(p.dir, 'build.xml'), out.xml(indent='\t', newl='\n')) or updated
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2456
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2457 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2458 out.open('project', {'xmlns' : 'http://www.netbeans.org/ns/project/1'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2459 out.element('type', data='org.netbeans.modules.java.j2seproject')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2460 out.open('configuration')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2461 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2462 out.element('name', data=p.name)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2463 out.element('explicit-platform', {'explicit-source-supported' : 'true'})
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2464 out.open('source-roots')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2465 out.element('root', {'id' : 'src.dir'})
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2466 if len(p.annotation_processors()) > 0:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2467 out.element('root', {'id' : 'src.ap-source-output.dir'})
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2468 out.close('source-roots')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2469 out.open('test-roots')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2470 out.close('test-roots')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2471 out.close('data')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2472
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2473 firstDep = True
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2474 for dep in p.all_deps([], True):
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2475 if dep == p:
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2476 continue;
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2477
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2478 if not dep.isLibrary():
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2479 n = dep.name.replace('.', '_')
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2480 if firstDep:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2481 out.open('references', {'xmlns' : 'http://www.netbeans.org/ns/ant-project-references/1'})
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2482 firstDep = False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2483
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2484 out.open('reference')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2485 out.element('foreign-project', data=n)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2486 out.element('artifact-type', data='jar')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2487 out.element('script', data='build.xml')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2488 out.element('target', data='jar')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2489 out.element('clean-target', data='clean')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2490 out.element('id', data='jar')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2491 out.close('reference')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2492
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2493 if not firstDep:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2494 out.close('references')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2495
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2496 out.close('configuration')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2497 out.close('project')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2498 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2499
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2500 out = StringIO.StringIO()
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2501 jdkPlatform = 'JDK_' + str(java().version)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2502
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2503 annotationProcessorEnabled = "false"
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2504 annotationProcessorReferences = ""
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2505 annotationProcessorSrcFolder = ""
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2506 if len(p.annotation_processors()) > 0:
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2507 annotationProcessorEnabled = "true"
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2508 annotationProcessorSrcFolder = "src.ap-source-output.dir=${build.generated.sources.dir}/ap-source-output"
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2509
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2510 content = """
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2511 annotation.processing.enabled=""" + annotationProcessorEnabled + """
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2512 annotation.processing.enabled.in.editor=""" + annotationProcessorEnabled + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2513 annotation.processing.processors.list=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2514 annotation.processing.run.all.processors=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2515 application.title=""" + p.name + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2516 application.vendor=mx
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2517 build.classes.dir=${build.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2518 build.classes.excludes=**/*.java,**/*.form
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2519 # This directory is removed when the project is cleaned:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2520 build.dir=bin
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2521 build.generated.dir=${build.dir}/generated
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2522 build.generated.sources.dir=${build.dir}/generated-sources
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2523 # Only compile against the classpath explicitly listed here:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2524 build.sysclasspath=ignore
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2525 build.test.classes.dir=${build.dir}/test/classes
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2526 build.test.results.dir=${build.dir}/test/results
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2527 # Uncomment to specify the preferred debugger connection transport:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2528 #debug.transport=dt_socket
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2529 debug.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2530 ${run.classpath}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2531 debug.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2532 ${run.test.classpath}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2533 # This directory is removed when the project is cleaned:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2534 dist.dir=dist
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2535 dist.jar=${dist.dir}/""" + p.name + """.jar
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2536 dist.javadoc.dir=${dist.dir}/javadoc
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2537 endorsed.classpath=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2538 excludes=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2539 includes=**
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2540 jar.compress=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2541 # Space-separated list of extra javac options
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2542 javac.compilerargs=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2543 javac.deprecation=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2544 javac.source=1.7
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2545 javac.target=1.7
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2546 javac.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2547 ${javac.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2548 ${build.classes.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2549 javadoc.additionalparam=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2550 javadoc.author=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2551 javadoc.encoding=${source.encoding}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2552 javadoc.noindex=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2553 javadoc.nonavbar=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2554 javadoc.notree=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2555 javadoc.private=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2556 javadoc.splitindex=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2557 javadoc.use=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2558 javadoc.version=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2559 javadoc.windowtitle=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2560 main.class=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2561 manifest.file=manifest.mf
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2562 meta.inf.dir=${src.dir}/META-INF
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2563 mkdist.disabled=false
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2564 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2565 platform.active=""" + jdkPlatform + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2566 run.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2567 ${javac.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2568 ${build.classes.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2569 # Space-separated list of JVM arguments used when running the project
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2570 # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2571 # or test-sys-prop.name=value to set system properties for unit tests):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2572 run.jvmargs=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2573 run.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2574 ${javac.test.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2575 ${build.test.classes.dir}
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2576 test.src.dir=./test
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2577 """ + annotationProcessorSrcFolder + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2578 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep)
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2579 print >> out, content
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2580
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2581 mainSrc = True
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2582 for src in p.srcDirs:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2583 srcDir = join(p.dir, src)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2584 if not exists(srcDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2585 os.mkdir(srcDir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2586 ref = 'file.reference.' + p.name + '-' + src
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2587 print >> out, ref + '=' + src
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2588 if mainSrc:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2589 print >> out, 'src.dir=${' + ref + '}'
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2590 mainSrc = False
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2591 else:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2592 print >> out, 'src.' + src + '.dir=${' + ref + '}'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2593
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2594 javacClasspath = []
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2595
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2596 deps = p.all_deps([], True)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2597 annotationProcessorOnlyDeps = []
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2598 if len(p.annotation_processors()) > 0:
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2599 for ap in p.annotation_processors():
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2600 apProject = project(ap)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2601 if not apProject in deps:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2602 deps.append(apProject)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2603 annotationProcessorOnlyDeps.append(apProject)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2604
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2605 annotationProcessorReferences = [];
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2606
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2607 for dep in deps:
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2608 if dep == p:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2609 continue;
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2610
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2611 if dep.isLibrary():
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2612 if not dep.mustExist:
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2613 continue
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2614 path = dep.get_path(resolve=True)
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2615 if os.sep == '\\':
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2616 path = path.replace('\\', '\\\\')
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2617 ref = 'file.reference.' + dep.name + '-bin'
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2618 print >> out, ref + '=' + path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2619
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2620 else:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2621 n = dep.name.replace('.', '_')
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2622 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/')
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2623 ref = 'reference.' + n + '.jar'
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2624 print >> out, 'project.' + n + '=' + relDepPath
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2625 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2626
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2627 if not dep in annotationProcessorOnlyDeps:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2628 javacClasspath.append('${' + ref + '}')
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2629 else:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2630 annotationProcessorReferences.append('${' + ref + '}')
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2631 annotationProcessorReferences += ":\\\n ${" + ref + "}"
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2632
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2633 print >> out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2634 print >> out, 'javac.test.processorpath=${javac.test.classpath}\\\n ' + (os.pathsep + '\\\n ').join(annotationProcessorReferences)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2635 print >> out, 'javac.processorpath=${javac.classpath}\\\n ' + (os.pathsep + '\\\n ').join(annotationProcessorReferences)
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2636
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2637 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2638 out.close()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2639
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2640 if updated:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2641 log('If using NetBeans:')
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
2642 log(' 1. Ensure that a platform named "JDK_' + str(java().version) + '" is defined (Tools -> Java Platforms)')
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
2643 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2644
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2645 def ideclean(args, suite=None):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2646 """remove all Eclipse and NetBeans project configurations"""
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2647 def rm(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2648 if exists(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2649 os.remove(path)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2650
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2651 for p in projects():
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2652 if p.native:
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2653 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2654
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2655 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True)
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2656 shutil.rmtree(join(p.dir, '.externalToolBuilders'), ignore_errors=True)
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2657 shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True)
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2658 rm(join(p.dir, '.classpath'))
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2659 rm(join(p.dir, '.project'))
10043
e063474076dd clean up .factorypath files on "mx ideclean"
Lukas Stadler <lukas.stadler@jku.at>
parents: 9857
diff changeset
2660 rm(join(p.dir, '.factorypath'))
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
2661 rm(join(p.dir, 'build.xml'))
7291
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2662 rm(join(p.dir, 'eclipse-build.xml'))
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2663 try:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2664 rm(join(p.dir, p.name + '.jar'))
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2665 except:
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2666 log("Error removing {0}".format(p.name + '.jar'))
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents: 6535
diff changeset
2667
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2668
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2669 def ideinit(args, suite=None):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2670 """(re)generate Eclipse and NetBeans project configurations"""
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2671 eclipseinit(args, suite)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2672 netbeansinit(args, suite)
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2673 fsckprojects([])
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2674
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2675 def fsckprojects(args):
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2676 """find directories corresponding to deleted Java projects and delete them"""
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2677 for suite in suites():
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2678 projectDirs = [p.dir for p in suite.projects]
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2679 for root, dirnames, files in os.walk(suite.dir):
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2680 currentDir = join(suite.dir, root)
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2681 if currentDir in projectDirs:
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2682 # don't traverse subdirs of an existing project
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2683 dirnames[:] = []
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2684 else:
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2685 projectConfigFiles = frozenset(['.classpath', 'nbproject'])
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2686 indicators = projectConfigFiles.intersection(files)
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2687 if len(indicators) != 0:
8138
1446b04e4148 'mx fsckprojects' should only ask on a tty
Andreas Woess <andreas.woess@jku.at>
parents: 8134
diff changeset
2688 if not sys.stdout.isatty() or raw_input(currentDir + ' looks like a removed project -- delete it? [yn]: ') == 'y':
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2689 shutil.rmtree(currentDir)
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
2690 log('Deleted ' + currentDir)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2691
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
2692 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True):
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2693 """generate javadoc for some/all Java projects"""
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2694
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
2695 parser = ArgumentParser(prog='mx javadoc') if parser is None else parser
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2696 parser.add_argument('-d', '--base', action='store', help='base directory for output')
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2697 parser.add_argument('--unified', action='store_true', help='put javadoc in a single directory instead of one per project')
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2698 parser.add_argument('--force', action='store_true', help='(re)generate javadoc even if package-list file exists')
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2699 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)')
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2700 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2701 parser.add_argument('--argfile', action='store', help='name of file containing extra javadoc options')
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2702 parser.add_argument('--arg', action='append', dest='extra_args', help='extra Javadoc arguments (e.g. --arg @-use)', metavar='@<arg>', default=[])
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2703 parser.add_argument('-m', '--memory', action='store', help='-Xmx value to pass to underlying JVM')
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2704 parser.add_argument('--packages', action='store', help='comma separated packages to process (omit to process all packages)')
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2705 parser.add_argument('--exclude-packages', action='store', help='comma separated packages to exclude')
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2706
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2707 args = parser.parse_args(args)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2708
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2709 # build list of projects to be processed
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2710 candidates = sorted_deps()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2711 if args.projects is not None:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2712 candidates = [project(name) for name in args.projects.split(',')]
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2713
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
2714 # optionally restrict packages within a project
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2715 packages = []
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2716 if args.packages is not None:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2717 packages = [name for name in args.packages.split(',')]
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2718
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2719 exclude_packages = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2720 if args.exclude_packages is not None:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2721 exclude_packages = [name for name in args.exclude_packages.split(',')]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2722
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2723 def outDir(p):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2724 if args.base is None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2725 return join(p.dir, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2726 return join(args.base, p.name, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2727
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2728 def check_package_list(p):
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
2729 return not exists(join(outDir(p), 'package-list'))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2730
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2731 def assess_candidate(p, projects):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2732 if p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2733 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2734 if args.force or args.unified or check_package_list(p):
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2735 projects.append(p)
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2736 return True
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2737 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2738
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2739 projects = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2740 for p in candidates:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2741 if not p.native:
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
2742 if includeDeps:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2743 deps = p.all_deps([], includeLibs=False, includeSelf=False)
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2744 for d in deps:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2745 assess_candidate(d, projects)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2746 if not assess_candidate(p, projects):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2747 log('[package-list file exists - skipping {0}]'.format(p.name))
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2748
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2749
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2750 def find_packages(sourceDirs, pkgs=set()):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2751 for sourceDir in sourceDirs:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2752 for root, _, files in os.walk(sourceDir):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2753 if len([name for name in files if name.endswith('.java')]) != 0:
5709
24347f3b605f fixed javadoc command on Windows
Doug Simon <doug.simon@oracle.com>
parents: 5706
diff changeset
2754 pkg = root[len(sourceDir) + 1:].replace(os.sep,'.')
24347f3b605f fixed javadoc command on Windows
Doug Simon <doug.simon@oracle.com>
parents: 5706
diff changeset
2755 if len(packages) == 0 or pkg in packages:
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2756 if len(exclude_packages) == 0 or not pkg in exclude_packages:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2757 pkgs.add(pkg)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2758 return pkgs
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2759
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2760 extraArgs = [a.lstrip('@') for a in args.extra_args]
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2761 if args.argfile is not None:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2762 extraArgs += ['@' + args.argfile]
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2763 memory = '2g'
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2764 if args.memory is not None:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2765 memory = args.memory
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2766 memory = '-J-Xmx' + memory
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2767
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2768 if not args.unified:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2769 for p in projects:
5710
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2770 # The project must be built to ensure javadoc can find class files for all referenced classes
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2771 build(['--no-native', '--projects', p.name])
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2772
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2773 pkgs = find_packages(p.source_dirs(), set())
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2774 deps = p.all_deps([], includeLibs=False, includeSelf=False)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2775 links = ['-link', 'http://docs.oracle.com/javase/' + str(p.javaCompliance.value) + '/docs/api/']
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2776 out = outDir(p)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2777 for d in deps:
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2778 depOut = outDir(d)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2779 links.append('-link')
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2780 links.append(os.path.relpath(depOut, out))
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2781 cp = classpath(p.name, includeSelf=True)
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2782 sp = os.pathsep.join(p.source_dirs())
5706
6f2ccb483d96 added overview.html for each project and integrated it into the generated 'mx site' command
Doug Simon <doug.simon@oracle.com>
parents: 5701
diff changeset
2783 overviewFile = join(p.dir, 'overview.html')
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2784 delOverviewFile = False
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2785 if not exists(overviewFile):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2786 with open(overviewFile, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2787 print >> fp, '<html><body>Documentation for the <code>' + p.name + '</code> project.</body></html>'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2788 delOverviewFile = True
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2789 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2790 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2791 nowarnAPI.append('-XDignore.symbol.file')
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2792 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2793 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2794 run([java().javadoc, memory,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2795 '-windowtitle', p.name + ' javadoc',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2796 '-XDignore.symbol.file',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2797 '-classpath', cp,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2798 '-quiet',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2799 '-d', out,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2800 '-overview', overviewFile,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2801 '-sourcepath', sp] +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2802 links +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2803 extraArgs +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2804 nowarnAPI +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2805 list(pkgs))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2806 log('Generated {2} for {0} in {1}'.format(p.name, out, docDir))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2807 finally:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2808 if delOverviewFile:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2809 os.remove(overviewFile)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2810
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2811 else:
5710
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2812 # The projects must be built to ensure javadoc can find class files for all referenced classes
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2813 build(['--no-native'])
8d31a849ca97 make the javadoc command work when classes have not been previously compiled
Doug Simon <doug.simon@oracle.com>
parents: 5709
diff changeset
2814
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2815 pkgs = set()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2816 sp = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2817 names = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2818 for p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2819 find_packages(p.source_dirs(), pkgs)
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2820 sp += p.source_dirs()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2821 names.append(p.name)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2822
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2823 links = ['-link', 'http://docs.oracle.com/javase/' + str(_java.javaCompliance.value) + '/docs/api/']
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2824 out = join(_mainSuite.dir, docDir)
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2825 if args.base is not None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
2826 out = join(args.base, docDir)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2827 cp = classpath()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2828 sp = os.pathsep.join(sp)
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2829 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2830 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2831 nowarnAPI.append('-XDignore.symbol.file')
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2832 log('Generating {2} for {0} in {1}'.format(', '.join(names), out, docDir))
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2833 run([java().javadoc, memory,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2834 '-classpath', cp,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2835 '-quiet',
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2836 '-d', out,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2837 '-sourcepath', sp] +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2838 links +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2839 extraArgs +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2840 nowarnAPI +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2841 list(pkgs))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
2842 log('Generated {2} for {0} in {1}'.format(', '.join(names), out, docDir))
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
2843
6335
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2844 class Chunk:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2845 def __init__(self, content, ldelim, rdelim=None):
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2846 lindex = content.find(ldelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2847 if rdelim is not None:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2848 rindex = content.find(rdelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2849 else:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2850 rindex = lindex + len(ldelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2851 self.ldelim = ldelim
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2852 self.rdelim = rdelim
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2853 if lindex != -1 and rindex != -1 and rindex > lindex:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2854 self.text = content[lindex + len(ldelim):rindex]
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2855 else:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2856 self.text = None
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2857
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2858 def replace(self, content, repl):
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2859 lindex = content.find(self.ldelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2860 if self.rdelim is not None:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2861 rindex = content.find(self.rdelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2862 rdelimLen = len(self.rdelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2863 else:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2864 rindex = lindex + len(self.ldelim)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2865 rdelimLen = 0
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2866 old = content[lindex:rindex + rdelimLen]
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2867 return content.replace(old, repl)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2868
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2869 # Post-process an overview-summary.html file to move the
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2870 # complete overview to the top of the page
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2871 def _fix_overview_summary(path, topLink):
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2872 """
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2873 Processes an "overview-summary.html" generated by javadoc to put the complete
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2874 summary text above the Packages table.
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2875 """
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2876
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2877 # This uses scraping and so will break if the relevant content produced by javadoc changes in any way!
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2878 with open(path) as fp:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2879 content = fp.read()
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2880
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2881 chunk1 = Chunk(content, """<div class="header">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2882 <div class="subTitle">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2883 <div class="block">""", """</div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2884 </div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2885 <p>See: <a href="#overview_description">Description</a></p>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2886 </div>""")
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2887
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2888 chunk2 = Chunk(content, """<div class="footer"><a name="overview_description">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2889 <!-- -->
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2890 </a>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2891 <div class="subTitle">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2892 <div class="block">""", """</div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2893 </div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2894 </div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2895 <!-- ======= START OF BOTTOM NAVBAR ====== -->""")
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2896
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2897 assert chunk1.text, 'Could not find header section in ' + path
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2898 assert chunk2.text, 'Could not find footer section in ' + path
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2899
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2900 content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text +'</div></div></div>')
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2901 content = chunk2.replace(content, '')
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2902
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2903 with open(path, 'w') as fp:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2904 fp.write(content)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2905
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2906
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2907 # Post-process a package-summary.html file to move the
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2908 # complete package description to the top of the page
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2909 def _fix_package_summary(path):
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2910 """
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2911 Processes an "overview-summary.html" generated by javadoc to put the complete
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2912 summary text above the Packages table.
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2913 """
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2914
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2915 # This uses scraping and so will break if the relevant content produced by javadoc changes in any way!
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2916 with open(path) as fp:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2917 content = fp.read()
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2918
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2919 chunk1 = Chunk(content, """<div class="header">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2920 <h1 title="Package" class="title">Package""", """<p>See:&nbsp;<a href="#package_description">Description</a></p>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2921 </div>""")
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2922
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2923 chunk2 = Chunk(content, """<a name="package_description">
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2924 <!-- -->
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2925 </a>""", """</div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2926 </div>
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2927 <!-- ======= START OF BOTTOM NAVBAR ====== -->""")
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2928
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2929 if chunk1.text:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2930 if chunk2.text:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2931 repl = re.sub(r'<h2 title=(.*) Description</h2>', r'<h1 title=\1</h1>', chunk2.text, 1)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2932 content = chunk1.replace(content, '<div class="header">' + repl +'</div></div>')
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2933 content = chunk2.replace(content, '')
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2934
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2935 with open(path, 'w') as fp:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2936 fp.write(content)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2937 else:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2938 log('warning: Could not find package description detail section in ' + path)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2939
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2940 else:
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2941 # no package description given
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2942 pass
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
2943
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2944 def site(args):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2945 """creates a website containing javadoc and the project dependency graph"""
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2946
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2947 parser = ArgumentParser(prog='site')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2948 parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='<dir>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2949 parser.add_argument('--name', action='store', help='name of overall documentation', required=True, metavar='<name>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2950 parser.add_argument('--overview', action='store', help='path to the overview content for overall documentation', required=True, metavar='<path>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2951 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)')
5782
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2952 parser.add_argument('--jd', action='append', help='extra Javadoc arguments (e.g. --jd @-use)', metavar='@<arg>', default=[])
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2953 parser.add_argument('--exclude-packages', action='store', help='comma separated packages to exclude', metavar='<pkgs>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2954 parser.add_argument('--dot-output-base', action='store', help='base file name (relative to <dir>/all) for project dependency graph .svg and .jpg files generated by dot (omit to disable dot generation)', metavar='<path>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2955 parser.add_argument('--title', action='store', help='value used for -windowtitle and -doctitle javadoc args for overall documentation (default: "<name>")', metavar='<title>')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2956 args = parser.parse_args(args)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2957
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2958 args.base = os.path.abspath(args.base)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2959 tmpbase = tempfile.mkdtemp(prefix=basename(args.base) + '.', dir=dirname(args.base))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2960 unified = join(tmpbase, 'all')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2961
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2962 exclude_packages_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2963 if args.exclude_packages is not None:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2964 exclude_packages_arg = ['--exclude-packages', args.exclude_packages]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2965
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2966 projects = sorted_deps()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2967 projects_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2968 if args.projects is not None:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2969 projects_arg = ['--projects', args.projects]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2970 projects = [project(name) for name in args.projects.split(',')]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2971
5782
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2972 extra_javadoc_args = []
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2973 for a in args.jd:
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2974 extra_javadoc_args.append('--arg')
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2975 extra_javadoc_args.append('@' + a)
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2976
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2977 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2978 # Create javadoc for each project
5782
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
2979 javadoc(['--base', tmpbase] + exclude_packages_arg + projects_arg + extra_javadoc_args)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2980
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
2981 # Create unified javadoc for all projects
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2982 with open(args.overview) as fp:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2983 content = fp.read()
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2984 idx = content.rfind('</body>')
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2985 if idx != -1:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2986 args.overview = join(tmpbase, 'overview_with_projects.html')
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2987 with open(args.overview, 'w') as fp2:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2988 print >> fp2, content[0:idx]
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2989 print >> fp2, """<div class="contentContainer">
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2990 <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Projects table">
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2991 <caption><span>Projects</span><span class="tabEnd">&nbsp;</span></caption>
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2992 <tr><th class="colFirst" scope="col">Project</th><th class="colLast" scope="col">&nbsp;</th></tr>
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2993 <tbody>"""
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2994 color = 'row'
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2995 for p in projects:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2996 print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html", target = "_top">{0}</a></td><td class="colLast">&nbsp;</td></tr>'.format(p.name, color)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2997 color = 'row' if color == 'alt' else 'alt'
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2998
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
2999 print >> fp2, '</tbody></table></div>'
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3000 print >> fp2, content[idx:]
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3001
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3002 title = args.title if args.title is not None else args.name
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3003 javadoc(['--base', tmpbase,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3004 '--unified',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3005 '--arg', '@-windowtitle', '--arg', '@' + title,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3006 '--arg', '@-doctitle', '--arg', '@' + title,
5782
488864d5069a added support for passing -tag option to javadoc to suppress warnings about unrecognized tags in javadoc comments
Doug Simon <doug.simon@oracle.com>
parents: 5778
diff changeset
3007 '--arg', '@-overview', '--arg', '@' + args.overview] + exclude_packages_arg + projects_arg + extra_javadoc_args)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3008 os.rename(join(tmpbase, 'javadoc'), unified)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3009
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3010 # Generate dependency graph with Graphviz
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3011 if args.dot_output_base is not None:
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3012 dotErr = None
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3013 try:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3014 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT):
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3015 dotErr = 'dot -V does not print a string containing "version"'
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3016 except subprocess.CalledProcessError as e:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3017 dotErr = 'error calling "dot -V": {}'.format(e)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3018 except OSError as e:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3019 dotErr = 'error calling "dot -V": {}'.format(e)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3020
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3021 if dotErr != None:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3022 abort('cannot generate dependency graph: ' + dotErr)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3023
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3024 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3025 svg = join(tmpbase, 'all', str(args.dot_output_base) + '.svg')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3026 jpg = join(tmpbase, 'all', str(args.dot_output_base) + '.jpg')
5854
2c00c51357d8 added more content to graal.api.meta overview
Doug Simon <doug.simon@oracle.com>
parents: 5853
diff changeset
3027 html = join(tmpbase, 'all', str(args.dot_output_base) + '.html')
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3028 with open(dot, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3029 dim = len(projects)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3030 print >> fp, 'digraph projects {'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3031 print >> fp, 'rankdir=BT;'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3032 print >> fp, 'size = "' + str(dim) + ',' + str(dim) + '";'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3033 print >> fp, 'node [shape=rect, fontcolor="blue"];'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3034 #print >> fp, 'edge [color="green"];'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3035 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3036 print >> fp, '"' + p.name + '" [URL = "../' + p.name + '/javadoc/index.html", target = "_top"]'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3037 for dep in p.canonical_deps():
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3038 if dep in [proj.name for proj in projects]:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3039 print >> fp, '"' + p.name + '" -> "' + dep + '"'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3040 depths = dict()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3041 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3042 d = p.max_depth()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3043 depths.setdefault(d, list()).append(p.name)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3044 print >> fp, '}'
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3045
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3046 run(['dot', '-Tsvg', '-o' + svg, '-Tjpg', '-o' + jpg, dot])
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3047
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3048 # Post-process generated SVG to remove title elements which most browsers
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3049 # render as redundant (and annoying) tooltips.
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3050 with open(svg, 'r') as fp:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3051 content = fp.read()
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3052 content = re.sub('<title>.*</title>', '', content)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3053 content = re.sub('xlink:title="[^"]*"', '', content)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3054 with open(svg, 'w') as fp:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3055 fp.write(content)
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3056
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3057 # Create HTML that embeds the svg file in an <object> frame
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3058 with open(html, 'w') as fp:
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3059 print >> fp, '<html><body><object data="{}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base)
5854
2c00c51357d8 added more content to graal.api.meta overview
Doug Simon <doug.simon@oracle.com>
parents: 5853
diff changeset
3060
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3061 top = join(tmpbase, 'all', 'overview-summary.html')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3062 for root, _, files in os.walk(tmpbase):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3063 for f in files:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3064 if f == 'overview-summary.html':
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3065 path = join(root, f)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3066 topLink = ''
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3067 if top != path:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3068 link = os.path.relpath(join(tmpbase, 'all', 'index.html'), dirname(path))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3069 topLink = '<p><a href="' + link + '", target="_top"><b>[return to the overall ' + args.name + ' documentation]</b></a></p>'
6335
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3070 _fix_overview_summary(path, topLink)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3071 elif f == 'package-summary.html':
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3072 path = join(root, f)
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3073 _fix_package_summary(path)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3074
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3075
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3076 if exists(args.base):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3077 shutil.rmtree(args.base)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3078 shutil.move(tmpbase, args.base)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3079
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3080 print 'Created website - root is ' + join(args.base, 'all', 'index.html')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3081
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3082 finally:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3083 if exists(tmpbase):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3084 shutil.rmtree(tmpbase)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3085
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3086 def findclass(args, logToConsole=True):
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3087 """find all classes matching a given substring"""
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3088
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3089 matches = []
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3090 for entry, filename in classpath_walk(includeBootClasspath=True):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3091 if filename.endswith('.class'):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3092 if isinstance(entry, zipfile.ZipFile):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3093 classname = filename.replace('/', '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3094 else:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3095 classname = filename.replace(os.sep, '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3096 classname = classname[:-len('.class')]
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3097 for a in args:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3098 if a in classname:
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3099 matches.append(classname)
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3100 if logToConsole:
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3101 log(classname)
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3102 return matches
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3103
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3104 def javap(args):
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3105 """disassemble classes matching given pattern with javap"""
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3106
4147
55376d8953a6 Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents: 4145
diff changeset
3107 javap = java().javap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3108 if not exists(javap):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3109 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
3110 else:
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3111 run([javap, '-private', '-verbose', '-classpath', classpath()] + findclass(args, logToConsole=False))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3112
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3113 def show_projects(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3114 """show all loaded projects"""
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3115 for s in suites():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3116 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
3117 if exists(projectsFile):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3118 log(projectsFile)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3119 for p in s.projects:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3120 log('\t' + p.name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3121
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3122 def add_argument(*args, **kwargs):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3123 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3124 Define how a single command-line argument.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3125 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3126 assert _argParser is not None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3127 _argParser.add_argument(*args, **kwargs)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3128
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3129 # Table of commands in alphabetical order.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3130 # 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
3131 # If any of the format args are instances of Callable, then they are called with an 'env' are before being
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3132 # used in the call to str.format().
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3133 # Extensions should update this table directly
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3134 commands = {
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3135 'about': [about, ''],
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3136 'build': [build, '[options]'],
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
3137 'checkstyle': [checkstyle, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3138 'canonicalizeprojects': [canonicalizeprojects, ''],
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3139 'clean': [clean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3140 'eclipseinit': [eclipseinit, ''],
7524
bbaa734b3627 added 'mx eclipseformat' command for applying the Eclipse Code Formatter to the Java source files in a suite
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
3141 'eclipseformat': [eclipseformat, ''],
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3142 'findclass': [findclass, ''],
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
3143 'fsckprojects': [fsckprojects, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3144 'help': [help_, '[command]'],
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3145 'ideclean': [ideclean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3146 'ideinit': [ideinit, ''],
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3147 'archive': [archive, '[options]'],
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
3148 'projectgraph': [projectgraph, ''],
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
3149 'javap': [javap, '<class name patterns>'],
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3150 'javadoc': [javadoc, '[options]'],
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3151 'site': [site, '[options]'],
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3152 'netbeansinit': [netbeansinit, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3153 'projects': [show_projects, ''],
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3154 }
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3155
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3156 _argParser = ArgParser()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3157
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3158 def _findPrimarySuite():
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3159 # try current working directory first
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3160 mxDir = join(os.getcwd(), 'mx')
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3161 if exists(mxDir) and isdir(mxDir):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3162 return dirname(mxDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3163
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3164 # now search path of my executable
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3165 me = sys.argv[0]
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3166 parent = dirname(me)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3167 while parent:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3168 mxDir = join(parent, 'mx')
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3169 if exists(mxDir) and isdir(mxDir):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3170 return parent
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3171 parent = dirname(parent)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3172 return None
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3173
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
3174 def main():
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3175 primarySuiteDir = _findPrimarySuite()
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3176 if primarySuiteDir:
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3177 global _mainSuite
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3178 _mainSuite = _loadSuite(primarySuiteDir, True)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3179
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3180 opts, commandAndArgs = _argParser._parse_cmd_line()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3181
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
3182 global _opts, _java
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3183 _opts = opts
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
3184 _java = JavaConfig(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3185
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
3186 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
3187 s._post_init(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3188
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3189 if len(commandAndArgs) == 0:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3190 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3191 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3192
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3193 command = commandAndArgs[0]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3194 command_args = commandAndArgs[1:]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3195
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3196 if not commands.has_key(command):
5824
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3197 hits = [c for c in commands.iterkeys() if c.startswith(command)]
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3198 if len(hits) == 1:
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3199 command = hits[0]
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3200 elif len(hits) == 0:
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3201 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands()))
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3202 else:
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
3203 abort('mx: command \'{0}\' is ambiguous\n {1}'.format(command, ' '.join(hits)))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3204
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3205 c, _ = commands[command][:2]
4293
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
3206 def term_handler(signum, frame):
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
3207 abort(1)
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
3208 signal.signal(signal.SIGTERM, term_handler)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3209 try:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3210 if opts.timeout != 0:
4239
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
3211 def alarm_handler(signum, frame):
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
3212 abort('Command timed out after ' + str(opts.timeout) + ' seconds: ' + ' '.join(commandAndArgs))
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
3213 signal.signal(signal.SIGALRM, alarm_handler)
676feaf8adee Made the --timeout option apply to the whole mx command as opposed to each subprocess executed (the new --ptimeout does the latter).
Doug Simon <doug.simon@oracle.com>
parents: 4236
diff changeset
3214 signal.alarm(opts.timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3215 retcode = c(command_args)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3216 if retcode is not None and retcode != 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3217 abort(retcode)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3218 except KeyboardInterrupt:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3219 # 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
3220 abort(1)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3221
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3222 if __name__ == '__main__':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3223 # 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
3224 sys.modules['mx'] = sys.modules.pop('__main__')
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
3225
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
3226 main()