4
4
5
5
namespace SPC \builder ;
6
6
7
- use PharIo \FileSystem \File ;
8
- use SPC \exception \ExceptionHandler ;
9
- use SPC \exception \FileSystemException ;
7
+ use SPC \exception \BuildFailureException ;
10
8
use SPC \exception \InterruptException ;
11
- use SPC \exception \RuntimeException ;
12
9
use SPC \exception \WrongUsageException ;
13
10
use SPC \store \Config ;
14
11
use SPC \store \FileSystem ;
15
12
use SPC \store \LockFile ;
16
13
use SPC \store \SourceManager ;
17
14
use SPC \store \SourcePatcher ;
18
- use SPC \util \CustomExt ;
15
+ use SPC \util \AttributeMapper ;
19
16
20
17
abstract class BuilderBase
21
18
{
@@ -64,12 +61,11 @@ public function setupLibs(): void
64
61
match ($ status ) {
65
62
LIB_STATUS_OK => logger ()->info ('lib [ ' . $ lib ::NAME . '] setup success, took ' . round (microtime (true ) - $ starttime , 2 ) . ' s ' ),
66
63
LIB_STATUS_ALREADY => logger ()->notice ('lib [ ' . $ lib ::NAME . '] already built ' ),
67
- LIB_STATUS_BUILD_FAILED => logger ()->error ('lib [ ' . $ lib ::NAME . '] build failed ' ),
68
64
LIB_STATUS_INSTALL_FAILED => logger ()->error ('lib [ ' . $ lib ::NAME . '] install failed ' ),
69
65
default => logger ()->warning ('lib [ ' . $ lib ::NAME . '] build status unknown ' ),
70
66
};
71
67
if (in_array ($ status , [LIB_STATUS_BUILD_FAILED , LIB_STATUS_INSTALL_FAILED ])) {
72
- throw new RuntimeException ('Library [ ' . $ lib ::NAME . '] setup failed. ' );
68
+ throw new BuildFailureException ('Library [ ' . $ lib ::NAME . '] setup failed. ' );
73
69
}
74
70
}
75
71
}
@@ -254,9 +250,8 @@ public function buildSharedExts(): void
254
250
}
255
251
$ ext ->buildShared ();
256
252
}
257
- } catch ( RuntimeException $ e ) {
253
+ } finally {
258
254
FileSystem::replaceFileLineContainsString (BUILD_BIN_PATH . '/php-config ' , 'extension_dir= ' , $ extension_dir_line );
259
- throw $ e ;
260
255
}
261
256
FileSystem::replaceFileLineContainsString (BUILD_BIN_PATH . '/php-config ' , 'extension_dir= ' , $ extension_dir_line );
262
257
FileSystem::replaceFileStr (BUILD_LIB_PATH . '/php/build/phpize.m4 ' , '# test "[$]$1" = "no" && $1=yes ' , 'test "[$]$1" = "no" && $1=yes ' );
@@ -311,7 +306,7 @@ public function getPHPVersionID(): int
311
306
return intval ($ match [1 ]);
312
307
}
313
308
314
- throw new RuntimeException ('PHP version file format is malformed, please remove it and download again ' );
309
+ throw new WrongUsageException ('PHP version file format is malformed, please remove "./source/php-src" dir and download/extract again ' );
315
310
}
316
311
317
312
public function getPHPVersion (bool $ exception_on_failure = true ): string
@@ -329,7 +324,7 @@ public function getPHPVersion(bool $exception_on_failure = true): string
329
324
if (!$ exception_on_failure ) {
330
325
return 'unknown ' ;
331
326
}
332
- throw new RuntimeException ('PHP version file format is malformed, please remove it and download again ' );
327
+ throw new WrongUsageException ('PHP version file format is malformed, please remove it and download again ' );
333
328
}
334
329
335
330
/**
@@ -476,7 +471,7 @@ public function emitPatchPoint(string $point_name): void
476
471
foreach ($ patches as $ patch ) {
477
472
try {
478
473
if (!file_exists ($ patch )) {
479
- throw new RuntimeException ("Additional patch script file {$ patch } not found! " );
474
+ throw new WrongUsageException ("Additional patch script file {$ patch } not found! " );
480
475
}
481
476
logger ()->debug ('Running additional patch script: ' . $ patch );
482
477
require $ patch ;
@@ -489,11 +484,6 @@ public function emitPatchPoint(string $point_name): void
489
484
exit ($ e ->getCode ());
490
485
} catch (\Throwable $ e ) {
491
486
logger ()->critical ('Patch script ' . $ patch . ' failed to run. ' );
492
- if ($ this ->getOption ('debug ' )) {
493
- ExceptionHandler::getInstance ()->handle ($ e );
494
- } else {
495
- logger ()->critical ('Please check with --debug option to see more details. ' );
496
- }
497
487
throw $ e ;
498
488
}
499
489
}
0 commit comments