Mercurial > hg > truffle
comparison mxtool/mx.py @ 4271:311d193de5a2
Fixed regressions and Windows issues in generated IDE project configurations.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 11 Jan 2012 18:25:25 +0100 |
parents | 2158e26b50cf |
children | d4906ea4255b fad6f1ebeb44 |
comparison
equal
deleted
inserted
replaced
4270:2158e26b50cf | 4271:311d193de5a2 |
---|---|
200 cp.append(self.output_dir()) | 200 cp.append(self.output_dir()) |
201 | 201 |
202 class Library(Dependency): | 202 class Library(Dependency): |
203 def __init__(self, suite, name, path, mustExist, urls): | 203 def __init__(self, suite, name, path, mustExist, urls): |
204 Dependency.__init__(self, suite, name) | 204 Dependency.__init__(self, suite, name) |
205 self.path = path | 205 self.path = path.replace('/', os.sep) |
206 self.urls = urls | 206 self.urls = urls |
207 self.mustExist = mustExist | 207 self.mustExist = mustExist |
208 | 208 |
209 def get_path(self, resolve): | 209 def get_path(self, resolve): |
210 path = self.path | 210 path = self.path |
212 path = join(self.suite.dir, path) | 212 path = join(self.suite.dir, path) |
213 if resolve and self.mustExist and not exists(path): | 213 if resolve and self.mustExist and not exists(path): |
214 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + " " + path; | 214 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + " " + path; |
215 print('Downloading ' + self.name + ' from ' + str(self.urls)) | 215 print('Downloading ' + self.name + ' from ' + str(self.urls)) |
216 download(path, self.urls) | 216 download(path, self.urls) |
217 | |
217 return path | 218 return path |
218 | 219 |
219 def append_to_classpath(self, cp, resolve): | 220 def append_to_classpath(self, cp, resolve): |
220 path = self.get_path(resolve) | 221 path = self.get_path(resolve) |
221 if exists(path) or not resolve: | 222 if exists(path) or not resolve: |
286 p.native = attrs.pop('native', '') == 'true' | 287 p.native = attrs.pop('native', '') == 'true' |
287 p.__dict__.update(attrs) | 288 p.__dict__.update(attrs) |
288 self.projects.append(p) | 289 self.projects.append(p) |
289 | 290 |
290 for name, attrs in libsMap.iteritems(): | 291 for name, attrs in libsMap.iteritems(): |
291 path = attrs['path'] | 292 path = attrs.pop('path') |
292 mustExist = attrs.pop('optional', 'false') != 'true' | 293 mustExist = attrs.pop('optional', 'false') != 'true' |
293 urls = pop_list(attrs, 'urls') | 294 urls = pop_list(attrs, 'urls') |
294 l = Library(self, name, path, mustExist, urls) | 295 l = Library(self, name, path, mustExist, urls) |
295 l.__dict__.update(attrs) | 296 l.__dict__.update(attrs) |
296 self.libs.append(l) | 297 self.libs.append(l) |
1318 for name in os.listdir(eclipseSettingsDir): | 1319 for name in os.listdir(eclipseSettingsDir): |
1319 path = join(eclipseSettingsDir, name) | 1320 path = join(eclipseSettingsDir, name) |
1320 if isfile(path): | 1321 if isfile(path): |
1321 with open(join(eclipseSettingsDir, name)) as f: | 1322 with open(join(eclipseSettingsDir, name)) as f: |
1322 content = f.read() | 1323 content = f.read() |
1323 update_file(path, content) | 1324 update_file(join(settingsDir, name), content) |
1324 | 1325 |
1325 def netbeansinit(args, suite=None): | 1326 def netbeansinit(args, suite=None): |
1326 """(re)generate NetBeans project configurations""" | 1327 """(re)generate NetBeans project configurations""" |
1327 | 1328 |
1328 if suite is None: | 1329 if suite is None: |
1489 for dep in p.all_deps([], True): | 1490 for dep in p.all_deps([], True): |
1490 if dep == p: | 1491 if dep == p: |
1491 continue; | 1492 continue; |
1492 | 1493 |
1493 if dep.isLibrary(): | 1494 if dep.isLibrary(): |
1494 path = dep.path | 1495 if not dep.mustExist: |
1495 if dep.mustExist: | 1496 continue |
1496 dep.get_path(resolve=True) | 1497 path = dep.get_path(resolve=True) |
1497 if not isabs(path): | 1498 if os.sep == '\\': |
1498 path = join(suite.dir, path) | 1499 path = path.replace('\\', '\\\\') |
1499 ref = 'file.reference.' + dep.name + '-bin' | 1500 ref = 'file.reference.' + dep.name + '-bin' |
1500 println(out, ref + '=' + path) | 1501 println(out, ref + '=' + path) |
1501 | 1502 |
1502 else: | 1503 else: |
1503 n = dep.name.replace('.', '_') | 1504 n = dep.name.replace('.', '_') |
1504 relDepPath = os.path.relpath(dep.dir, p.dir) | 1505 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') |
1505 ref = 'reference.' + n + '.jar' | 1506 ref = 'reference.' + n + '.jar' |
1506 println(out, 'project.' + n + '=' + relDepPath) | 1507 println(out, 'project.' + n + '=' + relDepPath) |
1507 println(out, ref + '=' + join('${project.' + n + '}', 'dist', dep.name + '.jar')) | 1508 println(out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar') |
1508 | 1509 |
1509 javacClasspath.append('${' + ref + '}') | 1510 javacClasspath.append('${' + ref + '}') |
1510 | 1511 |
1511 println(out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)) | 1512 println(out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)) |
1512 | 1513 |
1517 if updated: | 1518 if updated: |
1518 log('If using NetBeans:') | 1519 log('If using NetBeans:') |
1519 log(' 1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)') | 1520 log(' 1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)') |
1520 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') | 1521 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') |
1521 | 1522 |
1523 def ideclean(args, suite=None): | |
1524 """remove all Eclipse and NetBeans project configurations""" | |
1525 | |
1526 def rm(path): | |
1527 if exists(path): | |
1528 os.remove(path) | |
1529 | |
1530 for p in projects(): | |
1531 if p.native: | |
1532 continue | |
1533 | |
1534 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True) | |
1535 shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True) | |
1536 rm(join(p.dir, '.classpath')) | |
1537 rm(join(p.dir, '.project')) | |
1538 rm(join(p.dir, 'build.xml')) | |
1539 | |
1522 def ideinit(args, suite=None): | 1540 def ideinit(args, suite=None): |
1523 """(re)generate Eclipse and NetBeans project configurations""" | 1541 """(re)generate Eclipse and NetBeans project configurations""" |
1524 eclipseinit(args, suite) | 1542 eclipseinit(args, suite) |
1525 netbeansinit(args, suite) | 1543 netbeansinit(args, suite) |
1526 | 1544 |
1563 'checkstyle': [checkstyle, ''], | 1581 'checkstyle': [checkstyle, ''], |
1564 'canonicalizeprojects': [canonicalizeprojects, ''], | 1582 'canonicalizeprojects': [canonicalizeprojects, ''], |
1565 'clean': [clean, ''], | 1583 'clean': [clean, ''], |
1566 'eclipseinit': [eclipseinit, ''], | 1584 'eclipseinit': [eclipseinit, ''], |
1567 'help': [help_, '[command]'], | 1585 'help': [help_, '[command]'], |
1586 'ideclean': [ideclean, ''], | |
1568 'ideinit': [ideinit, ''], | 1587 'ideinit': [ideinit, ''], |
1569 'javap': [javap, ''], | 1588 'javap': [javap, ''], |
1570 'netbeansinit': [netbeansinit, ''], | 1589 'netbeansinit': [netbeansinit, ''], |
1571 'projects': [show_projects, ''], | 1590 'projects': [show_projects, ''], |
1572 } | 1591 } |