Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature ext xlswriter #59

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
def0917
添加使用脚本下载 库 或者 扩展
jingjingxyk Mar 28, 2023
a5bcd70
Extension add withFile()
jingjingxyk Mar 28, 2023
2eec93b
.php-cs-fixer.cache 会滚
jingjingxyk Mar 28, 2023
6650107
回滚 .php-cs-fixer.cache
jingjingxyk Mar 28, 2023
a5e292c
ignore .php-cs-fixer.cache
jingjingxyk Mar 28, 2023
919f5c7
合并代码
jingjingxyk Mar 29, 2023
933b166
Merge branch 'main' into feature_with_download_script
jingjingxyk Mar 30, 2023
2091648
Merge branch 'main' into feature_with_download_script
jingjingxyk Apr 5, 2023
b07ce12
改进打包,.git目录也需要打包
jingjingxyk Apr 5, 2023
d873dc7
更新使用脚本下载
jingjingxyk Apr 5, 2023
5db2bc2
改进使用脚本下载,打包参数
jingjingxyk Apr 5, 2023
bea0a23
fix mkdir cache dir bug
jingjingxyk May 1, 2023
fbef0f3
Merge branch 'main' into feature_with_download_script
jingjingxyk May 1, 2023
6dc6104
Merge branch 'main' into feature_with_download_script
jingjingxyk May 6, 2023
7614e2e
Merge branch 'main' into feature_with_download_script
jingjingxyk May 7, 2023
dc2b413
验证 链接参数调整
jingjingxyk May 10, 2023
f40e086
解决macos 编译,链接系统库
jingjingxyk May 10, 2023
5f56117
验证 macos 静态编译
jingjingxyk May 10, 2023
2f56f92
验证
jingjingxyk May 10, 2023
4c7714b
merge code
jingjingxyk May 10, 2023
71bf2a1
save changed
jingjingxyk May 10, 2023
a7903be
Merge branch 'feature_with_download_script' into feature_ext_xlswriter
jingjingxyk May 11, 2023
f8ac000
save changed
jingjingxyk May 11, 2023
57f00ce
调整缓存
jingjingxyk May 12, 2023
c82ade7
save changed
jingjingxyk May 12, 2023
7160301
新创建一个分支,验证xlswriter
jingjingxyk May 13, 2023
4b9f005
save changed
jingjingxyk May 13, 2023
0cc850e
验证 xlswriter
jingjingxyk May 14, 2023
358a71e
验证
jingjingxyk May 14, 2023
a155dac
save changed
jingjingxyk May 14, 2023
a2026fe
验证一波
jingjingxyk May 14, 2023
5512872
添加扩展执行hook
jingjingxyk May 14, 2023
a7d04a6
save changed
jingjingxyk May 14, 2023
2a26248
去除 xlswriter hook
jingjingxyk May 14, 2023
cb19a8a
fix shell 空函数体
jingjingxyk May 14, 2023
699dbc7
验证
jingjingxyk May 14, 2023
d7c160b
验证
jingjingxyk May 14, 2023
80929df
验证
jingjingxyk May 14, 2023
d841c2d
验证
jingjingxyk May 14, 2023
6ce85db
保存修改
jingjingxyk May 14, 2023
c70bf88
Merge branch 'feature_ldflags' into feature_ext_xlswriter
jingjingxyk May 14, 2023
00da450
使用脚本下载 依赖库和脚本 并保存源码压缩包
jingjingxyk May 14, 2023
dfbbcf3
merge code
jingjingxyk May 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [ push, pull_request ]

jobs:
linux-aarch64:
if: 0
if: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
set -eux
# export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer 容器
composer update --no-dev --optimize-autoloader
php prepare.php +inotify +apcu +ds
php prepare.php +inotify +apcu +ds +xlswriter
chmod a+x make.sh
head -n 20 make.sh
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [ push, pull_request ]

jobs:
linux-x86_64:
if: 0
if: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
set -eux
# export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer 容器
composer update --no-dev --optimize-autoloader
php prepare.php +inotify +apcu +ds
php prepare.php +inotify +apcu +ds +xlswriter
chmod a+x make.sh
head -n 20 make.sh
- name: Build
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/macos-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
macos-x86_64:
if: 0
if: 1
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -13,20 +13,25 @@ jobs:
env
echo $HOME
brew install wget curl libtool automake gettext coreutils re2c binutils
brew uninstall --ignore-dependencies oniguruma
brew uninstall --ignore-dependencies brotli
brew uninstall --ignore-dependencies freetype
brew uninstall --ignore-dependencies zstd
brew uninstall --ignore-dependencies capstone
which glibtool
ln -sf /usr/local/bin/glibtool /usr/local/bin/libtool
ln -sf /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
sudo xcode-select --switch /Applications/Xcode.app
# export MACOSX_DEPLOYMENT_TARGET=12.6
sudo mkdir -p pool/lib
sudo mkdir -p pool/ext
git submodule update --init

