diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index 5011d7161a..91961442d9 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -49,13 +49,16 @@ jobs: # composer update --no-dev --optimize-autoloader composer update --optimize-autoloader - php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 --with-install-library-cached=1 + php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +pgsql +pdo_pgsql --with-swoole-pgsql=1 --with-install-library-cached=1 chmod a+x make.sh head -n 20 make.sh + bash make-install-deps.sh + bash sapi/quickstart/mark-install-library-cached.sh - bash ./make.sh all-library + rm -rf /usr/local/swoole-cli/pgsql + rm -rf /usr/local/swoole-cli/freetype bash ./make.sh config bash ./make.sh build @@ -70,6 +73,9 @@ jobs: ./bin/swoole-cli -v ./bin/swoole-cli -m ./bin/swoole-cli --ri swoole + ./bin/swoole-cli --ri gd + ./bin/swoole-cli --ri pgsql + ./bin/swoole-cli --ri pdo_pgsql file ./bin/swoole-cli readelf -h ./bin/swoole-cli ./bin/swoole-cli -r "echo PHP_VERSION;" diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index c05995bd8a..70dc83e5c5 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -78,12 +78,17 @@ jobs: # composer update --no-dev --optimize-autoloader composer update --optimize-autoloader - php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 ${{ inputs.build_type }} ${{ inputs.build_options }} --with-install-library-cached=1 + php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +pgsql +pdo_pgsql --with-swoole-pgsql=1 ${{ inputs.build_type }} ${{ inputs.build_options }} --with-install-library-cached=1 chmod a+x make.sh head -n 20 make.sh + bash make-install-deps.sh + bash sapi/quickstart/mark-install-library-cached.sh + rm -rf /usr/local/swoole-cli/pgsql + rm -rf /usr/local/swoole-cli/freetype + bash ./make.sh all-library bash ./make.sh config @@ -95,6 +100,9 @@ jobs: ./bin/swoole-cli -v ./bin/swoole-cli -m ./bin/swoole-cli --ri swoole + ./bin/swoole-cli --ri gd + ./bin/swoole-cli --ri pgsql + ./bin/swoole-cli --ri pdo_pgsql file ./bin/swoole-cli readelf -h ./bin/swoole-cli ./bin/swoole-cli -r "echo PHP_VERSION;" diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 8fe5e9fb57..5fe844ff32 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -77,7 +77,7 @@ jobs: # composer update --no-dev --optimize-autoloader composer update --optimize-autoloader - php prepare.php --without-docker=1 +ds +apcu +xlswriter +ssh2 --with-build-type=release --with-swoole-pgsql=1 --with-install-library-cached=1 + php prepare.php --without-docker=1 +ds +apcu +xlswriter +ssh2 +pgsql +pdo_pgsql --with-build-type=release --with-swoole-pgsql=1 --with-install-library-cached=1 - name: Cache all-library uses: actions/cache@v3 @@ -90,7 +90,12 @@ jobs: # if: ${{ steps.all-library-cache.outputs.cache-hit != 'true' }} run: | export PATH=${GITHUB_WORKSPACE}/bin/runtime:$PATH + bash make-install-deps.sh + bash sapi/quickstart/mark-install-library-cached.sh + rm -rf /usr/local/swoole-cli/pgsql + rm -rf /usr/local/swoole-cli/freetype + bash ./make.sh all-library - name: Build @@ -105,6 +110,9 @@ jobs: ./bin/swoole-cli -v ./bin/swoole-cli -m ./bin/swoole-cli --ri swoole + ./bin/swoole-cli --ri gd + ./bin/swoole-cli --ri pgsql + ./bin/swoole-cli --ri pdo_pgsql file ./bin/swoole-cli otool -L ./bin/swoole-cli ./bin/swoole-cli -r "echo PHP_VERSION;" diff --git a/sapi/quickstart/linux/README.md b/sapi/quickstart/linux/README.md index 03708b3739..12eb7ec583 100644 --- a/sapi/quickstart/linux/README.md +++ b/sapi/quickstart/linux/README.md @@ -1,4 +1,4 @@ -# 快速启动容器环境 +# 快速准备基于容器的构建环境 > 提供了 debian 11 构建 和 alpine 构建环境 diff --git a/sapi/quickstart/linux/alpine-init.sh b/sapi/quickstart/linux/alpine-init.sh index 4ef9c2b00f..88a6bf52ee 100644 --- a/sapi/quickstart/linux/alpine-init.sh +++ b/sapi/quickstart/linux/alpine-init.sh @@ -39,3 +39,6 @@ apk add bash p7zip zip unzip flex pkgconf ca-certificates # apk add bash 7zip apk add wget git curl apk add libc++-static +apk add yasm nasm +apk add ninja python3 py3-pip +pip3 install meson diff --git a/sapi/quickstart/linux/debian-init.sh b/sapi/quickstart/linux/debian-init.sh index 32dcbd2306..54162b63ee 100644 --- a/sapi/quickstart/linux/debian-init.sh +++ b/sapi/quickstart/linux/debian-init.sh @@ -70,3 +70,6 @@ apt install -y pkg-config bzip2 flex p7zip apt install -y gcc g++ # apt install build-essential linux-headers-$(uname -r) +apt install -y python3 python3-pip ninja-build gn +apt install -y yasm nasm +apt install -y meson diff --git a/sapi/quickstart/macos/README.md b/sapi/quickstart/macos/README.md index 5cb65209f8..8cad503a95 100644 --- a/sapi/quickstart/macos/README.md +++ b/sapi/quickstart/macos/README.md @@ -1,12 +1,12 @@ -# macos快速准备运行环境 +# macos快速准备构建环境 ## 准备依赖 ```shell -bash sapi/quickstart/macos/setup-homebrew-dependency.sh +bash sapi/quickstart/macos/homebrew-init.sh # 使用中国大陆镜像 -bash sapi/quickstart/macos/setup-homebrew-dependency.sh --mirror china +bash sapi/quickstart/macos/homebrew-init.sh --mirror china ``` diff --git a/sapi/quickstart/macos/setup-homebrew-dependency.sh b/sapi/quickstart/macos/homebrew-init.sh similarity index 100% rename from sapi/quickstart/macos/setup-homebrew-dependency.sh rename to sapi/quickstart/macos/homebrew-init.sh diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 99b7be17a2..dd3369ee94 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -333,6 +333,11 @@ public function setMaxJob(int $n): static return $this; } + public function getMaxJob(): string + { + return $this->maxJob; + } + /** * set CPU logical processors * @param string $logicalProcessors @@ -431,8 +436,7 @@ protected function downloadFileWithScript( string $file, string $md5sum, string $downloadScript, - ): void - { + ): void { echo PHP_EOL; echo $downloadScript; echo PHP_EOL; diff --git a/sapi/src/builder/extension/gd.php b/sapi/src/builder/extension/gd.php index 2cf084e77c..07940b91af 100644 --- a/sapi/src/builder/extension/gd.php +++ b/sapi/src/builder/extension/gd.php @@ -8,7 +8,7 @@ $p->addExtension( (new Extension('gd')) ->withHomePage('https://www.php.net/manual/zh/book.image.php') - ->withOptions('--enable-gd --with-jpeg --with-freetype --with-webp') - ->withDependentLibraries('libjpeg', 'freetype', 'libwebp', 'libpng', 'libgif') + ->withOptions('--enable-gd --with-jpeg --with-freetype --with-webp --with-avif ') + ->withDependentLibraries('libjpeg', 'freetype', 'libwebp', 'libpng', 'libgif', 'libavif') ); }; diff --git a/sapi/src/builder/library/aom.php b/sapi/src/builder/library/aom.php new file mode 100644 index 0000000000..34f3099163 --- /dev/null +++ b/sapi/src/builder/library/aom.php @@ -0,0 +1,45 @@ +withHomePage('https://aomedia.googlesource.com/aom') + ->withLicense('https://aomedia.googlesource.com/aom/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) + ->withManual('https://aomedia.googlesource.com/aom') + ->withUrl('https://aomedia.googlesource.com/aom') + ->withFile('aom-v3.6.1.tar.gz') + ->withDownloadScript( + 'aom', + <<withPrefix($aom_prefix) + ->withBuildLibraryCached(true) + ->withCleanBuildDirectory() + ->withCleanPreInstallDirectory($aom_prefix) + ->withConfigure( + <<withBinPath($aom_prefix . '/bin/') + ->withPkgName('aom'); + + $p->addLibrary($lib); +}; diff --git a/sapi/src/builder/library/dav1d.php b/sapi/src/builder/library/dav1d.php new file mode 100644 index 0000000000..a31b81248a --- /dev/null +++ b/sapi/src/builder/library/dav1d.php @@ -0,0 +1,76 @@ +getOsType()=='macos' ? $macos_pre_install : $linux_pre_install; + $p->addLibrary( + (new Library('dav1d')) + ->withHomePage('https://code.videolan.org/videolan/dav1d/') + ->withLicense('https://code.videolan.org/videolan/dav1d/-/blob/master/COPYING', Library::LICENSE_BSD) + ->withManual('https://code.videolan.org/videolan/dav1d') + //->withUrl('https://code.videolan.org/videolan/dav1d/-/archive/1.2.1/dav1d-1.2.1.tar.gz') + //->withFile('dav1d-1.2.1.tar.gz') + ->withFile('dav1d-git-1.2.1.tar.gz') + ->withDownloadScript( + 'dav1d', + <<withPrefix($dav1d_prefix) + ->withBuildLibraryCached(true) + ->withCleanBuildDirectory() + ->withCleanPreInstallDirectory($dav1d_prefix) + ->withPreInstallCommand($pre_install) + ->withBuildScript( + <<withPkgName('dav1d') + ->withBinPath($dav1d_prefix . '/bin/') + ->withDependentLibraries('sdl2') + ); +}; diff --git a/sapi/src/builder/library/libavif.php b/sapi/src/builder/library/libavif.php new file mode 100644 index 0000000000..77b0249545 --- /dev/null +++ b/sapi/src/builder/library/libavif.php @@ -0,0 +1,67 @@ +addLibrary( + (new Library('libavif')) + ->withHomePage('https://aomediacodec.github.io/av1-avif/') + ->withLicense('https://github.com/AOMediaCodec/libavif/', Library::LICENSE_BSD) + ->withManual('https://github.com/AOMediaCodec/libavif/ext/') + ->withUrl('https://github.com/AOMediaCodec/libavif/archive/refs/tags/v0.11.1.tar.gz') + ->withFile('libavif-v0.11.1.tar.gz') + ->withPrefix($libavif_prefix) + ->withBuildLibraryCached(true) + ->withCleanBuildDirectory() + ->withCleanPreInstallDirectory($libavif_prefix) + ->withConfigure( + <<withPkgName('libavif') + ->withDependentLibraries( + 'aom', + 'svt_av1', + 'libgav1', + 'dav1d', + ) + # 'libyuv', 'libsharpyuv','rav1e' + # 'libgav1' 依赖 absl + ); +}; diff --git a/sapi/src/builder/library/libevent.php b/sapi/src/builder/library/libevent.php index 92ed2fee6b..8f6a94776b 100644 --- a/sapi/src/builder/library/libevent.php +++ b/sapi/src/builder/library/libevent.php @@ -6,6 +6,7 @@ return function (Preprocessor $p) { $libevent_prefix = LIBEVENT_PREFIX; $openssl_prefix = OPENSSL_PREFIX; + $zlib_prefix = ZLIB_PREFIX; $url = 'https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz'; $p->addLibrary( (new Library('libevent')) @@ -27,6 +28,8 @@ -DEVENT__LIBRARY_TYPE=STATIC \ -DEVENT__DISABLE_OPENSSL=OFF \ -DEVENT__DISABLE_THREAD_SUPPORT=OFF \ + -DZLIB_ROOT={$zlib_prefix} \ + -DCMAKE_DISABLE_FIND_PACKAGE_PythonInterp=ON \ -DOpenSSL_ROOT={$openssl_prefix} EOF @@ -36,7 +39,7 @@ ->withPkgName('libevent_extra') ->withPkgName('libevent_openssl') ->withPkgName(' libevent_pthreads') - ->withDependentLibraries('openssl') + ->withDependentLibraries('openssl', 'zlib') ->withBinPath($libevent_prefix . '/bin/') ); }; diff --git a/sapi/src/builder/library/libexpat.php b/sapi/src/builder/library/libexpat.php new file mode 100644 index 0000000000..4eb1e6ecd0 --- /dev/null +++ b/sapi/src/builder/library/libexpat.php @@ -0,0 +1,36 @@ +withHomePage('https://libexpat.github.io/') + ->withLicense('http://www.gnu.org/licenses/lgpl-2.1.html', Library::LICENSE_LGPL) + ->withUrl('https://github.com/libexpat/libexpat/archive/refs/tags/R_2_5_0.tar.gz') + ->withFile('libexpat-R_2_5_0.tar.gz') + ->withManual('https://github.com/libexpat/libexpat.git') + ->withPrefix($libexpat_prefix) + ->withConfigure( + <<withPkgName('expat') + ->withBinPath($libexpat_prefix . '/bin/') + ; + + $p->addLibrary($lib); + +}; diff --git a/sapi/src/builder/library/libgav1.php b/sapi/src/builder/library/libgav1.php new file mode 100644 index 0000000000..30bf9fd477 --- /dev/null +++ b/sapi/src/builder/library/libgav1.php @@ -0,0 +1,47 @@ +addLibrary( + (new Library('libgav1')) + ->withHomePage('https://chromium.googlesource.com/codecs/libgav1') + ->withLicense( + 'https://chromium.googlesource.com/codecs/libgav1/+/refs/heads/main/LICENSE', + Library::LICENSE_APACHE2 + ) + ->withFile('libgav1-latest.tar.gz') + ->withManual('https://chromium.googlesource.com/codecs/libgav1/+/refs/heads/main') + ->withDownloadScript( + 'libgav1', + <<withPrefix($libgav1_prefix) + ->withConfigure( + <<withPkgName('libgav1') + ->withBinPath($libgav1_prefix . '/bin/') + //->withDependentLibraries('absl') //测试需要它,更多请查看文档 + ); +}; diff --git a/sapi/src/builder/library/sdl2.php b/sapi/src/builder/library/sdl2.php new file mode 100644 index 0000000000..315593b770 --- /dev/null +++ b/sapi/src/builder/library/sdl2.php @@ -0,0 +1,44 @@ +withHomePage('libsdl.org') + ->withLicense('https://github.com/libsdl-org/SDL/blob/main/LICENSE.txt', Library::LICENSE_SPEC) + ->withManual('https://github.com/libsdl-org/SDL.git') + ->withFile('SDL-release-2.28.1.tar.gz') + ->withDownloadScript( + 'SDL', + <<withPrefix($sdl2_prefix) + ->withConfigure( + <<withPkgName('sdl2') + ->withBinPath($sdl2_prefix . '/bin/') + ->withDependentLibraries('openssl', 'libiconv') + ; + + $p->addLibrary($lib); +}; diff --git a/sapi/src/builder/library/svt_av1.php b/sapi/src/builder/library/svt_av1.php new file mode 100644 index 0000000000..bea87b953a --- /dev/null +++ b/sapi/src/builder/library/svt_av1.php @@ -0,0 +1,49 @@ +withHomePage('https://gitlab.com/AOMediaCodec/SVT-AV1.git') + ->withLicense( + 'https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/LICENSE.md', + Library::LICENSE_BSD + ) + ->withDownloadScript( + 'SVT-AV1', + <<withFile('SVT-AV1-v1.5.0.tar.gz') + ->withManual('https://gitlab.com/AOMediaCodec/SVT-AV1.git') + ->withManual('https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Build-Guide.md') + ->withPrefix($svt_av1_prefix) + ->withPreInstallCommand( + <<withBuildScript( + <<getMaxJob()} + make install +EOF + ) + ->withPkgName('SvtAv1Enc') + ->withPkgName('SvtAv1Dec') + ->withBinPath($svt_av1_prefix . '/bin/'); + + $p->addLibrary($lib); +}; diff --git a/sapi/src/constants.php b/sapi/src/constants.php index c0337d87fa..6d748c2249 100644 --- a/sapi/src/constants.php +++ b/sapi/src/constants.php @@ -57,3 +57,19 @@ define("LIBEVENT_PREFIX", $p->getGlobalPrefix() . '/libevent'); define("SNAPPY_PREFIX", $p->getGlobalPrefix() . '/snappy'); define("LIBSASL_PREFIX", $p->getGlobalPrefix() . '/sasl'); +define("LIBEXPAT_PREFIX", $p->getGlobalPrefix() . '/libexpat'); + +define("LIBAVIF_PREFIX", $p->getGlobalPrefix() . '/libavif'); +define("LIBYUV_PREFIX", $p->getGlobalPrefix() . '/libyuv'); +define("DAV1D_PREFIX", $p->getGlobalPrefix() . '/dav1d'); +define("LIBGAV1_PREFIX", $p->getGlobalPrefix() . '/libgav1'); +define("AOM_PREFIX", $p->getGlobalPrefix() . '/aom'); +define("SVT_AV1_PREFIX", $p->getGlobalPrefix() . '/svt_av1'); +define("LIBSHARPYUV_PREFIX", $p->getGlobalPrefix() . '/libsharpyuv'); +define("LIBTIFF_PREFIX", $p->getGlobalPrefix() . '/libtiff'); +define("LIBRAW_PREFIX", $p->getGlobalPrefix() . '/libraw'); +define("LCMS2_PREFIX", $p->getGlobalPrefix() . '/lcms2'); + +define("ABSL_PREFIX", $p->getGlobalPrefix() . '/absl'); +define("RAV1E_PREFIX", $p->getGlobalPrefix() . '/rav1e'); +define("SDL2_PREFIX", $p->getGlobalPrefix() . '/sdl2'); diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index 80c0e127f9..7f30a85472 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -216,6 +216,7 @@ export_variables echo $LDFLAGS > ldflags.log echo $CPPFLAGS > cppflags.log + echo $LIBS > libs.log ./configure $OPTIONS }