Compare commits

..

1 Commits

Author SHA1 Message Date
crazywhalecc
ee3be6f374 add pocketmine support 2023-12-21 21:57:03 +08:00
20 changed files with 187 additions and 263 deletions

View File

@@ -140,7 +140,7 @@ jobs:
run: bin/spc doctor --auto-fix run: bin/spc doctor --auto-fix
- name: "Run Build Tests (download)" - name: "Run Build Tests (download)"
run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug
- name: "Run Build Tests (build)" - name: "Run Build Tests (build)"
run: bin/spc build $(php src/globals/test-extensions.php cmd) --build-cli --build-micro --build-fpm --debug run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug

View File

@@ -16,6 +16,14 @@
"calendar": { "calendar": {
"type": "builtin" "type": "builtin"
}, },
"crypto": {
"type": "external",
"arg-type": "with",
"source": "ext-crypto",
"lib-depends": [
"openssl"
]
},
"ctype": { "ctype": {
"type": "builtin" "type": "builtin"
}, },
@@ -168,6 +176,14 @@
"openssl" "openssl"
] ]
}, },
"leveldb": {
"type": "external",
"arg-type": "with-prefix",
"source": "pmmp-leveldb",
"lib-depends": [
"leveldb"
]
},
"mbregex": { "mbregex": {
"type": "builtin", "type": "builtin",
"arg-type": "custom", "arg-type": "custom",
@@ -217,6 +233,10 @@
"zlib" "zlib"
] ]
}, },
"morton": {
"type": "external",
"source": "ext-morton"
},
"mysqli": { "mysqli": {
"type": "builtin", "type": "builtin",
"arg-type": "with", "arg-type": "with",
@@ -303,6 +323,16 @@
"zlib" "zlib"
] ]
}, },
"pmmp-chunkutils2": {
"type": "external",
"source": "pmmp-chunkutils2",
"arg-type": "custom",
"cpp-extension": true
},
"pmmpthread": {
"type": "external",
"source": "pmmpthread"
},
"posix": { "posix": {
"type": "builtin", "type": "builtin",
"unix-only": true "unix-only": true
@@ -335,12 +365,7 @@
"source": "redis", "source": "redis",
"arg-type": "custom", "arg-type": "custom",
"ext-suggests": [ "ext-suggests": [
"session", "session"
"igbinary"
],
"lib-suggests": [
"zstd",
"liblz4"
] ]
}, },
"session": { "session": {
@@ -400,17 +425,6 @@
"sqlite" "sqlite"
] ]
}, },
"sqlsrv": {
"type": "external",
"source": "sqlsrv",
"lib-depends": [
"unixodbc"
],
"cpp-extension": true,
"ext-depends-linux": [
"pcntl"
]
},
"ssh2": { "ssh2": {
"type": "external", "type": "external",
"source": "ext-ssh2", "source": "ext-ssh2",
@@ -471,14 +485,6 @@
"tokenizer": { "tokenizer": {
"type": "builtin" "type": "builtin"
}, },
"uv": {
"type": "external",
"source": "ext-uv",
"arg-type": "with-prefix",
"lib-depends": [
"libuv"
]
},
"xlswriter": { "xlswriter": {
"type": "external", "type": "external",
"source": "xlswriter", "source": "xlswriter",

View File

@@ -163,6 +163,13 @@
"libsodium" "libsodium"
] ]
}, },
"leveldb": {
"source": "leveldb",
"static-libs-unix": [
"libleveldb.a"
],
"cpp-library": true
},
"libargon2": { "libargon2": {
"source": "libargon2", "source": "libargon2",
"static-libs-unix": [ "static-libs-unix": [
@@ -224,10 +231,10 @@
"libturbojpeg.a" "libturbojpeg.a"
] ]
}, },
"liblz4": { "libmcrypt": {
"source": "liblz4", "source": "libmcrypt",
"static-libs-unix": [ "static-libs-unix": [
"liblz4.a" "libmcrypt.a"
] ]
}, },
"libmemcached": { "libmemcached": {
@@ -284,12 +291,6 @@
"zlib" "zlib"
] ]
}, },
"libuv": {
"source": "libuv",
"static-libs-unix": [
"libuv.a"
]
},
"libwebp": { "libwebp": {
"source": "libwebp", "source": "libwebp",
"static-libs-unix": [ "static-libs-unix": [
@@ -374,6 +375,12 @@
"openssl" "openssl"
] ]
}, },
"mcrypt": {
"source": "mcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"ncurses": { "ncurses": {
"source": "ncurses", "source": "ncurses",
"static-libs-unix": [ "static-libs-unix": [
@@ -496,17 +503,6 @@
"libtidy.a" "libtidy.a"
] ]
}, },
"unixodbc": {
"source": "unixodbc",
"static-libs-unix": [
"libodbc.a",
"libodbccr.a",
"libodbcinst.a"
],
"lib-depends": [
"libiconv"
]
},
"xz": { "xz": {
"source": "xz", "source": "xz",
"static-libs-unix": [ "static-libs-unix": [

View File

@@ -42,6 +42,16 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"ext-crypto": {
"type": "git",
"path": "php-src/ext/crypto",
"rev": "master",
"url": "https://github.com/bukka/php-crypto.git",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-event": { "ext-event": {
"type": "url", "type": "url",
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", "url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
@@ -80,6 +90,16 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-morton": {
"type": "git",
"path": "php-src/ext/morton",
"rev": "master",
"url": "https://github.com/pmmp/ext-morton.git",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-snappy": { "ext-snappy": {
"type": "git", "type": "git",
"path": "php-src/ext/snappy", "path": "php-src/ext/snappy",
@@ -100,16 +120,6 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-uv": {
"type": "url",
"url": "https://pecl.php.net/get/uv",
"path": "php-src/ext/uv",
"filename": "uv.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-zstd": { "ext-zstd": {
"type": "git", "type": "git",
"path": "php-src/ext/zstd", "path": "php-src/ext/zstd",
@@ -147,10 +157,9 @@
} }
}, },
"igbinary": { "igbinary": {
"type": "url", "type": "ghtar",
"url": "https://pecl.php.net/get/igbinary",
"path": "php-src/ext/igbinary", "path": "php-src/ext/igbinary",
"filename": "igbinary.tgz", "repo": "igbinary/igbinary",
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -192,6 +201,15 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"leveldb": {
"type": "git",
"rev": "mojang-compatible",
"url": "https://github.com/pmmp/leveldb.git",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libargon2": { "libargon2": {
"type": "git", "type": "git",
"rev": "master", "rev": "master",
@@ -244,13 +262,12 @@
"path": "LICENSE.md" "path": "LICENSE.md"
} }
}, },
"liblz4": { "libmcrypt": {
"type": "ghrel", "type": "url",
"repo": "lz4/lz4", "url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
"match": "lz4-.+\\.tar\\.gz",
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "COPYING"
} }
}, },
"libmemcached": { "libmemcached": {
@@ -272,9 +289,8 @@
} }
}, },
"libsodium": { "libsodium": {
"type": "ghrel", "type": "url",
"repo": "jedisct1/libsodium", "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -289,20 +305,6 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"libuv": {
"type": "ghtar",
"repo": "libuv/libuv",
"license": [
{
"type": "file",
"path": "LICENSE"
},
{
"type": "file",
"path": "LICENSE-extra"
}
]
},
"libwebp": { "libwebp": {
"type": "url", "type": "url",
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz", "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
@@ -346,6 +348,14 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"mcrypt": {
"type": "url",
"url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"memcached": { "memcached": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/memcached", "url": "https://pecl.php.net/get/memcached",
@@ -420,6 +430,34 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"pmmp-chunkutils2": {
"type": "ghtar",
"path": "php-src/ext/chunkutils2",
"repo": "pmmp/ext-chunkutils2",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"pmmp-leveldb": {
"type": "git",
"path": "php-src/ext/leveldb",
"rev": "pmmp-mojang-compatible",
"url": "https://github.com/pmmp/php-leveldb.git",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"pmmpthread": {
"type": "ghtar",
"path": "php-src/ext/pmmpthread",
"repo": "pmmp/ext-pmmpthread",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"postgresql": { "postgresql": {
"type": "url", "type": "url",
"url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz", "url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz",
@@ -485,16 +523,6 @@
"text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give." "text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give."
} }
}, },
"sqlsrv": {
"type": "url",
"url": "https://pecl.php.net/get/sqlsrv",
"path": "php-src/ext/sqlsrv",
"filename": "sqlsrv.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"swoole": { "swoole": {
"type": "ghtar", "type": "ghtar",
"path": "php-src/ext/swoole", "path": "php-src/ext/swoole",
@@ -524,14 +552,6 @@
"path": "README/LICENSE.md" "path": "README/LICENSE.md"
} }
}, },
"unixodbc": {
"type": "url",
"url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"xlswriter": { "xlswriter": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/xlswriter", "url": "https://pecl.php.net/get/xlswriter",

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('pmmp-chunkutils2')]
class pmmp_chunkutils2 extends Extension
{
public function getDistName(): string
{
return 'chunkutils2';
}
public function getUnixConfigureArg(): string
{
return '--enable-chunkutils2';
}
}

View File

@@ -13,14 +13,14 @@ class redis extends Extension
public function getUnixConfigureArg(): string public function getUnixConfigureArg(): string
{ {
$arg = '--enable-redis'; $arg = '--enable-redis';
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; if (!$this->builder->getExt('session')) {
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; $arg .= ' --disable-redis-session';
} else {
$arg .= ' --enable-redis-session';
}
if ($this->builder->getLib('zstd')) { if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"'; $arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
} }
if ($this->builder->getLib('liblz4')) {
$arg .= ' --enable-redis-lz4 --with-liblz4="' . BUILD_ROOT_PATH . '"';
}
return $arg; return $arg;
} }
} }

View File

@@ -144,7 +144,6 @@ class LinuxBuilder extends BuilderBase
// prepare build php envs // prepare build php envs
$envs_build_php = SystemUtil::makeEnvVarString([ $envs_build_php = SystemUtil::makeEnvVarString([
'CFLAGS' => $cflags, 'CFLAGS' => $cflags,
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
'LIBS' => '-ldl -lpthread', 'LIBS' => '-ldl -lpthread',
]); ]);

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class leveldb extends LinuxLibraryBase
{
use \SPC\builder\unix\library\leveldb;
public const NAME = 'leveldb';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class liblz4 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\liblz4;
public const NAME = 'liblz4';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libuv extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libuv;
public const NAME = 'libuv';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class unixodbc extends LinuxLibraryBase
{
use \SPC\builder\unix\library\unixodbc;
public const NAME = 'unixodbc';
}

View File

@@ -163,7 +163,6 @@ class MacOSBuilder extends BuilderBase
'--enable-shared=no ' . '--enable-shared=no ' .
'--enable-static=yes ' . '--enable-static=yes ' .
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " . "CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
"CPPFLAGS='-I" . BUILD_INCLUDE_PATH . "' " .
'--disable-all ' . '--disable-all ' .
'--disable-cgi ' . '--disable-cgi ' .
'--disable-phpdbg ' . '--disable-phpdbg ' .

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class leveldb extends MacOSLibraryBase
{
use \SPC\builder\unix\library\leveldb;
public const NAME = 'leveldb';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class liblz4 extends MacOSLibraryBase
{
use \SPC\builder\unix\library\liblz4;
public const NAME = 'liblz4';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class libuv extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libuv;
public const NAME = 'libuv';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class unixodbc extends MacOSLibraryBase
{
use \SPC\builder\unix\library\unixodbc;
public const NAME = 'unixodbc';
}

View File

@@ -8,7 +8,7 @@ use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
trait libuv trait leveldb
{ {
/** /**
* @throws FileSystemException * @throws FileSystemException
@@ -20,10 +20,14 @@ trait libuv
FileSystem::resetDir($this->source_dir . '/build'); FileSystem::resetDir($this->source_dir . '/build');
// Start build // Start build
shell()->cd($this->source_dir . '/build') shell()->cd($this->source_dir . '/build')
->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..") ->exec(
"cmake {$this->builder->makeCmakeArgs()} " .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DLEVELDB_BUILD_TESTS=OFF ' .
'-DLEVELDB_BUILD_BENCHMARKS=OFF ' .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}") ->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH); ->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
// patch pkgconfig
$this->patchPkgconfPrefix(['libuv-static.pc']);
} }
} }

View File

@@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\store\FileSystem;
trait liblz4
{
protected function build()
{
shell()->cd($this->source_dir)
->exec("make PREFIX='' clean")
->exec("make -j{$this->builder->concurrency} PREFIX=''")
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['liblz4.pc']);
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
}
}
}
}

View File

@@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
trait unixodbc
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
shell()->cd($this->source_dir)
->exec(
'./configure ' .
'--enable-static --disable-shared ' .
'--disable-debug ' .
'--disable-dependency-tracking ' .
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
'--with-included-ltdl ' .
'--enable-gui=no ' .
'--prefix='
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']);
$this->cleanLaFiles();
}
}

View File

@@ -2,24 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
# Normal test, contains `common` extension. # If you want to test new extensions here, just modify it.
$extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; $extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
# Normal test, contains gd extra libraries. if (PHP_OS_FAMILY === 'Darwin') {
$additional_libs = 'libwebp,libavif,libjpeg,freetype'; $extensions .= ',sodium';
# If you want to test additional extensions, add them below. (comma start)
$extensions .= ',uv';
# If you want to test additional features for extensions, add libs below. (comma start like extensions)
$additional_libs .= '';
if (!isset($argv[1])) {
exit("Please use 'extensions', 'cmd' or 'libs' as output type");
} }
echo match ($argv[1]) {
'extensions' => $extensions, echo $extensions;
'libs' => $additional_libs,
'cmd' => $extensions . ' --with-libs=' . $additional_libs,
default => '',
};