source: trunk/devel/run @ 1025

Last change on this file since 1025 was 1025, checked in by moo, 2 years ago

devel: take command line args first

  • Property svn:executable set to *
File size: 4.3 KB
RevLine 
[977]1#!/bin/bash
2# this script is for developers only
[998]3set -e
[977]4
[998]5. devel/run.cfg
6if [[ ! -z $1 ]]; then
7    type=$1
8fi
9
10case "$type" in
[988]11prep*)
12    exec ./devel/prepare
13    ;;
[1011]14dep*)
15    pwd=$(readlink -f "$(pwd)")
16    builddir=$(readlink -f ../trunk-php5-debug)
17    if [[ -z $builddir ]]; then
18        echo required ../trunk-php5-debug not found
19        return 1
20    fi
[1018]21    find . -iname \*.c | sort | while read -r sourceFile; do
[1011]22        sourceFile=${sourceFile#./}
[1015]23        case "$sourceFile" in
24        includes.c)
25            echo -n "\$(XCACHE_INCLUDES_I) "
26            ;;
27        esac
[1011]28        echo -n "\$(builddir)/${sourceFile%.c}.lo:"
29        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
30            dependency=$(readlink -f "$dependency")
31            case "$dependency" in
32            $pwd/*)
33                dependency=${dependency#$pwd/}
34                ;;
35            $builddir/*)
36                dependency="\$(builddir)/"${dependency#$builddir/}
37                ;;
38            esac
39
40            case "$dependency" in
41            /*) ;;
42            $sourceFile) ;;
43            \$\(builddir\)/xc_processor.h)
44                echo -n " \$(XCACHE_PROC_H)"
45                ;;
46            \$\(builddir\)/xc_processor.c.h)
47                echo -n " \$(XCACHE_PROC_C)"
48                ;;
49            *)
50                if [[ -r $dependency ]]; then
51                    echo -n " \$(srcdir)/$dependency"
52                else
53                    echo "$dependency not found" >&2
54                fi
55            esac
56        done
57        echo
58    done > Makefile.frag.deps
59    exit
60    ;;
[998]61xtest)
62    exec /usr/bin/make -f devel/test.mak
63    ;;
[988]64tags)
65    exec ./devel/prepare tags
66    ;;
67esac
68
[977]69basename=$(basename $(pwd))
70if echo $basename | grep -- - >/dev/null; then :; else
[998]71    svn propget svn:ignore . > .svnignore
72
[977]73    dirs=${dirs:-php5-debug}
74    for dir in $dirs; do
[998]75        mkdir -p ../${basename}-${dir}
[977]76        cd ../${basename}-${dir} || exit
[998]77        lndir ../${basename} > /dev/null
[982]78
[977]79        pwd
80        $0 "$@"
81    done
82    exit
83fi
[995]84
[982]85phpbasename=${basename#*-}
86xcachebasename=${basename%%-*}
[995]87xcachesrcdir=../$xcachebasename
[977]88
[1019]89if [[ $# -gt 0 ]]; then
[977]90    type=$1
91    shift
[1025]92    if [[ $# -gt 0 ]]; then
93        args=("$@")
94    fi
[977]95fi
96
[1002]97if [[ -z ${args[0]} ]]; then
[1025]98    args=(devel.php)
[1002]99fi
100
[988]101case "$type" in
[1013]102phpize)
[998]103    if [[ -r Makefile ]]; then
[1024]104        make xcachesvnclean || true
[998]105    fi
106    ;;
107esac
108
109rm -f php-src
110find -L . -type l | xargs rm -f
111lndir "$xcachesrcdir" >/dev/null
112find . -iname .\*.swp | xargs rm -f
113ln -sf ~/src/php/$phpbasename php-src
114for i in ~/src/php/$phpbasename/sapi/cgi/php{,-cgi}; do
115    if [[ -r $i ]]; then
116        ln -sf "$i" php-cgi
117    fi
118done
119ln -sf ~/src/php/$phpbasename/sapi/cli/php php-cli
120
121case "$type" in
[1013]122phpize)
[982]123    PHPDIRS=${PHPDIRS:-$HOME/test}
124    if [[ ! -x $PHPDIRS/$phpbasename/bin/phpize ]]; then
125        echo $PHPDIRS/$phpbasename/bin/phpize not found
126        exit
127    fi
128    export PATH=$PHPDIRS/$phpbasename/bin:$PATH
129    phpize --clean \
130    && phpize \
[1023]131    && CFLAGS="-g -O0 -Wall -Wno-unused -W -Wshadow -Werror=implicit-function-declaration -std=gnu99" ./configure \
[1003]132        --enable-xcache-cacher \
133        --enable-xcache-optimizer \
134        --enable-xcache-encoder \
135        --enable-xcache-decoder \
136        --enable-xcache-disassembler \
[1006]137        --enable-xcache-coverager \
[1022]138        --enable-xcache-test \
139        --enable-xcache-constant
[982]140    exit
141    ;;
142make)
[980]143    MAKEARGS=("$@")
[982]144    ;;
145esac
[980]146
[1022]147LANG=C /usr/bin/make $MAKEOPTS "${MAKEARGS[@]}" 2>&1 \
148| sed -ur 's#Werror=implicit-function-declaration#We/rror=i/mplicit-function-declaration#' \
149| hi error implicit warn FAIL
[980]150ret=${PIPESTATUS[0]}
151if [[ $ret -ne 0 || $type = make ]]; then
152    exit $ret
153fi
154
[977]155cmd=()
156tracer=()
157case "$basename" in
158*-apache1*)
159    cmd=($HOME/apache1/bin/httpd -X)
160    ;;
161*-apache*)
162    exit 1
163    ;;
164*)
[998]165    cmd=(./php-cgi -q -c devel.ini)
[1024]166    "${cmd[@]}" -v || true
[977]167    ;;
168esac
169
170case "${args[0]}" in
171fcgi)
172    args=(-b 1026)
173    ;;
174esac
175
176case "$type" in
177ltr*)
178    export USE_ZEND_ALLOC=0
179    tracer=(ltrace -s1024 -e malloc,realloc,free,write)
180    ;;
181str*)
182    tracer=(strace -s1024 -T ./php-cgi)
183    ;;
184gdb)
185    #USE_ZEND_ALLOC=0
186    tracer=(gdb --args)
187    ;;
188val*)
189    export USE_ZEND_ALLOC=0
190    tracer=(valgrind --gen-suppressions=all)
191    ;;
192dc)
[1003]193    exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdc.phpr "${args[@]}" | tee decompiled.php
[977]194    ;;
195dop)
[1003]196    exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdop.phpr "${args[@]}"
[977]197    ;;
198retest)
199    exec make xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
200    ;;
201test)
202    case "${args[0]}" in
203    *.phpt)
204        exec make xcachetest TEST_ARGS=-v TESTS="${args[*]}"
205        ;;
206    */)
207        exec make xcachetest TESTS="${args[@]}"
208        ;;
209    *)
210        exec make xcachetest
211        ;;
212    esac
213    ;;
214esac
215
216export XCACHE_SKIP_FCGI_WARNING=1
217echo "${tracer[@]}" "${cmd[@]}" "${args[@]}"
218exec "${tracer[@]}" "${cmd[@]}" "${args[@]}"
Note: See TracBrowser for help on using the repository browser.