Skip to content

Commit

Permalink
Merge pull request #694 from jingjingxyk/experiment_v4.8.x
Browse files Browse the repository at this point in the history
Experiment v4.8.x
  • Loading branch information
jingjingxyk committed Jul 11, 2024
2 parents 3968ed7 + 02d7ba3 commit 9dc8eb8
Show file tree
Hide file tree
Showing 22 changed files with 320 additions and 53 deletions.
2 changes: 1 addition & 1 deletion diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
->remove('core');

ob_start();
require_once __DIR__ . '/sapi/DownloadPHPSourceCode.php';
require_once __DIR__ . '/sapi/scripts/DownloadPHPSourceCode.php';
$php_source_folder = PHP_SRC_DIR;
ob_end_clean();

Expand Down
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
8 changes: 7 additions & 1 deletion prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
$p = Preprocessor::getInstance();
$p->parseArguments($argc, $argv);

$buildType = $p->getBuildType();
if ($p->getInputOption('with-build-type')) {
$buildType = $p->getInputOption('with-build-type');
$p->setBuildType($buildType);
}

# clean
# clean old make.sh
Expand All @@ -26,7 +31,7 @@


// Sync code from php-src
$p->setPhpSrcDir($homeDir . '/.phpbrew/build/php-' . BUILD_PHP_VERSION);
$p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION);

// Compile directly on the host machine, not in the docker container
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
Expand All @@ -39,6 +44,7 @@
$p->setExtEnabled([]);
}


if ($p->getInputOption('with-global-prefix')) {
$p->setGlobalPrefix($p->getInputOption('with-global-prefix'));
}
Expand Down
14 changes: 10 additions & 4 deletions sapi/docker/build-export-container.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

:<<'COMMENT'
从运行中的容器 将 /usr/local/swoole-cli/ 文件夹 拷贝出来 并生成新容器镜像 和 导出镜像到磁盘
从运行中的容器 将 /usr/local/swoole-cli/ 文件夹 拷贝出来 并生成新容器镜像 ,并把新容器镜像导出为文件
COMMENT

Expand All @@ -19,6 +20,7 @@ cd ${__PROJECT__}


CONTAINER_BASE_IMAGE='docker.io/library/alpine:3.18'
CONTAIENR_NAME='swoole-cli-builder'
MIRROR=''
PLATFORM=''
ARCH=$(uname -m)
Expand All @@ -39,6 +41,10 @@ while [ $# -gt 0 ]; do
--mirror)
MIRROR="$2"
;;
--quickstart-container)
CONTAIENR_NAME='swoole-cli-alpine-dev'
# 从quickstart 生成的容器中拷贝 /usr/local/swoole-cli/ 文件夹,并生成新容器镜像
;;
--*)
echo "Illegal option $1"
;;
Expand All @@ -58,8 +64,8 @@ cd ${__PROJECT__}/var/build-export-container/

test -d swoole-cli && rm -rf swoole-cli

container_id='swoole-cli-builder'
docker cp $container_id:/usr/local/swoole-cli/ .

docker cp ${CONTAIENR_NAME}:/usr/local/swoole-cli/ .


cat > Dockerfile <<'EOF'
Expand Down Expand Up @@ -99,7 +105,7 @@ IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}"

echo "MIRROR=${MIRROR}"
echo "BASE_IMAGE=${CONTAINER_BASE_IMAGE}"
docker build -t ${IMAGE} -f ./Dockerfile . --progress=plain --platform ${PLATFORM} --build-arg="MIRROR=${MIRROR}" --build-arg="BASE_IMAGE=${CONTAINER_BASE_IMAGE}"
docker build --no-cache -t ${IMAGE} -f ./Dockerfile . --progress=plain --platform ${PLATFORM} --build-arg="MIRROR=${MIRROR}" --build-arg="BASE_IMAGE=${CONTAINER_BASE_IMAGE}"

echo ${IMAGE}
echo ${IMAGE} > container-image.txt
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$poject_dir = realpath(__DIR__ . '/../');
$poject_dir = realpath(__DIR__ . '/../../');
$php_version_tag = trim(file_get_contents($poject_dir . '/sapi/PHP-VERSION.conf'));
define("PHP_SRC_DIR", $poject_dir . "/var/php-{$php_version_tag}");
$php_source_folder = PHP_SRC_DIR;
Expand Down
9 changes: 7 additions & 2 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ public function getWorkDir(): string
return $this->workDir;
}

public function getWorkExtDir(): string
{
return $this->workDir . '/ext/';
}

public function setExtraLdflags(string $flags)
{
$this->extraLdflags = $flags;
Expand Down Expand Up @@ -453,7 +458,7 @@ public function donotInstallLibrary(): void
/**
* @param string $url
* @param string $file
* @param object|null $project
* @param object|null $project [ $lib or $ext ]
* @param string $httpProxyConfig
* @return void
*/
Expand Down Expand Up @@ -1182,7 +1187,7 @@ public function execute(): void
$this->setExtensionDependency();

if ($this->getInputOption('skip-download')) {
$this->generateLibraryDownloadLinks();
$this->generateDownloadLinks();
}

$this->generateFile(__DIR__ . '/template/make-install-deps.php', $this->rootDir . '/make-install-deps.sh');
Expand Down
2 changes: 1 addition & 1 deletion sapi/src/PreprocessorTrait/DownloadBoxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait DownloadBoxTrait

EOF;

protected function generateLibraryDownloadLinks(): void
protected function generateDownloadLinks(): void
{
$this->mkdirIfNotExists($this->getRootDir() . '/var/download-box/', 0755, true);

Expand Down
5 changes: 3 additions & 2 deletions sapi/src/builder/extension/aaa_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@

// 扩展钩子 写法
$p->withBeforeConfigureScript('swoole', function (Preprocessor $p) {
$workdir = $p->getWorkDir();
$workDir = $p->getWorkDir();
$workExtDir = $p->getWorkExtDir();
$cmd = <<<EOF
cd {$workdir}
cd {$workDir}
# 构建之前对 swoole 源码做一些特别处理
# 比如加载一个补丁等
# 比如修改 swoole 源码的构建文件
Expand Down
Loading

0 comments on commit 9dc8eb8

Please sign in to comment.