Skip to content

Commit e3aba6c

Browse files
committed
merge code
2 parents f208ab3 + 009d49c commit e3aba6c

File tree

5 files changed

+124
-72
lines changed

5 files changed

+124
-72
lines changed

sapi/quickstart/windows/cygwin-build/download-cygwin.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ cd /d ..\..\..\..\
1212
set "__PROJECT__=%cd%"
1313
echo %cd%
1414

15-
md %__PROJECT__%\var\windows-cygwin-build-deps\
15+
md %__PROJECT__%\var\cygwin-build\
1616

17-
cd /d %__PROJECT__%\var\windows-cygwin-build-deps\
17+
cd /d %__PROJECT__%\var\cygwin-build\
1818

1919
curl.exe -fSLo setup-x86_64.exe https://cygwin.com/setup-x86_64.exe
2020

sapi/scripts/cygwin/cygwin-build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ __PROJECT__=$(
1010
pwd
1111
)
1212
cd ${__PROJECT__}
13-
cd ${__PROJECT__}/php-src
13+
WORK_TEMP_DIR=${__PROJECT__}/var/cygwin-build/
14+
cd ${WORK_TEMP_DIR}/php-src/
1415

1516
mkdir -p bin/.libs
1617
# export LDFLAGS="-all-static"
@@ -29,9 +30,9 @@ else
2930
fi
3031
set -u
3132

32-
${__PROJECT__}/php-src/sapi/cli/php.exe -v
33+
${WORK_TEMP_DIR}/php-src/sapi/cli/php.exe -v
3334

34-
cp -f ${__PROJECT__}/php-src/sapi/cli/php.exe ${__PROJECT__}/bin/
35+
cp -f ${WORK_TEMP_DIR}/php-src/sapi/cli/php.exe ${__PROJECT__}/bin/
3536

3637
${__PROJECT__}/bin/php.exe -v
3738
${__PROJECT__}/bin/php.exe -m

sapi/scripts/cygwin/cygwin-config-ext.sh

Lines changed: 73 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ __PROJECT__=$(
1111
)
1212
cd ${__PROJECT__}
1313

14-
ROOT=${__PROJECT__}
15-
1614
PHP_VERSION='8.2.27'
1715
SWOOLE_VERSION='v6.0.0'
1816
X_PHP_VERSION='8.2'
@@ -38,83 +36,98 @@ MONGODB_VERSION=1.17.2
3836
YAML_VERSION=2.2.2
3937
IMAGICK_VERSION=3.7.0
4038

41-
if [ ! -d pool/ext ]; then
42-
mkdir -p pool/ext
43-
fi
44-
45-
test -d ext && rm -rf ext
46-
test -d pool/ext && rm -rf pool/ext
4739
mkdir -p pool/ext
48-
mkdir -p ext
49-
cd pool/ext
50-
51-
if [ ! -d $ROOT/ext/redis ]; then
52-
if [ ! -f redis-${REDIS_VERSION}.tgz ]; then
53-
curl -fSLo redis-${REDIS_VERSION}.tgz https://pecl.php.net/get/redis-${REDIS_VERSION}.tgz
54-
fi
55-
tar xvf redis-${REDIS_VERSION}.tgz
56-
mv redis-${REDIS_VERSION} $ROOT/ext/redis
40+
mkdir -p pool/lib
41+
mkdir -p pool/php-tar
42+
43+
WORK_TEMP_DIR=${__PROJECT__}/var/cygwin-build/
44+
EXT_TEMP_CACHE_DIR=${WORK_TEMP_DIR}/pool/ext/
45+
mkdir -p ${WORK_TEMP_DIR}
46+
mkdir -p ${EXT_TEMP_CACHE_DIR}
47+
test -d ${WORK_TEMP_DIR}/ext/ && rm -rf ${WORK_TEMP_DIR}/ext/
48+
mkdir -p ${WORK_TEMP_DIR}/ext/
49+
50+
cd ${__PROJECT__}/pool/ext
51+
if [ ! -f redis-${REDIS_VERSION}.tgz ]; then
52+
curl -fSLo ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz https://pecl.php.net/get/redis-${REDIS_VERSION}.tgz
53+
mv ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz ${__PROJECT__}/pool/ext
5754
fi
55+
mkdir -p ${WORK_TEMP_DIR}/ext/redis/
56+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/redis/ -xf redis-${REDIS_VERSION}.tgz
5857

