Mercurial > hg > truffle
comparison mxtool/mx.py @ 8884:51a8368d0231
Adapt to changes in hotspot makefiles : pass our JAVA_HOME as ALT_BOOTDIR (so that things are built with a 'safe' jdk) and our jdk copy as JAVA_HOME (so that the jvm gets installed there)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sun, 07 Apr 2013 13:30:37 +0200 |
parents | c4bca84d86d7 |
children | 64d3d352f943 |
comparison
equal
deleted
inserted
replaced
8883:b9a918201d47 | 8884:51a8368d0231 |
---|---|
944 time.sleep(0.05) | 944 time.sleep(0.05) |
945 else: | 945 else: |
946 retcode = p.wait() | 946 retcode = p.wait() |
947 return retcode | 947 return retcode |
948 | 948 |
949 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None): | 949 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None): |
950 """ | 950 """ |
951 Run a command in a subprocess, wait for it to complete and return the exit status of the process. | 951 Run a command in a subprocess, wait for it to complete and return the exit status of the process. |
952 If the exit status is non-zero and `nonZeroIsFatal` is true, then mx is exited with | 952 If the exit status is non-zero and `nonZeroIsFatal` is true, then mx is exited with |
953 the same exit status. | 953 the same exit status. |
954 Each line of the standard output and error streams of the subprocess are redirected to | 954 Each line of the standard output and error streams of the subprocess are redirected to |
981 else: | 981 else: |
982 preexec_fn = os.setsid | 982 preexec_fn = os.setsid |
983 | 983 |
984 if not callable(out) and not callable(err) and timeout is None: | 984 if not callable(out) and not callable(err) and timeout is None: |
985 # The preexec_fn=os.setsid | 985 # The preexec_fn=os.setsid |
986 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags) | 986 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags, env=env) |
987 _currentSubprocess = (p, args) | 987 _currentSubprocess = (p, args) |
988 retcode = waitOn(p) | 988 retcode = waitOn(p) |
989 else: | 989 else: |
990 def redirect(stream, f): | 990 def redirect(stream, f): |
991 for line in iter(stream.readline, ''): | 991 for line in iter(stream.readline, ''): |
992 f(line) | 992 f(line) |
993 stream.close() | 993 stream.close() |
994 stdout=out if not callable(out) else subprocess.PIPE | 994 stdout=out if not callable(out) else subprocess.PIPE |
995 stderr=err if not callable(err) else subprocess.PIPE | 995 stderr=err if not callable(err) else subprocess.PIPE |
996 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags) | 996 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env) |
997 _currentSubprocess = (p, args) | 997 _currentSubprocess = (p, args) |
998 if callable(out): | 998 if callable(out): |
999 t = Thread(target=redirect, args=(p.stdout, out)) | 999 t = Thread(target=redirect, args=(p.stdout, out)) |
1000 t.daemon = True # thread dies with the program | 1000 t.daemon = True # thread dies with the program |
1001 t.start() | 1001 t.start() |