split project into static and dynamic modules
This commit is contained in:
parent
55dca44b4a
commit
b6b9054d0d
28 changed files with 188 additions and 161 deletions
|
@ -1,10 +1 @@
|
|||
__version__ = "2.5.dev3"
|
||||
|
||||
from ._raylib_cffi import ffi, lib as rl
|
||||
from _raylib_cffi.lib import *
|
||||
from .colors import *
|
||||
from .helpers import *
|
||||
|
||||
|
||||
|
||||
|
||||
__version__ = "2.5.dev4"
|
Binary file not shown.
38
raylib/dynamic/__init__.py
Normal file
38
raylib/dynamic/__init__.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
"""
|
||||
This is an attempt at a CFFI dynamic (ABI) binding. It was failing in the exactly same place the ctypes binding fails, accessing
|
||||
materials of a model. But now it __seems__ to work
|
||||
"""
|
||||
|
||||
import platform
|
||||
|
||||
# Probably unnecessary, just covering all bases in case people add or remove dlls
|
||||
MAC_NAMES = ['libraylib.2.5.0.dylib', 'libraylib.2.dylib', 'libraylib.dylib']
|
||||
LINUX_NAMES = ['libraylib.so.2.5.0','libraylib.so.2', 'libraylib.so']
|
||||
WINDOWS_NAMES = ['libraylib.dll', 'raylib.dll']
|
||||
|
||||
|
||||
if platform.system() == "Darwin":
|
||||
NAMES_TO_TRY = MAC_NAMES
|
||||
elif platform.system() == "Linux":
|
||||
NAMES_TO_TRY = LINUX_NAMES
|
||||
elif platform.system() == "Windows":
|
||||
NAMES_TO_TRY = WINDOWS_NAMES
|
||||
else:
|
||||
NAMES_TO_TRY = MAC_NAMES + LINUX_NAMES + WINDOWS_NAMES
|
||||
|
||||
import pathlib
|
||||
MODULE = pathlib.Path(__file__).parent.parent
|
||||
|
||||
from cffi import FFI
|
||||
ffi = FFI()
|
||||
ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
|
||||
for name in NAMES_TO_TRY:
|
||||
file = str(MODULE)+"/dynamic/"+name
|
||||
try:
|
||||
raylib = ffi.dlopen(file)
|
||||
print("LOADED DYNAMICALLY SHARED LIB "+file)
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
BIN
raylib/dynamic/libraylib.2.5.0.dylib
Normal file
BIN
raylib/dynamic/libraylib.2.5.0.dylib
Normal file
Binary file not shown.
1
raylib/dynamic/libraylib.2.dylib
Symbolic link
1
raylib/dynamic/libraylib.2.dylib
Symbolic link
|
@ -0,0 +1 @@
|
|||
libraylib.2.5.0.dylib
|
BIN
raylib/dynamic/libraylib.dylib
Normal file
BIN
raylib/dynamic/libraylib.dylib
Normal file
Binary file not shown.
|
@ -1,15 +0,0 @@
|
|||
"""
|
||||
This is an attempt at a CFFI dynamic (ABI) binding. However, it fails to work in the exactly same place the ctypes binding fails, accessing
|
||||
materials of a model.
|
||||
"""
|
||||
|
||||
|
||||
import pathlib
|
||||
MODULE = pathlib.Path(__file__).parent.parent
|
||||
|
||||
from cffi import FFI
|
||||
ffi = FFI()
|
||||
ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
|
||||
raylib = ffi.dlopen(str(MODULE)+"/dynamic_binding/libraylib.2.dylib")
|
||||
|
Binary file not shown.
8
raylib/static/__init__.py
Normal file
8
raylib/static/__init__.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from ._raylib_cffi import ffi, lib as rl
|
||||
from _raylib_cffi.lib import *
|
||||
from raylib.colors import *
|
||||
from .helpers import *
|
||||
|
||||
|
||||
print("RAYLIB STATIC LOADED")
|
||||
|
|
@ -490,7 +490,7 @@ static void (*_cffi_call_python_org)(struct _cffi_externpy_s *, char *);
|
|||
/************************************************************/
|
||||
|
||||
|
||||
#include "raylib.h" // the C header of the library
|
||||
#include "../raylib.h" // the C header of the library
|
||||
|
||||
|
||||
/************************************************************/
|
Binary file not shown.
|
@ -6,12 +6,12 @@ import platform
|
|||
ffibuilder = FFI()
|
||||
|
||||
|
||||
ffibuilder.cdef(open("raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.cdef(open("../raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
|
||||
|
||||
ffibuilder.set_source("_raylib_cffi",
|
||||
"""
|
||||
#include "raylib.h" // the C header of the library
|
||||
#include "raylib.h" // the C header, installed in the system include dir we assume
|
||||
""",
|
||||
#library_dirs=['/Volumes/Home/rich/raylib-latest/src'],
|
||||
# extra_link_args=['-Wl,-rpath,.'],
|
|
@ -4,16 +4,16 @@ import platform
|
|||
ffibuilder = FFI()
|
||||
|
||||
|
||||
ffibuilder.cdef(open("raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.cdef(open("../raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
|
||||
|
||||
ffibuilder.set_source("_raylib_cffi",
|
||||
"""
|
||||
#include "raylib.h" // the C header of the library
|
||||
#include "../raylib.h" // the C header of the library, supplied by us here
|
||||
"""
|
||||
)
|
||||
|
||||
# Hack to produce static linked lib
|
||||
# Hack to produce static linked lib using static librarylib.a supplied by us
|
||||
command = "clang -bundle -undefined dynamic_lookup ./_raylib_cffi.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib libraylib.a -F/System/Library/Frameworks -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo -o ./_raylib_cffi.cpython-37m-darwin.so"
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -3,10 +3,10 @@
|
|||
from cffi import FFI
|
||||
|
||||
ffibuilder = FFI()
|
||||
ffibuilder.cdef(open("raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.cdef(open("../raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.set_source("_raylib_cffi",
|
||||
"""
|
||||
#include "raylib.h" // the C header of the library
|
||||
#include "raylib.h" // THIS MIGHT NEED TO BE CHANGED TO "../raylib.h" IF RAYLIB HEADERS NOT FOUND
|
||||
""",
|
||||
extra_link_args=['/NODEFAULTLIB:MSVCRTD'],
|
||||
libraries=['raylib', 'gdi32', 'shell32', 'user32','OpenGL32', 'winmm'],
|
Reference in a new issue