- name: Cache
uses: actions/cache@v3
id: all-archive-cache
with:
path: |
${GITHUB_WORKSPACE}/var/all-archive.zip
${GITHUB_WORKSPACE}/bin/runtime/php
${GITHUB_WORKSPACE}/bin/runtime/composer
path: ${GITHUB_WORKSPACE}/var/all-archive.zip
key: all-archive
- name: Prepare runtime
if: ${{ steps.all-archive-cache.outputs.cache-hit != 'true' }}
Expand All @@ -47,14 +52,13 @@ jobs:
sudo sh sapi/download-box/download-box-get-archive-from-server.sh

sudo composer update --no-dev --optimize-autoloader
sudo php prepare.php --without-docker=1 --with-build-type=release +ds +apcu
sudo php prepare.php --without-docker=1 --with-build-type=release +ds +apcu +xlswriter
- name: Cache all-library
uses: actions/cache@v3
id: all-library-cache
with:
path: |
${HOME}/.swoole-cli
key: all-library-cache
path: ~/.swoole-cli
key: ${{ runner.os }}-build-all-library
- name: Build all-library
if: ${{ steps.all-library-cache.outputs.cache-hit != 'true' }}
run: |
Expand All @@ -68,6 +72,7 @@ jobs:
sudo ./make.sh build
sudo ./make.sh archive
file ./bin/swoole-cli
otool -L ./bin/swoole-cli
./bin/swoole-cli -r "echo PHP_VERSION;"

