[pypy-svn] r72619 - pypy/trunk/pypy/translator/platform
arigo at codespeak.net
arigo at codespeak.net
Tue Mar 23 13:57:03 CET 2010
Author: arigo
Date: Tue Mar 23 13:57:01 2010
New Revision: 72619
Modified:
pypy/trunk/pypy/translator/platform/__init__.py
pypy/trunk/pypy/translator/platform/posix.py
Log:
Change the current working directory when calling gcc.
It helps with obscure issues that might be related to
the fact that e.g. our pypy/translator/c directory
contains subdirectories called 'src' or 'gcc'.
Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py (original)
+++ pypy/trunk/pypy/translator/platform/__init__.py Tue Mar 23 13:57:01 2010
@@ -12,7 +12,7 @@
from subprocess import PIPE, Popen
-def _run_subprocess(executable, args, env=None):
+def _run_subprocess(executable, args, env=None, cwd=None):
if isinstance(args, str):
args = str(executable) + ' ' + args
shell = True
@@ -22,7 +22,7 @@
else:
args = [str(executable)] + args
shell = False
- pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env)
+ pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env, cwd=cwd)
stdout, stderr = pipe.communicate()
return pipe.returncode, stdout, stderr
@@ -108,9 +108,10 @@
# some helpers which seem to be cross-platform enough
- def _execute_c_compiler(self, cc, args, outname):
+ def _execute_c_compiler(self, cc, args, outname, cwd=None):
log.execute(cc + ' ' + ' '.join(args))
- returncode, stdout, stderr = _run_subprocess(cc, args, self.c_environ)
+ returncode, stdout, stderr = _run_subprocess(cc, args, self.c_environ,
+ cwd)
self._handle_error(returncode, stderr, stdout, outname)
def _handle_error(self, returncode, stderr, stdout, outname):
Modified: pypy/trunk/pypy/translator/platform/posix.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/posix.py (original)
+++ pypy/trunk/pypy/translator/platform/posix.py Tue Mar 23 13:57:01 2010
@@ -32,7 +32,8 @@
def _compile_c_file(self, cc, cfile, compile_args):
oname = cfile.new(ext='o')
args = ['-c'] + compile_args + [str(cfile), '-o', str(oname)]
- self._execute_c_compiler(cc, args, oname)
+ self._execute_c_compiler(cc, args, oname,
+ cwd=str(cfile.dirpath()))
return oname
def _link(self, cc, ofiles, link_args, standalone, exe_name):
@@ -40,7 +41,8 @@
args += ['-o', str(exe_name)]
if not standalone:
args = self._args_for_shared(args)
- self._execute_c_compiler(cc, args, exe_name)
+ self._execute_c_compiler(cc, args, exe_name,
+ cwd=str(exe_name.dirpath()))
return exe_name
def _preprocess_dirs(self, include_dirs):
More information about the Pypy-commit
mailing list