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

Experiment feature #688

Merged
merged 10 commits into from
Jul 11, 2024
3 changes: 2 additions & 1 deletion docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ bash setup-php-runtime.sh
composer install --no-interaction --no-autoloader --no-scripts --profile
composer dump-autoload --optimize --profile

php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid
# 生成构建脚本 make.sh
php prepare.php --without-docker --skip-download=1
bash ./make.sh docker-build
bash ./make.sh docker-bash

Expand Down
12 changes: 12 additions & 0 deletions sapi/quickstart/linux/connection-swoole-cli-builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)

cd ${__DIR__}

docker exec -it swoole-cli-builder sh

35 changes: 22 additions & 13 deletions sapi/quickstart/linux/install-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ mkdir -p ${__PROJECT__}/var

cd ${__PROJECT__}/var

# https://github.com/docker/docker-install.git


# test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh
test -f get-docker.sh || curl -fsSL https://github.com/docker/docker-install/blob/master/install.sh?raw=true -o get-docker.sh

if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then
echo 'Please delete proxy settings !'
echo 'Execute this script again !'
exit 0
fi

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -40,8 +28,29 @@ while [ $# -gt 0 ]; do
shift $(($# > 0 ? 1 : 0))
done


# https://github.com/docker/docker-install.git
# test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh

case "$MIRROR" in
china | ustc | tuna)
test -f get-docker.sh || curl -fsSL https://gitee.com/jingjingxyk/docker-install/raw/master/install.sh -o get-docker.sh
;;
*)
test -f get-docker.sh || curl -fsSL https://github.com/docker/docker-install/blob/master/install.sh?raw=true -o get-docker.sh
;;
esac


if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then
echo 'Please delete proxy settings !'
echo 'Execute this script again !'
exit 0
fi


case "$MIRROR" in
china|ustc)
china | ustc)
sed -i "s@https://mirrors.aliyun.com/docker-ce@https://mirrors.ustc.edu.cn/docker-ce@g" get-docker.sh
sed -i "s@Aliyun)@china)@g" get-docker.sh
sh get-docker.sh --mirror china
Expand Down
5 changes: 3 additions & 2 deletions sapi/quickstart/linux/rhel-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ dnf makecache

yum install -y git wget ca-certificates

yum install -y autoconf automake clang lld libtool cmake bison gettext zip unzip
yum install -y autoconf automake clang lld libtool cmake bison gettext zip unzip
yum install -y pkg-config bzip2 flex


yum install -y curl-minimal
yum install -y curl-minimal
yum install -y xz
yum install -y socat

exit 0
yum install -y clang-tools re2c lzip coreutils p7zip
36 changes: 36 additions & 0 deletions sapi/quickstart/linux/run-rhel-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,41 @@ cd ${__DIR__}
IMAGE=almalinux:9
IMAGE=rockylinux:9

OS="rocky"
MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--os)
OS="$2"
;;
--mirror)
MIRROR="$2"
;;
esac
shift $(($# > 0 ? 1 : 0))
done



case "$OS" in
rocky)
IMAGE=rockylinux:9
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/rockylinux:9"
;;
esac
;;
alma)
IMAGE=almalinux:9
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/almalinux:9"
;;
esac
;;
esac


