mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
[llvm.py] Initial skeleton for Python LLVM bindings
This contains a semi-functional skeleton for the implementation of the LLVM bindings for Python. The API for the Object.h interface is roughly designed but not implemented. MemoryBufferRef is implemented and actually appears to work! The ObjectFile unit test fails with a segmentation fault because the LLVM library isn't being properly initialized. The build system doesn't know about this code yet, so no alerts should fire. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152397 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
37
bindings/python/llvm/common.py
Normal file
37
bindings/python/llvm/common.py
Normal file
@ -0,0 +1,37 @@
|
||||
#===- common.py - Python LLVM Bindings -----------------------*- python -*--===#
|
||||
#
|
||||
# The LLVM Compiler Infrastructure
|
||||
#
|
||||
# This file is distributed under the University of Illinois Open Source
|
||||
# License. See LICENSE.TXT for details.
|
||||
#
|
||||
#===------------------------------------------------------------------------===#
|
||||
|
||||
from ctypes import cdll
|
||||
|
||||
import ctypes.util
|
||||
import platform
|
||||
|
||||
__all__ = [
|
||||
"find_library",
|
||||
"get_library",
|
||||
]
|
||||
|
||||
def find_library():
|
||||
# FIXME should probably have build system define absolute path of shared
|
||||
# library at install time.
|
||||
for lib in ["LLVM-3.1svn", "LLVM"]:
|
||||
result = ctypes.util.find_library(lib)
|
||||
if result:
|
||||
return result
|
||||
|
||||
# FIXME This is a local hack to ease development.
|
||||
return "/usr/local/llvm/lib/libLLVM-3.1svn.so"
|
||||
|
||||
def get_library():
|
||||
"""Obtain a reference to the llvm library."""
|
||||
lib = find_library()
|
||||
if not lib:
|
||||
raise Exception("LLVM shared library not found!")
|
||||
|
||||
return cdll.LoadLibrary(lib)
|
Reference in New Issue
Block a user