annotate mx/mx_graal.py @ 15913:67e0015b21d6

Use new jacocoreport version
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 26 May 2014 18:18:19 +0200
parents 7d1690e145ae
children 7c84f0ce7cae
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 #
4187
ac5c2bdfcca2 Disabled copyright check in the gate until the CheckCopyright tools supports the HotSpot copyright notice format.
Doug Simon <doug.simon@oracle.com>
parents: 4185
diff changeset
6 # Copyright (c) 2007, 2012, 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
15580
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
30 from os.path import join, exists, dirname, basename, getmtime
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
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
35 import sanitycheck
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
36 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
37 import json, textwrap
15329
3b56c9bbf60c mx: fix imports
Bernhard Urban <bernhard.urban@jku.at>
parents: 15328
diff changeset
38 import fnmatch
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39
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
40 # 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
41 _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
42
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
43 """ Used to distinguish an exported GraalVM (see 'mx export'). """
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
44 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src'))
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
45
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
46 """ The VMs that can be built and run along with an optional description. Only VMs with a
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
47 description are listed in the dialogue for setting the default VM (see _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
48 _vmChoices = {
15862
283c8d31c560 mx: update vm choice helptext
Bernhard Urban <bernhard.urban@jku.at>
parents: 15844
diff changeset
49 'graal' : 'Normal compilation is performed with a tiered system (C1 + Graal), Truffle compilation is performed with Graal.',
283c8d31c560 mx: update vm choice helptext
Bernhard Urban <bernhard.urban@jku.at>
parents: 15844
diff changeset
50 'server' : 'Normal compilation is performed with a tiered system (C1 + C2), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.',
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
51 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
52 'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
53 'client-nograal' : None, # all compilation with client compiler, Graal omitted
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
54 'original' : None, # default VM copied from bootstrap JDK
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
55 }
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
56
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
57 """ 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
58 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
59 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
60 _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
61
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
62 """ The VM builds that will be run by the 'vm' command - default is first in list """
9157
a38d748d4130 Add support for the 'optimized' build in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9130
diff changeset
63 _vmbuildChoices = ['product', 'fastdebug', 'debug', 'optimized']
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
64
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
65 """ The VM build that will be run by the 'vm' command.
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
66 This can be set via the global '--vmbuild' option.
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
67 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
68 _vmbuild = _vmbuildChoices[0]
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69
5024
7ccdae96e98a Allow JaCoCon to append to the execution file
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5016
diff changeset
70 _jacoco = 'off'
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
71
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
72 """ The current working directory to switch to before running the VM. """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
73 _vm_cwd = None
10454
590b0c26877f mx: add --workdir argument
Bernhard Urban <bernhard.urban@jku.at>
parents: 10417
diff changeset
74
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
75 """ The base directory in which the JDKs cloned from $JAVA_HOME exist. """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
76 _installed_jdks = None
10570
2f80624df8a2 Add a --vmdir argument to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10568
diff changeset
77
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
78 """ Prefix for running the VM. """
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
79 _vm_prefix = None
5875
000fb0550afe Add an option to launch the vm from a debugger in mx's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5871
diff changeset
80
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
81 _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
82
15594
62738ce98804 mx: set _minVersion to 1.8
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15593
diff changeset
83 _minVersion = mx.VersionSpec('1.8')
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7788
diff changeset
84
13919
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
85 JDK_UNIX_PERMISSIONS = 0755
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
86
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
87 def isVMSupported(vm):
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
88 if 'client' in vm and len(platform.mac_ver()[0]) != 0:
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
89 # 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
90 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
91 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
92
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
93 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
94 """
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
95 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
96 """
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
97 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
98 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
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 vm = mx.get_env('DEFAULT_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
101 if vm is None:
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
102 if not sys.stdout.isatty():
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
103 mx.abort('Need to specify VM with --vm option or 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
104 envPath = join(_graal_home, 'mx', 'env')
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
105 mx.log('Please select the VM to be executed from the following: ')
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
106 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None]
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
107 descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None]
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
108 vm = mx.select_items(items, descriptions, allowMultiple=False)
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11493
diff changeset
109 if mx.ask_yes_no('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath, 'y'):
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
110 with open(envPath, 'a') as fp:
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
111 print >> fp, 'DEFAULT_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
112 _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
113 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
114
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
115 """
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
116 A context manager that can be used with the 'with' statement to set the 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
117 used by all VM executions within the scope of the 'with' statement. For example:
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
118
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
119 with VM('server'):
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
120 dacapo(['pmd'])
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
121 """
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
122 class 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
123 def __init__(self, vm=None, build=None):
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
124 assert vm is None or vm in _vmChoices.keys()
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
125 assert build is None or build in _vmbuildChoices
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
126 self.vm = vm if vm else _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
127 self.build = build if build else _vmbuild
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
128 self.previousVm = _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
129 self.previousBuild = _vmbuild
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
130
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
131 def __enter__(self):
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
132 global _vm, _vmbuild
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
133 _vm = self.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
134 _vmbuild = self.build
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
135
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
136 def __exit__(self, exc_type, exc_value, traceback):
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
137 global _vm, _vmbuild
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
138 _vm = self.previousVm
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
139 _vmbuild = self.previousBuild
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
140
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
141 def _chmodDir(chmodFlags, dirname, fnames):
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
142 os.chmod(dirname, chmodFlags)
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7345
diff changeset
143 for name in fnames:
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7345
diff changeset
144 os.chmod(os.path.join(dirname, name), chmodFlags)
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
145
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
146 def chmodRecursive(dirname, chmodFlags):
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
147 os.path.walk(dirname, _chmodDir, chmodFlags)
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
148
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
149 def clean(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
150 """clean the GraalVM 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
151 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
152
4226
e03ff10d4bfc Made the gate clean the Java projects only.
Doug Simon <doug.simon@oracle.com>
parents: 4225
diff changeset
153 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
154 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
155 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
156 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
157 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
158 func(path)
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
159 else:
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
160 raise
ce201bb843b4 mx clean: try to change permission if deletion fails on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15577
diff changeset
161
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
162 def rmIfExists(name):
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
163 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
164 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
165 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
166 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
167
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
168 rmIfExists(join(_graal_home, 'build'))
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
169 rmIfExists(join(_graal_home, 'build-nograal'))
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
170 rmIfExists(_jdksDir())
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
171 rmIfExists(mx.distribution('GRAAL').path)
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172
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
173 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
174 """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
175
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
176 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
177 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
178
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
179 # collect data about export
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
180 infos = dict()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
181 infos['timestamp'] = time.time()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
182
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
183 hgcfg = mx.HgConfig()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
184 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
185 infos['revision'] = hgcfg.tip('.') + ('+' if hgcfg.isDirty('.') else '')
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
186 # TODO: infos['repository']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
187
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
188 infos['jdkversion'] = str(mx.java().version)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
189
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
190 infos['architecture'] = _arch()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
191 infos['platform'] = mx.get_os()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
192
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
193 if mx.get_os != 'windows':
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
194 pass
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
195 # infos['ccompiler']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
196 # infos['linker']
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
197
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
198 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
199
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
200 def _writeJson(suffix, properties):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
201 d = infos.copy()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
202 for k, v in properties.iteritems():
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
203 assert not d.has_key(k)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
204 d[k] = v
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
205
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
206 jsonFileName = 'export-' + suffix + '.json'
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
207 with open(jsonFileName, 'w') as f:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
208 print >> f, json.dumps(d)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
209 return jsonFileName
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
210
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
211
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
212 def _genFileName(archivtype, middle):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
213 idPrefix = infos['revision'] + '_'
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
214 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
215 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
216
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
217 def _genFileArchPlatformName(archivtype, middle):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
218 return _genFileName(archivtype, infos['platform'] + '_' + infos['architecture'] + '_' + middle)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
219
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
220
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
221 # archive different build types of hotspot
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
222 for vmBuild in _vmbuildChoices:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
223 jdkpath = join(_jdksDir(), vmBuild)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
224 if not exists(jdkpath):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
225 mx.logv("skipping " + vmBuild)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
226 continue
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
227
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
228 tarName = _genFileArchPlatformName('basejdk', vmBuild)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
229 mx.logv("creating basejdk " + tarName)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
230 vmSet = set()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
231 with tarfile.open(tarName, 'w:gz') as tar:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
232 for root, _, files in os.walk(jdkpath):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
233 if basename(root) in _vmChoices.keys():
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
234 # TODO: add some assert to check path assumption
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
235 vmSet.add(root)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
236 continue
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
237
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
238 for f in files:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
239 name = join(root, f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
240 # print name
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
241 tar.add(name, name)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
242
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
243 n = _writeJson("basejdk-" + vmBuild, {'vmbuild' : vmBuild})
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
244 tar.add(n, n)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
245
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
246 # create a separate archive for each VM
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
247 for vm in vmSet:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
248 bVm = basename(vm)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
249 vmTarName = _genFileArchPlatformName('vm', vmBuild + '_' + bVm)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
250 mx.logv("creating vm " + vmTarName)
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
251
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
252 debugFiles = set()
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
253 with tarfile.open(vmTarName, 'w:gz') as tar:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
254 for root, _, files in os.walk(vm):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
255 for f in files:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
256 # TODO: mac, windows, solaris?
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
257 if any(map(f.endswith, [".debuginfo"])):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
258 debugFiles.add(f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
259 else:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
260 name = join(root, f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
261 # print name
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
262 tar.add(name, name)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
263
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
264 n = _writeJson("vm-" + vmBuild + "-" + bVm, {'vmbuild' : vmBuild, 'vm' : bVm})
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
265 tar.add(n, n)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
266
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
267 if len(debugFiles) > 0:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
268 debugTarName = _genFileArchPlatformName('debugfilesvm', vmBuild + '_' + bVm)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
269 mx.logv("creating debugfilesvm " + debugTarName)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
270 with tarfile.open(debugTarName, 'w:gz') as tar:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
271 for f in debugFiles:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
272 name = join(root, f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
273 # print name
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
274 tar.add(name, name)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
275
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
276 n = _writeJson("debugfilesvm-" + vmBuild + "-" + bVm, {'vmbuild' : vmBuild, 'vm' : bVm})
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
277 tar.add(n, n)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
278
15402
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
279 # graal directory
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
280 graalDirTarName = _genFileName('classfiles', 'javac')
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
281 mx.logv("creating graal " + graalDirTarName)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
282 with tarfile.open(graalDirTarName, 'w:gz') as tar:
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
283 for root, _, files in os.walk("graal"):
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
284 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
285 name = join(root, f)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
286 # print name
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
287 tar.add(name, name)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
288
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
289 n = _writeJson("graal", {'javacompiler' : 'javac'})
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
290 tar.add(n, n)
5dcf0ae606f3 mx: new export command
Bernhard Urban <bernhard.urban@jku.at>
parents: 15401
diff changeset
291
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
292
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
293 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
294
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
295 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
296
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
297 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
298 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
299 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
300
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
301 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
302 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
303 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
304 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
305
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
306 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
307 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
308 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
309 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
310 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
311 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
312
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
313 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
314 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
315 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
316 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
317
4157
b26279781d95 Simplified 'dacapo' command and made it more suitable for gate usage.
Doug Simon <doug.simon@oracle.com>
parents: 4156
diff changeset
318 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
319 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
320
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
321 def dacapo(args):
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
322 """run one or more DaCapo 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
323
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
324 def launcher(bm, harnessArgs, extraVmOpts):
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
325 return sanitycheck.getDacapo(bm, harnessArgs).test(_get_vm(), extraVmOpts=extraVmOpts)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
326
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
327 _run_benchmark(args, sanitycheck.dacapoSanityWarmup.keys(), launcher)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
328
4480
7d6490436b57 Add Scala DaCapo benchs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4438
diff changeset
329 def scaladacapo(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
330 """run one or more Scala DaCapo benchmarks"""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
331
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
332 def launcher(bm, harnessArgs, extraVmOpts):
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
333 return sanitycheck.getScalaDacapo(bm, harnessArgs).test(_get_vm(), extraVmOpts=extraVmOpts)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
334
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
335 _run_benchmark(args, sanitycheck.dacapoScalaSanityWarmup.keys(), launcher)
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
336
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6340
diff changeset
337 def _arch():
6512
edea9ba7ac7b Windows-specific fix for mx.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6506
diff changeset
338 machine = platform.uname()[4]
6558
0a6d8857306d arch is i86pc on solaris x64 boxes.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6512
diff changeset
339 if machine in ['amd64', 'AMD64', 'x86_64', 'i86pc']:
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6340
diff changeset
340 return 'amd64'
11784
a2958b7bf83f add "sun4u" as a valid identifier for the SPARC architecture
Doug Simon <doug.simon@oracle.com>
parents: 11777
diff changeset
341 if machine in ['sun4v', 'sun4u']:
12540
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
342 return 'sparcv9'
6566
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
343 if machine == 'i386' and mx.get_os() == 'darwin':
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
344 try:
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
345 # Support for Snow Leopard and earlier version of MacOSX
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
346 if subprocess.check_output(['sysctl', '-n', 'hw.cpu64bit_capable']).strip() == '1':
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
347 return 'amd64'
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
348 except OSError:
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
349 # sysctl is not available
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
350 pass
ef48be91f5fd fixed detection of architecture on Snow Leopard and earlier versions of MacOSX
Doug Simon <doug.simon@oracle.com>
parents: 6558
diff changeset
351 mx.abort('unknown or unsupported architecture: os=' + mx.get_os() + ', machine=' + machine)
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6340
diff changeset
352
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
353 def _vmLibDirInJdk(jdk):
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
354 """
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
355 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
356 subdirectories are located.
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
357 """
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
358 if platform.system() == 'Darwin':
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
359 return join(jdk, 'jre', 'lib')
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
360 if platform.system() == 'Windows':
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
361 return join(jdk, 'jre', 'bin')
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6340
diff changeset
362 return join(jdk, 'jre', 'lib', _arch())
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
363
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
364 def _vmCfgInJdk(jdk):
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
365 """
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
366 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
367 """
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
368 if platform.system() == 'Windows':
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6340
diff changeset
369 return join(jdk, 'jre', 'lib', _arch(), '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
370 return join(_vmLibDirInJdk(jdk), 'jvm.cfg')
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
371
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
372 def _jdksDir():
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
373 return os.path.abspath(join(_installed_jdks if _installed_jdks else _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
374
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
375 def _handle_missing_VM(bld, 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
376 mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
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
377 if sys.stdout.isatty():
11511
3110bea9a6b0 mx: add helper method for yes/no question
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11493
diff changeset
378 if mx.ask_yes_no('Build it now', 'y'):
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
379 with VM(vm, bld):
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
380 build([])
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
381 return
11493
94779c895aad fixed documentation of --installed-jdks mx option
Doug Simon <doug.simon@oracle.com>
parents: 11424
diff changeset
382 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build 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
383
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
384 def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=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
385 """
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
386 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
387 """
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
388 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
389 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
390 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
391 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
392 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
393 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
394
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
395 # 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
396 # 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
397 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
398 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
399 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
400
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
401 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
402 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
403 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
404 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
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 else:
0aa37fd2f33e mx: fix detection for sparc. ignore unparsable lines in jvm.cfg
Bernhard Urban <bernhard.urban@jku.at>
parents: 12497
diff changeset
413 # 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
414 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
415 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
416 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
417
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
418 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg
6687
a9a50f21e000 Added change to copied directory's protection when source JDK directories are read-only.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6566
diff changeset
419 if mx.get_os() != 'windows':
13919
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
420 chmodRecursive(jdk, JDK_UNIX_PERMISSIONS)
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
421 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
422
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
423
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
424 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
425 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
426 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
427
13523
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
428 # 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
429 releaseFile = join(jdk, 'release')
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
430 if exists(releaseFile):
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
431 releaseFileLines = []
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
432 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
433 for line in f:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
434 releaseFileLines.append(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
435
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
436 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
437 for line in releaseFileLines:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
438 if line.startswith("SOURCE="):
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
439 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
440 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
441 hgcfg = mx.HgConfig()
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
442 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
443 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
444 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
445 except:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
446 fp.write(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
447 else:
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
448 fp.write(line)
137142009b0b mx: append graal revision to release file of jdk
Bernhard Urban <bernhard.urban@jku.at>
parents: 13522
diff changeset
449
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
450 # 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
451 try:
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
452 hsdis([], copyToDir=_vmLibDirInJdk(jdk))
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
453 except SystemExit:
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
454 pass
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
455 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
456 if not exists(jdk):
11797
65dbed1fdf46 be verbose when the JDK specified by --installed-jdks is missing
Doug Simon <doug.simon@oracle.com>
parents: 11784
diff changeset
457 if _installed_jdks:
65dbed1fdf46 be verbose when the JDK specified by --installed-jdks is missing
Doug Simon <doug.simon@oracle.com>
parents: 11784
diff changeset
458 mx.log("The selected JDK directory does not (yet) exist: " + jdk)
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
459 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
460
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
461 if installGraalJar:
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
462 _installGraalJarInJdks(mx.distribution('GRAAL'))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
463
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
464 if vmToCheck is not None:
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
465 jvmCfg = _vmCfgInJdk(jdk)
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
466 found = False
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
467 with open(jvmCfg) as f:
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
468 for line in f:
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
469 if line.strip() == '-' + vmToCheck + ' KNOWN':
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
470 found = True
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
471 break
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
472 if not found:
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
473 _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
474
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
475 return jdk
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
476
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
477 def _updateInstalledGraalOptionsFile(jdk):
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
478 graalOptions = join(_graal_home, 'graal.options')
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
479 jreLibDir = join(jdk, 'jre', 'lib')
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
480 if exists(graalOptions):
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
481 shutil.copy(graalOptions, join(jreLibDir, 'graal.options'))
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
482 else:
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
483 toDelete = join(jreLibDir, 'graal.options')
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
484 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
485 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
486
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
487 def _update_HotSpotOptions_inline_hpp(graalJar):
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
488 p = mx.project('com.oracle.graal.hotspot')
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
489 mainClass = 'com.oracle.graal.hotspot.HotSpotOptionsLoader'
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
490 assert exists(join(p.source_dirs()[0], mainClass.replace('.', os.sep) + '.java'))
15896
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
491
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
492 def mainClassExists():
15873
6dcf8ab4ad86 HotSpotOptions.inline.hpp generator writes to System.out to make generator errors more visible (they will show up when compiling the generated source)
Doug Simon <doug.simon@oracle.com>
parents: 15870
diff changeset
493 with zipfile.ZipFile(graalJar, 'r') as zf:
6dcf8ab4ad86 HotSpotOptions.inline.hpp generator writes to System.out to make generator errors more visible (they will show up when compiling the generated source)
Doug Simon <doug.simon@oracle.com>
parents: 15870
diff changeset
494 mainClassFile = mainClass.replace('.', '/') + '.class'
15896
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
495 return mainClassFile in zf.namelist()
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
496
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
497 if mainClassExists():
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
498 hsSrcGenDir = join(p.source_gen_dir(), 'hotspot')
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
499 if not exists(hsSrcGenDir):
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
500 os.makedirs(hsSrcGenDir)
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
501 tmp = StringIO.StringIO()
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
502 mx.run_java(['-cp', graalJar, mainClass], out=tmp.write)
db776f9bea7c mx: prevent spurious "Could not find or load main class com.oracle.graal.hotspot.HotSpotOptionsLoader" error message
Doug Simon <doug.simon@oracle.com>
parents: 15873
diff changeset
503 mx.update_file(join(hsSrcGenDir, 'HotSpotOptions.inline.hpp'), tmp.getvalue())
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
504
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
505 def _installGraalJarInJdks(graalDist):
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
506 graalJar = graalDist.path
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
507 _update_HotSpotOptions_inline_hpp(graalJar)
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
508 jdks = _jdksDir()
14930
5c7718ae8c86 install graal.jar into local Maven repo if MAVEN_INSTALL_GRAAL_JAR environment variable is "true"
Doug Simon <doug.simon@oracle.com>
parents: 14918
diff changeset
509
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):
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
512 jreLibDir = join(jdks, e, 'jre', 'lib')
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
513 if exists(jreLibDir):
14938
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
514 def install(srcJar, dstDir):
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
515 # do a copy and then a move to get atomic updating (on Unix)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
516 name = os.path.basename(srcJar)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
517 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
518 shutil.copyfile(srcJar, tmp)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
519 os.close(fd)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
520 dstJar = join(dstDir, name)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
521 shutil.move(tmp, dstJar)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
522 os.chmod(dstJar, JDK_UNIX_PERMISSIONS)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
523
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
524 install(graalJar, jreLibDir)
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
525 if graalDist.sourcesPath:
9d32e87ea98b GRAAL distribution now includes sources (graal.src.zip)
Doug Simon <doug.simon@oracle.com>
parents: 14930
diff changeset
526 install(graalDist.sourcesPath, join(jdks, e))
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
527
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
528 # 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
529 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
530 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
531 respondTo = {}
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
532 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
533 startToken = 'RUNINDEBUGSHELL_STARTSEQUENCE'
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
534 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
535
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
536 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
537
6306
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
538 if not exists(winSDK):
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
539 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
540
6306
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
541 if not exists(join(winSDK, 'Bin', 'SetEnv.cmd')):
2a819543cc45 Warnings for windows build if there is no SDK
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6294
diff changeset
542 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
543
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
544 p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + startToken + '"', \
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
545 shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
546 stdout = p.stdout
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
547 stdin = p.stdin
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
548 if logFile:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
549 log = open(logFile, 'w')
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
550 ret = False
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
551 while True:
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
552
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
553 # 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
554 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
555 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
556 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
557 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
558
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
559 line = stdout.readline().decode(encoding)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
560 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
561 log.write(line.encode('utf-8'))
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
562 line = line.strip()
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
563 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
564 if line == startToken:
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
565 stdin.write('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + endToken + newLine)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
566 for regex in respondTo.keys():
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
567 match = regex.search(line)
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
568 if match:
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
569 stdin.write(respondTo[regex] + newLine)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
570 if findInOutput:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
571 match = findInOutput.search(line)
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
572 if match:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
573 ret = True
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
574 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
575 if not findInOutput:
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
576 stdin.write('echo ERRXXX%errorlevel%' + newLine)
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
577 else:
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
578 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
579 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
580 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
581 ret = True
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
582 break
4269
ffd5ce8fc736 Moved IDE project configuration into mx.py.
Doug Simon <doug.simon@oracle.com>
parents: 4257
diff changeset
583 stdin.write('exit' + newLine)
4177
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
584 if logFile:
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
585 log.close()
c843578c269d Make building work on Windows.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4163
diff changeset
586 return ret
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
587
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
588 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
589 """return 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
590 build = _vmbuild if _vmSourcesAvailable else 'product'
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
591 return _jdk(build, installGraalJar=False)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
592
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
593 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
594 """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
595 print jdkhome(vm)
5103
276e14614531 Added jdkhome command to mx.
Doug Simon <doug.simon@oracle.com>
parents: 5094
diff changeset
596
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
597 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
598 """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
599
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
600 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
601 '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
602 'ALT_OUTPUTDIR' : 'Build directory',
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
603 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(multiprocessing.cpu_count()) + ')',
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
604 '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
605 '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
606 }
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
607
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
608 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
609 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
610 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
611 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
612 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
613
9120
9f361c0f912b added note about mx/env to the output of 'mx buildvars'
Doug Simon <doug.simon@oracle.com>
parents: 9119
diff changeset
614 mx.log('')
9f361c0f912b added note about mx/env to the output of 'mx buildvars'
Doug Simon <doug.simon@oracle.com>
parents: 9119
diff changeset
615 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
616
4577
bc8b58c11768 Added debug build of HotSpot Client to the gate.
Doug Simon <doug.simon@oracle.com>
parents: 4575
diff changeset
617 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
618 """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
619
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
620 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
621
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
622 # 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
623 # 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
624 # 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
625 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
626 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
627 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
628 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
629 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
630 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
631 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
632 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
633 ' 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
634 return result
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
635
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
636 # 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
637 parser = AP()
10083
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
638 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>')
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
639 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
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
640 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
641 assert len(opts2.remainder) == 0
4145
9aee7df31417 Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents: 4144
diff changeset
642
10083
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
643 if opts2.export_dir is not None:
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
644 if not exists(opts2.export_dir):
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
645 os.makedirs(opts2.export_dir)
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
646 else:
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
647 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir)
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
648
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
649 shutil.copy(mx.distribution('GRAAL').path, opts2.export_dir)
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
650 graalOptions = join(_graal_home, 'graal.options')
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
651 if exists(graalOptions):
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
652 shutil.copy(graalOptions, opts2.export_dir)
8dc4cdde75fb remove build-graal.xml and have make directly call mx to generate graal.jar
Doug Simon <doug.simon@oracle.com>
parents: 10067
diff changeset
653
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
654 if not _vmSourcesAvailable or not opts2.native:
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
655 return
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
656
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
657 builds = [_vmbuild]
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
658
4577
bc8b58c11768 Added debug build of HotSpot Client to the gate.
Doug Simon <doug.simon@oracle.com>
parents: 4575
diff changeset
659 if vm is None:
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
660 vm = _get_vm()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
661
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
662 if vm == 'original':
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
663 pass
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
664 elif vm.startswith('server'):
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
665 buildSuffix = ''
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
666 elif vm.startswith('client'):
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
667 buildSuffix = '1'
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
668 else:
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
669 assert vm == 'graal', vm
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
670 buildSuffix = 'graal'
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
671
11530
be9e54fbb699 Use a better warning message for building with --installed-jdks set
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11526
diff changeset
672 if _installed_jdks and _installed_jdks != _graal_home:
be9e54fbb699 Use a better warning message for building with --installed-jdks set
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11526
diff changeset
673 if not mx.ask_yes_no("Warning: building while --installed-jdks is set (" + _installed_jdks + ") is not recommanded - are you sure you want to continue", 'n'):
11512
38acec26d535 If _installed_jdk is set, ask confirmation before building
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11511
diff changeset
674 mx.abort(1)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
675
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
676 for build in builds:
5094
d3f547b08304 added mechanism for disabling automatic native builds from the IDE (set IDE_BUILD_TARGET="" in mx/env)
Doug Simon <doug.simon@oracle.com>
parents: 5090
diff changeset
677 if build == 'ide-build-target':
11302
fcb4cf14a3c3 absence of IDE_BUILD_TARGET environment variable prevents HotSpot builds when editing C++ sources in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 11296
diff changeset
678 build = os.environ.get('IDE_BUILD_TARGET', None)
fcb4cf14a3c3 absence of IDE_BUILD_TARGET environment variable prevents HotSpot builds when editing C++ sources in Eclipse
Doug Simon <doug.simon@oracle.com>
parents: 11296
diff changeset
679 if build is None or len(build) == 0:
5094
d3f547b08304 added mechanism for disabling automatic native builds from the IDE (set IDE_BUILD_TARGET="" in mx/env)
Doug Simon <doug.simon@oracle.com>
parents: 5090
diff changeset
680 continue
d3f547b08304 added mechanism for disabling automatic native builds from the IDE (set IDE_BUILD_TARGET="" in mx/env)
Doug Simon <doug.simon@oracle.com>
parents: 5090
diff changeset
681
9098
d766fd8eede0 VM copy made during initial copy of the JDK is now named 'boot' instead of 'server0' to better reflect that it is the default VM (which may not be 'server') from the boot JDK
Doug Simon <doug.simon@oracle.com>
parents: 9097
diff changeset
682 jdk = _jdk(build, create=True)
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
683
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
684 if vm == 'original':
9098
d766fd8eede0 VM copy made during initial copy of the JDK is now named 'boot' instead of 'server0' to better reflect that it is the default VM (which may not be 'server') from the boot JDK
Doug Simon <doug.simon@oracle.com>
parents: 9097
diff changeset
685 if build != 'product':
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
686 mx.log('only product build of original VM exists')
9098
d766fd8eede0 VM copy made during initial copy of the JDK is now named 'boot' instead of 'server0' to better reflect that it is the default VM (which may not be 'server') from the boot JDK
Doug Simon <doug.simon@oracle.com>
parents: 9097
diff changeset
687 continue
14605
5953ac9e0d93 fixed pylint errors
Doug Simon <doug.simon@oracle.com>
parents: 14602
diff changeset
688
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
689 if not isVMSupported(vm):
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
690 mx.log('The ' + vm + ' VM is not supported on this platform - skipping')
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
691 continue
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
692
4607
ee87cfe2f8f9 Made GraalVM build work on Mac OS X.
Doug Simon <doug.simon@oracle.com>
parents: 4602
diff changeset
693 vmDir = join(_vmLibDirInJdk(jdk), vm)
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
694 if not exists(vmDir):
6687
a9a50f21e000 Added change to copied directory's protection when source JDK directories are read-only.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6566
diff changeset
695 if mx.get_os() != 'windows':
13919
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
696 chmodRecursive(jdk, JDK_UNIX_PERMISSIONS)
14780
aaecb0ca0c7d fixed hard coded reference to JDK7
Doug Simon <doug.simon@oracle.com>
parents: 14777
diff changeset
697 mx.log('Creating VM directory in JDK: ' + vmDir)
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
698 os.makedirs(vmDir)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
699
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
700 def filterXusage(line):
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
701 if not 'Xusage.txt' in line:
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
702 sys.stderr.write(line + os.linesep)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
703
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
704 # Check if a build really needs to be done
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
705 timestampFile = join(vmDir, '.build-timestamp')
9098
d766fd8eede0 VM copy made during initial copy of the JDK is now named 'boot' instead of 'server0' to better reflect that it is the default VM (which may not be 'server') from the boot JDK
Doug Simon <doug.simon@oracle.com>
parents: 9097
diff changeset
706 if opts2.force or not exists(timestampFile):
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
707 mustBuild = True
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
708 else:
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
709 mustBuild = False
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
710 timestamp = os.path.getmtime(timestampFile)
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
711 sources = []
15844
d1822a8fe26f minor cleanups
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15820
diff changeset
712 for d in ['src', 'make', join('graal', 'com.oracle.graal.hotspot', 'src_gen', 'hotspot')]:
5244
55ff4ba8d7b1 ignore src/share/tools directory in native build out-of-date check
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
713 for root, dirnames, files in os.walk(join(_graal_home, d)):
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
714 # ignore <graal>/src/share/tools
5244
55ff4ba8d7b1 ignore src/share/tools directory in native build out-of-date check
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
715 if root == join(_graal_home, 'src', 'share'):
55ff4ba8d7b1 ignore src/share/tools directory in native build out-of-date check
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
716 dirnames.remove('tools')
55ff4ba8d7b1 ignore src/share/tools directory in native build out-of-date check
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
717 sources += [join(root, name) for name in files]
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
718 for f in sources:
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
719 if len(f) != 0 and os.path.getmtime(f) > timestamp:
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
720 mustBuild = True
5244
55ff4ba8d7b1 ignore src/share/tools directory in native build out-of-date check
Doug Simon <doug.simon@oracle.com>
parents: 5239
diff changeset
721 break
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
722
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
723 if not mustBuild:
10568
070b4a3c56f3 disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
Doug Simon <doug.simon@oracle.com>
parents: 10527
diff changeset
724 mx.logv('[all files in src and make directories are older than ' + timestampFile[len(_graal_home) + 1:] + ' - skipping native build]')
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
725 continue
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
726
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
727 if platform.system() == 'Windows':
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
728 compilelogfile = _graal_home + '/graalCompile.log'
4252
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
729 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
67e88b7624d5 Removed need for GRAAL environment variable on Windows.
Doug Simon <doug.simon@oracle.com>
parents: 4247
diff changeset
730
4572
76841bdd5f3e (Windows) Add Graal build configurations (with GRAAL defined) and fix build command.
Andreas Woess <andreas.woess@jku.at>
parents: 4559
diff changeset
731 variant = {'client': 'compiler1', 'server': 'compiler2'}.get(vm, vm)
76841bdd5f3e (Windows) Add Graal build configurations (with GRAAL defined) and fix build command.
Andreas Woess <andreas.woess@jku.at>
parents: 4559
diff changeset
732 project_config = variant + '_' + build
76841bdd5f3e (Windows) Add Graal build configurations (with GRAAL defined) and fix build command.
Andreas Woess <andreas.woess@jku.at>
parents: 4559
diff changeset
733 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', _graal_home)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
734 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + _graal_home + r'\make\windows"& call create.bat ' + _graal_home
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
735 print winCompileCmd
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
736 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
737 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
738 mx.log('Error executing create command')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
739 return
4572
76841bdd5f3e (Windows) Add Graal build configurations (with GRAAL defined) and fix build command.
Andreas Woess <andreas.woess@jku.at>
parents: 4559
diff changeset
740 winBuildCmd = 'msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcxproj /p:Configuration=' + project_config + ' /p:Platform=x64'
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
741 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile):
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
742 mx.log('Error building project')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
743 return
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
744 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
745 cpus = multiprocessing.cpu_count()
6718
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
746 runCmd = [mx.gmake_cmd()]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
747 runCmd.append(build + buildSuffix)
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8647
diff changeset
748 env = os.environ.copy()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
749
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
750 if opts2.D:
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
751 for nv in opts2.D:
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
752 name, value = nv.split('=', 1)
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
753 env[name.strip()] = value
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
754
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
755 env.setdefault('ARCH_DATA_MODEL', '64')
057620486c90 Improved time stamps of gate tasks to show duration of each task explicitly.
Doug Simon <doug.simon@oracle.com>
parents: 4230
diff changeset
756 env.setdefault('LANG', 'C')
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
757 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
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
758 env.setdefault('ALT_BOOTDIR', mx.java().jdk)
13846
1e72cd05b77e hs build: add graal tag to hotspot build version
Bernhard Urban <bernhard.urban@jku.at>
parents: 13761
diff changeset
759
9161
8d4174140745 Make the native build less verbose unless mx -v is used
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9159
diff changeset
760 if not mx._opts.verbose:
8d4174140745 Make the native build less verbose unless mx -v is used
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9159
diff changeset
761 runCmd.append('MAKE_VERBOSE=')
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8647
diff changeset
762 env['JAVA_HOME'] = jdk
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
763 if vm.endswith('nograal'):
9166
0f3fe35513a0 renamed build variable used to make a Graal/non-Graal build from OMIT_GRAAL to INCLUDE_GRAAL and ensured it is only used internally
Doug Simon <doug.simon@oracle.com>
parents: 9163
diff changeset
764 env['INCLUDE_GRAAL'] = 'false'
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
765 env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()))
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
766 else:
15000
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
767 # extract latest release tag for graal
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
768 try:
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
769 tags = [x.split(' ')[0] for x in subprocess.check_output(['hg', '-R', _graal_home, 'tags']).split('\n') if x.startswith("graal-")]
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
770 except:
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
771 # not a mercurial repository or hg commands are not available.
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
772 tags = None
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
773
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
774 if tags:
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
775 # extract the most recent tag
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
776 tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0]
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
777 env.setdefault('USER_RELEASE_SUFFIX', tag)
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
778 env.setdefault('GRAAL_VERSION', tag[len("graal-"):])
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
779 else:
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
780 version = 'unknown-{}-{}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
781 env.setdefault('USER_RELEASE_SUFFIX', 'graal-' + version)
cc844a4512f1 added graal.version system property that is (only) defined by Graal enabled VMs
Doug Simon <doug.simon@oracle.com>
parents: 14965
diff changeset
782 env.setdefault('GRAAL_VERSION', version)
9166
0f3fe35513a0 renamed build variable used to make a Graal/non-Graal build from OMIT_GRAAL to INCLUDE_GRAAL and ensured it is only used internally
Doug Simon <doug.simon@oracle.com>
parents: 9163
diff changeset
783 env['INCLUDE_GRAAL'] = 'true'
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
784 env.setdefault('INSTALL', 'y')
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
785 if mx.get_os() == 'solaris':
6702
602ee4d1db61 added setup of ENFORCE_COMPILER_REV and ENFORCE_CC_COMPILER_REV when using sunstudio compilers on Solaris to avoid build complaint from HotSpot makefiles.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6701
diff changeset
786 # If using sparcWorks, setup flags to avoid make complaining about CC version
602ee4d1db61 added setup of ENFORCE_COMPILER_REV and ENFORCE_CC_COMPILER_REV when using sunstudio compilers on Solaris to avoid build complaint from HotSpot makefiles.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6701
diff changeset
787 cCompilerVersion = subprocess.Popen('CC -V', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stderr.readlines()[0]
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
788 if cCompilerVersion.startswith('CC: Sun C++'):
6702
602ee4d1db61 added setup of ENFORCE_COMPILER_REV and ENFORCE_CC_COMPILER_REV when using sunstudio compilers on Solaris to avoid build complaint from HotSpot makefiles.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6701
diff changeset
789 compilerRev = cCompilerVersion.split(' ')[3]
6718
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
790 env.setdefault('ENFORCE_COMPILER_REV', compilerRev)
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
791 env.setdefault('ENFORCE_CC_COMPILER_REV', compilerRev)
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
792 if build == 'jvmg':
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
793 # I want ALL the symbols when I'm debugging on Solaris
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
794 # Some Makefile variable are overloaded by environment variable so we need to explicitely
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
795 # pass them down in the command line. This one is an example of that.
cce59a7ee92c Avoids stripping libjvm.so when building debug on Solaris (.debuginfo files don't work well with Oracle Solaris Studio 12.3's solaris).
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6705
diff changeset
796 runCmd.append('STRIP_POLICY=no_strip')
6276
03c4c25ae726 disabled zipping of lib*.debuginfo files to simplify debugging with gdb
Doug Simon <doug.simon@oracle.com>
parents: 5881
diff changeset
797 # This removes the need to unzip the *.diz files before debugging in gdb
03c4c25ae726 disabled zipping of lib*.debuginfo files to simplify debugging with gdb
Doug Simon <doug.simon@oracle.com>
parents: 5881
diff changeset
798 env.setdefault('ZIP_DEBUGINFO_FILES', '0')
03c4c25ae726 disabled zipping of lib*.debuginfo files to simplify debugging with gdb
Doug Simon <doug.simon@oracle.com>
parents: 5881
diff changeset
799
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
800 # Clear these 2 variables as having them set can cause very confusing build problems
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
801 env.pop('LD_LIBRARY_PATH', None)
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
802 env.pop('CLASSPATH', None)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
803
8884
51a8368d0231 Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8647
diff changeset
804 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
805
5680
87fc13b59258 Split _vmLibDirInJdk into _vmLibDirInJdk and _vmCfgInJdk to account for Windows jdk layout
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5649
diff changeset
806 jvmCfg = _vmCfgInJdk(jdk)
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
807 if not exists(jvmCfg):
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
808 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
809
8901
8ddaac81cb21 Be more careful while updating jvm.cfg (fixes a bug where the -server configuration would overwrite the -server0 one)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8900
diff changeset
810 prefix = '-' + vm + ' '
8ddaac81cb21 Be more careful while updating jvm.cfg (fixes a bug where the -server configuration would overwrite the -server0 one)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8900
diff changeset
811 vmKnown = prefix + 'KNOWN\n'
8889
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
812 lines = []
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
813 found = False
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
814 with open(jvmCfg) as f:
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
815 for line in f:
8889
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
816 if line.strip() == vmKnown.strip():
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
817 found = True
8889
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
818 lines.append(line)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
819
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
820 if not found:
8901
8ddaac81cb21 Be more careful while updating jvm.cfg (fixes a bug where the -server configuration would overwrite the -server0 one)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8900
diff changeset
821 mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg)
6688
806821a1c0a8 Make sure files in copy of JDK has write-protection unset before modifying it.
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6687
diff changeset
822 if mx.get_os() != 'windows':
13919
9d70445ea369 mx: set correct permissions for graal.jar
Bernhard Urban <bernhard.urban@jku.at>
parents: 13846
diff changeset
823 os.chmod(jvmCfg, JDK_UNIX_PERMISSIONS)
8889
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
824 with open(jvmCfg, 'w') as f:
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
825 for line in lines:
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
826 if line.startswith(prefix):
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
827 line = vmKnown
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
828 found = True
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
829 f.write(line)
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
830 if not found:
c669e8e621a1 Update the -client line in jvm.cfg when it already exists (ie IGNORE)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8887
diff changeset
831 f.write(vmKnown)
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
832
5239
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
833 if exists(timestampFile):
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
834 os.utime(timestampFile, None)
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
835 else:
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
836 file(timestampFile, 'a')
b9db4fee6eb2 skip a native build if all files in src and make are older than the timestamp of the previous build
Doug Simon <doug.simon@oracle.com>
parents: 5234
diff changeset
837
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
838 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
839 """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
840 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
841
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
842 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
843 """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
844 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
845
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
846 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
847 """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
848
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
849 if vm is None:
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
850 vm = _get_vm()
14164
10e07aaeb54f fixed pylint warning
Doug Simon <doug.simon@oracle.com>
parents: 14161
diff changeset
851
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
852 if not isVMSupported(vm):
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
853 mx.abort('The ' + vm + ' is not supported on this platform')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
854
10454
590b0c26877f mx: add --workdir argument
Bernhard Urban <bernhard.urban@jku.at>
parents: 10417
diff changeset
855 if cwd is None:
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
856 cwd = _vm_cwd
11424
ece40b452e65 mx: Fix commands.vm when an explicit cwd is passed and no --vmcwd is given
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11415
diff changeset
857 elif _vm_cwd is not None and _vm_cwd != cwd:
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
858 mx.abort("conflicting working directories: do not set --vmcwd for this command")
10454
590b0c26877f mx: add --workdir argument
Bernhard Urban <bernhard.urban@jku.at>
parents: 10417
diff changeset
859
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4216
diff changeset
860 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product'
11286
485a5f029b32 mx: graal.jar is not silently updated anymore in the vm function
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11237
diff changeset
861 jdk = _jdk(build, vmToCheck=vm, installGraalJar=False)
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
862 _updateInstalledGraalOptionsFile(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
863 mx.expand_project_in_args(args)
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
864 if _make_eclipse_launch:
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
865 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True))
5024
7ccdae96e98a Allow JaCoCon to append to the execution file
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5016
diff changeset
866 if _jacoco == 'on' or _jacoco == 'append':
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
867 jacocoagent = mx.library("JACOCOAGENT", True)
5366
67e63e8dcbd2 build JaCoCo exclude list by scanning for snippets
Doug Simon <doug.simon@oracle.com>
parents: 5295
diff changeset
868 # Exclude all compiler tests and snippets
5881
472a648769e4 better JaCoCo : only include com.oracle.graal.* and com.oracle.max.*, exclude com.oracle.graal.jtt.*
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5878
diff changeset
869 excludes = ['com.oracle.graal.compiler.tests.*', 'com.oracle.graal.jtt.*']
5366
67e63e8dcbd2 build JaCoCo exclude list by scanning for snippets
Doug Simon <doug.simon@oracle.com>
parents: 5295
diff changeset
870 for p in mx.projects():
8607
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8554
diff changeset
871 excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys()
c7672a325faf search for classes containing annotations returns source file as well as class name
Doug Simon <doug.simon@oracle.com>
parents: 8554
diff changeset
872 excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
873
9343
cdc21fd3d389 removed obsolete JaCoCo inclusion filter
Doug Simon <doug.simon@oracle.com>
parents: 9291
diff changeset
874 includes = ['com.oracle.graal.*']
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
875 agentOptions = {
5024
7ccdae96e98a Allow JaCoCon to append to the execution file
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5016
diff changeset
876 'append' : 'true' if _jacoco == 'append' else 'false',
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
877 'bootclasspath' : 'true',
5881
472a648769e4 better JaCoCo : only include com.oracle.graal.* and com.oracle.max.*, exclude com.oracle.graal.jtt.*
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5878
diff changeset
878 'includes' : ':'.join(includes),
5878
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
879 'excludes' : ':'.join(excludes),
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
880 'destfile' : 'jacoco.exec'
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
881 }
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
882 args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
883 exe = join(jdk, 'bin', mx.exe_suffix('java'))
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
884 pfx = _vm_prefix.split() if _vm_prefix is not None else []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
885
9667
1ef7b26e9177 mx/commands.py: warn about arguments after '-version' when launching the vm
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9639
diff changeset
886 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
887 ignoredArgs = args[args.index('-version') + 1:]
9667
1ef7b26e9177 mx/commands.py: warn about arguments after '-version' when launching the vm
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9639
diff changeset
888 if len(ignoredArgs) > 0:
1ef7b26e9177 mx/commands.py: warn about arguments after '-version' when launching the vm
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9639
diff changeset
889 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
890
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
891 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
892 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
893
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
894 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None):
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
895 (pfx_, exe_, vm_, args_, cwd) = _parseVmArgs(args, vm, cwd, vmbuild)
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
896 return mx.run(pfx_ + [exe_, '-' + vm_] + args_, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
897
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
898 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
899 """
5482
9f4783c0269e folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5438
diff changeset
900 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
901 (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
902 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
903 """
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
904
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
905 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
906 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
907
14744
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
908 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
909 """
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
910 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
911 """
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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
924 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
925 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
926 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
927 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
928
14744
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
929 if defaultAllVMArgs:
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
930 return args, []
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
931 else:
bf51a92a1bdd Add new optional method parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14720
diff changeset
932 return [], args
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
933
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
934 def _run_tests(args, harness, annotations, testfile, whitelist, regex):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
935
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
936
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
937 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
938 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
939 if t.startswith('-'):
11403
e45b540b0ef2 clearer error message
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
940 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
941
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
942 candidates = {}
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11758
diff changeset
943 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
944 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
945 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
946 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
947 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
948
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
949 classes = []
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
950 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
951 classes = candidates.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
952 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
953 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
954 projs = set()
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
955 for t in tests:
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
956 found = False
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
957 for c, p in candidates.iteritems():
10608
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
958 if t in c:
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
959 found = True
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
960 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
961 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
962 if not found:
eeb80dcd60d8 fixed regression in unittest command when no tests are specified
Doug Simon <doug.simon@oracle.com>
parents: 10606
diff changeset
963 mx.log('warning: no tests matched by substring "' + t)
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
964 projectscp = mx.classpath(projs)
8343
a3c30d467f96 unittest: just do a single JVM call
Bernhard Urban <bernhard.urban@jku.at>
parents: 8340
diff changeset
965
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
966 if whitelist:
15328
d89ed48ae349 mx: use generators
Bernhard Urban <bernhard.urban@jku.at>
parents: 15327
diff changeset
967 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
968
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
969 if regex:
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
970 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
971
8343
a3c30d467f96 unittest: just do a single JVM call
Bernhard Urban <bernhard.urban@jku.at>
parents: 8340
diff changeset
972 if len(classes) != 0:
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
973 f_testfile = open(testfile, 'w')
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
974 for c in classes:
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
975 f_testfile.write(c + '\n')
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
976 f_testfile.close()
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
977 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
978
15907
7d1690e145ae mx: option to force a GC after each unit test
Roland Schatz <roland.schatz@oracle.com>
parents: 15896
diff changeset
979 def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False):
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
980 mxdir = dirname(__file__)
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
981 name = 'JUnitWrapper'
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
982 javaSource = join(mxdir, name + '.java')
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
983 javaClass = join(mxdir, name + '.class')
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
984 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
985 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
986 (_, 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
987 os.close(_)
15500
f2132fab8a6f Add custom GraalJUnitCore.
Josef Eisl <josef.eisl@jku.at>
parents: 15461
diff changeset
988 corecp = mx.classpath(['com.oracle.graal.test'])
15575
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
989
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
990 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
991 subprocess.check_call([mx.java().javac, '-cp', corecp, '-d', mxdir, javaSource])
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
992
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
993 coreArgs = []
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
994 if verbose:
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
995 coreArgs.append('-JUnitVerbose')
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
996 if enable_timing:
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
997 coreArgs.append('-JUnitEnableTiming')
15655
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
998 if color:
ec29b2d3bdb4 mx unittest: add color support.
Josef Eisl <josef.eisl@jku.at>
parents: 15638
diff changeset
999 coreArgs.append('-JUnitColor')
15656
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
1000 if eager_stacktrace:
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
1001 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
1002 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
1003 coreArgs.append('-JUnitGCAfterTest')
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
1004
15575
cb2f3c49deb2 mx unittest: compile junitwrapper with right classpath
Bernhard Urban <bernhard.urban@jku.at>
parents: 15555
diff changeset
1005
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
1006 def harness(projectscp, vmArgs):
12647
b038b643a3a4 restricted BootstrapGraal option to GRAALVM builds only
Doug Simon <doug.simon@oracle.com>
parents: 12605
diff changeset
1007 if _get_vm() != 'graal':
8440
2d0160c35f8f Fix unittest on server0.
Roland Schatz <roland.schatz@oracle.com>
parents: 8433
diff changeset
1008 prefixArgs = ['-esa', '-ea']
2d0160c35f8f Fix unittest on server0.
Roland Schatz <roland.schatz@oracle.com>
parents: 8433
diff changeset
1009 else:
2d0160c35f8f Fix unittest on server0.
Roland Schatz <roland.schatz@oracle.com>
parents: 8433
diff changeset
1010 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
11227
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
1011 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
1012 testclasses = [l.rstrip() for l in fp.readlines()]
bd0e589a9a65 avoid use of JUnitWrapper when exactly one test is being executed
Doug Simon <doug.simon@oracle.com>
parents: 11179
diff changeset
1013 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
1014 # 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
1015 # replaying the VM execution in a native debugger (e.g., gdb).
15502
a26be2c9b81b Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents: 15500
diff changeset
1016 vm(prefixArgs + vmArgs + ['-cp', prefixcp + corecp + ':' + projectscp, 'com.oracle.graal.test.GraalJUnitCore'] + 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
1017 else:
15502
a26be2c9b81b Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents: 15500
diff changeset
1018 vm(prefixArgs + vmArgs + ['-cp', prefixcp + corecp + ':' + projectscp + os.pathsep + mxdir, name] + [testfile] + coreArgs)
8406
2bfb9644dcc2 unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents: 8343
diff changeset
1019
8433
87346100d7a5 temporary file is removed when unittests fail
Doug Simon <doug.simon@oracle.com>
parents: 8406
diff changeset
1020 try:
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
1021 _run_tests(args, harness, annotations, testfile, whitelist, regex)
8433
87346100d7a5 temporary file is removed when unittests fail
Doug Simon <doug.simon@oracle.com>
parents: 8406
diff changeset
1022 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
1023 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
1024 os.remove(testfile)
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
1025
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1026 _unittestHelpSuffix = """
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1027 Unittest options:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1028
15555
8c19ffc672fd mx unittest: add support for regular expressions.
Josef Eisl <josef.eisl@jku.at>
parents: 15506
diff changeset
1029 --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
1030 in the given whitelist
15502
a26be2c9b81b Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents: 15500
diff changeset
1031 --verbose enable verbose JUnit output
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
1032 --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
1033 --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
1034 --color enable colors output
15656
fcf6e5683082 mx unittest: add --eager-stacktrace.
Josef Eisl <josef.eisl@jku.at>
parents: 15655
diff changeset
1035 --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
1036 --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
1037
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1038 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
1039
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
1040 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
1041 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
1042
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1043 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
1044
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
1045 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
1046
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1047 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
1048 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
1049
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1050 -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
1051
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1052 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
1053 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
1054 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
1055 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
1056 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
1057 (unlike the temporary file otherwise used).
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1058
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1059 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
1060 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
1061 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
1062 """
9598
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1063
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1064 def unittest(args):
0fc67e300471 better help message for the unittest commands
Doug Simon <doug.simon@oracle.com>
parents: 9343
diff changeset
1065 """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
1066
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1067 parser = ArgumentParser(prog='mx unittest',
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1068 description='run the JUnit tests',
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1069 add_help=False,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1070 formatter_class=RawDescriptionHelpFormatter,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1071 epilog=_unittestHelpSuffix,
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1072 )
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
1073 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
1074 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true')
15503
c62e120e8cd9 Add TimingDecorator.
Josef Eisl <josef.eisl@jku.at>
parents: 15502
diff changeset
1075 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
1076 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
1077 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
1078 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
1079 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
1080
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1081 ut_args = []
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1082 delimiter = False
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1083 # check for delimiter
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1084 while len(args) > 0:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1085 arg = args.pop(0)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1086 if arg == '--':
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1087 delimiter = True
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1088 break
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1089 ut_args.append(arg)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1090
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1091 if delimiter:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1092 # all arguments before '--' must be recognized
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1093 parsed_args = parser.parse_args(ut_args)
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1094 else:
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1095 # parse all know arguments
15197
06bfcf5f941d mx: improve unittest options parsing.
Josef Eisl <josef.eisl@jku.at>
parents: 15178
diff changeset
1096 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
1097
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
1098 if parsed_args.whitelist:
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
1099 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
1100 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
1101 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
1102 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
1103 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist)
15114
2082889fc8f6 mx: add unittest option --baseline-whitelist.
Josef Eisl <josef.eisl@jku.at>
parents: 15113
diff changeset
1104
15657
50740bac9679 mx unittest: simplify argument passing.
Josef Eisl <josef.eisl@jku.at>
parents: 15656
diff changeset
1105 _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
1106
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
1107 def shortunittest(args):
15324
5b5f47104c0d mx: add whitelist for shortunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15323
diff changeset
1108 """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
1109
15324
5b5f47104c0d mx: add whitelist for shortunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15323
diff changeset
1110 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
1111 unittest(args)
8340
d9d883aeb96f unittest: seperate target `longunittest' and `shortunittest'
Bernhard Urban <bernhard.urban@jku.at>
parents: 8317
diff changeset
1112
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
1113 def buildvms(args):
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
1114 """build one or more VMs in various configurations"""
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1115
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
1116 vmsDefault = ','.join(_vmChoices.keys())
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
1117 vmbuildsDefault = ','.join(_vmbuildChoices)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1118
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1119 parser = ArgumentParser(prog='mx buildvms')
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
1120 parser.add_argument('--vms', help='a comma separated list of VMs to build (default: ' + vmsDefault + ')', metavar='<args>', default=vmsDefault)
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
1121 parser.add_argument('--builds', help='a comma separated list of build types (default: ' + vmbuildsDefault + ')', metavar='<args>', default=vmbuildsDefault)
9096
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1122 parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build')
9097
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1123 parser.add_argument('-c', '--console', action='store_true', help='send build output to console instead of log file')
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
1124
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
1125 args = parser.parse_args(args)
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
1126 vms = args.vms.split(',')
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
1127 builds = args.builds.split(',')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1128
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
1129 allStart = time.time()
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
1130 for v in vms:
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
1131 if not isVMSupported(v):
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
1132 mx.log('The ' + v + ' VM is not supported on this platform - skipping')
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
1133 continue
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
1134
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
1135 for vmbuild in builds:
9117
cbfcb1054619 renamed 'boot' VM to 'original' VM
Doug Simon <doug.simon@oracle.com>
parents: 9116
diff changeset
1136 if v == 'original' and vmbuild != 'product':
9095
d538dce8f403 support for non-GRAAL VMs co-existing with GRAAL VMs
Doug Simon <doug.simon@oracle.com>
parents: 9010
diff changeset
1137 continue
9097
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1138 if not args.console:
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1139 logFile = join(v + '-' + vmbuild + '.log')
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1140 log = open(join(_graal_home, logFile), 'wb')
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1141 start = time.time()
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1142 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1143 # Run as subprocess so that output can be directed to a file
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1144 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild',
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1145 vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
9097
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1146 duration = datetime.timedelta(seconds=time.time() - start)
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1147 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
a0ab945fb95f build output during buildvms command is sent to console (instead of log files) if -c option is given
Doug Simon <doug.simon@oracle.com>
parents: 9096
diff changeset
1148 else:
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
1149 with VM(v, vmbuild):
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
1150 build([])
9096
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1151 if not args.no_check:
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1152 vmargs = ['-version']
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1153 if v == 'graal':
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1154 vmargs.insert(0, '-XX:-BootstrapGraal')
d4b868ed9cfb buildvms command now runs "java -version" for each VM built unless -n option is specified
Doug Simon <doug.simon@oracle.com>
parents: 9095
diff changeset
1155 vm(vmargs, vm=v, vmbuild=vmbuild)
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
1156 allDuration = datetime.timedelta(seconds=time.time() - allStart)
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
1157 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']')
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
1158
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
1159 class Task:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1160 def __init__(self, title):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1161 self.start = 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
1162 self.title = title
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1163 self.end = None
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1164 self.duration = None
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1165 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1166 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
1167 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
1168 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
1169 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
1170 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
1171 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
1172 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
1173 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
1174 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
1175 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
1176 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
1177
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1178 def _basic_gate_body(args, tasks):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1179 t = Task('BuildHotSpotGraal: fastdebug,product')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1180 buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1181 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1182
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1183 with VM('graal', 'fastdebug'):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1184 t = Task('BootstrapWithSystemAssertions:fastdebug')
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1185 vm(['-esa', '-XX:-TieredCompilation', '-version'])
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
1186 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1187
14123
dc41eab09fe8 gate: add non-tiered bootstrap
Bernhard Urban <bernhard.urban@jku.at>
parents: 14116
diff changeset
1188 with VM('graal', 'fastdebug'):
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1189 t = Task('BootstrapWithSystemAssertionsNoCoop:fastdebug')
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1190 vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version'])
14123
dc41eab09fe8 gate: add non-tiered bootstrap
Bernhard Urban <bernhard.urban@jku.at>
parents: 14116
diff changeset
1191 tasks.append(t.stop())
dc41eab09fe8 gate: add non-tiered bootstrap
Bernhard Urban <bernhard.urban@jku.at>
parents: 14116
diff changeset
1192
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
1193 with VM('graal', 'product'):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1194 t = Task('BootstrapWithGCVerification:product')
12042
fbe1ee508936 added ability to suppress duplicate lines on an output stream and used it to filter the GC verification log messages in the gate
Doug Simon <doug.simon@oracle.com>
parents: 11936
diff changeset
1195 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1196 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
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
1197 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1198
12412
3c11430f62d8 Re-enable G1 verification in gate
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12359
diff changeset
1199 with VM('graal', 'product'):
3c11430f62d8 Re-enable G1 verification in gate
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12359
diff changeset
1200 t = Task('BootstrapWithG1GCVerification:product')
3c11430f62d8 Re-enable G1 verification in gate
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12359
diff changeset
1201 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1202 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
12412
3c11430f62d8 Re-enable G1 verification in gate
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12359
diff changeset
1203 tasks.append(t.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
1204
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1205 with VM('graal', 'product'):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1206 t = Task('BootstrapWithRegisterPressure:product')
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1207 vm(['-XX:-TieredCompilation', '-G:RegisterPressure=rbx,r11,r10,r14,xmm3,xmm11,xmm14', '-esa', '-version'])
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
1208 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1209
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1210 with VM('graal', 'product'):
13378
16d99e9d77ad Options: rename flag (AOTCompilation -> ImmutableCode)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13347
diff changeset
1211 t = Task('BootstrapWithImmutableCode:product')
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1212 vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version'])
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
1213 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1214
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1215 with VM('server', 'product'): # hosted mode
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1216 t = Task('UnitTests:hosted-product')
15506
d250613801fb gate: make unittests verbose
Bernhard Urban <bernhard.urban@jku.at>
parents: 15503
diff changeset
1217 unittest(['--enable-timing', '--verbose'])
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
1218 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1219
15325
25ce2866f105 gate: add baseline compiler unittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15324
diff changeset
1220 with VM('server', 'product'): # hosted mode
25ce2866f105 gate: add baseline compiler unittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15324
diff changeset
1221 t = Task('UnitTests-BaselineCompiler:hosted-product')
15506
d250613801fb gate: make unittests verbose
Bernhard Urban <bernhard.urban@jku.at>
parents: 15503
diff changeset
1222 unittest(['--enable-timing', '--verbose', '--whitelist', 'test/whitelist_baseline.txt', '-G:+UseBaselineCompiler'])
15325
25ce2866f105 gate: add baseline compiler unittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15324
diff changeset
1223 tasks.append(t.stop())
25ce2866f105 gate: add baseline compiler unittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 15324
diff changeset
1224
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
1225 for vmbuild in ['fastdebug', 'product']:
14877
fdb912b1eb7b gate: use no tiered to test bootstrap, add scaladacapo-kiama (fastdebug)
Bernhard Urban <bernhard.urban@jku.at>
parents: 14872
diff changeset
1226 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild):
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
1227 t = Task(str(test) + ':' + vmbuild)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1228 if not test.test('graal'):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1229 t.abort(test.name + ' Failed')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1230 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1231
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1232 if args.jacocout is not None:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1233 jacocoreport([args.jacocout])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1234
11758
4ac92e735a16 pylint fixes (retry)
Mick Jordan <mick.jordan@oracle.com>
parents: 11757
diff changeset
1235 global _jacoco
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
1236 _jacoco = 'off'
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1237
12497
98caa3872d83 gate: clean and build IGV (not GV)
Bernhard Urban <bernhard.urban@jku.at>
parents: 12412
diff changeset
1238 t = Task('CleanAndBuildIdealGraphVisualizer')
98caa3872d83 gate: clean and build IGV (not GV)
Bernhard Urban <bernhard.urban@jku.at>
parents: 12412
diff changeset
1239 mx.run(['ant', '-f', join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'), '-q', 'clean', 'build'])
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
1240 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1241
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1242 # Prevent Graal modifications from breaking the standard builds
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1243 if args.buildNonGraal:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1244 t = Task('BuildHotSpotVarieties')
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1245 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1246 buildvms(['--vms', 'server-nograal', '--builds', 'product'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1247 buildvms(['--vms', 'server-nograal', '--builds', 'optimized'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1248 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1249
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1250 for vmbuild in ['product', 'fastdebug']:
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1251 for theVm in ['client', 'server']:
14606
f50dece27798 fixed regression in gate command
Doug Simon <doug.simon@oracle.com>
parents: 14605
diff changeset
1252 if not isVMSupported(theVm):
f50dece27798 fixed regression in gate command
Doug Simon <doug.simon@oracle.com>
parents: 14605
diff changeset
1253 mx.log('The' + theVm + ' VM is not supported on this platform')
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
1254 continue
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
1255 with VM(theVm, vmbuild):
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1256 t = Task('DaCapo_pmd:' + theVm + ':' + vmbuild)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1257 dacapo(['pmd'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1258 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1259
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1260 t = Task('UnitTests:' + theVm + ':' + vmbuild)
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1261 unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api'])
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1262 tasks.append(t.stop())
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1263
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1264
78e6109ee411 mx refactoring for split-repo suites; should have no effect on existing repos
Mick Jordan <mick.jordan@oracle.com>
parents: 11605
diff changeset
1265 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
1266 """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
1267
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
1268 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
1269 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
1270
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1271 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
1272 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
1273 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
4608
05a33fabcfe6 Added -g option to 'mx gate' to omit the server and client builds (i.e. -g == graal only).
Doug Simon <doug.simon@oracle.com>
parents: 4607
diff changeset
1274 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM')
5033
d7ecce178ad2 Add jacoco report and a -XX:+DeoptimizeALot -XX:+VerifyOops bootstrap run to the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5032
diff changeset
1275 parser.add_argument('--jacocout', help='specify the output directory for jacoco report')
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
1276
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
1277 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
1278
5431
0bd1ba69db2a removed double declaration of _vmbuild global variable in gate command
Doug Simon <doug.simon@oracle.com>
parents: 5430
diff changeset
1279 global _jacoco
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1280
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1281 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
1282 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
1283 try:
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1284
11526
db297343d44e added pylint to gate
Doug Simon <doug.simon@oracle.com>
parents: 11525
diff changeset
1285 t = Task('Pylint')
11777
f3e5cbd1efae move pylint to mxtool
Mick Jordan <mick.jordan@oracle.com>
parents: 11758
diff changeset
1286 mx.pylint([])
11526
db297343d44e added pylint to gate
Doug Simon <doug.simon@oracle.com>
parents: 11525
diff changeset
1287 tasks.append(t.stop())
db297343d44e added pylint to gate
Doug Simon <doug.simon@oracle.com>
parents: 11525
diff changeset
1288
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1289 def _clean(name='Clean'):
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1290 t = Task(name)
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1291 cleanArgs = []
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1292 if not args.cleanNative:
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1293 cleanArgs.append('--no-native')
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1294 if not args.cleanJava:
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1295 cleanArgs.append('--no-java')
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1296 clean(cleanArgs)
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1297 tasks.append(t.stop())
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1298 _clean()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1299
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
1300 t = Task('IDEConfigCheck')
6fa4b4933892 added check to gate that generated IDE configurations don't break the build
Doug Simon <doug.simon@oracle.com>
parents: 9803
diff changeset
1301 mx.ideclean([])
6fa4b4933892 added check to gate that generated IDE configurations don't break the build
Doug Simon <doug.simon@oracle.com>
parents: 9803
diff changeset
1302 mx.ideinit([])
6fa4b4933892 added check to gate that generated IDE configurations don't break the build
Doug Simon <doug.simon@oracle.com>
parents: 9803
diff changeset
1303 tasks.append(t.stop())
6fa4b4933892 added check to gate that generated IDE configurations don't break the build
Doug Simon <doug.simon@oracle.com>
parents: 9803
diff changeset
1304
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1305 eclipse_exe = mx.get_env('ECLIPSE_EXE')
7533
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1306 if eclipse_exe is not None:
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1307 t = Task('CodeFormatCheck')
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1308 if mx.eclipseformat(['-e', eclipse_exe]) != 0:
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1309 t.abort('Formatter modified files - run "mx eclipseformat", check in changes and repush')
29b0768b7ba6 added eclipseformat to the gate
Doug Simon <doug.simon@oracle.com>
parents: 7509
diff changeset
1310 tasks.append(t.stop())
8211
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1311
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1312 t = Task('Canonicalization Check')
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1313 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...'))
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1314 if mx.canonicalizeprojects([]) != 0:
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1315 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.')
74896b25297a Test canonicalization and checkstyle early in gate process
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8183
diff changeset
1316 tasks.append(t.stop())
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1317
13928
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1318 if mx.get_env('JDT'):
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1319 t = Task('BuildJavaWithEcj')
15461
f73fc9309f12 gate: use parallelized Java building in the gate
Doug Simon <doug.simon@oracle.com>
parents: 15420
diff changeset
1320 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
1321 tasks.append(t.stop())
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1322
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1323 _clean('CleanAfterEcjBuild')
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1324
c4e5a685c6a1 gate: compile java with ECJ if available
Bernhard Urban <bernhard.urban@jku.at>
parents: 13919
diff changeset
1325 t = Task('BuildJavaWithJavac')
15461
f73fc9309f12 gate: use parallelized Java building in the gate
Doug Simon <doug.simon@oracle.com>
parents: 15420
diff changeset
1326 build(['-p', '--no-native', '--force-javac'])
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
1327 tasks.append(t.stop())
9172
bc5c5336008b Add gate test to check build-graal.xml is up to date.
Roland Schatz <roland.schatz@oracle.com>
parents: 9169
diff changeset
1328
14773
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1329 t = Task('Checkheaders')
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1330 if checkheaders([]) != 0:
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1331 t.abort('Checkheaders warnings were found')
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1332 tasks.append(t.stop())
78343531acc7 added checkheaders to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14772
diff changeset
1333
14751
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1334 t = Task('FindBugs')
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1335 if findbugs([]) != 0:
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1336 t.abort('FindBugs warnings were found')
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1337 tasks.append(t.stop())
015f84f0b375 added findbugs to the gate
Doug Simon <doug.simon@oracle.com>
parents: 14744
diff changeset
1338
5878
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1339 if exists('jacoco.exec'):
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1340 os.unlink('jacoco.exec')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1341
5878
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1342 if args.jacocout is not None:
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1343 _jacoco = 'append'
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1344 else:
191e08da4de4 Apply jacoco coverage to all gate tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5877
diff changeset
1345 _jacoco = 'off'
11757
ec058ce90a3d pylint fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1346
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
1347 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
1348
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
1349 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
1350 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
1351
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
1352 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
1353 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
1354 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
1355 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
1356
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
1357 total.stop()
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1358
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
1359 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
1360 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
1361 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
1362 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
1363 mx.log(' ' + str(total.duration))
11757
ec058ce90a3d pylint fixes
Mick Jordan <mick.jordan@oracle.com>
parents: 11756
diff changeset
1364
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1365 def deoptalot(args):
11377
0fbc1e418c88 fixed capitalization and tense in documentation of some mx commands
Doug Simon <doug.simon@oracle.com>
parents: 11373
diff changeset
1366 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1367
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1368 If the first argument is a number, the process will be repeated
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1369 this number of times. All other arguments are passed to the VM."""
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1370 count = 1
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1371 if len(args) > 0 and args[0].isdigit():
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1372 count = int(args[0])
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1373 del args[0]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1374
7509
442668d41bc2 fixed warnings
Doug Simon <doug.simon@oracle.com>
parents: 7345
diff changeset
1375 for _ in range(count):
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1376 if not vm(['-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version'], vmbuild='fastdebug') == 0:
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1377 mx.abort("Failed")
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1378
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1379 def longtests(args):
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1380
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1381 deoptalot(['15', '-Xmx48m'])
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1382
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
1383 dacapo(['100', 'eclipse', '-esa'])
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
1384
5089
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1385 def igv(args):
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1386 """run the Ideal Graph Visualizer"""
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
1387 with open(join(_graal_home, '.ideal_graph_visualizer.log'), 'w') as fp:
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
1388 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
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
1389 env = os.environ
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
1390 proxy = os.environ.get('http_proxy')
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
1391 if not (proxy is None) and len(proxy) > 0:
14590
e754ac1331ef fix string contains call
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14164
diff changeset
1392 if '://' in proxy:
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
1393 # Remove the http:// prefix (or any other protocol prefix)
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
1394 proxy = proxy.split('://', 1)[1]
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
1395 # Separate proxy server name and port number
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
1396 proxyName, proxyPort = proxy.split(':', 1)
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
1397 proxyEnv = '-DproxyHost="' + proxyName + '" -DproxyPort=' + proxyPort
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
1398 env['ANT_OPTS'] = proxyEnv
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
1399
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
1400 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
1401 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
1402
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
1403 # 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
1404 if 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
1405 dom = xml.dom.minidom.parse(join(nbplatform, 'platform', 'update_tracking', 'org-netbeans-core.xml'))
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
1406 currentVersion = mx.VersionSpec(dom.getElementsByTagName('module_version')[0].getAttribute('specification_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
1407 supportedVersion = mx.VersionSpec('3.43.1')
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
1408 if currentVersion < supportedVersion:
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
1409 mx.log('Replacing NetBeans platform version ' + str(currentVersion) + ' with version ' + str(supportedVersion))
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
1410 shutil.rmtree(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
1411 elif supportedVersion < currentVersion:
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
1412 mx.log('Supported NetBeans version in igv command should be updated to ' + str(currentVersion))
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
1413
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
1414 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
1415 mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]')
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
1416 mx.run(['ant', '-f', join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'), '-l', fp.name, 'run'], env=env)
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
1417
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
1418 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
1419 """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
1420 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
1421 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
1422 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
1423 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
1424 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
1425
15275
0c9406f9338f Update c1visualizer to version compatible with Java 8
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15253
diff changeset
1426 archive = join(libpath, 'c1visualizer_2014-04-22.zip')
15310
dc2dd913c47e mx: ensure newest version of c1visualizer is being used
Doug Simon <doug.simon@oracle.com>
parents: 15275
diff changeset
1427 if not exists(executable) or not exists(archive):
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
1428 if not exists(archive):
15275
0c9406f9338f Update c1visualizer to version compatible with Java 8
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15253
diff changeset
1429 mx.download(archive, ['https://java.net/downloads/c1visualizer/c1visualizer_2014-04-22.zip'])
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
1430 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
1431 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
1432
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
1433 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
1434 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
1435
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
1436 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
1437 # 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
1438 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
1439
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
1440 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
1441
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
1442 def bench(args):
4324
b0aa4a52b89c Added support for project specs in classpath.
Doug Simon <doug.simon@oracle.com>
parents: 4294
diff changeset
1443 """run benchmarks and parse their output for results
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1444
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1445 Results are JSON formated : {group : {benchmark : score}}."""
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1446 resultFile = None
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1447 if '-resultfile' in args:
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1448 index = args.index('-resultfile')
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1449 if index + 1 < len(args):
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1450 resultFile = args[index + 1]
4293
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4288
diff changeset
1451 del args[index]
d4906ea4255b Handle SIGTERM : killing mx will properly kill subprocesses
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4288
diff changeset
1452 del args[index]
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1453 else:
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1454 mx.abort('-resultfile must be followed by a file name')
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
1455 vm = _get_vm()
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1456 if len(args) is 0:
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1457 args = ['all']
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1458
8459
3393f870e6a4 Allow vm arguments in mx bench
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8440
diff changeset
1459 vmArgs = [arg for arg in args if arg.startswith('-')]
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1460
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1461 def benchmarks_in_group(group):
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1462 prefix = group + ':'
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1463 return [a[len(prefix):] for a in args if a.startswith(prefix)]
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1464
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4216
diff changeset
1465 results = {}
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1466 benchmarks = []
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1467 # DaCapo
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1468 if 'dacapo' in args or 'all' in args:
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1469 benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
4335
0d661161fa24 Add possibility to run individual DaCapo & SPECjvm2008 benchmarks, small fix in success and score regular expressions for SPECjvm2008
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4330
diff changeset
1470 else:
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1471 dacapos = benchmarks_in_group('dacapo')
4335
0d661161fa24 Add possibility to run individual DaCapo & SPECjvm2008 benchmarks, small fix in success and score regular expressions for SPECjvm2008
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4330
diff changeset
1472 for dacapo in dacapos:
0d661161fa24 Add possibility to run individual DaCapo & SPECjvm2008 benchmarks, small fix in success and score regular expressions for SPECjvm2008
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4330
diff changeset
1473 if dacapo not in sanitycheck.dacapoSanityWarmup.keys():
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1474 mx.abort('Unknown DaCapo : ' + dacapo)
8891
ca82d06ec93a mx: bench command should not run dacapos with -n 0 when using a specification such as scaladacapo:specs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8890
diff changeset
1475 iterations = sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark]
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1476 if iterations > 0:
8891
ca82d06ec93a mx: bench command should not run dacapos with -n 0 when using a specification such as scaladacapo:specs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8890
diff changeset
1477 benchmarks += [sanitycheck.getDacapo(dacapo, iterations)]
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1478
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1479 if 'scaladacapo' in args or 'all' in args:
4480
7d6490436b57 Add Scala DaCapo benchs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4438
diff changeset
1480 benchmarks += sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
7d6490436b57 Add Scala DaCapo benchs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4438
diff changeset
1481 else:
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1482 scaladacapos = benchmarks_in_group('scaladacapo')
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1483 for scaladacapo in scaladacapos:
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1484 if scaladacapo not in sanitycheck.dacapoScalaSanityWarmup.keys():
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1485 mx.abort('Unknown Scala DaCapo : ' + scaladacapo)
8891
ca82d06ec93a mx: bench command should not run dacapos with -n 0 when using a specification such as scaladacapo:specs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8890
diff changeset
1486 iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark]
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1487 if iterations > 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
1488 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, ['-n', str(iterations)])]
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1489
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1490 # Bootstrap
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1491 if 'bootstrap' in args or 'all' in args:
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1492 benchmarks += sanitycheck.getBootstraps()
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1493 # SPECjvm2008
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1494 if 'specjvm2008' in args or 'all' in args:
11373
6675167d52b6 fixed specjvm2008 regression in bench command
Doug Simon <doug.simon@oracle.com>
parents: 11372
diff changeset
1495 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120'])]
4335
0d661161fa24 Add possibility to run individual DaCapo & SPECjvm2008 benchmarks, small fix in success and score regular expressions for SPECjvm2008
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4330
diff changeset
1496 else:
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1497 specjvms = benchmarks_in_group('specjvm2008')
4335
0d661161fa24 Add possibility to run individual DaCapo & SPECjvm2008 benchmarks, small fix in success and score regular expressions for SPECjvm2008
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4330
diff changeset
1498 for specjvm in specjvms:
11373
6675167d52b6 fixed specjvm2008 regression in bench command
Doug Simon <doug.simon@oracle.com>
parents: 11372
diff changeset
1499 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120', specjvm])]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1500
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1501 if 'specjbb2005' in args or 'all' in args:
5877
0e54d9bb922d Add SPECjbb2005 to the benchmarks
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5875
diff changeset
1502 benchmarks += [sanitycheck.getSPECjbb2005()]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1503
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1504 if 'specjbb2013' in args: # or 'all' in args //currently not in default set
7565
9a521597686b Add SPECjbb2013
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7563
diff changeset
1505 benchmarks += [sanitycheck.getSPECjbb2013()]
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1506
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1507 if 'ctw-full' in args:
9157
a38d748d4130 Add support for the 'optimized' build in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9130
diff changeset
1508 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.Full))
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1509 if 'ctw-noinline' in args:
9157
a38d748d4130 Add support for the 'optimized' build in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9130
diff changeset
1510 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.NoInline))
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1511 if 'ctw-nocomplex' in args:
9157
a38d748d4130 Add support for the 'optimized' build in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9130
diff changeset
1512 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.NoComplex))
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1513
4219
47f7d91d34cf Fix javac build issues with classpath
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4216
diff changeset
1514 for test in benchmarks:
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
1515 for (groupName, res) in test.bench(vm, extraVmOpts=vmArgs).items():
7563
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1516 group = results.setdefault(groupName, {})
3aab15f42934 moved execution of a benchmark out of OutputParser
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
1517 group.update(res)
4282
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1518 mx.log(json.dumps(results))
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1519 if resultFile:
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1520 with open(resultFile, 'w') as f:
063ea022532c mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4276
diff changeset
1521 f.write(json.dumps(results))
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1522
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1523 def _get_jmh_path():
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1524 path = mx.get_env('JMH_BENCHMARKS', None)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1525 if not path:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1526 probe = join(dirname(_graal_home), 'java-benchmarks')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1527 if exists(probe):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1528 path = probe
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1529
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1530 if not path:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1531 mx.abort("Please set the JMH_BENCHMARKS environment variable to point to the java-benchmarks workspace")
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1532 if not exists(path):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1533 mx.abort("The directory denoted by the JMH_BENCHMARKS environment variable does not exist: " + path)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1534 return path
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1535
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1536 def makejmhdeps(args):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1537 """creates and installs Maven dependencies required by the JMH benchmarks
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1538
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1539 The dependencies are specified by files named pom.mxdeps in the
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1540 JMH directory tree. Each such file contains a list of dependencies
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1541 defined in JSON format. For example:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1542
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1543 '[{"artifactId" : "compiler.test", "groupId" : "com.oracle.graal", "deps" : ["com.oracle.graal.compiler.test"]}]'
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1544
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1545 will result in a dependency being installed in the local Maven repository
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1546 that can be referenced in a pom.xml file as follows:
15178
0c53453c4d5e mx: improved jmh command to (a) look for JMH benchmarks in ../java-benchmarks, (b) omit building benchmarks if they are up to date and (c) offer better message with 'mx help jmh'
Doug Simon <doug.simon@oracle.com>
parents: 15114
diff changeset
1547
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1548 <dependency>
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1549 <groupId>com.oracle.graal</groupId>
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1550 <artifactId>compiler.test</artifactId>
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1551 <version>1.0-SNAPSHOT</version>
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1552 </dependency>"""
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1553
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1554 parser = ArgumentParser(prog='mx makejmhdeps')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1555 parser.add_argument('-s', '--settings', help='alternative path for Maven user settings file', metavar='<path>')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1556 parser.add_argument('-p', '--permissive', action='store_true', help='issue note instead of error if a Maven dependency cannot be built due to missing projects/libraries')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1557 args = parser.parse_args(args)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1558
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1559 def makejmhdep(artifactId, groupId, deps):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1560 graalSuite = mx.suite("graal")
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1561 path = artifactId + '.jar'
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1562 if args.permissive:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1563 for name in deps:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1564 if not mx.project(name, fatalIfMissing=False):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1565 if not mx.library(name, fatalIfMissing=False):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1566 mx.log('Skipping ' + groupId + '.' + artifactId + '.jar as ' + name + ' cannot be resolved')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1567 return
15819
2460aed6c899 mx: add support for setting a main class in distributions
Bernhard Urban <bernhard.urban@jku.at>
parents: 15805
diff changeset
1568 d = mx.Distribution(graalSuite, name=artifactId, path=path, sourcesPath=path, deps=deps, mainClass=None, excludedDependencies=[], distDependencies=[])
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1569 d.make_archive()
15253
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1570 cmd = ['mvn', 'install:install-file', '-DgroupId=' + groupId, '-DartifactId=' + artifactId,
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1571 '-Dversion=1.0-SNAPSHOT', '-Dpackaging=jar', '-Dfile=' + d.path]
15253
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1572 if not mx._opts.verbose:
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1573 cmd.append('-q')
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1574 if args.settings:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1575 cmd = cmd + ['-s', args.settings]
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1576 mx.run(cmd)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1577 os.unlink(d.path)
15178
0c53453c4d5e mx: improved jmh command to (a) look for JMH benchmarks in ../java-benchmarks, (b) omit building benchmarks if they are up to date and (c) offer better message with 'mx help jmh'
Doug Simon <doug.simon@oracle.com>
parents: 15114
diff changeset
1578
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1579 jmhPath = _get_jmh_path()
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1580 for root, _, filenames in os.walk(jmhPath):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1581 for f in [join(root, n) for n in filenames if n == 'pom.mxdeps']:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1582 mx.logv('[processing ' + f + ']')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1583 try:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1584 with open(f) as fp:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1585 for d in json.load(fp):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1586 artifactId = d['artifactId']
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1587 groupId = d['groupId']
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1588 deps = d['deps']
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1589 makejmhdep(artifactId, groupId, deps)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1590 except ValueError as e:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1591 mx.abort('Error parsing {}:\n{}'.format(f, e))
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1592
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1593 def buildjmh(args):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1594 """build the JMH benchmarks"""
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1595
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1596 parser = ArgumentParser(prog='mx buildjmh')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1597 parser.add_argument('-s', '--settings', help='alternative path for Maven user settings file', metavar='<path>')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1598 parser.add_argument('-c', action='store_true', dest='clean', help='clean before building')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1599 args = parser.parse_args(args)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1600
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1601 jmhPath = _get_jmh_path()
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1602 mx.log('JMH benchmarks: ' + jmhPath)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1603
15253
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1604 # Ensure the mx injected dependencies are up to date
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1605 makejmhdeps(['-p'] + (['-s', args.settings] if args.settings else []))
9ff9f6643986 mx: unconditionally ensure mx injected dependencies are up to date in buildjmh command
Doug Simon <doug.simon@oracle.com>
parents: 15250
diff changeset
1606
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1607 timestamp = mx.TimeStampFile(join(_graal_home, 'mx', 'jmh', jmhPath.replace(os.sep, '_') + '.timestamp'))
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1608 mustBuild = args.clean
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1609 if not mustBuild:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1610 try:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1611 hgfiles = [join(jmhPath, f) for f in subprocess.check_output(['hg', '-R', jmhPath, 'locate']).split('\n')]
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1612 mustBuild = timestamp.isOlderThan(hgfiles)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1613 except:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1614 # not a Mercurial repository or hg commands are not available.
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1615 mustBuild = True
15178
0c53453c4d5e mx: improved jmh command to (a) look for JMH benchmarks in ../java-benchmarks, (b) omit building benchmarks if they are up to date and (c) offer better message with 'mx help jmh'
Doug Simon <doug.simon@oracle.com>
parents: 15114
diff changeset
1616
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1617 if mustBuild:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1618 buildOutput = []
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1619 def _redirect(x):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1620 if mx._opts.verbose:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1621 mx.log(x[:-1])
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1622 else:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1623 buildOutput.append(x)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1624 env = os.environ.copy()
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1625 env['JAVA_HOME'] = _jdk(vmToCheck='server')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1626 env['MAVEN_OPTS'] = '-server'
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1627 mx.log("Building benchmarks...")
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1628 cmd = ['mvn']
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1629 if args.settings:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1630 cmd = cmd + ['-s', args.settings]
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1631 if args.clean:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1632 cmd.append('clean')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1633 cmd.append('package')
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1634 retcode = mx.run(cmd, cwd=jmhPath, out=_redirect, env=env, nonZeroIsFatal=False)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1635 if retcode != 0:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1636 mx.log(''.join(buildOutput))
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1637 mx.abort(retcode)
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1638 timestamp.touch()
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1639 else:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1640 mx.logv('[all Mercurial controlled files in ' + jmhPath + ' are older than ' + timestamp.path + ' - skipping build]')
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1641
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1642 def jmh(args):
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1643 """run the JMH benchmarks
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1644
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1645 This command respects the standard --vm and --vmbuild options
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1646 for choosing which VM to run the benchmarks with."""
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1647 if '-h' in args:
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1648 mx.help_(['jmh'])
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1649 mx.abort(1)
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1650
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1651 vmArgs, benchmarksAndJsons = _extract_VM_args(args)
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1652
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1653 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')]
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1654 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')]
15593
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1655 jmhOutDir = join(_graal_home, 'mx', 'jmh')
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1656 if not exists(jmhOutDir):
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1657 os.makedirs(jmhOutDir)
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1658 jmhOut = join(jmhOutDir, 'jmh.out')
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1659 jmhArgs = {'-rff' : jmhOut, '-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'}
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1660
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1661 # e.g. '{"-wi" : 20}'
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1662 for j in jmhArgJsons:
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1663 try:
15051
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1664 for n, v in json.loads(j).iteritems():
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1665 if v is None:
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1666 del jmhArgs[n]
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1667 else:
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1668 jmhArgs[n] = v
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1669 except ValueError as e:
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1670 mx.abort('error parsing JSON input: {}\n{}'.format(j, e))
14965
c64cd1dd4bd1 moved Maven installation of Graal dependency from build to jmh command
Doug Simon <doug.simon@oracle.com>
parents: 14938
diff changeset
1671
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1672 jmhPath = _get_jmh_path()
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
1673 mx.log('Using benchmarks in ' + jmhPath)
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1674
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1675 matchedSuites = set()
13949
f694daada5bf mx jmh: display the number of benchmarks that will run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13948
diff changeset
1676 numBench = [0]
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1677 for micros in os.listdir(jmhPath):
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1678 absoluteMicro = os.path.join(jmhPath, micros)
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1679 if not os.path.isdir(absoluteMicro):
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1680 continue
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1681 if not micros.startswith("micros-"):
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1682 mx.logv('JMH: ignored ' + absoluteMicro + " because it doesn't start with 'micros-'")
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1683 continue
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1684
13948
69928d77bc0a mx jmh: avoid mx crash if JMH_BENCHMARKS is not defined at all and skip suites that do not contain the correct jar
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13935
diff changeset
1685 microJar = os.path.join(absoluteMicro, "target", "microbenchmarks.jar")
69928d77bc0a mx jmh: avoid mx crash if JMH_BENCHMARKS is not defined at all and skip suites that do not contain the correct jar
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13935
diff changeset
1686 if not exists(microJar):
15593
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1687 mx.log('Missing ' + microJar + ' - please run "mx buildjmh"')
e381346a8223 JMH: do not abort on missing jar file. Create necessary output directory if needed
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15580
diff changeset
1688 continue
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1689 if benchmarks:
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1690 def _addBenchmark(x):
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1691 if x.startswith("Benchmark:"):
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1692 return
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1693 match = False
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1694 for b in benchmarks:
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1695 match = match or (b in x)
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1696
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1697 if match:
13949
f694daada5bf mx jmh: display the number of benchmarks that will run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13948
diff changeset
1698 numBench[0] += 1
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1699 matchedSuites.add(micros)
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1700
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
1701 mx.run_java(['-jar', microJar, "-l"], cwd=jmhPath, out=_addBenchmark, addDefaultArgs=False)
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1702 else:
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1703 matchedSuites.add(micros)
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1704
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1705 mx.logv("matchedSuites: " + str(matchedSuites))
13949
f694daada5bf mx jmh: display the number of benchmarks that will run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13948
diff changeset
1706 plural = 's' if not benchmarks or numBench[0] > 1 else ''
f694daada5bf mx jmh: display the number of benchmarks that will run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13948
diff changeset
1707 number = str(numBench[0]) if benchmarks else "all"
f694daada5bf mx jmh: display the number of benchmarks that will run
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13948
diff changeset
1708 mx.log("Running " + number + " benchmark" + plural + '...')
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1709
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1710 regex = []
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1711 if benchmarks:
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1712 regex.append(r".*(" + "|".join(benchmarks) + ").*")
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1713
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1714 for suite in matchedSuites:
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1715 absoluteMicro = os.path.join(jmhPath, suite)
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
1716 (pfx, exe, vm, forkedVmArgs, _) = _parseVmArgs(vmArgs)
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
1717 if pfx:
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
1718 mx.warn("JMH ignores prefix: \"" + pfx + "\"")
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1719 javaArgs = ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"),
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1720 '--jvm', exe,
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1721 '--jvmArgs', ' '.join(["-" + vm] + forkedVmArgs)]
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1722 for k, v in jmhArgs.iteritems():
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1723 javaArgs.append(k)
15051
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1724 if len(str(v)):
2df054b37edc add support for removing default JMH args (e.g., '{"-wi" : null, "-i" : null}')
Doug Simon <doug.simon@oracle.com>
parents: 15048
diff changeset
1725 javaArgs.append(str(v))
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
1726 mx.run_java(javaArgs + regex, addDefaultArgs=False, cwd=jmhPath)
13935
ca0e1af320f6 mx: add support for jmh benchmark suites
Bernhard Urban <bernhard.urban@jku.at>
parents: 13928
diff changeset
1727
4228
e872562f95f8 add a simple specjvm2008 command, fail a benchmark if one of the failureRE matches
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4227
diff changeset
1728 def specjvm2008(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
1729 """run one or more SPECjvm2008 benchmarks"""
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1730
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
1731 def launcher(bm, harnessArgs, extraVmOpts):
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
1732 return sanitycheck.getSPECjvm2008(harnessArgs + [bm]).bench(_get_vm(), extraVmOpts=extraVmOpts)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1733
11372
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1734 availableBenchmarks = set(sanitycheck.specjvm2008Names)
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1735 for name in sanitycheck.specjvm2008Names:
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1736 parts = name.rsplit('.', 1)
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1737 if len(parts) > 1:
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1738 assert len(parts) == 2
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1739 group = parts[0]
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1740 availableBenchmarks.add(group)
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1741
76c45fb64191 added support to the specjvm2008 command for specifying a benchmark group
Doug Simon <doug.simon@oracle.com>
parents: 11371
diff changeset
1742 _run_benchmark(args, sorted(availableBenchmarks), launcher)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1743
8147
9786ac8fff61 Use different vm args for SPECjbb2013
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8135
diff changeset
1744 def specjbb2013(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
1745 """runs the composite SPECjbb2013 benchmark"""
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1746
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
1747 def launcher(bm, harnessArgs, extraVmOpts):
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
1748 assert bm is None
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
1749 return sanitycheck.getSPECjbb2013(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1750
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
1751 _run_benchmark(args, None, launcher)
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1752
8506
c3657d00e343 -Merge with tip
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8406
diff changeset
1753 def specjbb2005(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
1754 """runs the composite SPECjbb2005 benchmark"""
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1755
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
1756 def launcher(bm, harnessArgs, extraVmOpts):
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
1757 assert bm is None
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
1758 return sanitycheck.getSPECjbb2005(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1759
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
1760 _run_benchmark(args, None, launcher)
8506
c3657d00e343 -Merge with tip
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8406
diff changeset
1761
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1762 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
1763 """download the hsdis library
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1764
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1765 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
1766 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
1767 flavor = 'intel'
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1768 if 'att' in args:
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
1769 flavor = 'att'
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
1770 lib = mx.add_lib_suffix('hsdis-' + _arch())
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1771 path = join(_graal_home, 'lib', lib)
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
1772 if not exists(path):
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
1773 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavor + "/" + lib])
5596
e4b1bc5e29e0 hsdis library is downloaded into newly created Graal JDK
Doug Simon <doug.simon@oracle.com>
parents: 5517
diff changeset
1774 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
1775 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
1776
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1777 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
1778 """disassemble HexCodeFiles embedded in text files
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1779
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1780 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
1781 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
1782
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1783 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
1784 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
1785 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
1786
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
1787 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
1788
6278
4f9574b2893e removed dependence on private java.lang.String internals in HexCodeFile
Doug Simon <doug.simon@oracle.com>
parents: 6276
diff changeset
1789 path = join(_graal_home, 'lib', 'hcfdis-1.jar')
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1790 if not exists(path):
6278
4f9574b2893e removed dependence on private java.lang.String internals in HexCodeFile
Doug Simon <doug.simon@oracle.com>
parents: 6276
diff changeset
1791 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-1.jar'])
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
1792 mx.run_java(['-jar', path] + args.files)
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1793
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
1794 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
1795 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
1796 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
1797 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
1798 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
1799 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
1800 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
1801 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
1802 address, symbol = addressAndSymbol
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
1803 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
1804 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
1805 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
1806 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
1807 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
1808 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
1809 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
1810 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
1811 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
1812 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
1813 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
1814 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
1815 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
1816 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
1817 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
1818 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
1819 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
1820 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
1821 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
1822 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
1823 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
1824 print >> fp, l
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
1825
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1826 def jacocoreport(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
1827 """create a JaCoCo coverage report
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1828
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1829 Creates the report from the 'jacoco.exec' file in the current directory.
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1830 Default output directory is 'coverage', but an alternative can be provided as an argument."""
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1831 jacocoreport = mx.library("JACOCOREPORT", True)
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1832 out = 'coverage'
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1833 if len(args) == 1:
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1834 out = args[0]
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1835 elif len(args) > 1:
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
1836 mx.abort('jacocoreport takes only one argument : an output directory')
15913
67e0015b21d6 Use new jacocoreport version
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15907
diff changeset
1837 mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + [p.dir for p in mx.projects()])
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
1838
11867
952ecf32788a mx sl command.
Chris Seaton <chris.seaton@oracle.com>
parents: 11797
diff changeset
1839 def sl(args):
12693
c6b833f7935e mx sl: change vm args syntax
Andreas Woess <andreas.woess@jku.at>
parents: 12647
diff changeset
1840 """run an SL program"""
c6b833f7935e mx sl: change vm args syntax
Andreas Woess <andreas.woess@jku.at>
parents: 12647
diff changeset
1841 vmArgs, slArgs = _extract_VM_args(args)
13761
7c418666c6c9 Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13695
diff changeset
1842 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl"), "com.oracle.truffle.sl.SLMain"] + slArgs)
11867
952ecf32788a mx sl command.
Chris Seaton <chris.seaton@oracle.com>
parents: 11797
diff changeset
1843
9803
8e33b4ebfef1 add isGraalEnabled(vm) function in commands.py
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9667
diff changeset
1844 def isGraalEnabled(vm):
8e33b4ebfef1 add isGraalEnabled(vm) function in commands.py
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9667
diff changeset
1845 return vm != 'original' and not vm.endswith('nograal')
8e33b4ebfef1 add isGraalEnabled(vm) function in commands.py
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9667
diff changeset
1846
5700
12a34d1bcaa2 added site command to generate a javadoc-based website
Doug Simon <doug.simon@oracle.com>
parents: 5688
diff changeset
1847 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
1848 """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
1849
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5764
diff changeset
1850 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
1851 '--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
1852 '--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
1853 '--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
1854 '--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
1855 '--jd', '@-tag', '--jd', '@vmoption:X',
5771
613a3ddb9a71 moved core site functionality into mx.py
Doug Simon <doug.simon@oracle.com>
parents: 5764
diff changeset
1856 '--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
1857 '--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
1858 '--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
1859
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1860 def generateZshCompletion(args):
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1861 """generate zsh completion for mx"""
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1862 try:
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1863 from genzshcomp import CompletionGenerator
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1864 except ImportError:
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1865 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
1866
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1867 # 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
1868 originalModule = mx._argParser.__module__
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1869 mx._argParser.__module__ = "argparse"
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1870 generator = CompletionGenerator("mx", mx._argParser)
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1871 mx._argParser.__module__ = originalModule
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1872
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1873 # 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
1874 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
1875
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1876 # 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
1877 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
1878 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
1879 complt += '\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1880 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
1881 complt += '\t(command)\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1882 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
1883 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
1884 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
1885 c, _ = mx._commands[cmd][:2]
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1886 doc = c.__doc__
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1887 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
1888 if doc:
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1889 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
1890 complt += '"\n'
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1891 complt += '\t\t)\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1892 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
1893 complt += '\t\t;;\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1894
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1895 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
1896 # 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
1897 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
1898 complt += '\t\t\t(vm)\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1899 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
1900 complt += '\t\t\t\t\t_arguments -s -S \\\n'
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1901 complt += _appendOptions("graal", r"G\:")
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1902 # 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
1903 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
1904 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
1905 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
1906 complt += '\t\tesac\n'
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1907 complt += '\t\t;;\n'
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1908 complt += 'esac\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1909 complt += '\n'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1910 complt += 'return $ret'
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1911 print complt
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
1912
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1913 def _fixQuotes(arg):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1914 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
1915
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1916 def _appendOptions(optionType, optionPrefix):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1917 def isBoolean(vmap, field):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1918 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
1919
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1920 def hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1921 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
1922
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1923 complt = ""
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1924 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
1925 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
1926 complt += optionPrefix
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1927 if isBoolean(vmap, 'optType'):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1928 complt += '"{-,+}"'
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1929 complt += vmap['optName']
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1930 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
1931 complt += '='
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1932 if hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1933 complt += "["
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1934 if vmap['optDefault']:
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1935 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
1936 if vmap['optDoc']:
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1937 complt += _fixQuotes(vmap['optDoc'])
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1938 if hasDescription(vmap):
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1939 complt += "]"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1940 complt += '" \\\n'
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1941 return complt
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1942
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1943 def _parseVMOptions(optionType):
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1944 parser = OutputParser()
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1945 # 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
1946 # 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
1947 jvmOptions = re.compile(
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1948 r"^[ \t]*"
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1949 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
1950 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
1951 r"[ \t]+=[ \t]*"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1952 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
1953 r"[ \t]*"
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1954 r"(?P<optDoc>.+)?",
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1955 re.MULTILINE)
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1956 parser.addMatcher(ValuesMatcher(jvmOptions, {
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1957 'optType' : '<optType>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1958 'optName' : '<optName>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1959 'optDefault' : '<optDefault>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1960 'optDoc' : '<optDoc>',
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1961 }))
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1962
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1963 # gather graal options
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1964 output = StringIO.StringIO()
13509
a8831418ff04 mx: add completion support for hotspot options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13508
diff changeset
1965 vm(['-XX:-BootstrapGraal', '-G:+PrintFlags' if optionType == "graal" else '-XX:+PrintFlagsWithComments'],
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
1966 vm="graal",
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
1967 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
1968 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
1969 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
1970 err=subprocess.STDOUT)
13508
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1971
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1972 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
1973 return valueMap
8a5b39d0bfb5 mx: add completion support for graal options (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13507
diff changeset
1974
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1975 def findbugs(args):
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1976 '''run FindBugs against non-test Java projects'''
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1977 findBugsHome = mx.get_env('FINDBUGS_HOME', None)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1978 if findBugsHome:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1979 findbugsJar = join(findBugsHome, 'lib', 'findbugs.jar')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1980 else:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1981 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
1982 if not exists(findbugsLib):
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1983 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
1984 try:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1985 findbugsDist = join(tmp, 'findbugs.zip')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1986 mx.download(findbugsDist, ['http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0-dev-20131204-e3cbbd5.zip'])
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1987 with zipfile.ZipFile(findbugsDist) as zf:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1988 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
1989 assert len(candidates) == 1, candidates
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1990 libDirInZip = os.path.dirname(candidates[0])
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1991 zf.extractall(tmp)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1992 shutil.copytree(join(tmp, libDirInZip), findbugsLib)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1993 finally:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1994 shutil.rmtree(tmp)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1995 findbugsJar = join(findbugsLib, 'findbugs.jar')
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1996 assert exists(findbugsJar)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1997 nonTestProjects = [p for p in mx.projects() if not p.name.endswith('.test') and not p.name.endswith('.jtt')]
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1998 outputDirs = [p.output_dir() for p in nonTestProjects]
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
1999 findbugsResults = join(_graal_home, 'findbugs.results')
14769
141d570b397c fixed pylint errors
Doug Simon <doug.simon@oracle.com>
parents: 14767
diff changeset
2000
14777
10c6700908ef mx: removed use of exclusion filter files from findbugs command
Doug Simon <doug.simon@oracle.com>
parents: 14773
diff changeset
2001 cmd = ['-jar', findbugsJar, '-textui', '-low', '-maxRank', '15']
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
2002 if sys.stdout.isatty():
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
2003 cmd.append('-progress')
14872
e6ce6d9f477f made findbugs quiet if running headless
Doug Simon <doug.simon@oracle.com>
parents: 14780
diff changeset
2004 cmd = cmd + ['-auxclasspath', mx.classpath([p.name for p in nonTestProjects]), '-output', findbugsResults, '-exitcode'] + args + outputDirs
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
2005 exitcode = mx.run_java(cmd, nonZeroIsFatal=False)
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2006 if exitcode != 0:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2007 with open(findbugsResults) as fp:
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2008 mx.log(fp.read())
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2009 os.unlink(findbugsResults)
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2010 return exitcode
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
2011
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2012 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
2013 """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
2014 failures = {}
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2015 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
2016 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
2017 continue
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2018
14918
31a9c79399c8 disabled current Checkstyle configurations (until Checkstyle supports Java8)
Doug Simon <doug.simon@oracle.com>
parents: 14905
diff changeset
2019 csConfig = join(mx.project(p.checkstyleProj).dir, '.checkstyle_checks.xml.disabled')
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2020 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
2021 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
2022 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
2023 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
2024 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
2025 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
2026 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
2027 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
2028 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
2029 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
2030 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
2031 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
2032 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
2033 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
2034 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
2035 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
2036 for n, v in failures.iteritems():
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2037 mx.log('{}: header does not match RegexpHeader defined in {}'.format(n, v))
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2038 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
2039
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
2040 def mx_init(suite):
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2041 commands = {
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
2042 'build': [build, ''],
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
2043 'buildjmh': [buildjmh, '[-options]'],
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
2044 'buildvars': [buildvars, ''],
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
2045 'buildvms': [buildvms, '[-options]'],
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
2046 'c1visualizer' : [c1visualizer, ''],
14772
c929a4a3b6c5 added checkheaders command for checking Java source headers without relying on Checkstyle
Doug Simon <doug.simon@oracle.com>
parents: 14769
diff changeset
2047 '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
2048 'clean': [clean, ''],
14546
942c4daa9db9 added findbugs command to mx
Doug Simon <doug.simon@oracle.com>
parents: 14164
diff changeset
2049 'findbugs': [findbugs, ''],
13507
d3ec6003856d mx: experimental autocompletion generation for zsh (GRAAL-297)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13486
diff changeset
2050 'generateZshCompletion' : [generateZshCompletion, ''],
4482
7903b6c28f9c Add hsdis command to mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4480
diff changeset
2051 'hsdis': [hsdis, '[att]'],
5245
71ac4221b1b0 added hcfdis command
Doug Simon <doug.simon@oracle.com>
parents: 5244
diff changeset
2052 'hcfdis': [hcfdis, ''],
5089
206e68bb66c6 Made the IdealGraphVisualizer runnable from mx with new 'igv' command.
Doug Simon <doug.simon@oracle.com>
parents: 5064
diff changeset
2053 'igv' : [igv, ''],
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
2054 'jdkhome': [print_jdkhome, ''],
15021
9dcd5407a603 added support for overriding/complementing JMH arguments in jmh command with a JSON string
Doug Simon <doug.simon@oracle.com>
parents: 15014
diff changeset
2055 'jmh': [jmh, '[VM options] [filters|JMH-args-as-json...]'],
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
2056 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'],
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
2057 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'],
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
2058 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'],
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
2059 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'],
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
2060 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
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
2061 'gate' : [gate, '[-options]'],
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
2062 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
2063 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
15250
4c68a0eb69ca mx: refactored JMH benchmark building and dependency creation out of 'jmh' into 'buildjmh' and 'makejmhdeps' respectively
Doug Simon <doug.simon@oracle.com>
parents: 15229
diff changeset
2064 'makejmhdeps' : [makejmhdeps, ''],
15113
4da162518b39 mx: add unittest options.
Josef Eisl <josef.eisl@jku.at>
parents: 15057
diff changeset
2065 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
4684
e136f2d0d002 Activate jtt for the gate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4660
diff changeset
2066 'jacocoreport' : [jacocoreport, '[output directory]'],
5700
12a34d1bcaa2 added site command to generate a javadoc-based website
Doug Simon <doug.simon@oracle.com>
parents: 5688
diff changeset
2067 'site' : [site, '[-options]'],
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
2068 'vm': [vm, '[-options] class [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
2069 'vmg': [vmg, '[-options] class [args...]'],
6340
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
2070 'vmfg': [vmfg, '[-options] class [args...]'],
74560fdffd51 Add a draft longtests command to mc's commands
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6319
diff changeset
2071 'deoptalot' : [deoptalot, '[n]'],
11867
952ecf32788a mx sl command.
Chris Seaton <chris.seaton@oracle.com>
parents: 11797
diff changeset
2072 'longtests' : [longtests, ''],
15576
0c0b479903bb mx trufflejar: use distribution feature of mx instead (`mx archive @TRUFFLE')
Bernhard Urban <bernhard.urban@jku.at>
parents: 15575
diff changeset
2073 'sl' : [sl, '[SL args|@VM options]']
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2074 }
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
2075
5064
8a88c903e381 Updated mx commands.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5047
diff changeset
2076 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2077 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>')
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2078 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' +
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2079 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' +
11493
94779c895aad fixed documentation of --installed-jdks mx option
Doug Simon <doug.simon@oracle.com>
parents: 11424
diff changeset
2080 join('<path>', '<jdk-version>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>')
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
2081
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
2082 if _vmSourcesAvailable:
11371
74414b248381 mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
Doug Simon <doug.simon@oracle.com>
parents: 11368
diff changeset
2083 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run')
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
2084 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] + ')')
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
2085 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2086 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>')
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2087 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"')
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
2088
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
2089 commands.update({
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
2090 'export': [export, '[-options] [zipfile]'],
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
2091 })
5729
dab877fe7c31 prevented error during mx site from corrupting an existing site
Doug Simon <doug.simon@oracle.com>
parents: 5708
diff changeset
2092
11605
3676540f71cf Allow mxtool suites to be in separate repositories (CR-1367)
Mick Jordan <mick.jordan@oracle.com>
parents: 11534
diff changeset
2093 mx.update_commands(suite, commands)
4144
34527a24bcf8 Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents: 3736
diff changeset
2094
11514
dc3c8df55905 added support for pylint and fixed errors/warnings it found
Doug Simon <doug.simon@oracle.com>
parents: 11512
diff changeset
2095 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
2096 # 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
2097 if mx.java().version < _minVersion:
7916
9bff64f43299 Better java version numbers support in mx
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7788
diff changeset
2098 mx.abort('Requires Java version ' + str(_minVersion) + ' or greater, 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
2099
13967
4cd7c6629841 mx_graal: fix pylint 1.1.0 warnings
Bernhard Urban <bernhard.urban@jku.at>
parents: 13952
diff changeset
2100 if _vmSourcesAvailable:
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
2101 if hasattr(opts, 'vm') and opts.vm is not None:
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
2102 global _vm
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4540
diff changeset
2103 _vm = opts.vm
4216
a13d61d3910e fix for when no vm build is explicitely selected
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents: 4215
diff changeset
2104 if hasattr(opts, 'vmbuild') and opts.vmbuild is not None:
4178
d1b26c17910a Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4177
diff changeset
2105 global _vmbuild
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
2106 _vmbuild = opts.vmbuild
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
2107 global _make_eclipse_launch
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
2108 _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False)
5024
7ccdae96e98a Allow JaCoCon to append to the execution file
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5016
diff changeset
2109 global _jacoco
7ccdae96e98a Allow JaCoCon to append to the execution file
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5016
diff changeset
2110 _jacoco = opts.jacoco
11401
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2111 global _vm_cwd
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2112 _vm_cwd = opts.vm_cwd
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2113 global _installed_jdks
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2114 _installed_jdks = opts.installed_jdks
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2115 global _vm_prefix
2d228d304247 minor improvements/cleanups to mx (CR-1313)
Doug Simon <doug.simon@oracle.com>
parents: 11395
diff changeset
2116 _vm_prefix = opts.vm_prefix
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
2117
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
2118 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks)