forked from swoole/swoole-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.php
executable file
·66 lines (51 loc) · 1.95 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
60
61
62
63
64
65
#!/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);
$buildType = $p->getBuildType();
if ($p->getInputOption('with-build-type')) {
$buildType = $p->getInputOption('with-build-type');
$p->setBuildType($buildType);
}
# clean old make.sh
if (($buildType == 'dev') && file_exists(__DIR__ . '/make.sh')) {
unlink(__DIR__ . '/make.sh');
}
// Sync code from php-src
$p->setPhpSrcDir($p->getWorkDir() . '/var/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');
}
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('');
$homebrew_prefix = trim(shell_exec('brew --prefix'));
$p->withBinPath($homebrew_prefix . '/opt/llvm/bin')
->withBinPath($homebrew_prefix . '/opt/flex/bin')
->withBinPath($homebrew_prefix . '/opt/bison/bin')
->withBinPath($homebrew_prefix . '/opt/libtool/bin')
->withBinPath($homebrew_prefix . '/opt/m4/bin')
->withBinPath($homebrew_prefix . '/opt/automake/bin/')
->withBinPath($homebrew_prefix . '/opt/autoconf/bin/')
->withBinPath($homebrew_prefix . '/opt/gettext/bin')
->setLinker('ld64.lld');
$p->setLogicalProcessors('$(sysctl -n hw.ncpu)');
} else {
$p->setLinker('ld.lld');
$p->setLogicalProcessors('$(nproc 2> /dev/null)');
}
$p->setExtraCflags(' -Os');
// Generate make.sh
$p->execute();