Author: Matti Picus <[email protected]>
Branch: precompiled-headers
Changeset: r69089:bceb0005f00f
Date: 2014-02-06 19:49 +0200
http://bitbucket.org/pypy/pypy/changeset/bceb0005f00f/
Log: backed out changeset: 7fb7c9228605
diff --git a/rpython/translator/platform/posix.py
b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -158,29 +158,16 @@
('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
('LINKFILES', eci.link_files),
]
+ for args in definitions:
+ m.definition(*args)
rules = [
('all', '$(DEFAULT_TARGET)', []),
('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) $(LDFLAGSEXTRA) -o $@
$(OBJECTS) $(LIBDIRS) $(LIBS) $(LINKFILES) $(LDFLAGS)'),
+ ('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $<
$(INCLUDEDIRS)'),
('%.o', '%.cxx', '$(CXX) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $<
$(INCLUDEDIRS)'),
]
- if len(headers_to_precompile)>0:
- stdafx_h = path.join('stdafx.h')
- txt = '#ifndef PYPY_STDAFX_H\n'
- txt += '#define PYPY_STDAFX_H\n'
- txt += '\n'.join(['#include "' + m.pathrel(c) + '"' for c in
headers_to_precompile])
- txt += '\n#endif\n'
- stdafx_h.write(txt)
- rules.append(('$(OBJECTS)', 'stdafx.h.gch', []))
- rules.append(('%.h.gch', '%.h',
- '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $<
$(INCLUDEDIRS)'))
- rules.append(('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA)
-include stdafx.h -o $@ -c $< $(INCLUDEDIRS)'))
- else:
- rules.append(('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@
-c $< $(INCLUDEDIRS)'))
-
- for args in definitions:
- m.definition(*args)
for rule in rules:
m.rule(*rule)
diff --git a/rpython/translator/platform/test/test_makefile.py
b/rpython/translator/platform/test/test_makefile.py
--- a/rpython/translator/platform/test/test_makefile.py
+++ b/rpython/translator/platform/test/test_makefile.py
@@ -6,13 +6,6 @@
from StringIO import StringIO
import re, sys
-import time
-if sys.platform == 'win32':
- get_time = time.clock
-else:
- get_time = time.time
-
-
def test_simple_makefile():
m = Makefile()
m.definition('CC', 'xxx')
@@ -38,7 +31,7 @@
m.write(s)
val = s.getvalue()
assert not re.search('CC += +xxx', val, re.M)
- assert re.search('CC += +yyy', val, re.M)
+ assert re.search('CC += +yyy', val, re.M)
class TestMakefile(object):
platform = host
@@ -48,13 +41,13 @@
assert res.out == expected
if self.strict_on_stderr:
assert res.err == ''
- assert res.returncode == 0
-
+ assert res.returncode == 0
+
def test_900_files(self):
txt = '#include <stdio.h>\n'
for i in range(900):
txt += 'int func%03d();\n' % i
- txt += 'int main() {\n int j=0;'
+ txt += 'int main() {\n int j=0;'
for i in range(900):
txt += ' j += func%03d();\n' % i
txt += ' printf("%d\\n", j);\n'
@@ -78,6 +71,7 @@
self.check_res(res, '%d\n' %sum(range(900)))
def test_precompiled_headers(self):
+ import time
tmpdir = udir.join('precompiled_headers').ensure(dir=1)
# Create an eci that should not use precompiled headers
eci = ExternalCompilationInfo(include_dirs=[tmpdir])
@@ -85,7 +79,7 @@
eci.separate_module_files = [main_c]
ncfiles = 10
nprecompiled_headers = 20
- txt = '#include <stdio.h>\n'
+ txt = ''
for i in range(ncfiles):
txt += "int func%03d();\n" % i
txt += "\nint main(int argc, char * argv[])\n"
@@ -103,8 +97,8 @@
for j in range(3000):
txt += "int pcfunc%03d_%03d();\n" %(i, j)
txt += '#endif'
- pch_name.write(txt)
- cfiles_precompiled_headers.append(pch_name)
+ pch_name.write(txt)
+ cfiles_precompiled_headers.append(pch_name)
# Create some cfiles with headers we want precompiled
cfiles = []
for i in range(ncfiles):
@@ -114,18 +108,18 @@
txt += '#include "%s"\n' % pch_name
txt += "int func%03d(){ return %d;};\n" % (i, i)
c_name.write(txt)
- cfiles.append(c_name)
+ cfiles.append(c_name)
if sys.platform == 'win32':
clean = ('clean', '', 'for %f in ( $(OBJECTS) $(TARGET) ) do @if
exist %f del /f %f')
- else:
+ else:
clean = ('clean', '', 'rm -f $(OBJECTS) $(TARGET) ')
#write a non-precompiled header makefile
mk = self.platform.gen_makefile(cfiles, eci, path=tmpdir)
mk.rule(*clean)
mk.write()
- t0 = get_time()
+ t0 = time.clock()
self.platform.execute_makefile(mk)
- t1 = get_time()
+ t1 = time.clock()
t_normal = t1 - t0
self.platform.execute_makefile(mk, extra_opts=['clean'])
# Write a super-duper makefile with precompiled headers
@@ -133,13 +127,13 @@
headers_to_precompile=cfiles_precompiled_headers,)
mk.rule(*clean)
mk.write()
- t0 = get_time()
+ t0 = time.clock()
self.platform.execute_makefile(mk)
- t1 = get_time()
+ t1 = time.clock()
t_precompiled = t1 - t0
res = self.platform.execute(mk.exe_name)
self.check_res(res, '%d\n' %sum(range(ncfiles)))
print "precompiled haeder 'make' time %.2f, non-precompiled header
time %.2f" %(t_precompiled, t_normal)
- assert t_precompiled < t_normal * 0.8
+ assert t_precompiled < t_normal * 0.5
-
+
diff --git a/rpython/translator/platform/windows.py
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -31,7 +31,7 @@
raise Exception("Win64 is not supported. You must either build for Win32"
" or contribute the missing support in PyPy.")
return _get_compiler_type(cc, True)
-
+
def _get_msvc_env(vsver, x64flag):
try:
toolsdir = os.environ['VS%sCOMNTOOLS' % vsver]
@@ -94,7 +94,7 @@
name = "msvc"
so_ext = 'dll'
exe_ext = 'exe'
-
+
relevant_environ = ('PATH', 'INCLUDE', 'LIB')
cc = 'cl.exe'
@@ -105,7 +105,7 @@
standalone_only = ()
shared_only = ()
environ = None
-
+
def __init__(self, cc=None, x64=False):
self.x64 = x64
msvc_compiler_environ = find_msvc_env(x64)
@@ -136,7 +136,7 @@
else:
masm32 = 'ml.exe'
masm64 = 'ml64.exe'
-
+
if x64:
self.masm = masm64
else:
@@ -336,10 +336,10 @@
definitions.append(('CREATE_PCH', '/Ycstdafx.h /Fpstdafx.pch
/FIstdafx.h'))
definitions.append(('USE_PCH', '/Yustdafx.h /Fpstdafx.pch
/FIstdafx.h'))
rules.append(('$(OBJECTS)', 'stdafx.pch', []))
- rules.append(('stdafx.pch', 'stdafx.h',
+ rules.append(('stdafx.pch', 'stdafx.h',
'$(CC) stdafx.c /c /nologo $(CFLAGS) $(CFLAGSEXTRA) '
'$(CREATE_PCH) $(INCLUDEDIRS)'))
- rules.append(('.c.obj', '',
+ rules.append(('.c.obj', '',
'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) $(USE_PCH) '
'/Fo$@ /c $< $(INCLUDEDIRS)'))
#Do not use precompiled headers for some files
@@ -359,7 +359,7 @@
'/Fo%s /c %s $(INCLUDEDIRS)' %(target, f)))
else:
- rules.append(('.c.obj', '',
+ rules.append(('.c.obj', '',
'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) '
'/Fo$@ /c $< $(INCLUDEDIRS)'))
@@ -369,7 +369,7 @@
for rule in rules:
m.rule(*rule)
-
+
objects = ' $(OBJECTS)'
create_obj_response_file = []
if len(' '.join(rel_ofiles)) > 4000:
@@ -378,7 +378,7 @@
for i in range(len(rel_ofiles) - 1):
create_obj_response_file.append('echo %s >> obj_names.rsp' % \
rel_ofiles[i])
- # use cmd /c for the last one so that the file is flushed
+ # use cmd /c for the last one so that the file is flushed
create_obj_response_file.append('cmd /c echo %s >> obj_names.rsp'
% \
rel_ofiles[-1])
objects = ' @obj_names.rsp'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit