annotate mx.truffle/mx_truffle.py @ 21972:ff6f34159b8a

Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Tue, 23 Jun 2015 12:44:41 +0200
parents e61e89bd867a
children 1ecffe20e460
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 #
4225
339cf8d4904d Made mx.run work properly when stderr is redirected to stdout.
Doug Simon <doug.simon@oracle.com>
parents: 4219
diff changeset
2 # commands.py - the GraalVM specific commands
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 # ----------------------------------------------------------------------------------------------------
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 #
18891
9afee75cee46 mx: add microbench command to run JMH benchmarks
Roland Schatz <roland.schatz@oracle.com>
parents: 18888
diff changeset
6 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 # This code is free software; you can redistribute it and/or modify it
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 # under the terms of the GNU General Public License version 2 only, as
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 # published by the Free Software Foundation.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 # This code is distributed in the hope that it will be useful, but WITHOUT
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 # version 2 for more details (a copy is included in the LICENSE file that
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 # accompanied this code).
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License version
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 # 2 along with this work; if not, write to the Free Software Foundation,
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 # or visit www.oracle.com if you need additional information or have any
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 # questions.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 # ----------------------------------------------------------------------------------------------------
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18869
diff changeset
29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, StringIO, socket
16419
7520833c6e7f eliminate JUnitWrapper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16417
diff changeset
30 from os.path import join, exists, dirname, basename
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
32 from outputparser import OutputParser, ValuesMatcher
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
33 import mx
13472
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
34 import xml.dom.minidom
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
35 import itertools
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
36 import json, textwrap
15329
3b56c9bbf60c mx: fix imports
Bernhard Urban <bernhard.urban@jku.at>
parents: 15328
diff changeset
37 import fnmatch
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
10574
0cad5096735e commands.py: Make sure _jdk returns an absolute path. Use _jdk and _jdksDir where necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10570
diff changeset
39 # This works because when mx loads this file, it makes sure __file__ gets an absolute path
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
40 _graal_home = dirname(dirname(__file__))
4417
648a7873cea2 Made it possible to build and run the client and server VM with a new '--vm' option to 'mx build' and a global option of the same name.
Doug Simon <doug.simon@oracle.com>
parents: 4407
diff changeset
41
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
42 """ The VM that will be run by the 'vm' command and built by default by the 'build' command.
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
43 This can be set via the global '--vm' option or the DEFAULT_VM environment variable.
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
44 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
45 _vm = None
4417
648a7873cea2 Made it possible to build and run the client and server VM with a new '--vm' option to 'mx build' and a global option of the same name.
Doug Simon <doug.simon@oracle.com>
parents: 4407
diff changeset
46
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
47 _make_eclipse_launch = False
a6eceb5efb0e added --ecl option to mx for saving VM execution(s) as Eclipse launch configurations
Doug Simon <doug.simon@oracle.com>
parents: 5189
diff changeset
48
21940
3ecd0f489818 minimal version for Truffle is 1.7 and less checks when skipping the build of JDK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21939
diff changeset
49 _minVersion = mx.VersionSpec('1.7')
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7788
diff changeset
50
20102
6e5df2d60fbd mx: fix compliance check for EXTRA_JAVA_HOMES, add maximum JAVA_HOME version in mx_graal
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20032
diff changeset
51 # max version (first _unsupported_ version)
20805
379471b334cb Lift 8u40 mx restriction
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20102
diff changeset
52 _untilVersion = None
20102
6e5df2d60fbd mx: fix compliance check for EXTRA_JAVA_HOMES, add maximum JAVA_HOME version in mx_graal
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20032
diff changeset
53
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
54 class JDKDeployedDist:
21740
6c3c21d9b5ef Add -m switch to mx build, which builds/exports JVMCI with the make/jvmci.make file
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21720
diff changeset
55 def __init__(self, name, isExtension=False, usesJVMCIClassLoader=False, partOfHotSpot=False):
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
56 self.name = name
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
57 self.isExtension = isExtension
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
58 self.usesJVMCIClassLoader = usesJVMCIClassLoader
21740
6c3c21d9b5ef Add -m switch to mx build, which builds/exports JVMCI with the make/jvmci.make file
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21720
diff changeset
59 self.partOfHotSpot = partOfHotSpot # true when this distribution is delivered with HotSpot
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
60
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
61 _jdkDeployedDists = [
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
62 JDKDeployedDist('TRUFFLE'),
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
63 ]
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
64
16627
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
65 JDK_UNIX_PERMISSIONS_DIR = 0755
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
66 JDK_UNIX_PERMISSIONS_FILE = 0644
16782
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
67 JDK_UNIX_PERMISSIONS_EXEC = 0755
13919
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
68
14602
591f4a575ebf issue warning/error where ever relevant if a non-supported VM (e.g., client VM on Mac) is used in mx
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
69 def isVMSupported(vm):
18799
750db34c9fe1 client-nograal is supported on Mac
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18733
diff changeset
70 if 'client' == vm and len(platform.mac_ver()[0]) != 0:
14602
591f4a575ebf issue warning/error where ever relevant if a non-supported VM (e.g., client VM on Mac) is used in mx
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
71 # Client VM not supported: java launcher on Mac OS X translates '-client' to '-server'
591f4a575ebf issue warning/error where ever relevant if a non-supported VM (e.g., client VM on Mac) is used in mx
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
72 return False
591f4a575ebf issue warning/error where ever relevant if a non-supported VM (e.g., client VM on Mac) is used in mx
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
73 return True
591f4a575ebf issue warning/error where ever relevant if a non-supported VM (e.g., client VM on Mac) is used in mx
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
74
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
75 def _get_vm():
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
76 """
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
77 Gets the configured VM, presenting a dialogue if there is no currently configured VM.
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
78 """
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
79 global _vm
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
80 if _vm:
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
81 return _vm
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
82 vm = mx.get_env('DEFAULT_VM')
21938
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
83 if vm is None:
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
84 extras = mx.get_env('EXTRA_JAVA_HOMES')
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
85 if not extras is None:
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
86 for e in extras.split(':'):
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
87 vm = e
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
88 break
21584
9bb04af58490 support DEFAULT_VM=graal in mx/env
Doug Simon <doug.simon@oracle.com>
parents: 21580
diff changeset
89 envPath = join(_graal_home, 'mx', 'env')
21640
11f68b116a07 mx: added support for server-nograal and client-nograal aliases
Doug Simon <doug.simon@oracle.com>
parents: 21639
diff changeset
90 if vm and 'graal' in vm:
21584
9bb04af58490 support DEFAULT_VM=graal in mx/env
Doug Simon <doug.simon@oracle.com>
parents: 21580
diff changeset
91 if exists(envPath):
9bb04af58490 support DEFAULT_VM=graal in mx/env
Doug Simon <doug.simon@oracle.com>
parents: 21580
diff changeset
92 with open(envPath) as fp:
21642
57912478d94d fixed pylint issue
Doug Simon <doug.simon@oracle.com>
parents: 21640
diff changeset
93 if 'DEFAULT_VM=' + vm in fp.read():
21640
11f68b116a07 mx: added support for server-nograal and client-nograal aliases
Doug Simon <doug.simon@oracle.com>
parents: 21639
diff changeset
94 mx.log('Please update the DEFAULT_VM value in ' + envPath + ' to replace "graal" with "jvmci"')
11f68b116a07 mx: added support for server-nograal and client-nograal aliases
Doug Simon <doug.simon@oracle.com>
parents: 21639
diff changeset
95 vm = vm.replace('graal', 'jvmci')
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
96 if vm is None:
21957
04fd8d2361df Additional simplification of the mx_truffle.py
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21956
diff changeset
97 mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable')
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
98 _vm = vm
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
99 return vm
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
100
16627
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
101 def chmodRecursive(dirname, chmodFlagsDir):
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
102 if mx.get_os() == 'windows':
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
103 return
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
104
16627
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
105 def _chmodDir(chmodFlags, dirname, fnames):
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
106 os.chmod(dirname, chmodFlagsDir)
6705
0cb1ac637dd0 Added recursive chmod for cases where JAVA_HOME is not owned by graal workspace owner.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6702
diff changeset
107
16627
68deb37eed70 mx: fix permissions of copied bootstrap JDK files (don't make everything executable)
Bernhard Urban <bernhard.urban@jku.at>
parents: 16623
diff changeset
108 os.path.walk(dirname, _chmodDir, chmodFlagsDir)
6705
0cb1ac637dd0 Added recursive chmod for cases where JAVA_HOME is not owned by graal workspace owner.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6702
diff changeset
109
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
110 def clean(args):
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
111 """clean the source tree"""
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: 4244
diff changeset
112 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
15580
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
113
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
114 if opts.native:
15580
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
115 def handleRemoveReadonly(func, path, exc):
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
116 excvalue = exc[1]
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
117 if mx.get_os() == 'windows' and func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15862
diff changeset
118 os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
15580
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
119 func(path)
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
120 else:
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
121 raise
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
122
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
123 def rmIfExists(name):
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
124 if os.path.isdir(name):
15580
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
125 shutil.rmtree(name, ignore_errors=False, onerror=handleRemoveReadonly)
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
126 elif os.path.isfile(name):
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
127 os.unlink(name)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
128
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
129 rmIfExists(join(_graal_home, 'build'))
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
130 rmIfExists(join(_graal_home, 'build-nojvmci'))
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131
4156
843c8d6720da Added 'export' command for creating a GraalVM zip file distribution without the Mercurial data or VM sources.
Doug Simon <doug.simon@oracle.com>
parents: 4155
diff changeset
132 def export(args):
15420
5947bb02474f mx export: change the way of marking a repo as dirty
Bernhard Urban <bernhard.urban@jku.at>
parents: 15402
diff changeset
133 """create archives of builds split by vmbuild and vm"""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
134
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
135 parser = ArgumentParser(prog='mx export')
4156
843c8d6720da Added 'export' command for creating a GraalVM zip file distribution without the Mercurial data or VM sources.
Doug Simon <doug.simon@oracle.com>
parents: 4155
diff changeset
136 args = parser.parse_args(args)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
137
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
138 # collect data about export
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
139 infos = dict()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
140 infos['timestamp'] = time.time()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
141
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
142 hgcfg = mx.HgConfig()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
143 hgcfg.check()
15420
5947bb02474f mx export: change the way of marking a repo as dirty
Bernhard Urban <bernhard.urban@jku.at>
parents: 15402
diff changeset
144 infos['revision'] = hgcfg.tip('.') + ('+' if hgcfg.isDirty('.') else '')
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
145 # TODO: infos['repository']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
146
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
147 infos['jdkversion'] = str(mx.java().version)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
148
17012
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16979
diff changeset
149 infos['architecture'] = mx.get_arch()
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
150 infos['platform'] = mx.get_os()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
151
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
152 if mx.get_os != 'windows':
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
153 pass
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
154 # infos['ccompiler']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
155 # infos['linker']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
156
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
157 infos['hostname'] = socket.gethostname()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
158
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
159 def _writeJson(suffix, properties):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
160 d = infos.copy()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
161 for k, v in properties.iteritems():
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
162 assert not d.has_key(k)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
163 d[k] = v
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
164
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
165 jsonFileName = 'export-' + suffix + '.json'
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
166 with open(jsonFileName, 'w') as f:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
167 print >> f, json.dumps(d)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
168 return jsonFileName
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
169
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
170
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
171 def _genFileName(archivtype, middle):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
172 idPrefix = infos['revision'] + '_'
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
173 idSuffix = '.tar.gz'
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15862
diff changeset
174 return join(_graal_home, "graalvm_" + archivtype + "_" + idPrefix + middle + idSuffix)
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
175
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
176 # graal directory
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
177 graalDirTarName = _genFileName('classfiles', 'javac')
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
178 mx.logv("creating graal " + graalDirTarName)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
179 with tarfile.open(graalDirTarName, 'w:gz') as tar:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
180 for root, _, files in os.walk("graal"):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
181 for f in [f for f in files if not f.endswith('.java')]:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
182 name = join(root, f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
183 # print name
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
184 tar.add(name, name)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
185
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
186 n = _writeJson("graal", {'javacompiler' : 'javac'})
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
187 tar.add(n, n)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
188
4156
843c8d6720da Added 'export' command for creating a GraalVM zip file distribution without the Mercurial data or VM sources.
Doug Simon <doug.simon@oracle.com>
parents: 4155
diff changeset
189
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
190 def _run_benchmark(args, availableBenchmarks, runBenchmark):
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
191
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
192 vmOpts, benchmarksAndOptions = _extract_VM_args(args, useDoubleDash=availableBenchmarks is None)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
193
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
194 if availableBenchmarks is None:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
195 harnessArgs = benchmarksAndOptions
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
196 return runBenchmark(None, harnessArgs, vmOpts)
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: 4187
diff changeset
197
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
198 if len(benchmarksAndOptions) == 0:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
199 mx.abort('at least one benchmark name or "all" must be specified')
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
200 benchmarks = list(itertools.takewhile(lambda x: not x.startswith('-'), benchmarksAndOptions))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
201 harnessArgs = benchmarksAndOptions[len(benchmarks):]
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
202
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
203 if 'all' in benchmarks:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
204 benchmarks = availableBenchmarks
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
205 else:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
206 for bm in benchmarks:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
207 if bm not in availableBenchmarks:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
208 mx.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(availableBenchmarks))
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
209
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: 4187
diff changeset
210 failed = []
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
211 for bm in benchmarks:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
212 if not runBenchmark(bm, harnessArgs, vmOpts):
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
213 failed.append(bm)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
214
4157
b26279781d95 Simplified 'dacapo' command and made it more suitable for gate usage.
Doug Simon <doug.simon@oracle.com>
parents: 4156
diff changeset
215 if len(failed) != 0:
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
216 mx.abort('Benchmark failures: ' + str(failed))
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
217
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
218 def _vmLibDirInJdk(jdk):
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
219 """
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
220 Get the directory within a JDK where the server and client
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
221 subdirectories are located.
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
222 """
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
223 mxos = mx.get_os()
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
224 if mxos == 'darwin':
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
225 return join(jdk, 'jre', 'lib')
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
226 if mxos == 'windows' or mxos == 'cygwin':
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
227 return join(jdk, 'jre', 'bin')
17012
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16979
diff changeset
228 return join(jdk, 'jre', 'lib', mx.get_arch())
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
229
17014
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
230 def _vmJliLibDirs(jdk):
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
231 """
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
232 Get the directories within a JDK where the jli library designates to.
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
233 """
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
234 mxos = mx.get_os()
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
235 if mxos == 'darwin':
17014
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
236 return [join(jdk, 'jre', 'lib', 'jli')]
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
237 if mxos == 'windows' or mxos == 'cygwin':
17014
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
238 return [join(jdk, 'jre', 'bin'), join(jdk, 'bin')]
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
239 return [join(jdk, 'jre', 'lib', mx.get_arch(), 'jli'), join(jdk, 'lib', mx.get_arch(), 'jli')]
6a30738791f7 mx: add helper for determine jli location
Bernhard Urban <bernhard.urban@jku.at>
parents: 17012
diff changeset
240
17015
ffddcdca8e74 mx: support different name for jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 17014
diff changeset
241 def _vmCfgInJdk(jdk, jvmCfgFile='jvm.cfg'):
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
242 """
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
243 Get the jvm.cfg file.
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
244 """
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
245 mxos = mx.get_os()
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
246 if mxos == "windows" or mxos == "cygwin":
17015
ffddcdca8e74 mx: support different name for jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 17014
diff changeset
247 return join(jdk, 'jre', 'lib', mx.get_arch(), jvmCfgFile)
ffddcdca8e74 mx: support different name for jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 17014
diff changeset
248 return join(_vmLibDirInJdk(jdk), jvmCfgFile)
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
249
9119
0c9c4ae236b2 refactoring to ensure the path to the JDKs dir is consistent between the _jdk() and clean() command
Doug Simon <doug.simon@oracle.com>
parents: 9118
diff changeset
250 def _jdksDir():
21955
aab974a50deb Removing --installed-jdks option
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21954
diff changeset
251 return os.path.abspath(join(_graal_home, 'jdk' + str(mx.java().version)))
9119
0c9c4ae236b2 refactoring to ensure the path to the JDKs dir is consistent between the _jdk() and clean() command
Doug Simon <doug.simon@oracle.com>
parents: 9118
diff changeset
252
17055
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
253 def _handle_missing_VM(bld, vm=None):
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
254 if not vm:
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
255 vm = _get_vm()
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
256 mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
21957
04fd8d2361df Additional simplification of the mx_truffle.py
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21956
diff changeset
257 mx.abort('You need to run "mx --javahome ' + vm + ' use the selected VM')
11296
4e943a311d9c mx presents a command line dialogue to select the default VM if it is not configured (GRAAL-416)
Doug Simon <doug.simon@oracle.com>
parents: 11287
diff changeset
258
17055
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
259 def _jdk(build=None, vmToCheck=None, create=False, installJars=True):
4155
394404b2d9bd Removed strict requirement for GRAAL environment variable. It only needs to be set now if the graal directory is not in the directory hierarchy of GraalVM JDK.
Doug Simon <doug.simon@oracle.com>
parents: 4153
diff changeset
260 """
394404b2d9bd Removed strict requirement for GRAAL environment variable. It only needs to be set now if the graal directory is not in the directory hierarchy of GraalVM JDK.
Doug Simon <doug.simon@oracle.com>
parents: 4153
diff changeset
261 Get the JDK into which Graal is installed, creating it first if necessary.
394404b2d9bd Removed strict requirement for GRAAL environment variable. It only needs to be set now if the graal directory is not in the directory hierarchy of GraalVM JDK.
Doug Simon <doug.simon@oracle.com>
parents: 4153
diff changeset
262 """
9119
0c9c4ae236b2 refactoring to ensure the path to the JDKs dir is consistent between the _jdk() and clean() command
Doug Simon <doug.simon@oracle.com>
parents: 9118
diff changeset
263 jdk = join(_jdksDir(), build)
4582
b24386206122 Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal).
Doug Simon <doug.simon@oracle.com>
parents: 4577
diff changeset
264 if create:
10574
0cad5096735e commands.py: Make sure _jdk returns an absolute path. Use _jdk and _jdksDir where necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10570
diff changeset
265 srcJdk = mx.java().jdk
4582
b24386206122 Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal).
Doug Simon <doug.simon@oracle.com>
parents: 4577
diff changeset
266 if not exists(jdk):
b24386206122 Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal).
Doug Simon <doug.simon@oracle.com>
parents: 4577
diff changeset
267 mx.log('Creating ' + jdk + ' from ' + srcJdk)
13525
7cbd4f2194aa mx: omit weird logic to copy bootstrap jdk, just do cp -R
Bernhard Urban <bernhard.urban@jku.at>
parents: 13524
diff changeset
268 shutil.copytree(srcJdk, jdk)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
269
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
270 # Make a copy of the default VM so that this JDK can be
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
271 # reliably used as the bootstrap for a HotSpot build.
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
272 jvmCfg = _vmCfgInJdk(jdk)
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
273 if not exists(jvmCfg):
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
274 mx.abort(jvmCfg + ' does not exist')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
275
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
276 defaultVM = None
8647
5f8299106dd9 A server0 "build" needs to create a jdk copy if it does not exist yet
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8646
diff changeset
277 jvmCfgLines = []
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
278 with open(jvmCfg) as f:
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
279 for line in f:
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
280 if line.startswith('-') and defaultVM is None:
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
281 parts = line.split()
12540
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
282 if len(parts) == 2:
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
283 assert parts[1] == 'KNOWN', parts[1]
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
284 defaultVM = parts[0][1:]
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
285 jvmCfgLines += ['# default VM is a copy of the unmodified ' + defaultVM + ' VM\n']
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
286 jvmCfgLines += ['-original KNOWN\n']
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
287 else:
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
288 # skip lines which we cannot parse (e.g. '-hotspot ALIASED_TO -client')
12583
110c3faa57e9 mx: print warning if encounter a non-parsable line in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12540
diff changeset
289 mx.log("WARNING: skipping not parsable line \"" + line + "\"")
8647
5f8299106dd9 A server0 "build" needs to create a jdk copy if it does not exist yet
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8646
diff changeset
290 else:
5f8299106dd9 A server0 "build" needs to create a jdk copy if it does not exist yet
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8646
diff changeset
291 jvmCfgLines += [line]
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
292
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
293 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
294 chmodRecursive(jdk, JDK_UNIX_PERMISSIONS_DIR)
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
295 shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), 'original'))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
296
18733
d7ec30ebb0f2 Properly chmod files modified when creating JDK image
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18714
diff changeset
297 if mx.get_os() != 'windows':
d7ec30ebb0f2 Properly chmod files modified when creating JDK image
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18714
diff changeset
298 os.chmod(jvmCfg, JDK_UNIX_PERMISSIONS_FILE)
8261
2237260c6fdb the contents of jvm.cfg are reset when copying the JDK so that the non-default VMs must be built before being run
Doug Simon <doug.simon@oracle.com>
parents: 8223
diff changeset
299 with open(jvmCfg, 'w') as fp:
8647
5f8299106dd9 A server0 "build" needs to create a jdk copy if it does not exist yet
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8646
diff changeset
300 for line in jvmCfgLines:
5f8299106dd9 A server0 "build" needs to create a jdk copy if it does not exist yet
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8646
diff changeset
301 fp.write(line)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
302
13523
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
303 # patch 'release' file (append graalvm revision)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
304 releaseFile = join(jdk, 'release')
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
305 if exists(releaseFile):
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
306 releaseFileLines = []
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
307 with open(releaseFile) as f:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
308 for line in f:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
309 releaseFileLines.append(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
310
18733
d7ec30ebb0f2 Properly chmod files modified when creating JDK image
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18714
diff changeset
311 if mx.get_os() != 'windows':
d7ec30ebb0f2 Properly chmod files modified when creating JDK image
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18714
diff changeset
312 os.chmod(releaseFile, JDK_UNIX_PERMISSIONS_FILE)
13523
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
313 with open(releaseFile, 'w') as fp:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
314 for line in releaseFileLines:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
315 if line.startswith("SOURCE="):
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
316 try:
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
317 sourceLine = line[0:-2] # remove last char
13523
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
318 hgcfg = mx.HgConfig()
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
319 hgcfg.check()
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
320 revision = hgcfg.tip('.')[:12] # take first 12 chars
13523
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
321 fp.write(sourceLine + ' graal:' + revision + '\"\n')
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
322 except:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
323 fp.write(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
324 else:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
325 fp.write(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
326
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
327 # Install a copy of the disassembler library
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
328 try:
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
329 hsdis([], copyToDir=_vmLibDirInJdk(jdk))
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
330 except SystemExit:
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
331 pass
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332 else:
4582
b24386206122 Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal).
Doug Simon <doug.simon@oracle.com>
parents: 4577
diff changeset
333 if not exists(jdk):
17055
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
334 _handle_missing_VM(build, vmToCheck)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
335
16623
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16622
diff changeset
336 if installJars:
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
337 for jdkDist in _jdkDeployedDists:
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
338 dist = mx.distribution(jdkDist.name)
21741
b6ee5d3f3255 Exclude distributions from exporting which are delivered with HotSpot (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
339 if exists(dist.path) and jdkDist.partOfHotSpot:
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
340 _installDistInJdks(jdkDist)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
341
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
342 return jdk
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
343
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
344 def _updateInstalledJVMCIOptionsFile(jdk):
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
345 jvmciOptions = join(_graal_home, 'jvmci.options')
11936
4cdf7623fbe6 ensure graal.options in the JDK is deployed/updated/deleted each time the VM is run
Doug Simon <doug.simon@oracle.com>
parents: 11867
diff changeset
346 jreLibDir = join(jdk, 'jre', 'lib')
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
347 if exists(jvmciOptions):
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
348 shutil.copy(jvmciOptions, join(jreLibDir, 'jvmci.options'))
11936
4cdf7623fbe6 ensure graal.options in the JDK is deployed/updated/deleted each time the VM is run
Doug Simon <doug.simon@oracle.com>
parents: 11867
diff changeset
349 else:
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
350 toDelete = join(jreLibDir, 'jvmci.options')
11936
4cdf7623fbe6 ensure graal.options in the JDK is deployed/updated/deleted each time the VM is run
Doug Simon <doug.simon@oracle.com>
parents: 11867
diff changeset
351 if exists(toDelete):
4cdf7623fbe6 ensure graal.options in the JDK is deployed/updated/deleted each time the VM is run
Doug Simon <doug.simon@oracle.com>
parents: 11867
diff changeset
352 os.unlink(toDelete)
4cdf7623fbe6 ensure graal.options in the JDK is deployed/updated/deleted each time the VM is run
Doug Simon <doug.simon@oracle.com>
parents: 11867
diff changeset
353
16605
c55478e640e1 generalized check that VM is up-to-date with all generated sources
Doug Simon <doug.simon@oracle.com>
parents: 16600
diff changeset
354 def _makeHotspotGeneratedSourcesDir():
16628
d3fec84757ed improved generated sources up-to-date check by using SHA1 digests
Doug Simon <doug.simon@oracle.com>
parents: 16627
diff changeset
355 """
d3fec84757ed improved generated sources up-to-date check by using SHA1 digests
Doug Simon <doug.simon@oracle.com>
parents: 16627
diff changeset
356 Gets the directory containing all the HotSpot sources generated from
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21537
diff changeset
357 JVMCI Java sources. This directory will be created if it doesn't yet exist.
16628
d3fec84757ed improved generated sources up-to-date check by using SHA1 digests
Doug Simon <doug.simon@oracle.com>
parents: 16627
diff changeset
358 """
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21537
diff changeset
359 hsSrcGenDir = join(mx.project('com.oracle.jvmci.hotspot').source_gen_dir(), 'hotspot')
16600
6e7311d571ff modify the 'mx vm' command to check that the VM is up-to-date with respect to graalRuntime.inline.hpp
Doug Simon <doug.simon@oracle.com>
parents: 16599
diff changeset
360 if not exists(hsSrcGenDir):
6e7311d571ff modify the 'mx vm' command to check that the VM is up-to-date with respect to graalRuntime.inline.hpp
Doug Simon <doug.simon@oracle.com>
parents: 16599
diff changeset
361 os.makedirs(hsSrcGenDir)
16605
c55478e640e1 generalized check that VM is up-to-date with all generated sources
Doug Simon <doug.simon@oracle.com>
parents: 16600
diff changeset
362 return hsSrcGenDir
c55478e640e1 generalized check that VM is up-to-date with all generated sources
Doug Simon <doug.simon@oracle.com>
parents: 16600
diff changeset
363
16863
0d2e3399acfe mx: add argument for permissions to copyToJdk()
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16862
diff changeset
364 def _copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE):
16782
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
365 name = os.path.basename(src)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
366 dstLib = join(dst, name)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
367 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true':
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
368 # Using symlinks is much faster than copying but may
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
369 # cause issues if the lib is being updated while
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
370 # the VM is running.
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
371 if not os.path.islink(dstLib) or not os.path.realpath(dstLib) == src:
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
372 if exists(dstLib):
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
373 os.remove(dstLib)
16858
a8af2abc2039 fixed regression in mx causing problems for the SYMLINK_GRAAL_JAR feature
Doug Simon <doug.simon@oracle.com>
parents: 16782
diff changeset
374 os.symlink(src, dstLib)
16782
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
375 else:
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
376 # do a copy and then a move to get atomic updating (on Unix)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
377 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dst)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
378 shutil.copyfile(src, tmp)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
379 os.close(fd)
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
380 shutil.move(tmp, dstLib)
16863
0d2e3399acfe mx: add argument for permissions to copyToJdk()
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16862
diff changeset
381 os.chmod(dstLib, permissions)
16782
9f5e33cf8d52 Factored out the '_copyToJdk' function and allow copying files to jre/lib/ext.
Danilo Ansaloni <danilo.ansaloni@oracle.com>
parents: 16729
diff changeset
382
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
383 def _filterJVMCIServices(servicesMap, classpath):
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
384 """
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
385 Filters and returns the names in 'serviceImplNames' that denote
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
386 types available in 'classpath' implementing or extending
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
387 com.oracle.jvmci.service.Service.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
388 """
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
389 _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__))
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
390 serialized = [k + '=' + ','.join(v) for k, v in servicesMap.iteritems()]
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
391 cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serialized
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
392 serialized = subprocess.check_output(cmd)
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
393 if len(serialized) == 0:
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
394 return {}
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
395 servicesMap = {}
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
396 for e in serialized.split(' '):
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
397 k, v = e.split('=')
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
398 impls = v.split(',')
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
399 servicesMap[k] = impls
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
400 return servicesMap
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
401
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
402 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True):
21099
3f51d02e536f Make should export graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21098
diff changeset
403 if cleanDestination:
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
404 if exists(servicesDir):
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
405 shutil.rmtree(servicesDir)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
406 if exists(optionsDir):
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
407 shutil.rmtree(optionsDir)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
408 if not exists(servicesDir):
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
409 os.makedirs(servicesDir)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
410 if not exists(optionsDir):
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
411 os.makedirs(optionsDir)
21105
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
412 servicesMap = {}
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
413 optionsFiles = []
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
414 for jar in jvmciJars:
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
415 if os.path.isfile(jar):
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
416 with zipfile.ZipFile(jar) as zf:
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
417 for member in zf.namelist():
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21708
diff changeset
418 if member.startswith('META-INF/services') and member:
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
419 serviceName = basename(member)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21708
diff changeset
420 if serviceName == "":
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21708
diff changeset
421 continue # Zip files may contain empty entries for directories (jar -cf ... creates such)
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
422 # we don't handle directories
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
423 assert serviceName and member == 'META-INF/services/' + serviceName
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
424 with zf.open(member) as serviceFile:
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
425 serviceImpls = servicesMap.setdefault(serviceName, [])
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
426 for line in serviceFile.readlines():
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
427 line = line.strip()
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
428 if line:
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
429 serviceImpls.append(line)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
430 elif member.startswith('META-INF/options'):
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
431 filename = basename(member)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21708
diff changeset
432 if filename == "":
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21708
diff changeset
433 continue # Zip files may contain empty entries for directories (jar -cf ... creates such)
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
434 # we don't handle directories
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
435 assert filename and member == 'META-INF/options/' + filename
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
436 targetpath = join(optionsDir, filename)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
437 optionsFiles.append(filename)
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
438 with zf.open(member) as optionsFile, \
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
439 file(targetpath, "wb") as target:
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
440 shutil.copyfileobj(optionsFile, target)
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
441 servicesMap = _filterJVMCIServices(servicesMap, jdkJars)
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21886
diff changeset
442 for serviceName, serviceImpls in servicesMap.iteritems():
21105
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
443 fd, tmp = tempfile.mkstemp(prefix=serviceName)
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
444 f = os.fdopen(fd, 'w+')
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
445 for serviceImpl in serviceImpls:
21122
7f78f999512a mx: services: make sure we don't produce empty lines
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21118
diff changeset
446 f.write(serviceImpl + os.linesep)
21518
c2e58b2a2a76 Extract options file to build
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21514
diff changeset
447 target = join(servicesDir, serviceName)
21105
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
448 f.close()
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
449 shutil.move(tmp, target)
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
450 if mx.get_os() != 'windows':
db2de6c2bf95 mx create each service file atomically
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21104
diff changeset
451 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE)
21562
Doug Simon <doug.simon@oracle.com>
parents: 21560 21522
diff changeset
452
Doug Simon <doug.simon@oracle.com>
parents: 21560 21522
diff changeset
453 def _updateJVMCIFiles(jdkDir):
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
454 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci')
21607
71b338926f2e moved JVMCI classes into their own distributions (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
455 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')]
21671
8d0c2aabfc2d missed Graal -> JVMCI renamings
Doug Simon <doug.simon@oracle.com>
parents: 21642
diff changeset
456 jreJVMCIServicesDir = join(jreJVMCIDir, 'services')
8d0c2aabfc2d missed Graal -> JVMCI renamings
Doug Simon <doug.simon@oracle.com>
parents: 21642
diff changeset
457 jreJVMCIOptionsDir = join(jreJVMCIDir, 'options')
8d0c2aabfc2d missed Graal -> JVMCI renamings
Doug Simon <doug.simon@oracle.com>
parents: 21642
diff changeset
458 _extractJVMCIFiles(_getJdkDeployedJars(jdkDir), jvmciJars, jreJVMCIServicesDir, jreJVMCIOptionsDir)
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
459
21560
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
460 def _patchGraalVersionConstant(dist):
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
461 """
21693
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
462 Patches the constant "@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@" in the constant pool of Graal.class
21560
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
463 with the computed Graal version string.
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
464 """
21603
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
465 zf = zipfile.ZipFile(dist.path, 'r')
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
466 graalClassfilePath = 'com/oracle/graal/api/runtime/Graal.class'
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21705
diff changeset
467 try:
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21705
diff changeset
468 graalClassfile = zf.read(graalClassfilePath)
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21705
diff changeset
469 except KeyError:
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21705
diff changeset
470 mx.log(graalClassfilePath + ' is not present in ' + dist.path)
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21705
diff changeset
471 return
21693
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
472 placeholder = '@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@'
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
473 placeholderLen = len(placeholder)
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
474 versionSpec = '{:' + str(placeholderLen) + '}'
21603
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
475 versionStr = versionSpec.format(graal_version())
21693
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
476
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
477 if len(versionStr) > placeholderLen:
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
478 # Truncate the version string if necessary
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
479 assert versionStr.startswith('unknown'), versionStr
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
480 versionStr = versionStr[:placeholderLen]
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
481 if placeholder not in graalClassfile:
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
482 assert versionStr in graalClassfile, 'could not find "' + placeholder + '" or "' + versionStr + '" constant in ' + dist.path + '!' + graalClassfilePath
21603
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
483 zf.close()
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
484 return False
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
485
21560
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
486 zfOutFd, zfOutPath = tempfile.mkstemp(suffix='', prefix=basename(dist.path) + '.', dir=dirname(dist.path))
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
487 zfOut = zipfile.ZipFile(zfOutPath, 'w')
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
488 for zi in zf.infolist():
21603
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
489 if zi.filename == graalClassfilePath:
21693
dd987b035a0b fix bug where computed graal.version value is longer than the placeholder value
Doug Simon <doug.simon@oracle.com>
parents: 21671
diff changeset
490 data = graalClassfile.replace(placeholder, versionStr)
21603
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
491 else:
4437f0da4b26 handle graal.jar that has already had Graal.class patched
Doug Simon <doug.simon@oracle.com>
parents: 21589
diff changeset
492 data = zf.read(zi)
21560
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
493 zfOut.writestr(zi, data)
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
494 zfOut.close()
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
495 os.close(zfOutFd)
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
496 zf.close()
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
497 shutil.move(zfOutPath, dist.path)
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
498
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
499 def _installDistInJdks(deployableDist):
16623
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16622
diff changeset
500 """
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
501 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs
16623
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16622
diff changeset
502 """
21938
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
503 if True:
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
504 return
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
505 dist = mx.distribution(deployableDist.name)
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
506 if dist.name == 'GRAAL':
21560
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
507 _patchGraalVersionConstant(dist)
a9fba0dfb155 added lower runtime overhead mechanism for setting "graal.version" system property
Doug Simon <doug.simon@oracle.com>
parents: 21559
diff changeset
508
10574
0cad5096735e commands.py: Make sure _jdk returns an absolute path. Use _jdk and _jdksDir where necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10570
diff changeset
509 jdks = _jdksDir()
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8132
diff changeset
510 if exists(jdks):
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8132
diff changeset
511 for e in os.listdir(jdks):
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
512 jdkDir = join(jdks, e)
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
513 jreLibDir = join(jdkDir, 'jre', 'lib')
8134
6e3ebc6fd5a4 graal.jar is installed in all JDKs every time it is updated (GRAAL-136)
Doug Simon <doug.simon@oracle.com>
parents: 8132
diff changeset
514 if exists(jreLibDir):
21040
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
515 if deployableDist.isExtension:
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
516 targetDir = join(jreLibDir, 'ext')
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
517 elif deployableDist.usesJVMCIClassLoader:
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
518 targetDir = join(jreLibDir, 'jvmci')
21040
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
519 else:
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
520 targetDir = jreLibDir
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
521 if not exists(targetDir):
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
522 os.makedirs(targetDir)
12e94cba3696 Graal Loader: load all jars matching lib/graal/graal*.jar
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21032
diff changeset
523 _copyToJdk(dist.path, targetDir)
16623
addc0564e5b5 split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
Doug Simon <doug.simon@oracle.com>
parents: 16622
diff changeset
524 if dist.sourcesPath:
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
525 _copyToJdk(dist.sourcesPath, jdkDir)
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
526 if deployableDist.usesJVMCIClassLoader:
21070
2ee48d02afe3 mx: Merge graal service files
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21059
diff changeset
527 # deploy service files
21562
Doug Simon <doug.simon@oracle.com>
parents: 21560 21522
diff changeset
528 _updateJVMCIFiles(jdkDir)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
529
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
530 def _getJdkDeployedJars(jdkDir):
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
531 """
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
532 Gets jar paths for all deployed distributions in the context of
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
533 a given JDK directory.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
534 """
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
535 jreLibDir = join(jdkDir, 'jre', 'lib')
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
536 jars = []
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
537 for dist in _jdkDeployedDists:
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
538 jar = basename(mx.distribution(dist.name).path)
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
539 if dist.isExtension:
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
540 jars.append(join(jreLibDir, 'ext', jar))
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
541 elif dist.usesJVMCIClassLoader:
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
542 jars.append(join(jreLibDir, 'jvmci', jar))
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
543 else:
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
544 jars.append(join(jreLibDir, jar))
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
545 return jars
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
546
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
547
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
548 # run a command in the windows SDK Debug Shell
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
549 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
550 if respondTo is None:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
551 respondTo = {}
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
552 newLine = os.linesep
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
553 startToken = 'RUNINDEBUGSHELL_STARTSEQUENCE'
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
554 endToken = 'RUNINDEBUGSHELL_ENDSEQUENCE'
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
555
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
556 winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
557
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17224
diff changeset
558 if not exists(mx._cygpathW2U(winSDK)):
6306
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
559 mx.abort("Could not find Windows SDK : '" + winSDK + "' does not exist")
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
560
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17224
diff changeset
561 winSDKSetEnv = mx._cygpathW2U(join(winSDK, 'Bin', 'SetEnv.cmd'))
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
562 if not exists(winSDKSetEnv):
6306
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
563 mx.abort("Invalid Windows SDK path (" + winSDK + ") : could not find Bin/SetEnv.cmd (you can use the WIN_SDK environment variable to specify an other path)")
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
564
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17224
diff changeset
565 wincmd = 'cmd.exe /E:ON /V:ON /K "' + mx._cygpathU2W(winSDKSetEnv) + '"'
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
566 p = subprocess.Popen(wincmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
567 stdout = p.stdout
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
568 stdin = p.stdin
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
569 if logFile:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
570 log = open(logFile, 'w')
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
571 ret = False
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
572
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
573 def _writeProcess(s):
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
574 stdin.write(s + newLine)
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
575
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
576 _writeProcess("echo " + startToken)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
577 while 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: 7290
diff changeset
578 # encoding may be None on windows plattforms
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: 7290
diff changeset
579 if sys.stdout.encoding is None:
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: 7290
diff changeset
580 encoding = 'utf-8'
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: 7290
diff changeset
581 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: 7290
diff changeset
582 encoding = sys.stdout.encoding
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
583
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: 7290
diff changeset
584 line = stdout.readline().decode(encoding)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
585 if logFile:
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
586 log.write(line.encode('utf-8'))
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
587 line = line.strip()
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
588 mx.log(line)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
589 if line == startToken:
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
590 _writeProcess('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + endToken)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
591 for regex in respondTo.keys():
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
592 match = regex.search(line)
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
593 if match:
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
594 _writeProcess(respondTo[regex])
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
595 if findInOutput:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
596 match = findInOutput.search(line)
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
597 if match:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
598 ret = True
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
599 if line == endToken:
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
600 if not findInOutput:
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
601 _writeProcess('echo ERRXXX%errorlevel%')
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
602 else:
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
603 break
5868
a10e72af4dc5 Make windows build work even if Visual Studio is not installed (only the Windows SDK is required)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5782
diff changeset
604 if line.startswith('ERRXXX'):
a10e72af4dc5 Make windows build work even if Visual Studio is not installed (only the Windows SDK is required)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5782
diff changeset
605 if line == 'ERRXXX0':
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
606 ret = True
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
607 break
17224
a02c295218aa mx: add support for cygwin
Bernhard Urban <bernhard.urban@jku.at>
parents: 17055
diff changeset
608 _writeProcess("exit")
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
609 if logFile:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
610 log.close()
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
611 return ret
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
612
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
613 def jdkhome(vm=None):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
614 """return the JDK directory selected for the 'vm' command"""
17055
3e4d3be0b6bf mx: fix default handling of vm config and build type
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17052
diff changeset
615 return _jdk(installJars=False)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
616
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
617 def print_jdkhome(args, vm=None):
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
618 """print the JDK directory selected for the 'vm' command"""
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
619 print jdkhome(vm)
5103
276e14614531 Added jdkhome command to mx.
Doug Simon <doug.simon@oracle.com>
parents: 5094
diff changeset
620
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
621 def buildvars(args):
11377
0fbc1e418c88 fixed capitalization and tense in documentation of some mx commands
Doug Simon <doug.simon@oracle.com>
parents: 11373
diff changeset
622 """describe the variables that can be set by the -D option to the 'mx build' commmand"""
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
623
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
624 buildVars = {
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
625 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.java().jdk + ')',
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
626 'ALT_OUTPUTDIR' : 'Build directory',
18876
c446d00f2cdf mx: added support for Jython 2.7b3 and made ordering in generated files more deterministic\nContributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Doug Simon <doug.simon@oracle.com>
parents: 18869
diff changeset
627 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(mx.cpu_count()) + ')',
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
628 'INSTALL' : 'Install the built VM into the JDK? (default: y)',
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
629 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)',
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
630 }
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
631
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
632 mx.log('HotSpot build variables that can be set by the -D option to "mx build":')
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
633 mx.log('')
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
634 for n in sorted(buildVars.iterkeys()):
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
635 mx.log(n)
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
636 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
637
9120
9f361c0f912b added note about mx/env to the output of 'mx buildvars'
Doug Simon <doug.simon@oracle.com>
parents: 9119
diff changeset
638 mx.log('')
9f361c0f912b added note about mx/env to the output of 'mx buildvars'
Doug Simon <doug.simon@oracle.com>
parents: 9119
diff changeset
639 mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
640
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
641 cached_graal_version = None
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
642
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
643 def graal_version(dev_suffix='dev'):
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
644 global cached_graal_version
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
645
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
646 if not cached_graal_version:
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
647 # extract latest release tag for graal
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
648 try:
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
649 tags = [x.split() for x in subprocess.check_output(['hg', '-R', _graal_home, 'tags']).split('\n') if x.startswith("graal-")]
16862
bf499b4d86e9 mx: fix release tag detection for -dev suffix
Bernhard Urban <bernhard.urban@jku.at>
parents: 16858
diff changeset
650 current_id = subprocess.check_output(['hg', '-R', _graal_home, 'log', '--template', '{rev}\n', '--rev', 'tip']).strip()
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
651 except:
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
652 # not a mercurial repository or hg commands are not available.
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
653 tags = None
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
654
16862
bf499b4d86e9 mx: fix release tag detection for -dev suffix
Bernhard Urban <bernhard.urban@jku.at>
parents: 16858
diff changeset
655 if tags and current_id:
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
656 sorted_tags = sorted(tags, key=lambda e: [int(x) for x in e[0][len("graal-"):].split('.')], reverse=True)
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
657 most_recent_tag_name, most_recent_tag_revision = sorted_tags[0]
16862
bf499b4d86e9 mx: fix release tag detection for -dev suffix
Bernhard Urban <bernhard.urban@jku.at>
parents: 16858
diff changeset
658 most_recent_tag_id = most_recent_tag_revision[:most_recent_tag_revision.index(":")]
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
659 most_recent_tag_version = most_recent_tag_name[len("graal-"):]
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
660
16862
bf499b4d86e9 mx: fix release tag detection for -dev suffix
Bernhard Urban <bernhard.urban@jku.at>
parents: 16858
diff changeset
661 # tagged commit is one-off with commit that tags it
bf499b4d86e9 mx: fix release tag detection for -dev suffix
Bernhard Urban <bernhard.urban@jku.at>
parents: 16858
diff changeset
662 if int(current_id) - int(most_recent_tag_id) <= 1:
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
663 cached_graal_version = most_recent_tag_version
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
664 else:
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
665 major, minor = map(int, most_recent_tag_version.split('.'))
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
666 cached_graal_version = str(major) + '.' + str(minor + 1) + '-' + dev_suffix
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
667 else:
21886
b1234c06ea49 removed timestamp from "unknown" Graal version string
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
668 cached_graal_version = 'unknown-{0}'.format(platform.node())
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
669
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
670 return cached_graal_version
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
671
4577
bc8b58c11768 Added debug build of HotSpot Client to the gate.
Doug Simon <doug.simon@oracle.com>
parents: 4575
diff changeset
672 def build(args, vm=None):
4575
ccb5369481a2 Clarified mx help text on how to build/run [Graal|Client|Server].
Doug Simon <doug.simon@oracle.com>
parents: 4572
diff changeset
673 """build the VM binary
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
674
11392
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
675 The global '--vm' and '--vmbuild' options select which VM type and build target to build."""
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
676
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
677 # Override to fail quickly if extra arguments are given
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
678 # at the end of the command line. This allows for a more
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
679 # helpful error message.
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
680 class AP(ArgumentParser):
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
681 def __init__(self):
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
682 ArgumentParser.__init__(self, prog='mx build')
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
683 def parse_args(self, args):
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
684 result = ArgumentParser.parse_args(self, args)
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
685 if len(result.remainder) != 0:
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
686 firstBuildTarget = result.remainder[0]
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
687 mx.abort('To specify the ' + firstBuildTarget + ' VM build target, you need to use the global "--vmbuild" option. For example:\n' +
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
688 ' mx --vmbuild ' + firstBuildTarget + ' build')
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
689 return result
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
690
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
691 # Call mx.build to compile the Java sources
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
692 parser = AP()
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
693 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
21791
cd36556e1b78 Remove conditional makefile-based compilation of jvmci from mx_graal.py
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21790
diff changeset
694
9116
e2dae636732a added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
Doug Simon <doug.simon@oracle.com>
parents: 9098
diff changeset
695 opts2 = mx.build(['--source', '1.7'] + args, parser=parser)
11392
66251d9f62ab fail faster with better error message if deprecated and unsupported mx build command line is given
Doug Simon <doug.simon@oracle.com>
parents: 11377
diff changeset
696 assert len(opts2.remainder) == 0
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
697
5257
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
698 def vmg(args):
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
699 """run the debug build of VM selected by the '--vm' option"""
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
700 return vm(args, vmbuild='debug')
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
701
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
702 def vmfg(args):
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
703 """run the fastdebug build of VM selected by the '--vm' option"""
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
704 return vm(args, vmbuild='fastdebug')
a549662f6c6f added 'vmg' and 'vmfg' commands to mx as convenient aliases for running the debug and fastdebug builds of the selected VM
Doug Simon <doug.simon@oracle.com>
parents: 5245
diff changeset
705
13951
392b6ac8da36 Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents: 13949
diff changeset
706 def _parseVmArgs(args, vm=None, cwd=None, vmbuild=None):
4575
ccb5369481a2 Clarified mx help text on how to build/run [Graal|Client|Server].
Doug Simon <doug.simon@oracle.com>
parents: 4572
diff changeset
707 """run the VM selected by the '--vm' option"""
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4216
diff changeset
708
21939
e24237684856 Few more tweaks to help us pass the gate
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21938
diff changeset
709 jdk = mx.java().jdk
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: 5153
diff changeset
710 mx.expand_project_in_args(args)
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
711 exe = join(jdk, 'bin', mx.exe_suffix('java'))
21958
ef8c90391f1e Removing references to vmSources
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21957
diff changeset
712 pfx = []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
713
9667
1ef7b26e9177 mx/commands.py: warn about arguments after '-version' when launching the vm
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9639
diff changeset
714 if '-version' in args:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
715 ignoredArgs = args[args.index('-version') + 1:]
21939
e24237684856 Few more tweaks to help us pass the gate
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21938
diff changeset
716 if len(ignoredArgs) > 0:
9667
1ef7b26e9177 mx/commands.py: warn about arguments after '-version' when launching the vm
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9639
diff changeset
717 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
718
21796
1c22030625eb moved putting truffle.jar on the boot class path from the VM to mx (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21791
diff changeset
719 # Unconditionally prepend Truffle to the boot class path.
1c22030625eb moved putting truffle.jar on the boot class path from the VM to mx (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21791
diff changeset
720 # This used to be done by the VM itself but was removed to
1c22030625eb moved putting truffle.jar on the boot class path from the VM to mx (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21791
diff changeset
721 # separate the VM from Truffle.
1c22030625eb moved putting truffle.jar on the boot class path from the VM to mx (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21791
diff changeset
722 truffle_jar = mx.archive(['@TRUFFLE'])[0]
1c22030625eb moved putting truffle.jar on the boot class path from the VM to mx (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21791
diff changeset
723 args = ['-Xbootclasspath/p:' + truffle_jar] + args
16877
6adb14d2320c truffle.jar should always be on the bootclasspath regardless of the 'graal' status of the vm.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16875
diff changeset
724
13952
b076b5c13c3f mx: factor out JavaConfig.processArgs and use it in mx vm. remove default -J arguments.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13951
diff changeset
725 args = mx.java().processArgs(args)
13951
392b6ac8da36 Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents: 13949
diff changeset
726 return (pfx, exe, vm, args, cwd)
392b6ac8da36 Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents: 13949
diff changeset
727
392b6ac8da36 Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness
Bernhard Urban <bernhard.urban@jku.at>
parents: 13949
diff changeset
728 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None):
21939
e24237684856 Few more tweaks to help us pass the gate
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21938
diff changeset
729 (pfx_, exe_, _, args_, cwd) = _parseVmArgs(args, vm, cwd, vmbuild)
e24237684856 Few more tweaks to help us pass the gate
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21938
diff changeset
730 return mx.run(pfx_ + [exe_] + args_, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
731
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: 5729
diff changeset
732 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False):
5366
67e63e8dcbd2 build JaCoCo exclude list by scanning for snippets
Doug Simon <doug.simon@oracle.com>
parents: 5295
diff changeset
733 """
5482
9f4783c0269e folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5438
diff changeset
734 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation'
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: 5729
diff changeset
735 (ignoring preceding whitespace) and return the fully qualified class name for each 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: 5729
diff changeset
736 source file matched in a list.
5366
67e63e8dcbd2 build JaCoCo exclude list by scanning for snippets
Doug Simon <doug.simon@oracle.com>
parents: 5295
diff changeset
737 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
738
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
739 matches = lambda line: len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0
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: 5729
diff changeset
740 return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses)
5366
67e63e8dcbd2 build JaCoCo exclude list by scanning for snippets
Doug Simon <doug.simon@oracle.com>
parents: 5295
diff changeset
741
14744
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
742 def _extract_VM_args(args, allowClasspath=False, useDoubleDash=False, defaultAllVMArgs=True):
11359
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
743 """
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
744 Partitions a command line into a leading sequence of HotSpot VM options and the rest.
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
745 """
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
746 for i in range(0, len(args)):
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
747 if useDoubleDash:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
748 if args[i] == '--':
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
749 vmArgs = args[:i]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
750 remainder = args[i + 1:]
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
751 return vmArgs, remainder
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
752 else:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
753 if not args[i].startswith('-'):
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
754 if i != 0 and (args[i - 1] == '-cp' or args[i - 1] == '-classpath'):
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
755 if not allowClasspath:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
756 mx.abort('Cannot supply explicit class path option')
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
757 else:
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
758 continue
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
759 vmArgs = args[:i]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
760 remainder = args[i:]
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
761 return vmArgs, remainder
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
762
14744
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
763 if defaultAllVMArgs:
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
764 return args, []
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
765 else:
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
766 return [], args
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
767
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
768 def _run_tests(args, harness, annotations, testfile, blacklist, whitelist, regex):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
769
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
770
11359
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
771 vmArgs, tests = _extract_VM_args(args)
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
772 for t in tests:
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
773 if t.startswith('-'):
11403
e45b540b0ef2 clearer error message
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
774 mx.abort('VM option ' + t + ' must precede ' + tests[0])
4159
e253ca26b2d5 Added 'unittest' command to run the Graal unit tests.
Doug Simon <doug.simon@oracle.com>
parents: 4157
diff changeset
775
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
776 candidates = {}
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11758
diff changeset
777 for p in mx.projects_opt_limit_to_suites():
9639
fde5ccbab3a3 made unittest command take Java compliance of a project into account
Doug Simon <doug.simon@oracle.com>
parents: 9598
diff changeset
778 if mx.java().javaCompliance < p.javaCompliance:
fde5ccbab3a3 made unittest command take Java compliance of a project into account
Doug Simon <doug.simon@oracle.com>
parents: 9598
diff changeset
779 continue
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
780 for c in _find_classes_with_annotations(p, None, annotations).keys():
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
781 candidates[c] = p
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
782
10606
a6c0ae38e05e more robust command line checking for unittest (at cost of removing support for negative filters)
Doug Simon <doug.simon@oracle.com>
parents: 10574
diff changeset
783 classes = []
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
784 if len(tests) == 0:
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
785 classes = candidates.keys()
16393
380290b81eb0 mx: converted class path variables to camel case for better readability
Doug Simon <doug.simon@oracle.com>
parents: 16388
diff changeset
786 projectsCp = mx.classpath([pcp.name for pcp in mx.projects_opt_limit_to_suites() if pcp.javaCompliance <= mx.java().javaCompliance])
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
787 else:
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
788 projs = set()
18237
6924bb0badc9 mx: set initial value for flag
Bernhard Urban <bernhard.urban@jku.at>
parents: 18224
diff changeset
789 found = False
16388
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
790 if len(tests) == 1 and '#' in tests[0]:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
791 words = tests[0].split('#')
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
792 if len(words) != 2:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
793 mx.abort("Method specification is class#method: " + tests[0])
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
794 t, method = words
18237
6924bb0badc9 mx: set initial value for flag
Bernhard Urban <bernhard.urban@jku.at>
parents: 18224
diff changeset
795
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
796 for c, p in candidates.iteritems():
18714
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
797 # prefer exact matches first
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
798 if t == c:
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
799 found = True
18714
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
800 classes.append(c)
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
801 projs.add(p.name)
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
802 if not found:
18714
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
803 for c, p in candidates.iteritems():
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
804 if t in c:
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
805 found = True
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
806 classes.append(c)
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
807 projs.add(p.name)
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
808 if not found:
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
809 mx.log('warning: no tests matched by substring "' + t)
18714
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
810 elif len(classes) != 1:
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
811 mx.abort('More than one test matches substring {0} {1}'.format(t, classes))
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
812
b56e88144e0a prefer exact class matches when searching for unit tests with method name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18711
diff changeset
813 classes = [c + "#" + method for c in classes]
16388
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
814 else:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
815 for t in tests:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
816 if '#' in t:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
817 mx.abort('Method specifications can only be used in a single test: ' + t)
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
818 for c, p in candidates.iteritems():
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
819 if t in c:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
820 found = True
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
821 classes.append(c)
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
822 projs.add(p.name)
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
823 if not found:
31e242cad4d1 Allow mx unittest to run single test method from a class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16381
diff changeset
824 mx.log('warning: no tests matched by substring "' + t)
16393
380290b81eb0 mx: converted class path variables to camel case for better readability
Doug Simon <doug.simon@oracle.com>
parents: 16388
diff changeset
825 projectsCp = mx.classpath(projs)
8343
a3c30d467f96 unittest: just do a single JVM call
Bernhard Urban <bernhard.urban@jku.at>
parents: 8340
diff changeset
826
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
827 if blacklist:
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
828 classes = [c for c in classes if not any((glob.match(c) for glob in blacklist))]
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
829
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
830 if whitelist:
15328
d89ed48ae349 mx: use generators
Bernhard Urban <bernhard.urban@jku.at>
parents: 15327
diff changeset
831 classes = [c for c in classes if any((glob.match(c) for glob in whitelist))]
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
832
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
833 if regex:
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
834 classes = [c for c in classes if re.search(regex, c)]
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
835
8343
a3c30d467f96 unittest: just do a single JVM call
Bernhard Urban <bernhard.urban@jku.at>
parents: 8340
diff changeset
836 if len(classes) != 0:
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
837 f_testfile = open(testfile, 'w')
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
838 for c in classes:
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
839 f_testfile.write(c + '\n')
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
840 f_testfile.close()
16393
380290b81eb0 mx: converted class path variables to camel case for better readability
Doug Simon <doug.simon@oracle.com>
parents: 16388
diff changeset
841 harness(projectsCp, vmArgs)
5649
14505f3e6b4c modified harness for running JUnit and JTT tests such that only projects declaring a 'testHarness' attribute in mx/projects are scanned for tests
Doug Simon <doug.simon@oracle.com>
parents: 5596
diff changeset
842
18326
840257b6cdc5 mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents: 18237
diff changeset
843 def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False):
9010
08a16c26907f MX_TESTFILE environment variable can be used to specify (and preserve) the test list file used by 'mx unittest'.
Doug Simon <doug.simon@oracle.com>
parents: 8901
diff changeset
844 testfile = os.environ.get('MX_TESTFILE', None)
08a16c26907f MX_TESTFILE environment variable can be used to specify (and preserve) the test list file used by 'mx unittest'.
Doug Simon <doug.simon@oracle.com>
parents: 8901
diff changeset
845 if testfile is None:
08a16c26907f MX_TESTFILE environment variable can be used to specify (and preserve) the test list file used by 'mx unittest'.
Doug Simon <doug.simon@oracle.com>
parents: 8901
diff changeset
846 (_, testfile) = tempfile.mkstemp(".testclasses", "graal")
9236
ec607ddaa99b windows-specific mx fix for executing unit tests selectively
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9177
diff changeset
847 os.close(_)
18351
1e7b53d7489d fixed pylint issue
Doug Simon <doug.simon@oracle.com>
parents: 18346
diff changeset
848
21938
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
849 coreCp = mx.classpath(['com.oracle.truffle.tck', 'HCFDIS'])
15575
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
850
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
851 coreArgs = []
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
852 if verbose:
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
853 coreArgs.append('-JUnitVerbose')
18326
840257b6cdc5 mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents: 18237
diff changeset
854 if fail_fast:
840257b6cdc5 mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents: 18237
diff changeset
855 coreArgs.append('-JUnitFailFast')
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
856 if enable_timing:
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
857 coreArgs.append('-JUnitEnableTiming')
15655
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
858 if color:
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
859 coreArgs.append('-JUnitColor')
15656
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
860 if eager_stacktrace:
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
861 coreArgs.append('-JUnitEagerStackTrace')
15907
7d1690e145ae mx: option to force a GC after each unit test
Roland Schatz <roland.schatz@oracle.com>
parents: 15896
diff changeset
862 if gc_after_test:
7d1690e145ae mx: option to force a GC after each unit test
Roland Schatz <roland.schatz@oracle.com>
parents: 15896
diff changeset
863 coreArgs.append('-JUnitGCAfterTest')
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
864
15575
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
865
16393
380290b81eb0 mx: converted class path variables to camel case for better readability
Doug Simon <doug.simon@oracle.com>
parents: 16388
diff changeset
866 def harness(projectsCp, vmArgs):
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
867 if _get_vm() != 'jvmci':
8440
2d0160c35f8f Fix unittest on server0.
Roland Schatz <roland.schatz@oracle.com>
parents: 8433
diff changeset
868 prefixArgs = ['-esa', '-ea']
2d0160c35f8f Fix unittest on server0.
Roland Schatz <roland.schatz@oracle.com>
parents: 8433
diff changeset
869 else:
21632
abcb811659e0 mx: use BootstrapJVMCI rather than BootstrapGraal
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21615
diff changeset
870 prefixArgs = ['-XX:-BootstrapJVMCI', '-esa', '-ea']
16002
c60362c5150f mx: Use -XX:-DisableExplicitGC when running unit tests with --gc-after-test.
Roland Schatz <roland.schatz@oracle.com>
parents: 15940
diff changeset
871 if gc_after_test:
c60362c5150f mx: Use -XX:-DisableExplicitGC when running unit tests with --gc-after-test.
Roland Schatz <roland.schatz@oracle.com>
parents: 15940
diff changeset
872 prefixArgs.append('-XX:-DisableExplicitGC')
11227
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
873 with open(testfile) as fp:
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
874 testclasses = [l.rstrip() for l in fp.readlines()]
16395
ad431bf0de07 added support to load classes from graal.jar with a separate class loader
Doug Simon <doug.simon@oracle.com>
parents: 16394
diff changeset
875
ad431bf0de07 added support to load classes from graal.jar with a separate class loader
Doug Simon <doug.simon@oracle.com>
parents: 16394
diff changeset
876 # Remove entries from class path that are in graal.jar and
ad431bf0de07 added support to load classes from graal.jar with a separate class loader
Doug Simon <doug.simon@oracle.com>
parents: 16394
diff changeset
877 # run the VM in a mode where application/test classes can
ad431bf0de07 added support to load classes from graal.jar with a separate class loader
Doug Simon <doug.simon@oracle.com>
parents: 16394
diff changeset
878 # access core Graal classes.
16394
0dd27c6472d7 mx: remove entries from unittest class path that are in graal.jar when running with a Graal enabled VM
Doug Simon <doug.simon@oracle.com>
parents: 16393
diff changeset
879 cp = prefixCp + coreCp + os.pathsep + projectsCp
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
880 if isJVMCIEnabled(_get_vm()):
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
881 excluded = set()
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
882 for jdkDist in _jdkDeployedDists:
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
883 dist = mx.distribution(jdkDist.name)
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
884 excluded.update([d.output_dir() for d in dist.sorted_deps()])
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
885 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded])
16395
ad431bf0de07 added support to load classes from graal.jar with a separate class loader
Doug Simon <doug.simon@oracle.com>
parents: 16394
diff changeset
886
18224
bfa20550f0a8 Suppress menubar for GraalJUnitCore on Mac
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18218
diff changeset
887 # suppress menubar and dock when running on Mac
bfa20550f0a8 Suppress menubar for GraalJUnitCore on Mac
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18218
diff changeset
888 vmArgs = ['-Djava.awt.headless=true'] + vmArgs
bfa20550f0a8 Suppress menubar for GraalJUnitCore on Mac
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18218
diff changeset
889
11227
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
890 if len(testclasses) == 1:
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
891 # Execute Junit directly when one test is being run. This simplifies
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
892 # replaying the VM execution in a native debugger (e.g., gdb).
21938
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
893 vm(prefixArgs + vmArgs + ['-cp', mx._separatedCygpathU2W(cp), 'com.oracle.truffle.tck.TruffleJUnitCore'] + coreArgs + testclasses)
11227
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
894 else:
21938
0a6e10379b9b Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21910
diff changeset
895 vm(prefixArgs + vmArgs + ['-cp', mx._separatedCygpathU2W(cp), 'com.oracle.truffle.tck.TruffleJUnitCore'] + coreArgs + ['@' + mx._cygpathU2W(testfile)])
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
896
8433
87346100d7a5 temporary file is removed when unittests fail
Doug Simon <doug.simon@oracle.com>
parents: 8406
diff changeset
897 try:
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
898 _run_tests(args, harness, annotations, testfile, blacklist, whitelist, regex)
8433
87346100d7a5 temporary file is removed when unittests fail
Doug Simon <doug.simon@oracle.com>
parents: 8406
diff changeset
899 finally:
9010
08a16c26907f MX_TESTFILE environment variable can be used to specify (and preserve) the test list file used by 'mx unittest'.
Doug Simon <doug.simon@oracle.com>
parents: 8901
diff changeset
900 if os.environ.get('MX_TESTFILE') is None:
08a16c26907f MX_TESTFILE environment variable can be used to specify (and preserve) the test list file used by 'mx unittest'.
Doug Simon <doug.simon@oracle.com>
parents: 8901
diff changeset
901 os.remove(testfile)
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
902
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
903 _unittestHelpSuffix = """
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
904 Unittest options:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
905
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
906 --blacklist <file> run all testcases not specified in the blacklist
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
907 --whitelist <file> run only testcases which are included
15323
6b3bb5a9a889 mx: allow to specify a path for the whitelist in the unittest command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15322
diff changeset
908 in the given whitelist
15502
a26be2c9b81b Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents: 15500
diff changeset
909 --verbose enable verbose JUnit output
18326
840257b6cdc5 mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents: 18237
diff changeset
910 --fail-fast stop after first JUnit test class that has a failure
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
911 --enable-timing enable JUnit test timing
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
912 --regex <regex> run only testcases matching a regular expression
15655
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
913 --color enable colors output
15656
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
914 --eager-stacktrace print stacktrace eagerly
15907
7d1690e145ae mx: option to force a GC after each unit test
Roland Schatz <roland.schatz@oracle.com>
parents: 15896
diff changeset
915 --gc-after-test force a GC after each test
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
916
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
917 To avoid conflicts with VM options '--' can be used as delimiter.
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
918
5649
14505f3e6b4c modified harness for running JUnit and JTT tests such that only projects declaring a 'testHarness' attribute in mx/projects are scanned for tests
Doug Simon <doug.simon@oracle.com>
parents: 5596
diff changeset
919 If filters are supplied, only tests whose fully qualified name
10606
a6c0ae38e05e more robust command line checking for unittest (at cost of removing support for negative filters)
Doug Simon <doug.simon@oracle.com>
parents: 10574
diff changeset
920 includes a filter as a substring are run.
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
921
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
922 For example, this command line:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
923
11367
39b86b83ddeb normalized the command line interface for the dacapo, scaladacapo, specjvm2008, specjbb2005 and specjbb2013 commands
Doug Simon <doug.simon@oracle.com>
parents: 11359
diff changeset
924 mx unittest -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG BC_aload
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
925
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
926 will run all JUnit test classes that contain 'BC_aload' in their
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
927 fully qualified name and will pass these options to the VM:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
928
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
929 -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
930
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
931 To get around command line length limitations on some OSes, the
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
932 JUnit class names to be executed are written to a file that a
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
933 custom JUnit wrapper reads and passes onto JUnit proper. The
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
934 MX_TESTFILE environment variable can be set to specify a
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
935 file which will not be deleted once the unittests are done
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
936 (unlike the temporary file otherwise used).
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
937
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
938 As with all other commands, using the global '-v' before 'unittest'
11359
51b0b1104114 changed unittest command to remove use of '@' character. The format is now: mx unittest [VM options] [test filters...]
Doug Simon <doug.simon@oracle.com>
parents: 11302
diff changeset
939 command will cause mx to show the complete command line
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
940 it uses to run the VM.
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
941 """
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
942
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
943 def unittest(args):
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
944 """run the JUnit tests (all testcases){0}"""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
945
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
946 parser = ArgumentParser(prog='mx unittest',
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
947 description='run the JUnit tests',
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
948 add_help=False,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
949 formatter_class=RawDescriptionHelpFormatter,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
950 epilog=_unittestHelpSuffix,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
951 )
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
952 parser.add_argument('--blacklist', help='run all testcases not specified in the blacklist', metavar='<path>')
15323
6b3bb5a9a889 mx: allow to specify a path for the whitelist in the unittest command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15322
diff changeset
953 parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>')
15502
a26be2c9b81b Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents: 15500
diff changeset
954 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true')
18326
840257b6cdc5 mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents: 18237
diff changeset
955 parser.add_argument('--fail-fast', help='stop after first JUnit test class that has a failure', action='store_true')
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
956 parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true')
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
957 parser.add_argument('--regex', help='run only testcases matching a regular expression', metavar='<regex>')
15655
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
958 parser.add_argument('--color', help='enable color output', action='store_true')
15656
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
959 parser.add_argument('--eager-stacktrace', help='print stacktrace eagerly', action='store_true')
15907
7d1690e145ae mx: option to force a GC after each unit test
Roland Schatz <roland.schatz@oracle.com>
parents: 15896
diff changeset
960 parser.add_argument('--gc-after-test', help='force a GC after each test', action='store_true')
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
961
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
962 ut_args = []
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
963 delimiter = False
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
964 # check for delimiter
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
965 while len(args) > 0:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
966 arg = args.pop(0)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
967 if arg == '--':
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
968 delimiter = True
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
969 break
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
970 ut_args.append(arg)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
971
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
972 if delimiter:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
973 # all arguments before '--' must be recognized
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
974 parsed_args = parser.parse_args(ut_args)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
975 else:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
976 # parse all know arguments
15197
06bfcf5f941d mx: improve unittest options parsing.
Josef Eisl <josef.eisl@jku.at>
parents: 15178
diff changeset
977 parsed_args, args = parser.parse_known_args(ut_args)
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
978
15323
6b3bb5a9a889 mx: allow to specify a path for the whitelist in the unittest command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15322
diff changeset
979 if parsed_args.whitelist:
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
980 try:
15323
6b3bb5a9a889 mx: allow to specify a path for the whitelist in the unittest command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15322
diff changeset
981 with open(join(_graal_home, parsed_args.whitelist)) as fp:
15657
50740bac9679 mx unittest: simplify argument passing.
Josef Eisl <josef.eisl@jku.at>
parents: 15656
diff changeset
982 parsed_args.whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')]
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
983 except IOError:
15323
6b3bb5a9a889 mx: allow to specify a path for the whitelist in the unittest command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15322
diff changeset
984 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist)
16979
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
985 if parsed_args.blacklist:
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
986 try:
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
987 with open(join(_graal_home, parsed_args.blacklist)) as fp:
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
988 parsed_args.blacklist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')]
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
989 except IOError:
e9ff3e7055e5 mx: add unittest --blacklist.
Josef Eisl <josef.eisl@jku.at>
parents: 16976
diff changeset
990 mx.log('warning: could not read blacklist: ' + parsed_args.blacklist)
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
991
15657
50740bac9679 mx unittest: simplify argument passing.
Josef Eisl <josef.eisl@jku.at>
parents: 15656
diff changeset
992 _unittest(args, ['@Test', '@Parameters'], **parsed_args.__dict__)
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
993
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
994 def shortunittest(args):
15324
5b5f47104c0d mx: add whitelist for shortunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15323
diff changeset
995 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}"""
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
996
15324
5b5f47104c0d mx: add whitelist for shortunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15323
diff changeset
997 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
998 unittest(args)
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
999
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1000 class Task:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1001 # None or a list of strings. If not None, only tasks whose title
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1002 # matches at least one of the substrings in this list will return
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1003 # a non-None value from __enter__. The body of a 'with Task(...) as t'
20002
5aa0cb2914f8 fixed pylint issue
Doug Simon <doug.simon@oracle.com>
parents: 20000
diff changeset
1004 # statement should check 't' and exit immediately if it is None.
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1005 filters = None
21639
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1006 filtersExclude = False
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1007
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1008 def __init__(self, title, tasks=None):
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1009 self.tasks = tasks
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1010 self.title = title
21639
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1011 if tasks is not None and Task.filters is not None:
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1012 if Task.filtersExclude:
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1013 self.skipped = any([f in title for f in Task.filters])
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1014 else:
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1015 self.skipped = not any([f in title for f in Task.filters])
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1016 else:
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1017 self.skipped = False
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1018 if not self.skipped:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1019 self.start = time.time()
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1020 self.end = None
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1021 self.duration = None
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1022 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title)
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1023 def __enter__(self):
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1024 assert self.tasks is not None, "using Task with 'with' statement requires to pass the tasks list in the constructor"
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1025 if self.skipped:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1026 return None
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1027 return self
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1028 def __exit__(self, exc_type, exc_value, traceback):
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1029 if not self.skipped:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1030 self.tasks.append(self.stop())
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1031 def stop(self):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1032 self.end = time.time()
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1033 self.duration = datetime.timedelta(seconds=self.end - self.start)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1034 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: END: ') + self.title + ' [' + str(self.duration) + ']')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1035 return self
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1036 def abort(self, codeOrMessage):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1037 self.end = time.time()
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1038 self.duration = datetime.timedelta(seconds=self.end - self.start)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1039 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: ABORT: ') + self.title + ' [' + str(self.duration) + ']')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1040 mx.abort(codeOrMessage)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1041 return self
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1042
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1043 def _basic_gate_body(args, tasks):
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1044 # Run unit tests on server-hosted-jvmci
21957
04fd8d2361df Additional simplification of the mx_truffle.py
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21956
diff changeset
1045 with Task('UnitTests:hosted-product', tasks) as t:
04fd8d2361df Additional simplification of the mx_truffle.py
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21956
diff changeset
1046 if t: unittest(['--enable-timing', '--verbose', '--fail-fast'])
19160
d4f80cf249d0 Run unittest earlier during gate
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19044
diff changeset
1047
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1048
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1049 def gate(args, gate_body=_basic_gate_body):
4159
e253ca26b2d5 Added 'unittest' command to run the Graal unit tests.
Doug Simon <doug.simon@oracle.com>
parents: 4157
diff changeset
1050 """run the tests used to validate a push
e253ca26b2d5 Added 'unittest' command to run the Graal unit tests.
Doug Simon <doug.simon@oracle.com>
parents: 4157
diff changeset
1051
4438
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1052 If this command exits with a 0 exit code, then the source code is in
4159
e253ca26b2d5 Added 'unittest' command to run the Graal unit tests.
Doug Simon <doug.simon@oracle.com>
parents: 4157
diff changeset
1053 a state that would be accepted for integration into the main repository."""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1054
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1055 parser = ArgumentParser(prog='mx gate')
5232
c005ca943790 added -j option to gate command to disable cleaning of Java class files
Doug Simon <doug.simon@oracle.com>
parents: 5197
diff changeset
1056 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
5750
30876d0bb92d In gate command, allways build natives, use '-n' to avoid cleaning them only
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5729
diff changeset
1057 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
21482
2fe8729dd813 mx gate: add option to skip ideclean
Roland Schatz <roland.schatz@oracle.com>
parents: 21447
diff changeset
1058 parser.add_argument('-i', '--omit-ide-clean', action='store_false', dest='cleanIde', help='omit cleaning the ide project files')
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1059 parser.add_argument('-g', '--only-build-jvmci', action='store_false', dest='buildNonJVMCI', help='only build the JVMCI VM')
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1060 parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run')
21639
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1061 parser.add_argument('-x', action='store_true', help='makes --task-filter an exclusion instead of inclusion filter')
4601
ade18666f2be Added --omit-native-build to gate command so that native cleaning and building can be omitted for changesets that made no changes to the C/C++ code.
Doug Simon <doug.simon@oracle.com>
parents: 4584
diff changeset
1062
ade18666f2be Added --omit-native-build to gate command so that native cleaning and building can be omitted for changesets that made no changes to the C/C++ code.
Doug Simon <doug.simon@oracle.com>
parents: 4584
diff changeset
1063 args = parser.parse_args(args)
ade18666f2be Added --omit-native-build to gate command so that native cleaning and building can be omitted for changesets that made no changes to the C/C++ code.
Doug Simon <doug.simon@oracle.com>
parents: 4584
diff changeset
1064
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1065 if args.task_filter:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1066 Task.filters = args.task_filter.split(',')
21639
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1067 Task.filtersExclude = args.x
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1068 elif args.x:
e65bf81961be added -x option to gate command that makes --task-filter an exclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
1069 mx.abort('-x option cannot be used without --task-filter option')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1070
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1071 # Force
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1072 if not mx._opts.strict_compliance:
21514
b426469fadb7 mx: better description for strict-compliance and fix typo
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21169
diff changeset
1073 mx.log("[gate] forcing strict compliance")
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1074 mx._opts.strict_compliance = True
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1075
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1076 tasks = []
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
1077 total = Task('Gate')
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
1078 try:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1079 with Task('Pylint', tasks) as t:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1080 if t: mx.pylint([])
11526
db297343d44e added pylint to gate
Doug Simon <doug.simon@oracle.com>
parents: 11525
diff changeset
1081
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1082 def _clean(name='Clean'):
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1083 with Task(name, tasks) as t:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1084 if t:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1085 cleanArgs = []
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1086 if not args.cleanNative:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1087 cleanArgs.append('--no-native')
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1088 if not args.cleanJava:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1089 cleanArgs.append('--no-java')
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1090 clean(cleanArgs)
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1091 _clean()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1092
21482
2fe8729dd813 mx gate: add option to skip ideclean
Roland Schatz <roland.schatz@oracle.com>
parents: 21447
diff changeset
1093 with Task('IDEConfigCheck', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1094 if t:
21482
2fe8729dd813 mx gate: add option to skip ideclean
Roland Schatz <roland.schatz@oracle.com>
parents: 21447
diff changeset
1095 if args.cleanIde:
2fe8729dd813 mx gate: add option to skip ideclean
Roland Schatz <roland.schatz@oracle.com>
parents: 21447
diff changeset
1096 mx.ideclean([])
2fe8729dd813 mx gate: add option to skip ideclean
Roland Schatz <roland.schatz@oracle.com>
parents: 21447
diff changeset
1097 mx.ideinit([])
9824
6fa4b4933892 added check to gate that generated IDE configurations don't break the build
Doug Simon <doug.simon@oracle.com>
parents: 9803
diff changeset
1098
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1099 eclipse_exe = mx.get_env('ECLIPSE_EXE')
7533
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1100 if eclipse_exe is not None:
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1101 with Task('CodeFormatCheck', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1102 if t and mx.eclipseformat(['-e', eclipse_exe]) != 0:
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1103 t.abort('Formatter modified files - run "mx eclipseformat", check in changes and repush')
8211
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1104
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1105 with Task('Canonicalization Check', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1106 if t:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1107 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...'))
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1108 if mx.canonicalizeprojects([]) != 0:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1109 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1110
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1111 if mx.get_env('JDT'):
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1112 with Task('BuildJavaWithEcj', tasks):
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1113 if t: build(['-p', '--no-native', '--jdt-warning-as-error'])
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1114 _clean('CleanAfterEcjBuild')
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1115
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1116 with Task('BuildJavaWithJavac', tasks):
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1117 if t: build(['-p', '--no-native', '--force-javac'])
9172
bc5c5336008b Add gate test to check build-graal.xml is up to date.
Roland Schatz <roland.schatz@oracle.com>
parents: 9169
diff changeset
1118
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18116
diff changeset
1119 with Task('Checkstyle', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1120 if t and mx.checkstyle([]) != 0:
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18116
diff changeset
1121 t.abort('Checkstyle warnings were found')
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18116
diff changeset
1122
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1123 with Task('Checkheaders', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1124 if t and checkheaders([]) != 0:
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1125 t.abort('Checkheaders warnings were found')
14773
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1126
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1127 with Task('FindBugs', tasks) as t:
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1128 if t and findbugs([]) != 0:
17438
b8d89559915d mx: implement with support for Task()
Bernhard Urban <bernhard.urban@jku.at>
parents: 17437
diff changeset
1129 t.abort('FindBugs warnings were found')
14751
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1130
11756
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1131 gate_body(args, tasks)
7155
c356cab093bc added execution of the Graal API unittest with non-GraalVM HotSpot builds to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
1132
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: 4244
diff changeset
1133 except KeyboardInterrupt:
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: 4244
diff changeset
1134 total.abort(1)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1135
4584
7e5d8d1c74a1 Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build.
Doug Simon <doug.simon@oracle.com>
parents: 4582
diff changeset
1136 except BaseException as e:
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: 4244
diff changeset
1137 import traceback
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: 4244
diff changeset
1138 traceback.print_exc()
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
1139 total.abort(str(e))
4159
e253ca26b2d5 Added 'unittest' command to run the Graal unit tests.
Doug Simon <doug.simon@oracle.com>
parents: 4157
diff changeset
1140
4234
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
1141 total.stop()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1142
4438
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1143 mx.log('Gate task times:')
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1144 for t in tasks:
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1145 mx.log(' ' + str(t.duration) + '\t' + t.title)
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1146 mx.log(' =======')
0312460af9fc Made gate do a full clean and added timing report for all gate tasks to end of gate log.
Doug Simon <doug.simon@oracle.com>
parents: 4417
diff changeset
1147 mx.log(' ' + str(total.duration))
11757
ec058ce90a3d pylint fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1148
20000
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1149 if args.task_filter:
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1150 Task.filters = None
e8a0a61526b2 added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
Doug Simon <doug.simon@oracle.com>
parents: 19799
diff changeset
1151
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1152 def _igvJdk():
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1153 v8u20 = mx.VersionSpec("1.8.0_20")
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1154 v8u40 = mx.VersionSpec("1.8.0_40")
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1155 v8 = mx.VersionSpec("1.8")
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1156 def _igvJdkVersionCheck(version):
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1157 return version >= v8 and (version < v8u20 or version >= v8u40)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1158 return mx.java_version(_igvJdkVersionCheck, versionDescription='>= 1.8 and < 1.8.0u20 or >= 1.8.0u40').jdk
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1159
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1160 def _igvBuildEnv():
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1161 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1162 env = dict(os.environ)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1163 proxy = os.environ.get('http_proxy')
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1164 if not (proxy is None) and len(proxy) > 0:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1165 if '://' in proxy:
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1166 # Remove the http:// prefix (or any other protocol prefix)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1167 proxy = proxy.split('://', 1)[1]
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1168 # Separate proxy server name and port number
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1169 proxyName, proxyPort = proxy.split(':', 1)
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1170 proxyEnv = '-DproxyHost="' + proxyName + '" -DproxyPort=' + proxyPort
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1171 env['ANT_OPTS'] = proxyEnv
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1172
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1173 env['JAVA_HOME'] = _igvJdk()
17388
9e5abd0e7916 mx/igv: fallback mechanism to work around a javac bug in jdk8u20
Bernhard Urban <bernhard.urban@jku.at>
parents: 17378
diff changeset
1174 return env
9e5abd0e7916 mx/igv: fallback mechanism to work around a javac bug in jdk8u20
Bernhard Urban <bernhard.urban@jku.at>
parents: 17378
diff changeset
1175
5089
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1176 def igv(args):
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1177 """run the Ideal Graph Visualizer"""
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1178 logFile = '.ideal_graph_visualizer.log'
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1179 with open(join(_graal_home, logFile), 'w') as fp:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10527
diff changeset
1180 mx.logv('[Ideal Graph Visualizer log is in ' + fp.name + ']')
13472
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1181 nbplatform = join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'nbplatform')
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1182
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1183 # Remove NetBeans platform if it is earlier than the current supported version
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1184 if exists(nbplatform):
19427
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1185 updateTrackingFile = join(nbplatform, 'platform', 'update_tracking', 'org-netbeans-core.xml')
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1186 if not exists(updateTrackingFile):
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1187 mx.log('Could not find \'' + updateTrackingFile + '\', removing NetBeans platform')
13472
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1188 shutil.rmtree(nbplatform)
19427
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1189 else:
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1190 dom = xml.dom.minidom.parse(updateTrackingFile)
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1191 currentVersion = mx.VersionSpec(dom.getElementsByTagName('module_version')[0].getAttribute('specification_version'))
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1192 supportedVersion = mx.VersionSpec('3.43.1')
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1193 if currentVersion < supportedVersion:
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1194 mx.log('Replacing NetBeans platform version ' + str(currentVersion) + ' with version ' + str(supportedVersion))
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1195 shutil.rmtree(nbplatform)
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1196 elif supportedVersion < currentVersion:
9f037830060a Make mx igv more robust against bad nbplatform states
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19335
diff changeset
1197 mx.log('Supported NetBeans version in igv command should be updated to ' + str(currentVersion))
13472
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1198
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1199 if not exists(nbplatform):
72e2ec923b7b added support to replace NetBeans platform used by IGV if it is out of date (GRAAL-420)
Doug Simon <doug.simon@oracle.com>
parents: 13471
diff changeset
1200 mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]')
21165
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1201
bdeaa5a7b83c Look for JDKs on demand, add --strict-compliance flag. Allow more precise search for JDK versions (use it for IGV)
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21122
diff changeset
1202 env = _igvBuildEnv()
18983
43baadc1913a Automatically install Batik for SVG export in IGV
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18931
diff changeset
1203 # make the jar for Batik 1.7 available.
43baadc1913a Automatically install Batik for SVG export in IGV
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18931
diff changeset
1204 env['IGV_BATIK_JAR'] = mx.library('BATIK').get_path(True)
18887
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1205 if mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env, nonZeroIsFatal=False):
19d99eec8876 Fix mx igv: do not use Java < 1.8, handle the case where no JDKs are supported. Give some hints when the igv ant build fails.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18876
diff changeset
1206 mx.abort("IGV ant build & launch failed. Check '" + logFile + "'. You can also try to delete 'src/share/tools/IdealGraphVisualizer/nbplatform'.")
14116
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1207
16693
b002c864e974 Truffle: rename install to maven-install-truffle and update location of Truffle JARs.
Chris Seaton <chris.seaton@oracle.com>
parents: 16676
diff changeset
1208 def maven_install_truffle(args):
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
1209 """install Truffle into your local Maven repository"""
21942
dd4050aadaf8 Using _ instead of - as agreed to yesterday
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21941
diff changeset
1210 for name in ['TRUFFLE', 'TRUFFLE_TCK', 'TRUFFLE_DSL_PROCESSOR', 'TRUFFLE_SL']:
16729
3d148f5e90b8 mx: refactor maven_install_truffle such that it uses specified paths from the project file
Bernhard Urban <bernhard.urban@jku.at>
parents: 16699
diff changeset
1211 mx.archive(["@" + name])
3d148f5e90b8 mx: refactor maven_install_truffle such that it uses specified paths from the project file
Bernhard Urban <bernhard.urban@jku.at>
parents: 16699
diff changeset
1212 path = mx._dists[name].path
3d148f5e90b8 mx: refactor maven_install_truffle such that it uses specified paths from the project file
Bernhard Urban <bernhard.urban@jku.at>
parents: 16699
diff changeset
1213 mx.run(['mvn', 'install:install-file', '-DgroupId=com.oracle', '-DartifactId=' + name.lower(), '-Dversion=' + graal_version('SNAPSHOT'), '-Dpackaging=jar', '-Dfile=' + path])
16622
faaea970b951 Add an mx install command to install the Truffle jars to the local Maven repository.
Chris Seaton <chris.seaton@oracle.com>
parents: 16621
diff changeset
1214
14116
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1215 def c1visualizer(args):
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1216 """run the Cl Compiler Visualizer"""
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1217 libpath = join(_graal_home, 'lib')
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1218 if mx.get_os() == 'windows':
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1219 executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer.exe')
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1220 else:
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1221 executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer')
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1222
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1223 # Check whether the current C1Visualizer installation is the up-to-date
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1224 if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)):
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1225 mx.log('Updating C1Visualizer')
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1226 shutil.rmtree(join(libpath, 'c1visualizer'))
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1227
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1228 archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1229
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1230 if not exists(executable):
14116
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1231 zf = zipfile.ZipFile(archive, 'r')
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1232 zf.extractall(libpath)
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1233
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1234 if not exists(executable):
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1235 mx.abort('C1Visualizer binary does not exist: ' + executable)
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1236
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1237 if mx.get_os() != 'windows':
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1238 # Make sure that execution is allowed. The zip file does not always specfiy that correctly
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1239 os.chmod(executable, 0777)
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1240
be7ebdf41bea mx: new command to start c1visualizer; support for IGV download when using a proxy server
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14048
diff changeset
1241 mx.run([executable])
5089
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1242
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1243 def hsdis(args, copyToDir=None):
6291
633136426f26 consolidated jtt command into unittest command and removed need for explicit 'testHarness' property in 'projects' file
Doug Simon <doug.simon@oracle.com>
parents: 6278
diff changeset
1244 """download the hsdis library
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1245
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1246 This is needed to support HotSpot's assembly dumping features.
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1247 By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1248 flavor = 'intel'
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1249 if 'att' in args:
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1250 flavor = 'att'
19684
84b85c43633b [SPARC] Install hsdis-sparcv9.so into the jvm with mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19427
diff changeset
1251 if mx.get_arch() == "sparcv9":
84b85c43633b [SPARC] Install hsdis-sparcv9.so into the jvm with mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19427
diff changeset
1252 flavor = "sparcv9"
17012
ad10671d1bbd mx: move get_arch() to mxtool
Bernhard Urban <bernhard.urban@jku.at>
parents: 16979
diff changeset
1253 lib = mx.add_lib_suffix('hsdis-' + mx.get_arch())
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1254 path = join(_graal_home, 'lib', lib)
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1255
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1256 sha1s = {
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1257 'att/hsdis-amd64.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72',
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1258 'att/hsdis-amd64.so' : '58919ba085d4ef7a513f25bae75e7e54ee73c049',
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1259 'intel/hsdis-amd64.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30',
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1260 'intel/hsdis-amd64.so' : '844ed9ffed64fe9599638f29a8450c50140e3192',
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1261 'intel/hsdis-amd64.dylib' : 'fdb13ef0d7d23d93dacaae9c98837bea0d4fc5a2',
20989
4213d02d95b5 Update hsdis for SPARC to latest binutils version (VIS3 and OSA2011 architecture included)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20967
diff changeset
1262 'sparcv9/hsdis-sparcv9.so': '970640a9af0bd63641f9063c11275b371a59ee60',
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1263 }
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1264
16976
87fc600ec586 mx: skip downloading hsdis if not available.
Josef Eisl <josef.eisl@jku.at>
parents: 16918
diff changeset
1265 flavoredLib = flavor + "/" + lib
87fc600ec586 mx: skip downloading hsdis if not available.
Josef Eisl <josef.eisl@jku.at>
parents: 16918
diff changeset
1266 if flavoredLib not in sha1s:
87fc600ec586 mx: skip downloading hsdis if not available.
Josef Eisl <josef.eisl@jku.at>
parents: 16918
diff changeset
1267 mx.logv("hsdis not supported on this plattform or architecture")
87fc600ec586 mx: skip downloading hsdis if not available.
Josef Eisl <josef.eisl@jku.at>
parents: 16918
diff changeset
1268 return
87fc600ec586 mx: skip downloading hsdis if not available.
Josef Eisl <josef.eisl@jku.at>
parents: 16918
diff changeset
1269
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: 5153
diff changeset
1270 if not exists(path):
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1271 sha1 = sha1s[flavoredLib]
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1272 sha1path = path + '.sha1'
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1273 mx.download_file_with_sha1('hsdis', path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavoredLib], sha1, sha1path, True, True, sources=False)
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1274 if copyToDir is not None and exists(copyToDir):
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1275 shutil.copy(path, copyToDir)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1276
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1277 def hcfdis(args):
6291
633136426f26 consolidated jtt command into unittest command and removed need for explicit 'testHarness' property in 'projects' file
Doug Simon <doug.simon@oracle.com>
parents: 6278
diff changeset
1278 """disassemble HexCodeFiles embedded in text files
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1279
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1280 Run a tool over the input files to convert all embedded HexCodeFiles
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1281 to a disassembled format."""
6958
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1282
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1283 parser = ArgumentParser(prog='mx hcfdis')
6958
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1284 parser.add_argument('-m', '--map', help='address to symbol map applied to disassembler output')
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1285 parser.add_argument('files', nargs=REMAINDER, metavar='files...')
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1286
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1287 args = parser.parse_args(args)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1288
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1289 path = mx.library('HCFDIS').get_path(resolve=True)
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1290 mx.run_java(['-cp', path, 'com.oracle.max.hcfdis.HexCodeFileDis'] + args.files)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1291
6958
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1292 if args.map is not None:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1293 addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)')
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1294 with open(args.map) as fp:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1295 lines = fp.read().splitlines()
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1296 symbols = dict()
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1297 for l in lines:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1298 addressAndSymbol = l.split(' ', 1)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1299 if len(addressAndSymbol) == 2:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1300 address, symbol = addressAndSymbol
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1301 if address.startswith('0x'):
6958
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1302 address = long(address, 16)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1303 symbols[address] = symbol
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1304 for f in args.files:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1305 with open(f) as fp:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1306 lines = fp.read().splitlines()
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1307 updated = False
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1308 for i in range(0, len(lines)):
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1309 l = lines[i]
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1310 for m in addressRE.finditer(l):
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1311 sval = m.group(0)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1312 val = long(sval, 16)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1313 sym = symbols.get(val)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1314 if sym:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1315 l = l.replace(sval, sym)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1316 updated = True
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1317 lines[i] = l
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1318 if updated:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1319 mx.log('updating ' + f)
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1320 with open('new_' + f, "w") as fp:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1321 for l in lines:
abbe4faaf0c1 added support for dumping an address to symbol map (with -G:+PrintAddressMap) to translate addresses in disassembled output (via new '-m' option to the hcfdis command)
Doug Simon <doug.simon@oracle.com>
parents: 6718
diff changeset
1322 print >> fp, l
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1323
11867
952ecf32788a mx sl command.
Chris Seaton <chris.seaton@oracle.com>
parents: 11797
diff changeset
1324 def sl(args):
12693
c6b833f7935e mx sl: change vm args syntax
Andreas Woess <andreas.woess@jku.at>
parents: 12647
diff changeset
1325 """run an SL program"""
c6b833f7935e mx sl: change vm args syntax
Andreas Woess <andreas.woess@jku.at>
parents: 12647
diff changeset
1326 vmArgs, slArgs = _extract_VM_args(args)
21890
894f82515e38 Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21741
diff changeset
1327 vm(vmArgs + ['-cp', mx.classpath(["TRUFFLE", "com.oracle.truffle.sl"]), "com.oracle.truffle.sl.SLLanguage"] + slArgs)
11867
952ecf32788a mx sl command.
Chris Seaton <chris.seaton@oracle.com>
parents: 11797
diff changeset
1328
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21447
diff changeset
1329 def sldebug(args):
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21447
diff changeset
1330 """run a simple command line debugger for the Simple Language"""
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21447
diff changeset
1331 vmArgs, slArgs = _extract_VM_args(args, useDoubleDash=True)
21571
189d7a64b4d9 Truffle/Debugging: fix a python problem with the "sldebug" command
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
1332 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl.tools"), "com.oracle.truffle.sl.tools.debug.SLREPLServer"] + slArgs)
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21447
diff changeset
1333
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1334 def isJVMCIEnabled(vm):
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1335 return vm != 'original' and not vm.endswith('nojvmci')
9803
8e33b4ebfef1 add isGraalEnabled(vm) function in commands.py
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9667
diff changeset
1336
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1337 def jol(args):
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1338 """Java Object Layout"""
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1339 joljar = mx.library('JOL_INTERNALS').get_path(resolve=True)
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1340 candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s))
18218
8588db09f5e9 mx jol: let user select from found classes, skip duplicates
Andreas Woess <andreas.woess@jku.at>
parents: 18163
diff changeset
1341
8588db09f5e9 mx jol: let user select from found classes, skip duplicates
Andreas Woess <andreas.woess@jku.at>
parents: 18163
diff changeset
1342 if len(candidates) > 0:
18601
676f1800077c mx: removed unused _read_projects_file function
Doug Simon <doug.simon@oracle.com>
parents: 18414
diff changeset
1343 candidates = mx.select_items(sorted(candidates))
18218
8588db09f5e9 mx jol: let user select from found classes, skip duplicates
Andreas Woess <andreas.woess@jku.at>
parents: 18163
diff changeset
1344 else:
8588db09f5e9 mx jol: let user select from found classes, skip duplicates
Andreas Woess <andreas.woess@jku.at>
parents: 18163
diff changeset
1345 # mx.findclass can be mistaken, don't give up yet
8588db09f5e9 mx jol: let user select from found classes, skip duplicates
Andreas Woess <andreas.woess@jku.at>
parents: 18163
diff changeset
1346 candidates = args
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1347
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1348 vm(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates)
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1349
5700
12a34d1bcaa2 added site command to generate a javadoc-based website
Doug Simon <doug.simon@oracle.com>
parents: 5688
diff changeset
1350 def site(args):
6291
633136426f26 consolidated jtt command into unittest command and removed need for explicit 'testHarness' property in 'projects' file
Doug Simon <doug.simon@oracle.com>
parents: 6278
diff changeset
1351 """create a website containing javadoc and the project dependency graph"""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1352
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5764
diff changeset
1353 return mx.site(['--name', 'Graal',
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: 5771
diff changeset
1354 '--jd', '@-tag', '--jd', '@test:X',
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: 5771
diff changeset
1355 '--jd', '@-tag', '--jd', '@run:X',
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: 5771
diff changeset
1356 '--jd', '@-tag', '--jd', '@bug:X',
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: 5771
diff changeset
1357 '--jd', '@-tag', '--jd', '@summary:X',
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: 5771
diff changeset
1358 '--jd', '@-tag', '--jd', '@vmoption:X',
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5764
diff changeset
1359 '--overview', join(_graal_home, 'graal', 'overview.html'),
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5764
diff changeset
1360 '--title', 'Graal OpenJDK Project Documentation',
6506
305b9166b455 added projects table to the top level javadoc page generated by the site command
Doug Simon <doug.simon@oracle.com>
parents: 6495
diff changeset
1361 '--dot-output-base', 'projects'] + args)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1362
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1363 def generateZshCompletion(args):
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1364 """generate zsh completion for mx"""
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1365 try:
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1366 from genzshcomp import CompletionGenerator
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1367 except ImportError:
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1368 mx.abort("install genzshcomp (pip install genzshcomp)")
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1369
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1370 # need to fake module for the custom mx arg parser, otherwise a check in genzshcomp fails
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1371 originalModule = mx._argParser.__module__
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1372 mx._argParser.__module__ = "argparse"
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1373 generator = CompletionGenerator("mx", mx._argParser)
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1374 mx._argParser.__module__ = originalModule
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1375
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1376 # strip last line and define local variable "ret"
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1377 complt = "\n".join(generator.get().split('\n')[0:-1]).replace('context state line', 'context state line ret=1')
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1378
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1379 # add array of possible subcommands (as they are not part of the argument parser)
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1380 complt += '\n ": :->command" \\\n'
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1381 complt += ' "*::args:->args" && ret=0\n'
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1382 complt += '\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1383 complt += 'case $state in\n'
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1384 complt += '\t(command)\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1385 complt += '\t\tlocal -a main_commands\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1386 complt += '\t\tmain_commands=(\n'
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1387 for cmd in sorted(mx._commands.iterkeys()):
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1388 c, _ = mx._commands[cmd][:2]
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1389 doc = c.__doc__
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1390 complt += '\t\t\t"{0}'.format(cmd)
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1391 if doc:
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1392 complt += ':{0}'.format(_fixQuotes(doc.split('\n', 1)[0]))
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1393 complt += '"\n'
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1394 complt += '\t\t)\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1395 complt += '\t\t_describe -t main_commands command main_commands && ret=0\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1396 complt += '\t\t;;\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1397
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1398 complt += '\t(args)\n'
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1399 # TODO: improve matcher: if mx args are given, this doesn't work
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1400 complt += '\t\tcase $line[1] in\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1401 complt += '\t\t\t\tnoglob \\\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1402 complt += '\t\t\t\t\t_arguments -s -S \\\n'
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1403 complt += _appendOptions("jvmci", r"G\:")
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1404 # TODO: fix -XX:{-,+}Use* flags
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1405 complt += _appendOptions("hotspot", r"XX\:")
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1406 complt += '\t\t\t\t\t"-version" && ret=0 \n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1407 complt += '\t\t\t\t;;\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1408 complt += '\t\tesac\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1409 complt += '\t\t;;\n'
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1410 complt += 'esac\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1411 complt += '\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1412 complt += 'return $ret'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1413 print complt
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1414
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1415 def _fixQuotes(arg):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1416 return arg.replace('\"', '').replace('\'', '').replace('`', '').replace('{', '\\{').replace('}', '\\}').replace('[', '\\[').replace(']', '\\]')
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1417
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1418 def _appendOptions(optionType, optionPrefix):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1419 def isBoolean(vmap, field):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1420 return vmap[field] == "Boolean" or vmap[field] == "bool"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1421
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1422 def hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1423 return vmap['optDefault'] or vmap['optDoc']
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1424
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1425 complt = ""
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1426 for vmap in _parseVMOptions(optionType):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1427 complt += '\t\t\t\t\t-"'
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1428 complt += optionPrefix
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1429 if isBoolean(vmap, 'optType'):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1430 complt += '"{-,+}"'
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1431 complt += vmap['optName']
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1432 if not isBoolean(vmap, 'optType'):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1433 complt += '='
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1434 if hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1435 complt += "["
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1436 if vmap['optDefault']:
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1437 complt += r"(default\: " + vmap['optDefault'] + ")"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1438 if vmap['optDoc']:
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1439 complt += _fixQuotes(vmap['optDoc'])
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1440 if hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1441 complt += "]"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1442 complt += '" \\\n'
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1443 return complt
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1444
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1445 def _parseVMOptions(optionType):
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1446 parser = OutputParser()
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1447 # TODO: the optDoc part can wrapped accross multiple lines, currently only the first line will be captured
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1448 # TODO: fix matching for float literals
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1449 jvmOptions = re.compile(
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1450 r"^[ \t]*"
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1451 r"(?P<optType>(Boolean|Integer|Float|Double|String|bool|intx|uintx|ccstr|double)) "
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1452 r"(?P<optName>[a-zA-Z0-9]+)"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1453 r"[ \t]+=[ \t]*"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1454 r"(?P<optDefault>([\-0-9]+(\.[0-9]+(\.[0-9]+\.[0-9]+))?|false|true|null|Name|sun\.boot\.class\.path))?"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1455 r"[ \t]*"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1456 r"(?P<optDoc>.+)?",
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1457 re.MULTILINE)
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1458 parser.addMatcher(ValuesMatcher(jvmOptions, {
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1459 'optType' : '<optType>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1460 'optName' : '<optName>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1461 'optDefault' : '<optDefault>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1462 'optDoc' : '<optDoc>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1463 }))
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1464
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1465 # gather JVMCI options
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1466 output = StringIO.StringIO()
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1467 vm(['-XX:-BootstrapJVMCI', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "jvmci" else '-XX:+PrintFlagsWithComments'],
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1468 vm="jvmci",
13695
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
1469 vmbuild="optimized",
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
1470 nonZeroIsFatal=False,
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
1471 out=output.write,
b688e7da4c69 refined class path used by unittest to only include dependencies of the tests that will be run
Doug Simon <doug.simon@oracle.com>
parents: 13526
diff changeset
1472 err=subprocess.STDOUT)
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1473
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1474 valueMap = parser.parse(output.getvalue())
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1475 return valueMap
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1476
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1477 def findbugs(args):
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1478 '''run FindBugs against non-test Java projects'''
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1479 findBugsHome = mx.get_env('FINDBUGS_HOME', None)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1480 if findBugsHome:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1481 findbugsJar = join(findBugsHome, 'lib', 'findbugs.jar')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1482 else:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1483 findbugsLib = join(_graal_home, 'lib', 'findbugs-3.0.0')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1484 if not exists(findbugsLib):
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1485 tmp = tempfile.mkdtemp(prefix='findbugs-download-tmp', dir=_graal_home)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1486 try:
16599
89be7c4db12c made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal
Doug Simon <doug.simon@oracle.com>
parents: 16499
diff changeset
1487 findbugsDist = mx.library('FINDBUGS_DIST').get_path(resolve=True)
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1488 with zipfile.ZipFile(findbugsDist) as zf:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1489 candidates = [e for e in zf.namelist() if e.endswith('/lib/findbugs.jar')]
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1490 assert len(candidates) == 1, candidates
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1491 libDirInZip = os.path.dirname(candidates[0])
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1492 zf.extractall(tmp)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1493 shutil.copytree(join(tmp, libDirInZip), findbugsLib)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1494 finally:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1495 shutil.rmtree(tmp)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1496 findbugsJar = join(findbugsLib, 'findbugs.jar')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1497 assert exists(findbugsJar)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1498 nonTestProjects = [p for p in mx.projects() if not p.name.endswith('.test') and not p.name.endswith('.jtt')]
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17224
diff changeset
1499 outputDirs = map(mx._cygpathU2W, [p.output_dir() for p in nonTestProjects])
18613
8c3a85077f84 mx: run findbugs with the appropriate jdk
Doug Simon <doug.simon@oracle.com>
parents: 18606
diff changeset
1500 javaCompliance = max([p.javaCompliance for p in nonTestProjects])
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1501 findbugsResults = join(_graal_home, 'findbugs.results')
14769
141d570b397c fixed pylint errors
Doug Simon <doug.simon@oracle.com>
parents: 14767
diff changeset
1502
17262
b641450c19ce mx: rename helper functions for cygwin support and update comments
Bernhard Urban <bernhard.urban@jku.at>
parents: 17224
diff changeset
1503 cmd = ['-jar', mx._cygpathU2W(findbugsJar), '-textui', '-low', '-maxRank', '15']
21166
f383ff4c9af8 mx: fix JDK selection when running outside a tty, capture STRICT_COMPLIANCE from the env file, make sure raw_input promt goes to stdout
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21165
diff changeset
1504 if mx.is_interactive():
14767
ded08e344e4a findbugs will also use any findbugsExcludeFilter.xml it finds in a suite's root
Doug Simon <doug.simon@oracle.com>
parents: 14762
diff changeset
1505 cmd.append('-progress')
18116
c4f649042a7b mx/unittest: fix cygwin path issue
Bernhard Urban <bernhard.urban@jku.at>
parents: 18115
diff changeset
1506 cmd = cmd + ['-auxclasspath', mx._separatedCygpathU2W(mx.classpath([d.name for d in _jdkDeployedDists] + [p.name for p in nonTestProjects])), '-output', mx._cygpathU2W(findbugsResults), '-exitcode'] + args + outputDirs
18613
8c3a85077f84 mx: run findbugs with the appropriate jdk
Doug Simon <doug.simon@oracle.com>
parents: 18606
diff changeset
1507 exitcode = mx.run_java(cmd, nonZeroIsFatal=False, javaConfig=mx.java(javaCompliance))
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1508 if exitcode != 0:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1509 with open(findbugsResults) as fp:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1510 mx.log(fp.read())
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1511 os.unlink(findbugsResults)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1512 return exitcode
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1513
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1514 def checkheaders(args):
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1515 """check Java source headers against any required pattern"""
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1516 failures = {}
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1517 for p in mx.projects():
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1518 if p.native:
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1519 continue
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1520
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18116
diff changeset
1521 csConfig = join(mx.project(p.checkstyleProj).dir, '.checkstyle_checks.xml')
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1522 dom = xml.dom.minidom.parse(csConfig)
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1523 for module in dom.getElementsByTagName('module'):
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1524 if module.getAttribute('name') == 'RegexpHeader':
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1525 for prop in module.getElementsByTagName('property'):
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1526 if prop.getAttribute('name') == 'header':
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1527 value = prop.getAttribute('value')
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1528 matcher = re.compile(value, re.MULTILINE)
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1529 for sourceDir in p.source_dirs():
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1530 for root, _, files in os.walk(sourceDir):
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1531 for name in files:
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1532 if name.endswith('.java') and name != 'package-info.java':
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1533 f = join(root, name)
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1534 with open(f) as fp:
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1535 content = fp.read()
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1536 if not matcher.match(content):
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1537 failures[f] = csConfig
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1538 for n, v in failures.iteritems():
18637
d5d1fbe270e9 mx: fixed format string
Doug Simon <doug.simon@oracle.com>
parents: 18635
diff changeset
1539 mx.log('{0}: header does not match RegexpHeader defined in {1}'.format(n, v))
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1540 return len(failures)
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1541
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
1542 def mx_init(suite):
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1543 commands = {
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
1544 'checkheaders': [checkheaders, ''],
4156
843c8d6720da Added 'export' command for creating a GraalVM zip file distribution without the Mercurial data or VM sources.
Doug Simon <doug.simon@oracle.com>
parents: 4155
diff changeset
1545 'clean': [clean, ''],
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1546 'findbugs': [findbugs, ''],
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1547 'generateZshCompletion' : [generateZshCompletion, ''],
16693
b002c864e974 Truffle: rename install to maven-install-truffle and update location of Truffle JARs.
Chris Seaton <chris.seaton@oracle.com>
parents: 16676
diff changeset
1548 'maven-install-truffle' : [maven_install_truffle, ''],
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
1549 'jdkhome': [print_jdkhome, ''],
4601
ade18666f2be Added --omit-native-build to gate command so that native cleaning and building can be omitted for changesets that made no changes to the C/C++ code.
Doug Simon <doug.simon@oracle.com>
parents: 4584
diff changeset
1550 'gate' : [gate, '[-options]'],
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1551 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1552 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
5700
12a34d1bcaa2 added site command to generate a javadoc-based website
Doug Simon <doug.simon@oracle.com>
parents: 5688
diff changeset
1553 'site' : [site, '[-options]'],
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1554 'sl' : [sl, '[SL args|@VM options]'],
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21447
diff changeset
1555 'sldebug' : [sldebug, '[SL args|@VM options]'],
16167
1f4955abca9b mx: add jol command for java object layout introspection
Andreas Woess <andreas.woess@jku.at>
parents: 16117
diff changeset
1556 'jol' : [jol, ''],
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1557 }
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1558
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
1559 mx.update_commands(suite, commands)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
1560
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1561 def mx_post_parse_cmd_line(opts): #
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7788
diff changeset
1562 # TODO _minVersion check could probably be part of a Suite in mx?
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1563 if mx.java().version < _minVersion:
20102
6e5df2d60fbd mx: fix compliance check for EXTRA_JAVA_HOMES, add maximum JAVA_HOME version in mx_graal
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20032
diff changeset
1564 mx.abort('Requires Java version ' + str(_minVersion) + ' or greater for JAVA_HOME, got version ' + str(mx.java().version))
20805
379471b334cb Lift 8u40 mx restriction
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20102
diff changeset
1565 if _untilVersion and mx.java().version >= _untilVersion:
20102
6e5df2d60fbd mx: fix compliance check for EXTRA_JAVA_HOMES, add maximum JAVA_HOME version in mx_graal
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20032
diff changeset
1566 mx.abort('Requires Java version strictly before ' + str(_untilVersion) + ' for JAVA_HOME, got version ' + str(mx.java().version))
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1567
16902
0583d157992a formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
Doug Simon <doug.simon@oracle.com>
parents: 16877
diff changeset
1568 for jdkDist in _jdkDeployedDists:
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
1569 def _close(jdkDeployable):
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
1570 def _install(dist):
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
1571 assert dist.name == jdkDeployable.name, dist.name + "!=" + jdkDeployable.name
21741
b6ee5d3f3255 Exclude distributions from exporting which are delivered with HotSpot (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
1572 if not jdkDist.partOfHotSpot:
b6ee5d3f3255 Exclude distributions from exporting which are delivered with HotSpot (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
1573 _installDistInJdks(jdkDeployable)
21031
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
1574 return _install
e1c063565b3c Graal Services: use services files in jre/lib/graal/services
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20996
diff changeset
1575 mx.distribution(jdkDist.name).add_update_listener(_close(jdkDist))