- name: Archive production artifacts
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,6 @@ tmp-php.ini
/.phpunit.result.cache
/samples/sfx/*.phar
composer.lock
.php-cs-fixer.cache
.php-cs-fixer.cache
ldflags.log
cppflags.log
48 changes: 21 additions & 27 deletions conf.d/imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,13 @@
->withConfigure(
<<<EOF
./configure --help

package_names="libjpeg libturbojpeg libwebp libwebpdecoder libwebpdemux libwebpmux "
package_names="\${package_names} libbrotlicommon libbrotlidec libbrotlienc libcrypto libssl openssl"

ZIP_CFLAGS=$(pkg-config --cflags --static libzip ) \
ZIP_LIBS=$(pkg-config --libs --static libzip ) \
ZLIB_CFLAGS=$(pkg-config --cflags --static zlib ) \
ZLIB_LIBS=$(pkg-config --libs --static zlib ) \
LIBZSTD_CFLAGS=$(pkg-config --cflags --static libzstd ) \
LIBZSTD_LIBS=$(pkg-config --libs --static libzstd ) \
FREETYPE_CFLAGS=$(pkg-config --cflags --static freetype2 ) \
FREETYPE_LIBS=$(pkg-config --libs --static freetype2 ) \
LZMA_CFLAGS=$(pkg-config --cflags --static liblzma ) \
LZMA_LIBS=$(pkg-config --libs --static liblzma ) \
PNG_CFLAGS=$(pkg-config --cflags --static libpng ) \
PNG_LIBS=$(pkg-config --libs --static libpng ) \
WEBP_CFLAGS=$(pkg-config --cflags --static libwebp ) \
WEBP_LIBS=$(pkg-config --libs --static libwebp ) \
WEBPMUX_CFLAGS=$(pkg-config --cflags --static libwebpmux ) \
WEBPMUX_LIBS=$(pkg-config --libs --static libwebpmux ) \
XML_CFLAGS=$(pkg-config --cflags --static libxml-2.0 ) \
XML_LIBS=$(pkg-config --libs --static libxml-2.0 ) \
CPPFLAGS="\$(pkg-config --cflags-only-I --static \$package_names ) -I{$bzip2_prefix}/include" \
LDFLAGS="\$(pkg-config --libs-only-L --static \$package_names ) -L{$bzip2_prefix}/lib" \
LIBS="\$(pkg-config --libs-only-l --static \$package_names ) -lbz2" \
PACKAGES_NAMES="libjpeg libturbojpeg libwebp libwebpdecoder libwebpdemux libwebpmux libpng freetype2"
PACKAGES_NAMES="\${PACKAGES_NAMES} libbrotlicommon libbrotlidec libbrotlienc libzip zlib libzstd liblzma"
PACKAGES_NAMES="\${PACKAGES_NAMES} libcrypto libssl openssl"
PACKAGES_NAMES="\${PACKAGES_NAMES} libxml-2.0"
CPPFLAGS="\$(pkg-config --cflags-only-I --static \$PACKAGES_NAMES ) -I{$bzip2_prefix}/include" \
LDFLAGS="\$(pkg-config --libs-only-L --static \$PACKAGES_NAMES ) -L{$bzip2_prefix}/lib" \
LIBS="\$(pkg-config --libs-only-l --static \$PACKAGES_NAMES ) -lbz2" \
./configure \
--prefix={$imagemagick_prefix} \
--enable-shared=no \
Expand Down Expand Up @@ -78,11 +60,22 @@
--without-lqr \
--without-openexr \
--without-pango \
--without-jbig \
--without-x \
--without-modules \
--without-magick-plus-plus \
--without-utilities
--without-utilities \
--without-gvc \
--without-autotrace \
--without-dps \
--without-fftw \
--without-flif \
--without-fpx \
--without-gslib \
--without-ltdl \
--without-perl \
--without-raqm \
--without-wmf

EOF
)
->withPkgName('ImageMagick-7.Q16HDRI')
Expand All @@ -96,6 +89,7 @@
'libxml2',
'libzip',
'zlib',
'liblzma',
'libjpeg',
'freetype',
'libwebp',
Expand Down
14 changes: 11 additions & 3 deletions conf.d/protobuf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@
);

$p->setExtCallback('protobuf', function (Preprocessor $p) {
$work_dir=$p->getWorkDir();

$cmd=" cd {$work_dir}/ext/xlswriter " . PHP_EOL;

// compatible with redis
if ($p->getOsType() === 'macos') {
echo `sed -i '.bak' 's/arginfo_void,/arginfo_void_protobuf,/g' ext/protobuf/*.c ext/protobuf/*.h ext/protobuf/*.inc`;
echo `find ext/protobuf/ -name \*.bak | xargs rm -f`;
$cmd .="sed -i '.bak' 's/arginfo_void,/arginfo_void_protobuf,/g' ext/protobuf/*.c ext/protobuf/*.h ext/protobuf/*.inc " . PHP_EOL ;
$cmd .="find ext/protobuf/ -name \*.bak | xargs rm -f " . PHP_EOL ;
} else {
echo `sed -i 's/arginfo_void,/arginfo_void_protobuf,/g' ext/protobuf/*.c ext/protobuf/*.h ext/protobuf/*.inc`;
$cmd .="sed -i 's/arginfo_void,/arginfo_void_protobuf,/g' ext/protobuf/*.c ext/protobuf/*.h ext/protobuf/*.inc " . PHP_EOL ;
}

$cmd .= $cmd . PHP_EOL . "cd {$work_dir}/" .PHP_EOL;

return $cmd;
});
};
46 changes: 46 additions & 0 deletions conf.d/xlswriter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use SwooleCli\Library;
use SwooleCli\Preprocessor;
use SwooleCli\Extension;

return function (Preprocessor $p) {
$p->addExtension(
(new Extension('xlswriter'))
->withHomePage('https://github.com/viest/php-ext-xlswriter')
->withLicense('https://github.com/viest/php-ext-xlswriter/blob/master/LICENSE', Extension::LICENSE_BSD)
->withPeclVersion('1.5.4')
->withDownloadScript(
'xlswriter',
<<<EOF
test -d php-ext-xlswriter && rm -rf php-ext-xlswriter

# git clone -b v1.5.4 --depth=1 --recursive https://github.com/viest/php-ext-xlswriter.git
# git clone -b feature_openssl_dir --depth=1 --recursive https://github.com/jingjingxyk/php-ext-xlswriter.git
# git clone -b main_static_built --depth=1 --recursive https://github.com/viest/php-ext-xlswriter.git

git clone -b dev --depth=1 --recursive https://github.com/viest/php-ext-xlswriter.git
mv php-ext-xlswriter xlswriter
EOF
)
->withOptions(' --with-xlswriter --enable-reader --with-openssl=' . OPENSSL_PREFIX)
);

$p->setExtCallback('xlswriter', function (Preprocessor $p) {
$work_dir=$p->getWorkDir();
$cmd=<<<EOF
cd {$work_dir}/ext/xlswriter
if [[ ! -f config.m4.backup ]] ;then
# 替换为空行
sed -i.backup "42s/.*//" config.m4
sed -i.backup "187s/.*//" config.m4
# 删除行
# sed -i '42,187d' config.m4
fi
cd {$work_dir}/
EOF;
//停用 hook
$cmd='';
return $cmd;
});
};
14 changes: 13 additions & 1 deletion conf.d/xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
->withPrefix($libxml2_prefix)
->withConfigure(
<<<EOF
./autogen.sh && ./configure --prefix=$libxml2_prefix --with-iconv=$iconv_prefix --enable-static=yes --enable-shared=no --without-python
./autogen.sh
./configure --help
./configure \
--prefix=$libxml2_prefix \
--with-iconv=$iconv_prefix \
--enable-static=yes \
--enable-shared=no \
--without-python \
--without-zlib \
--without-lzma \
--without-debug \
--without-icu

EOF
)
->withPkgName('libxml-2.0')
Expand Down
2 changes: 2 additions & 0 deletions docs/macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ brew uninstall --ignore-dependencies oniguruma
brew uninstall --ignore-dependencies brotli
brew uninstall --ignore-dependencies freetype
brew uninstall --ignore-dependencies zstd
brew uninstall --ignore-dependencies capstone

