[pypy-commit] pypy precompiled-headers: implement precompiled header use for windows
mattip
noreply at buildbot.pypy.org
Sat Feb 1 18:56:41 CET 2014
Author: Matti Picus <matti.picus at gmail.com>
Branch: precompiled-headers
Changeset: r69043:d74d5f697984
Date: 2014-01-31 14:56 +0200
http://bitbucket.org/pypy/pypy/changeset/d74d5f697984/
Log: implement precompiled header use for windows
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
@@ -93,9 +93,10 @@
cfiles_precompiled_headers = []
for i in range(nprecompiled_headers):
pch_name =tmpdir.join('pcheader%03d.h' % i)
- txt = ''
+ txt = '#ifndef PCHEADER%03d_H\n#define PCHEADER%03d_H\n' %(i, i)
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)
# Create some cfiles with headers we want precompiled
@@ -108,12 +109,22 @@
txt += "int func%03d(){ return %d;};\n" % (i, i)
c_name.write(txt)
cfiles.append(c_name)
- mk = self.platform.gen_makefile(cfiles, eci, path=udir,
- cfile_precompilation=cfiles_precompiled_headers)
if sys.platform == 'win32':
clean = ('clean', '', 'for %f in ( $(OBJECTS) $(TARGET) ) do @if exist %f del /f %f')
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 = time.clock()
+ self.platform.execute_makefile(mk)
+ t1 = time.clock()
+ t_normal = t1 - t0
+ self.platform.execute_makefile(mk, extra_opts=['clean'])
+ # Write a super-duper makefile with precompiled headers
+ mk = self.platform.gen_makefile(cfiles, eci, path=tmpdir,
+ cfile_precompilation=cfiles_precompiled_headers,)
mk.rule(*clean)
mk.write()
t0 = time.clock()
@@ -122,15 +133,6 @@
t_precompiled = t1 - t0
res = self.platform.execute(mk.exe_name)
self.check_res(res, '%d\n' %sum(range(ncfiles)))
- self.platform.execute_makefile(mk, extra_opts=['clean'])
- #Rewrite a non-precompiled header makefile
- mk = self.platform.gen_makefile(cfiles, eci, path=udir)
- mk.rule(*clean)
- mk.write()
- t0 = time.clock()
- self.platform.execute_makefile(mk)
- t1 = time.clock()
- t_normal = t1 - t0
print "precompiled haeder 'make' time %.2f, non-precompiled header time %.2f" %(t_precompiled, t_normal)
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
@@ -318,15 +318,38 @@
if self.x64:
definitions.append(('_WIN64', '1'))
+ rules = [
+ ('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'),
+ ]
+
+ if cfile_precompilation:
+ 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 cfile_precompilation])
+ txt += '\n#endif\n'
+ stdafx_h.write(txt)
+ stdafx_c = path.join('stdafx.c')
+ stdafx_c.write('#include "stdafx.h"\n')
+ definitions.append(('CREATE_PCH', '/Ycstdafx.h /Fpstdafx.pch /FIstdafx.h'))
+ definitions.append(('USE_PCH', '/Yustdafx.h /Fpstdafx.pch /FIstdafx.h'))
+ rules.append(('all', 'stdafx.pch $(DEFAULT_TARGET)', []))
+ rules.append(('stdafx.pch', '',
+ '$(CC) stdafx.c /c /nologo $(CFLAGS) $(CFLAGSEXTRA) $(CREATE_PCH) $(INCLUDEDIRS)'))
+ rules.append(('.c.obj', '',
+ '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) $(USE_PCH) /Fo$@ /c $< $(INCLUDEDIRS)'))
+
+ target_deps = 'stdafx.obj $(OBJECTS)'
+ else:
+ rules.append(('all', '$(DEFAULT_TARGET)', []))
+ rules.append(('.c.obj', '',
+ '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $< $(INCLUDEDIRS)'))
+ target_deps = '$(OBJECTS)'
+
+
for args in definitions:
m.definition(*args)
- rules = [
- ('all', '$(DEFAULT_TARGET)', []),
- ('.c.obj', '', '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $< $(INCLUDEDIRS)'),
- ('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'),
- ]
-
for rule in rules:
m.rule(*rule)
@@ -343,12 +366,12 @@
rel_ofiles[-1])
objects = ' @obj_names.rsp'
if self.version < 80:
- m.rule('$(TARGET)', '$(OBJECTS)',
+ m.rule('$(TARGET)', target_deps,
create_obj_response_file + [\
'$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA)' + objects + ' /out:$@ $(LIBDIRS) $(LIBS)',
])
else:
- m.rule('$(TARGET)', '$(OBJECTS)',
+ m.rule('$(TARGET)', target_deps,
create_obj_response_file + [\
'$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA)' + objects + ' $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST /MANIFESTFILE:$*.manifest',
'mt.exe -nologo -manifest $*.manifest -outputresource:$@;1',
More information about the pypy-commit
mailing list