2727THIS_DIR = Path (__file__ ).resolve ().parent
2828REPO_ROOT = THIS_DIR .parent
2929
30-
30+ # TODO: I think the customisation is making this file overly complex and probably isn't used
31+ # by many/any users, see discussion at https://github.com/electronstudio/raylib-python-cffi/pull/172
32+ #
3133# Environment variables you can set before build
3234#
3335# RAYLIB_PLATFORM: Any one of: Desktop, SDL, DRM, PLATFORM_COMMA
4345# e.g.: /usr/local/include
4446# LIBFFI_INCLUDE_PATH:
4547# e.g.: /usr/local/include
48+ #
49+ # PKG_CONFIG_LIB_raylib: the package to request from pkg-config for raylib include files, default 'raylib'
50+ # PKG_CONFIG_LIB_raygui: the package to request from pkg-config for raygui include files
51+ # set to 'raygui' if you have a separate raygui package, else unset for default 'raylib'
52+ # PKG_CONFIG_LIB_physac: the package to request from pkg-config for physac indlude files
53+ # set to 'physac' if you have a separate raygui physac, else unset for default 'raylib'
54+ # PKG_CONFIG_LIB_glfw3: the package to request from pkg-config for glfw3 include files
55+ # set to 'glfw3' if you have a separate glfw3 package, else unset for default 'raylib'
56+ # PKG_CONFIG_LIB_libffi: the package to request from pkg-config for libffi include files
4657
4758RAYLIB_PLATFORM = os .getenv ("RAYLIB_PLATFORM" , "Desktop" )
4859
@@ -54,9 +65,11 @@ def check_sdl_pkgconfig_installed():
5465 # this should be 'pkg-config --exists sdl2' but result is non-deterministic on old versions of pkg-config!
5566 return subprocess .run (['pkg-config' , '--libs' , 'sdl2' ], text = True , stdout = subprocess .PIPE ).returncode == 0
5667
57- def get_the_include_path_from_pkgconfig ():
58- return subprocess .run (['pkg-config' , '--variable=includedir' , 'raylib' ], text = True ,
59- stdout = subprocess .PIPE ).stdout .strip ()
68+
69+ def get_the_include_path_from_pkgconfig (libname ):
70+ return subprocess .run (
71+ ['pkg-config' , '--variable=includedir' , os .environ .get ("PKG_CONFIG_LIB_" + libname , 'raylib' )], text = True ,
72+ stdout = subprocess .PIPE ).stdout .strip ()
6073
6174
6275def get_the_lib_path_from_pkgconfig ():
@@ -137,7 +150,7 @@ def build_unix():
137150
138151 raylib_include_path = os .getenv ("RAYLIB_INCLUDE_PATH" )
139152 if raylib_include_path is None :
140- raylib_include_path = get_the_include_path_from_pkgconfig ()
153+ raylib_include_path = get_the_include_path_from_pkgconfig ("raylib" )
141154 raylib_h = raylib_include_path + "/raylib.h"
142155 rlgl_h = raylib_include_path + "/rlgl.h"
143156 raymath_h = raylib_include_path + "/raymath.h"
@@ -159,7 +172,7 @@ def build_unix():
159172
160173 glfw_include_path = os .getenv ("GLFW_INCLUDE_PATH" )
161174 if glfw_include_path is None :
162- glfw_include_path = get_the_include_path_from_pkgconfig ()
175+ glfw_include_path = get_the_include_path_from_pkgconfig ("glfw3" )
163176 glfw3_h = glfw_include_path + "/GLFW/glfw3.h"
164177 if RAYLIB_PLATFORM == "Desktop" and check_header_exists (glfw3_h ):
165178 ffi_includes += """
@@ -168,7 +181,7 @@ def build_unix():
168181
169182 raygui_include_path = os .getenv ("RAYGUI_INCLUDE_PATH" )
170183 if raygui_include_path is None :
171- raygui_include_path = get_the_include_path_from_pkgconfig ()
184+ raygui_include_path = get_the_include_path_from_pkgconfig ("raygui" )
172185 raygui_h = raygui_include_path + "/raygui.h"
173186 if check_header_exists (raygui_h ):
174187 ffi_includes += """
@@ -179,7 +192,7 @@ def build_unix():
179192
180193 physac_include_path = os .getenv ("PHYSAC_INCLUDE_PATH" )
181194 if physac_include_path is None :
182- physac_include_path = get_the_include_path_from_pkgconfig ()
195+ physac_include_path = get_the_include_path_from_pkgconfig ("physac" )
183196 physac_h = physac_include_path + "/physac.h"
184197 if check_header_exists (physac_h ):
185198 ffi_includes += """
@@ -189,7 +202,7 @@ def build_unix():
189202
190203 libffi_include_path = os .getenv ("LIBFFI_INCLUDE_PATH" )
191204 if libffi_include_path is None :
192- libffi_include_path = get_the_include_path_from_pkgconfig ()
205+ libffi_include_path = get_the_include_path_from_pkgconfig ("libffi" )
193206
194207 ffibuilder .cdef (pre_process_header (raylib_h ))
195208 ffibuilder .cdef (pre_process_header (rlgl_h ))
0 commit comments