2222import platform
2323import sys
2424
25-
2625ffibuilder = FFI ()
2726
27+
2828def mangle (file ):
2929 result = ""
3030 skip = False
3131 for line in open (file ):
32- line = line .strip ().replace ("va_list" , "void *" )+ "\n "
32+ line = line .strip ().replace ("va_list" , "void *" ) + "\n "
3333 if skip :
3434 if line .startswith ("#endif" ):
3535 skip = False
@@ -50,16 +50,14 @@ def mangle(file):
5050 if line .startswith ("PHYSACDEF" ):
5151 line = line .replace ('PHYSACDEF ' , '' )
5252 result += line
53- print (line )
53+ # print(line)
5454 return result
5555
5656
5757def build_linux ():
5858 print ("BUILDING FOR LINUX" )
59- ffibuilder .cdef (mangle ("raylib/raylib.h" ))
60- #ffibuilder.cdef(mangle("raylib/raygui.h"))
59+ ffibuilder .cdef (mangle ("/usr/local/include/raylib.h" ))
6160 ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ))
62- #ffibuilder.cdef(mangle("raylib/physac.h"))
6361 ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ))
6462 ffibuilder .set_source ("raylib._raylib_cffi" ,
6563 """
@@ -70,18 +68,20 @@ def build_linux():
7068 #define PHYSAC_IMPLEMENTATION
7169 #include "physac.h"
7270 """ ,
73- extra_link_args = ['/usr/local/lib/libraylib.a' ,'-lm' , '-lpthread' , '-lGLU' , '-lGL' , '-lrt' , '-lm' , '-ldl' , '-lX11' , '-lpthread' ],
74- libraries = ['GL' ,'m' ,'pthread' , 'dl' , 'rt' , 'X11' ],
71+ extra_link_args = ['/usr/local/lib/libraylib.a' , '-lm' , '-lpthread' , '-lGLU' , '-lGL' , '-lrt' ,
72+ '-lm' , '-ldl' , '-lX11' , '-lpthread' ],
73+ libraries = ['GL' , 'm' , 'pthread' , 'dl' , 'rt' , 'X11' ],
7574 include_dirs = ['raylib' ]
7675 )
7776 if __name__ == "__main__" :
7877 ffibuilder .compile (verbose = True )
7978
79+
8080def build_windows ():
8181 print ("BUILDING FOR WINDOWS" )
82- ffibuilder .cdef (mangle ("raylib/raylib.h" ))
83- ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ).replace ('bool' ,'int' ))
84- ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ).replace ('bool' ,'int' ))
82+ ffibuilder .cdef (mangle ("raylib/raylib.h" ). replace ( 'bool' , 'int' ) )
83+ ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ).replace ('bool' , 'int' ))
84+ ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ).replace ('bool' , 'int' ))
8585 ffibuilder .set_source ("raylib._raylib_cffi" ,
8686 """
8787 #include "raylib.h"
@@ -92,20 +92,31 @@ def build_windows():
9292 #include "physac.h"
9393 """ ,
9494 extra_link_args = ['/NODEFAULTLIB:MSVCRTD' ],
95- libraries = ['raylib' , 'gdi32' , 'shell32' , 'user32' ,'OpenGL32' , 'winmm' ],
95+ libraries = ['raylib' , 'gdi32' , 'shell32' , 'user32' , 'OpenGL32' , 'winmm' ],
9696 include_dirs = ['raylib' ],
9797 )
9898 if __name__ == "__main__" :
9999 ffibuilder .compile (verbose = True )
100100
101+
101102def build_mac ():
102103 print ("BUILDING FOR MAC" )
103- ffibuilder .cdef (open ("raylib/raylib_modified.h" ).read ().replace ('RLAPI ' , '' ))
104+ ffibuilder .cdef (mangle ("/usr/local/include/raylib.h" ))
105+ ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ))
106+ ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ))
104107 ffibuilder .set_source ("raylib._raylib_cffi" ,
105108 """
106- #include "../../raylib/raylib.h" // the C header of the library, supplied by us here
109+ #include "raylib.h"
110+ #define RAYGUI_IMPLEMENTATION
111+ #define RAYGUI_SUPPORT_RICONS
112+ #include "raygui.h"
113+ #define PHYSAC_IMPLEMENTATION
114+ #include "physac.h"
107115 """ ,
108- extra_link_args = ['/usr/local/lib/libraylib.a' , '-framework' , 'OpenGL' , '-framework' , 'Cocoa' , '-framework' , 'IOKit' , '-framework' , 'CoreFoundation' , '-framework' , 'CoreVideo' ],
116+ extra_link_args = ['/usr/local/lib/libraylib.a' , '-framework' , 'OpenGL' , '-framework' , 'Cocoa' ,
117+ '-framework' , 'IOKit' , '-framework' , 'CoreFoundation' , '-framework' ,
118+ 'CoreVideo' ],
119+ include_dirs = ['raylib' ],
109120 )
110121
111122 if __name__ == "__main__" :
@@ -114,32 +125,38 @@ def build_mac():
114125
115126def build_rpi_nox ():
116127 print ("BUILDING FOR RASPBERRY PI" )
117- ffibuilder .cdef (mangle ("raylib/raylib.h" ))
128+ ffibuilder .cdef (mangle ("/usr/local/include/raylib.h" ))
129+ ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ))
130+ ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ))
118131 ffibuilder .set_source ("raylib._raylib_cffi" ,
119132 """
120- #include "../../raylib/raylib.h"
133+ #include "raylib.h"
134+ #define RAYGUI_IMPLEMENTATION
135+ #define RAYGUI_SUPPORT_RICONS
136+ #include "raygui.h"
137+ #define PHYSAC_IMPLEMENTATION
138+ #include "physac.h"
121139 """ ,
122140 extra_link_args = ['/usr/local/lib/libraylib.a' ,
123141 '/opt/vc/lib/libEGL_static.a' , '/opt/vc/lib/libGLESv2_static.a' ,
124142 '-L/opt/vc/lib' , '-lvcos' , '-lbcm_host' , '-lbrcmEGL' , '-lbrcmGLESv2' ,
125143 '-lm' , '-lpthread' , '-lrt' ],
144+ include_dirs = ['raylib' ],
126145 )
127146
128-
129147 if __name__ == "__main__" :
130148 ffibuilder .compile (verbose = True )
131149
132150
133-
134- if platform .system ()== "Darwin" :
151+ if platform .system () == "Darwin" :
135152 build_mac ()
136- elif platform .system ()== "Linux" :
153+ elif platform .system () == "Linux" :
137154 if "x86" in platform .machine ():
138155 build_linux ()
139156 elif "arm" in platform .machine ():
140157 build_rpi_nox ()
141- elif platform .system ()== "Windows" :
158+ elif platform .system () == "Windows" :
142159 build_windows ()
143160else :
144161 print ("WARNING: UKKNOWN PLATFORM - trying Linux build" )
145- build_linux ()
162+ build_linux ()
0 commit comments