-
Notifications
You must be signed in to change notification settings - Fork 36
/
prepare.php
executable file
·77 lines (62 loc) · 2.42 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
66
67
68
69
70
71
72
73
74
75
76
#!/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('-undefined dynamic_lookup');
if (is_file('/usr/local/opt/llvm/bin/ld64.lld')) {
$p->withBinPath('/usr/local/opt/llvm/bin')
->withBinPath('/usr/local/opt/flex/bin')
->withBinPath('/usr/local/opt/bison/bin')
->withBinPath('/usr/local/opt/libtool/bin')
->withBinPath('/usr/local/opt/m4/bin')
->withBinPath('/usr/local/opt/automake/bin/')
->withBinPath('/usr/local/opt/autoconf/bin/')
->setLinker('ld64.lld');
} elseif (is_file('/opt/homebrew/opt/llvm/bin/ld64.lld')) {
$p->withBinPath('/opt/homebrew/opt/llvm/bin/')
->withBinPath('/opt/homebrew/opt/flex/bin')
->withBinPath('/opt/homebrew/opt/bison/bin')
->withBinPath('/opt/homebrew/opt/libtool/bin')
->withBinPath('/opt/homebrew/opt/m4/bin')
->withBinPath('/opt/homebrew/opt/automake/bin/')
->withBinPath('/opt/homebrew/opt/autoconf/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(' -Os');
// Generate make.sh
$p->execute();