@@ -23,7 +23,7 @@ impl<'a> Provider<'a> {
23
23
fn get_php_lib_name ( & self ) -> Result < String > {
24
24
Ok ( self
25
25
. devel
26
- . php_lib ( )
26
+ . php_lib ( self . info . debug ( ) ? )
27
27
. file_stem ( )
28
28
. context ( "Failed to get PHP library name" ) ?
29
29
. to_string_lossy ( )
@@ -85,7 +85,7 @@ impl<'a> PHPProvider<'a> for Provider<'a> {
85
85
let php_lib_name = self . get_php_lib_name ( ) ?;
86
86
let php_lib_search = self
87
87
. devel
88
- . php_lib ( )
88
+ . php_lib ( self . info . debug ( ) ? )
89
89
. parent ( )
90
90
. context ( "Failed to get PHP library parent folder" ) ?
91
91
. to_string_lossy ( )
@@ -233,13 +233,46 @@ impl DevelPack {
233
233
}
234
234
235
235
/// Returns the path of the PHP library containing symbols for linking.
236
- pub fn php_lib ( & self ) -> PathBuf {
237
- let php_nts = self . 0 . join ( "lib" ) . join ( "php8.lib" ) ;
238
- if php_nts. exists ( ) {
239
- php_nts
240
- } else {
241
- self . 0 . join ( "lib" ) . join ( "php8ts.lib" )
236
+ pub fn php_lib ( & self , is_debug : bool ) -> PathBuf {
237
+ let php_lib_path = std:: env:: var ( "PHP_LIB" )
238
+ . map ( PathBuf :: from)
239
+ . unwrap_or_else ( |_| self . 0 . join ( "lib" ) ) ;
240
+
241
+ if !php_lib_path. exists ( ) {
242
+ panic ! (
243
+ "Error: Specified PHP library path '{}' does not exist." ,
244
+ php_lib_path. display( )
245
+ ) ;
242
246
}
247
+
248
+ let candidates = if is_debug {
249
+ [ "php8_debug.lib" , "php8ts_debug.lib" ]
250
+ } else {
251
+ [ "php8.lib" , "php8ts.lib" ]
252
+ } ;
253
+
254
+ candidates
255
+ . iter ( )
256
+ . map ( |lib| php_lib_path. join ( lib) )
257
+ . find ( |path| path. exists ( ) )
258
+ . expect ( & format ! (
259
+ "{}" ,
260
+ if is_debug {
261
+ format!(
262
+ r#"Error: No suitable PHP library found in '{}'.
263
+ To build the application in DEBUG mode on Windows,
264
+ you must have a PHP SDK built with the DEBUG option enabled
265
+ and specify the PHP_LIB to the folder containing the lib files.
266
+ For example: set PHP_LIB=C:\php-sdk\php-dev\vc16\x64\php-8.3.13-src\x64\Debug_TS."# ,
267
+ php_lib_path. display( )
268
+ )
269
+ } else {
270
+ format!(
271
+ "Error: No suitable PHP library found in '{}'." ,
272
+ php_lib_path. display( )
273
+ )
274
+ }
275
+ ) )
243
276
}
244
277
245
278
/// Returns a list of include paths to pass to the compiler.
0 commit comments