Skip to content

Commit

Permalink
Merge pull request #308 from jingjingxyk/experiment-webui
Browse files Browse the repository at this point in the history
添加libavif
  • Loading branch information
jingjingxyk authored Jul 31, 2023
2 parents 69ead1d + b8210f6 commit 3d729a7
Show file tree
Hide file tree
Showing 20 changed files with 429 additions and 13 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/macos-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;"
Expand Down
2 changes: 1 addition & 1 deletion sapi/quickstart/linux/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 快速启动容器环境
# 快速准备基于容器的构建环境

> 提供了 debian 11 构建 和 alpine 构建环境
Expand Down
3 changes: 3 additions & 0 deletions sapi/quickstart/linux/alpine-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions sapi/quickstart/linux/debian-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions sapi/quickstart/macos/README.md
Original file line number Diff line number Diff line change
@@ -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

```

Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -431,8 +436,7 @@ protected function downloadFileWithScript(
string $file,
string $md5sum,
string $downloadScript,
): void
{
): void {
echo PHP_EOL;
echo $downloadScript;
echo PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions sapi/src/builder/extension/gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
};
45 changes: 45 additions & 0 deletions sapi/src/builder/library/aom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

use SwooleCli\Library;
use SwooleCli\Preprocessor;

return function (Preprocessor $p) {
$aom_prefix = AOM_PREFIX;
$lib = new Library('aom');
$lib->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',
<<<EOF
git clone -b v3.6.1 --depth=1 https://aomedia.googlesource.com/aom
EOF
)
->withPrefix($aom_prefix)
->withBuildLibraryCached(true)
->withCleanBuildDirectory()
->withCleanPreInstallDirectory($aom_prefix)
->withConfigure(
<<<EOF
mkdir -p build_dir
cd build_dir
cmake .. \
-DCMAKE_INSTALL_PREFIX={$aom_prefix} \
-DCMAKE_C_STANDARD=11 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_STANDARD=11 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DENABLE_DOCS=OFF \
-DENABLE_EXAMPLES=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_TOOLS=ON
EOF
)
->withBinPath($aom_prefix . '/bin/')
->withPkgName('aom');

$p->addLibrary($lib);
};
76 changes: 76 additions & 0 deletions sapi/src/builder/library/dav1d.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

use SwooleCli\Library;
use SwooleCli\Preprocessor;

return function (Preprocessor $p) {
$dav1d_prefix = DAV1D_PREFIX;
$linux_pre_install=<<<EOF
# library dav1d :
apk add ninja python3 py3-pip nasm yasm
pip3 install meson
EOF;
$macos_pre_install=<<<EOF
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_AUTO_UPDATE=1
brew install ninja python3 nasm
# python3 -m pip install --upgrade pip
pip3 install meson
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
EOF;
$pre_install = $p->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',
<<<EOF
git clone -b 1.2.1 --depth=1 --progress https://code.videolan.org/videolan/dav1d.git
EOF
)
->withPrefix($dav1d_prefix)
->withBuildLibraryCached(true)
->withCleanBuildDirectory()
->withCleanPreInstallDirectory($dav1d_prefix)
->withPreInstallCommand($pre_install)
->withBuildScript(
<<<EOF
meson setup build \
-Dprefix={$dav1d_prefix} \
-Dbackend=ninja \
-Dbuildtype=release \
-Ddefault_library=static \
-Db_staticpic=true \
-Db_pie=true \
-Dprefer_static=true \
-Denable_asm=true \
-Denable_tools=true \
-Denable_examples=false \
-Denable_tests=false \
-Denable_docs=false \
-Dlogging=false \
-Dfuzzing_engine=none
meson compile -C build
ninja -C build
ninja -C build install
EOF
)
->withPkgName('dav1d')
->withBinPath($dav1d_prefix . '/bin/')
->withDependentLibraries('sdl2')
);
};
67 changes: 67 additions & 0 deletions sapi/src/builder/library/libavif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

use SwooleCli\Library;
use SwooleCli\Preprocessor;

return function (Preprocessor $p) {
$libavif_prefix = LIBAVIF_PREFIX;
$libyuv_prefix = LIBYUV_PREFIX;
$dav1d_prefix = DAV1D_PREFIX;
$libgav1_prefix = LIBGAV1_PREFIX;
$aom_prefix = AOM_PREFIX;
$libwebp_prefix = WEBP_PREFIX;
$svt_av1_prefix = SVT_AV1_PREFIX;
$p->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(
<<<EOF
mkdir -p build
cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX={$libavif_prefix} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DAVIF_BUILD_EXAMPLES=OFF \
-DCMAKE_DISABLE_FIND_PACKAGE_libyuv=ON \
-DCMAKE_DISABLE_FIND_PACKAGE_libsharpyuv=ON \
-Dsvt_ROOT={$svt_av1_prefix} \
-Daom_ROOT={$aom_prefix} \
-Dlibgav1_ROOT={$libgav1_prefix} \
-Ddav1d_ROOT={$dav1d_prefix} \
-DAVIF_CODEC_AOM=ON \
-DAVIF_CODEC_DAV1D=ON \
-DAVIF_CODEC_LIBGAV1=ON \
-DAVIF_CODEC_RAV1E=OFF \
-DAVIF_CODEC_SVT=ON
# -Dlibyuv_ROOT={$libyuv_prefix} \
# -DLIBYUV_INCLUDE_DIR={$libyuv_prefix}/include \
# -DLIBYUV_LIBRARY={$libyuv_prefix}/lib
# -DLIBSHARPYUV_INCLUDE_DIR={$libwebp_prefix}/include \
# -DLIBSHARPYUV_LIBRARY={$libwebp_prefix}/include
EOF
)
->withPkgName('libavif')
->withDependentLibraries(
'aom',
'svt_av1',
'libgav1',
'dav1d',
)
# 'libyuv', 'libsharpyuv','rav1e'
# 'libgav1' 依赖 absl
);
};
5 changes: 4 additions & 1 deletion sapi/src/builder/library/libevent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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
Expand All @@ -36,7 +39,7 @@
->withPkgName('libevent_extra')
->withPkgName('libevent_openssl')
->withPkgName(' libevent_pthreads')
->withDependentLibraries('openssl')
->withDependentLibraries('openssl', 'zlib')
->withBinPath($libevent_prefix . '/bin/')
);
};
Loading

0 comments on commit 3d729a7

Please sign in to comment.