Mercurial > hg > graal-compiler
comparison mx/commands.py @ 9116:e2dae636732a
added 'mx buildvars' command to list (some of) the variables that can be passed to 'mx build' with the -D option
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 15 Apr 2013 12:55:46 +0200 |
parents | d766fd8eede0 |
children | cbfcb1054619 |
comparison
equal
deleted
inserted
replaced
9115:79b098d44d20 | 9116:e2dae636732a |
---|---|
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing | 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing |
30 from os.path import join, exists, dirname, basename, getmtime | 30 from os.path import join, exists, dirname, basename, getmtime |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, REMAINDER |
32 import mx | 32 import mx |
33 import sanitycheck | 33 import sanitycheck |
34 import json | 34 import json, textwrap |
35 | 35 |
36 _graal_home = dirname(dirname(__file__)) | 36 _graal_home = dirname(dirname(__file__)) |
37 | 37 |
38 """ Used to distinguish an exported GraalVM (see 'mx export'). """ | 38 """ Used to distinguish an exported GraalVM (see 'mx export'). """ |
39 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) | 39 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) |
528 | 528 |
529 out.close('project') | 529 out.close('project') |
530 | 530 |
531 mx.update_file(args.buildfile, out.xml(indent=' ', newl='\n')) | 531 mx.update_file(args.buildfile, out.xml(indent=' ', newl='\n')) |
532 | 532 |
533 def buildvars(args): | |
534 """Describes the variables that can be set by the -D option to the 'mx build' commmand""" | |
535 | |
536 buildVars = { | |
537 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.java().jdk + ')', | |
538 'ALT_OUTPUTDIR' : 'Build directory', | |
539 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(multiprocessing.cpu_count()) + ')', | |
540 'INSTALL' : 'Install the built VM into the JDK? (default: y)', | |
541 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)', | |
542 'TEST_IN_BUILD' : 'Run the Queens test as part of build (default: false)' | |
543 } | |
544 | |
545 mx.log('HotSpot build variables that can be set by the -D option to "mx build":') | |
546 mx.log('') | |
547 for n in sorted(buildVars.iterkeys()): | |
548 mx.log(n) | |
549 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200)) | |
550 | |
533 def build(args, vm=None): | 551 def build(args, vm=None): |
534 """build the VM binary | 552 """build the VM binary |
535 | 553 |
536 The global '--vm' option selects which VM to build. This command also | 554 The global '--vm' option selects which VM to build. This command also |
537 compiles the Graal classes irrespective of what VM is being built. | 555 compiles the Graal classes irrespective of what VM is being built. |
538 The optional last argument specifies what build level is to be used | 556 The optional last argument specifies what build level is to be used |
539 for the VM binary.""" | 557 for the VM binary.""" |
540 | 558 |
541 # Call mx.build to compile the Java sources | 559 # Call mx.build to compile the Java sources |
542 opts2 = mx.build(['--source', '1.7'] + args, parser=ArgumentParser(prog='mx build')) | 560 parser=ArgumentParser(prog='mx build') |
561 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') | |
562 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) | |
543 | 563 |
544 if not _vmSourcesAvailable or not opts2.native: | 564 if not _vmSourcesAvailable or not opts2.native: |
545 return | 565 return |
546 | 566 |
547 builds = opts2.remainder | 567 builds = opts2.remainder |
631 runCmd = [mx.gmake_cmd()] | 651 runCmd = [mx.gmake_cmd()] |
632 if build == 'debug': | 652 if build == 'debug': |
633 build = 'jvmg' | 653 build = 'jvmg' |
634 runCmd.append(build + buildSuffix) | 654 runCmd.append(build + buildSuffix) |
635 env = os.environ.copy() | 655 env = os.environ.copy() |
656 | |
657 if opts2.D: | |
658 for nv in opts2.D: | |
659 name, value = nv.split('=', 1) | |
660 env[name.strip()] = value | |
661 | |
636 env.setdefault('ARCH_DATA_MODEL', '64') | 662 env.setdefault('ARCH_DATA_MODEL', '64') |
637 env.setdefault('LANG', 'C') | 663 env.setdefault('LANG', 'C') |
638 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) | 664 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) |
639 env['ALT_BOOTDIR'] = mx.java().jdk | 665 env.setdefault('ALT_BOOTDIR', mx.java().jdk) |
640 env['JAVA_HOME'] = jdk | 666 env['JAVA_HOME'] = jdk |
641 if vm.endswith('nograal'): | 667 if vm.endswith('nograal'): |
642 env['OMIT_GRAAL'] = 'true' | 668 env['OMIT_GRAAL'] = 'true' |
643 env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os())) | 669 env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os())) |
644 else: | 670 else: |
1290 | 1316 |
1291 def mx_init(): | 1317 def mx_init(): |
1292 _vmbuild = 'product' | 1318 _vmbuild = 'product' |
1293 commands = { | 1319 commands = { |
1294 'build': [build, '[-options]'], | 1320 'build': [build, '[-options]'], |
1321 'buildvars': [buildvars, ''], | |
1295 'buildvms': [buildvms, '[-options]'], | 1322 'buildvms': [buildvms, '[-options]'], |
1296 'clean': [clean, ''], | 1323 'clean': [clean, ''], |
1297 'hsdis': [hsdis, '[att]'], | 1324 'hsdis': [hsdis, '[att]'], |
1298 'hcfdis': [hcfdis, ''], | 1325 'hcfdis': [hcfdis, ''], |
1299 'initantbuild' : [initantbuild, '[-options]'], | 1326 'initantbuild' : [initantbuild, '[-options]'], |