Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 4226:e03ff10d4bfc
Made the gate clean the Java projects only.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 05 Jan 2012 13:17:15 +0100 |
parents | 339cf8d4904d |
children | 1fe200db8c30 |
comparison
equal
deleted
inserted
replaced
4225:339cf8d4904d | 4226:e03ff10d4bfc |
---|---|
785 except IOError as e: | 785 except IOError as e: |
786 abort('Error while writing to ' + path + ': ' + str(e)); | 786 abort('Error while writing to ' + path + ': ' + str(e)); |
787 | 787 |
788 # Builtin commands | 788 # Builtin commands |
789 | 789 |
790 def build(args): | 790 def build(args, parser=None): |
791 """compile the Java and C sources, linking the latter | 791 """compile the Java and C sources, linking the latter |
792 | 792 |
793 Compile all the Java source code using the appropriate compilers | 793 Compile all the Java source code using the appropriate compilers |
794 and linkers for the various source code types.""" | 794 and linkers for the various source code types.""" |
795 | 795 |
796 parser = ArgumentParser(prog='mx build'); | 796 parser = parser if parser is not None else ArgumentParser(prog='mx build'); |
797 parser.add_argument('-f', action='store_true', dest='force', help='force compilation even if class files are up to date') | 797 parser.add_argument('-f', action='store_true', dest='force', help='force compilation even if class files are up to date') |
798 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') | 798 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
799 parser.add_argument('--source', dest='compliance', help='Java compliance level', default='1.6') | 799 parser.add_argument('--source', dest='compliance', help='Java compliance level', default='1.6') |
800 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') | 800 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
801 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') | |
801 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') | 802 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
802 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='<path>') | 803 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='<path>') |
803 | 804 |
804 args = parser.parse_args(args) | 805 args = parser.parse_args(args) |
805 | 806 |
815 | 816 |
816 built = set() | 817 built = set() |
817 for p in sorted_deps(): | 818 for p in sorted_deps(): |
818 | 819 |
819 if p.native: | 820 if p.native: |
820 log('Calling GNU make {0}...'.format(p.dir)) | 821 if args.native: |
821 | 822 log('Calling GNU make {0}...'.format(p.dir)) |
822 if args.clean: | 823 |
823 run([gmake_cmd(), 'clean'], cwd=p.dir) | 824 if args.clean: |
824 | 825 run([gmake_cmd(), 'clean'], cwd=p.dir) |
825 run([gmake_cmd()], cwd=p.dir) | 826 |
826 built.add(p.name) | 827 run([gmake_cmd()], cwd=p.dir) |
828 built.add(p.name) | |
827 continue | 829 continue |
830 else: | |
831 if not args.java: | |
832 continue | |
833 | |
828 | 834 |
829 outputDir = p.output_dir() | 835 outputDir = p.output_dir() |
830 if exists(outputDir): | 836 if exists(outputDir): |
831 if args.clean: | 837 if args.clean: |
832 log('Cleaning {0}...'.format(outputDir)) | 838 log('Cleaning {0}...'.format(outputDir)) |
913 | 919 |
914 for name in nonjavafilelist: | 920 for name in nonjavafilelist: |
915 dst = join(outputDir, name[len(sourceDir) + 1:]) | 921 dst = join(outputDir, name[len(sourceDir) + 1:]) |
916 if exists(dirname(dst)): | 922 if exists(dirname(dst)): |
917 shutil.copyfile(name, dst) | 923 shutil.copyfile(name, dst) |
924 return args | |
918 | 925 |
919 def canonicalizeprojects(args): | 926 def canonicalizeprojects(args): |
920 """process all project files to canonicalize the dependencies | 927 """process all project files to canonicalize the dependencies |
921 | 928 |
922 The exit code of this command reflects how many files were updated.""" | 929 The exit code of this command reflects how many files were updated.""" |
1054 finally: | 1061 finally: |
1055 if exists(auditfileName): | 1062 if exists(auditfileName): |
1056 os.unlink(auditfileName) | 1063 os.unlink(auditfileName) |
1057 return 0 | 1064 return 0 |
1058 | 1065 |
1059 def clean(args): | 1066 def clean(args, parser=None): |
1060 """remove all class files, images, and executables | 1067 """remove all class files, images, and executables |
1061 | 1068 |
1062 Removes all files created by a build, including Java class files, executables, and | 1069 Removes all files created by a build, including Java class files, executables, and |
1063 generated images. | 1070 generated images. |
1064 """ | 1071 """ |
1065 | 1072 |
1073 parser = parser if parser is not None else ArgumentParser(prog='mx build'); | |
1074 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') | |
1075 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') | |
1076 | |
1077 args = parser.parse_args(args) | |
1078 | |
1066 for p in projects(): | 1079 for p in projects(): |
1067 if p.native: | 1080 if p.native: |
1068 run([gmake_cmd(), '-C', p.dir, 'clean']) | 1081 if args.native: |
1082 run([gmake_cmd(), '-C', p.dir, 'clean']) | |
1069 else: | 1083 else: |
1070 outputDir = p.output_dir() | 1084 if args.java: |
1071 if outputDir != '' and exists(outputDir): | 1085 outputDir = p.output_dir() |
1072 log('Removing {0}...'.format(outputDir)) | 1086 if outputDir != '' and exists(outputDir): |
1073 shutil.rmtree(outputDir) | 1087 log('Removing {0}...'.format(outputDir)) |
1088 shutil.rmtree(outputDir) | |
1089 return args | |
1074 | 1090 |
1075 def help_(args): | 1091 def help_(args): |
1076 """show help for a given command | 1092 """show help for a given command |
1077 | 1093 |
1078 With no arguments, print a list of commands and short help for each command. | 1094 With no arguments, print a list of commands and short help for each command. |
1136 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...] | 1152 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...] |
1137 # If any of the format args are instances of Callable, then they are called with an 'env' are before being | 1153 # If any of the format args are instances of Callable, then they are called with an 'env' are before being |
1138 # used in the call to str.format(). | 1154 # used in the call to str.format(). |
1139 # Extensions should update this table directly | 1155 # Extensions should update this table directly |
1140 commands = { | 1156 commands = { |
1141 'build': [build, '[options] projects...'], | 1157 'build': [build, '[options]'], |
1142 'checkstyle': [checkstyle, 'projects...'], | 1158 'checkstyle': [checkstyle, ''], |
1143 'canonicalizeprojects': [canonicalizeprojects, ''], | 1159 'canonicalizeprojects': [canonicalizeprojects, ''], |
1144 'clean': [clean, ''], | 1160 'clean': [clean, ''], |
1145 'help': [help_, '[command]'], | 1161 'help': [help_, '[command]'], |
1146 'javap': [javap, ''], | 1162 'javap': [javap, ''], |
1147 'projects': [show_projects, ''], | 1163 'projects': [show_projects, ''], |