22
22
import platform
23
23
import sys
24
24
25
-
26
25
ffibuilder = FFI ()
27
26
27
+
28
28
def mangle (file ):
29
29
result = ""
30
30
skip = False
31
31
for line in open (file ):
32
- line = line .strip ().replace ("va_list" , "void *" )+ "\n "
32
+ line = line .strip ().replace ("va_list" , "void *" ) + "\n "
33
33
if skip :
34
34
if line .startswith ("#endif" ):
35
35
skip = False
@@ -50,16 +50,14 @@ def mangle(file):
50
50
if line .startswith ("PHYSACDEF" ):
51
51
line = line .replace ('PHYSACDEF ' , '' )
52
52
result += line
53
- print (line )
53
+ # print(line)
54
54
return result
55
55
56
56
57
57
def build_linux ():
58
58
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" ))
61
60
ffibuilder .cdef (open ("raylib/raygui_modified.h" ).read ().replace ('RAYGUIDEF ' , '' ))
62
- #ffibuilder.cdef(mangle("raylib/physac.h"))
63
61
ffibuilder .cdef (open ("raylib/physac_modified.h" ).read ().replace ('PHYSACDEF ' , '' ))
64
62
ffibuilder .set_source ("raylib._raylib_cffi" ,
65
63
"""
@@ -70,18 +68,20 @@ def build_linux():
70
68
#define PHYSAC_IMPLEMENTATION
71
69
#include "physac.h"
72
70
""" ,
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' ],
75
74
include_dirs = ['raylib' ]
76
75
)
77
76
if __name__ == "__main__" :
78
77
ffibuilder .compile (verbose = True )
79
78
79
+
80
80
def build_windows ():
81
81
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' ))
85
85
ffibuilder .set_source ("raylib._raylib_cffi" ,
86
86
"""
87
87
#include "raylib.h"
@@ -92,20 +92,31 @@ def build_windows():
92
92
#include "physac.h"
93
93
""" ,
94
94
extra_link_args = ['/NODEFAULTLIB:MSVCRTD' ],
95
- libraries = ['raylib' , 'gdi32' , 'shell32' , 'user32' ,'OpenGL32' , 'winmm' ],
95
+ libraries = ['raylib' , 'gdi32' , 'shell32' , 'user32' , 'OpenGL32' , 'winmm' ],
96
96
include_dirs = ['raylib' ],
97
97
)
98
98
if __name__ == "__main__" :
99
99
ffibuilder .compile (verbose = True )
100
100
101
+
101
102
def build_mac ():
102
103
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 ' , '' ))
104
107
ffibuilder .set_source ("raylib._raylib_cffi" ,
105
108
"""
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"
107
115
""" ,
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' ],
109
120
)
110
121
111
122
if __name__ == "__main__" :
@@ -114,32 +125,38 @@ def build_mac():
114
125
115
126
def build_rpi_nox ():
116
127
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 ' , '' ))
118
131
ffibuilder .set_source ("raylib._raylib_cffi" ,
119
132
"""
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"
121
139
""" ,
122
140
extra_link_args = ['/usr/local/lib/libraylib.a' ,
123
141
'/opt/vc/lib/libEGL_static.a' , '/opt/vc/lib/libGLESv2_static.a' ,
124
142
'-L/opt/vc/lib' , '-lvcos' , '-lbcm_host' , '-lbrcmEGL' , '-lbrcmGLESv2' ,
125
143
'-lm' , '-lpthread' , '-lrt' ],
144
+ include_dirs = ['raylib' ],
126
145
)
127
146
128
-
129
147
if __name__ == "__main__" :
130
148
ffibuilder .compile (verbose = True )
131
149
132
150
133
-
134
- if platform .system ()== "Darwin" :
151
+ if platform .system () == "Darwin" :
135
152
build_mac ()
136
- elif platform .system ()== "Linux" :
153
+ elif platform .system () == "Linux" :
137
154
if "x86" in platform .machine ():
138
155
build_linux ()
139
156
elif "arm" in platform .machine ():
140
157
build_rpi_nox ()
141
- elif platform .system ()== "Windows" :
158
+ elif platform .system () == "Windows" :
142
159
build_windows ()
143
160
else :
144
161
print ("WARNING: UKKNOWN PLATFORM - trying Linux build" )
145
- build_linux ()
162
+ build_linux ()
0 commit comments