comparison mxtool/mx.py @ 5778:74c802348d1f

added --jdt-warning-as-error option to 'mx build'
author Doug Simon <doug.simon@oracle.com>
date Fri, 06 Jul 2012 09:19:23 +0200
parents 613a3ddb9a71
children 488864d5069a
comparison
equal deleted inserted replaced
5777:9e56d5113c66 5778:74c802348d1f
1153 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') 1153 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
1154 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') 1154 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)')
1155 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') 1155 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects')
1156 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') 1156 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects')
1157 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>') 1157 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>')
1158 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors')
1158 1159
1159 if suppliedParser: 1160 if suppliedParser:
1160 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') 1161 parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
1161 1162
1162 args = parser.parse_args(args) 1163 args = parser.parse_args(args)
1283 argfileName = join(p.dir, 'javafilelist.txt') 1284 argfileName = join(p.dir, 'javafilelist.txt')
1284 argfile = open(argfileName, 'wb') 1285 argfile = open(argfileName, 'wb')
1285 argfile.write('\n'.join(javafilelist)) 1286 argfile.write('\n'.join(javafilelist))
1286 argfile.close() 1287 argfile.close()
1287 1288
1289 toBeDeleted = [argfileName]
1288 try: 1290 try:
1289 if jdtJar is None: 1291 if jdtJar is None:
1290 log('Compiling Java sources for {0} with javac...'.format(p.name)) 1292 log('Compiling Java sources for {0} with javac...'.format(p.name))
1291 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name] 1293 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name]
1292 if not args.warnAPI: 1294 if not args.warnAPI:
1303 # Try to fix a missing properties file by running eclipseinit 1305 # Try to fix a missing properties file by running eclipseinit
1304 eclipseinit([]) 1306 eclipseinit([])
1305 if not exists(jdtProperties): 1307 if not exists(jdtProperties):
1306 log('JDT properties file {0} not found'.format(jdtProperties)) 1308 log('JDT properties file {0} not found'.format(jdtProperties))
1307 else: 1309 else:
1308 jdtArgs += ['-properties', jdtProperties] 1310 # convert all warnings to errors
1311 if args.jdt_warning_as_error:
1312 jdtPropertiesTmp = jdtProperties + '.tmp'
1313 with open(jdtProperties) as fp:
1314 content = fp.read().replace('=warning', '=error')
1315 with open(jdtPropertiesTmp, 'w') as fp:
1316 fp.write(content)
1317 toBeDeleted.append(jdtPropertiesTmp)
1318 jdtArgs += ['-properties', jdtPropertiesTmp]
1319 else:
1320 jdtArgs += ['-properties', jdtProperties]
1309 jdtArgs.append('@' + argfile.name) 1321 jdtArgs.append('@' + argfile.name)
1310 run(jdtArgs) 1322 run(jdtArgs)
1311 finally: 1323 finally:
1312 os.remove(argfileName) 1324 for n in toBeDeleted:
1325 os.remove(n)
1313 1326
1314 if suppliedParser: 1327 if suppliedParser:
1315 return args 1328 return args
1316 return None 1329 return None
1317 1330