59-
# mongodb no support cygwin
60-
if [ ! -d $ROOT/ext/mongodb ]; then
61-
if [ ! -f mongodb-${MONGODB_VERSION}.tgz ]; then
62-
curl -fSLo mongodb-${MONGODB_VERSION}.tgz https://pecl.php.net/get/mongodb-${MONGODB_VERSION}.tgz
63-
fi
64-
tar xvf mongodb-${MONGODB_VERSION}.tgz
65-
mv mongodb-${MONGODB_VERSION} $ROOT/ext/mongodb
58+
: <<EOF
59+
# mongodb 扩展 不支持 cygwin 环境下构建
60+
# 详见: https://github.com/mongodb/mongo-php-driver/issues/1381
61+
62+
cd ${__PROJECT__}/pool/ext
63+
if [ ! -f mongodb-${MONGODB_VERSION}.tgz ]; then
64+
curl -fSLo ${EXT_TEMP_CACHE_DIR}/mongodb-${MONGODB_VERSION}.tgz https://pecl.php.net/get/mongodb-${MONGODB_VERSION}.tgz
65+
mv ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz ${__PROJECT__}/pool/ext
6666
fi
67+
mkdir -p ${WORK_TEMP_DIR}/ext/mongodb/
68+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/mongodb/ -xf redis-${REDIS_VERSION}.tgz
69+
70+
EOF
6771

68-
if [ ! -d $ROOT/ext/yaml ]; then
69-
if [ ! -f yaml-${YAML_VERSION}.tgz ]; then
70-
curl -fSLo yaml-${YAML_VERSION}.tgz https://pecl.php.net/get/yaml-${YAML_VERSION}.tgz
71-
fi
72-
tar xvf yaml-${YAML_VERSION}.tgz
73-
mv yaml-${YAML_VERSION} $ROOT/ext/yaml
72+
cd ${__PROJECT__}/pool/ext
73+
if [ ! -f yaml-${YAML_VERSION}.tgz ]; then
74+
curl -fSLo ${EXT_TEMP_CACHE_DIR}/yaml-${YAML_VERSION}.tgz https://pecl.php.net/get/yaml-${YAML_VERSION}.tgz
75+
mv ${EXT_TEMP_CACHE_DIR}/yaml-${YAML_VERSION}.tgz ${__PROJECT__}/pool/ext
7476
fi
77+
mkdir -p ${WORK_TEMP_DIR}/ext/yaml/
78+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/yaml/ -xf yaml-${YAML_VERSION}.tgz
7579

76-
if [ ! -d $ROOT/ext/imagick ]; then
77-
if [ ! -f imagick-${IMAGICK_VERSION}.tgz ]; then
78-
curl -fSLo imagick-${IMAGICK_VERSION}.tgz https://pecl.php.net/get/imagick-${IMAGICK_VERSION}.tgz
79-
fi
80-
tar xvf imagick-${IMAGICK_VERSION}.tgz
81-
mv imagick-${IMAGICK_VERSION} $ROOT/ext/imagick
82-
if [ "$X_PHP_VERSION" = "8.4" ]; then
83-
sed -i.backup "s/php_strtolower(/zend_str_tolower(/" $ROOT/ext/imagick/imagick.c
84-
fi
80+
cd ${__PROJECT__}/pool/ext
81+
if [ ! -f imagick-${IMAGICK_VERSION}.tgz ]; then
82+
curl -fSLo ${EXT_TEMP_CACHE_DIR}/imagick-${IMAGICK_VERSION}.tgz https://pecl.php.net/get/imagick-${IMAGICK_VERSION}.tgz
83+
mv ${EXT_TEMP_CACHE_DIR}/imagick-${IMAGICK_VERSION}.tgz ${__PROJECT__}/pool/ext
8584
fi
85+
mkdir -p ${WORK_TEMP_DIR}/ext/imagick/
86+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/imagick/ -xf imagick-${IMAGICK_VERSION}.tgz
8687

