Mercurial > hg > graal-compiler
comparison mx/commands.py @ 10083:8dc4cdde75fb
remove build-graal.xml and have make directly call mx to generate graal.jar
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 18 Jun 2013 18:17:04 +0200 |
parents | 0d378ea2b822 |
children | acc1c61ba408 |
comparison
equal
deleted
inserted
replaced
10082:665e95c28965 | 10083:8dc4cdde75fb |
---|---|
422 """print the JDK directory selected for the 'vm' command""" | 422 """print the JDK directory selected for the 'vm' command""" |
423 | 423 |
424 build = _vmbuild if _vmSourcesAvailable else 'product' | 424 build = _vmbuild if _vmSourcesAvailable else 'product' |
425 print join(_graal_home, 'jdk' + str(mx.java().version), build) | 425 print join(_graal_home, 'jdk' + str(mx.java().version), build) |
426 | 426 |
427 def initantbuild(args): | |
428 """(re)generates an ant build file for producing graal.jar""" | |
429 parser=ArgumentParser(prog='mx initantbuild') | |
430 parser.add_argument('-f', '--buildfile', help='file to generate', default=join(_graal_home, 'make', 'build-graal.xml')) | |
431 | |
432 args = parser.parse_args(args) | |
433 | |
434 out = mx.XMLDoc() | |
435 | |
436 out.comment(""" | |
437 Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
438 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
439 | |
440 This code is free software; you can redistribute it and/or modify it | |
441 under the terms of the GNU General Public License version 2 only, as | |
442 published by the Free Software Foundation. Oracle designates this | |
443 particular file as subject to the "Classpath" exception as provided | |
444 by Oracle in the LICENSE file that accompanied this code. | |
445 | |
446 This code is distributed in the hope that it will be useful, but WITHOUT | |
447 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
448 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
449 version 2 for more details (a copy is included in the LICENSE file that | |
450 accompanied this code). | |
451 | |
452 You should have received a copy of the GNU General Public License version | |
453 2 along with this work; if not, write to the Free Software Foundation, | |
454 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
455 | |
456 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
457 or visit www.oracle.com if you need additional information or have any | |
458 questions. | |
459 """) | |
460 | |
461 out.open('project', {'name' : 'graal', 'default' : 'main', 'basedir' : '.'}) | |
462 out.element('property', {'name' : 'src.dir', 'value' : '${gamma.dir}/graal'}) | |
463 out.element('property', {'name' : 'classes.dir', 'value' : '${shared.dir}/graal'}) | |
464 out.element('property', {'name' : 'jar.dir', 'value' : '${shared.dir}'}) | |
465 out.element('property', {'name' : 'jar.file', 'value' : '${jar.dir}/graal.jar'}) | |
466 | |
467 out.element('target', {'name' : 'main', 'depends' : 'options,jar'}) | |
468 | |
469 serviceMap = {}; | |
470 def addService(service, provider): | |
471 if service not in serviceMap: | |
472 serviceMap[service] = set(); | |
473 serviceMap[service].add(provider) | |
474 | |
475 out.open('target', {'name' : 'compile', 'depends' : 'cleanclasses'}) | |
476 out.element('mkdir', {'dir' : '${classes.dir}'}) | |
477 out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', }) | |
478 | |
479 for p in mx.sorted_deps(mx.distribution('GRAAL').deps): | |
480 out.element('src', {'path' : '${src.dir}/' + p.name}) | |
481 servicesDir = join(p.output_dir(), 'META-INF', 'services') | |
482 if exists(servicesDir): | |
483 for service in os.listdir(servicesDir): | |
484 with open(join(servicesDir, service), 'r') as serviceFile: | |
485 for line in serviceFile: | |
486 addService(service, line.strip()) | |
487 providersDir = join(p.output_dir(), 'META-INF', 'providers') | |
488 if exists(providersDir): | |
489 for provider in os.listdir(providersDir): | |
490 with open(join(providersDir, provider), 'r') as providerFile: | |
491 for line in providerFile: | |
492 addService(line.strip(), provider) | |
493 | |
494 out.element('compilerarg', {'value' : '-XDignore.symbol.file'}) | |
495 | |
496 out.open('classpath') | |
497 out.open('fileset', {'dir' : '${java.home}/../lib'}) | |
498 out.element('include', {'name' : 'tools.jar'}) | |
499 out.close('fileset') | |
500 out.close('classpath') | |
501 | |
502 out.close('javac') | |
503 out.close('target') | |
504 | |
505 out.open('target', {'name' : 'jar', 'depends' : 'compile'}) | |
506 out.element('mkdir', {'dir' : '${jar.dir}'}) | |
507 out.open('jar', {'destfile' : '${jar.file}', 'basedir' : '${classes.dir}'}) | |
508 | |
509 for service in sorted(serviceMap.iterkeys()): | |
510 out.open('service', {'type' : service}) | |
511 for provider in sorted(serviceMap[service]): | |
512 out.element('provider', {'classname' : provider}) | |
513 out.close('service') | |
514 | |
515 out.close('jar'); | |
516 out.close('target') | |
517 | |
518 out.open('target', {'name' : 'cleanclasses'}) | |
519 out.element('delete', {'dir' : '${classes.dir}'}) | |
520 out.close('target') | |
521 | |
522 out.open('target', {'name' : 'options', 'if' : 'graal.options.exists'}) | |
523 out.open('copy', {'todir' : '${jar.dir}'}) | |
524 out.element('filelist', {'dir' : '${gamma.dir}', 'files' : 'graal.options'}) | |
525 out.close('copy') | |
526 out.close('target') | |
527 | |
528 out.open('target', {'name' : 'check-graal-options-exists'}) | |
529 out.element('available', {'property' : 'graal.options.exists', 'file' : '${gamma.dir}/graal.options'}) | |
530 out.close('target') | |
531 | |
532 out.open('target', {'name' : 'clean', 'depends' : 'cleanclasses'}) | |
533 out.element('delete', {'file' : '${jar.file}'}) | |
534 out.close('target') | |
535 | |
536 out.close('project') | |
537 | |
538 return mx.update_file(args.buildfile, out.xml(indent=' ', newl='\n')) | |
539 | |
540 def buildvars(args): | 427 def buildvars(args): |
541 """Describes the variables that can be set by the -D option to the 'mx build' commmand""" | 428 """Describes the variables that can be set by the -D option to the 'mx build' commmand""" |
542 | 429 |
543 buildVars = { | 430 buildVars = { |
544 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.java().jdk + ')', | 431 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.java().jdk + ')', |
565 The optional last argument specifies what build level is to be used | 452 The optional last argument specifies what build level is to be used |
566 for the VM binary.""" | 453 for the VM binary.""" |
567 | 454 |
568 # Call mx.build to compile the Java sources | 455 # Call mx.build to compile the Java sources |
569 parser=ArgumentParser(prog='mx build') | 456 parser=ArgumentParser(prog='mx build') |
457 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') | |
570 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') | 458 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') |
571 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) | 459 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) |
460 | |
461 if opts2.export_dir is not None: | |
462 if not exists(opts2.export_dir): | |
463 os.makedirs(opts2.export_dir) | |
464 else: | |
465 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir) | |
466 | |
467 shutil.copy(mx.distribution('GRAAL').path, opts2.export_dir) | |
468 graalOptions = join(_graal_home, 'graal.options') | |
469 if exists(graalOptions): | |
470 shutil.copy(graalOptions, opts2.export_dir) | |
572 | 471 |
573 if not _vmSourcesAvailable or not opts2.native: | 472 if not _vmSourcesAvailable or not opts2.native: |
574 return | 473 return |
575 | 474 |
576 builds = opts2.remainder | 475 builds = opts2.remainder |
588 buildSuffix = '1' | 487 buildSuffix = '1' |
589 else: | 488 else: |
590 assert vm == 'graal', vm | 489 assert vm == 'graal', vm |
591 buildSuffix = 'graal' | 490 buildSuffix = 'graal' |
592 | 491 |
593 initantbuild([]) | |
594 | |
595 for build in builds: | 492 for build in builds: |
596 if build == 'ide-build-target': | 493 if build == 'ide-build-target': |
597 build = os.environ.get('IDE_BUILD_TARGET', 'product') | 494 build = os.environ.get('IDE_BUILD_TARGET', 'product') |
598 if len(build) == 0: | 495 if len(build) == 0: |
599 mx.log('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]') | 496 mx.log('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]') |
1009 | 906 |
1010 t = Task('BuildJava') | 907 t = Task('BuildJava') |
1011 build(['--no-native', '--jdt-warning-as-error']) | 908 build(['--no-native', '--jdt-warning-as-error']) |
1012 tasks.append(t.stop()) | 909 tasks.append(t.stop()) |
1013 | 910 |
1014 t = Task('Check build-graal.xml') | |
1015 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring make/build-graal.xml file is up to date...')) | |
1016 if initantbuild([]): | |
1017 t.abort('Rerun "mx build" and check-in the modified make/build-graal.xml file.') | |
1018 tasks.append(t.stop()) | |
1019 | |
1020 t = Task('Checkstyle') | 911 t = Task('Checkstyle') |
1021 if mx.checkstyle([]) != 0: | 912 if mx.checkstyle([]) != 0: |
1022 t.abort('Checkstyle warnings were found') | 913 t.abort('Checkstyle warnings were found') |
1023 tasks.append(t.stop()) | 914 tasks.append(t.stop()) |
1024 | 915 |
1382 'buildvars': [buildvars, ''], | 1273 'buildvars': [buildvars, ''], |
1383 'buildvms': [buildvms, '[-options]'], | 1274 'buildvms': [buildvms, '[-options]'], |
1384 'clean': [clean, ''], | 1275 'clean': [clean, ''], |
1385 'hsdis': [hsdis, '[att]'], | 1276 'hsdis': [hsdis, '[att]'], |
1386 'hcfdis': [hcfdis, ''], | 1277 'hcfdis': [hcfdis, ''], |
1387 'initantbuild' : [initantbuild, '[-options]'], | |
1388 'igv' : [igv, ''], | 1278 'igv' : [igv, ''], |
1389 'jdkhome': [jdkhome, ''], | 1279 'jdkhome': [jdkhome, ''], |
1390 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], | 1280 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], |
1391 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], | 1281 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], |
1392 'specjvm2008': [specjvm2008, '[VM options|specjvm2008 options (-v, -ikv, -ict, -wt, -it)]'], | 1282 'specjvm2008': [specjvm2008, '[VM options|specjvm2008 options (-v, -ikv, -ict, -wt, -it)]'], |