2012-07-17 08:35:45 +00:00
#!/bin/bash
# this script is for developers only
2012-08-04 02:19:15 +00:00
stopfpm() {
if [[ -f $pidfile ]]; then
pid=`cat $pidfile 2>/dev/null || true`
if [[ $pid -gt 0 ]]; then
echo
echo Stopping fpm $pid @ $pidfile
kill $pid || true
fi
fi
}
2012-07-19 03:57:56 +00:00
set -e
2012-07-31 16:21:50 +00:00
MAKE=/usr/bin/make
2012-07-17 08:35:45 +00:00
2012-07-19 03:57:56 +00:00
. devel/run.cfg
2012-08-01 04:26:43 +00:00
if [[ $# -gt 0 ]]; then
2012-08-04 02:32:05 +00:00
action=$1
2012-08-01 04:26:43 +00:00
shift
if [[ $# -gt 0 ]]; then
args=("$@")
2012-08-04 02:32:05 +00:00
elif [[ $action = "make" ]]; then
2012-08-01 17:55:06 +00:00
args=()
2012-08-01 04:26:43 +00:00
fi
fi
2012-08-04 02:32:05 +00:00
case "$action" in
2012-07-18 06:38:45 +00:00
prep*)
2012-08-01 04:26:43 +00:00
exec $MAKE -f devel/prepare.mak "${args[@]}"
2012-07-31 16:21:50 +00:00
;;
2012-08-01 09:11:21 +00:00
po2php)
2012-08-04 02:32:05 +00:00
./run mergepo "${args[0]}"
2012-08-01 08:00:21 +00:00
find htdocs -iname '*.po' | while read -r i; do
2012-08-01 08:12:14 +00:00
phpfile=${i/.po/.php}
2012-08-01 09:11:21 +00:00
devel/po2php.awk < $i > $phpfile.tmp
2012-08-01 08:12:14 +00:00
mv $phpfile.tmp $phpfile
2012-08-01 08:00:21 +00:00
done
exit
;;
mergepo)
2012-08-04 02:32:05 +00:00
./run prep "${args[0]}"
2012-08-01 08:00:21 +00:00
find htdocs -iname '*.po' | while read -r i; do
if [[ -f $i-merged ]]; then
mv $i-merged $i
fi
done
exit
;;
2012-07-31 16:21:50 +00:00
tags)
rm -f tags
2012-08-01 04:26:43 +00:00
exec $MAKE -f devel/prepare.mak tags "${args[@]}"
2012-07-18 06:38:45 +00:00
;;
2012-07-20 03:26:55 +00:00
dep*)
pwd=$(readlink -f "$(pwd)")
2012-07-31 16:25:21 +00:00
builddir=$(readlink -f ../trunk-php5-debug-zts)
2012-07-20 03:26:55 +00:00
if [[ -z $builddir ]]; then
2012-07-31 16:25:21 +00:00
echo required ../trunk-php5-debug-zts not found
2012-07-20 03:26:55 +00:00
return 1
fi
2012-07-20 16:21:44 +00:00
find . -iname \*.c | sort | while read -r sourceFile; do
2012-07-20 03:26:55 +00:00
sourceFile=${sourceFile#./}
2012-07-20 06:16:51 +00:00
case "$sourceFile" in
includes.c)
echo -n "\$(XCACHE_INCLUDES_I) "
;;
esac
2012-07-20 03:26:55 +00:00
echo -n "\$(builddir)/${sourceFile%.c}.lo:"
2012-07-31 16:25:21 +00:00
for dependency in $(gcc -M $sourceFile -I$HOME/test/php5-debug-zts/include/php/{,main,Zend,TSRM} -I. -I${builddir} -MG | sed 's#.*:##g' | sed 's#\\##g'); do
2012-07-20 03:26:55 +00:00
dependency=$(readlink -f "$dependency")
case "$dependency" in
$pwd/*)
dependency=${dependency#$pwd/}
;;
$builddir/*)
dependency="\$(builddir)/"${dependency#$builddir/}
;;
esac
case "$dependency" in
/*) ;;
$sourceFile) ;;
\$\(builddir\)/xc_processor.h)
echo -n " \$(XCACHE_PROC_H)"
;;
\$\(builddir\)/xc_processor.c.h)
echo -n " \$(XCACHE_PROC_C)"
;;
*)
if [[ -r $dependency ]]; then
echo -n " \$(srcdir)/$dependency"
else
echo "$dependency not found" >&2
fi
esac
done
echo
done > Makefile.frag.deps
exit
;;
2012-07-19 03:57:56 +00:00
xtest)
2012-07-31 16:21:50 +00:00
exec $MAKE -f devel/test.mak
2012-07-18 06:38:45 +00:00
;;
esac
2012-08-04 02:19:15 +00:00
case "${args[0]}" in
fpm)
pidfile=devel.pid
stopfpm
;;
stopfpm)
pidfile=devel.pid
stopfpm
exit
;;
esac
2012-07-17 08:35:45 +00:00
basename=$(basename $(pwd))
if echo $basename | grep -- - >/dev/null; then :; else
2012-07-19 03:57:56 +00:00
svn propget svn:ignore . > .svnignore
2012-07-17 08:35:45 +00:00
2012-07-31 16:25:21 +00:00
dirs=${dirs:-php5-debug-zts}
2012-07-17 08:35:45 +00:00
for dir in $dirs; do
2012-07-19 03:57:56 +00:00
mkdir -p ../${basename}-${dir}
2012-07-17 08:35:45 +00:00
cd ../${basename}-${dir} || exit
2012-08-01 08:12:14 +00:00
lndir ../${basename} >/dev/null || true
2012-07-17 08:35:45 +00:00
pwd
2012-08-04 02:32:05 +00:00
$0 "$action" "${args[@]}"
2012-07-17 08:35:45 +00:00
done
exit
fi
2012-07-19 02:27:53 +00:00
2012-07-17 08:35:45 +00:00
phpbasename=${basename#*-}
xcachebasename=${basename%%-*}
2012-07-19 02:27:53 +00:00
xcachesrcdir=../$xcachebasename
2012-08-04 02:19:15 +00:00
pidfile=../$xcachebasename/devel.pid
2012-07-19 02:27:53 +00:00
2012-08-04 02:32:05 +00:00
case "$action" in
2012-07-20 06:09:26 +00:00
phpize)
2012-07-19 03:57:56 +00:00
if [[ -r Makefile ]]; then
2012-07-31 16:21:50 +00:00
$MAKE xcachesvnclean || true
2012-07-19 03:57:56 +00:00
fi
;;
esac
rm -f php-src
2012-08-04 02:32:05 +00:00
find -L . -action l | xargs rm -fv
2012-08-01 08:12:14 +00:00
lndir "$xcachesrcdir" >/dev/null || true
2012-07-19 03:57:56 +00:00
find . -iname .\*.swp | xargs rm -f
ln -sf ~/src/php/$phpbasename php-src
for i in ~/src/php/$phpbasename/sapi/cgi/php{,-cgi}; do
if [[ -r $i ]]; then
ln -sf "$i" php-cgi
fi
done
ln -sf ~/src/php/$phpbasename/sapi/cli/php php-cli
2012-07-25 13:34:12 +00:00
ln -sf ~/src/php/$phpbasename/sapi/fpm/php-fpm php-fpm
2012-07-19 03:57:56 +00:00
2012-08-04 02:32:05 +00:00
case "$action" in
2012-07-20 06:09:26 +00:00
phpize)
2012-07-17 08:35:45 +00:00
PHPDIRS=${PHPDIRS:-$HOME/test}
if [[ ! -x $PHPDIRS/$phpbasename/bin/phpize ]]; then
echo $PHPDIRS/$phpbasename/bin/phpize not found
exit
fi
export PATH=$PHPDIRS/$phpbasename/bin:$PATH
phpize --clean \
&& phpize \
2012-08-01 17:59:34 +00:00
&& CFLAGS="-g -O0 -pedantic-errors -Wno-variadic-macros -Wno-long-long -Wall -Wno-unused-parameter -Wno-unused-function -W -Wshadow -Werror=implicit-function-declaration -std=c89 -D_GNU_SOURCE -D_POSIX_SOURCE -Dinline=" ./configure \
2012-07-19 06:51:33 +00:00
--enable-xcache-cacher \
--enable-xcache-optimizer \
--enable-xcache-encoder \
--enable-xcache-decoder \
--enable-xcache-disassembler \
2012-07-19 15:11:16 +00:00
--enable-xcache-coverager \
2012-07-22 03:28:21 +00:00
--enable-xcache-test \
--enable-xcache-constant
2012-07-17 08:35:45 +00:00
exit
;;
make)
MAKEARGS=("$@")
;;
esac
2012-07-31 16:21:50 +00:00
LANG=C $MAKE $MAKEOPTS "${MAKEARGS[@]}" 2>&1 \
2012-07-27 15:10:17 +00:00
| sed -ur \
-e 's#Werror=implicit-function-declaration#We/rror=i/mplicit-function-declaration#' \
2012-08-01 17:59:34 +00:00
-e 's#-pedantic-errors#-pedantic-e/rrors#' \
2012-07-27 15:10:17 +00:00
-e 's#\./xc_processor\.h#'$PWD'/xc_processor.h#' \
-e 's#\./xc_processor\.c\.h#'$PWD'/xc_processor.c.h#' \
2012-07-22 03:28:21 +00:00
| hi error implicit warn FAIL
2012-07-17 08:35:45 +00:00
ret=${PIPESTATUS[0]}
2012-08-04 02:32:05 +00:00
if [[ $ret -ne 0 || $action = make ]]; then
2012-07-17 08:35:45 +00:00
exit $ret
fi
2012-08-01 04:29:42 +00:00
if [[ -z ${args[0]} ]]; then
args=(devel.php)
fi
2012-07-17 08:35:45 +00:00
cmd=()
tracer=()
case "$basename" in
*-apache1*)
cmd=($HOME/apache1/bin/httpd -X)
;;
*-apache*)
exit 1
;;
*)
2012-07-25 13:34:12 +00:00
case "${args[0]}" in
fcgi)
cmd=(./php-cgi -q -c devel.ini)
args=(-b 1026)
;;
fpm)
2012-08-04 02:19:15 +00:00
echo Starting fpm ...
cmd=(./php-fpm -c devel.ini -y devel.fpm -g $(readlink -f $pidfile))
args=()
2012-07-25 13:34:12 +00:00
;;
*)
cmd=(./php-cgi -q -c devel.ini)
;;
esac
2012-07-17 08:35:45 +00:00
2012-07-25 13:34:12 +00:00
"${cmd[@]}" -v || true
2012-07-17 08:35:45 +00:00
esac
2012-08-04 02:32:05 +00:00
case "$action" in
2012-07-17 08:35:45 +00:00
ltr*)
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
2012-07-22 07:28:32 +00:00
tracer=(strace -s1024 -T)
2012-07-17 08:35:45 +00:00
;;
gdb)
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
dc)
2012-07-27 07:17:42 +00:00
exec ./php-cli -c devel.ini ./bin/phpdc.phpr "${args[@]}" | tee decompiled.php
2012-07-17 08:35:45 +00:00
;;
dop)
2012-07-27 07:17:42 +00:00
exec ./php-cli -c devel.ini ./bin/phpdop.phpr "${args[@]}"
2012-07-17 08:35:45 +00:00
;;
retest)
2012-07-31 16:21:50 +00:00
exec $MAKE xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
2012-07-17 08:35:45 +00:00
;;
test)
case "${args[0]}" in
*.phpt)
2012-07-31 16:21:50 +00:00
exec $MAKE xcachetest TEST_ARGS=-v TESTS="${args[*]}"
2012-07-17 08:35:45 +00:00
;;
*/)
2012-07-31 16:21:50 +00:00
exec $MAKE xcachetest TESTS="${args[@]}"
2012-07-17 08:35:45 +00:00
;;
*)
2012-07-31 16:21:50 +00:00
exec $MAKE xcachetest
2012-07-17 08:35:45 +00:00
;;
esac
;;
esac
export XCACHE_SKIP_FCGI_WARNING=1
2012-08-04 02:19:15 +00:00
commandLine=("${tracer[@]}" "${cmd[@]}" "${args[@]}")
case "${cmd[0]}" in
*php-fpm*)
stopfpm
"${commandLine[@]}"
echo -n "Ctrl-C to stop"
trap stopfpm SIGINT SIGTERM
cat > /dev/null || true
;;
*)
exec "${commandLine[@]}"
;;
esac