XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
4.1 KiB

#!/bin/bash
# this script is for developers only
set -e
. devel/run.cfg
if [[ ! -z $1 ]]; then
type=$1
fi
case "$type" in
prep*)
exec ./devel/prepare
;;
dep*)
pwd=$(readlink -f "$(pwd)")
builddir=$(readlink -f ../trunk-php5-debug)
if [[ -z $builddir ]]; then
echo required ../trunk-php5-debug not found
return 1
fi
find . -iname \*.c | while read -r sourceFile; do
sourceFile=${sourceFile#./}
case "$sourceFile" in
includes.c)
echo -n "\$(XCACHE_INCLUDES_I) "
;;
esac
echo -n "\$(builddir)/${sourceFile%.c}.lo:"
for dependency in $(gcc -M $sourceFile -I$HOME/test/php5-debug/include/php/{,main,Zend,TSRM} -I. -I${builddir} -MG | sed 's#.*:##g' | sed 's#\\##g'); do
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
;;
xtest)
exec /usr/bin/make -f devel/test.mak
;;
tags)
exec ./devel/prepare tags
;;
esac
basename=$(basename $(pwd))
if echo $basename | grep -- - >/dev/null; then :; else
svn propget svn:ignore . > .svnignore
dirs=${dirs:-php5-debug}
for dir in $dirs; do
mkdir -p ../${basename}-${dir}
cd ../${basename}-${dir} || exit
lndir ../${basename} > /dev/null
pwd
$0 "$@"
done
exit
fi
phpbasename=${basename#*-}
xcachebasename=${basename%%-*}
xcachesrcdir=../$xcachebasename
if [[ ! -z $1 ]]; then
type=$1
shift
args=("$@")
fi
if [[ -z ${args[0]} ]]; then
args=(devel.php)
fi
case "$type" in
phpize)
if [[ -r Makefile ]]; then
if make xcachesvnclean; then
:
fi
fi
;;
esac
rm -f php-src
find -L . -type l | xargs rm -f
lndir "$xcachesrcdir" >/dev/null
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
case "$type" in
phpize)
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 \
&& CFLAGS="-Wall -Wno-unused -W -Wshadow -std=gnu99" ./configure \
--enable-xcache-cacher \
--enable-xcache-optimizer \
--enable-xcache-encoder \
--enable-xcache-decoder \
--enable-xcache-disassembler \
--enable-xcache-coverager \
--enable-xcache-test --enable-xcache-constant
exit
;;
make)
MAKEARGS=("$@")
;;
esac
LANG=C /usr/bin/make $MAKEOPTS "${MAKEARGS[@]}" 2>&1 | hi error implicit warn FAIL
ret=${PIPESTATUS[0]}
if [[ $ret -ne 0 || $type = make ]]; then
exit $ret
fi
cmd=()
tracer=()
case "$basename" in
*-apache1*)
cmd=($HOME/apache1/bin/httpd -X)
;;
*-apache*)
exit 1
;;
*)
cmd=(./php-cgi -q -c devel.ini)
"${cmd[@]}" -v
;;
esac
case "${args[0]}" in
fcgi)
args=(-b 1026)
shift
;;
esac
case "$type" in
ltr*)
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
tracer=(strace -s1024 -T ./php-cgi)
;;
gdb)
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
dc)
exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdc.phpr "${args[@]}" | tee decompiled.php
;;
dop)
exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdop.phpr "${args[@]}"
;;
retest)
exec make xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
;;
test)
case "${args[0]}" in
*.phpt)
exec make xcachetest TEST_ARGS=-v TESTS="${args[*]}"
;;
*/)
exec make xcachetest TESTS="${args[@]}"
;;
*)
exec make xcachetest
;;
esac
;;
esac
export XCACHE_SKIP_FCGI_WARNING=1
echo "${tracer[@]}" "${cmd[@]}" "${args[@]}"
exec "${tracer[@]}" "${cmd[@]}" "${args[@]}"