88+
cd ${__PROJECT__}/pool/ext
8789
if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then
88-
test -d /tmp/swoole && rm -rf /tmp/swoole
89-
git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git /tmp/swoole
90-
cd /tmp/swoole
91-
tar -czvf $ROOT/pool/ext/swoole-${SWOOLE_VERSION}.tgz .
92-
cd $ROOT/pool/ext/
90+
test -d ${WORK_TEMP_DIR}/swoole && rm -rf ${WORK_TEMP_DIR}/swoole
91+
git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git ${WORK_TEMP_DIR}/swoole
92+
cd ${WORK_TEMP_DIR}/swoole
93+
tar -czvf ${EXT_TEMP_CACHE_DIR}/swoole-${SWOOLE_VERSION}.tgz .
94+
mv ${EXT_TEMP_CACHE_DIR}/swoole-${SWOOLE_VERSION}.tgz ${__PROJECT__}/pool/ext
95+
cd ${__PROJECT__}/pool/ext
9396
fi
94-
mkdir -p swoole-${SWOOLE_VERSION}
95-
tar --strip-components=1 -C swoole-${SWOOLE_VERSION} -xf swoole-${SWOOLE_VERSION}.tgz
96-
test -d $ROOT/ext/swoole && rm -rf $ROOT/ext/swoole
97-
mv swoole-${SWOOLE_VERSION} $ROOT/ext/swoole
97+
mkdir -p ${WORK_TEMP_DIR}/ext/swoole/
98+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/swoole/ -xf swoole-${SWOOLE_VERSION}.tgz
9899

99-
cd $ROOT
100+
cd ${__PROJECT__}
101+
# clean extension folder
102+
NO_BUILT_IN_EXTENSIONS=$(ls ${WORK_TEMP_DIR}/ext/)
103+
for EXT_NAME in $NO_BUILT_IN_EXTENSIONS; do
104+
echo "EXTENSION_NAME: $EXT_NAME "
105+
test -d ${__PROJECT__}/ext/${EXT_NAME} && rm -rf ${__PROJECT__}/ext/${EXT_NAME}
106+
done
100107

101108
# download php-src source code
102-
109+
cd ${__PROJECT__}/pool/php-tar
103110
if [ ! -f php-${PHP_VERSION}.tar.gz ]; then
104111
curl -fSLo php-${PHP_VERSION}.tar.gz https://github.com/php/php-src/archive/refs/tags/php-${PHP_VERSION}.tar.gz
105112
fi
106-
test -d php-src && rm -rf php-src
107-
mkdir -p php-src
108-
tar --strip-components=1 -C php-src -xf php-${PHP_VERSION}.tar.gz
113+
test -d ${WORK_TEMP_DIR}/php-src && rm -rf ${WORK_TEMP_DIR}/php-src
114+
mkdir -p ${WORK_TEMP_DIR}/php-src
115+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/php-src -xf php-${PHP_VERSION}.tar.gz
109116