```

# 问题
Expand Down
2 changes: 2 additions & 0 deletions sapi/quickstart/linux/run-alpine-3.16-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ cd ${__DIR__}
cd ${__DIR__}
IMAGE=alpine:3.16

IMAGE=docker.io/jingjingxyk/build-swoole-cli:all-dependencies-alpine-swoole-cli-x86_64-20230505T120137Z

cd ${__DIR__}
docker run --rm --name swoole-cli-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null
3 changes: 2 additions & 1 deletion sapi/quickstart/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ composer update
php prepare.php --with-build-type=release +apcu +ds @macos

# linux
php prepare.php --with-build-type=release +apcu +ds
php prepare.php --with-build-type=release +apcu +ds -zip -swoole -curl -gd -imagick -mongodb -redis
php prepare.php --with-build-type=release -zip -swoole -curl -gd -imagick -mongodb -redis -sqlite3 -pdo_sqlite -mysqli -pdo_mysql -soap -xsl -gmp -yaml +xlswriter
8 changes: 2 additions & 6 deletions sapi/quickstart/setup-php-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ case $ARCH in
esac

VERSION='v5.0.3'
if [[ $OS = 'macos' ]]; then
VERSION='v5.0.1'
fi

mkdir -p bin/runtime
mkdir -p var/runtime

Expand All @@ -53,9 +51,7 @@ cd ${__PROJECT__}/var/runtime
SWOOLE_CLI_DOWNLOAD_URL="https://github.com/swoole/swoole-src/releases/download/${VERSION}/swoole-cli-${VERSION}-${OS}-${ARCH}.tar.xz"
COMPOSER_DOWNLOAD_URL="https://getcomposer.org/download/latest-stable/composer.phar"

if [[ $ARCH = 'arm64' ]] && [[ $OS = 'linux' ]]; then
SWOOLE_CLI_DOWNLOAD_URL='https://github.com/jingjingxyk/swoole-cli/releases/download/build-native-php-v0.1.1/swoole-cli-v5.0.3-linux-arm64.tar.xz'
fi


mirror=''
while [ $# -gt 0 ]; do
Expand Down
34 changes: 34 additions & 0 deletions sapi/scripts/download-dependencies-use-git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__PROJECT__=$(
cd ${__DIR__}/../../
pwd
)
cd ${__PROJECT__}


mkdir -p ${__PROJECT__}/var/

cd ${__PROJECT__}/var/


test -f download_library_use_git.sh && bash download_library_use_git.sh
test -f download_extension_use_git.sh && bash download_extension_use_git.sh


cd ${__PROJECT__}

mkdir -p pool/lib
mkdir -p pool/ext

# cp -rf ${__PROJECT__}/var/download/* ${__PROJECT__}/pool/lib

awk 'BEGIN { cmd="cp -ri var/libraries/* pool/lib" ; print "n" |cmd; }'
awk 'BEGIN { cmd="cp -ri var/extensions/* pool/ext"; print "n" |cmd; }'

cd ${__PROJECT__}