# HG changeset patch # User Doug Simon # Date 1331729672 -3600 # Node ID 9d055af068a892695b77d0ce013de932873a8d9d # Parent b593e82d9309dac77b0023fd3756a9628a6168df Made Java builds look for mx/ecj.jar to use Eclipse batch compiler by default. Made library paths absolute in generated Eclipse configuration to avoid issues with how relative paths are interpreted (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737). diff -r b593e82d9309 -r 9d055af068a8 mxtool/mx.py --- a/mxtool/mx.py Sun Mar 11 13:11:37 2012 +0100 +++ b/mxtool/mx.py Wed Mar 14 13:54:32 2012 +0100 @@ -727,7 +727,7 @@ class JavaCompliance: def __init__(self, ver): m = re.match('1\.(\d+).*', ver) - assert m is not None, 'not a recognized version string: ' + vstring + assert m is not None, 'not a recognized version string: ' + ver self.value = int(m.group(1)) def __str__ (self): @@ -957,6 +957,8 @@ javaCompliance = java().javaCompliance + defaultEcjPath = join(_mainSuite.dir, 'mx', 'ecj.jar') + parser = parser if parser is not None else ArgumentParser(prog='mx build') parser.add_argument('-f', action='store_true', dest='force', help='force compilation even if class files are up to date') parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') @@ -965,7 +967,7 @@ parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') - parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='') + parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='') if suppliedParser: parser.add_argument('remainder', nargs=REMAINDER, metavar='...') @@ -976,6 +978,9 @@ if args.jdt is not None: if args.jdt.endswith('.jar'): jdtJar=args.jdt + if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath): + # Silently ignore JDT if default location is used but not ecj.jar exists there + jdtJar = None elif isdir(args.jdt): plugins = join(args.jdt, 'plugins') choices = [f for f in os.listdir(plugins) if fnmatch.fnmatch(f, 'org.eclipse.jdt.core_*.jar')] @@ -1053,7 +1058,7 @@ with open(os.devnull) as devnull: subprocess.call('jasmin', stdout=devnull, stderr=subprocess.STDOUT) jasminAvailable = True - except OSError as e: + except OSError: jasminAvailable = False if jasminAvailable: @@ -1119,15 +1124,18 @@ run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt) else: log('Compiling Java sources for {0} with JDT...'.format(p.name)) + jdtArgs = [java().java, '-Xmx1g', '-jar', jdtJar, + '-' + args.compliance, + '-cp', cp, '-g', '-enableJavadoc', + '-warn:-unusedImport,-unchecked', + '-d', outputDir] jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') if not exists(jdtProperties): - raise SystemError('JDT properties file {0} not found'.format(jdtProperties)) - run([java().java, '-Xmx1g', '-jar', jdtJar, - '-properties', jdtProperties, - '-' + args.compliance, - '-cp', cp, '-g', - '-warn:-unusedImport,-unchecked', - '-d', outputDir, '@' + argfile.name]) + log('JDT properties file {0} not found - fix by running "mx eclipseinit"'.format(jdtProperties)) + else: + jdtArgs += ['-properties', jdtProperties] + jdtArgs.append('@' + argfile.name) + run(jdtArgs) finally: os.remove(argfileName) @@ -1358,21 +1366,12 @@ out.write(str(obj) + '\n') for p in projects(): + if p.native: + continue + if not exists(p.dir): os.makedirs(p.dir) - if p.native: - eclipseNativeSettingsDir = join(suite.dir, 'mx', 'eclipse-native-settings') - if exists(eclipseNativeSettingsDir): - for name in os.listdir(eclipseNativeSettingsDir): - path = join(eclipseNativeSettingsDir, name) - if isfile(path): - with open(join(eclipseNativeSettingsDir, name)) as f: - content = f.read() - content = content.replace('${javaHome}', java().jdk) - update_file(join(p.dir, name), content) - continue - out = StringIO.StringIO() println(out, '') @@ -1402,8 +1401,10 @@ if isabs(path): println(out, '\t') else: - projRelPath = os.path.relpath(join(suite.dir, path), p.dir) - println(out, '\t') + # Relative paths for "lib" class path entries have various semantics depending on the Eclipse + # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's + # safest to simply use absolute paths. + println(out, '\t') else: println(out, '\t')