110-
cd $ROOT
117+
cd ${__PROJECT__}
118+
# copy extension
119+
# cp -rf var/cygwin-build/ext/* ${WORK_TEMP_DIR}/php-src
120+
cp -rf ${WORK_TEMP_DIR}/ext/* ${WORK_TEMP_DIR}/php-src
111121

112-
if [ ! -d $ROOT/ext/pgsql ]; then
113-
mv $ROOT/php-src/ext/pgsql $ROOT/ext/pgsql
122+
# extension hook
123+
if [ "$X_PHP_VERSION" = "8.4" ]; then
124+
sed -i.backup "s/php_strtolower(/zend_str_tolower(/" ${WORK_TEMP_DIR}/php-src/ext/imagick/imagick.c
114125
fi
115126

116-
cd $ROOT
127+
# php source code hook
128+
cd ${WORK_TEMP_DIR}/php-src
129+
if [ "$X_PHP_VERSION" = "8.4" ] || [ "$X_PHP_VERSION" = "8.3" ] || [ "$X_PHP_VERSION" = "8.2" ] || [ "$X_PHP_VERSION" = "8.1" ]; then
130+
sed -i.backup 's/!defined(__HAIKU__)/!defined(__HAIKU__) \&\& !defined(__CYGWIN__)/' TSRM/TSRM.c
131+
fi
117132

118-
ls -lh $ROOT
119-
ls -lh $ROOT/ext/
120-
cd $ROOT
133+
cd ${__PROJECT__}

sapi/scripts/cygwin/cygwin-config.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@ while [ $# -gt 0 ]; do
3636
done
3737

3838
mkdir -p ${__PROJECT__}/bin/
39-
# cp -f ${__PROJECT__}/php-src/ext/openssl/config0.m4 ${__PROJECT__}/php-src/ext/openssl/config.m4
4039

41-
cp -rf ${__PROJECT__}/ext/* ${__PROJECT__}/php-src/ext/
42-
43-
cd ${__PROJECT__}/php-src/
44-
if [ "$X_PHP_VERSION" = "8.4" ] || [ "$X_PHP_VERSION" = "8.3" ] || [ "$X_PHP_VERSION" = "8.2" ] || [ "$X_PHP_VERSION" = "8.1" ]; then
45-
sed -i.backup 's/!defined(__HAIKU__)/!defined(__HAIKU__) \&\& !defined(__CYGWIN__)/' TSRM/TSRM.c
46-
fi
40+
WORK_TEMP_DIR=${__PROJECT__}/var/cygwin-build/
41+
cd ${WORK_TEMP_DIR}/php-src/
4742

4843
# export CPPFLAGS="-I/usr/include"
4944
# export CFLAGS=""

sapi/scripts/cygwin/cygwin-pack.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
set -exu
4+
__DIR__=$(
5+
cd "$(dirname "$0")"
6+
pwd
7+
)
8+
__PROJECT__=$(
9+
cd ${__DIR__}/../../../
10+
pwd
11+
)
12+
cd ${__PROJECT__}
13+
14+
cd ${__PROJECT__}/
15+
ldd ${__PROJECT__}/bin/php.exe
16+
17+
cd ${__PROJECT__}
18+
APP_VERSION=$(${__PROJECT__}/bin/php.exe -v | head -n 1 | awk '{ print $2 }')
19+
NAME="php-cli-v${APP_VERSION}-cygwin-x64"
20+
21+
test -d /tmp/${NAME} && rm -rf /tmp/${NAME}
22+
mkdir -p /tmp/${NAME}/
23+
mkdir -p /tmp/${NAME}/etc/
24+
mkdir -p /tmp/${NAME}/bin/
25+
26+
cd ${__PROJECT__}/
27+
ldd ${__PROJECT__}/bin/php.exe | grep -v '/cygdrive/' | awk '{print $3}'
28+
ldd ${__PROJECT__}/bin/php.exe | grep -v '/cygdrive/' | awk '{print $3}' | xargs -I {} cp {} /tmp/${NAME}/
29+
30+
ls -lh /tmp/${NAME}/
31+
32+
cp -f ${__PROJECT__}/bin/php.exe /tmp/${NAME}/bin/
33+
# cp -f ${__PROJECT__}/bin/LICENSE /tmp/${NAME}/
34+
# cp -f ${__PROJECT__}/bin/credits.html /tmp/${NAME}/
35+
36+
cp -rL /etc/pki/ /tmp/${NAME}/etc/
37+
38+
cd /tmp/${NAME}/
39+
40+
test -f ${__PROJECT__}/${NAME}.zip && rm -f ${__PROJECT__}/${NAME}.zip
41+
zip -r ${__PROJECT__}/${NAME}.zip .
42+
43+
cd ${__PROJECT__}

0 commit comments

Comments
 (0)