-
Notifications
You must be signed in to change notification settings - Fork 2
/
manage.sh
executable file
·152 lines (127 loc) · 3.91 KB
/
manage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
source /usr/share/annyung-release/functions.d/bash/functions
setAnsi
tcolor="${bblack}${bgwhite}"
errmsg () {
echo "$*" 1>&2
}
usage () {
echo "${bcyan}Usage:${normal} $0 [clean|pack|test [php-version]]"
exit 1
}
mod_name="$( grep "^ZEND_GET_MODULE" *.c | grep -Po '(?<=\()[a-z]+(?=\))' )"
opts=$(getopt -u -o h -l help -- "$@")
[ $? != 0 ] && usage
set -- ${opts}
for i
do
case "$i" in
-h|--help)
usage
shift
;;
--)
shift
break
;;
esac
done
mode="${1}"
case "${mode}" in
clean)
cat <<-EOL
${bwhite}[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 compile
rm -f config.h* config.nice configure* config.sub config.guess
rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
rm -f package.xml
find ./tests ! -name '*.phpt' -a ! -name '*.txt' -a -type f
rm -f ${mod_name}_arginfo.h && git checkout -- ${mod_name}_arginfo.h
${normal}----->
EOL
[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 compile tags
rm -f config.h* config.nice configure* config.sub config.guess
rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
rm -f tests/*.{diff,exp,log,out,php,sh,mem}
rm -f ${mod_name}_arginfo.h && git checkout -- ${mod_name}_arginfo.h
;;
pack)
cp -af package.xml.tmpl package.xml
list=$(grep "md5sum" ./package.xml | sed -r 's/.*"@|@".*//g')
for i in ${list}
do
md5s=$(md5sum "$i" | awk '{print $1}')
perl -pi -e "s!\@${i}\@!${md5s}!g" ./package.xml
done
curdate=$(date +'%Y-%m-%d')
curtime=$(date +'%H:%M:%S')
perl -pi -e "s!\@curdate\@!${curdate}!g" ./package.xml
perl -pi -e "s!\@curtime\@!${curtime}!g" ./package.xml
pecl package
rm -f package.xml
;;
test)
PHPBIN=/opt/php-qa/php${2}/bin/php
PHPIZE=/opt/php-qa/php${2}/bin/phpize
PHPCONFIG=/opt/php-qa/php${2}/bin/php-config
PHP_OPT="-n"
if [[ $# == 2 ]]; then
./manage.sh clean
echo "${PHPIZE} && ./configure"
${PHPIZE} && ./configure && make -j8 || exit 0
fi
if (( $2 > 71 )); then
PHP_OPT+=" -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
else
PHP_OPT+=" -d 'track_errors=1' -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
fi
if [[ -f tests/${3}.php ]]; then
cat <<-EOL
${bgreen}------------------------------------------------------------------------
Sample code execution:
${bcyan}${PHPBIN} ${PHP_OPT} test/${3}.php
${bgreen}------------------------------------------------------------------------${normal}
EOL
${PHPBIN} ${PHP_OPT} test/${3}.php
exit $?
elif [[ -f ${3} ]]; then
cat <<-EOL
${bgreen}------------------------------------------------------------------------
Sample code execution:
${bcyan}${PHPBIN} ${PHP_OPT} ${3}
${bgreen}------------------------------------------------------------------------${normal}
EOL
eval "${PHPBIN} ${PHP_OPT} ${3}"
exit $?
fi
cat <<-EOL
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${tcolor}** MAKE test:: ${normal}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${bcyan}make test PHP_EXECUTABLE=${PHPBIN}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${normal}
EOL
make test PHP_EXECUTABLE=${PHPBIN} <<< n
;;
stub)
# stub tagging
# /** @generate-function-entries **/ build with function entryies
# /** @generate-legacy-arginfo **/ build with legacy style
if [[ ! -f build/gen_stub.php ]]; then
cat <<-EOL
ERROR: execute before PHP 8 build environment or before execute phpize
EOL
exit 1
fi
phpcmd="/usr/bin/php80"
perl -pi -e 's/ext_functions/${mod_name}_functions/g' build/gen_stub.php
${phpcmd} build/gen_stub.php -f *.stub.php
;;
*)
errmsg "Unsupport mode '${1}'"
exit 1
esac
exit 0