diff 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
line wrap: on
line diff
--- a/mxtool/mx.py	Mon Jan 02 17:47:48 2012 +0100
+++ b/mxtool/mx.py	Mon Jan 02 21:52:23 2012 +0100
@@ -214,6 +214,7 @@
             path = join(self.suite.dir, path)
         if resolve and self.mustExist and not exists(path):
             assert not len(self.urls) == 0, 'cannot find required library  ' + self.name + " " + path;
+            print('Downloading ' + self.name + ' from ' + str(self.urls))
             download(path, self.urls)
         return path
         
@@ -290,6 +291,7 @@
             urls = pop_list(attrs, 'urls')
             l = Library(self, name, path, mustExist, urls)
             l.__dict__.update(attrs)
+            l.get_path(True)
             self.libs.append(l)
         
     def _load_commands(self, mxDir):
@@ -629,11 +631,18 @@
     """
     Gets an environment variable, aborting with a useful message if it is not set.
     """
-    value = os.environ.get(key)
+    value = get_env(key)
     if value is None:
         abort('Required environment variable ' + key + ' must be set')
     return value
 
+def get_env(key):
+    """
+    Gets an environment variable.
+    """
+    value = os.environ.get(key)
+    return value
+
 def log(msg=None):
     """
     Write a message to the console.
@@ -719,12 +728,12 @@
             
                 zf = zipfile.ZipFile(zipdata, 'r')
                 data = zf.read(entry)
-                with open(path, 'w') as f:
+                with open(path, 'wb') as f:
                     f.write(data)
             else:
                 with contextlib.closing(url_open(url)) as f:
                     data = f.read()
-                with open(path, 'w') as f:
+                with open(path, 'wb') as f:
                     f.write(data)
             return
         except IOError as e:
@@ -849,7 +858,7 @@
             built.add(p.name)
 
             argfileName = join(p.dir, 'javafilelist.txt')
-            argfile = open(argfileName, 'w')
+            argfile = open(argfileName, 'wb')
             argfile.write('\n'.join(javafilelist))
             argfile.close()
             
@@ -1139,8 +1148,6 @@
                 _loadSuite(path)
                 
     cwdMxDir = join(os.getcwd(), 'mx')
-    if exists(cwdMxDir) and isdir(cwdMxDir):
-        _loadSuite(os.getcwd(), True)
             
     opts, commandAndArgs = _argParser._parse_cmd_line()
     
@@ -1148,6 +1155,9 @@
     _opts = opts
     _java = JavaConfig(opts)
     
+    if exists(cwdMxDir) and isdir(cwdMxDir):
+        _loadSuite(os.getcwd(), True)
+    
     for s in suites():
         if s.commands is not None and hasattr(s.commands, 'mx_post_parse_cmd_line'):
             s.commands.mx_post_parse_cmd_line(opts)