Skip to content

Commit

Permalink
merge code
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jul 31, 2023
2 parents 42efce8 + b8210f6 commit f98b1be
Show file tree
Hide file tree
Showing 24 changed files with 469 additions and 29 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-install-library-cached=1
php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +pgsql +pdo_pgsql --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 ${{ inputs.build_type }} ${{ inputs.build_options }} --with-install-library-cached=1
php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +pgsql +pdo_pgsql ${{ 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-install-library-cached=1
php prepare.php --without-docker=1 +ds +apcu +xlswriter +ssh2 +pgsql +pdo_pgsql --with-build-type=release --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.
14 changes: 8 additions & 6 deletions sapi/src/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ class Library extends Project
public string $ldflags = '';

public string $buildScript = '';

public string $makeOptions = '';

public string $makeVariables = '';

public string $makeInstallCommand = 'install';

public string $makeInstallOptions = '';

public string $beforeInstallScript = '';

public string $afterInstallScript = '';

public string $pkgConfig = '';

public array $pkgNames = [];

public string $prefix = '/usr';
Expand Down Expand Up @@ -152,12 +160,6 @@ public function withCleanPreInstallDirectory(string $preInstallDir): static
return $this;
}

public function withBuildLibraryCached(bool $enableBuildLibraryCached): static
{
$this->enableBuildLibraryCached = $enableBuildLibraryCached;
return $this;
}

public function withPreInstallCommand(string $preInstallCommand): static
{
$this->preInstallCommand = $preInstallCommand;
Expand Down
35 changes: 25 additions & 10 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ class Preprocessor
'openssl',
'readline',
'xml',
'gd',
'redis',
'swoole',
'yaml',
'imagick',
'mongodb',
'gd',
];
protected array $extEnabledBuff = [];
protected array $endCallbacks = [];
Expand All @@ -144,7 +144,7 @@ class Preprocessor

protected string $proxyConfig = '';

protected string $httpProxy= '';
protected string $httpProxy = '';

protected bool $installLibraryCached = false;

Expand Down 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 All @@ -359,7 +364,7 @@ public function getBuildType(): string
public function setProxyConfig(string $shell = '', string $httpProxy = ''): static
{
$this->proxyConfig = $shell;
$this->httpProxy=$httpProxy;
$this->httpProxy = $httpProxy;
return $this;
}

Expand All @@ -376,7 +381,7 @@ public function getHttpProxy(): string

public function setExtEnabled(array $extEnabled = []): static
{
$this->extEnabled=array_merge($this->extEnabledBuff, $extEnabled);
$this->extEnabled = array_merge($this->extEnabledBuff, $extEnabled);
return $this;
}

Expand Down Expand Up @@ -585,7 +590,7 @@ public function addExtension(Extension $ext): void
if (empty($ext->file)) {
$ext->file = $ext->name . '.tgz';
}
$ext->url='';
$ext->url = '';
}
$ext->path = $this->extensionDir . '/' . $ext->file;

Expand Down Expand Up @@ -613,7 +618,7 @@ public function addExtension(Extension $ext): void
if (!file_exists($ext->path)) {
$httpProxyConfig = $this->getProxyConfig();
if (!$ext->enableHttpProxy) {
$httpProxyConfig='';
$httpProxyConfig = '';
}
if ($ext->enableDownloadScript && !$ext->enableDownloadWithMirrorURL) {
if (!empty($ext->downloadScript) && !empty($ext->downloadDirName)) {
Expand Down Expand Up @@ -652,17 +657,27 @@ public function addExtension(Extension $ext): void
}

$dst_dir = "{$this->rootDir}/ext/{$ext->name}";
$ext_name = $ext->name;
if (!empty($ext->aliasName)) {
$dst_dir = "{$this->rootDir}/ext/{$ext->aliasName}";
$ext_name = $ext->aliasName;
}
if ($ext->enableLatestTarball
if (($ext->enableLatestTarball || !$ext->enableBuildLibraryCached)
&&
(!empty($ext->peclVersion) ||$ext->enableDownloadScript ||!empty($ext->url))
(!empty($ext->peclVersion) || $ext->enableDownloadScript || !empty($ext->url))
) {
$this->deleteDirectoryIfExists($dst_dir);
}
$this->mkdirIfNotExists($dst_dir, 0777, true);
echo `tar --strip-components=1 -C $dst_dir -xf {$ext->path}`;
$cached = $dst_dir . '/.completed';
if (file_exists($cached) && $ext->enableBuildLibraryCached) {
echo 'ext/' . $ext_name . ' cached ';
} else {
echo `tar --strip-components=1 -C $dst_dir -xf {$ext->path}`;
if ($ext->enableBuildLibraryCached) {
touch($cached);
}
}
}
}
$this->extensionList[] = $ext;
Expand Down Expand Up @@ -907,7 +922,7 @@ protected function deleteDirectoryIfExists($path): bool
}
if ($fileinfo->islink()) {
throw new Exception(
'file is '. $fileinfo->getPathname() .' link ; The real path is '.$fileinfo->getRealPath()
'file is ' . $fileinfo->getPathname() . ' link ; The real path is ' . $fileinfo->getRealPath()
);
}
if ($fileinfo->isFile()) {
Expand Down
8 changes: 8 additions & 0 deletions sapi/src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ abstract class Project

public bool $enableDownloadWithMirrorURL = false;

public bool $enableBuildLibraryCached = true;

public function __construct(string $name)
{
$this->name = $name;
Expand Down Expand Up @@ -119,4 +121,10 @@ public function withHttpProxy(bool $enableHttpProxy = true): static
$this->enableHttpProxy = $enableHttpProxy;
return $this;
}

public function withBuildLibraryCached(bool $enableBuildLibraryCached): static
{
$this->enableBuildLibraryCached = $enableBuildLibraryCached;
return $this;
}
}
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')
);
};
4 changes: 2 additions & 2 deletions sapi/src/builder/extension/swoole_git.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
->withHomePage('https://github.com/swoole/swoole-src')
->withManual('https://wiki.swoole.com/#/')
->withFile('swoole-git-submodule.tar.gz')
->withAutoUpdateFile(true)
# 自动 拷贝子模块 swoole 的源代码到 pool/ext/ 目录
->withBuildLibraryCached(false) //及时更新 ext/swoole 的源代码
# 打包 sapi/swoole 的源代码到 pool/ext/swoole-git-submodule.tar.gz
# swoole 版本由子模块控制
->withDownloadScript(
'swoole',
Expand Down
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);
};
Loading

0 comments on commit f98b1be

Please sign in to comment.