Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 10576:aee899c96b0b
distribution jars (e.g., graal.jar) now contain library dependencies
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 29 Jun 2013 11:40:52 +0200 |
parents | 070b4a3c56f3 |
children | be8b942f448f |
comparison
equal
deleted
inserted
replaced
10575:97d280a879ff | 10576:aee899c96b0b |
---|---|
1732 if name.startswith('@'): | 1732 if name.startswith('@'): |
1733 dname = name[1:] | 1733 dname = name[1:] |
1734 d = distribution(dname) | 1734 d = distribution(dname) |
1735 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) | 1735 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) |
1736 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) | 1736 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) |
1737 | |
1738 def overwriteCheck(zf, arcname, source): | |
1739 if arcname in zf.namelist(): | |
1740 log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']') | |
1741 | |
1737 try: | 1742 try: |
1738 zf = zipfile.ZipFile(tmp, 'w') | 1743 zf = zipfile.ZipFile(tmp, 'w') |
1739 for p in sorted_deps(d.deps): | 1744 for dep in sorted_deps(d.deps, includeLibs=True): |
1740 # skip a Java project if its Java compliance level is "higher" than the configured JDK | 1745 if dep.isLibrary(): |
1741 if java().javaCompliance < p.javaCompliance: | 1746 l = dep |
1742 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path)) | 1747 # merge library jar into distribution jar |
1743 continue | 1748 logv('[' + d.path + ': adding library ' + l.name + ']') |
1744 | 1749 lpath = l.get_path(resolve=True) |
1745 outputDir = p.output_dir() | 1750 with zipfile.ZipFile(lpath, 'r') as lp: |
1746 for root, _, files in os.walk(outputDir): | 1751 for arcname in lp.namelist(): |
1747 relpath = root[len(outputDir) + 1:] | 1752 if arcname.startswith('META-INF/services/'): |
1748 if relpath == join('META-INF', 'services'): | 1753 f = arcname[len('META-INF/services/'):].replace('/', os.sep) |
1749 for f in files: | 1754 with open(join(services, f), 'a') as outfile: |
1750 with open(join(services, f), 'a') as outfile: | 1755 for line in lp.read(arcname).splitlines(): |
1756 outfile.write(line) | |
1757 else: | |
1758 overwriteCheck(zf, arcname, lpath + '!' + arcname) | |
1759 zf.writestr(arcname, lp.read(arcname)) | |
1760 else: | |
1761 p = dep | |
1762 # skip a Java project if its Java compliance level is "higher" than the configured JDK | |
1763 if java().javaCompliance < p.javaCompliance: | |
1764 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path)) | |
1765 continue | |
1766 | |
1767 logv('[' + d.path + ': adding project ' + p.name + ']') | |
1768 outputDir = p.output_dir() | |
1769 for root, _, files in os.walk(outputDir): | |
1770 relpath = root[len(outputDir) + 1:] | |
1771 if relpath == join('META-INF', 'services'): | |
1772 for f in files: | |
1773 with open(join(services, f), 'a') as outfile: | |
1774 with open(join(root, f), 'r') as infile: | |
1775 for line in infile: | |
1776 outfile.write(line) | |
1777 elif relpath == join('META-INF', 'providers'): | |
1778 for f in files: | |
1751 with open(join(root, f), 'r') as infile: | 1779 with open(join(root, f), 'r') as infile: |
1752 for line in infile: | 1780 for line in infile: |
1753 outfile.write(line) | 1781 with open(join(services, line.strip()), 'a') as outfile: |
1754 elif relpath == join('META-INF', 'providers'): | 1782 outfile.write(f + '\n') |
1755 for f in files: | 1783 else: |
1756 with open(join(root, f), 'r') as infile: | 1784 for f in files: |
1757 for line in infile: | 1785 arcname = join(relpath, f).replace(os.sep, '/') |
1758 with open(join(services, line.strip()), 'a') as outfile: | 1786 overwriteCheck(zf, arcname, join(root, f)) |
1759 outfile.write(f + '\n') | 1787 zf.write(join(root, f), arcname) |
1760 else: | |
1761 for f in files: | |
1762 arcname = join(relpath, f).replace(os.sep, '/') | |
1763 zf.write(join(root, f), arcname) | |
1764 for f in os.listdir(services): | 1788 for f in os.listdir(services): |
1765 arcname = join('META-INF', 'services', f).replace(os.sep, '/') | 1789 arcname = join('META-INF', 'services', f).replace(os.sep, '/') |
1766 zf.write(join(services, f), arcname) | 1790 zf.write(join(services, f), arcname) |
1767 zf.close() | 1791 zf.close() |
1768 os.close(fd) | 1792 os.close(fd) |