本文整理汇总了Python中pypy.translator.tool.cbuild.ExternalCompilationInfo.merge方法的典型用法代码示例。如果您正苦于以下问题:Python ExternalCompilationInfo.merge方法的具体用法?Python ExternalCompilationInfo.merge怎么用?Python ExternalCompilationInfo.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.translator.tool.cbuild.ExternalCompilationInfo
的用法示例。
在下文中一共展示了ExternalCompilationInfo.merge方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_eci
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def get_eci(self):
from distutils import sysconfig
python_inc = sysconfig.get_python_inc()
eci = ExternalCompilationInfo(
include_dirs=[python_inc],
includes=["Python.h",
],
)
return eci.merge(CBuilder.get_eci(self))
示例2: get_rsdl_compilation_info
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def get_rsdl_compilation_info():
if sys.platform == 'darwin':
eci = ExternalCompilationInfo(
includes = ['SDL.h'],
include_dirs = ['/Library/Frameworks/SDL.framework/Headers'],
link_files = [
str(py.magic.autopath().dirpath().join('macosx-sdl-main/SDLMain.m')),
],
frameworks = ['SDL', 'Cocoa']
)
else:
eci = ExternalCompilationInfo(
includes=['SDL.h'],
)
eci = eci.merge(ExternalCompilationInfo.from_config_tool('sdl-config'))
return eci
示例3: test_merge2
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def test_merge2(self):
e1 = ExternalCompilationInfo(
pre_include_bits = ['1'],
link_files = ['1.c']
)
e2 = ExternalCompilationInfo(
pre_include_bits = ['2'],
link_files = ['1.c', '2.c']
)
e3 = ExternalCompilationInfo(
pre_include_bits = ['3'],
link_files = ['1.c', '2.c', '3.c']
)
e = e1.merge(e2)
e = e.merge(e3, e3)
assert e.pre_include_bits == ('1', '2', '3')
assert e.link_files == ('1.c', '2.c', '3.c')
示例4: test_platforms
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def test_platforms(self):
from pypy.translator.platform import Platform
class Maemo(Platform):
def __init__(self, cc=None):
self.cc = cc
eci = ExternalCompilationInfo(platform=Maemo())
eci2 = ExternalCompilationInfo()
assert eci != eci2
assert hash(eci) != hash(eci2)
assert repr(eci) != repr(eci2)
py.test.raises(Exception, eci2.merge, eci)
assert eci.merge(eci).platform == Maemo()
assert (ExternalCompilationInfo(platform=Maemo(cc='xxx')) !=
ExternalCompilationInfo(platform=Maemo(cc='yyy')))
assert (repr(ExternalCompilationInfo(platform=Maemo(cc='xxx'))) !=
repr(ExternalCompilationInfo(platform=Maemo(cc='yyy'))))
示例5: test_merge
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def test_merge(self):
e1 = ExternalCompilationInfo(
pre_include_bits = ['1'],
includes = ['x.h'],
post_include_bits = ['p1']
)
e2 = ExternalCompilationInfo(
pre_include_bits = ['2'],
includes = ['x.h', 'y.h'],
post_include_bits = ['p2'],
)
e3 = ExternalCompilationInfo(
pre_include_bits = ['3'],
includes = ['y.h', 'z.h'],
post_include_bits = ['p1', 'p3']
)
e = e1.merge(e2, e3)
assert e.pre_include_bits == ('1', '2', '3')
assert e.includes == ('x.h', 'y.h', 'z.h')
assert e.post_include_bits == ('p1', 'p2', 'p3')
示例6: ExternalCompilationInfo
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
from pypy.rlib.rsdl import RSDL
if sys.platform == 'darwin':
eci = ExternalCompilationInfo(
includes = ['SDL_mixer.h'],
frameworks = ['SDL_mixer'],
include_dirs = ['/Library/Frameworks/SDL_Mixer.framework/Headers']
)
else:
eci = ExternalCompilationInfo(
includes=['SDL_mixer.h'],
libraries=['SDL_mixer'],
)
eci = eci.merge(RSDL.eci)
eci = eci.merge(eci)
eci = eci.merge(eci)
ChunkPtr = lltype.Ptr(lltype.ForwardReference())
class CConfig:
_compilation_info_ = eci
Chunk = platform.Struct('Mix_Chunk', [('allocated', rffi.INT),
('abuf', RSDL.Uint8P),
('alen', RSDL.Uint32),
('volume', RSDL.Uint8)])
globals().update(platform.configure(CConfig))
示例7: CBuilder
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
class CBuilder(object):
c_source_filename = None
_compiled = False
modulename = None
def __init__(self, translator, entrypoint, config, gcpolicy=None):
self.translator = translator
self.entrypoint = entrypoint
self.entrypoint_name = self.entrypoint.func_name
self.originalentrypoint = entrypoint
self.config = config
self.gcpolicy = gcpolicy # for tests only, e.g. rpython/memory/
if gcpolicy is not None and gcpolicy.requires_stackless:
config.translation.stackless = True
self.eci = ExternalCompilationInfo()
def build_database(self):
translator = self.translator
gcpolicyclass = self.get_gcpolicyclass()
if self.config.translation.gcrootfinder == "asmgcc":
if not self.standalone:
raise NotImplementedError("--gcrootfinder=asmgcc requires standalone")
if self.config.translation.stackless:
if not self.standalone:
raise Exception("stackless: only for stand-alone builds")
from pypy.translator.stackless.transform import StacklessTransformer
stacklesstransformer = StacklessTransformer(
translator, self.originalentrypoint,
stackless_gc=gcpolicyclass.requires_stackless)
self.entrypoint = stacklesstransformer.slp_entry_point
else:
stacklesstransformer = None
db = LowLevelDatabase(translator, standalone=self.standalone,
gcpolicyclass=gcpolicyclass,
stacklesstransformer=stacklesstransformer,
thread_enabled=self.config.translation.thread,
sandbox=self.config.translation.sandbox)
self.db = db
# give the gc a chance to register interest in the start-up functions it
# need (we call this for its side-effects of db.get())
list(db.gcpolicy.gc_startup_code())
# build entrypoint and eventually other things to expose
pf = self.getentrypointptr()
pfname = db.get(pf)
self.c_entrypoint_name = pfname
db.complete()
self.collect_compilation_info(db)
return db
have___thread = None
def collect_compilation_info(self, db):
# we need a concrete gcpolicy to do this
self.eci = self.eci.merge(ExternalCompilationInfo(
libraries=db.gcpolicy.gc_libraries()))
all = []
for node in self.db.globalcontainers():
eci = getattr(node, 'compilation_info', None)
if eci:
all.append(eci)
self.eci = self.eci.merge(*all)
def get_gcpolicyclass(self):
if self.gcpolicy is None:
name = self.config.translation.gctransformer
if self.config.translation.gcrootfinder == "stackless":
name = "%s+stacklessgc" % (name,)
elif self.config.translation.gcrootfinder == "llvmgc":
name = "%s+llvmgcroot" % (name,)
elif self.config.translation.gcrootfinder == "asmgcc":
name = "%s+asmgcroot" % (name,)
return gc.name_to_gcpolicy[name]
return self.gcpolicy
# use generate_source(defines=DEBUG_DEFINES) to force the #definition
# of the macros that enable debugging assertions
DEBUG_DEFINES = {'RPY_ASSERT': 1,
'RPY_LL_ASSERT': 1}
def generate_source(self, db=None, defines={}):
assert self.c_source_filename is None
translator = self.translator
if db is None:
db = self.build_database()
pf = self.getentrypointptr()
pfname = db.get(pf)
if self.modulename is None:
self.modulename = uniquemodulename('testing')
modulename = self.modulename
targetdir = udir.ensure(modulename, dir=1)
#.........这里部分代码省略.........