forked from swoole/swoole-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare.php
executable file
·59 lines (46 loc) · 1.63 KB
/
prepare.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use SwooleCli\Preprocessor;
$php_version_tag = trim(file_get_contents(__DIR__ . '/sapi/PHP-VERSION.conf'));
define('BUILD_PHP_VERSION', $php_version_tag);
$homeDir = getenv('HOME');
$p = Preprocessor::getInstance();
$p->parseArguments($argc, $argv);
# clean old make.sh
if (($p->getInputOption('with-build-type') == 'dev') && file_exists(__DIR__ . '/make.sh')) {
unlink(__DIR__ . '/make.sh');
}
// Sync code from php-src
$p->setPhpSrcDir($homeDir . '/.phpbrew/build/php-' . BUILD_PHP_VERSION);
// Compile directly on the host machine, not in the docker container
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
$p->setWorkDir(__DIR__);
$p->setBuildDir(__DIR__ . '/thirdparty');
}
$buildType = $p->getBuildType();
if ($p->getInputOption('with-build-type')) {
$buildType = $p->getInputOption('with-build-type');
$p->setBuildType($buildType);
}
if ($p->getInputOption('with-global-prefix')) {
$p->setGlobalPrefix($p->getInputOption('with-global-prefix'));
}
if ($p->getInputOption('with-parallel-jobs')) {
$p->setMaxJob(intval($p->getInputOption('with-parallel-jobs')));
}
if ($p->isMacos()) {
$p->setExtraLdflags('-undefined dynamic_lookup');
if (is_file('/usr/local/opt/llvm/bin/ld64.lld')) {
$p->withBinPath('/usr/local/opt/llvm/bin')->setLinker('ld64.lld');
} else {
$p->setLinker('lld');
}
$p->setLogicalProcessors('$(sysctl -n hw.ncpu)');
} else {
$p->setLinker('ld.lld');
$p->setLogicalProcessors('$(nproc 2> /dev/null)');
}
$p->setExtraCflags('-fno-ident -Os');
// Generate make.sh
$p->execute();