Mercurial > hg > truffle
comparison mx/commands.py @ 4559:723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Use the --vm option instead of a special -vm option in the bench command
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 10 Feb 2012 17:04:03 +0100 |
parents | f1d3800b59e1 |
children | 76841bdd5f3e |
comparison
equal
deleted
inserted
replaced
4558:3706975946e4 | 4559:723df37192d6 |
---|---|
286 src = join(srcJdk, d) | 286 src = join(srcJdk, d) |
287 dst = join(jdk, d) | 287 dst = join(jdk, d) |
288 if not exists(src): | 288 if not exists(src): |
289 mx.abort('Host JDK directory is missing: ' + src) | 289 mx.abort('Host JDK directory is missing: ' + src) |
290 shutil.copytree(src, dst) | 290 shutil.copytree(src, dst) |
291 | |
292 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | |
293 found = False | |
294 if not exists(jvmCfg): | |
295 mx.abort(jvmCfg + ' does not exist') | |
296 | |
297 with open(jvmCfg) as f: | |
298 for line in f: | |
299 if '-graal KNOWN' in line: | |
300 found = True | |
301 break | |
302 if not found: | |
303 mx.log('Appending "-graal KNOWN" to ' + jvmCfg) | |
304 with open(jvmCfg, 'a') as f: | |
305 f.write('-graal KNOWN\n') | |
306 | 291 |
307 if build == 'product': | 292 if build == 'product': |
308 return jdk | 293 return jdk |
309 elif build in ['debug', 'fastdebug']: | 294 elif build in ['debug', 'fastdebug']: |
310 res = join(jdk, build) | 295 res = join(jdk, build) |
359 | 344 |
360 def build(args): | 345 def build(args): |
361 """builds the GraalVM binary and compiles the Graal classes | 346 """builds the GraalVM binary and compiles the Graal classes |
362 | 347 |
363 The optional last argument specifies what type of VM to build.""" | 348 The optional last argument specifies what type of VM to build.""" |
364 | |
365 | |
366 parser = ArgumentParser(prog='mx build'); | |
367 parser.add_argument('--vm', action='store', dest='vm', default='graal', choices=['graal', 'server', 'client'], help='the VM to be built') | |
368 | 349 |
369 # Call mx.build to compile the Java sources | 350 # Call mx.build to compile the Java sources |
370 opts = mx.build(['--source', '1.7'] + args, parser=parser) | 351 opts2 = mx.build(['--source', '1.7'] + args, parser=ArgumentParser(prog='mx build')) |
371 | 352 |
372 if not _vmSourcesAvailable or not opts.native: | 353 if not _vmSourcesAvailable or not opts2.native: |
373 return | 354 return |
374 | 355 |
375 builds = opts.remainder | 356 builds = opts2.remainder |
376 if len(builds) == 0: | 357 if len(builds) == 0: |
377 builds = ['product'] | 358 builds = ['product'] |
378 | 359 |
379 vm = opts.vm | 360 vm = _vm |
380 if vm == 'server': | 361 if vm == 'server': |
381 buildSuffix = '' | 362 buildSuffix = '' |
382 elif vm == 'client': | 363 elif vm == 'client': |
383 buildSuffix = '1' | 364 buildSuffix = '1' |
384 else: | 365 else: |
385 assert vm is 'graal' | 366 assert vm == 'graal', vm |
386 buildSuffix = 'graal' | 367 buildSuffix = 'graal' |
387 | 368 |
388 for build in builds: | 369 for build in builds: |
389 | 370 |
390 jdk = _jdk(build, True) | 371 jdk = _jdk(build, True) |
422 env.setdefault('LANG', 'C') | 403 env.setdefault('LANG', 'C') |
423 env.setdefault('HOTSPOT_BUILD_JOBS', '3') | 404 env.setdefault('HOTSPOT_BUILD_JOBS', '3') |
424 env['ALT_BOOTDIR'] = jdk | 405 env['ALT_BOOTDIR'] = jdk |
425 env.setdefault('INSTALL', 'y') | 406 env.setdefault('INSTALL', 'y') |
426 mx.run([mx.gmake_cmd(), build + buildSuffix], cwd=join(_graal_home, 'make'), err=filterXusage) | 407 mx.run([mx.gmake_cmd(), build + buildSuffix], cwd=join(_graal_home, 'make'), err=filterXusage) |
408 | |
409 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | |
410 found = False | |
411 if not exists(jvmCfg): | |
412 mx.abort(jvmCfg + ' does not exist') | |
413 | |
414 prefix = '-' + vm | |
415 vmKnown = prefix + ' KNOWN\n' | |
416 lines = [] | |
417 with open(jvmCfg) as f: | |
418 for line in f: | |
419 if vmKnown in line: | |
420 found = True | |
421 break | |
422 if not line.startswith(prefix): | |
423 lines.append(line) | |
424 if not found: | |
425 mx.log('Appending "' + prefix + ' KNOWN" to ' + jvmCfg) | |
426 lines.append(vmKnown) | |
427 with open(jvmCfg, 'w') as f: | |
428 for line in lines: | |
429 f.write(line) | |
427 | 430 |
428 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): | 431 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): |
429 """run the GraalVM""" | 432 """run the GraalVM""" |
430 | 433 |
431 if vm is None: | 434 if vm is None: |
603 resultFile = args[index + 1] | 606 resultFile = args[index + 1] |
604 del args[index] | 607 del args[index] |
605 del args[index] | 608 del args[index] |
606 else: | 609 else: |
607 mx.abort('-resultfile must be followed by a file name') | 610 mx.abort('-resultfile must be followed by a file name') |
608 vm = 'graal' | 611 vm = _vm |
609 if '-vm' in args: | |
610 index = args.index('-vm') | |
611 if index + 1 < len(args): | |
612 vm = args[index + 1] | |
613 del args[index] | |
614 del args[index] | |
615 else: | |
616 mx.abort('-vm must be followed by a vm name (graal, server, client..)') | |
617 if len(args) is 0: | 612 if len(args) is 0: |
618 args += ['all'] | 613 args += ['all'] |
619 | 614 |
620 results = {} | 615 results = {} |
621 benchmarks = [] | 616 benchmarks = [] |
713 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], | 708 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], |
714 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'], | 709 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'], |
715 'example': [example, '[-v] example names...'], | 710 'example': [example, '[-v] example names...'], |
716 'gate' : [gate, ''], | 711 'gate' : [gate, ''], |
717 'gv' : [gv, ''], | 712 'gv' : [gv, ''], |
718 'bench' : [bench, '[-vm vm] [-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], | 713 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
719 'unittest' : [unittest, '[filters...]'], | 714 'unittest' : [unittest, '[filters...]'], |
720 'vm': [vm, '[-options] class [args...]'] | 715 'vm': [vm, '[-options] class [args...]'] |
721 } | 716 } |
722 | 717 |
723 if (_vmSourcesAvailable): | 718 if (_vmSourcesAvailable): |
741 major = int(parts[1]) | 736 major = int(parts[1]) |
742 if not major >= 7: | 737 if not major >= 7: |
743 mx.abort('Requires Java version 1.7 or greater, got version ' + version) | 738 mx.abort('Requires Java version 1.7 or greater, got version ' + version) |
744 | 739 |
745 if (_vmSourcesAvailable): | 740 if (_vmSourcesAvailable): |
746 global _vm | 741 if hasattr(opts, 'vm') and opts.vm is not None: |
747 _vm = opts.vm | 742 global _vm |
743 _vm = opts.vm | |
748 if hasattr(opts, 'vmbuild') and opts.vmbuild is not None: | 744 if hasattr(opts, 'vmbuild') and opts.vmbuild is not None: |
749 global _vmbuild | 745 global _vmbuild |
750 _vmbuild = opts.vmbuild | 746 _vmbuild = opts.vmbuild |