Browse Source

devel: smarter args for run

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1128 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 9 years ago
parent
commit
8bc2ff8553
  1. 131
      devel/run

131
devel/run

@ -123,26 +123,37 @@ if [[ $# -eq 0 ]]; then
set -- "$action" "${args[@]}"
fi
if [[ $# -gt 0 ]]; then
action=$1
shift
fi
# devel actions
case "$action" in
prep*) prep "$@"; exit;;
tags) rm -f tags; prep tags "$@"; exit;;
case "$1" in
prep*) shift; prep "$@"; exit;;
tags) shift; rm -f tags; prep tags "$@"; exit;;
po2php) po2php; exit;;
mergepo) mergepo; exit;;
dep*) updatedeps; exit;;
xtest) xtest; exit;;
stopfpm) stopfpm devel.pid; exit;;
esac
case "$1" in
fpm) stopfpm devel.pid;;
stopfpm) stopfpm devel.pid; exit;;
basename=$(basename $(pwd))
case "$basename" in
*-*)
# in build dir, starts from src dir
dirs="$basename"
xcachesrcdir=../${basename%%-*}
cd $xcachesrcdir
;;
*)
# in src dir
dirs=${dirs:-php5-debug-zts}
xcachesrcdir=../$basename
;;
esac
touch devel.pid
svn propget svn:ignore . > .svnignore
# ==========================
do_phpize() { # {{{1
if [[ ! -x $PHPSDIR/$phpbasename/bin/phpize ]]; then
hiecho $PHPSDIR/$phpbasename/bin/phpize not found
@ -182,12 +193,16 @@ do_make() { # {{{1
exit $ret
fi
}
cleanfpm() { # {{{1
echo
stopfpm $pidfile
}
# }}}
run() {
pidfile=$xcachesrcdir/devel.pid
# prepare {{{1
case "$action" in
case "$1" in
phpize)
if [[ -r Makefile ]]; then
$MAKE xcachesvnclean || true
@ -208,7 +223,7 @@ run() {
ln -snf ~/src/php/$phpbasename/sapi/cli/php php-cli
ln -snf ~/src/php/$phpbasename/sapi/fpm/php-fpm php-fpm
case "$action" in
case "$1" in
phpize) do_phpize; exit;;
make) do_make "$@"; exit;;
*) do_make;;
@ -223,20 +238,24 @@ run() {
tracer=()
# run utils {{{1
case "$action" in
case "$1" in
dc)
shift
./php-cli -c devel.ini ./bin/phpdc.phpr $@ | tee decompiled.php
return
;;
dop)
shift
./php-cli -c devel.ini ./bin/phpdop.phpr $@
return
;;
retest)
shift
$MAKE xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
return
;;
test)
shift
case "$1" in
*.phpt)
$MAKE xcachetest TEST_ARGS=-v TESTS="$*"
@ -254,21 +273,47 @@ run() {
;;
esac
# }}}
# pick tracer {{{1
case "$1" in
ltr*)
shift
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
shift
tracer=(strace -s1024 -T)
;;
gdb)
shift
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
shift
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
esac
# pick sapi {{{1
case "$basename" in
*-apache1*)
cmd=($HOME/apache1/bin/httpd -X)
;;
*-apache*)
echo "Don't know how to run apache"
exit 1
;;
*)
case "$1" in
fcgi)
shift
cmd=(./php-cgi -q -c devel.ini)
set -- -b 1026
;;
fpm)
shift
cmd=(./php-fpm -c devel.ini -y devel.fpm -g $(readlink -f $pidfile))
set --
;;
@ -279,41 +324,19 @@ run() {
"${cmd[@]}" -v || true
esac
# }}}
# pick action {{{1
case "$action" in
ltr*)
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
tracer=(strace -s1024 -T)
;;
gdb)
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
esac
# run {{{1
commandLine=("${tracer[@]}" "${cmd[@]}" "$@")
case "${cmd[0]}" in
*php-fpm*)
stopfpm
hiecho Starting fpm ...
"${commandLine[@]}"
# echo -n "Ctrl-C to stop"
cleanfpm() {
echo
stopfpm $pidfile
}
# trap stopfpm SIGINT SIGTERM exit
# cat > /dev/null || true
# stopfpm
echo -n "Ctrl-C to stop"
trap cleanfpm SIGINT SIGTERM exit
cat > /dev/null || true
stopfpm
;;
*)
"${commandLine[@]}"
@ -322,23 +345,11 @@ run() {
# }}}
}
# process each $dirs
basename=$(basename $(pwd))
if echo $basename | grep -- - >/dev/null; then
phpbasename=${basename#*-}
xcachesrcdir=../${basename%%-*}
run "$@"
else
svn propget svn:ignore . > .svnignore
dirs=${dirs:-php5-debug-zts}
xcachesrcdir=../$basename
for phpbasename in $dirs; do
mkdir -p ../${basename}-${phpbasename}
cd ../${basename}-${phpbasename} || exit
lndir ${xcachesrcdir} >/dev/null || true
for phpbasename in "${dirs[@]}"; do
mkdir -p ../${basename}-${phpbasename}
cd ../${basename}-${phpbasename} || exit
lndir ${xcachesrcdir} >/dev/null || true
pwd
run "$@"
done
fi
pwd
run "$@"
done

Loading…
Cancel
Save