Mercurial > hg > truffle
comparison mxtool/mx.py @ 4178:d1b26c17910a
Add the Dacapo benchmarks to the "lib" folder instead of using the environment variable. Fixed an issue in the downloader.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 02 Jan 2012 21:52:23 +0100 |
parents | 8c507a8dd6a4 |
children | 383c1272cd1f |
comparison
equal
deleted
inserted
replaced
4177:c843578c269d | 4178:d1b26c17910a |
---|---|
212 path = self.path | 212 path = self.path |
213 if not isabs(path): | 213 if not isabs(path): |
214 path = join(self.suite.dir, path) | 214 path = join(self.suite.dir, path) |
215 if resolve and self.mustExist and not exists(path): | 215 if resolve and self.mustExist and not exists(path): |
216 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + " " + path; | 216 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + " " + path; |
217 print('Downloading ' + self.name + ' from ' + str(self.urls)) | |
217 download(path, self.urls) | 218 download(path, self.urls) |
218 return path | 219 return path |
219 | 220 |
220 def append_to_classpath(self, cp, resolve): | 221 def append_to_classpath(self, cp, resolve): |
221 path = self.get_path(resolve) | 222 path = self.get_path(resolve) |
288 path = attrs['path'] | 289 path = attrs['path'] |
289 mustExist = attrs.pop('optional', 'false') != 'true' | 290 mustExist = attrs.pop('optional', 'false') != 'true' |
290 urls = pop_list(attrs, 'urls') | 291 urls = pop_list(attrs, 'urls') |
291 l = Library(self, name, path, mustExist, urls) | 292 l = Library(self, name, path, mustExist, urls) |
292 l.__dict__.update(attrs) | 293 l.__dict__.update(attrs) |
294 l.get_path(True) | |
293 self.libs.append(l) | 295 self.libs.append(l) |
294 | 296 |
295 def _load_commands(self, mxDir): | 297 def _load_commands(self, mxDir): |
296 commands = join(mxDir, 'commands.py') | 298 commands = join(mxDir, 'commands.py') |
297 if exists(commands): | 299 if exists(commands): |
627 | 629 |
628 def check_get_env(key): | 630 def check_get_env(key): |
629 """ | 631 """ |
630 Gets an environment variable, aborting with a useful message if it is not set. | 632 Gets an environment variable, aborting with a useful message if it is not set. |
631 """ | 633 """ |
632 value = os.environ.get(key) | 634 value = get_env(key) |
633 if value is None: | 635 if value is None: |
634 abort('Required environment variable ' + key + ' must be set') | 636 abort('Required environment variable ' + key + ' must be set') |
637 return value | |
638 | |
639 def get_env(key): | |
640 """ | |
641 Gets an environment variable. | |
642 """ | |
643 value = os.environ.get(key) | |
635 return value | 644 return value |
636 | 645 |
637 def log(msg=None): | 646 def log(msg=None): |
638 """ | 647 """ |
639 Write a message to the console. | 648 Write a message to the console. |
717 data = f.read() | 726 data = f.read() |
718 zipdata = StringIO.StringIO(f.read()) | 727 zipdata = StringIO.StringIO(f.read()) |
719 | 728 |
720 zf = zipfile.ZipFile(zipdata, 'r') | 729 zf = zipfile.ZipFile(zipdata, 'r') |
721 data = zf.read(entry) | 730 data = zf.read(entry) |
722 with open(path, 'w') as f: | 731 with open(path, 'wb') as f: |
723 f.write(data) | 732 f.write(data) |
724 else: | 733 else: |
725 with contextlib.closing(url_open(url)) as f: | 734 with contextlib.closing(url_open(url)) as f: |
726 data = f.read() | 735 data = f.read() |
727 with open(path, 'w') as f: | 736 with open(path, 'wb') as f: |
728 f.write(data) | 737 f.write(data) |
729 return | 738 return |
730 except IOError as e: | 739 except IOError as e: |
731 log('Error reading from ' + url + ': ' + str(e)) | 740 log('Error reading from ' + url + ': ' + str(e)) |
732 except zipfile.BadZipfile as e: | 741 except zipfile.BadZipfile as e: |
847 continue | 856 continue |
848 | 857 |
849 built.add(p.name) | 858 built.add(p.name) |
850 | 859 |
851 argfileName = join(p.dir, 'javafilelist.txt') | 860 argfileName = join(p.dir, 'javafilelist.txt') |
852 argfile = open(argfileName, 'w') | 861 argfile = open(argfileName, 'wb') |
853 argfile.write('\n'.join(javafilelist)) | 862 argfile.write('\n'.join(javafilelist)) |
854 argfile.close() | 863 argfile.close() |
855 | 864 |
856 try: | 865 try: |
857 if jdtJar is None: | 866 if jdtJar is None: |
1137 d = join(path, 'mx') | 1146 d = join(path, 'mx') |
1138 if exists(d) and isdir(d): | 1147 if exists(d) and isdir(d): |
1139 _loadSuite(path) | 1148 _loadSuite(path) |
1140 | 1149 |
1141 cwdMxDir = join(os.getcwd(), 'mx') | 1150 cwdMxDir = join(os.getcwd(), 'mx') |
1142 if exists(cwdMxDir) and isdir(cwdMxDir): | |
1143 _loadSuite(os.getcwd(), True) | |
1144 | 1151 |
1145 opts, commandAndArgs = _argParser._parse_cmd_line() | 1152 opts, commandAndArgs = _argParser._parse_cmd_line() |
1146 | 1153 |
1147 global _opts, _java | 1154 global _opts, _java |
1148 _opts = opts | 1155 _opts = opts |
1149 _java = JavaConfig(opts) | 1156 _java = JavaConfig(opts) |
1157 | |
1158 if exists(cwdMxDir) and isdir(cwdMxDir): | |
1159 _loadSuite(os.getcwd(), True) | |
1150 | 1160 |
1151 for s in suites(): | 1161 for s in suites(): |
1152 if s.commands is not None and hasattr(s.commands, 'mx_post_parse_cmd_line'): | 1162 if s.commands is not None and hasattr(s.commands, 'mx_post_parse_cmd_line'): |
1153 s.commands.mx_post_parse_cmd_line(opts) | 1163 s.commands.mx_post_parse_cmd_line(opts) |
1154 | 1164 |