Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 15580:ce201bb843b4
mx clean: try to change permission if deletion fails on windows
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Fri, 09 May 2014 16:43:26 +0200 |
parents | 406a94c03ffa |
children | e381346a8223 |
comparison
equal
deleted
inserted
replaced
15579:c3869fe3d917 | 15580:ce201bb843b4 |
---|---|
24 # or visit www.oracle.com if you need additional information or have any | 24 # or visit www.oracle.com if you need additional information or have any |
25 # questions. | 25 # questions. |
26 # | 26 # |
27 # ---------------------------------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------------------------------- |
28 | 28 |
29 import os, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket | 29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket |
30 from os.path import join, exists, dirname, basename, getmtime | 30 from os.path import join, exists, dirname, basename, getmtime |
31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER | 31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER |
32 from outputparser import OutputParser, ValuesMatcher | 32 from outputparser import OutputParser, ValuesMatcher |
33 import mx | 33 import mx |
34 import xml.dom.minidom | 34 import xml.dom.minidom |
148 os.path.walk(dirname, _chmodDir, chmodFlags) | 148 os.path.walk(dirname, _chmodDir, chmodFlags) |
149 | 149 |
150 def clean(args): | 150 def clean(args): |
151 """clean the GraalVM source tree""" | 151 """clean the GraalVM source tree""" |
152 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) | 152 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) |
153 | |
153 if opts.native: | 154 if opts.native: |
155 def handleRemoveReadonly(func, path, exc): | |
156 excvalue = exc[1] | |
157 if mx.get_os() == 'windows' and func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: | |
158 os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 | |
159 func(path) | |
160 else: | |
161 raise | |
162 | |
154 def rmIfExists(name): | 163 def rmIfExists(name): |
155 if os.path.isdir(name): | 164 if os.path.isdir(name): |
156 shutil.rmtree(name) | 165 shutil.rmtree(name, ignore_errors=False, onerror=handleRemoveReadonly) |
157 elif os.path.isfile(name): | 166 elif os.path.isfile(name): |
158 os.unlink(name) | 167 os.unlink(name) |
159 | 168 |
160 rmIfExists(join(_graal_home, 'build')) | 169 rmIfExists(join(_graal_home, 'build')) |
161 rmIfExists(join(_graal_home, 'build-nograal')) | 170 rmIfExists(join(_graal_home, 'build-nograal')) |