Mercurial > hg > truffle
comparison mxtool/mx.py @ 4270:2158e26b50cf
Made generated NetBeans projects use project cross referencing.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 11 Jan 2012 16:55:30 +0100 |
parents | ffd5ce8fc736 |
children | 311d193de5a2 |
comparison
equal
deleted
inserted
replaced
4269:ffd5ce8fc736 | 4270:2158e26b50cf |
---|---|
463 if get_os() != 'windows': | 463 if get_os() != 'windows': |
464 # Time outs are (currently) implemented with Unix specific functionality | 464 # Time outs are (currently) implemented with Unix specific functionality |
465 self.add_argument('--timeout', help='Timeout (in seconds) for command', type=int, default=0, metavar='<secs>') | 465 self.add_argument('--timeout', help='Timeout (in seconds) for command', type=int, default=0, metavar='<secs>') |
466 self.add_argument('--ptimeout', help='Timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') | 466 self.add_argument('--ptimeout', help='Timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') |
467 | 467 |
468 | |
469 def _parse_cmd_line(self, args=None): | 468 def _parse_cmd_line(self, args=None): |
470 if args is None: | 469 if args is None: |
471 args = sys.argv[1:] | 470 args = sys.argv[1:] |
472 | 471 |
473 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') | 472 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') |
474 | 473 |
475 opts = self.parse_args() | 474 opts = self.parse_args() |
475 | |
476 # Give the timeout options a default value to avoid the need for hasattr() tests | |
477 opts.__dict__.setdefault('timeout', 0) | |
478 opts.__dict__.setdefault('ptimeout', 0) | |
476 | 479 |
477 if opts.java_home is None: | 480 if opts.java_home is None: |
478 opts.java_home = os.environ.get('JAVA_HOME') | 481 opts.java_home = os.environ.get('JAVA_HOME') |
479 | 482 |
480 if opts.java_home is None or opts.java_home == '': | 483 if opts.java_home is None or opts.java_home == '': |
567 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) | 570 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) |
568 | 571 |
569 if _opts.verbose: | 572 if _opts.verbose: |
570 log(' '.join(args)) | 573 log(' '.join(args)) |
571 | 574 |
572 if timeout is None and hasattr(_opts, 'ptimeout') and _opts.ptimeout != 0: | 575 if timeout is None and _opts.ptimeout != 0: |
573 timeout = _opts.ptimeout | 576 timeout = _opts.ptimeout |
574 | 577 |
575 global _currentSubprocess | 578 global _currentSubprocess |
576 | 579 |
577 try: | 580 try: |
1347 out.close() | 1350 out.close() |
1348 | 1351 |
1349 out = StringIO.StringIO() | 1352 out = StringIO.StringIO() |
1350 println(out, '<?xml version="1.0" encoding="UTF-8"?>') | 1353 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
1351 println(out, '<project xmlns="http://www.netbeans.org/ns/project/1">') | 1354 println(out, '<project xmlns="http://www.netbeans.org/ns/project/1">') |
1352 println(out, '\t<type>org.netbeans.modules.java.j2seproject</type>') | 1355 println(out, ' <type>org.netbeans.modules.java.j2seproject</type>') |
1353 println(out, '\t<configuration>') | 1356 println(out, ' <configuration>') |
1354 println(out, '\t\t<data xmlns="http://www.netbeans.org/ns/j2se-project/3">') | 1357 println(out, ' <data xmlns="http://www.netbeans.org/ns/j2se-project/3">') |
1355 println(out, '\t\t\t<name>' + p.name + '</name>') | 1358 println(out, ' <name>' + p.name+ '</name>') |
1356 println(out, '\t\t\t<explicit-platform explicit-source-supported="true"/>') | 1359 println(out, ' <explicit-platform explicit-source-supported="true"/>') |
1357 println(out, '\t\t\t<source-roots>') | 1360 println(out, ' <source-roots>') |
1358 println(out, '\t\t\t\t<root id="src.dir"/>') | 1361 println(out, ' <root id="src.dir"/>') |
1359 println(out, '\t\t\t</source-roots>') | 1362 println(out, ' </source-roots>') |
1360 println(out, '\t\t\t<test-roots>') | 1363 println(out, ' <test-roots>') |
1361 println(out, '\t\t\t\t<root id="test.src.dir"/>') | 1364 println(out, ' <root id="test.src.dir"/>') |
1362 println(out, '\t\t\t</test-roots>') | 1365 println(out, ' </test-roots>') |
1363 println(out, '\t\t</data>') | 1366 println(out, ' </data>') |
1364 println(out, '\t</configuration>') | 1367 |
1368 firstDep = True | |
1369 for dep in p.all_deps([], True): | |
1370 if dep == p: | |
1371 continue; | |
1372 | |
1373 if not dep.isLibrary(): | |
1374 n = dep.name.replace('.', '_') | |
1375 if firstDep: | |
1376 println(out, ' <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">') | |
1377 firstDep = False | |
1378 | |
1379 println(out, ' <reference>') | |
1380 println(out, ' <foreign-project>' + n + '</foreign-project>') | |
1381 println(out, ' <artifact-type>jar</artifact-type>') | |
1382 println(out, ' <script>build.xml</script>') | |
1383 println(out, ' <target>jar</target>') | |
1384 println(out, ' <clean-target>clean</clean-target>') | |
1385 println(out, ' <id>jar</id>') | |
1386 println(out, ' </reference>') | |
1387 | |
1388 if not firstDep: | |
1389 println(out, ' </references>') | |
1390 | |
1391 println(out, ' </configuration>') | |
1365 println(out, '</project>') | 1392 println(out, '</project>') |
1366 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.getvalue()) or updated | 1393 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.getvalue()) or updated |
1367 out.close() | 1394 out.close() |
1368 | 1395 |
1369 out = StringIO.StringIO() | 1396 out = StringIO.StringIO() |
1426 javadoc.version=false | 1453 javadoc.version=false |
1427 javadoc.windowtitle= | 1454 javadoc.windowtitle= |
1428 main.class= | 1455 main.class= |
1429 manifest.file=manifest.mf | 1456 manifest.file=manifest.mf |
1430 meta.inf.dir=${src.dir}/META-INF | 1457 meta.inf.dir=${src.dir}/META-INF |
1431 mkdist.disabled=true | 1458 mkdist.disabled=false |
1432 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """ | 1459 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """ |
1433 platform.active=""" + jdkPlatform + """ | 1460 platform.active=""" + jdkPlatform + """ |
1434 run.classpath=\\ | 1461 run.classpath=\\ |
1435 ${javac.classpath}:\\ | 1462 ${javac.classpath}:\\ |
1436 ${build.classes.dir} | 1463 ${build.classes.dir} |
1467 path = dep.path | 1494 path = dep.path |
1468 if dep.mustExist: | 1495 if dep.mustExist: |
1469 dep.get_path(resolve=True) | 1496 dep.get_path(resolve=True) |
1470 if not isabs(path): | 1497 if not isabs(path): |
1471 path = join(suite.dir, path) | 1498 path = join(suite.dir, path) |
1499 ref = 'file.reference.' + dep.name + '-bin' | |
1500 println(out, ref + '=' + path) | |
1472 | 1501 |
1473 else: | 1502 else: |
1474 path = dep.output_dir() | 1503 n = dep.name.replace('.', '_') |
1504 relDepPath = os.path.relpath(dep.dir, p.dir) | |
1505 ref = 'reference.' + n + '.jar' | |
1506 println(out, 'project.' + n + '=' + relDepPath) | |
1507 println(out, ref + '=' + join('${project.' + n + '}', 'dist', dep.name + '.jar')) | |
1475 | 1508 |
1476 ref = 'file.reference.' + dep.name + '-bin' | |
1477 println(out, ref + '=' + path) | |
1478 javacClasspath.append('${' + ref + '}') | 1509 javacClasspath.append('${' + ref + '}') |
1479 | 1510 |
1480 println(out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)) | 1511 println(out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath)) |
1481 | 1512 |
1482 | 1513 |
1483 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated | 1514 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated |
1484 out.close() | 1515 out.close() |
1485 | 1516 |
1486 if updated: | 1517 if updated: |
1487 log('If using NetBeans, ensure that a platform name ' + jdkPlatform + ' is defined (Tools -> Java Platforms)') | 1518 log('If using NetBeans:') |
1519 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)') | |
1488 | 1521 |
1489 def ideinit(args, suite=None): | 1522 def ideinit(args, suite=None): |
1490 """(re)generate Eclipse and NetBeans project configurations""" | 1523 """(re)generate Eclipse and NetBeans project configurations""" |
1491 eclipseinit(args, suite) | 1524 eclipseinit(args, suite) |
1492 netbeansinit(args, suite) | 1525 netbeansinit(args, suite) |
1532 'clean': [clean, ''], | 1565 'clean': [clean, ''], |
1533 'eclipseinit': [eclipseinit, ''], | 1566 'eclipseinit': [eclipseinit, ''], |
1534 'help': [help_, '[command]'], | 1567 'help': [help_, '[command]'], |
1535 'ideinit': [ideinit, ''], | 1568 'ideinit': [ideinit, ''], |
1536 'javap': [javap, ''], | 1569 'javap': [javap, ''], |
1570 'netbeansinit': [netbeansinit, ''], | |
1537 'projects': [show_projects, ''], | 1571 'projects': [show_projects, ''], |
1538 } | 1572 } |
1539 | 1573 |
1540 _argParser = ArgParser() | 1574 _argParser = ArgParser() |
1541 | 1575 |
1564 if not commands.has_key(command): | 1598 if not commands.has_key(command): |
1565 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands())) | 1599 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands())) |
1566 | 1600 |
1567 c, _ = commands[command][:2] | 1601 c, _ = commands[command][:2] |
1568 try: | 1602 try: |
1569 if hasattr(opts, 'timeout') and opts.timeout != 0: | 1603 if opts.timeout != 0: |
1570 def alarm_handler(signum, frame): | 1604 def alarm_handler(signum, frame): |
1571 abort('Command timed out after ' + str(opts.timeout) + ' seconds: ' + ' '.join(commandAndArgs)) | 1605 abort('Command timed out after ' + str(opts.timeout) + ' seconds: ' + ' '.join(commandAndArgs)) |
1572 signal.signal(signal.SIGALRM, alarm_handler) | 1606 signal.signal(signal.SIGALRM, alarm_handler) |
1573 signal.alarm(opts.timeout) | 1607 signal.alarm(opts.timeout) |
1574 retcode = c(command_args) | 1608 retcode = c(command_args) |