summaryrefslogtreecommitdiff
path: root/tests/prepare.sh
blob: 5339fffa00c381be1825997ed25a7eaa0e4be29f (plain)
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
#!/bin/bash
#
#  do not run this script manually.
#  This script is intended to be run from a script test.sh
#  Create a local copy of the directory with the extension for run tests without installation
#
#  @author valmat <ufabiz@gmail.com>
#

# Local directory in which to copy the links to all installed extensions
EXTDLOC=ext_dir
mkdir -p "./$EXTDLOC"

SO=extfortest.so

# to check whether specified the extension name as parameter
if [ $1 ]
then
    SO=$1
fi

# a directory of extensions already installed in the operating system
EXTDIR=$(php-config --extension-dir)

# To copy references for all extensions to the local directory
for LIBFILE in `find $EXTDIR -type f -or -type l -name "*.so"`; do

    BN=$(basename $LIBFILE)
    NF="$PWD/$EXTDLOC/$BN"
    
    # if still no exist
    if [ ! -L $NF ];
    then
        if [ -L $LIBFILE ];
        then
            cp --no-dereference $LIBFILE $NF
        else
            ln -s $LIBFILE $NF
        fi
    else
        :
    fi;
done

# current extention
if [ ! -L "$PWD/$EXTDLOC/$SO" ]
then
    ln -s "$PWD/cpp/$SO" "$PWD/$EXTDLOC/$SO"
fi