annotate mxtool/mx.py @ 12508:5cde653f58f9

mxtool: handle missing hg executable gracefully
author Mick Jordan <mick.jordan@oracle.com>
date Mon, 21 Oct 2013 15:14:43 -0700
parents 1d68b3962a10
children 21aa1ce5c666 8ee3a8dd762e
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
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
40 at the top level of the suite. A suite is given a name by a 'suite=name'
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
41 property in the 'mx/projects' file (if omitted the name is suite directory).
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
42 An 'mx' subdirectory can be named as plain 'mx' or 'mx.name', where
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
43 'name' is typically the name as the suite name.
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
44 The latter is useful to avoid clashes in IDE project names.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
45
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
46 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
47 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
48
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
49 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
50
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
51 projects
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
52 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
53 dependencies between them.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
54
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
55 commands.py
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
56 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
57
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
58 imports
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
59 Other suites to be loaded. This is recursive. Each
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
60 line in an imports file is the name of an imported suite.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
61 The suite is located using a SuiteModel (cf searchpath)
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 env
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
64 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
65 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
66 include JAVA_HOME and IGNORED_PROJECTS.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
67
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
68 The env file is typically not put under version control
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
69 as it usually contain local file-system paths.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
70
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
71 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
72 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
73 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
74 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
75 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
76 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
77
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
78 Library specification format:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
79
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
80 library@<name>@<prop>=<value>
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 Built-in library properties (* = required):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
83
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
84 *path
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
85 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
86
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
87 urls
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
88 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
89 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
90
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
91 optional
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
92 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
93 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
94
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
95 sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
96 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
97
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
98 sourceUrls
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
99 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
100 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
101
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
102 Project specification format:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
103
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
104 project@<name>@<prop>=<value>
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
105
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
106 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
107
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
108 Built-in project properties (* = required):
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 subDir
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
111 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
112 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
113 under the suite directory.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
114
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
115 *sourceDirs
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
116 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
117 the project directory).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
118
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
119 dependencies
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
120 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
121 depends upon (transitive dependencies should be omitted).
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
122
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
123 checkstyle
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
124 The project whose Checkstyle configuration
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
125 (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
126
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
127 native
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
128 "true" if the project is native.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
129
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
130 javaCompliance
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
131 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
132 sources comply (required for non-native projects).
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
133
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
134 workingSets
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
135 A comma separated list of working set names. The project belongs
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
136 to the given working sets, for which the eclipseinit command
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
137 will generate Eclipse configurations.
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
138
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
139 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
140 by extension commands.
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
141
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
142 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
143 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
145 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
146 import textwrap
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
147 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
148 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
149 from collections import Callable
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 from threading import Thread
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 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
152 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
153
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
154 _projects = dict()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
155 _libs = dict()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
156 _dists = dict()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
157 _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
158 _annotationProcessors = None
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
159 _mainSuite = None
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
160 _src_suitemodel = None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
161 _dst_suitemodel = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
162 _opts = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
163 _java = None
12042
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
164 _check_global_structures = True # can be set False to allow suites with duplicate definitions to load without aborting
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
165 _warn = False
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
166 _hg = None
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
167
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
168
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
169 """
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
170 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
171 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
172 class Distribution:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
173 def __init__(self, suite, name, path, deps):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
174 self.suite = suite
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
175 self.name = name
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
176 self.path = path.replace('/', os.sep)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
177 if not isabs(self.path):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
178 self.path = join(suite.dir, self.path)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
179 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
180 self.update_listeners = set()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
181
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
182 def __str__(self):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
183 return self.name
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
184
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
185 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
186 self.update_listeners.add(listener)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
187
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
188 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
189 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
190 l(self)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
191
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
192 """
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
193 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
194 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 class Dependency:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
196 def __init__(self, suite, name):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 self.name = name
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
198 self.suite = suite
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 def __str__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 return self.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
202
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 def __eq__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 return self.name == other.name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
205
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 def __ne__(self, other):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 return self.name != other.name
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 def __hash__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 return hash(self.name)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
211
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 def isLibrary(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 return isinstance(self, Library)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
214
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
215 def isProject(self):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
216 return isinstance(self, Project)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
217
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218 class Project(Dependency):
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
219 def __init__(self, suite, name, srcDirs, deps, javaCompliance, workingSets, d):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
220 Dependency.__init__(self, suite, name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221 self.srcDirs = srcDirs
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 self.deps = deps
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 self.checkstyleProj = name
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
224 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
225 self.native = False
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
226 self.workingSets = workingSets
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
227 self.dir = d
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
228
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
229 # Create directories for projects that don't yet exist
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
230 if not exists(d):
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
231 os.mkdir(d)
5581
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
232 for s in self.source_dirs():
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
233 if not exists(s):
9911227e6dd3 create directories for not yet existing projects
Doug Simon <doug.simon@oracle.com>
parents: 5455
diff changeset
234 os.mkdir(s)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
235
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
236 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
237 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
238 Add the transitive set of dependencies for this project, including
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
239 libraries if 'includeLibs' is true, to the 'deps' list.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
240 """
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
241 childDeps = list(self.deps)
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
242 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
243 childDeps = self.annotation_processors() + childDeps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 if self in deps:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 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
246 for name in childDeps:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247 assert name != self.name
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
248 dep = dependency(name)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
249 if not dep in deps and (includeLibs or not dep.isLibrary()):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
250 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
251 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
252 deps.append(self)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253 return deps
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
254
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
255 def _compute_max_dep_distances(self, name, distances, dist):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
256 currentDist = distances.get(name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
257 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
258 distances[name] = dist
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
259 p = project(name, False)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
260 if p is not None:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
261 for dep in p.deps:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
262 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
263
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
264 def canonical_deps(self):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
265 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
266 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
267 via other dependencies).
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
268 """
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
269 distances = dict()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
270 result = set()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
271 self._compute_max_dep_distances(self.name, distances, 0)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
272 for n, d in distances.iteritems():
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
273 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
274 if d == 1:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
275 result.add(n)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
276
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
277 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
278 return self.deps
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
279 return result
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
280
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
281 def max_depth(self):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
282 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
283 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
284 """
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
285 distances = dict()
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
286 self._compute_max_dep_distances(self.name, distances, 0)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
287 return max(distances.values())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
289 def source_dirs(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
290 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
291 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
292 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
293 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
294
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
295 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
296 """
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
297 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
298 """
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
299 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
300 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
301 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
302
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303 def output_dir(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
304 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
305 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
306 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
307 if self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
308 return None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
309 return join(self.dir, 'bin')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
310
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
311 def jasmin_output_dir(self):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
312 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
313 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
314 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
315 if self.native:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
316 return None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
317 return join(self.dir, 'jasmin_classes')
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
318
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
319 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
320 if not self.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
321 cp.append(self.output_dir())
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322
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
323 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
324 """
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 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
326 '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
327 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
328 """
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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 break
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
349
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 if matchFound:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
351 simpleClassName = name[:-len('.java')]
5762
b30cced39597 generalized functionality for finding classes based on searching for patterns in source code and moved it from commands.py to mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5712
diff changeset
352 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
353 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
354 pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep))
11245
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
355 if exists(pkgOutputDir):
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
356 for e in os.listdir(pkgOutputDir):
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
357 if includeInnerClasses:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
358 if e.endswith('.class') and (e.startswith(simpleClassName) or e.startswith(simpleClassName + '$')):
11245
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
359 className = pkg + '.' + e[:-len('.class')]
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
360 result[className] = source
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
361 elif e == simpleClassName + '.class':
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
362 className = pkg + '.' + simpleClassName
11245
d89a5dbaaaf6 ignore sources for which class files do not exist
Doug Simon <doug.simon@oracle.com>
parents: 11205
diff changeset
363 result[className] = source
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8585
diff changeset
364 return result
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
365
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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 if len(javaSources) != 0:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
379 pkg = root[len(sourceDir) + 1:].replace(os.sep, '.')
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
380 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
381 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
382 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
383 # 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
384 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
385 imports.add(pkg)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
386
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
387 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
388 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
389 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
390 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
391 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
392 self._extended_java_packages = frozenset(extendedPackages)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
393
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
394 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
395 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
396 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
397 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
398 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
399 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
400 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
401 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
402 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
403 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
404 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
405 self._imported_java_packages = frozenset(importedPackages)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
406
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
407 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
408 """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
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._defined_java_packages
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
411
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
412 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
413 """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
414 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
415 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
416
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
417 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
418 """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
419 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
420 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
421 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
422
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
423 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
424 if not hasattr(self, '_annotationProcessors'):
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
425 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
426 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
427 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
428
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
429 # find dependencies that auto-inject themselves as annotation processors to all dependents
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
430 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
431 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
432 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
433 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
434 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
435 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
436
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
437 class Library(Dependency):
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
438 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
439 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
440 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
441 self.urls = urls
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
442 self.mustExist = mustExist
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
443 self.sourcePath = sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
444 self.sourceUrls = sourceUrls
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
445 for url in urls:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
446 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
447 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
448
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
449 def __eq__(self, other):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
450 if isinstance(other, Library):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
451 if len(self.urls) == 0:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
452 return self.path == other.path
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
453 else:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
454 return self.urls == other.urls
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
455 else:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
456 return NotImplemented
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
457
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
458
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
459 def __ne__(self, other):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
460 result = self.__eq__(other)
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
461 if result is NotImplemented:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
462 return result
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
463 return not result
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
464
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
465
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
466 def get_path(self, resolve):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
467 path = self.path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
468 if not isabs(path):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
469 path = join(self.suite.dir, path)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
470 includedInJDK = getattr(self, 'includedInJDK', None)
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
471 if includedInJDK and java().javaCompliance >= JavaCompliance(includedInJDK):
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
472 return None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
473 if resolve and self.mustExist and not exists(path):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
474 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
475 print('Downloading ' + self.name + ' from ' + str(self.urls))
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
476 download(path, self.urls)
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
477 return path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
478
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
479 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
480 path = self.sourcePath
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
481 if path is None:
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
482 return None
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
483 if not isabs(path):
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
484 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
485 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
486 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
487 download(path, self.sourceUrls)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
488 return path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
489
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
490 def append_to_classpath(self, cp, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
491 path = self.get_path(resolve)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
492 if path and (exists(path) or not resolve):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
493 cp.append(path)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
494
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
495 def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
496 if not includeLibs or not includeSelf:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
497 return deps
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
498 deps.append(self)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
499 return deps
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
500
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
501 class HgConfig:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
502 """
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
503 Encapsulates access to Mercurial (hg)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
504 """
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
505 def __init__(self):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
506 self.missing = 'no hg executable found'
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
507 try:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
508 subprocess.check_output(['hg'])
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
509 self.has_hg = True
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
510 except OSError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
511 self.has_hg = False
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
512 warn(self.missing)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
513
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
514 def _check(self, abortOnFail=True):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
515 if not self.has_hg:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
516 if abortOnFail:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
517 abort(self.missing)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
518 else:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
519 warn(self.missing)
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
520 return self.has_hg
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
521
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
522 def _tip(self, s, abortOnError=True):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
523 if not self.has_hg:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
524 return None
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
525 try:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
526 version = subprocess.check_output(['hg', 'tip', '-R', s.dir, '--template', '{node}'])
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
527 if s.version is not None and s.version != version:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
528 abort('version of suite ' + s.name +' has changed during run')
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
529 return version
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
530 except subprocess.CalledProcessError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
531 if abortOnError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
532 abort('failed to get tip revision id')
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
533 else:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
534 return None
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
535
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
536 def _canpush(self, s, strict=True):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
537 try:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
538 output = subprocess.check_output(['hg', '-R', s.dir, 'status'])
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
539 # super strict
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
540 return output == ''
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
541 except subprocess.CalledProcessError:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
542 return False
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
543
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
544 def _default_push(self, sdir):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
545 with open(join(sdir, '.hg', 'hgrc')) as f:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
546 for line in f:
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
547 line = line.rstrip()
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
548 if line.startswith('default = '):
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
549 return line[len('default = '):]
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
550 return None
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
551
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
552 class SuiteModel:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
553 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
554 Defines how to locate a URL/path for a suite, including imported suites.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
555 Conceptually a SuiteModel is defined by a primary suite URL/path and a
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
556 map from suite name to URL/path for imported suites.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
557 Subclasses define a specfic implementation.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
558 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
559 def __init__(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
560 self.primaryDir = None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
561 self.suitenamemap = {}
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
562
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
563 def _find_suite_dir(self, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
564 """locates the URL/path for suitename or None if not found"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
565 abort('_find_suite_dir not implemented')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
566
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
567 def _set_primary_dir(self, d):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
568 """informs that d is the primary suite directory"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
569 self._primaryDir = d
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
570
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
571 def _importee_dir(self, importer_dir, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
572 """returns the directory path for an import of suitename, given importer_dir"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
573 abort('_importee_dir not implemented')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
574
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
575 def _nestedsuites_dirname(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
576 """Returns the dirname that contains any nested suites if the model supports that"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
577 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
578
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
579 def _mxDirName(self, name):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
580 # temporary workaround until mx.graal exists
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
581 if name == 'graal':
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
582 return 'mx'
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
583 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
584 return 'mx.' + name
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
585
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
586 def _search_dir(self, searchDir, mxDirName):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
587 for dd in os.listdir(searchDir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
588 sd = _is_suite_dir(join(searchDir, dd), mxDirName)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
589 if sd is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
590 return sd
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
591
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
592 def _create_suitenamemap(self, optionspec, suitemap):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
593 """Three ways to specify a suite name mapping, in order of precedence:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
594 1. Explicitly in optionspec.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
595 2. In suitemap.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
596 3. in MXSUITEMAP environment variable.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
597 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
598 if optionspec != '':
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
599 spec = optionspec
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
600 elif suitemap is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
601 spec = suitemap
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
602 elif get_env('MXSUITEMAP') is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
603 spec = get_env('MXSUITEMAP')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
604 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
605 return
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
606 pairs = spec.split(',')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
607 for pair in pairs:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
608 mappair = pair.split('=')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
609 self.suitenamemap[mappair[0]] = mappair[1]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
610
12491
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
611 @staticmethod
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
612 def _set_suitemodel(option, suitemap):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
613 if option.startswith('sibling'):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
614 return SiblingSuiteModel(os.getcwd(), option, suitemap)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
615 elif option.startswith('nested'):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
616 return NestedImportsSuiteModel(os.getcwd(), option, suitemap)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
617 elif option.startswith('path'):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
618 return PathSuiteModel(option[len('path:'):])
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
619 else:
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
620 abort('unknown suitemodel type: ' + option)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
621
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
622 @staticmethod
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
623 def _parse_options():
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
624 # suite-specific args may match the known args so there is no way at this early stage
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
625 # to use ArgParser to handle the suite model global arguments, so we just do it manually.
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
626 def _get_argvalue(arg, args, i):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
627 if i < len(args):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
628 return args[i]
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
629 else:
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
630 abort('value expected with ' + arg)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
631
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
632 args = sys.argv[1:]
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
633 src_suitemodel_arg = dst_suitemodel_arg = 'sibling'
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
634 suitemap_arg = None
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
635
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
636 i = 0
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
637 while i < len(args):
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
638 arg = args[i]
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
639 if arg == '--src-suitemodel':
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
640 src_suitemodel_arg = _get_argvalue(arg, args, i + 1)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
641 elif arg == '--dst-suitemodel':
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
642 dst_suitemodel_arg = _get_argvalue(arg, args, i + 1)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
643 elif arg == '--suitemap':
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
644 suitemap_arg = _get_argvalue(arg, args, i + 1)
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
645 elif arg == '-w':
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
646 # to get warnings on suite loading issues before command line is parsed
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
647 global _warn
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
648 _warn = True
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
649
12491
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
650 i = i + 1
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
651
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
652 global _src_suitemodel
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
653 _src_suitemodel = SuiteModel._set_suitemodel(src_suitemodel_arg, suitemap_arg)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
654 global _dst_suitemodel
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
655 _dst_suitemodel = SuiteModel._set_suitemodel(dst_suitemodel_arg, suitemap_arg)
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
656
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
657
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
658 class SiblingSuiteModel(SuiteModel):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
659 """All suites are siblings in the same parent directory, recorded as _suiteRootDir"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
660 def __init__(self, suiteRootDir, option, suitemap):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
661 SuiteModel.__init__(self)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
662 self._suiteRootDir = suiteRootDir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
663 self._create_suitenamemap(option[len('sibling:'):], suitemap)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
664
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
665 def _find_suite_dir(self, name):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
666 return self._search_dir(self._suiteRootDir, self._mxDirName(name))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
667
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
668 def _set_primary_dir(self, d):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
669 SuiteModel._set_primary_dir(self, d)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
670 self._suiteRootDir = dirname(d)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
671
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
672 def _importee_dir(self, importer_dir, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
673 if self.suitenamemap.has_key(suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
674 suitename = self.suitenamemap[suitename]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
675 return join(dirname(importer_dir), suitename)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
676
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
677 class NestedImportsSuiteModel(SuiteModel):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
678 """Imported suites are all siblings in an 'imported_suites' directory of the primary suite"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
679 def _imported_suites_dirname(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
680 return "imported_suites"
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
681
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
682 def __init__(self, primaryDir, option, suitemap):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
683 SuiteModel.__init__(self)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
684 self._primaryDir = primaryDir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
685 self._create_suitenamemap(option[len('nested:'):], suitemap)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
686
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
687 def _find_suite_dir(self, name):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
688 return self._search_dir(join(self._primaryDir, self._imported_suites_dirname()), self._mxDirName(name))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
689
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
690 def _importee_dir(self, importer_dir, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
691 if self.suitenamemap.has_key(suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
692 suitename = self.suitenamemap[suitename]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
693 if basename(importer_dir) == basename(self._primaryDir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
694 # primary is importer
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
695 this_imported_suites_dirname = join(importer_dir, self._imported_suites_dirname())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
696 if not exists(this_imported_suites_dirname):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
697 os.mkdir(this_imported_suites_dirname)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
698 return join(this_imported_suites_dirname, suitename)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
699 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
700 return join(dirname(importer_dir), suitename)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
701
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
702 def _nestedsuites_dirname(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
703 return self._imported_suites_dirname()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
704
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
705 class PathSuiteModel(SuiteModel):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
706 """The most general model. Uses a map from suitename to URL/path provided by the user"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
707 def __init__(self, path):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
708 SuiteModel.__init__(self)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
709 paths = path.split(',')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
710 self.suit_to_url = {}
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
711 for path in paths:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
712 pair = path.split('=')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
713 if len(pair) > 1:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
714 suitename = pair[0]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
715 suiteurl = pair[1]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
716 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
717 suitename = basename(pair[0])
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
718 suiteurl = pair[0]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
719 self.suit_to_url[suitename] = suiteurl
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
720
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
721 def _find_suite_dir(self, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
722 if self.suit_to_url.has_key(suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
723 return self.suit_to_url[suitename]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
724 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
725 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
726
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
727 def _importee_dir(self, importer_dir, suitename):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
728 if suitename in self.suit_to_url:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
729 return self.suit_to_url[suitename]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
730 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
731 abort('suite ' + suitename + ' not found')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
732
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
733 class SuiteImport:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
734 def __init__(self, name, version):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
735 self.name = name
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
736 self.version = version
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
737
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
738 @staticmethod
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
739 def _parse_specification(specification):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
740 pair = specification.split(',')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
741 name = pair[0]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
742 if len(pair) > 1:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
743 version = pair[1]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
744 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
745 version = None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
746 return SuiteImport(name, version)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
747
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
748 @staticmethod
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
749 def _tostring(name, version):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
750 return name + ',' + version
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
751
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
752 def __str__(self):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
753 return self.name + ',' + self.version
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
754
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
755 class Suite:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
756 def __init__(self, mxDir, primary, load=True):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
757 self.dir = dirname(mxDir)
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
758 self.mxDir = mxDir
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
759 self.projects = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
760 self.libs = []
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
761 self.dists = []
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
762 self.imports = []
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
763 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
764 self.primary = primary
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
765 self.name = _suitename(mxDir) # validated in _load_projects
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
766 self.version = None # _hg._tip checks current version if not None
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
767 self.version = _hg._tip(self, False)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
768 if load:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
769 # load suites bottom up to make sure command overriding works properly
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
770 self._load_imports()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
771 self._load_env()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
772 self._load_commands()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
773 _suites[self.name] = self
9193
c8f4e1081c0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([]))
Doug Simon <doug.simon@oracle.com>
parents: 9144
diff changeset
774
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
775 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
776 return self.name
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
777
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
778 def _load_projects(self):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
779 libsMap = dict()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
780 projsMap = dict()
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
781 distsMap = dict()
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
782 projectsFile = join(self.mxDir, 'projects')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
783 if not exists(projectsFile):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
784 return
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
785
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
786 with open(projectsFile) as f:
12455
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
787 prefix = ''
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
788 for line in f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
789 line = line.strip()
12455
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
790 if line.endswith('\\'):
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
791 prefix = prefix + line[:-1]
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
792 continue
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
793 if len(prefix) != 0:
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
794 line = prefix + line
d08accd58925 added support for wrapping long lines in mx/projects by placing a "\" at the end of the line (like the C preprocessor accepts)
Doug Simon <doug.simon@oracle.com>
parents: 12441
diff changeset
795 prefix = ''
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
796 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
797 key, value = line.split('=', 1)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
798
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
799 parts = key.split('@')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
800
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
801 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
802 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
803 abort('Single part property must be "suite": ' + key)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
804 if self.name != value:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
805 abort('suite name in project file does not match ' + _suitename(self.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
806 continue
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
807 if len(parts) != 3:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
808 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
809 kind, name, attr = parts
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
810 if kind == 'project':
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
811 m = projsMap
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
812 elif kind == 'library':
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
813 m = libsMap
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
814 elif kind == 'distribution':
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
815 m = distsMap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
816 else:
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
817 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
818
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
819 attrs = m.get(name)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
820 if attrs is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
821 attrs = dict()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
822 m[name] = attrs
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
823 value = expandvars_in_property(value)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
824 attrs[attr] = value
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
825
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
826 def pop_list(attrs, name):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
827 v = attrs.pop(name, None)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
828 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
829 return []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
830 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
831
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
832 for name, attrs in projsMap.iteritems():
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
833 srcDirs = pop_list(attrs, 'sourceDirs')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
834 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
835 ap = pop_list(attrs, 'annotationProcessors')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
836 # deps += ap
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
837 javaCompliance = attrs.pop('javaCompliance', None)
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
838 subDir = attrs.pop('subDir', None)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
839 if subDir is None:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
840 d = join(self.dir, name)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
841 else:
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7299
diff changeset
842 d = join(self.dir, subDir, name)
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
843 workingSets = attrs.pop('workingSets', None)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
844 p = Project(self, name, srcDirs, deps, javaCompliance, workingSets, d)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
845 p.checkstyleProj = attrs.pop('checkstyle', name)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
846 p.native = attrs.pop('native', '') == 'true'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
847 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
848 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
849 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
850 p._declaredAnnotationProcessors = ap
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
851 p.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
852 self.projects.append(p)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
853
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
854 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
855 path = attrs.pop('path')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
856 mustExist = attrs.pop('optional', 'false') != 'true'
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
857 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
858 sourcePath = attrs.pop('sourcePath', None)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
859 sourceUrls = pop_list(attrs, 'sourceUrls')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
860 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
861 l.__dict__.update(attrs)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
862 self.libs.append(l)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
863
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
864 for name, attrs in distsMap.iteritems():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
865 path = attrs.pop('path')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
866 deps = pop_list(attrs, 'dependencies')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
867 d = Distribution(self, name, path, deps)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
868 d.__dict__.update(attrs)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
869 self.dists.append(d)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
870
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
871 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
872 abort('Missing "suite=<name>" in ' + projectsFile)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
873
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
874 def _commands_name(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
875 return 'mx_' + self.name
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
876
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
877 def _find_commands(self, name):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
878 commandsPath = join(self.mxDir, name + '.py')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
879 if exists(commandsPath):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
880 return name
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
881 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
882 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
883
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
884 def _load_commands(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
885 commandsName = self._find_commands(self._commands_name())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
886 if commandsName is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
887 # backwards compatibility
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
888 commandsName = self._find_commands('commands')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
889 if commandsName is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
890 if commandsName in sys.modules:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
891 abort(commandsName + '.py in suite ' + self.name + ' duplicates ' + sys.modules[commandsName].__file__)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
892 # temporarily extend the Python path
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
893 sys.path.insert(0, self.mxDir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
894 mod = __import__(commandsName)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
895
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
896 self.commands = sys.modules.pop(commandsName)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
897 sys.modules[commandsName] = self.commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
898
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
899 # revert the Python path
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
900 del sys.path[0]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
901
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
902 if not hasattr(mod, 'mx_init'):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
903 abort(commandsName + '.py in suite ' + self.name + ' must define an mx_init(suite) function')
4215
a2caa019ba3a Fix mx : commands' scripts mx_init hook should be called before parsing command line arguments.
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4188
diff changeset
904 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
905 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
906
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
907 mod.mx_init(self)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
908 self.commands = mod
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
909
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
910 def _visit_imports(self, visitor, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
911 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
912 Visitor support for the imports file.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
913 For each line of the imports file that specifies an import, the visitor function is
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
914 called with this suite, a SuiteImport instance created from the line and any extra args
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
915 passed to this call. In addition, if extra_args contains a key 'update_versions' that is True,
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
916 a StringIO value is added to extra_args with key 'updated_imports', and the visitor is responsible
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
917 for writing a (possibly) updated import line to the file, and the file is (possibly) updated after
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
918 all imports are processed.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
919 N.B. There is no built-in support for avoiding visiting the same suite multiple times,
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
920 as this function only visits the imports of a singkle suite. If a (recursive) visitor function
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
921 wishes to visit a suite exactly once, it must manage that through extra_args.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
922 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
923 importsFile = join(self.mxDir, 'imports')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
924 if exists(importsFile):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
925 update_versions = extra_args.has_key('update_versions') and extra_args['update_versions']
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
926 out = StringIO.StringIO() if update_versions else None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
927 extra_args['updated_imports'] = out
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
928 with open(importsFile) as f:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
929 for line in f:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
930 sline = line.strip()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
931 if len(sline) == 0 or sline.startswith('#'):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
932 if out is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
933 out.write(sline + '\n')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
934 continue
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
935 suite_import = SuiteImport._parse_specification(line.strip())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
936 visitor(self, suite_import, **extra_args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
937
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
938 if out is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
939 update_file(importsFile, out.getvalue())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
940
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
941 @staticmethod
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
942 def _find_and_loadsuite(suite, suite_import, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
943 """visitor for the initial suite load"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
944 importMxDir = _src_suitemodel._find_suite_dir(suite_import.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
945 if importMxDir is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
946 abort('import ' + suite_import.name + ' not found')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
947 suite.imports.append(suite_import)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
948 imported_suite = _loadSuite(importMxDir, False)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
949 if imported_suite.version != suite.version:
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
950 warn('import version of ' + imported_suite.name +' does not match tip of ' + suite.version)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
951
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
952 def _load_imports(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
953 self._visit_imports(self._find_and_loadsuite)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
954
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
955 def _load_env(self):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
956 e = join(self.mxDir, 'env')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
957 if exists(e):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
958 with open(e) as f:
10585
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
959 lineNum = 0
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
960 for line in f:
10585
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
961 lineNum = lineNum + 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
962 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
963 if len(line) != 0 and line[0] != '#':
10585
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
964 if not '=' in line:
be8b942f448f made parsing of mx/env more robust
Doug Simon <doug.simon@oracle.com>
parents: 10576
diff changeset
965 abort(e + ':' + str(lineNum) + ': line does not match pattern "key=value"')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
966 key, value = line.split('=', 1)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
967 os.environ[key.strip()] = expandvars_in_property(value.strip())
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
968
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
969 def _post_init(self, opts):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
970 self._load_projects()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
971 # set the global data structures, checking for conflicts unless _check_global_structures is False
4180
383c1272cd1f Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4178
diff changeset
972 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
973 existing = _projects.get(p.name)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
974 if existing is not None and _check_global_structures:
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
975 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
976 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
977 _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
978 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
979 existing = _libs.get(l.name)
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
980 # Check that suites that define same library are consistent
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
981 if existing is not None and existing != l and _check_global_structures:
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
982 abort('inconsistent library redefinition of ' + l.name + ' in ' + existing.suite.dir + ' and ' + l.suite.dir)
4180
383c1272cd1f Fixed gate script such that JAVA_HOME can be set in env file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4178
diff changeset
983 _libs[l.name] = l
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
984 for d in self.dists:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
985 existing = _dists.get(d.name)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
986 if existing is not None and _check_global_structures:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
987 # allow redefinition, so use path from existing
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
988 # abort('cannot redefine distribution ' + d.name)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
989 warn('distribution ' + d.name + ' redefined')
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
990 d.path = existing.path
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
991 _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
992 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
993 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
994
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
995 class XMLElement(xml.dom.minidom.Element):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
996 def writexml(self, writer, indent="", addindent="", newl=""):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
997 writer.write(indent + "<" + self.tagName)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
998
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
999 attrs = self._get_attributes()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1000 a_names = attrs.keys()
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1001 a_names.sort()
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1002
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1003 for a_name in a_names:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1004 writer.write(" %s=\"" % a_name)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1005 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
1006 writer.write("\"")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1007 if self.childNodes:
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1008 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
1009 # 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
1010 # 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
1011 writer.write(">")
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1012 self.childNodes[0].writexml(writer)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1013 writer.write("</%s>%s" % (self.tagName, newl))
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1014 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1015 writer.write(">%s" % (newl))
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1016 for node in self.childNodes:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1017 node.writexml(writer, indent + addindent, addindent, newl)
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1018 writer.write("%s</%s>%s" % (indent, self.tagName, newl))
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1019 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1020 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
1021
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1022 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
1023
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
1024 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
1025 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
1026 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
1027 self.padTextNodeWithoutSiblings = False
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1028
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1029 def createElement(self, tagName):
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1030 # overwritten to create XMLElement
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1031 e = XMLElement(tagName)
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1032 e.ownerDocument = self
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
1033 return e
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1034
8302
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
1035 def comment(self, txt):
b246434a3e4a made build-graal.xml be generated by mx
Doug Simon <doug.simon@oracle.com>
parents: 8189
diff changeset
1036 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
1037
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1038 def open(self, tag, attributes=None, data=None):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1039 if attributes is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1040 attributes = {}
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
1041 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
1042 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
1043 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
1044 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
1045 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
1046 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
1047 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
1048 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
1049
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1050 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
1051 assert self.current != self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1052 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
1053 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
1054 return self
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1055
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1056 def element(self, tag, attributes=None, data=None):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1057 if attributes is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1058 attributes = {}
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
1059 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
1060
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
1061 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
1062 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
1063 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
1064 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
1065 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
1066 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
1067 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
1068 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
1069 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
1070
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1071 def get_os():
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1072 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1073 Get a canonical form of sys.platform.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1074 """
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1075 if sys.platform.startswith('darwin'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1076 return 'darwin'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1077 elif sys.platform.startswith('linux'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1078 return 'linux'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1079 elif sys.platform.startswith('sunos'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1080 return 'solaris'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1081 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1082 return 'windows'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1083 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1084 abort('Unknown operating system ' + sys.platform)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1085
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1086 def _loadSuite(mxDir, primary=False):
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1087 """
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1088 Load a suite from 'mxDir'.
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1089 """
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1090 for s in _suites.itervalues():
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1091 if s.mxDir == mxDir:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1092 return s
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1093 # create the new suite
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1094 s = Suite(mxDir, primary)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1095 return s
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1096
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1097 def suites(opt_limit_to_suite=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1098 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1099 Get the list of all loaded suites.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1100 """
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1101 if opt_limit_to_suite and _opts.specific_suites:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1102 result = []
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
1103 for s in _suites.values():
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1104 if s.name in _opts.specific_suites:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1105 result.append(s)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1106 return result
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1107 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1108 return _suites.values()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1109
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
1110 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
1111 """
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
1112 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
1113 """
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
1114 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
1115 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
1116 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
1117 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
1118
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1119
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1120 def projects_from_names(projectNames):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1121 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1122 Get the list of projects corresponding to projectNames; all projects if None
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1123 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1124 if projectNames is None:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1125 return projects()
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1126 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1127 return [project(name) for name in projectNames]
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1128
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1129 def projects(opt_limit_to_suite=False):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1130 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1131 Get the list of all loaded projects limited by --suite option if opt_limit_to_suite == True
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1132 """
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1133
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1134 if opt_limit_to_suite:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1135 return _projects_opt_limit_to_suites(_projects.values())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1136 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1137 return _projects.values()
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1138
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1139 def projects_opt_limit_to_suites():
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1140 """
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1141 Get the list of all loaded projects optionally limited by --suite option
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1142 """
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1143 return projects(True)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1144
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1145 def _projects_opt_limit_to_suites(projects):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1146 if not _opts.specific_suites:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1147 return projects
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1148 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1149 result = []
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1150 for p in projects:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1151 s = p.suite
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1152 if s.name in _opts.specific_suites:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1153 result.append(p)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1154 return result
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1155
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
1156 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
1157 """
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
1158 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
1159 """
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
1160 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
1161 if _annotationProcessors is None:
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1162 aps = set()
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1163 for p in projects():
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1164 for ap in p.annotation_processors():
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1165 if project(ap, False):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1166 aps.add(ap)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1167 _annotationProcessors = list(aps)
9857
719a290b8a23 added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
Doug Simon <doug.simon@oracle.com>
parents: 9854
diff changeset
1168 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
1169
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1170 def distribution(name, fatalIfMissing=True):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1171 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1172 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
1173 not exist and 'fatalIfMissing' is true.
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1174 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1175 d = _dists.get(name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1176 if d is None and fatalIfMissing:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1177 abort('distribution named ' + name + ' not found')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1178 return d
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
1179
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1180 def dependency(name, fatalIfMissing=True):
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1181 """
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1182 Get the project or library for a given name. This will abort if a project or library does
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1183 not exist for 'name' and 'fatalIfMissing' is true.
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1184 """
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1185 d = _projects.get(name)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1186 if d is None:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1187 d = _libs.get(name)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1188 if d is None and fatalIfMissing:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1189 if name in _opts.ignored_projects:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1190 abort('project named ' + name + ' is ignored')
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1191 abort('project or library named ' + name + ' not found')
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1192 return d
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1193
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1194 def project(name, fatalIfMissing=True):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1195 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1196 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
1197 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1198 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1199 p = _projects.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1200 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
1201 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
1202 abort('project named ' + name + ' is ignored')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1203 abort('project named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1204 return p
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1205
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1206 def library(name, fatalIfMissing=True):
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 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
1209 not exist and 'fatalIfMissing' is true.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1210 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1211 l = _libs.get(name)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1212 if l is None and fatalIfMissing:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1213 abort('library named ' + name + ' not found')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1214 return l
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1215
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1216 def _as_classpath(deps, resolve):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1217 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1218 if _opts.cp_prefix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1219 cp = [_opts.cp_prefix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1220 for d in deps:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1221 d.append_to_classpath(cp, resolve)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1222 if _opts.cp_suffix is not None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1223 cp += [_opts.cp_suffix]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1224 return os.pathsep.join(cp)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1225
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1226 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
1227 """
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1228 Get the class path for a list of given dependencies, resolving each entry in the
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1229 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
1230 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1231 if names is None:
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1232 result = _as_classpath(sorted_deps(includeLibs=True), resolve)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1233 else:
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1234 deps = []
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1235 if isinstance(names, types.StringTypes):
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1236 names = [names]
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1237 for n in names:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
1238 dependency(n).all_deps(deps, True, includeSelf)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1239 result = _as_classpath(deps, resolve)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1240 if includeBootClasspath:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1241 result = os.pathsep.join([java().bootclasspath(), result])
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1242 return result
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1243
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1244 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
1245 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1246 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
1247 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
1248 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
1249 to the classpath entry.
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1250 """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1251 cp = classpath(names, resolve, includeSelf, includeBootClasspath)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1252 for entry in cp.split(os.pathsep):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1253 if not exists(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1254 continue
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1255 if isdir(entry):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1256 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
1257 for d in dirs:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1258 entryPath = join(root[len(entry) + 1:], d)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1259 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1260 for f in files:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1261 entryPath = join(root[len(entry) + 1:], f)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1262 yield entry, entryPath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1263 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
1264 with zipfile.ZipFile(entry, 'r') as zf:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1265 for zi in zf.infolist():
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1266 entryPath = zi.filename
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1267 yield zf, entryPath
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1268
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
1269 def sorted_deps(projectNames=None, includeLibs=False, includeAnnotationProcessors=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1270 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1271 Gets projects and libraries sorted such that dependencies
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1272 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
1273 true, libraries are omitted from the result.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1274 """
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1275 projects = projects_from_names(projectNames)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1276
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1277 return sorted_project_deps(projects, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1278
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1279 def sorted_project_deps(projects, includeLibs=False, includeAnnotationProcessors=False):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1280 deps = []
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1281 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
1282 p.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1283 return deps
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1284
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1285 def _handle_missing_java_home():
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1286 if not sys.stdout.isatty():
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1287 abort('Could not find bootstrap JDK. Use --java-home option or ensure JAVA_HOME environment variable is set.')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1288
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1289 candidateJdks = []
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1290 if get_os() == 'darwin':
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1291 base = '/Library/Java/JavaVirtualMachines'
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1292 candidateJdks = [join(base, n, 'Contents/Home') for n in os.listdir(base) if exists(join(base, n, 'Contents/Home'))]
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1293 elif get_os() == 'linux':
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1294 base = '/usr/lib/jvm'
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1295 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, 'jre/lib/rt.jar'))]
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1296 elif get_os() == 'solaris':
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1297 base = '/usr/jdk/instances'
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1298 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, 'jre/lib/rt.jar'))]
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1299 elif get_os() == 'windows':
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1300 base = r'C:\Program Files\Java'
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1301 candidateJdks = [join(base, n) for n in os.listdir(base) if exists(join(base, n, r'jre\lib\rt.jar'))]
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1302
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1303 javaHome = None
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1304 if len(candidateJdks) != 0:
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1305 javaHome = select_items(candidateJdks + ['<other>'], allowMultiple=False)
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1306 if javaHome == '<other>':
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1307 javaHome = None
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1308
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1309 while javaHome is None:
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1310 javaHome = raw_input('Enter path of bootstrap JDK: ')
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1311 rtJarPath = join(javaHome, 'jre', 'lib', 'rt.jar')
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1312 if not exists(rtJarPath):
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1313 log('Does not appear to be a valid JDK as ' + rtJarPath + ' does not exist')
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1314 javaHome = None
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1315 else:
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1316 break
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1317
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1318 envPath = join(_mainSuite.mxDir, 'env')
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
1319 if ask_yes_no('Persist this setting by adding "JAVA_HOME=' + javaHome + '" to ' + envPath, 'y'):
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1320 with open(envPath, 'a') as fp:
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1321 print >> fp, 'JAVA_HOME=' + javaHome
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1322
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1323 return javaHome
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1324
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1325 class ArgParser(ArgumentParser):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1326 # 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
1327 def format_help(self):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1328 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
1329
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1330
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1331 def __init__(self):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1332 self.java_initialized = False
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1333 # this doesn't resolve the right way, but can't figure out how to override _handle_conflict_resolve in _ActionsContainer
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1334 ArgumentParser.__init__(self, prog='mx', conflict_handler='resolve')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1335
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1336 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
1337 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output')
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1338 self.add_argument('-w', action='store_true', dest='warn', help='enable warning messages')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1339 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
1340 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
1341 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
1342 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1343 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default='-ea -Xss2m -Xmx1g')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1344 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
1345 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
1346 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~'))
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1347 self.add_argument('--java-home', help='bootstrap 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
1348 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[])
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1349 self.add_argument('--suite', action='append', dest='specific_suites', help='limit command to given suite', default=[])
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1350 self.add_argument('--src-suitemodel', help='mechanism for locating imported suites', metavar='<arg>', default='sibling')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1351 self.add_argument('--dst-suitemodel', help='mechanism for placing cloned/pushed suites', metavar='<arg>', default='sibling')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1352 self.add_argument('--suitemap', help='explicit remapping of suite names', metavar='<args>')
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
1353 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
1354 # Time outs are (currently) implemented with Unix specific functionality
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1355 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>')
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1356 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
1357
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1358 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
1359 if args is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1360 args = sys.argv[1:]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1361
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1362 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
1363
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1364 opts = self.parse_args()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1365
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1366 # 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
1367 opts.__dict__.setdefault('timeout', 0)
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1368 opts.__dict__.setdefault('ptimeout', 0)
4149
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
1369
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
1370 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
1371 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
1372
4149
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
1373 if opts.java_home is None:
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
1374 opts.java_home = os.environ.get('JAVA_HOME')
cf4de9cc1268 Integrated latest mxtool updates.
Doug Simon <doug.simon@oracle.com>
parents: 4148
diff changeset
1375
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1376 if opts.java_home is None or opts.java_home == '':
11301
8bcae501c51b added dialogue for determining JAVA_HOME if it's not set
Doug Simon <doug.simon@oracle.com>
parents: 11295
diff changeset
1377 opts.java_home = _handle_missing_java_home()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1378
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1379 if opts.user_home is None or opts.user_home == '':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1380 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
1381
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1382 os.environ['JAVA_HOME'] = opts.java_home
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1383 os.environ['HOME'] = opts.user_home
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1384
5821
0cd337450409 added support to mx for ignoring (broken) projects
Doug Simon <doug.simon@oracle.com>
parents: 5782
diff changeset
1385 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
1386
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1387 commandAndArgs = opts.__dict__.pop('commandAndArgs')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1388 return opts, commandAndArgs
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1389
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1390 def _handle_conflict_resolve(self, action, conflicting_actions):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1391 self._handle_conflict_error(action, conflicting_actions)
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
1392
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1393 def _format_commands():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1394 msg = '\navailable commands:\n\n'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1395 for cmd in sorted(_commands.iterkeys()):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1396 c, _ = _commands[cmd][:2]
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1397 doc = c.__doc__
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1398 if doc is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1399 doc = ''
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1400 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
1401 return msg + '\n'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1402
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1403 def java():
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1404 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1405 Get a JavaConfig object containing Java commands launch details.
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1406 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1407 assert _java is not None
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1408 return _java
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1409
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1410 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
1411 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
1412
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1413 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
1414 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
1415 try:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1416 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
1417 return True
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1418 except:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1419 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
1420 return False
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1421
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1422 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
1423 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
1424 while True:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1425 try:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1426 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
1427 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
1428 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
1429 continue
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1430 raise
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1431
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
1432 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
1433 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
1434 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
1435 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
1436 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
1437 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
1438 # 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
1439 raise RuntimeError("Unknown child exit status!")
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1440
4158
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1441 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
1442 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
1443 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
1444 (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
1445 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
1446 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
1447 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
1448 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
1449 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
1450 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
1451 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
1452
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1453 # 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
1454 # 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
1455 _currentSubprocess = None
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1456
4660
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1457 def waitOn(p):
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1458 if get_os() == 'windows':
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1459 # 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
1460 retcode = None
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1461 while retcode == None:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1462 retcode = p.poll()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1463 time.sleep(0.05)
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1464 else:
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1465 retcode = p.wait()
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1466 return retcode
b06ade6e927c Fixed Ctrl+C for Windows in mx.py
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4482
diff changeset
1467
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
1468 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
1469 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1470 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
1471 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
1472 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
1473 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
1474 out and err if they are callable objects.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1475 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1476
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1477 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
1478 for arg in args:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1479 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
1480
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1481 if env is None:
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1482 env = os.environ
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1483
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1484 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
1485 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
1486 log('Environment variables:')
9262
0f4ae7bbe062 fixed bug in handling of -V mx option
Doug Simon <doug.simon@oracle.com>
parents: 9193
diff changeset
1487 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
1488 log(' ' + key + '=' + env[key])
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1489 log(' '.join(args))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1490
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
1491 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
1492 timeout = _opts.ptimeout
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1493
4293
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
1494 global _currentSubprocess
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1495
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1496 try:
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1497 # 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
1498 # 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
1499 preexec_fn = None
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1500 creationflags = 0
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1501 if get_os() == 'windows':
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1502 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
1503 else:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1504 preexec_fn = os.setsid
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1505
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
1506 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
1507 # 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
1508 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
1509 _currentSubprocess = (p, args)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1510 retcode = waitOn(p)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1511 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1512 def redirect(stream, f):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1513 for line in iter(stream.readline, ''):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1514 f(line)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1515 stream.close()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1516 stdout = out if not callable(out) else subprocess.PIPE
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1517 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
1518 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
1519 _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
1520 if callable(out):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1521 t = Thread(target=redirect, args=(p.stdout, out))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1522 t.daemon = True # thread dies with the program
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1523 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
1524 if callable(err):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1525 t = Thread(target=redirect, args=(p.stderr, err))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1526 t.daemon = True # thread dies with the program
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1527 t.start()
4161
8c507a8dd6a4 Interpret '--timeout 0' correctly (i.e. as no timeout).
Doug Simon <doug.simon@oracle.com>
parents: 4158
diff changeset
1528 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
1529 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
1530 else:
f3a50640333b Added support for specifying a timeout when running an external command.
Doug Simon <doug.simon@oracle.com>
parents: 4150
diff changeset
1531 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
1532 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
1533 retcode = _waitWithTimeout(p, args, timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1534 except OSError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1535 log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1536 if _opts.verbose:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1537 raise e
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1538 abort(e.errno)
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1539 except KeyboardInterrupt:
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1540 abort(1)
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1541 finally:
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
1542 _currentSubprocess = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1543
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1544 if retcode and nonZeroIsFatal:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1545 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
1546 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
1547 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
1548 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1549 log('[exit code: ' + str(retcode) + ']')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1550 abort(retcode)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1551
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1552 return retcode
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1553
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1554 def exe_suffix(name):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1555 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1556 Gets the platform specific suffix for an executable
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1557 """
4258
8d2c14f722ac mx.py: fix OS detection in exe_suffix()
Andreas Woess <andreas.woess@jku.at>
parents: 4257
diff changeset
1558 if get_os() == 'windows':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1559 return name + '.exe'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1560 return name
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1561
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1562 def add_lib_prefix(name):
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1563 """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1564 Adds the platform specific library prefix to a name
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1565 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1566 os = get_os()
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1567 if os == 'linux' or os == 'solaris' or os == 'darwin':
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1568 return 'lib' + name
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1569 return name
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1570
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1571 def add_lib_suffix(name):
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1572 """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11374
diff changeset
1573 Adds the platform specific library suffix to a name
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1574 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1575 os = get_os()
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1576 if os == 'windows':
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1577 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
1578 if os == 'linux' or os == 'solaris':
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1579 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
1580 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
1581 return name + '.dylib'
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1582 return name
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4396
diff changeset
1583
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1584 """
12042
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1585 Utility for filtering duplicate lines.
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1586 """
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1587 class DuplicateSuppressingStream:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1588 """
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1589 Creates an object that will suppress duplicate lines sent to 'out'.
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1590 The lines considered for suppression are those that contain one of the
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1591 strings in 'restrictTo' if it is not None.
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1592 """
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1593 def __init__(self, restrictTo=None, out=sys.stdout):
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1594 self.restrictTo = restrictTo
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1595 self.seen = set()
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1596 self.out = out
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1597
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1598 def isSuppressionCandidate(self, line):
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1599 if self.restrictTo:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1600 for p in self.restrictTo:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1601 if p in line:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1602 return True
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1603 return False
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1604 else:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1605 return True
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1606
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1607 def write(self, line):
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1608 if self.isSuppressionCandidate(line):
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1609 if line in self.seen:
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1610 return
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1611 self.seen.add(line)
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1612 self.out.write(line)
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1613
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
1614 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1615 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
1616 """
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1617 class JavaCompliance:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1618 def __init__(self, ver):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1619 m = re.match(r'1\.(\d+).*', ver)
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
1620 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
1621 self.value = int(m.group(1))
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1622
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1623 def __str__ (self):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1624 return '1.' + str(self.value)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1625
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1626 def __cmp__ (self, other):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1627 if isinstance(other, types.StringType):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1628 other = JavaCompliance(other)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1629
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1630 return cmp(self.value, other.value)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1631
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1632 """
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1633 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
1634 """
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1635 class JavaVersion:
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1636 def __init__(self, versionString):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1637 validChar = r'[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1638 separator = r'[.\-_]'
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1639 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
1640 assert m is not None, 'not a recognized version string: ' + versionString
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1641 self.versionString = versionString
8391
d1d486c03e8a Fix version parsing in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8302
diff changeset
1642 self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1643
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1644 def __str__(self):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1645 return self.versionString
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1646
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1647 def __cmp__(self, other):
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1648 return cmp(self.parts, other.parts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1649
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1650 """
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1651 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
1652 """
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1653 class JavaConfig:
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1654 def __init__(self, opts):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1655 self.jdk = opts.java_home
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1656 self.debug_port = opts.java_dbg_port
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1657 self.jar = exe_suffix(join(self.jdk, 'bin', 'jar'))
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1658 self.java = exe_suffix(join(self.jdk, 'bin', 'java'))
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1659 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac'))
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1660 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
1661 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
1662 self._bootclasspath = None
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1663
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
1664 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
1665 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
1666
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1667 def delAtAndSplit(s):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1668 return shlex.split(s.lstrip('@'))
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1669
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1670 self.java_args = delAtAndSplit(_opts.java_args)
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1671 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
1672 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
1673
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1674 # 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
1675 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1676 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
1677 self.java_args = ['-d64'] + self.java_args
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1678 except subprocess.CalledProcessError as e:
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1679 try:
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1680 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
1681 except subprocess.CalledProcessError as e:
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1682 print e.output
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1683 abort(e.returncode)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1684
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
1685 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
1686 assert output[1] == 'version'
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1687 self.version = JavaVersion(output[2].strip('"'))
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
1688 self.javaCompliance = JavaCompliance(self.version.versionString)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1689
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1690 if self.debug_port is not None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1691 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
1692
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1693 def format_cmd(self, args):
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
1694 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
1695
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1696 def bootclasspath(self):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1697 if self._bootclasspath is None:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1698 tmpDir = tempfile.mkdtemp()
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1699 try:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1700 src = join(tmpDir, 'bootclasspath.java')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1701 with open(src, 'w') as fp:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1702 print >> fp, """
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1703 public class bootclasspath {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1704 public static void main(String[] args) {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1705 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
1706 if (s != null) {
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1707 System.out.println(s);
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1708 }
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1709 }
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1710 }"""
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1711 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
1712 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
1713 finally:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1714 shutil.rmtree(tmpDir)
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1715 return self._bootclasspath
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1716
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1717 def check_get_env(key):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1718 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1719 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
1720 """
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
1721 value = get_env(key)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1722 if value is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1723 abort('Required environment variable ' + key + ' must be set')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1724 return value
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1725
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
1726 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
1727 """
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
1728 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
1729 """
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
1730 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
1731 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
1732
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
1733 def logv(msg=None):
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
1734 if _opts.verbose:
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
1735 log(msg)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1736
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1737 def log(msg=None):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1738 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1739 Write a message to the console.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1740 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
1741 to redirect it.
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1742 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1743 if msg is None:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1744 print
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1745 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1746 print msg
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1747
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1748 def expand_project_in_class_path_arg(cpArg):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1749 cp = []
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1750 for part in cpArg.split(os.pathsep):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1751 if part.startswith('@'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1752 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
1753 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1754 cp.append(part)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1755 return os.pathsep.join(cp)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1756
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1757 def expand_project_in_args(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1758 for i in range(len(args)):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1759 if args[i] == '-cp' or args[i] == '-classpath':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1760 if i + 1 < len(args):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1761 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
1762 return
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1763
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1764
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1765 def gmake_cmd():
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1766 for a in ['make', 'gmake', 'gnumake']:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1767 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1768 output = subprocess.check_output([a, '--version'])
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1769 if 'GNU' in output:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1770 return a
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1771 except:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1772 pass
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1773 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
1774
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1775 def expandvars_in_property(value):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1776 result = expandvars(value)
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1777 if '$' in result or '%' in result:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1778 abort('Property contains an undefined environment variable: ' + value)
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1779 return result
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1780
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1781
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1782 def abort(codeOrMessage):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1783 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1784 Aborts the program with a SystemExit exception.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1785 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
1786 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
1787 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
1788 """
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1789
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1790 # import traceback
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1791 # traceback.print_stack()
4242
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1792 currentSubprocess = _currentSubprocess
3e25132be4b4 Disabled eager resolution of libraries as they are defined.
Doug Simon <doug.simon@oracle.com>
parents: 4241
diff changeset
1793 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
1794 p, _ = currentSubprocess
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1795 if get_os() == 'windows':
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1796 p.kill()
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1797 else:
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4248
diff changeset
1798 _kill_process_group(p.pid)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1799
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1800 raise SystemExit(codeOrMessage)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1801
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1802 def download(path, urls, verbose=False):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1803 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1804 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
1805 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
1806 is written to the file indicated by 'path'.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1807 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1808 d = dirname(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1809 if d != '' and not exists(d):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1810 os.makedirs(d)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1811
4188
148fa38782e8 Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents: 4186
diff changeset
1812 # 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
1813 myDir = dirname(__file__)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1814
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1815 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
1816 javaSource = join(myDir, 'URLConnectionDownload.java')
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1817 javaClass = join(myDir, 'URLConnectionDownload.class')
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1818 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
1819 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
1820 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
1821 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1822
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1823 def url_open(url):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1824 userAgent = 'Mozilla/5.0 (compatible)'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1825 headers = { 'User-Agent' : userAgent }
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1826 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
1827 return urllib2.urlopen(req)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1828
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1829 for url in urls:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1830 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1831 if (verbose):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1832 log('Downloading ' + url + ' to ' + path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1833 if url.startswith('zip:') or url.startswith('jar:'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1834 i = url.find('!/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1835 if i == -1:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1836 abort('Zip or jar URL does not contain "!/": ' + url)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1837 url, _, entry = url[len('zip:'):].partition('!/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1838 with contextlib.closing(url_open(url)) as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1839 data = f.read()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1840 zipdata = StringIO.StringIO(f.read())
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1841
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1842 zf = zipfile.ZipFile(zipdata, 'r')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1843 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
1844 with open(path, 'wb') as f:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1845 f.write(data)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1846 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1847 with contextlib.closing(url_open(url)) as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1848 data = f.read()
6350
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1849 if path.endswith(os.sep):
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1850 # 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
1851 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
1852 if len(hrefs) != 0:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1853 for href in hrefs:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1854 if not '/' in href:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1855 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
1856 else:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1857 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
1858 else:
f45d5cb03c3b added support for downloading dependencies that are directories
Doug Simon <doug.simon@oracle.com>
parents: 6335
diff changeset
1859 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
1860 f.write(data)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1861 return
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1862 except IOError as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1863 log('Error reading from ' + url + ': ' + str(e))
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1864 except zipfile.BadZipfile as e:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1865 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
1866
4188
148fa38782e8 Downloads are attempted via Java first since it shows a progress counter.
Doug Simon <doug.simon@oracle.com>
parents: 4186
diff changeset
1867 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
1868 '\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
1869
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1870 def update_file(path, content):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1871 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1872 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
1873 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
1874 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1875 existed = exists(path)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1876 try:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1877 old = None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1878 if existed:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1879 with open(path, 'rb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1880 old = f.read()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1881
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1882 if old == content:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1883 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1884
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1885 with open(path, 'wb') as f:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1886 f.write(content)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1887
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1888 log(('modified ' if existed else 'created ') + path)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1889 return True
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1890 except IOError as e:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1891 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
1892
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1893 # Builtin commands
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1894
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1895 def build(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1896 """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
1897
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1898 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
1899 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
1900
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
1901 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
1902 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
1903 parser = ArgumentParser(prog='mx build')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1904
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1905 javaCompliance = java().javaCompliance
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1906
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
1907 defaultEcjPath = join(_mainSuite.mxDir, 'ecj.jar')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
1908
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
1909 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
1910 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
1911 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
1912 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
1913 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
1914 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
1915 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
1916 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
1917 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
1918 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
1919 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
1920
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
1921 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
1922 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
1923
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1924 args = parser.parse_args(args)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1925
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1926 jdtJar = None
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1927 if args.jdt is not None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1928 if args.jdt.endswith('.jar'):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1929 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
1930 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
1931 # 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
1932 jdtJar = None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1933
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1934 built = set()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1935
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
1936 if args.only is not None:
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1937 # N.B. This build will not include dependencies including annotation processor dependencies
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
1938 sortedProjects = [project(name) for name in args.only.split(',')]
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1939 else:
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1940 if args.projects is not None:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1941 projectNames = args.projects.split(',')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1942 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1943 projectNames = None
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1944
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1945 projects = _projects_opt_limit_to_suites(projects_from_names(projectNames))
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1946 # N.B. Limiting to a suite only affects the starting set of projects. Dependencies in other suites will still be compiled
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
1947 sortedProjects = sorted_project_deps(projects, includeAnnotationProcessors=True)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1948
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
1949 if args.java:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
1950 ideinit([], refreshOnly=True, buildProcessorJars=False)
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
1951
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
1952 for p in sortedProjects:
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1953 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1954 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1955 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
1956
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1957 if args.clean:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1958 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
1959
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1960 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
1961 built.add(p.name)
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1962 continue
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1963 else:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1964 if not args.java:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
1965 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
1966 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
1967 continue
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1968
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1969 # 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
1970 if javaCompliance < p.javaCompliance:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1971 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
1972 continue
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1973
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1974 outputDir = p.output_dir()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1975 if exists(outputDir):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1976 if args.clean:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1977 log('Cleaning {0}...'.format(outputDir))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1978 shutil.rmtree(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1979 os.mkdir(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1980 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1981 os.mkdir(outputDir)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1982
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
1983 cp = classpath(p.name, includeSelf=True)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1984 sourceDirs = p.source_dirs()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1985 mustBuild = args.force
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1986 if not mustBuild:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
1987 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
1988 if dep.name in built:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1989 mustBuild = True
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1990
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1991 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
1992 javafilelist = []
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1993 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1994 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
1995 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
1996 javafilelist += javafiles
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1997
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
1998 # 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
1999 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
2000 for src in nonjavafilelist:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2001 if src.endswith('.jasm'):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2002 className = None
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2003 with open(src) as f:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2004 for line in f:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2005 if line.startswith('.class '):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2006 className = line.split()[-1]
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2007 break
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2008
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2009 if className is not None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2010 jasminOutputDir = p.jasmin_output_dir()
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2011 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
2012 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
2013 if jasminAvailable is None:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2014 try:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2015 with open(os.devnull) as devnull:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2016 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
2017 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
2018 except OSError:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2019 jasminAvailable = False
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2020
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2021 if jasminAvailable:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2022 log('Assembling Jasmin file ' + src)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2023 run(['jasmin', '-d', jasminOutputDir, src])
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2024 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2025 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
2026 with file(classFile, 'a'):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2027 os.utime(classFile, None)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2028
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2029 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2030 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
2031 else:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2032 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
2033 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
2034 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
2035 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
2036 shutil.copyfile(src, dst)
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2037
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2038 if not mustBuild:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2039 for javafile in javafiles:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2040 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
2041 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
2042 mustBuild = True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2043 break
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2044
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
2045 if not mustBuild:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2046 logv('[all class files for {0} are up to date - skipping]'.format(p.name))
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
2047 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2048
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
2049 if len(javafilelist) == 0:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2050 logv('[no Java sources for {0} - skipping]'.format(p.name))
4247
3f6c6e61614e Changed 'mx build' such that all Java sources for a project are compiled together instead of by source directory.
Doug Simon <doug.simon@oracle.com>
parents: 4242
diff changeset
2051 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
2052
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
2053 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
2054
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
2055 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
2056 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
2057 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
2058 argfile.close()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2059
11189
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2060 processorArgs = []
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
2061
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2062 ap = p.annotation_processors()
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2063 if len(ap) > 0:
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2064 processorPath = classpath(ap, resolve=True)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2065 genDir = p.source_gen_dir()
6535
f938212e56ab Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6533
diff changeset
2066 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
2067 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
2068 os.mkdir(genDir)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2069 processorArgs += ['-processorpath', join(processorPath), '-s', genDir]
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2070 else:
11189
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2071 processorArgs += ['-proc:none']
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
2072
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2073 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
2074 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
2075 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
2076 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
2077 log('Compiling Java sources for {0} with javac...'.format(p.name))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2078
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2079
11189
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2080 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-classpath', cp, '-d', outputDir]
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2081 if java().debug_port is not None:
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2082 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2083 javacCmd += processorArgs
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2084 javacCmd += ['@' + argfile.name]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2085
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
2086 if not args.warnAPI:
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2087 javacCmd.append('-XDignore.symbol.file')
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
2088 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
2089 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
2090 log('Compiling Java sources for {0} with JDT...'.format(p.name))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2091
11189
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2092 jdtArgs = [java().java, '-Xmx1g']
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2093 if java().debug_port is not None:
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2094 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2095
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2096 jdtArgs += [ '-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
2097 '-' + 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
2098 '-cp', cp, '-g', '-enableJavadoc',
11189
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2099 '-d', outputDir]
8ce168d68d49 Fixed mx script debug vm arguments for ecj builds. Its now possible to debug ecj builds using -d as argument.
Christian Humer <christian.humer@gmail.com>
parents: 10585
diff changeset
2100 jdtArgs += processorArgs
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2101
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2102
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
2103 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
2104 rootJdtProperties = join(p.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs')
7787
2865133eeef2 mx: When doanload fails using Java, try using python
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7778
diff changeset
2105 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
2106 # 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
2107 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
2108 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
2109 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
2110 else:
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2111 # 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
2112 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
2113 jdtPropertiesTmp = jdtProperties + '.tmp'
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2114 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
2115 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
2116 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
2117 fp.write(content)
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2118 toBeDeleted.append(jdtPropertiesTmp)
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2119 jdtArgs += ['-properties', jdtPropertiesTmp]
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2120 else:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2121 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
2122 jdtArgs.append('@' + argfile.name)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2123
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
2124 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
2125 finally:
5778
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2126 for n in toBeDeleted:
74c802348d1f added --jdt-warning-as-error option to 'mx build'
Doug Simon <doug.simon@oracle.com>
parents: 5771
diff changeset
2127 os.remove(n)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2128
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2129 for dist in _dists.values():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2130 archive(['@' + dist.name])
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2131
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
2132 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
2133 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
2134 return None
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2135
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
2136 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
2137 """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
2138
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
2139 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
2140
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
2141 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
2142 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
2143 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
2144 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2145
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
2146 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
2147 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
2148 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
2149 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
2150 abort('Could not find Eclipse executable. Use -e option or ensure ECLIPSE_EXE environment variable is set.')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2151
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
2152 # 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
2153 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
2154 args.eclipse_exe = join(args.eclipse_exe, exe_suffix('eclipse'))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2155
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
2156 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
2157 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
2158
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
2159 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
2160
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2161 # build list of projects to be processed
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2162 projects = sorted_deps()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2163 if args.projects is not None:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2164 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
2165
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2166 class Batch:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2167 def __init__(self, settingsFile):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2168 self.path = settingsFile
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2169 self.javafiles = list()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2170
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2171 def settings(self):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2172 with open(self.path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2173 return fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2174
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2175 class FileInfo:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2176 def __init__(self, path):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2177 self.path = path
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2178 with open(path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2179 self.content = fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2180 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
2181
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2182 def update(self):
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2183 with open(self.path) as fp:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2184 content = fp.read()
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2185 if self.content != content:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2186 self.content = content
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2187 return True
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2188 os.utime(self.path, self.times)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2189
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2190 modified = list()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2191 batches = dict() # all sources with the same formatting settings are formatted together
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2192 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
2193 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
2194 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
2195 sourceDirs = p.source_dirs()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2196
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2197 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
2198
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2199 if not exists(batch.path):
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2200 if _opts.verbose:
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2201 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
2202 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
2203
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
2204 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
2205 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
2206 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
2207 batch.javafiles.append(FileInfo(f))
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2208 if len(batch.javafiles) == 0:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2209 logv('[no Java sources in {0} - skipping]'.format(p.name))
7528
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2210 continue
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2211
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2212 res = batches.setdefault(batch.settings(), batch)
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2213 if res is not batch:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2214 res.javafiles = res.javafiles + batch.javafiles
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2215
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2216 for batch in batches.itervalues():
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2217 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
2218 for fi in batch.javafiles:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2219 if fi.update():
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2220 modified.append(fi)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2221
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
2222 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
2223 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
2224 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
2225 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
2226 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
2227 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
2228 for fi in modified:
4584ca2618d5 made eclipseformat command use batching
Doug Simon <doug.simon@oracle.com>
parents: 7524
diff changeset
2229 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
2230 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
2231 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
2232 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
2233 return 1
7533
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7532
diff changeset
2234 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
2235
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
2236 def processorjars():
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2237
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
2238 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
2239 for p in sorted_deps():
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2240 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
2241 projs.add(p)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2242
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
2243 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
2244 return
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2245
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
2246 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
2247 build(['--projects', ",".join(pnames)])
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2248 archive(pnames)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2249
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2250 def pylint(args):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2251 """run pylint (if available) over Python source files (found by 'hg locate' or by tree walk with -walk)"""
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2252
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2253 parser = ArgumentParser(prog='mx pylint')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2254 parser.add_argument('--walk', action='store_true', help='use tree walk find .py files')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2255 args = parser.parse_args(args)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2256
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2257 rcfile = join(dirname(__file__), '.pylintrc')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2258 if not exists(rcfile):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2259 log('pylint configuration file does not exist: ' + rcfile)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2260 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2261
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2262 try:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2263 output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2264 m = re.match(r'.*pylint (\d+)\.(\d+)\.(\d+).*', output, re.DOTALL)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2265 if not m:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2266 log('could not determine pylint version from ' + output)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2267 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2268 major, minor, micro = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2269 if major < 1:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2270 log('require pylint version >= 1 (got {0}.{1}.{2})'.format(major, minor, micro))
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2271 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2272 except BaseException:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2273 log('pylint is not available')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2274 return
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2275
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2276 def findfiles_by_walk():
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2277 result = []
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2278 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2279 for root, dirs, files in os.walk(suite.dir):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2280 for f in files:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2281 if f.endswith('.py'):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2282 pyfile = join(root, f)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2283 result.append(pyfile)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2284 if 'bin' in dirs:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2285 dirs.remove('bin')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2286 if 'lib' in dirs:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2287 # avoids downloaded .py files
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2288 dirs.remove('lib')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2289 return result
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2290
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2291 def findfiles_by_hg():
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2292 result = []
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2293 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2294 versioned = subprocess.check_output(['hg', 'locate', '-f'], stderr=subprocess.STDOUT, cwd=suite.dir).split(os.linesep)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2295 for f in versioned:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2296 if f.endswith('.py') and exists(f):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2297 result.append(f)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2298 return result
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2299
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2300 # Perhaps we should just look in suite.mxDir directories for .py files?
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2301 if args.walk:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2302 pyfiles = findfiles_by_walk()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2303 else:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2304 pyfiles = findfiles_by_hg()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2305
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2306 env = os.environ.copy()
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2307
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2308 pythonpath = dirname(__file__)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2309 for suite in suites(True):
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2310 pythonpath = os.pathsep.join([pythonpath, suite.mxDir])
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2311
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2312 env['PYTHONPATH'] = pythonpath
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2313
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2314 for pyfile in pyfiles:
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2315 log('Running pylint on ' + pyfile + '...')
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2316 run(['pylint', '--reports=n', '--rcfile=' + rcfile, pyfile], env=env, nonZeroIsFatal=False)
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
2317
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2318 def archive(args):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2319 """create jar files for projects and distributions"""
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2320 parser = ArgumentParser(prog='mx archive')
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2321 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
2322 args = parser.parse_args(args)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2323
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2324 for name in args.names:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2325 if name.startswith('@'):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2326 dname = name[1:]
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2327 d = distribution(dname)
8183
4b11a0983557 fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents: 8182
diff changeset
2328 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
2329 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
10576
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2330
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2331 def overwriteCheck(zf, arcname, source):
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2332 if arcname in zf.namelist():
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2333 log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2334
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
2335 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
2336 zf = zipfile.ZipFile(tmp, 'w')
10576
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2337 for dep in sorted_deps(d.deps, includeLibs=True):
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2338 if dep.isLibrary():
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2339 l = dep
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2340 # merge library jar into distribution jar
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2341 logv('[' + d.path + ': adding library ' + l.name + ']')
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2342 lpath = l.get_path(resolve=True)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2343 if lpath:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2344 with zipfile.ZipFile(lpath, 'r') as lp:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2345 for arcname in lp.namelist():
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2346 if arcname.startswith('META-INF/services/') and not arcname == 'META-INF/services/':
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2347 f = arcname[len('META-INF/services/'):].replace('/', os.sep)
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2348 with open(join(services, f), 'a') as outfile:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2349 for line in lp.read(arcname).splitlines():
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2350 outfile.write(line)
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2351 else:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2352 overwriteCheck(zf, arcname, lpath + '!' + arcname)
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2353 zf.writestr(arcname, lp.read(arcname))
10576
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2354 else:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2355 p = dep
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2356 # skip a Java project if its Java compliance level is "higher" than the configured JDK
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2357 if java().javaCompliance < p.javaCompliance:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2358 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path))
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2359 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2360
10576
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2361 logv('[' + d.path + ': adding project ' + p.name + ']')
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2362 outputDir = p.output_dir()
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2363 for root, _, files in os.walk(outputDir):
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2364 relpath = root[len(outputDir) + 1:]
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2365 if relpath == join('META-INF', 'services'):
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2366 for f in files:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2367 with open(join(services, f), 'a') as outfile:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2368 with open(join(root, f), 'r') as infile:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2369 for line in infile:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2370 outfile.write(line)
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2371 elif relpath == join('META-INF', 'providers'):
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2372 for f in files:
8585
aaf3988bd1b4 made 'mx archive' clean up temporary files upon failure during archive file creation
Doug Simon <doug.simon@oracle.com>
parents: 8528
diff changeset
2373 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
2374 for line in infile:
10576
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2375 with open(join(services, line.strip()), 'a') as outfile:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2376 outfile.write(f + '\n')
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2377 else:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2378 for f in files:
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2379 arcname = join(relpath, f).replace(os.sep, '/')
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2380 overwriteCheck(zf, arcname, join(root, f))
aee899c96b0b distribution jars (e.g., graal.jar) now contain library dependencies
Doug Simon <doug.simon@oracle.com>
parents: 10568
diff changeset
2381 zf.write(join(root, f), arcname)
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
2382 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
2383 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
2384 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
2385 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
2386 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
2387 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
2388 # 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
2389 shutil.move(tmp, d.path)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2390 # print time.time(), 'move:', tmp, '->', 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
2391 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
2392 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
2393 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
2394 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
2395 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
2396 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
2397
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2398 else:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2399 p = project(name)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2400 outputDir = p.output_dir()
8183
4b11a0983557 fixed issue with deleting temp files on Windows
Doug Simon <doug.simon@oracle.com>
parents: 8182
diff changeset
2401 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
2402 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
2403 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
2404 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
2405 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
2406 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
2407 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
2408 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
2409 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
2410 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
2411 # 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
2412 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
2413 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
2414 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
2415 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
2416
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2417 def canonicalizeprojects(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2418 """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
2419
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2420 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
2421
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2422 changedFiles = 0
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
2423 for s in suites(True):
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2424 projectsFile = join(s.mxDir, 'projects')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2425 if not exists(projectsFile):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2426 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2427 with open(projectsFile) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2428 out = StringIO.StringIO()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2429 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
2430 lineNo = 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2431 for line in f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2432 line = line.strip()
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2433 m = pattern.match(line)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2434 if m is None:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2435 out.write(line + '\n')
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2436 else:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2437 p = project(m.group(1))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2438
6533
250babea75d5 modified canonicalizeprojects to ensure all package prefixes match the enclosing project
Doug Simon <doug.simon@oracle.com>
parents: 6527
diff changeset
2439 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
2440 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
2441 abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2442
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
2443 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
2444 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
2445 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
2446 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
2447 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
2448 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
2449 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
2450 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
2451 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
2452 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
2453 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
2454 if len(ignoredDeps) != 0:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2455 candidates = set()
6527
3c5b19e8f2a3 modified canonicalizeprojects to detect imprecise dependencies (e.g., A specifies that it depends on B but only imports packages from B's dependencies)
Doug Simon <doug.simon@oracle.com>
parents: 6509
diff changeset
2456 # 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
2457 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
2458 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
2459 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
2460 # 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
2461 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
2462 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
2463 candidates = [d.name for d in candidates]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2464
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
2465 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
2466 projectsFile, lineNo, p, ', '.join(ignoredDeps), ','.join(candidates)))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2467
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2468 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
2469 lineNo = lineNo + 1
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2470 content = out.getvalue()
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2471 if update_file(projectsFile, content):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2472 changedFiles += 1
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2473 return changedFiles
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2474
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2475 class TimeStampFile:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2476 def __init__(self, path):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2477 self.path = path
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2478 self.timestamp = os.path.getmtime(path) if exists(path) else None
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2479
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2480 def outOfDate(self, arg):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2481 if not self.timestamp:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2482 return True
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2483 if isinstance(arg, types.ListType):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2484 files = arg
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2485 else:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2486 files = [arg]
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2487 for f in files:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2488 if os.path.getmtime(f) > self.timestamp:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2489 return True
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2490 return False
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2491
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2492 def exists(self):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2493 return exists(self.path)
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2494
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2495 def touch(self):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2496 if exists(self.path):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2497 os.utime(self.path, None)
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2498 else:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2499 if not isdir(dirname(self.path)):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2500 os.makedirs(dirname(self.path))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2501 file(self.path, 'a')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2502
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2503 def checkstyle(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2504 """run Checkstyle on the Java sources
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2505
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2506 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
2507 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
2508
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2509 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
2510
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2511 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
2512 args = parser.parse_args(args)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2513
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2514 totalErrors = 0
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2515 for p in projects_opt_limit_to_suites():
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2516 if p.native:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2517 continue
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2518 sourceDirs = p.source_dirs()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2519 dotCheckstyle = join(p.dir, '.checkstyle')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2520
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2521 if not exists(dotCheckstyle):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2522 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2523
10060
193d5163a94a exclude projects from mx checkstyle if their Java compliance level is higher than the configured JDK
Doug Simon <doug.simon@oracle.com>
parents: 10059
diff changeset
2524 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK
193d5163a94a exclude projects from mx checkstyle if their Java compliance level is higher than the configured JDK
Doug Simon <doug.simon@oracle.com>
parents: 10059
diff changeset
2525 if java().javaCompliance < p.javaCompliance:
193d5163a94a exclude projects from mx checkstyle if their Java compliance level is higher than the configured JDK
Doug Simon <doug.simon@oracle.com>
parents: 10059
diff changeset
2526 log('Excluding {0} from checking (Java compliance level {1} required)'.format(p.name, p.javaCompliance))
193d5163a94a exclude projects from mx checkstyle if their Java compliance level is higher than the configured JDK
Doug Simon <doug.simon@oracle.com>
parents: 10059
diff changeset
2527 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2528
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2529 for sourceDir in sourceDirs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2530 javafilelist = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2531 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
2532 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
2533 if len(javafilelist) == 0:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2534 logv('[no Java sources in {0} - skipping]'.format(sourceDir))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2535 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2536
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2537 timestamp = TimeStampFile(join(p.suite.mxDir, 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp'))
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2538 mustCheck = False
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2539 if not args.force and timestamp.exists():
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2540 mustCheck = timestamp.outOfDate(javafilelist)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2541 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2542 mustCheck = True
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2543
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2544 if not mustCheck:
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2545 if _opts.verbose:
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2546 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
2547 continue
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2548
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2549 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2550 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
2551 configLocation = localCheckConfig.getAttribute('location')
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2552 configType = localCheckConfig.getAttribute('type')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2553 if configType == 'project':
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2554 # Eclipse plugin "Project Relative Configuration" format:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2555 #
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2556 # '/<project_name>/<suffix>'
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2557 #
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2558 if configLocation.startswith('/'):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2559 name, _, suffix = configLocation.lstrip('/').partition('/')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2560 config = join(project(name).dir, suffix)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2561 else:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2562 config = join(p.dir, configLocation)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2563 else:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
2564 logv('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir))
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2565 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2566
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2567 exclude = join(p.dir, '.checkstyle.exclude')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2568
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2569 if exists(exclude):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2570 with open(exclude) as f:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2571 # Convert patterns to OS separators
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2572 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
2573 def match(name):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2574 for p in patterns:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2575 if p in name:
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2576 if _opts.verbose:
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2577 log('excluding: ' + name)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2578 return True
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2579 return False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2580
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2581 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
2582
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2583 auditfileName = join(p.dir, 'checkstyleOutput.txt')
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2584 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
2585
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2586 try:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2587
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2588 # 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
2589 # 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
2590 # 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
2591 # 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
2592 while len(javafilelist) != 0:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2593 i = 0
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2594 size = 0
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2595 while i < len(javafilelist):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2596 s = len(javafilelist[i]) + 1
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2597 if (size + s < 30000):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2598 size += s
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2599 i += 1
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2600 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2601 break
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2602
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2603 batch = javafilelist[:i]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2604 javafilelist = javafilelist[i:]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2605 try:
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2606 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
2607 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2608 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
2609 errors = []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2610 source = [None]
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
2611 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
2612 if name == 'file':
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2613 source[0] = attrs['name']
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
2614 elif name == 'error':
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2615 errors.append('{}:{}: {}'.format(source[0], attrs['line'], attrs['message']))
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
2616
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2617 xp = xml.parsers.expat.ParserCreate()
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2618 xp.StartElementHandler = start_element
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
2619 with open(auditfileName) as fp:
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2620 xp.ParseFile(fp)
9826
cff647969dfa fixed detection of Checkstyle errors in checkstyle command (GRAAL-293)
Doug Simon <doug.simon@oracle.com>
parents: 9262
diff changeset
2621 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
2622 map(log, errors)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2623 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
2624 else:
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2625 timestamp.touch()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2626 finally:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2627 if exists(auditfileName):
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2628 os.unlink(auditfileName)
10059
4dada3ec9c58 mx checkstyle command no longer exits on first error
Doug Simon <doug.simon@oracle.com>
parents: 10058
diff changeset
2629 return totalErrors
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2630
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2631 def clean(args, parser=None):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2632 """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
2633
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2634 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
2635 generated images.
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2636 """
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
2637
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
2638 suppliedParser = parser is not None
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2639
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2640 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
2641 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
2642 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
2643
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2644 args = parser.parse_args(args)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2645
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2646 for p in projects_opt_limit_to_suites():
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2647 if p.native:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2648 if args.native:
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2649 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
2650 else:
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2651 if args.java:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2652 genDir = p.source_gen_dir()
7778
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2653 if genDir != '' and exists(genDir):
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2654 log('Clearing {0}...'.format(genDir))
6b540bb82312 Fixed clean should clean also generated source directories.
Christian Humer <christian.humer@gmail.com>
parents: 7681
diff changeset
2655 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
2656 shutil.rmtree(join(genDir, f))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2657
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2658
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2659 outputDir = p.output_dir()
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2660 if outputDir != '' and exists(outputDir):
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2661 log('Removing {0}...'.format(outputDir))
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
2662 shutil.rmtree(outputDir)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2663
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
2664 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
2665 return args
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2666
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2667 def about(args):
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2668 """show the 'man page' for mx"""
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2669 print __doc__
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2670
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2671 def help_(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2672 """show help for a given command
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2673
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2674 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
2675
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2676 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
2677 if len(args) == 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2678 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2679 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2680
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2681 name = args[0]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2682 if not _commands.has_key(name):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2683 hits = [c for c in _commands.iterkeys() if c.startswith(name)]
6284
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2684 if len(hits) == 1:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2685 name = hits[0]
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2686 elif len(hits) == 0:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2687 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
2688 else:
e952911afd2f made mx help command accept abbreviations
Doug Simon <doug.simon@oracle.com>
parents: 5876
diff changeset
2689 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
2690
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2691 value = _commands[name]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2692 (func, usage) = value[:2]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2693 doc = func.__doc__
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2694 if len(value) > 2:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2695 docArgs = value[2:]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2696 fmtArgs = []
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2697 for d in docArgs:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2698 if isinstance(d, Callable):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
2699 fmtArgs += [d()]
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2700 else:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2701 fmtArgs += [str(d)]
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2702 doc = doc.format(*fmtArgs)
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2703 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
2704
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2705 def projectgraph(args, suite=None):
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2706 """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
2707
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2708 print 'digraph projects {'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2709 print 'rankdir=BT;'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2710 print 'node [shape=rect];'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2711 for p in projects():
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2712 for dep in p.canonical_deps():
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2713 print '"' + p.name + '"->"' + dep + '"'
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
2714 print '}'
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2715
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2716 def _source_locator_memento(deps):
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2717 slm = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2718 slm.open('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2719 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
2720
5252
1a9a048386d6 added JRE to source path in generated Eclipse launches
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
2721 # 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
2722 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
2723 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
2724
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2725 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
2726 if dep.isLibrary():
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2727 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
2728 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
2729 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
2730 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
2731 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
2732 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
2733
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2734 slm.close('sourceContainers')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2735 slm.close('sourceLookupDirector')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2736 return slm
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2737
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2738 def make_eclipse_attach(suite, hostname, port, name=None, deps=None):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2739 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2740 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
2741 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2742 if deps is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2743 deps = []
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2744 slm = _source_locator_memento(deps)
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2745 launch = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2746 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
2747 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
2748 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
2749 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
2750 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
2751 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
2752 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
2753 launch.close('mapAttribute')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2754 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
2755 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
2756 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
2757 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
2758
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2759 if name is None:
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2760 if len(suites()) == 1:
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
2761 suitePrefix = ''
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2762 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2763 suitePrefix = suite.name + '-'
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2764 name = suitePrefix + 'attach-' + hostname + '-' + port
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2765 eclipseLaunches = join(suite.mxDir, 'eclipse-launches')
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2766 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
2767 os.makedirs(eclipseLaunches)
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2768 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
2769
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2770 def make_eclipse_launch(javaArgs, jre, name=None, deps=None):
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2771 """
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2772 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
2773 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2774 if deps is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2775 deps = []
5194
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2776 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
2777 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
2778 appArgs = []
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
2779 cp = None
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2780 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
2781 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
2782 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
2783 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
2784 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
2785 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
2786 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
2787 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
2788 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
2789 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
2790 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
2791 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
2792 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
2793 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
2794 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
2795 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
2796 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
2797 break
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2798
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
2799 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
2800 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
2801 return False
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2802
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
2803 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
2804 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
2805 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
2806 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
2807 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
2808 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
2809 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
2810 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
2811
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
2812 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
2813 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
2814 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
2815 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
2816 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
2817
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2818 slm = _source_locator_memento(deps)
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2819
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2820 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
2821 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
2822 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
2823 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
2824 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
2825 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
2826 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
2827 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
2828 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
2829 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
2830 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
2831
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
2832 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
2833 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
2834 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
2835 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
2836
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2837 def eclipseinit(args, buildProcessorJars=True, refreshOnly=False):
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
2838 """(re)generate Eclipse project configurations and working sets"""
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2839 for s in suites(True):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2840 _eclipseinit_suite(args, s, buildProcessorJars, refreshOnly)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
2841
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2842 generate_eclipse_workingsets()
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2843
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2844
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2845 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False):
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2846 projectsFile = join(suite.mxDir, 'projects')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2847 timestamp = TimeStampFile(join(suite.mxDir, 'eclipseinit.timestamp'))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2848 if refreshOnly and not timestamp.exists():
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2849 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2850
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2851 if not timestamp.outOfDate(projectsFile):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2852 logv('[Eclipse configurations are up to date - skipping]')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2853 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
2854
7293
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
2855 if buildProcessorJars:
12042
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
2856 # todo suite specific
7293
4974776828ec Avoid recursive calls of build
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7291
diff changeset
2857 processorjars()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2858
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2859 projToDist = dict()
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2860 for dist in _dists.values():
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2861 distDeps = sorted_deps(dist.deps)
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2862 for p in distDeps:
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2863 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
2864
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
2865 for p in suite.projects:
5071
9d055af068a8 Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default.
Doug Simon <doug.simon@oracle.com>
parents: 5032
diff changeset
2866 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
2867 continue
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2868
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2869 if not exists(p.dir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2870 os.makedirs(p.dir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2871
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2872 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2873 out.open('classpath')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
2874
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2875 for src in p.srcDirs:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2876 srcDir = join(p.dir, src)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2877 if not exists(srcDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2878 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
2879 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
2880
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
2881 if len(p.annotation_processors()) > 0:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2882 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
2883 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
2884 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
2885 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
2886
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2887 # 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
2888 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
2889
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2890 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2891 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
2892
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2893 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
2894 if dep == p:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2895 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2896
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2897 if dep.isLibrary():
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2898 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
2899 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
2900 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
2901 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
2902 else:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2903 path = dep.path
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2904 dep.get_path(resolve=True)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
2905 if not path or (not exists(path) and not dep.mustExist):
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2906 continue
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2907
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2908 if not isabs(path):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2909 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2910 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2911 # safest to simply use absolute paths.
11620
60e3fe0fe939 mxtool: fix eclipseinit to use project suite dir for included suites
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
2912 path = join(p.suite.dir, path)
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2913
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2914 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path}
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2915
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2916 sourcePath = dep.get_source_path(resolve=True)
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2917 if sourcePath is not None:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2918 attributes['sourcepath'] = sourcePath
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
2919 out.element('classpathentry', attributes)
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2920 else:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2921 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
2922
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2923 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
2924 out.close('classpath')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2925 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
2926
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2927 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
2928 if exists(csConfig):
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2929 out = XMLDoc()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2930
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2931 dotCheckstyle = join(p.dir, ".checkstyle")
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2932 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
2933 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
2934 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
2935 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
2936 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
2937 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
2938 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
2939 out.close('fileset')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2940 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
2941 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
2942 out.close('filter')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2943
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2944 exclude = join(p.dir, '.checkstyle.exclude')
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2945 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
2946 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
2947 with open(exclude) as f:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2948 for line in f:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2949 if not line.startswith('#'):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2950 line = line.strip()
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2951 exclDir = join(p.dir, line)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2952 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
2953 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
2954 out.close('filter')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
2955
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2956 out.close('fileset-config')
5219
ddccd4abdb09 configured test source directory for graal.graph project
Doug Simon <doug.simon@oracle.com>
parents: 5217
diff changeset
2957 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
2958
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
2959 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2960 out.open('projectDescription')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2961 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
2962 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
2963 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
2964 out.open('buildSpec')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2965 out.open('buildCommand')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2966 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
2967 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
2968 out.close('buildCommand')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
2969 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
2970 out.open('buildCommand')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2971 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
2972 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
2973 out.close('buildCommand')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2974 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2975 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
2976 out.open('buildCommand')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2977 out.element('name', data=buildCommand)
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2978 out.element('arguments', data='')
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2979 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
2980
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2981 if _isAnnotationProcessorDependency(p):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2982 _genEclipseBuilder(out, p, 'Jar.launch', 'archive ' + p.name, refresh=False, async=False, xmlIndent='', xmlStandalone='no')
12487
28d7a11ba008 revert attempt to avoid Eclipse build loops
Doug Simon <doug.simon@oracle.com>
parents: 12477
diff changeset
2983 _genEclipseBuilder(out, p, 'Refresh.launch', '', refresh=True, async=True)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2984
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2985 if projToDist.has_key(p.name):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
2986 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
2987 _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist.launch', 'archive @' + dist.name, refresh=False, async=True)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2988
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2989 out.close('buildSpec')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2990 out.open('natures')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2991 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
2992 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
2993 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
2994 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
2995 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
2996 out.close('natures')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2997 out.close('projectDescription')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
2998 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
2999
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3000 settingsDir = join(p.dir, ".settings")
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3001 if not exists(settingsDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3002 os.mkdir(settingsDir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3003
11620
60e3fe0fe939 mxtool: fix eclipseinit to use project suite dir for included suites
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
3004 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings')
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3005 if exists(eclipseSettingsDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3006 for name in os.listdir(eclipseSettingsDir):
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
3007 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
3008 continue
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3009 path = join(eclipseSettingsDir, name)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3010 if isfile(path):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3011 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
3012 content = f.read()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3013 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
3014 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
3015 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
3016 update_file(join(settingsDir, name), content)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3017
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
3018 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
3019 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
3020 out.open('factorypath')
11701
e29743466d00 fixed regression in mx.py
Doug Simon <doug.simon@oracle.com>
parents: 11687
diff changeset
3021 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
3022 for ap in p.annotation_processors():
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
3023 for dep in dependency(ap).all_deps([], True):
5876
c21886d4e125 Annotation Processor support in mx : use annotationProcessorClasses property on projects that contain annotation processors and annotationProcessors on projects that require annotation processing
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5854
diff changeset
3024 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
3025 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
3026 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
3027 path = dep.get_path(resolve=True)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3028 if path:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3029 if not isabs(path):
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3030 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3031 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3032 # safest to simply use absolute paths.
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3033 path = join(p.suite.dir, path)
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3034 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
3035 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
3036 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
3037 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
3038 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
3039
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3040 make_eclipse_attach(suite, 'localhost', '8000', deps=projects())
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3041 timestamp.touch()
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3042
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3043 def _isAnnotationProcessorDependency(p):
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3044 """
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3045 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
3046 """
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
3047 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
3048
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
3049 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, xmlIndent='\t', xmlStandalone=None):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3050 launchOut = XMLDoc()
8181
989e0582a30f enabled Eclipse builders to use console logging
Doug Simon <doug.simon@oracle.com>
parents: 8180
diff changeset
3051 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
3052 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'})
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3053 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
3054 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3055 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk})
8174
67d654d9ee9a pass JAVA_HOME to eclipse builder
Lukas Stadler <lukas.stadler@jku.at>
parents: 8138
diff changeset
3056 launchOut.close('mapAttribute')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3057
7681
f81be78f15a5 Fixed eclipse configuration for annotation processors. Annotation processor jars
Christian Humer <christian.humer@gmail.com>
parents: 7533
diff changeset
3058 if refresh:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3059 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3060 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3061 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3062
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3063 # expect to find the OS command to invoke mx in the same directory
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3064 baseDir = dirname(os.path.abspath(__file__))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3065
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
3066 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
3067 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
3068 cmd = 'mx.cmd'
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3069 cmdPath = join(baseDir, cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3070 if not os.path.exists(cmdPath):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3071 # backwards compatibility for when the commands lived in parent of mxtool
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3072 cmdPath = join(dirname(baseDir), cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3073 if not os.path.exists(cmdPath):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3074 abort('cannot locate ' + cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3075
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3076 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': cmdPath})
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3077 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3078 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3079 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED', 'value': 'true'})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3080 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir})
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3081
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3082
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
3083 launchOut.close('launchConfiguration')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3084
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
3085 externalToolDir = join(p.dir, '.externalToolBuilders')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3086
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
3087 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
3088 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
3089 update_file(join(externalToolDir, name), launchOut.xml(indent=xmlIndent, standalone=xmlStandalone, newl='\n'))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3090
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3091 dotProjectDoc.open('buildCommand')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3092 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
3093 dotProjectDoc.element('triggers', data='auto,full,incremental,')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3094 dotProjectDoc.open('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3095 dotProjectDoc.open('dictionary')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3096 dotProjectDoc.element('key', data='LaunchConfigHandle')
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3097 dotProjectDoc.element('value', data='<project>/.externalToolBuilders/' + name)
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3098 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3099 dotProjectDoc.open('dictionary')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3100 dotProjectDoc.element('key', data='incclean')
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3101 dotProjectDoc.element('value', data='true')
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3102 dotProjectDoc.close('dictionary')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3103 dotProjectDoc.close('arguments')
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
3104 dotProjectDoc.close('buildCommand')
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3105
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3106 def generate_eclipse_workingsets():
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3107 """
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3108 Populate the workspace's working set configuration with working sets generated from project data for the primary suite
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3109 If the workspace already contains working set definitions, the existing ones will be retained and extended.
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3110 In case mx/env does not contain a WORKSPACE definition pointing to the workspace root directory, a parent search from the primary suite directory is performed.
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3111 If no workspace root directory can be identified, the primary suite directory is used and the user has to place the workingsets.xml file by hand.
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3112 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3113
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3114 # identify the location where to look for workingsets.xml
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3115 wsfilename = 'workingsets.xml'
11597
723796685546 more verbose output for eclipseinit if it cannot place workingsets.xml in Eclipse metadata location
Michael Haupt <michael.haupt@oracle.com>
parents: 11514
diff changeset
3116 wsloc = '.metadata/.plugins/org.eclipse.ui.workbench'
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3117 if os.environ.has_key('WORKSPACE'):
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3118 expected_wsroot = os.environ['WORKSPACE']
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3119 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3120 expected_wsroot = _mainSuite.dir
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3121
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3122 wsroot = _find_eclipse_wsroot(expected_wsroot)
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3123 if wsroot is None:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3124 # failed to find it
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3125 wsroot = expected_wsroot
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3126
11597
723796685546 more verbose output for eclipseinit if it cannot place workingsets.xml in Eclipse metadata location
Michael Haupt <michael.haupt@oracle.com>
parents: 11514
diff changeset
3127 wsdir = join(wsroot, wsloc)
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3128 if not exists(wsdir):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3129 wsdir = wsroot
11597
723796685546 more verbose output for eclipseinit if it cannot place workingsets.xml in Eclipse metadata location
Michael Haupt <michael.haupt@oracle.com>
parents: 11514
diff changeset
3130 log('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.')
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3131 wspath = join(wsdir, wsfilename)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3132
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3133 # gather working set info from project data
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3134 workingSets = dict()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3135 for p in projects():
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3136 if p.workingSets is None:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3137 continue
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3138 for w in p.workingSets.split(","):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3139 if not workingSets.has_key(w):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3140 workingSets[w] = [p.name]
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3141 else:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3142 workingSets[w].append(p.name)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3143
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3144 if exists(wspath):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3145 wsdoc = _copy_workingset_xml(wspath, workingSets)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3146 else:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3147 wsdoc = _make_workingset_xml(workingSets)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3148
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3149 update_file(wspath, wsdoc.xml(newl='\n'))
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
3150
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3151 def _find_eclipse_wsroot(wsdir):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3152 md = join(wsdir, '.metadata')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3153 if exists(md):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3154 return wsdir
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3155 split = os.path.split(wsdir)
12042
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11807
diff changeset
3156 if split[0] == wsdir: # root directory
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3157 return None
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3158 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3159 return _find_eclipse_wsroot(split[0])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3160
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3161 def _foobar(val):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3162 print(val)
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3163
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3164 def _make_workingset_xml(workingSets):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3165 wsdoc = XMLDoc()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3166 wsdoc.open('workingSetManager')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3167
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3168 for w in sorted(workingSets.keys()):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3169 _workingset_open(wsdoc, w)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3170 for p in workingSets[w]:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3171 _workingset_element(wsdoc, p)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3172 wsdoc.close('workingSet')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3173
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3174 wsdoc.close('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3175 return wsdoc
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3176
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3177 def _copy_workingset_xml(wspath, workingSets):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3178 target = XMLDoc()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3179 target.open('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3180
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3181 parser = xml.parsers.expat.ParserCreate()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3182
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3183 class ParserState(object):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3184 def __init__(self):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3185 self.current_ws_name = 'none yet'
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3186 self.current_ws = None
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3187 self.seen_ws = list()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3188 self.seen_projects = list()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3189
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3190 ps = ParserState()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3191
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3192 # parsing logic
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3193 def _ws_start(name, attributes):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3194 if name == 'workingSet':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3195 ps.current_ws_name = attributes['name']
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3196 if workingSets.has_key(ps.current_ws_name):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3197 ps.current_ws = workingSets[ps.current_ws_name]
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3198 ps.seen_ws.append(ps.current_ws_name)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3199 ps.seen_projects = list()
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3200 else:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3201 ps.current_ws = None
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3202 target.open(name, attributes)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3203 parser.StartElementHandler = _ws_item
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3204
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3205 def _ws_end(name):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3206 if name == 'workingSet':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3207 if not ps.current_ws is None:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3208 for p in ps.current_ws:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3209 if not p in ps.seen_projects:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3210 _workingset_element(target, p)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3211 target.close('workingSet')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3212 parser.StartElementHandler = _ws_start
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3213 elif name == 'workingSetManager':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3214 # process all working sets that are new to the file
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3215 for w in sorted(workingSets.keys()):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3216 if not w in ps.seen_ws:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3217 _workingset_open(target, w)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3218 for p in workingSets[w]:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3219 _workingset_element(target, p)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3220 target.close('workingSet')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3221
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3222 def _ws_item(name, attributes):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3223 if name == 'item':
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3224 if ps.current_ws is None:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3225 target.element(name, attributes)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3226 else:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3227 p_name = attributes['elementID'][1:] # strip off the leading '='
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3228 _workingset_element(target, p_name)
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3229 ps.seen_projects.append(p_name)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3230
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3231 # process document
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3232 parser.StartElementHandler = _ws_start
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3233 parser.EndElementHandler = _ws_end
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3234 with open(wspath, 'r') as wsfile:
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3235 parser.ParseFile(wsfile)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3236
10061
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3237 target.close('workingSetManager')
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3238 return target
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3239
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3240 def _workingset_open(wsdoc, ws):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3241 wsdoc.open('workingSet', {'editPageID': 'org.eclipse.jdt.ui.JavaWorkingSetPage', 'factoryID': 'org.eclipse.ui.internal.WorkingSetFactory', 'id': 'wsid_' + ws, 'label': ws, 'name': ws})
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3242
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3243 def _workingset_element(wsdoc, p):
b6dfe12478ff [GRAAL-308] pre-defined working sets for Eclipse
Michael Haupt <michael.haupt@oracle.com>
parents: 10060
diff changeset
3244 wsdoc.element('item', {'elementID': '=' + p, 'factoryID': 'org.eclipse.jdt.ui.PersistableJavaElementFactory'})
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3245
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3246 def netbeansinit(args, refreshOnly=False, buildProcessorJars=True):
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3247 """(re)generate NetBeans project configurations"""
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3248
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3249 for suite in suites(True):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3250 _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3251
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3252 def _netbeansinit_suite(args, suite, refreshOnly=False, buildProcessorJars=True):
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3253 projectsFile = join(suite.mxDir, 'projects')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3254 timestamp = TimeStampFile(join(suite.mxDir, 'netbeansinit.timestamp'))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3255 if refreshOnly and not timestamp.exists():
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3256 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3257
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3258 if not timestamp.outOfDate(projectsFile):
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3259 logv('[NetBeans configurations are up to date - skipping]')
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3260 return
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3261
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3262 updated = False
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3263 for p in suite.projects:
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3264 if p.native:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3265 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3266
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3267 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
5853
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
3268 continue
767312416f6a added support to mx for specifying library sources
Doug Simon <doug.simon@oracle.com>
parents: 5824
diff changeset
3269
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3270 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
3271 os.makedirs(join(p.dir, 'nbproject'))
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3272
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
3273 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3274 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
3275 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
3276 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
3277 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
3278 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
3279 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
3280 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
3281 out.element('arg', {'value' : 'archive'})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
3282 out.element('arg', {'value' : '@GRAAL'})
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
3283 out.close('exec')
3c74a32bb262 generated NetBeans projects will also update graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 8183
diff changeset
3284 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
3285 out.close('project')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3286 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
3287
5217
70777e50f1e6 replace monkey patch with subclassing instead
Doug Simon <doug.simon@oracle.com>
parents: 5198
diff changeset
3288 out = XMLDoc()
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3289 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
3290 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
3291 out.open('configuration')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3292 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
3293 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
3294 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
3295 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
3296 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
3297 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
3298 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
3299 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
3300 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
3301 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
3302 out.close('data')
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
3303
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3304 firstDep = True
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3305 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
3306 if dep == p:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3307 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3308
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3309 if not dep.isLibrary():
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3310 n = dep.name.replace('.', '_')
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3311 if firstDep:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3312 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
3313 firstDep = False
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3314
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3315 out.open('reference')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3316 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
3317 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
3318 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
3319 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
3320 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
3321 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
3322 out.close('reference')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3323
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3324 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
3325 out.close('references')
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3326
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3327 out.close('configuration')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3328 out.close('project')
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3329 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
3330
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3331 out = StringIO.StringIO()
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
3332 jdkPlatform = 'JDK_' + str(java().version)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3333
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
3334 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
3335 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
3336 annotationProcessorSrcFolder = ""
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
3337 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
3338 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
3339 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
3340
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3341 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
3342 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
3343 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
3344 annotation.processing.processors.list=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3345 annotation.processing.run.all.processors=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3346 application.title=""" + p.name + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3347 application.vendor=mx
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3348 build.classes.dir=${build.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3349 build.classes.excludes=**/*.java,**/*.form
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3350 # 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
3351 build.dir=bin
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3352 build.generated.dir=${build.dir}/generated
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3353 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
3354 # 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
3355 build.sysclasspath=ignore
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3356 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
3357 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
3358 # 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
3359 #debug.transport=dt_socket
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3360 debug.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3361 ${run.classpath}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3362 debug.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3363 ${run.test.classpath}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3364 # 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
3365 dist.dir=dist
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3366 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
3367 dist.javadoc.dir=${dist.dir}/javadoc
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3368 endorsed.classpath=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3369 excludes=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3370 includes=**
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3371 jar.compress=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3372 # 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
3373 javac.compilerargs=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3374 javac.deprecation=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3375 javac.source=1.7
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3376 javac.target=1.7
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3377 javac.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3378 ${javac.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3379 ${build.classes.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3380 javadoc.additionalparam=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3381 javadoc.author=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3382 javadoc.encoding=${source.encoding}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3383 javadoc.noindex=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3384 javadoc.nonavbar=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3385 javadoc.notree=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3386 javadoc.private=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3387 javadoc.splitindex=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3388 javadoc.use=true
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3389 javadoc.version=false
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3390 javadoc.windowtitle=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3391 main.class=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3392 manifest.file=manifest.mf
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3393 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
3394 mkdist.disabled=false
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3395 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3396 platform.active=""" + jdkPlatform + """
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3397 run.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3398 ${javac.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3399 ${build.classes.dir}
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3400 # 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
3401 # (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
3402 # 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
3403 run.jvmargs=
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3404 run.test.classpath=\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3405 ${javac.test.classpath}:\\
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3406 ${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
3407 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
3408 """ + annotationProcessorSrcFolder + """
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3409 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
3410 print >> out, content
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3411
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3412 mainSrc = True
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3413 for src in p.srcDirs:
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3414 srcDir = join(p.dir, src)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3415 if not exists(srcDir):
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3416 os.mkdir(srcDir)
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3417 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
3418 print >> out, ref + '=' + src
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3419 if mainSrc:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3420 print >> out, 'src.dir=${' + ref + '}'
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3421 mainSrc = False
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3422 else:
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3423 print >> out, 'src.' + src + '.dir=${' + ref + '}'
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3424
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3425 javacClasspath = []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3426
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
3427 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
3428 annotationProcessorOnlyDeps = []
9854
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
3429 if len(p.annotation_processors()) > 0:
394f38496856 made projects inherit annotation processors from dependencies
Doug Simon <doug.simon@oracle.com>
parents: 9847
diff changeset
3430 for ap in p.annotation_processors():
11374
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
3431 apDep = dependency(ap)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
3432 if not apDep in deps:
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
3433 deps.append(apDep)
9cdf7a9d3475 Enable library as annotation processor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11318
diff changeset
3434 annotationProcessorOnlyDeps.append(apDep)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3435
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3436 annotationProcessorReferences = []
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3437
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
3438 for dep in deps:
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3439 if dep == p:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3440 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3441
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3442 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
3443 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
3444 continue
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3445 path = dep.get_path(resolve=True)
11687
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3446 if path:
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3447 if os.sep == '\\':
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3448 path = path.replace('\\', '\\\\')
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3449 ref = 'file.reference.' + dep.name + '-bin'
facb442de5db added support for specifying the JDK version in which a library becomes redundant (e.g., nashorn.jar)
Doug Simon <doug.simon@oracle.com>
parents: 11659
diff changeset
3450 print >> out, ref + '=' + path
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3451
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3452 else:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3453 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
3454 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
3455 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
3456 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
3457 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
3458
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
3459 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
3460 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
3461 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
3462 annotationProcessorReferences.append('${' + ref + '}')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3463 annotationProcessorReferences += ":\\\n ${" + ref + "}"
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3464
5198
887b45f6aa02 improved name of Eclipse launch file created for jar applications
Doug Simon <doug.simon@oracle.com>
parents: 5194
diff changeset
3465 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
3466 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
3467 print >> out, 'javac.processorpath=${javac.classpath}\\\n ' + (os.pathsep + '\\\n ').join(annotationProcessorReferences)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3468
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3469 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
3470 out.close()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3471
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3472 if updated:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
3473 log('If using NetBeans:')
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7787
diff changeset
3474 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
3475 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
3476
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3477 timestamp.touch()
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3478
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3479 def ideclean(args):
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3480 """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
3481 def rm(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3482 if exists(path):
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3483 os.remove(path)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3484
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3485 for s in suites():
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3486 rm(join(s.mxDir, 'eclipseinit.timestamp'))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3487 rm(join(s.mxDir, 'netbeansinit.timestamp'))
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3488
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3489 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
3490 if p.native:
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3491 continue
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3492
4271
311d193de5a2 Fixed regressions and Windows issues in generated IDE project configurations.
Doug Simon <doug.simon@oracle.com>
parents: 4270
diff changeset
3493 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
3494 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
3495 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
3496 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
3497 rm(join(p.dir, '.project'))
10043
e063474076dd clean up .factorypath files on "mx ideclean"
Lukas Stadler <lukas.stadler@jku.at>
parents: 9857
diff changeset
3498 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
3499 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
3500 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
3501 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
3502 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
3503 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
3504 log("Error removing {0}".format(p.name + '.jar'))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3505
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
3506
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3507 def ideinit(args, refreshOnly=False, buildProcessorJars=True):
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
3508 """(re)generate Eclipse and NetBeans project configurations"""
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3509 eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3510 netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3511 if not refreshOnly:
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
3512 fsckprojects([])
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
3513
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
3514 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
3515 """find directories corresponding to deleted Java projects and delete them"""
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3516 for suite in suites(True):
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
3517 projectDirs = [p.dir for p in suite.projects]
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3518 for dirpath, dirnames, files in os.walk(suite.dir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3519 if dirpath == suite.dir:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3520 # no point in traversing .hg
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3521 if '.hg' in dirnames:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3522 dirnames.remove('.hg')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3523 # if there are nested suites must not scan those now, as they are not in projectDirs
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3524 if _src_suitemodel._nestedsuites_dirname() in dirnames:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3525 dirnames.remove(_src_suitemodel._nestedsuites_dirname())
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3526 elif dirpath in projectDirs:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3527 # don't traverse subdirs of an existing project in this suite
7913
0df252296c8d added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
Doug Simon <doug.simon@oracle.com>
parents: 7787
diff changeset
3528 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
3529 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
3530 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
3531 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
3532 if len(indicators) != 0:
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3533 if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3534 shutil.rmtree(dirpath)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3535 log('Deleted ' + dirpath)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3536
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3537 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True):
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3538 """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
3539
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
3540 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
3541 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
3542 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
3543 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
3544 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
3545 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
3546 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
3547 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
3548 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
3549 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
3550 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
3551
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3552 args = parser.parse_args(args)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3553
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3554 # 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
3555 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
3556 candidates = [project(name) for name in args.projects.split(',')]
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3557 else:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11701
diff changeset
3558 candidates = projects_opt_limit_to_suites()
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3559
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
3560 # optionally restrict packages within a project
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3561 packages = []
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3562 if args.packages is not None:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3563 packages = [name for name in args.packages.split(',')]
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3564
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3565 exclude_packages = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3566 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
3567 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
3568
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3569 def outDir(p):
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3570 if args.base is None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3571 return join(p.dir, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3572 return join(args.base, p.name, docDir)
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3573
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3574 def check_package_list(p):
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
3575 return not exists(join(outDir(p), 'package-list'))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3576
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3577 def assess_candidate(p, projects):
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3578 if p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3579 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3580 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
3581 projects.append(p)
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3582 return True
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3583 return False
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3584
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3585 projects = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3586 for p in candidates:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3587 if not p.native:
5701
d0a6e25de770 integrated mxtool changes from Maxine project
Doug Simon <doug.simon@oracle.com>
parents: 5699
diff changeset
3588 if includeDeps:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3589 deps = p.all_deps([], includeLibs=False, includeSelf=False)
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3590 for d in deps:
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3591 assess_candidate(d, projects)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3592 if not assess_candidate(p, projects):
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10530
diff changeset
3593 logv('[package-list file exists - skipping {0}]'.format(p.name))
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3594
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3595
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3596 def find_packages(sourceDirs, pkgs=None):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3597 if pkgs is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3598 pkgs = set()
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3599 for sourceDir in sourceDirs:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3600 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
3601 if len([name for name in files if name.endswith('.java')]) != 0:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3602 pkg = root[len(sourceDir) + 1:].replace(os.sep, '.')
5709
24347f3b605f fixed javadoc command on Windows
Doug Simon <doug.simon@oracle.com>
parents: 5706
diff changeset
3603 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
3604 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
3605 pkgs.add(pkg)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3606 return pkgs
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3607
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3608 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
3609 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
3610 extraArgs += ['@' + args.argfile]
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3611 memory = '2g'
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3612 if args.memory is not None:
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3613 memory = args.memory
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3614 memory = '-J-Xmx' + memory
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3615
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3616 if not args.unified:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3617 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
3618 # 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
3619 build(['--no-native', '--projects', p.name])
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3620
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3621 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
3622 deps = p.all_deps([], includeLibs=False, includeSelf=False)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3623 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
3624 out = outDir(p)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3625 for d in deps:
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3626 depOut = outDir(d)
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3627 links.append('-link')
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3628 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
3629 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
3630 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
3631 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
3632 delOverviewFile = False
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3633 if not exists(overviewFile):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3634 with open(overviewFile, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3635 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
3636 delOverviewFile = True
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3637 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3638 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3639 nowarnAPI.append('-XDignore.symbol.file')
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3640
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3641 # windowTitle onloy applies to the standard doclet processor
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3642 windowTitle = []
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3643 if stdDoclet:
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3644 windowTitle = ['-windowtitle', p.name + ' javadoc']
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3645 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3646 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
3647 run([java().javadoc, memory,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3648 '-XDignore.symbol.file',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3649 '-classpath', cp,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3650 '-quiet',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3651 '-d', out,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3652 '-overview', overviewFile,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3653 '-sourcepath', sp] +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3654 links +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3655 extraArgs +
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3656 nowarnAPI +
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
3657 windowTitle +
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3658 list(pkgs))
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3659 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
3660 finally:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3661 if delOverviewFile:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3662 os.remove(overviewFile)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3663
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3664 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
3665 # 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
3666 build(['--no-native'])
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3667
5171
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3668 pkgs = set()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3669 sp = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3670 names = []
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3671 for p in projects:
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3672 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
3673 sp += p.source_dirs()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3674 names.append(p.name)
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3675
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3676 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
3677 out = join(_mainSuite.dir, docDir)
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3678 if args.base is not None:
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
3679 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
3680 cp = classpath()
99ad84da5f99 added javadoc command (from Maxine version of mx)
Doug Simon <doug.simon@oracle.com>
parents: 5166
diff changeset
3681 sp = os.pathsep.join(sp)
5712
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3682 nowarnAPI = []
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3683 if not args.warnAPI:
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3684 nowarnAPI.append('-XDignore.symbol.file')
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3685 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
3686 run([java().javadoc, memory,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3687 '-classpath', cp,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3688 '-quiet',
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3689 '-d', out,
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3690 '-sourcepath', sp] +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3691 links +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3692 extraArgs +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3693 nowarnAPI +
dfcb73ac6ba2 made invalid javadoc cause a JDT error
Doug Simon <doug.simon@oracle.com>
parents: 5710
diff changeset
3694 list(pkgs))
5376
bfc9aeb1264c synchronized mxtool with Maxine
Doug Simon <doug.simon@oracle.com>
parents: 5252
diff changeset
3695 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
3696
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
3697 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
3698 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
3699 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
3700 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
3701 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
3702 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
3703 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
3704 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
3705 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
3706 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
3707 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
3708 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
3709 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
3710
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
3711 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
3712 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
3713 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
3714 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
3715 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
3716 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
3717 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
3718 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
3719 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
3720 return content.replace(old, repl)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3721
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
3722 # 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
3723 # 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
3724 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
3725 """
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
3726 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
3727 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
3728 """
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
3729
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
3730 # 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
3731 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
3732 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
3733
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
3734 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
3735 <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
3736 <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
3737 </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
3738 <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
3739 </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
3740
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
3741 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
3742 <!-- -->
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
3743 </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
3744 <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
3745 <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
3746 </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
3747 </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
3748 <!-- ======= 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
3749
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
3750 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
3751 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
3752
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3753 content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text + '</div></div></div>')
6335
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3754 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
3755
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
3756 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
3757 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
3758
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
3759
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
3760 # 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
3761 # 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
3762 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
3763 """
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
3764 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
3765 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
3766 """
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
3767
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
3768 # 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
3769 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
3770 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
3771
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
3772 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
3773 <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
3774 </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
3775
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
3776 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
3777 <!-- -->
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
3778 </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
3779 </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
3780 <!-- ======= 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
3781
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
3782 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
3783 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
3784 repl = re.sub(r'<h2 title=(.*) Description</h2>', r'<h1 title=\1</h1>', chunk2.text, 1)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3785 content = chunk1.replace(content, '<div class="header">' + repl + '</div></div>')
6335
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3786 content = chunk2.replace(content, '')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3787
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
3788 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
3789 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
3790 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
3791 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
3792
897f5bb96d60 fixed generated package-summary.html files to put the complete package description at the top of the page
Doug Simon <doug.simon@oracle.com>
parents: 6284
diff changeset
3793 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
3794 # 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
3795 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
3796
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3797 def site(args):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3798 """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
3799
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3800 parser = ArgumentParser(prog='site')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3801 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
3802 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
3803 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
3804 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
3805 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
3806 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
3807 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
3808 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
3809 args = parser.parse_args(args)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3810
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3811 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
3812 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
3813 unified = join(tmpbase, 'all')
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3814
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3815 exclude_packages_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3816 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
3817 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
3818
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3819 projects = sorted_deps()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3820 projects_arg = []
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3821 if args.projects is not None:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3822 projects_arg = ['--projects', args.projects]
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3823 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
3824
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
3825 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
3826 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
3827 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
3828 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
3829
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3830 try:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3831 # 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
3832 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
3833
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3834 # 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
3835 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
3836 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
3837 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
3838 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
3839 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
3840 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
3841 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
3842 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
3843 <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
3844 <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
3845 <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
3846 <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
3847 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
3848 for p in projects:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3849 print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html",target = "_top">{0}</a></td><td class="colLast">&nbsp;</td></tr>'.format(p.name, color)
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3850 color = 'row' if color == 'alt' else 'alt'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3851
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
3852 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
3853 print >> fp2, content[idx:]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3854
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3855 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
3856 javadoc(['--base', tmpbase,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3857 '--unified',
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3858 '--arg', '@-windowtitle', '--arg', '@' + title,
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3859 '--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
3860 '--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
3861 os.rename(join(tmpbase, 'javadoc'), unified)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3862
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3863 # Generate dependency graph with Graphviz
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3864 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
3865 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
3866 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
3867 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
3868 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
3869 except subprocess.CalledProcessError as e:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3870 dotErr = 'error calling "dot -V": {}'.format(e)
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6350
diff changeset
3871 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
3872 dotErr = 'error calling "dot -V": {}'.format(e)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3873
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
3874 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
3875 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
3876
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3877 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
3878 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
3879 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
3880 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
3881 with open(dot, 'w') as fp:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3882 dim = len(projects)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3883 print >> fp, 'digraph projects {'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3884 print >> fp, 'rankdir=BT;'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3885 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
3886 print >> fp, 'node [shape=rect, fontcolor="blue"];'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3887 # print >> fp, 'edge [color="green"];'
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3888 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3889 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
3890 for dep in p.canonical_deps():
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3891 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
3892 print >> fp, '"' + p.name + '" -> "' + dep + '"'
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3893 depths = dict()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3894 for p in projects:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3895 d = p.max_depth()
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3896 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
3897 print >> fp, '}'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3898
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3899 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
3900
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
3901 # 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
3902 # 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
3903 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
3904 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
3905 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
3906 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
3907 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
3908 fp.write(content)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
3909
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
3910 # 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
3911 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
3912 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
3913
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3914 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
3915 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
3916 for f in files:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3917 if f == 'overview-summary.html':
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3918 path = join(root, f)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3919 topLink = ''
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3920 if top != path:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3921 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
3922 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
3923 _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
3924 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
3925 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
3926 _fix_package_summary(path)
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3927
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3928
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3929 if exists(args.base):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3930 shutil.rmtree(args.base)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3931 shutil.move(tmpbase, args.base)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3932
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3933 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
3934
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3935 finally:
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3936 if exists(tmpbase):
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3937 shutil.rmtree(tmpbase)
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
3938
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3939 def _kwArg(kwargs):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3940 if len(kwargs) > 0:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3941 return kwargs.pop(0)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3942 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3943
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3944 def sclone(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3945 """clone a suite repository, and its imported suites"""
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
3946 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3947 parser = ArgumentParser(prog='mx sclone')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3948 parser.add_argument('--source', help='url/path of repo containing suite', metavar='<url>')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3949 parser.add_argument('--dest', help='destination directory (default basename of source)', metavar='<path>')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3950 parser.add_argument("--no-imports", action='store_true', help='do not clone imported suites')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3951 parser.add_argument('nonKWArgs', nargs=REMAINDER, metavar='source [dest]...')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3952 args = parser.parse_args(args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3953 # check for non keyword args
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3954 if args.source is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3955 args.source = _kwArg(args.nonKWArgs)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3956 if args.dest is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3957 args.dest = _kwArg(args.nonKWArgs)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3958 if len(args.nonKWArgs) > 0:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3959 abort('unrecognized args: ' + ' '.join(args.nonKWArgs))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3960
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3961 if args.source is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3962 # must be primary suite and dest is required
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3963 if _mainSuite is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3964 abort('--source missing and no primary suite found')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3965 if args.dest is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3966 abort('--dest required when --source is not given')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3967 source = _mainSuite.dir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3968 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3969 source = args.source
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3970
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3971 if args.dest is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3972 dest = args.dest
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3973 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3974 dest = basename(source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3975
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3976 dest = os.path.abspath(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3977 # We can now set the primary dir for the src/dst suitemodel
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3978 _dst_suitemodel._set_primary_dir(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3979 _src_suitemodel._set_primary_dir(source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3980
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3981 _sclone(source, dest, None, args.no_imports)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3982
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3983 def _sclone(source, dest, version, no_imports):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3984 cmd = ['hg', 'clone']
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3985 if version is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3986 cmd.append('-r')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3987 cmd.append(version)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3988 cmd.append(source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3989 cmd.append(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3990
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3991 run(cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3992
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3993 mxDir = _is_suite_dir(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3994 if mxDir is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3995 warn(source + ' is not an mx suite')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3996 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3997
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3998 # create a Suite (without loading) to enable imports visitor
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
3999 s = Suite(mxDir, False, load=False)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4000 if not no_imports:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4001 s._visit_imports(_scloneimports_visitor, source=source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4002 return s
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4003
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4004 def _scloneimports_visitor(s, suite_import, source, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4005 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4006 cloneimports visitor for Suite._visit_imports.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4007 The destination information is encapsulated by 's'
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4008 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4009 _scloneimports(s, suite_import, source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4010
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4011 def _scloneimports_suitehelper(sdir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4012 mxDir = _is_suite_dir(sdir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4013 if mxDir is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4014 abort(sdir + ' is not an mx suite')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4015 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4016 # create a Suite (without loading) to enable imports visitor
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4017 return Suite(mxDir, False, load=False)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4018
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4019 def _scloneimports(s, suite_import, source):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4020 # clone first, then visit imports once we can locate them
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4021 importee_source = _src_suitemodel._importee_dir(source, suite_import.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4022 importee_dest = _dst_suitemodel._importee_dir(s.dir, suite_import.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4023 if exists(importee_dest):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4024 importee_suite = _scloneimports_suitehelper(importee_dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4025 importee_suite._visit_imports(_scloneimports_visitor, source=importee_source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4026 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4027 _sclone(importee_source, importee_dest, suite_import.version, False)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4028 # _clone handles the recursive visit of the new imports
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4029
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4030 def scloneimports(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4031 """clone the imports of an existing suite"""
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4032 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4033 parser = ArgumentParser(prog='mx scloneimports')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4034 parser.add_argument('--source', help='url/path of repo containing suite', metavar='<url>')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4035 parser.add_argument('nonKWArgs', nargs=REMAINDER, metavar='source [dest]...')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4036 args = parser.parse_args(args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4037 # check for non keyword args
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4038 if args.source is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4039 args.source = _kwArg(args.nonKWArgs)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4040
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4041 if not os.path.isdir(args.source):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4042 abort(args.source + ' is not a directory')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4043
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4044 s = _scloneimports_suitehelper(args.source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4045
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4046 default_path = _hg._default_push(args.source)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4047
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4048 if default_path is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4049 abort('no default path in ' + join(args.source, '.hg', 'hgrc'))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4050
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4051 # We can now set the primary dir for the dst suitemodel
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4052 # N.B. source is effectively the destination and the default_path is the (original) source
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4053 _dst_suitemodel._set_primary_dir(args.source)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4054
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4055 s._visit_imports(_scloneimports_visitor, source=default_path)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4056
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4057 def _spush_import_visitor(s, suite_import, dest, checks, clonemissing, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4058 """push visitor for Suite._visit_imports"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4059 if dest is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4060 dest = _dst_suitemodel._importee_dir(dest, suite_import.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4061 _spush(suite(suite_import.name), suite_import, dest, checks, clonemissing)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4062
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4063 def _spush_check_import_visitor(s, suite_import, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4064 """push check visitor for Suite._visit_imports"""
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4065 currentTip = _hg._tip(suite(suite_import.name))
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4066 if currentTip != suite_import.version:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4067 abort('import version of ' + suite_import.name + ' in suite ' + s.name + ' does not match tip')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4068
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4069 def _spush(s, suite_import, dest, checks, clonemissing):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4070 if checks:
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4071 if not _hg._canpush(s):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4072 abort('working directory ' + s.dir + ' contains uncommitted changes, push aborted')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4073
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4074 # check imports first
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4075 if checks:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4076 s._visit_imports(_spush_check_import_visitor)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4077
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4078 # ok, push imports
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4079 s._visit_imports(_spush_import_visitor, dest=dest, checks=checks, clonemissing=clonemissing)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4080
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4081 dest_exists = True
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4082
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4083 if clonemissing:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4084 if not os.path.exists(dest):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4085 dest_exists = False
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4086
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4087 def add_version(cmd, suite_import):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4088 if suite_import is not None and suite_import.version is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4089 cmd.append('-r')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4090 cmd.append(suite_import.version)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4091
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4092 if dest_exists:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4093 cmd = ['hg', '-R', s.dir, 'push']
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4094 add_version(cmd, suite_import)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4095 if dest is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4096 cmd.append(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4097 rc = run(cmd, nonZeroIsFatal=False)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4098 if rc != 0:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4099 # rc of 1 not an error, means no changes
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4100 if rc != 1:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4101 abort("push failed, exit code " + str(rc))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4102 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4103 cmd = ['hg', 'clone']
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4104 add_version(cmd, suite_import)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4105 cmd.append(s.dir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4106 cmd.append(dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4107 run(cmd)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4108
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4109 def spush(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4110 """push primary suite and all its imports"""
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4111 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4112 parser = ArgumentParser(prog='mx spush')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4113 parser.add_argument('--dest', help='url/path of repo to push to (default as per hg push)', metavar='<path>')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4114 parser.add_argument('--no-checks', action='store_true', help='checks on status, versions are disabled')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4115 parser.add_argument('--clonemissing', action='store_true', help='clone missing imported repos at destination (forces --no-checks)')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4116 parser.add_argument('nonKWArgs', nargs=REMAINDER, metavar='source [dest]...')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4117 args = parser.parse_args(args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4118 if args.dest is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4119 args.dest = _kwArg(args.nonKWArgs)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4120 if len(args.nonKWArgs) > 0:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4121 abort('unrecognized args: ' + ' '.join(args.nonKWArgs))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4122
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4123 if args.dest is not None and not os.path.isdir(args.dest):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4124 abort('destination must be a directory')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4125
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4126 s = _check_primary_suite()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4127
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4128 if args.clonemissing:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4129 if args.dest is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4130 abort('--dest required with --clonemissing')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4131 args.nochecks = True
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4132
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4133 if args.dest is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4134 _dst_suitemodel._set_primary_dir(args.dest)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4135
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4136 _spush(s, None, args.dest, not args.no_checks, args.clonemissing)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4137
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4138 def _supdate_import_visitor(s, suite_import, **extra_args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4139 _supdate(suite(suite_import.name), suite_import)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4140
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4141 def _supdate(s, suite_import):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4142 s._visit_imports(_supdate_import_visitor)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4143
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4144 run(['hg', '-R', s.dir, 'update'])
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4145
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4146 def supdate(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4147 """update primary suite and all its imports"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4148
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4149 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4150 s = _check_primary_suite()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4151
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4152 _supdate(s, None)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4153
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4154 def _scheck_imports_visitor(s, suite_import, update_versions, updated_imports):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4155 """checkimportversions visitor for Suite._visit_imports"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4156 _scheck_imports(suite(suite_import.name), suite_import, update_versions, updated_imports)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4157
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4158 def _scheck_imports(s, suite_import, update_versions, updated_imports):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4159 # check imports recursively
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4160 s._visit_imports(_scheck_imports_visitor, update_versions=update_versions)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4161
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4162 currentTip = _hg._tip(s)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4163 if currentTip != suite_import.version:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4164 print('import version of ' + s.name + ' does not match tip' + (': updating' if update_versions else ''))
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4165
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4166 if update_versions:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4167 suite_import.version = currentTip
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4168 line = str(suite_import)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4169 updated_imports.write(line + '\n')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4170
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4171 def scheckimports(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4172 """check that suite import versions are up to date"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4173 parser = ArgumentParser(prog='mx scheckimports')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4174 parser.add_argument('--update-versions', help='update imported version ids', action='store_true')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4175 args = parser.parse_args(args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4176 _check_primary_suite()._visit_imports(_scheck_imports_visitor, update_versions=args.update_versions)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4177
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4178 def _spull_import_visitor(s, suite_import, update_versions, updated_imports):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4179 """pull visitor for Suite._visit_imports"""
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4180 _spull(suite(suite_import.name), update_versions, updated_imports)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4181
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4182 def _spull(s, update_versions, updated_imports):
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4183 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4184 # pull imports first
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4185 s._visit_imports(_spull_import_visitor, update_versions=update_versions)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4186
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4187 run(['hg', '-R', s.dir, 'pull', '-u'])
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4188 if update_versions and updated_imports is not None:
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4189 tip = _hg._tip(s)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4190 updated_imports.write(SuiteImport._tostring(s.name, tip) + '\n')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4191
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4192 def spull(args):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4193 """pull primary suite and all its imports"""
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4194 _hg._check(True)
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4195 parser = ArgumentParser(prog='mx spull')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4196 parser.add_argument('--update-versions', action='store_true', help='update version ids of imported suites')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4197 args = parser.parse_args(args)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4198
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4199 _spull(_check_primary_suite(), args.update_versions, None)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4200
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
4201 def findclass(args, logToConsole=True):
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4202 """find all classes matching a given substring"""
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
4203 matches = []
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4204 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
4205 if filename.endswith('.class'):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4206 if isinstance(entry, zipfile.ZipFile):
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4207 classname = filename.replace('/', '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4208 else:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4209 classname = filename.replace(os.sep, '.')
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4210 classname = classname[:-len('.class')]
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4211 for a in args:
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4212 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
4213 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
4214 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
4215 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
4216 return matches
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4217
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4218 def select_items(items, descriptions=None, allowMultiple=True):
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4219 """
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4220 Presents a command line interface for selecting one or more (if allowMultiple is true) items.
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4221
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4222 """
11318
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
4223 if len(items) <= 1:
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
4224 return items
345bce66c04a mx: fix for select_items
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11301
diff changeset
4225 else:
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4226 if allowMultiple:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4227 log('[0] <all>')
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4228 for i in range(0, len(items)):
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4229 if descriptions is None:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4230 log('[{0}] {1}'.format(i + 1, items[i]))
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4231 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4232 assert len(items) == len(descriptions)
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4233 wrapper = textwrap.TextWrapper(subsequent_indent=' ')
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4234 log('\n'.join(wrapper.wrap('[{0}] {1} - {2}'.format(i + 1, items[i], descriptions[i]))))
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4235 while True:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4236 if allowMultiple:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4237 s = raw_input('Enter number(s) of selection (separate multiple choices with spaces): ').split()
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4238 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4239 s = [raw_input('Enter number of selection: ')]
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4240 try:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4241 s = [int(x) for x in s]
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4242 except:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4243 log('Selection contains non-numeric characters: "' + ' '.join(s) + '"')
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4244 continue
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4245
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4246 if allowMultiple and 0 in s:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4247 return items
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4248
11295
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4249 indexes = []
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4250 for n in s:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4251 if n not in range(1, len(items) + 1):
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4252 log('Invalid selection: ' + str(n))
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4253 continue
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4254 else:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4255 indexes.append(n - 1)
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4256 if allowMultiple:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4257 return [items[i] for i in indexes]
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4258 if len(indexes) == 1:
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4259 return items[indexes[0]]
bb70a309a7cf enhanced select_items to support multiple selections
Doug Simon <doug.simon@oracle.com>
parents: 11245
diff changeset
4260 return None
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4261
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4262 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
4263 """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
4264
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4265 javapExe = java().javap
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4266 if not exists(javapExe):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4267 abort('The javap executable does not exists: ' + javapExe)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4268 else:
11203
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4269 candidates = findclass(args, logToConsole=False)
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4270 if len(candidates) == 0:
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4271 log('no matches')
8ab76b7c6ff6 added interactive selection capability to 'mx javap' command
Doug Simon <doug.simon@oracle.com>
parents: 10585
diff changeset
4272 selection = select_items(candidates)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4273 run([javapExe, '-private', '-verbose', '-classpath', classpath()] + selection)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4274
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4275 def show_projects(args):
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4276 """show all loaded projects"""
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4277 for s in suites():
11659
ec7aad9dfc47 made 'mx build' refresh IDE configs automatically
Doug Simon <doug.simon@oracle.com>
parents: 11620
diff changeset
4278 projectsFile = join(s.mxDir, 'projects')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4279 if exists(projectsFile):
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4280 log(projectsFile)
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4281 for p in s.projects:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4282 log('\t' + p.name)
11759
8bcd76c3f23b mx.py whitespace fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
4283
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4284 def ask_yes_no(question, default=None):
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4285 """"""
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4286 assert not default or default == 'y' or default == 'n'
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4287 if not sys.stdout.isatty():
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4288 if default:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4289 return default
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4290 else:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4291 abort("Can not answer '" + question + "?' if stdout is not a tty")
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4292 questionMark = '? [yn]: '
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4293 if default:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4294 questionMark = questionMark.replace(default, default.upper())
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4295 answer = raw_input(question + questionMark) or default
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4296 while not answer:
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4297 answer = raw_input(question + questionMark)
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11401
diff changeset
4298 return answer.lower().startswith('y')
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4299
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4300 def add_argument(*args, **kwargs):
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4301 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4302 Define how a single command-line argument.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4303 """
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4304 assert _argParser is not None
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4305 _argParser.add_argument(*args, **kwargs)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4306
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4307 def update_commands(suite, new_commands):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4308 for key, value in new_commands.iteritems():
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4309 if _commands.has_key(key):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4310 warn("redefining command '" + key + "' in suite " + suite.name)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4311 _commands[key] = value
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4312
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4313 def warn(msg):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4314 if _warn:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4315 print('WARNING: ' + msg)
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4316
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4317 # Table of commands in alphabetical order.
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4318 # 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
4319 # 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
4320 # used in the call to str.format().
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4321 # Suite extensions should not update this table directly, but use update_commands
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4322 _commands = {
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4323 'about': [about, ''],
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
4324 'build': [build, '[options]'],
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
4325 'checkstyle': [checkstyle, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4326 'canonicalizeprojects': [canonicalizeprojects, ''],
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4327 'clean': [clean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4328 '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
4329 'eclipseformat': [eclipseformat, ''],
5455
271e83dcfcef added findclass command to mx tool
Doug Simon <doug.simon@oracle.com>
parents: 5376
diff changeset
4330 '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
4331 'fsckprojects': [fsckprojects, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4332 '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
4333 'ideclean': [ideclean, ''],
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4334 'ideinit': [ideinit, ''],
8131
83ec1df0a30f added support for distributions to mx
Doug Simon <doug.simon@oracle.com>
parents: 7925
diff changeset
4335 'archive': [archive, '[options]'],
4301
fad6f1ebeb44 mx.py: new projectgraph command
Lukas Stadler <lukas.stadler@jku.at>
parents: 4271
diff changeset
4336 'projectgraph': [projectgraph, ''],
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4337 'sclone': [sclone, '[options]'],
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4338 'scheckimports': [scheckimports, ''],
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4339 'scloneimports': [scloneimports, '[options]'],
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4340 'spull': [spull, '[options'],
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4341 'spush': [spush, '[options'],
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4342 'supdate': [supdate, ''],
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11759
diff changeset
4343 'pylint': [pylint, ''],
9009
1eb16dbb31a7 changed 'mx javap' command to accept class name patterns instead of fully qualified class names
Doug Simon <doug.simon@oracle.com>
parents: 9002
diff changeset
4344 '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
4345 'javadoc': [javadoc, '[options]'],
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5762
diff changeset
4346 'site': [site, '[options]'],
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
4347 'netbeansinit': [netbeansinit, ''],
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4348 'projects': [show_projects, ''],
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4349 }
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4350
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4351 _argParser = ArgParser()
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4352
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4353 def _suitename(mxDir):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4354 base = os.path.basename(mxDir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4355 parts = base.split('.')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4356 # temporary workaround until mx.graal exists
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4357 if len(parts) == 1:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4358 return 'graal'
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4359 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4360 return parts[1]
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4361
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4362 def _is_suite_dir(d, mxDirName=None):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4363 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4364 Checks if d contains a suite.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4365 If mxDirName is None, matches any suite name, otherwise checks for exactly that suite.
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4366 """
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4367 if os.path.isdir(d):
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4368 for f in os.listdir(d):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4369 if (mxDirName == None and (f == 'mx' or fnmatch.fnmatch(f, 'mx.*'))) or f == mxDirName:
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4370 mxDir = join(d, f)
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11597
diff changeset
4371 if exists(mxDir) and isdir(mxDir) and exists(join(mxDir, 'projects')):
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4372 return mxDir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4373
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4374 def _check_primary_suite():
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4375 if _mainSuite is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4376 abort('no primary suite found')
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4377 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4378 return _mainSuite
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4379
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4380 def _needs_primary_suite(command):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4381 return not command.startswith("sclone")
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4382
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4383 def _findPrimarySuiteMxDir():
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4384 # try current working directory first, the look up the tree
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4385 curdir = os.getcwd()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4386 while curdir:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4387 mxDir = _is_suite_dir(curdir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4388 if mxDir is not None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4389 return mxDir
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4390 parent = dirname(curdir)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4391 if curdir == parent:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4392 return None
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4393 curdir = parent
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4394
5699
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4395 return None
e9f7d16194a8 added --base argument to javadoc command
Doug Simon <doug.simon@oracle.com>
parents: 5581
diff changeset
4396
4241
8fece0287975 Made command timeout also kill any currently executing subprocess (group).
Doug Simon <doug.simon@oracle.com>
parents: 4239
diff changeset
4397 def main():
12491
11f217e8476a mxtool: fix command-specific option parsing regression
Mick Jordan <mick.jordan@oracle.com>
parents: 12487
diff changeset
4398 SuiteModel._parse_options()
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4399
12508
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4400 global _hg
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4401 _hg = HgConfig()
5cde653f58f9 mxtool: handle missing hg executable gracefully
Mick Jordan <mick.jordan@oracle.com>
parents: 12504
diff changeset
4402
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4403 primarySuiteMxDir = _findPrimarySuiteMxDir()
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4404 if primarySuiteMxDir:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4405 _src_suitemodel._set_primary_dir(dirname(primarySuiteMxDir))
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4258
diff changeset
4406 global _mainSuite
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4407 _mainSuite = _loadSuite(primarySuiteMxDir, True)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4408
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4409 opts, commandAndArgs = _argParser._parse_cmd_line()
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4410
12477
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4411 if primarySuiteMxDir is None:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4412 msg = 'no primary suite found'
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4413 if len(commandAndArgs) > 0 and _needs_primary_suite(commandAndArgs[0]):
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4414 abort(msg)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4415 else:
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4416 warn(msg)
a5d83166dca6 mxtool hg support for suites
Mick Jordan <mick.jordan@oracle.com>
parents: 12455
diff changeset
4417
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
4418 global _opts, _java
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4419 _opts = opts
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
4420 _java = JavaConfig(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4421
4148
bf5efc22fb3f Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents: 4147
diff changeset
4422 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
4423 s._post_init(opts)
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4424
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4425 if len(commandAndArgs) == 0:
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4426 _argParser.print_help()
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4427 return
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4428
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4429 command = commandAndArgs[0]
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4430 command_args = commandAndArgs[1:]
5032
e2de9649f0a9 Integrated mxtool updates from Maxine project.
Doug Simon <doug.simon@oracle.com>
parents: 4664
diff changeset
4431
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4432 if not _commands.has_key(command):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4433 hits = [c for c in _commands.iterkeys() if c.startswith(command)]
5824
b1dc8fbebb48 mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
Doug Simon <doug.simon@oracle.com>
parents: 5821
diff changeset
4434 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
4435 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
4436 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
4437 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
4438 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
4439 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
4440
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11511
diff changeset
4441 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
4442 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
4443 abort(1)
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4271
diff changeset
4444 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
4445 try:
4270
2158e26b50cf Made generated NetBeans projects use project cross referencing.
Doug Simon <doug.simon@oracle.com>
parents: 4269
diff changeset
4446 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
4447 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
4448 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
4449 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
4450 signal.alarm(opts.timeout)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4451 retcode = c(command_args)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4452 if retcode is not None and retcode != 0:
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4453 abort(retcode)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4454 except KeyboardInterrupt:
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4455 # 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
4456 abort(1)
3723
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4457
6c5f528c7aac Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4458 if __name__ == '__main__':
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4459 # 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
4460 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
4461
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3732
diff changeset
4462 main()