Author: Matti Picus <[email protected]>
Branch: precompiled-headers
Changeset: r69072:9598a8f45a76
Date: 2014-02-02 22:59 +0200
http://bitbucket.org/pypy/pypy/changeset/9598a8f45a76/
Log: add more include guards, permeate headers_to_precompile to
everywhere needed, create windows make targets without precompiled
headers
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -910,6 +910,8 @@
# implement function callbacks and generate function decls
functions = []
pypy_decls = []
+ pypy_decls.append("#ifndef _PYPY_PYPY_DECL_H\n")
+ pypy_decls.append("#define _PYPY_PYPY_DECL_H\n")
pypy_decls.append("#ifndef PYPY_STANDALONE\n")
pypy_decls.append("#ifdef __cplusplus")
pypy_decls.append("extern \"C\" {")
@@ -953,6 +955,7 @@
pypy_decls.append("}")
pypy_decls.append("#endif")
pypy_decls.append("#endif /*PYPY_STANDALONE*/\n")
+ pypy_decls.append("#endif /*_PYPY_PYPY_DECL_H*/\n")
pypy_decl_h = udir.join('pypy_decl.h')
pypy_decl_h.write('\n'.join(pypy_decls))
diff --git a/rpython/translator/c/dlltool.py b/rpython/translator/c/dlltool.py
--- a/rpython/translator/c/dlltool.py
+++ b/rpython/translator/c/dlltool.py
@@ -21,7 +21,8 @@
entrypoints.append(getfunctionptr(graph))
return entrypoints
- def gen_makefile(self, targetdir, exe_name=None):
+ def gen_makefile(self, targetdir, exe_name=None,
+ headers_to_precompile=[]):
pass # XXX finish
def compile(self):
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -260,12 +260,13 @@
defines['PYPY_MAIN_FUNCTION'] = "pypy_main_startup"
self.eci = self.eci.merge(ExternalCompilationInfo(
export_symbols=["pypy_main_startup", "pypy_debug_file"]))
- self.eci, cfile, extra = gen_source(db, modulename, targetdir,
- self.eci, defines=defines,
- split=self.split)
+ self.eci, cfile, extra, headers_to_precompile = \
+ gen_source(db, modulename, targetdir,
+ self.eci, defines=defines, split=self.split)
self.c_source_filename = py.path.local(cfile)
self.extrafiles = self.eventually_copy(extra)
- self.gen_makefile(targetdir, exe_name=exe_name)
+ self.gen_makefile(targetdir, exe_name=exe_name,
+ headers_to_precompile=headers_to_precompile)
return cfile
def eventually_copy(self, cfiles):
@@ -375,13 +376,14 @@
self._compiled = True
return self.executable_name
- def gen_makefile(self, targetdir, exe_name=None):
+ def gen_makefile(self, targetdir, exe_name=None, headers_to_precompile=[]):
cfiles = [self.c_source_filename] + self.extrafiles
if exe_name is not None:
exe_name = targetdir.join(exe_name)
mk = self.translator.platform.gen_makefile(
cfiles, self.eci,
path=targetdir, exe_name=exe_name,
+ headers_to_precompile=headers_to_precompile,
shared=self.config.translation.shared)
if self.has_profopt():
@@ -511,6 +513,7 @@
def __init__(self, database):
self.database = database
self.extrafiles = []
+ self.headers_to_precompile = []
self.path = None
self.namespace = NameManager()
@@ -539,6 +542,8 @@
filepath = self.path.join(name)
if name.endswith('.c'):
self.extrafiles.append(filepath)
+ if name.endswith('.h'):
+ self.headers_to_precompile.append(filepath)
return filepath.open('w')
def getextrafiles(self):
@@ -732,12 +737,14 @@
print >> f, "#endif"
def gen_preimpl(f, database):
+ f.write('#ifndef _PY_PREIMPLE_H\n#define _PY_PREIMPL_H\n')
if database.translator is None or database.translator.rtyper is None:
return
preimplementationlines = pre_include_code_lines(
database, database.translator.rtyper)
for line in preimplementationlines:
print >> f, line
+ f.write('#endif /* _PY_PREIMPL_H */\n')
def gen_startupcode(f, database):
# generate the start-up code and put it into a function
@@ -799,6 +806,7 @@
f = filename.open('w')
incfilename = targetdir.join('common_header.h')
fi = incfilename.open('w')
+ fi.write('#ifndef _PY_COMMON_HEADER_H\n#define _PY_COMMON_HEADER_H\n')
#
# Header
@@ -811,6 +819,7 @@
eci.write_c_header(fi)
print >> fi, '#include "src/g_prerequisite.h"'
+ fi.write('#endif /* _PY_COMMON_HEADER_H*/\n')
fi.close()
@@ -822,6 +831,8 @@
sg.set_strategy(targetdir, split)
database.prepare_inline_helpers()
sg.gen_readable_parts_of_source(f)
+ headers_to_precompile = sg.headers_to_precompile[:]
+ headers_to_precompile.insert(0, incfilename)
gen_startupcode(f, database)
f.close()
@@ -835,4 +846,4 @@
eci = add_extra_files(eci)
eci = eci.convert_sources_to_files()
files, eci = eci.get_module_files()
- return eci, filename, sg.getextrafiles() + list(files)
+ return eci, filename, sg.getextrafiles() + list(files),
headers_to_precompile
diff --git a/rpython/translator/platform/__init__.py
b/rpython/translator/platform/__init__.py
--- a/rpython/translator/platform/__init__.py
+++ b/rpython/translator/platform/__init__.py
@@ -100,7 +100,7 @@
return ExecutionResult(returncode, stdout, stderr)
def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
- shared=False, cfile_precompilation=None):
+ shared=False, headers_to_precompile=[]):
raise NotImplementedError("Pure abstract baseclass")
def __repr__(self):
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
@@ -83,7 +83,7 @@
return [entry[2:] for entry in out.split()]
def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
- shared=False, cfile_precompilation=None):
+ shared=False, headers_to_precompile=[]):
cfiles = self._all_cfiles(cfiles, eci)
if path is None:
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
@@ -249,7 +249,7 @@
def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
- shared=False, cfile_precompilation=None):
+ shared=False, headers_to_precompile=[]):
cfiles = self._all_cfiles(cfiles, eci)
if path is None:
@@ -319,32 +319,35 @@
definitions.append(('_WIN64', '1'))
rules = [
+ ('all', '$(DEFAULT_TARGET)', []),
('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'),
]
- if cfile_precompilation:
+ 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
cfile_precompilation])
+ txt += '\n'.join(['#include "' + m.pathrel(c) + '"' for c in
headers_to_precompile])
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', '',
+ rules.append(('$(OBJECTS)', 'stdafx.pch', []))
+ rules.append(('stdafx.pch', 'stdafx.h',
'$(CC) stdafx.c /c /nologo $(CFLAGS) $(CFLAGSEXTRA)
$(CREATE_PCH) $(INCLUDEDIRS)'))
rules.append(('.c.obj', '',
'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) $(USE_PCH) /Fo$@
/c $< $(INCLUDEDIRS)'))
+ #Do not use precompiled headers for some files
+ rules.append((r'{..\module_cache}.c{..\module_cache}.obj', '',
+ '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $<
$(INCLUDEDIRS)'))
+ rules.append(('allocator.obj', 'allocator.c',
+ '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /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:
@@ -366,12 +369,12 @@
rel_ofiles[-1])
objects = ' @obj_names.rsp'
if self.version < 80:
- m.rule('$(TARGET)', target_deps,
+ m.rule('$(TARGET)', '$(OBJECTS)',
create_obj_response_file + [\
'$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA)' + objects +
' /out:$@ $(LIBDIRS) $(LIBS)',
])
else:
- m.rule('$(TARGET)', target_deps,
+ m.rule('$(TARGET)', '$(OBJECTS)',
create_obj_response_file + [\
'$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA)' + objects
+ ' $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST
/MANIFESTFILE:$*.manifest',
'mt.exe -nologo -manifest $*.manifest
-outputresource:$@;1',
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit