Compare commits

..

8 Commits

Author SHA1 Message Date
Jerry Ma
6b8df97282 Add uv/libuv support (#296)
* add uv/libuv support

* sort config
2023-12-23 16:23:37 +08:00
crazywhalecc
584f96484c add liblz4 suggest 2023-12-23 15:18:39 +08:00
crazywhalecc
e1e5515694 fix tests 2023-12-23 15:18:39 +08:00
crazywhalecc
d3ff6fd8c0 sort config 2023-12-23 15:18:39 +08:00
crazywhalecc
6bcda6a5a0 add lz4, igbinary support for redis 2023-12-23 15:18:39 +08:00
crazywhalecc
3828ba7c77 fix x86_64 build 2023-12-22 13:28:22 +08:00
crazywhalecc
a632caed54 add sqlsrv support test 2023-12-22 13:28:22 +08:00
crazywhalecc
1e0265e673 add sqlsrv support 2023-12-22 13:28:22 +08:00
20 changed files with 263 additions and 187 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)" --with-php=${{ matrix.php }} --debug run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --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)" --build-cli --build-micro --build-fpm --debug run: bin/spc build $(php src/globals/test-extensions.php cmd) --build-cli --build-micro --build-fpm --debug

View File

@@ -16,14 +16,6 @@
"calendar": { "calendar": {
"type": "builtin" "type": "builtin"
}, },
"crypto": {
"type": "external",
"arg-type": "with",
"source": "ext-crypto",
"lib-depends": [
"openssl"
]
},
"ctype": { "ctype": {
"type": "builtin" "type": "builtin"
}, },
@@ -176,14 +168,6 @@
"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",
@@ -233,10 +217,6 @@
"zlib" "zlib"
] ]
}, },
"morton": {
"type": "external",
"source": "ext-morton"
},
"mysqli": { "mysqli": {
"type": "builtin", "type": "builtin",
"arg-type": "with", "arg-type": "with",
@@ -323,16 +303,6 @@
"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
@@ -365,7 +335,12 @@
"source": "redis", "source": "redis",
"arg-type": "custom", "arg-type": "custom",
"ext-suggests": [ "ext-suggests": [
"session" "session",
"igbinary"
],
"lib-suggests": [
"zstd",
"liblz4"
] ]
}, },
"session": { "session": {
@@ -425,6 +400,17 @@
"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",
@@ -485,6 +471,14 @@
"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,13 +163,6 @@
"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": [
@@ -231,10 +224,10 @@
"libturbojpeg.a" "libturbojpeg.a"
] ]
}, },
"libmcrypt": { "liblz4": {
"source": "libmcrypt", "source": "liblz4",
"static-libs-unix": [ "static-libs-unix": [
"libmcrypt.a" "liblz4.a"
] ]
}, },
"libmemcached": { "libmemcached": {
@@ -291,6 +284,12 @@
"zlib" "zlib"
] ]
}, },
"libuv": {
"source": "libuv",
"static-libs-unix": [
"libuv.a"
]
},
"libwebp": { "libwebp": {
"source": "libwebp", "source": "libwebp",
"static-libs-unix": [ "static-libs-unix": [
@@ -375,12 +374,6 @@
"openssl" "openssl"
] ]
}, },
"mcrypt": {
"source": "mcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"ncurses": { "ncurses": {
"source": "ncurses", "source": "ncurses",
"static-libs-unix": [ "static-libs-unix": [
@@ -503,6 +496,17 @@
"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,16 +42,6 @@
"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",
@@ -90,16 +80,6 @@
"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",
@@ -120,6 +100,16 @@
"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",
@@ -157,9 +147,10 @@
} }
}, },
"igbinary": { "igbinary": {
"type": "ghtar", "type": "url",
"url": "https://pecl.php.net/get/igbinary",
"path": "php-src/ext/igbinary", "path": "php-src/ext/igbinary",
"repo": "igbinary/igbinary", "filename": "igbinary.tgz",
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -201,15 +192,6 @@
"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",
@@ -262,12 +244,13 @@
"path": "LICENSE.md" "path": "LICENSE.md"
} }
}, },
"libmcrypt": { "liblz4": {
"type": "url", "type": "ghrel",
"url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", "repo": "lz4/lz4",
"match": "lz4-.+\\.tar\\.gz",
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "LICENSE"
} }
}, },
"libmemcached": { "libmemcached": {
@@ -289,8 +272,9 @@
} }
}, },
"libsodium": { "libsodium": {
"type": "url", "type": "ghrel",
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", "repo": "jedisct1/libsodium",
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -305,6 +289,20 @@
"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",
@@ -348,14 +346,6 @@
"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",
@@ -430,34 +420,6 @@
"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",
@@ -523,6 +485,16 @@
"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",
@@ -552,6 +524,14 @@
"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

@@ -1,22 +0,0 @@
<?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';
if (!$this->builder->getExt('session')) { $arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= ' --disable-redis-session'; $arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
} 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,6 +144,7 @@ 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

@@ -1,12 +0,0 @@
<?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

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,12 @@
<?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,6 +163,7 @@ 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

@@ -1,12 +0,0 @@
<?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

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,26 @@
<?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

@@ -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 leveldb trait libuv
{ {
/** /**
* @throws FileSystemException * @throws FileSystemException
@@ -20,14 +20,10 @@ trait leveldb
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( ->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..")
"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

@@ -0,0 +1,35 @@
<?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,11 +2,24 @@
declare(strict_types=1); declare(strict_types=1);
# If you want to test new extensions here, just modify it. # Normal test, contains `common` extension.
$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'; $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';
if (PHP_OS_FAMILY === 'Darwin') { # Normal test, contains gd extra libraries.
$extensions .= ',sodium'; $additional_libs = 'libwebp,libavif,libjpeg,freetype';
# 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]) {
echo $extensions; 'extensions' => $extensions,
'libs' => $additional_libs,
'cmd' => $extensions . ' --with-libs=' . $additional_libs,
default => '',
};