cd ${__DIR__}
docker run --rm --name swoole-cli-rhel-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null
17 changes: 16 additions & 1 deletion sapi/quickstart/linux/run-ubuntu-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ cd ${__DIR__}
echo $?
}
cd ${__DIR__}
IMAGE=ubuntu:22.04
IMAGE=ubuntu:23.10

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/ubuntu:23.10"
;;
esac
;;
esac
shift $(($# > 0 ? 1 : 0))
done

cd ${__DIR__}
docker run --rm --name swoole-cli-ubuntu-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null
37 changes: 17 additions & 20 deletions sapi/src/builder/library/aaa_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
$lib->withHomePage('https://opencv.org/')
->withLicense('http://www.gnu.org/licenses/lgpl-2.1.html', Library::LICENSE_LGPL)
->withManual('https://github.com/opencv/opencv.git')
/*

//设置现在文件 hash 值验证,hash 值不匹配,下载文件的自动被丢弃
/*
*
//设置现在文件 hash 值验证,hash 值不匹配,下载文件的自动被丢弃
->withFileHash('sha1', '32ead1982fed95c52060cd92187a411de3376ac9')
->withFileHash('md5','538378de497a830092cd497e2f963b5d')
->withFileHash('sha256','5dc841d2dc9f492d57d4550c114f15a03d5ee0275975571ebd82a1fca8604176')
Expand Down Expand Up @@ -68,26 +69,18 @@
EOF
)
->withPrefix($example_prefix)
/*

// 当--with-build_type=dev 时 如下2个配置才生效

// 自动清理构建目录
->withCleanBuildDirectory()

// 自动清理安装目录
->withCleanPreInstallDirectory($example_prefix)

/*

//明确申明 不使用构建缓存 例子: thirdparty/openssl (每次都解压全新源代码到此目录)
->withBuildCached(false)

//明确申明 不使用库缓存 例子: /usr/local/swoole-cli/zlib (每次构建都需要安装到此目录)
->withBuildCached(false)
->withInstallCached(false)

*/


# 构建源码可以使用cmake 、 autoconfig 、 meson 构建等


Expand Down Expand Up @@ -178,6 +171,9 @@
PACKAGES='openssl '
PACKAGES="\$PACKAGES zlib"

OPENSSL_CFLAGS=$(pkg-config --cflags --static openssl)
OPENSSL_LIBS=$(pkg-config --libs --static openssl)

CPPFLAGS="$(pkg-config --cflags-only-I --static \$PACKAGES)" \
LDFLAGS="$(pkg-config --libs-only-L --static \$PACKAGES) " \
LIBS="$(pkg-config --libs-only-l --static \$PACKAGES)" \
Expand All @@ -197,9 +193,8 @@
/* 使用 autoconfig automake 构建 end */


/*
/* 默认不需要此配置

//默认不需要此配置

->withScriptAfterInstall(
<<<EOF
Expand All @@ -209,8 +204,6 @@
EOF
)

*/
/*
//没有pkgconfig 配置的库,手动生成 pkgconfig 配置
->withScriptAfterInstall(
<<<EOF
Expand All @@ -235,11 +228,16 @@

EOF
)


*/

->withPkgName('libexample')
->withBinPath($example_prefix . '/bin/')
//依赖其它静态链接库
->withDependentLibraries('zlib', 'openssl')/*
->withDependentLibraries('zlib', 'openssl')
/*


//默认不需要此配置,特殊目录才需要配置
->withLdflags('-L' . $example_prefix . '/lib64')
Expand All @@ -248,6 +246,7 @@
->withPkgConfig($example_prefix . '/lib/ib64/pkgconfig')

*/

;

$p->addLibrary($lib);
Expand All @@ -263,12 +262,10 @@

*/

/*
//导入需要的变量
/* 导入需要的变量

$p->withExportVariable('LIBPQ_CFLAGS', '$(pkg-config --cflags --static libpq)');
$p->withExportVariable('LIBPQ_LIBS', '$(pkg-config --libs --static libpq)');

*/
};

4 changes: 3 additions & 1 deletion sapi/webUI/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
./data
./.idea
./deploy.sh
./node_modules
./public/ajax/
./public/data/
./package-lock.json
./var/
./bin/
./myapp.phar
5 changes: 5 additions & 0 deletions sapi/webUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## 启动 web ui

```shell

bash build-release-example.sh --webui
# 或者
php prepare.php --without-docker --skip-download=1 --with-web-ui=1

# 准备数据
bash sapi/webUI/sync-webui-data.sh

Expand Down
6 changes: 5 additions & 1 deletion sapi/webUI/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
if ($request_uri == '/') {
$path = '/index.html';
}
$file = realpath(__DIR__ . '/public/') . $path;
//$file = realpath(__DIR__ . '/public/') . $path;
$file = __DIR__ . '/public/' . $path;
echo __DIR__ . PHP_EOL;
echo $file;
echo PHP_EOL;

//printf("%s,%s%s", $path, $file,PHP_EOL);
$result = [];
Expand Down
16 changes: 16 additions & 0 deletions sapi/webUI/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__PROJECT__=${__DIR__}
cd ${__PROJECT__}
bash setup-nodejs-runtime.sh

export PATH="${__PROJECT__}/bin/runtime/node/bin/:$PATH"

npm install

bash sync-frontend-library.sh
7 changes: 7 additions & 0 deletions sapi/webUI/phar-builder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$phar = new Phar("myapp.phar");
$phar->buildFromDirectory(__DIR__);
$phar->startBuffering();
$phar->setStub($phar->createDefaultStub('bootstrap.php'));
$phar->stopBuffering();
Loading
Loading