[pypy-svn] r76738 - in pypy/trunk/pypy/translator: c/test platform platform/test
arigo at codespeak.net
arigo at codespeak.net
Thu Aug 26 10:33:55 CEST 2010
Author: arigo
Date: Thu Aug 26 10:33:52 2010
New Revision: 76738
Modified:
pypy/trunk/pypy/translator/c/test/test_standalone.py
pypy/trunk/pypy/translator/platform/__init__.py
pypy/trunk/pypy/translator/platform/test/test_platform.py
Log:
Support for the env var CC containing the name of the compiler followed
by some compiler options.
Modified: pypy/trunk/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/trunk/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/trunk/pypy/translator/c/test/test_standalone.py Thu Aug 26 10:33:52 2010
@@ -604,6 +604,33 @@
out, err = cbuilder.cmdexec("a b")
assert out == "3"
+ def test_gcc_options(self):
+ # check that the env var CC is correctly interpreted, even if
+ # it contains the compiler name followed by some options.
+ if sys.platform == 'win32':
+ py.test.skip("only for gcc")
+
+ from pypy.rpython.lltypesystem import lltype, rffi
+ dir = udir.ensure('test_gcc_options', dir=1)
+ dir.join('someextraheader.h').write('#define someextrafunc() 42\n')
+ eci = ExternalCompilationInfo(includes=['someextraheader.h'])
+ someextrafunc = rffi.llexternal('someextrafunc', [], lltype.Signed,
+ compilation_info=eci)
+
+ def entry_point(argv):
+ return someextrafunc()
+
+ old_cc = os.environ.get('CC')
+ try:
+ os.environ['CC'] = 'gcc -I%s' % dir
+ t, cbuilder = self.compile(entry_point)
+ finally:
+ if old_cc is None:
+ del os.environ['CC']
+ else:
+ os.environ['CC'] = old_cc
+
+
class TestMaemo(TestStandalone):
def setup_class(cls):
py.test.skip("TestMaemo: tests skipped for now")
Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py (original)
+++ pypy/trunk/pypy/translator/platform/__init__.py Thu Aug 26 10:33:52 2010
@@ -99,15 +99,20 @@
self.__dict__ == other.__dict__)
def key(self):
- bits = [self.__class__.__name__, 'cc=%s' % self.cc]
+ bits = [self.__class__.__name__, 'cc=%r' % self.cc]
for varname in self.relevant_environ:
- bits.append('%s=%s' % (varname, os.environ.get(varname)))
+ bits.append('%s=%r' % (varname, os.environ.get(varname)))
return ' '.join(bits)
# some helpers which seem to be cross-platform enough
def _execute_c_compiler(self, cc, args, outname, cwd=None):
log.execute(cc + ' ' + ' '.join(args))
+ # 'cc' can also contain some options for the C compiler;
+ # e.g. it can be "gcc -m32". We handle it by splitting on ' '.
+ cclist = cc.split()
+ cc = cclist[0]
+ args = cclist[1:] + args
returncode, stdout, stderr = _run_subprocess(cc, args, self.c_environ,
cwd)
self._handle_error(returncode, stderr, stdout, outname)
Modified: pypy/trunk/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_platform.py (original)
+++ pypy/trunk/pypy/translator/platform/test/test_platform.py Thu Aug 26 10:33:52 2010
@@ -131,7 +131,7 @@
self.cc = 'xcc'
x = XPlatform()
res = x.key()
- assert res.startswith('XPlatform cc=xcc CPATH=')
+ assert res.startswith("XPlatform cc='xcc' CPATH=")
def test_equality():
class X(Platform):
More information about the Pypy-commit
mailing list