comparison mxtool/mx.py @ 5158:8ea90b7c8586

made eclipseinit generate Eclipse debug-on-attach launch config in mx/attach-8000.launch
author Doug Simon <doug.simon@oracle.com>
date Mon, 26 Mar 2012 22:25:26 +0200
parents 54819cdcca7f
children 7f9010a55761
comparison
equal deleted inserted replaced
5157:2a3938fac230 5158:8ea90b7c8586
122 by extension commands. 122 by extension commands.
123 123
124 Property values can use environment variables with Bash syntax (e.g. ${HOME}). 124 Property values can use environment variables with Bash syntax (e.g. ${HOME}).
125 """ 125 """
126 126
127 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal 127 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils
128 import shutil, fnmatch, re, xml.dom.minidom 128 import shutil, fnmatch, re, xml.dom.minidom
129 from collections import Callable 129 from collections import Callable
130 from threading import Thread 130 from threading import Thread
131 from argparse import ArgumentParser, REMAINDER 131 from argparse import ArgumentParser, REMAINDER
132 from os.path import join, dirname, exists, getmtime, isabs, expandvars, isdir, isfile 132 from os.path import join, dirname, exists, getmtime, isabs, expandvars, isdir, isfile
1377 suite = _mainSuite 1377 suite = _mainSuite
1378 1378
1379 def println(out, obj): 1379 def println(out, obj):
1380 out.write(str(obj) + '\n') 1380 out.write(str(obj) + '\n')
1381 1381
1382 source_locator_memento = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<sourceLookupDirector><sourceContainers duplicates="false">'
1383 entities = { '"': "&quot;", "'": "&apos;", '\n': '&#10;' }
1384
1382 for p in projects(): 1385 for p in projects():
1383 if p.native: 1386 if p.native:
1384 continue 1387 continue
1385 1388
1386 if not exists(p.dir): 1389 if not exists(p.dir):
1490 println(out, '\t</natures>') 1493 println(out, '\t</natures>')
1491 println(out, '</projectDescription>') 1494 println(out, '</projectDescription>')
1492 update_file(join(p.dir, '.project'), out.getvalue()) 1495 update_file(join(p.dir, '.project'), out.getvalue())
1493 out.close() 1496 out.close()
1494 1497
1495 out = StringIO.StringIO()
1496 settingsDir = join(p.dir, ".settings") 1498 settingsDir = join(p.dir, ".settings")
1497 if not exists(settingsDir): 1499 if not exists(settingsDir):
1498 os.mkdir(settingsDir) 1500 os.mkdir(settingsDir)
1499 1501
1500 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings') 1502 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings')
1504 if isfile(path): 1506 if isfile(path):
1505 with open(join(eclipseSettingsDir, name)) as f: 1507 with open(join(eclipseSettingsDir, name)) as f:
1506 content = f.read() 1508 content = f.read()
1507 content = content.replace('${javaCompliance}', str(p.javaCompliance)) 1509 content = content.replace('${javaCompliance}', str(p.javaCompliance))
1508 update_file(join(settingsDir, name), content) 1510 update_file(join(settingsDir, name), content)
1511
1512 memento = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<javaProject name="' + p.name + '"/>\n'
1513 source_locator_memento += '\n<container memento="' + xml.sax.saxutils.escape(memento, entities) + '" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/>'
1514
1515 source_locator_memento += '</sourceContainers>\n</sourceLookupDirector>'
1516 launch = r"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1517 <launchConfiguration type="org.eclipse.jdt.launching.remoteJavaApplication">
1518 <stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
1519 <stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="{0}"/>
1520 <booleanAttribute key="org.eclipse.jdt.launching.ALLOW_TERMINATE" value="true"/>
1521 <mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
1522 <mapEntry key="hostname" value="localhost"/>
1523 <mapEntry key="port" value="8000"/>
1524 </mapAttribute>
1525 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
1526 <stringAttribute key="org.eclipse.jdt.launching.VM_CONNECTOR_ID" value="org.eclipse.jdt.launching.socketAttachConnector"/>
1527 </launchConfiguration>""".format(xml.sax.saxutils.escape(source_locator_memento, entities))
1528 update_file(join(suite.dir, 'mx', 'attach-8000.launch'), launch)
1509 1529
1510 def netbeansinit(args, suite=None): 1530 def netbeansinit(args, suite=None):
1511 """(re)generate NetBeans project configurations""" 1531 """(re)generate NetBeans project configurations"""
1512 1532
1513 if suite is None: 1533 if suite is None: